6.7.0 - Alpha6 - 新增 structuredClone 全局方法
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
"zip 模块, 用于文件压缩与解压缩操作 (Ref to [Auto.js Pro](https://g.pro.autojs.org/)) (参阅 项目文档 > [Zip](https://docs.autojs6.com/#/zip))",
|
||||
"mediainfo 模块, 用于查看媒体文件的详细信息 (参阅 项目文档 > [媒体信息](https://docs.autojs6.com/#/mediainfo))",
|
||||
"UiObject#isShifted 方法, 用于检测控件位置变化",
|
||||
"structuredClone 全局方法, 用于深拷贝 JavaScript 对象 (参阅 [MDN](https://developer.mozilla.org/zh-CN/docs/Web/API/Window/structuredClone))",
|
||||
"设置页面支持应用启动器图标设置选项 _[`issue #405`](http://issues.autojs6.com/405)_",
|
||||
"JS 脚本工具 (run-scrapers.mjs) 用于自动更新 Gradle 构建脚本锚点数据/README 通用数据/README 模板数据"
|
||||
],
|
||||
|
||||
1
app/src/main/assets/modules/structured-clone.min.js
vendored
Normal file
1
app/src/main/assets/modules/structured-clone.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports=function(e){function h(e){var t;return"function"==typeof e.slice?e.slice(0):(t=new ArrayBuffer(e.byteLength),e=new Uint8Array(e),new Uint8Array(t).set(e),t)}function m(t,n){if(null===(s=t)||"object"!=typeof s&&"function"!=typeof s)return t;if(n.has(t))return n.get(t);if(Array.isArray(t)){var r=new Array(t.length);n.set(t,r);for(let e=0;e<t.length;e++)e in t&&(r[e]=m(t[e],n));return r}var e,a,c,s=Object.prototype.toString.call(t).slice(8,-1);switch(s){case"Date":return new Date(t.getTime());case"RegExp":var o=function(e){var t=(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.dotAll?"s":"")+(e.unicode?"u":"")+(e.sticky?"y":""),t=new RegExp(e.source,t);try{t.lastIndex=e.lastIndex}catch(e){}return t}(t);return n.set(t,o),o;case"Map":{o=t;var u=n;const p=new Map;return u.set(o,p),o.forEach(function(e,t){p.set(m(t,u),m(e,u))}),p;return}case"Set":{var i=t;var f=n;const A=new Set;return f.set(i,A),i.forEach(function(e){A.add(m(e,f))}),A;return}case"ArrayBuffer":i=h(t);return n.set(t,i),i;case"DataView":return a=n,c=h((e=t).buffer),c=new DataView(c,e.byteOffset,e.byteLength),a.set(e,c),c;case"Uint8Array":case"Uint8ClampedArray":case"Uint16Array":case"Uint32Array":case"Int8Array":case"Int16Array":case"Int32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return a=n,c=new(e=t).constructor(h(e.buffer),e.byteOffset,e.length),a.set(e,c),c;case"Error":{var y=t;var l=n;var g=y.constructor;let r;try{r=new g(y.message)}catch(e){r=new Error(String(y&&y.message))}if(l.set(y,r),"name"in y)try{r.name=y.name}catch(e){}if("stack"in y)try{r.stack=y.stack}catch(e){}if("cause"in y)try{r.cause=m(y.cause,l)}catch(e){}return Reflect.ownKeys(y).forEach(function(e){if("message"!==e&&"name"!==e&&"stack"!==e&&"cause"!==e){var t=Object.getOwnPropertyDescriptor(y,e);if(t){"value"in t&&(t.value=m(t.value,l));try{Object.defineProperty(r,e,t)}catch(e){}}}}),r;return}case"Boolean":case"Number":case"String":case"BigInt":case"Symbol":return Object(t.valueOf());default:if("function"==typeof t)throw new Error("DataCloneError: Cannot clone function");{var v=t;var w=n;g=Object.getPrototypeOf(v);const b=Object.create(g);return w.set(v,b),Reflect.ownKeys(v).forEach(function(e){var t=Object.getOwnPropertyDescriptor(v,e);t&&("value"in t&&(t.value=m(t.value,w)),Object.defineProperty(b,e,t))}),b;return}}}"function"!=typeof e.structuredClone&&(e.structuredClone=function(e){return m(e,new WeakMap)})};
|
||||
@@ -433,6 +433,8 @@ class ScriptRuntime private constructor(builder: Builder) {
|
||||
|
||||
private val js_array_observe_min by lazy { rhinoRequire("array-observe.min") as BaseFunction }
|
||||
|
||||
private val js_structured_clone by lazy { rhinoRequire("structured-clone.min") as BaseFunction }
|
||||
|
||||
private val js_mod_continuation by lazy { rhinoRequire("continuation") as ScriptableObject }
|
||||
|
||||
private val js_mod_internal by lazy { rhinoRequire("internal") as ScriptableObject }
|
||||
@@ -491,6 +493,8 @@ class ScriptRuntime private constructor(builder: Builder) {
|
||||
callFunction(this, js_object_observe_lite_min, topLevelScope, topLevelScope, arrayOf(topLevelScope))
|
||||
callFunction(this, js_array_observe_min, topLevelScope, topLevelScope, arrayOf(topLevelScope))
|
||||
|
||||
callFunction(this, js_structured_clone, topLevelScope, topLevelScope, arrayOf(topLevelScope))
|
||||
|
||||
if (Pref.isExtendingJsBuildInObjectsEnabled) Jsox.extendAllRhinoWithRuntime(this)
|
||||
|
||||
// @Hint by Stardust (https://github.com/hyb1996) on Feb 27, 2018
|
||||
|
||||
Reference in New Issue
Block a user