quickjs-emscripten-sync 1.8.4 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +231 -150
- package/dist/index.d.ts +50 -7
- package/dist/quickjs-emscripten-sync.js +652 -387
- package/dist/quickjs-emscripten-sync.umd.cjs +17 -8
- package/package.json +5 -2
- package/src/index.test.ts +250 -5
- package/src/index.ts +126 -9
- package/src/jsonleak.test.ts +178 -0
- package/src/marshal/custom.ts +16 -2
- package/src/marshal/function.ts +6 -2
- package/src/marshal/hostref.ts +18 -0
- package/src/marshal/index.ts +25 -2
- package/src/marshal/mapset.ts +37 -0
- package/src/marshal/object.ts +4 -1
- package/src/marshal/primitive.ts +2 -11
- package/src/marshal/properties.ts +19 -6
- package/src/unmarshal/custom.ts +35 -4
- package/src/unmarshal/function.ts +2 -2
- package/src/unmarshal/hostref.ts +21 -0
- package/src/unmarshal/index.ts +21 -1
- package/src/unmarshal/mapset.ts +43 -0
- package/src/unmarshal/object.ts +16 -20
- package/src/unmarshal/primitive.ts +6 -17
- package/src/unmarshal/properties.ts +7 -6
- package/src/vmmap.ts +59 -69
- package/src/vmutil.ts +97 -12
- package/src/wrapper.ts +97 -30
|
@@ -1,23 +1,48 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var z = Object.defineProperty;
|
|
2
|
+
var B = Object.getOwnPropertySymbols;
|
|
3
|
+
var $ = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var M = (n, e, t) => e in n ? z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, F = (n, e) => {
|
|
5
|
+
for (var t in e || (e = {}))
|
|
6
|
+
$.call(e, t) && M(n, t, e[t]);
|
|
7
|
+
if (B)
|
|
8
|
+
for (var t of B(e))
|
|
9
|
+
L.call(e, t) && M(n, t, e[t]);
|
|
10
|
+
return n;
|
|
11
|
+
};
|
|
12
|
+
var l = (n, e, t) => M(n, typeof e != "symbol" ? e + "" : e, t);
|
|
13
|
+
var A = (n, e, t) => new Promise((r, s) => {
|
|
14
|
+
var i = (a) => {
|
|
15
|
+
try {
|
|
16
|
+
f(t.next(a));
|
|
17
|
+
} catch (u) {
|
|
18
|
+
s(u);
|
|
19
|
+
}
|
|
20
|
+
}, o = (a) => {
|
|
21
|
+
try {
|
|
22
|
+
f(t.throw(a));
|
|
23
|
+
} catch (u) {
|
|
24
|
+
s(u);
|
|
25
|
+
}
|
|
26
|
+
}, f = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(i, o);
|
|
27
|
+
f((t = t.apply(n, e)).next());
|
|
28
|
+
});
|
|
29
|
+
const K = (n) => {
|
|
30
|
+
const e = new q(n);
|
|
6
31
|
return new Proxy(n, {
|
|
7
32
|
get(t, r, s) {
|
|
8
33
|
return r in e ? e[r] : Reflect.get(t, r, s);
|
|
9
34
|
}
|
|
10
35
|
});
|
|
11
36
|
};
|
|
12
|
-
class
|
|
37
|
+
class q {
|
|
13
38
|
constructor(e) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
39
|
+
l(this, "context");
|
|
40
|
+
l(this, "fn");
|
|
41
|
+
l(this, "fnGenerator");
|
|
42
|
+
l(this, "fnCounter", Number.MIN_SAFE_INTEGER);
|
|
43
|
+
l(this, "fnMap", /* @__PURE__ */ new Map());
|
|
19
44
|
/** Similar to the original newFunction, but no matter how many new functions are generated, newFunction is called only once. */
|
|
20
|
-
|
|
45
|
+
l(this, "newFunction", (e, t) => {
|
|
21
46
|
this.fnCounter++;
|
|
22
47
|
const r = this.fnCounter;
|
|
23
48
|
return this.fnMap.set(r, t), this.context.unwrapResult(
|
|
@@ -34,9 +59,9 @@ class U {
|
|
|
34
59
|
this.context = e;
|
|
35
60
|
const t = this.fnMap;
|
|
36
61
|
this.fn = this.context.newFunction("", function(r, ...s) {
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
-
return
|
|
62
|
+
const i = e.getNumber(r), o = t.get(i);
|
|
63
|
+
if (!o) throw new Error("function is not registered");
|
|
64
|
+
return o.call(this, ...s);
|
|
40
65
|
}), this.fnGenerator = e.unwrapResult(
|
|
41
66
|
e.evalCode(`((name, length, id, f) => {
|
|
42
67
|
const fn = function(...args) {
|
|
@@ -52,7 +77,7 @@ class U {
|
|
|
52
77
|
this.fnGenerator.dispose(), this.fn.dispose();
|
|
53
78
|
}
|
|
54
79
|
}
|
|
55
|
-
const
|
|
80
|
+
const Q = [
|
|
56
81
|
// basic objects
|
|
57
82
|
[Symbol, "Symbol"],
|
|
58
83
|
[Symbol.prototype, "Symbol.prototype"],
|
|
@@ -85,32 +110,72 @@ const I = [
|
|
|
85
110
|
...Object.getOwnPropertyNames(Symbol).filter((n) => typeof Symbol[n] == "symbol").map((n) => [Symbol[n], `Symbol.${n}`])
|
|
86
111
|
];
|
|
87
112
|
function T(n, e) {
|
|
88
|
-
|
|
89
|
-
|
|
113
|
+
if ("error" in e && e.error) {
|
|
114
|
+
const { error: t } = e;
|
|
115
|
+
let r;
|
|
116
|
+
try {
|
|
117
|
+
r = n.dump(t);
|
|
118
|
+
} catch (i) {
|
|
119
|
+
} finally {
|
|
120
|
+
t.alive && t.dispose();
|
|
121
|
+
}
|
|
122
|
+
const s = new Error(
|
|
123
|
+
typeof r == "object" && r && "message" in r ? String(r.message) : r !== void 0 ? String(r) : "quickjs-emscripten-sync: VM evaluation failed"
|
|
124
|
+
);
|
|
125
|
+
throw typeof r == "object" && r && ("name" in r && (s.name = String(r.name)), "stack" in r && (s.stack = String(r.stack))), s;
|
|
126
|
+
}
|
|
127
|
+
return e.value;
|
|
128
|
+
}
|
|
129
|
+
function X(n, e) {
|
|
130
|
+
const t = T(n, n.evalCode(e)), r = (i, ...o) => T(n, n.callFunction(t, i != null ? i : n.undefined, ...o)), s = () => t.dispose();
|
|
131
|
+
return r.dispose = s, r[Symbol.dispose] = s, Object.defineProperty(r, "alive", {
|
|
90
132
|
get: () => t.alive
|
|
91
133
|
}), r;
|
|
92
134
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
135
|
+
const H = /* @__PURE__ */ new WeakMap();
|
|
136
|
+
function Y(n) {
|
|
137
|
+
H.has(n) || H.set(n, /* @__PURE__ */ new Map());
|
|
138
|
+
}
|
|
139
|
+
function Z(n) {
|
|
140
|
+
const e = H.get(n);
|
|
141
|
+
if (e) {
|
|
142
|
+
for (const t of e.values())
|
|
143
|
+
t.alive && t.dispose();
|
|
144
|
+
H.delete(n);
|
|
99
145
|
}
|
|
100
146
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
147
|
+
function m(n, e, t, ...r) {
|
|
148
|
+
const s = H.get(n);
|
|
149
|
+
if (!s) {
|
|
150
|
+
const o = X(n, e);
|
|
151
|
+
try {
|
|
152
|
+
return o(t, ...r);
|
|
153
|
+
} finally {
|
|
154
|
+
o.dispose();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
let i = s.get(e);
|
|
158
|
+
return (!i || !i.alive) && (i = T(n, n.evalCode(e)), s.set(e, i)), T(n, n.callFunction(i, t != null ? t : n.undefined, ...r));
|
|
103
159
|
}
|
|
104
|
-
function
|
|
105
|
-
return n.dump(
|
|
106
|
-
|
|
107
|
-
|
|
160
|
+
function x(n, e, t) {
|
|
161
|
+
return n.dump(m(n, "(a, b) => a instanceof b", void 0, e, t));
|
|
162
|
+
}
|
|
163
|
+
function ee(n, e) {
|
|
164
|
+
const t = n.typeof(e);
|
|
165
|
+
return t === "function" || t === "object" && !n.sameValue(e, n.null);
|
|
108
166
|
}
|
|
109
|
-
function
|
|
167
|
+
function te(n, e) {
|
|
110
168
|
const t = JSON.stringify(e);
|
|
111
|
-
return t ?
|
|
169
|
+
return t ? n.newString(t).consume((r) => m(n, "JSON.parse", void 0, r)) : n.undefined;
|
|
112
170
|
}
|
|
113
|
-
function
|
|
171
|
+
function g(n, e) {
|
|
172
|
+
try {
|
|
173
|
+
return e(n);
|
|
174
|
+
} finally {
|
|
175
|
+
n.alive && n.dispose();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function ne(n, e) {
|
|
114
179
|
try {
|
|
115
180
|
return e(n);
|
|
116
181
|
} finally {
|
|
@@ -118,14 +183,14 @@ function _e(n, e) {
|
|
|
118
183
|
t.alive && t.dispose();
|
|
119
184
|
}
|
|
120
185
|
}
|
|
121
|
-
function
|
|
186
|
+
function re([n, e], t) {
|
|
122
187
|
try {
|
|
123
188
|
return t(n);
|
|
124
189
|
} finally {
|
|
125
190
|
e && n.dispose();
|
|
126
191
|
}
|
|
127
192
|
}
|
|
128
|
-
function
|
|
193
|
+
function R(n, e) {
|
|
129
194
|
try {
|
|
130
195
|
return e(...n.map((t) => t[0]));
|
|
131
196
|
} finally {
|
|
@@ -133,59 +198,70 @@ function g(n, e) {
|
|
|
133
198
|
r && t.dispose();
|
|
134
199
|
}
|
|
135
200
|
}
|
|
136
|
-
function
|
|
201
|
+
function se(n) {
|
|
137
202
|
return "handle" in n;
|
|
138
203
|
}
|
|
139
|
-
function
|
|
140
|
-
return
|
|
204
|
+
function C(n) {
|
|
205
|
+
return se(n) ? n.handle : n;
|
|
141
206
|
}
|
|
142
|
-
function
|
|
143
|
-
var
|
|
207
|
+
function ie(n, e, t, r) {
|
|
208
|
+
var i;
|
|
144
209
|
let s;
|
|
145
|
-
for (const
|
|
146
|
-
if (s =
|
|
147
|
-
return s ? (
|
|
210
|
+
for (const o of r)
|
|
211
|
+
if (s = o(e, n), s) break;
|
|
212
|
+
return s ? (i = t(e, s)) != null ? i : s : void 0;
|
|
148
213
|
}
|
|
149
|
-
function
|
|
150
|
-
return typeof n != "symbol" ? void 0 :
|
|
214
|
+
function oe(n, e) {
|
|
215
|
+
return typeof n != "symbol" ? void 0 : m(
|
|
151
216
|
e,
|
|
152
217
|
"d => Symbol(d)",
|
|
153
218
|
void 0,
|
|
154
219
|
n.description ? e.newString(n.description) : e.undefined
|
|
155
220
|
);
|
|
156
221
|
}
|
|
157
|
-
function
|
|
158
|
-
return n instanceof Date ?
|
|
222
|
+
function ue(n, e) {
|
|
223
|
+
return n instanceof Date ? m(e, "d => new Date(d)", void 0, e.newNumber(n.getTime())) : void 0;
|
|
159
224
|
}
|
|
160
|
-
|
|
161
|
-
|
|
225
|
+
function ae(n, e) {
|
|
226
|
+
if (n instanceof ArrayBuffer)
|
|
227
|
+
return e.newArrayBuffer(n.slice(0));
|
|
228
|
+
if (ArrayBuffer.isView(n)) {
|
|
229
|
+
const t = new Uint8Array(n.buffer, n.byteOffset, n.byteLength).slice();
|
|
230
|
+
return ne(
|
|
231
|
+
[e.newArrayBuffer(t.buffer), e.newString(n.constructor.name)],
|
|
232
|
+
([r, s]) => m(e, "(buf, name) => new globalThis[name](buf)", void 0, r, s)
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const fe = [oe, ue, ae];
|
|
237
|
+
function ce(n) {
|
|
162
238
|
return typeof n == "function" && /^class\s/.test(Function.prototype.toString.call(n));
|
|
163
239
|
}
|
|
164
|
-
function
|
|
240
|
+
function S(n) {
|
|
165
241
|
return typeof n == "function" || typeof n == "object" && n !== null;
|
|
166
242
|
}
|
|
167
|
-
function
|
|
243
|
+
function N(n, e) {
|
|
168
244
|
const t = /* @__PURE__ */ new Set(), r = (s) => {
|
|
169
|
-
if (!(!
|
|
245
|
+
if (!(!S(s) || t.has(s) || (e == null ? void 0 : e(s, t)) === !1)) {
|
|
170
246
|
if (t.add(s), Array.isArray(s)) {
|
|
171
|
-
for (const
|
|
172
|
-
r(
|
|
247
|
+
for (const i of s)
|
|
248
|
+
r(i);
|
|
173
249
|
return;
|
|
174
250
|
}
|
|
175
251
|
if (typeof s == "object") {
|
|
176
|
-
const
|
|
177
|
-
|
|
252
|
+
const i = Object.getPrototypeOf(s);
|
|
253
|
+
i && i !== Object.prototype && r(i);
|
|
178
254
|
}
|
|
179
|
-
for (const
|
|
180
|
-
"value" in
|
|
255
|
+
for (const i of Object.values(Object.getOwnPropertyDescriptors(s)))
|
|
256
|
+
"value" in i && r(i.value), "get" in i && r(i.get), "set" in i && r(i.set);
|
|
181
257
|
}
|
|
182
258
|
};
|
|
183
259
|
return r(n), t;
|
|
184
260
|
}
|
|
185
|
-
function
|
|
186
|
-
return
|
|
261
|
+
function Ie(n, e) {
|
|
262
|
+
return N(n, e ? (t, r) => r.size < e : void 0).size;
|
|
187
263
|
}
|
|
188
|
-
function
|
|
264
|
+
function pe() {
|
|
189
265
|
let n = () => {
|
|
190
266
|
}, e = () => {
|
|
191
267
|
};
|
|
@@ -197,34 +273,43 @@ function Z() {
|
|
|
197
273
|
reject: e
|
|
198
274
|
};
|
|
199
275
|
}
|
|
200
|
-
function
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
b
|
|
207
|
-
|
|
276
|
+
function D(n, e, t, r, s = () => {
|
|
277
|
+
}) {
|
|
278
|
+
const i = n.newObject(), o = [], f = (a, u) => {
|
|
279
|
+
const p = r(a), y = typeof u.value == "undefined" ? void 0 : r(u.value), h = typeof u.get == "undefined" ? void 0 : r(u.get), c = typeof u.set == "undefined" ? void 0 : r(u.set);
|
|
280
|
+
y && o.push(y), h && o.push(h), c && o.push(c), n.newObject().consume((d) => {
|
|
281
|
+
Object.entries(u).forEach(([_, v]) => {
|
|
282
|
+
const b = _ === "value" ? y : _ === "get" ? h : _ === "set" ? c : v ? n.true : n.false;
|
|
283
|
+
b && n.setProp(d, _, b);
|
|
284
|
+
}), n.setProp(i, p, d);
|
|
208
285
|
});
|
|
209
|
-
}
|
|
210
|
-
|
|
286
|
+
};
|
|
287
|
+
try {
|
|
288
|
+
const a = Object.getOwnPropertyDescriptors(e);
|
|
289
|
+
Object.entries(a).forEach(([u, p]) => f(u, p)), Object.getOwnPropertySymbols(a).forEach((u) => f(u, a[u])), m(n, "Object.defineProperties", void 0, t, i).dispose();
|
|
290
|
+
for (const u of o) s(u);
|
|
291
|
+
} finally {
|
|
292
|
+
i.dispose();
|
|
293
|
+
}
|
|
211
294
|
}
|
|
212
|
-
function
|
|
295
|
+
function le(n, e, t, r, s, i, o = () => {
|
|
296
|
+
}) {
|
|
213
297
|
var u;
|
|
214
298
|
if (typeof e != "function") return;
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
const
|
|
219
|
-
return Object.entries(
|
|
220
|
-
|
|
299
|
+
const f = n.newFunction(e.name, function(...p) {
|
|
300
|
+
const y = r(this), h = p.map((c) => r(c));
|
|
301
|
+
if (ce(e) && S(y)) {
|
|
302
|
+
const c = new e(...h);
|
|
303
|
+
return Object.entries(c).forEach(([d, _]) => {
|
|
304
|
+
const v = t(_);
|
|
305
|
+
n.setProp(this, d, v), o(v);
|
|
221
306
|
}), this;
|
|
222
307
|
}
|
|
223
|
-
return t(
|
|
308
|
+
return t(i ? i(e, y, h) : e.apply(y, h));
|
|
224
309
|
}).consume(
|
|
225
310
|
(p) => (
|
|
226
311
|
// fucntions created by vm.newFunction are not callable as a class constrcutor
|
|
227
|
-
|
|
312
|
+
m(
|
|
228
313
|
n,
|
|
229
314
|
`Cls => {
|
|
230
315
|
const fn = function(...args) { return Cls.apply(this, args); };
|
|
@@ -236,21 +321,46 @@ function K(n, e, t, r, s, o) {
|
|
|
236
321
|
p
|
|
237
322
|
)
|
|
238
323
|
)
|
|
239
|
-
), a = (u = s(e,
|
|
240
|
-
return
|
|
324
|
+
), a = (u = s(e, f)) != null ? u : f;
|
|
325
|
+
return D(n, e, f, t, o), a;
|
|
241
326
|
}
|
|
242
|
-
function
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
327
|
+
function de(n, e, t) {
|
|
328
|
+
if (!(typeof e != "object" && typeof e != "function") && e !== null)
|
|
329
|
+
return t(e, n.newHostRef(e).handle);
|
|
330
|
+
}
|
|
331
|
+
function ye(n, e, t) {
|
|
332
|
+
var i;
|
|
333
|
+
const r = te(n, e);
|
|
334
|
+
return (i = t(e, r)) != null ? i : r;
|
|
335
|
+
}
|
|
336
|
+
function he(n, e, t, r, s = () => {
|
|
337
|
+
}) {
|
|
338
|
+
var i, o;
|
|
339
|
+
if (e instanceof Map) {
|
|
340
|
+
const f = m(n, "() => new Map()"), a = (i = r(e, f)) != null ? i : f;
|
|
341
|
+
for (const [u, p] of e) {
|
|
342
|
+
const y = t(u), h = t(p);
|
|
343
|
+
m(n, "(m, k, v) => m.set(k, v)", void 0, f, y, h).dispose(), s(y), s(h);
|
|
344
|
+
}
|
|
345
|
+
return a;
|
|
346
|
+
}
|
|
347
|
+
if (e instanceof Set) {
|
|
348
|
+
const f = m(n, "() => new Set()"), a = (o = r(e, f)) != null ? o : f;
|
|
349
|
+
for (const u of e) {
|
|
350
|
+
const p = t(u);
|
|
351
|
+
m(n, "(s, v) => s.add(v)", void 0, f, p).dispose(), s(p);
|
|
352
|
+
}
|
|
353
|
+
return a;
|
|
354
|
+
}
|
|
246
355
|
}
|
|
247
|
-
function
|
|
356
|
+
function me(n, e, t, r, s = () => {
|
|
357
|
+
}) {
|
|
248
358
|
var u;
|
|
249
359
|
if (typeof e != "object" || e === null) return;
|
|
250
|
-
const
|
|
251
|
-
return a &&
|
|
360
|
+
const i = Array.isArray(e) ? n.newArray() : n.newObject(), o = (u = r(e, i)) != null ? u : i, f = Object.getPrototypeOf(e), a = f && f !== Object.prototype && f !== Array.prototype ? t(f) : void 0;
|
|
361
|
+
return a && (m(n, "Object.setPrototypeOf", void 0, o, a).dispose(), s(a)), D(n, e, i, t, s), o;
|
|
252
362
|
}
|
|
253
|
-
function
|
|
363
|
+
function _e(n, e) {
|
|
254
364
|
switch (typeof e) {
|
|
255
365
|
case "undefined":
|
|
256
366
|
return n.undefined;
|
|
@@ -260,179 +370,248 @@ function te(n, e) {
|
|
|
260
370
|
return n.newString(e);
|
|
261
371
|
case "boolean":
|
|
262
372
|
return e ? n.true : n.false;
|
|
373
|
+
case "bigint":
|
|
374
|
+
return n.newBigInt(e);
|
|
263
375
|
case "object":
|
|
264
376
|
return e === null ? n.null : void 0;
|
|
265
377
|
}
|
|
266
378
|
}
|
|
267
|
-
function
|
|
268
|
-
var
|
|
379
|
+
function ve(n, e, t, r) {
|
|
380
|
+
var i;
|
|
269
381
|
if (!(e instanceof Promise)) return;
|
|
270
382
|
const s = n.newPromise();
|
|
271
383
|
return e.then(
|
|
272
|
-
(
|
|
273
|
-
(
|
|
274
|
-
), (
|
|
384
|
+
(o) => s.resolve(t(o)),
|
|
385
|
+
(o) => s.reject(t(o))
|
|
386
|
+
), (i = r(e, s)) != null ? i : s.handle;
|
|
275
387
|
}
|
|
276
|
-
function
|
|
277
|
-
var
|
|
278
|
-
const { ctx: t, unmarshal: r, isMarshalable: s, find:
|
|
388
|
+
function U(n, e) {
|
|
389
|
+
var y, h, c, d, _, v, b, j;
|
|
390
|
+
const { ctx: t, unmarshal: r, isMarshalable: s, find: i, pre: o } = e;
|
|
279
391
|
{
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
return
|
|
392
|
+
const w = _e(t, n);
|
|
393
|
+
if (w)
|
|
394
|
+
return typeof n == "bigint" && ((y = e.registerTransient) == null || y.call(e, w)), w;
|
|
283
395
|
}
|
|
284
396
|
{
|
|
285
|
-
const
|
|
286
|
-
if (
|
|
397
|
+
const w = i(n);
|
|
398
|
+
if (w) return w;
|
|
399
|
+
}
|
|
400
|
+
if ((h = e.marshalByReference) != null && h.call(e, n) && e.registerHostRef) {
|
|
401
|
+
const w = de(t, n, e.registerHostRef);
|
|
402
|
+
if (w) return w;
|
|
287
403
|
}
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
404
|
+
const f = s == null ? void 0 : s(n);
|
|
405
|
+
if (f === !1)
|
|
290
406
|
return t.undefined;
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
return
|
|
294
|
-
const
|
|
295
|
-
return (
|
|
407
|
+
const a = (w, k) => o(w, k, f);
|
|
408
|
+
if (f === "json")
|
|
409
|
+
return ye(t, n, a);
|
|
410
|
+
const u = (w) => U(w, e), p = e.disposeTransient;
|
|
411
|
+
return (j = (b = (v = (_ = (d = ie(t, n, a, [...fe, ...(c = e.custom) != null ? c : []])) != null ? d : ve(t, n, u, a)) != null ? _ : le(t, n, u, r, a, e.preApply, p)) != null ? v : he(t, n, u, a, p)) != null ? b : me(t, n, u, a, p)) != null ? j : t.undefined;
|
|
296
412
|
}
|
|
297
|
-
function
|
|
298
|
-
var
|
|
413
|
+
function be(n, e, t, r) {
|
|
414
|
+
var i;
|
|
299
415
|
let s;
|
|
300
|
-
for (const
|
|
301
|
-
if (s =
|
|
302
|
-
return s ? (
|
|
416
|
+
for (const o of r)
|
|
417
|
+
if (s = o(e, n), s) break;
|
|
418
|
+
return s ? (i = t(s, e)) != null ? i : s : void 0;
|
|
303
419
|
}
|
|
304
|
-
function
|
|
420
|
+
function we(n, e) {
|
|
305
421
|
if (e.typeof(n) !== "symbol") return;
|
|
306
422
|
const t = e.getString(e.getProp(n, "description"));
|
|
307
423
|
return Symbol(t);
|
|
308
424
|
}
|
|
309
|
-
function
|
|
310
|
-
if (!
|
|
311
|
-
const t =
|
|
425
|
+
function ge(n, e) {
|
|
426
|
+
if (!g(m(e, "a => a instanceof Date", void 0, n), (r) => e.dump(r))) return;
|
|
427
|
+
const t = g(m(e, "a => a.getTime()", void 0, n), (r) => e.getNumber(r));
|
|
312
428
|
return new Date(t);
|
|
313
429
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
430
|
+
function je(n, e) {
|
|
431
|
+
if (g(m(e, "a => a instanceof ArrayBuffer", void 0, n), (t) => e.dump(t))) {
|
|
432
|
+
const t = e.getArrayBuffer(n), r = t.value.slice();
|
|
433
|
+
return t.dispose(), r.buffer;
|
|
434
|
+
}
|
|
435
|
+
if (g(m(e, "a => ArrayBuffer.isView(a)", void 0, n), (t) => e.dump(t))) {
|
|
436
|
+
const t = g(
|
|
437
|
+
m(e, "a => a.constructor.name", void 0, n),
|
|
438
|
+
(f) => e.getString(f)
|
|
439
|
+
), r = globalThis[t];
|
|
440
|
+
if (typeof r != "function") return;
|
|
441
|
+
const s = m(
|
|
442
|
+
e,
|
|
443
|
+
"a => a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength)",
|
|
444
|
+
void 0,
|
|
445
|
+
n
|
|
446
|
+
), i = e.getArrayBuffer(s), o = i.value.slice();
|
|
447
|
+
return i.dispose(), s.dispose(), new r(o.buffer);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const Pe = [we, ge, je];
|
|
451
|
+
function V(n, e, t, r) {
|
|
452
|
+
g(
|
|
453
|
+
n.newFunction("", (s, i) => {
|
|
454
|
+
const [o] = r(s);
|
|
455
|
+
if (typeof o != "string" && typeof o != "number" && typeof o != "symbol")
|
|
456
|
+
return;
|
|
457
|
+
const f = [
|
|
458
|
+
["value", !0],
|
|
459
|
+
["get", !0],
|
|
460
|
+
["set", !0],
|
|
461
|
+
["configurable", !1],
|
|
462
|
+
["enumerable", !1],
|
|
463
|
+
["writable", !1]
|
|
464
|
+
].reduce((a, [u, p]) => {
|
|
465
|
+
const y = n.getProp(i, u), h = n.typeof(y);
|
|
466
|
+
if (h === "undefined") return a;
|
|
467
|
+
if (!p && h === "boolean")
|
|
468
|
+
return a[u] = n.dump(n.getProp(i, u)), a;
|
|
469
|
+
const [c, d] = r(y);
|
|
470
|
+
return d && y.dispose(), a[u] = c, a;
|
|
471
|
+
}, {});
|
|
472
|
+
Object.defineProperty(t, o, f);
|
|
473
|
+
}),
|
|
474
|
+
(s) => {
|
|
475
|
+
m(
|
|
476
|
+
n,
|
|
477
|
+
`(o, fn) => {
|
|
340
478
|
const descs = Object.getOwnPropertyDescriptors(o);
|
|
341
479
|
Object.entries(descs).forEach(([k, v]) => fn(k, v));
|
|
342
480
|
Object.getOwnPropertySymbols(descs).forEach(k => fn(k, descs[k]));
|
|
343
481
|
}`,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
482
|
+
void 0,
|
|
483
|
+
e,
|
|
484
|
+
s
|
|
485
|
+
).dispose();
|
|
486
|
+
}
|
|
487
|
+
);
|
|
349
488
|
}
|
|
350
|
-
function
|
|
351
|
-
var
|
|
489
|
+
function Se(n, e, t, r, s) {
|
|
490
|
+
var f;
|
|
352
491
|
if (n.typeof(e) !== "function") return;
|
|
353
|
-
const
|
|
354
|
-
return
|
|
355
|
-
[t(this), ...
|
|
356
|
-
(
|
|
492
|
+
const i = function(...a) {
|
|
493
|
+
return R(
|
|
494
|
+
[t(this), ...a.map((u) => t(u))],
|
|
495
|
+
(u, ...p) => {
|
|
357
496
|
if (new.target) {
|
|
358
|
-
const [
|
|
359
|
-
|
|
497
|
+
const [d] = r(
|
|
498
|
+
m(n, "(Cls, ...args) => new Cls(...args)", u, e, ...p)
|
|
360
499
|
);
|
|
361
|
-
return Object.defineProperties(this, Object.getOwnPropertyDescriptors(
|
|
500
|
+
return Object.defineProperties(this, Object.getOwnPropertyDescriptors(d)), this;
|
|
362
501
|
}
|
|
363
|
-
const
|
|
364
|
-
return
|
|
502
|
+
const y = T(n, n.callFunction(e, u, ...p)), [h, c] = r(y);
|
|
503
|
+
return c && y.dispose(), h;
|
|
365
504
|
}
|
|
366
505
|
);
|
|
367
|
-
},
|
|
368
|
-
return
|
|
506
|
+
}, o = (f = s(i, e)) != null ? f : i;
|
|
507
|
+
return V(n, e, i, r), o;
|
|
369
508
|
}
|
|
370
|
-
function
|
|
371
|
-
|
|
372
|
-
if (
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
509
|
+
function G(n, e) {
|
|
510
|
+
const t = n.toHostRef(e);
|
|
511
|
+
if (t)
|
|
512
|
+
try {
|
|
513
|
+
return { value: t.value };
|
|
514
|
+
} finally {
|
|
515
|
+
t.dispose();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
function ke(n, e, t, r) {
|
|
519
|
+
const s = g(m(n, "a => a instanceof Map", void 0, e), (a) => n.dump(a)), i = !s && g(m(n, "a => a instanceof Set", void 0, e), (a) => n.dump(a));
|
|
520
|
+
if (!s && !i) return;
|
|
521
|
+
const o = s ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
|
|
522
|
+
r(o, e);
|
|
523
|
+
const f = n.unwrapResult(n.getIterator(e));
|
|
524
|
+
try {
|
|
525
|
+
for (const a of f) {
|
|
526
|
+
const u = n.unwrapResult(a);
|
|
527
|
+
if (s) {
|
|
528
|
+
const p = n.getProp(u, 0), y = n.getProp(u, 1), [h, c] = t(p), [d, _] = t(y);
|
|
529
|
+
c && p.dispose(), _ && y.dispose(), o.set(h, d), u.dispose();
|
|
530
|
+
} else {
|
|
531
|
+
const [p, y] = t(u);
|
|
532
|
+
y && u.dispose(), o.add(p);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
} finally {
|
|
536
|
+
f.alive && f.dispose();
|
|
537
|
+
}
|
|
538
|
+
return o;
|
|
539
|
+
}
|
|
540
|
+
function Te(n, e, t, r) {
|
|
541
|
+
var f;
|
|
542
|
+
if (n.typeof(e) !== "object" || n.sameValue(e, n.null)) return;
|
|
543
|
+
const s = g(m(n, "Array.isArray", void 0, e), (a) => n.dump(a)) ? [] : {}, i = (f = r(s, e)) != null ? f : s, o = g(
|
|
544
|
+
m(
|
|
545
|
+
n,
|
|
546
|
+
`o => {
|
|
378
547
|
const p = Object.getPrototypeOf(o);
|
|
379
548
|
return !p || p === Object.prototype || p === Array.prototype ? undefined : p;
|
|
380
549
|
}`,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
550
|
+
void 0,
|
|
551
|
+
e
|
|
552
|
+
),
|
|
553
|
+
(a) => {
|
|
554
|
+
if (n.typeof(a) === "undefined") return;
|
|
555
|
+
const [u] = t(a);
|
|
556
|
+
return u;
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
return typeof o == "object" && Object.setPrototypeOf(i, o), V(n, e, s, t), i;
|
|
389
560
|
}
|
|
390
|
-
function
|
|
561
|
+
function He(n, e) {
|
|
391
562
|
const t = n.typeof(e);
|
|
392
|
-
return t === "undefined" || t === "number" || t === "string" || t === "boolean" ? [n.dump(e), !0] : t === "
|
|
563
|
+
return t === "undefined" || t === "number" || t === "string" || t === "boolean" ? [n.dump(e), !0] : t === "bigint" ? [n.getBigInt(e), !0] : t === "object" && n.sameValue(e, n.null) ? [null, !0] : [void 0, !1];
|
|
393
564
|
}
|
|
394
|
-
function
|
|
395
|
-
var
|
|
396
|
-
if (!
|
|
397
|
-
const s =
|
|
398
|
-
return
|
|
565
|
+
function Re(n, e, t, r) {
|
|
566
|
+
var u;
|
|
567
|
+
if (!Ee(n, e)) return;
|
|
568
|
+
const s = pe(), [i, o] = t(s.resolve), [f, a] = t(s.reject);
|
|
569
|
+
return m(n, "(p, res, rej) => { p.then(res, rej); }", void 0, e, i, f), o && i.dispose(), a && f.dispose(), (u = r(s.promise, e)) != null ? u : s.promise;
|
|
399
570
|
}
|
|
400
|
-
function
|
|
401
|
-
return e.owner ? n.unwrapResult(n.evalCode("Promise")).consume((t) => e.owner ?
|
|
571
|
+
function Ee(n, e) {
|
|
572
|
+
return e.owner ? n.unwrapResult(n.evalCode("Promise")).consume((t) => e.owner ? x(n, e, t) : !1) : !1;
|
|
402
573
|
}
|
|
403
|
-
function
|
|
404
|
-
const [t] =
|
|
574
|
+
function Oe(n, e) {
|
|
575
|
+
const [t] = J(n, e);
|
|
405
576
|
return t;
|
|
406
577
|
}
|
|
407
|
-
function
|
|
408
|
-
var
|
|
409
|
-
const { ctx: t, marshal: r, find: s, pre:
|
|
578
|
+
function J(n, e) {
|
|
579
|
+
var p, y, h;
|
|
580
|
+
const { ctx: t, marshal: r, find: s, pre: i } = e;
|
|
410
581
|
{
|
|
411
|
-
const [
|
|
412
|
-
if (
|
|
582
|
+
const [c, d] = He(t, n);
|
|
583
|
+
if (d) return [c, !1];
|
|
413
584
|
}
|
|
414
585
|
{
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
417
|
-
return [
|
|
586
|
+
const c = s(n);
|
|
587
|
+
if (c)
|
|
588
|
+
return [c, !0];
|
|
418
589
|
}
|
|
419
|
-
const
|
|
420
|
-
|
|
590
|
+
const o = (c) => J(c, e);
|
|
591
|
+
if (e.hostRef) {
|
|
592
|
+
const c = G(t, n);
|
|
593
|
+
if (c) return [c.value, !0];
|
|
594
|
+
}
|
|
595
|
+
const f = be(t, n, i, [...Pe, ...(p = e.custom) != null ? p : []]);
|
|
596
|
+
if (f) return [f, !0];
|
|
597
|
+
const a = ke(t, n, o, i);
|
|
598
|
+
return a ? [a, !0] : [(h = (y = Re(t, n, r, i)) != null ? y : Se(t, n, r, o, i)) != null ? h : Te(t, n, o, i), !1];
|
|
421
599
|
}
|
|
422
|
-
class
|
|
600
|
+
class I {
|
|
423
601
|
constructor(e) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
602
|
+
l(this, "ctx");
|
|
603
|
+
l(this, "_keyToId", /* @__PURE__ */ new Map());
|
|
604
|
+
l(this, "_key2ToId", /* @__PURE__ */ new Map());
|
|
605
|
+
l(this, "_idToHandle", /* @__PURE__ */ new Map());
|
|
606
|
+
l(this, "_idToHandle2", /* @__PURE__ */ new Map());
|
|
607
|
+
l(this, "_idToKey", /* @__PURE__ */ new Map());
|
|
608
|
+
l(this, "_idToKey2", /* @__PURE__ */ new Map());
|
|
609
|
+
l(this, "_disposables", /* @__PURE__ */ new Set());
|
|
610
|
+
l(this, "_mapGet");
|
|
611
|
+
l(this, "_mapSet");
|
|
612
|
+
l(this, "_mapDelete");
|
|
613
|
+
l(this, "_mapClear");
|
|
614
|
+
l(this, "_nextId", Number.MIN_SAFE_INTEGER);
|
|
436
615
|
this.ctx = e;
|
|
437
616
|
const t = e.unwrapResult(
|
|
438
617
|
e.evalCode(`() => {
|
|
@@ -463,14 +642,14 @@ class O {
|
|
|
463
642
|
this._mapGet = e.getProp(t, "get"), this._mapSet = e.getProp(t, "set"), this._mapDelete = e.getProp(t, "delete"), this._mapClear = e.getProp(t, "clear"), t.dispose(), this._disposables.add(this._mapGet), this._disposables.add(this._mapSet), this._disposables.add(this._mapDelete), this._disposables.add(this._mapClear);
|
|
464
643
|
}
|
|
465
644
|
set(e, t, r, s) {
|
|
466
|
-
var
|
|
645
|
+
var f;
|
|
467
646
|
if (!t.alive || s && !s.alive) return !1;
|
|
468
|
-
const
|
|
469
|
-
if (
|
|
470
|
-
return
|
|
471
|
-
const
|
|
472
|
-
return this.
|
|
473
|
-
this._call(this._mapSet, void 0, t,
|
|
647
|
+
const i = (f = this.get(e)) != null ? f : this.get(r);
|
|
648
|
+
if (i)
|
|
649
|
+
return i === t || i === s;
|
|
650
|
+
const o = this._nextId++;
|
|
651
|
+
return this._keyToId.set(e, o), this._idToHandle.set(o, t), this._idToKey.set(o, e), r && (this._key2ToId.set(r, o), this._idToKey2.set(o, r), s && this._idToHandle2.set(o, s)), this.ctx.newNumber(o).consume((a) => {
|
|
652
|
+
this._call(this._mapSet, void 0, t, a, s != null ? s : this.ctx.undefined);
|
|
474
653
|
}), !0;
|
|
475
654
|
}
|
|
476
655
|
merge(e) {
|
|
@@ -480,7 +659,7 @@ class O {
|
|
|
480
659
|
}
|
|
481
660
|
get(e) {
|
|
482
661
|
var s;
|
|
483
|
-
const t = (s = this.
|
|
662
|
+
const t = (s = this._keyToId.get(e)) != null ? s : this._key2ToId.get(e), r = typeof t == "number" ? this._idToHandle.get(t) : void 0;
|
|
484
663
|
if (r) {
|
|
485
664
|
if (!r.alive) {
|
|
486
665
|
this.delete(e);
|
|
@@ -491,7 +670,7 @@ class O {
|
|
|
491
670
|
}
|
|
492
671
|
getByHandle(e) {
|
|
493
672
|
if (e.alive)
|
|
494
|
-
return this.
|
|
673
|
+
return this._idToKey.get(this.ctx.getNumber(this._call(this._mapGet, void 0, e)));
|
|
495
674
|
}
|
|
496
675
|
has(e) {
|
|
497
676
|
return !!this.get(e);
|
|
@@ -500,77 +679,60 @@ class O {
|
|
|
500
679
|
return typeof this.getByHandle(e) != "undefined";
|
|
501
680
|
}
|
|
502
681
|
keys() {
|
|
503
|
-
return this.
|
|
682
|
+
return this._keyToId.keys();
|
|
504
683
|
}
|
|
505
684
|
delete(e, t) {
|
|
506
|
-
var
|
|
507
|
-
const r = (
|
|
685
|
+
var a;
|
|
686
|
+
const r = (a = this._keyToId.get(e)) != null ? a : this._key2ToId.get(e);
|
|
508
687
|
if (typeof r == "undefined") return;
|
|
509
|
-
const s = this.
|
|
688
|
+
const s = this._idToHandle.get(r), i = this._idToHandle2.get(r);
|
|
510
689
|
this._call(
|
|
511
690
|
this._mapDelete,
|
|
512
691
|
void 0,
|
|
513
|
-
...[s,
|
|
514
|
-
)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
this._map1.delete(a);
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
for (const [a, u] of this._map2)
|
|
521
|
-
if (u === r) {
|
|
522
|
-
this._map2.delete(a);
|
|
523
|
-
break;
|
|
524
|
-
}
|
|
525
|
-
for (const [a, u] of this._counterMap)
|
|
526
|
-
if (u === e) {
|
|
527
|
-
this._counterMap.delete(a);
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
t && (s != null && s.alive && s.dispose(), o != null && o.alive && o.dispose());
|
|
692
|
+
...[s, i].filter((u) => !!(u != null && u.alive))
|
|
693
|
+
);
|
|
694
|
+
const o = this._idToKey.get(r), f = this._idToKey2.get(r);
|
|
695
|
+
typeof o != "undefined" && this._keyToId.delete(o), typeof f != "undefined" && this._key2ToId.delete(f), this._idToHandle.delete(r), this._idToHandle2.delete(r), this._idToKey.delete(r), this._idToKey2.delete(r), t && (s != null && s.alive && s.dispose(), i != null && i.alive && i.dispose());
|
|
531
696
|
}
|
|
532
697
|
deleteByHandle(e, t) {
|
|
533
698
|
const r = this.getByHandle(e);
|
|
534
699
|
typeof r != "undefined" && this.delete(r, t);
|
|
535
700
|
}
|
|
536
701
|
clear() {
|
|
537
|
-
this.
|
|
702
|
+
this._nextId = 0, this._keyToId.clear(), this._key2ToId.clear(), this._idToHandle.clear(), this._idToHandle2.clear(), this._idToKey.clear(), this._idToKey2.clear(), this._mapClear.alive && this._call(this._mapClear, void 0);
|
|
538
703
|
}
|
|
539
704
|
dispose() {
|
|
540
705
|
for (const e of this._disposables.values())
|
|
541
706
|
e.alive && e.dispose();
|
|
542
|
-
for (const e of this.
|
|
707
|
+
for (const e of this._idToHandle.values())
|
|
543
708
|
e.alive && e.dispose();
|
|
544
|
-
for (const e of this.
|
|
709
|
+
for (const e of this._idToHandle2.values())
|
|
545
710
|
e.alive && e.dispose();
|
|
546
711
|
this._disposables.clear(), this.clear();
|
|
547
712
|
}
|
|
548
713
|
get size() {
|
|
549
|
-
return this.
|
|
714
|
+
return this._keyToId.size;
|
|
550
715
|
}
|
|
551
716
|
[Symbol.iterator]() {
|
|
552
|
-
const e = this.
|
|
717
|
+
const e = this._keyToId.keys();
|
|
553
718
|
return {
|
|
554
719
|
next: () => {
|
|
555
720
|
for (; ; ) {
|
|
556
721
|
const t = e.next();
|
|
557
722
|
if (t.done) return { value: void 0, done: !0 };
|
|
558
|
-
const r = this.
|
|
723
|
+
const r = this._keyToId.get(t.value);
|
|
559
724
|
if (typeof r == "undefined") continue;
|
|
560
|
-
const s = this.
|
|
725
|
+
const s = this._idToHandle.get(r), i = this._idToHandle2.get(r);
|
|
561
726
|
if (!s) continue;
|
|
562
|
-
const
|
|
563
|
-
return { value: [t.value, s,
|
|
727
|
+
const o = this._idToKey2.get(r);
|
|
728
|
+
return { value: [t.value, s, o, i], done: !1 };
|
|
564
729
|
}
|
|
565
730
|
}
|
|
566
731
|
};
|
|
567
732
|
}
|
|
568
|
-
_get2(e) {
|
|
569
|
-
for (const [t, r] of this._map2)
|
|
570
|
-
if (r === e) return t;
|
|
571
|
-
}
|
|
572
733
|
_call(e, t, ...r) {
|
|
573
|
-
return
|
|
734
|
+
return T(
|
|
735
|
+
this.ctx,
|
|
574
736
|
this.ctx.callFunction(
|
|
575
737
|
e,
|
|
576
738
|
typeof t == "undefined" ? this.ctx.undefined : t,
|
|
@@ -579,72 +741,100 @@ class O {
|
|
|
579
741
|
);
|
|
580
742
|
}
|
|
581
743
|
}
|
|
582
|
-
function
|
|
583
|
-
if (!
|
|
744
|
+
function Me(n, e, t, r, s, i, o, f = !0) {
|
|
745
|
+
if (!S(e) || e instanceof Promise || e instanceof Date || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || e instanceof Map || e instanceof Set || o && !o(e))
|
|
584
746
|
return;
|
|
585
|
-
if (
|
|
747
|
+
if (Be(e, t) || !f) return e;
|
|
586
748
|
const a = new Proxy(e, {
|
|
587
749
|
get(u, p) {
|
|
588
750
|
return p === t ? u : Reflect.get(u, p);
|
|
589
751
|
},
|
|
590
|
-
set(u, p,
|
|
591
|
-
var
|
|
592
|
-
const
|
|
593
|
-
return
|
|
594
|
-
[s(
|
|
595
|
-
(
|
|
596
|
-
const [
|
|
597
|
-
|
|
752
|
+
set(u, p, y, h) {
|
|
753
|
+
var _;
|
|
754
|
+
const c = P(y, t), d = (_ = i == null ? void 0 : i(h)) != null ? _ : "host";
|
|
755
|
+
return d !== "vm" && !Reflect.set(u, p, c) || d === "host" || !n.alive || R(
|
|
756
|
+
[s(h), s(p), s(c)],
|
|
757
|
+
(v, b, j) => {
|
|
758
|
+
const [w, k] = E(n, v, r);
|
|
759
|
+
k ? w.consume((O) => n.setProp(O, b, j)) : n.setProp(w, b, j);
|
|
598
760
|
}
|
|
599
761
|
), !0;
|
|
600
762
|
},
|
|
601
763
|
deleteProperty(u, p) {
|
|
602
|
-
var
|
|
603
|
-
const
|
|
604
|
-
return
|
|
605
|
-
const [
|
|
606
|
-
if (
|
|
607
|
-
if (
|
|
608
|
-
|
|
764
|
+
var h;
|
|
765
|
+
const y = (h = i == null ? void 0 : i(a)) != null ? h : "host";
|
|
766
|
+
return R([s(a), s(p)], (c, d) => {
|
|
767
|
+
const [_, v] = E(n, c, r);
|
|
768
|
+
if (y === "vm" || Reflect.deleteProperty(u, p)) {
|
|
769
|
+
if (y === "host" || !n.alive) return !0;
|
|
770
|
+
v ? _.consume((b) => m(n, "(a, b) => delete a[b]", void 0, b, d)) : m(n, "(a, b) => delete a[b]", void 0, _, d);
|
|
609
771
|
}
|
|
610
772
|
return !0;
|
|
611
773
|
});
|
|
774
|
+
},
|
|
775
|
+
defineProperty(u, p, y) {
|
|
776
|
+
var d;
|
|
777
|
+
const h = (d = i == null ? void 0 : i(a)) != null ? d : "host", c = F({}, y);
|
|
778
|
+
return "value" in c && (c.value = P(c.value, t)), typeof c.get == "function" && (c.get = P(c.get, t)), typeof c.set == "function" && (c.set = P(c.set, t)), h !== "vm" && !Reflect.defineProperty(u, p, c) ? !1 : (h === "host" || !n.alive || R(
|
|
779
|
+
[s(a), s(p), s(c)],
|
|
780
|
+
(_, v, b) => {
|
|
781
|
+
const [j, w] = E(n, _, r), k = (O) => m(
|
|
782
|
+
n,
|
|
783
|
+
"(o, k, d) => { Object.defineProperty(o, k, d); }",
|
|
784
|
+
void 0,
|
|
785
|
+
O,
|
|
786
|
+
v,
|
|
787
|
+
b
|
|
788
|
+
).dispose();
|
|
789
|
+
w ? j.consume(k) : k(j);
|
|
790
|
+
}
|
|
791
|
+
), !0);
|
|
612
792
|
}
|
|
613
793
|
});
|
|
614
794
|
return a;
|
|
615
795
|
}
|
|
616
|
-
function
|
|
617
|
-
if (!
|
|
796
|
+
function Ce(n, e, t, r, s, i, o, f = !0) {
|
|
797
|
+
if (!ee(n, e) || o && !o(e, n))
|
|
618
798
|
return [void 0, !1];
|
|
619
|
-
if (
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
799
|
+
if (W(n, e, r)) return [e, !1];
|
|
800
|
+
if (!f) return [e, !1];
|
|
801
|
+
const a = (c) => {
|
|
802
|
+
const d = i == null ? void 0 : i(s(c));
|
|
803
|
+
return typeof d == "string" ? n.newString(d) : n.undefined;
|
|
804
|
+
}, u = (c, d, _) => {
|
|
805
|
+
const v = s(c);
|
|
806
|
+
if (!v) return;
|
|
807
|
+
const b = s(d);
|
|
808
|
+
if (b === "__proto__") return;
|
|
809
|
+
const j = s(_);
|
|
810
|
+
P(v, t)[b] = j;
|
|
811
|
+
}, p = (c, d) => {
|
|
812
|
+
const _ = s(c);
|
|
813
|
+
if (!_) return;
|
|
814
|
+
const v = s(d);
|
|
815
|
+
Reflect.deleteProperty(P(_, t), v);
|
|
816
|
+
}, y = (c, d, _) => {
|
|
817
|
+
const v = s(c);
|
|
818
|
+
if (!v) return;
|
|
819
|
+
const b = s(d);
|
|
820
|
+
if (b === "__proto__") return;
|
|
821
|
+
const j = s(_);
|
|
822
|
+
Object.defineProperty(P(v, t), b, j);
|
|
823
|
+
}, h = n.newFunction("proxyFuncs", (c, ...d) => {
|
|
824
|
+
switch (n.getNumber(c)) {
|
|
638
825
|
case 1:
|
|
639
|
-
return a(
|
|
826
|
+
return a(d[0]);
|
|
640
827
|
case 2:
|
|
641
|
-
return u(
|
|
828
|
+
return u(d[0], d[1], d[2]);
|
|
642
829
|
case 3:
|
|
643
|
-
return p(
|
|
830
|
+
return p(d[0], d[1]);
|
|
831
|
+
case 4:
|
|
832
|
+
return y(d[0], d[1], d[2]);
|
|
644
833
|
}
|
|
645
834
|
return n.undefined;
|
|
646
|
-
})
|
|
647
|
-
|
|
835
|
+
});
|
|
836
|
+
return g(h, (c) => [
|
|
837
|
+
m(
|
|
648
838
|
n,
|
|
649
839
|
`(target, sym, proxyFuncs) => {
|
|
650
840
|
const rec = new Proxy(target, {
|
|
@@ -656,7 +846,7 @@ function me(n, e, t, r, s, o, i) {
|
|
|
656
846
|
? value[sym] ?? value
|
|
657
847
|
: value;
|
|
658
848
|
const sync = proxyFuncs(1, receiver) ?? "vm";
|
|
659
|
-
if (sync === "host" || Reflect.set(obj, key, v
|
|
849
|
+
if (sync === "host" || Reflect.set(obj, key, v)) {
|
|
660
850
|
if (sync !== "vm") {
|
|
661
851
|
proxyFuncs(2, receiver, key, v);
|
|
662
852
|
}
|
|
@@ -672,68 +862,105 @@ function me(n, e, t, r, s, o, i) {
|
|
|
672
862
|
}
|
|
673
863
|
return true;
|
|
674
864
|
},
|
|
865
|
+
defineProperty(obj, key, descriptor) {
|
|
866
|
+
const sync = proxyFuncs(1, rec) ?? "vm";
|
|
867
|
+
if (sync === "host" || Reflect.defineProperty(obj, key, descriptor)) {
|
|
868
|
+
if (sync !== "vm") {
|
|
869
|
+
proxyFuncs(4, rec, key, descriptor);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return true;
|
|
873
|
+
},
|
|
675
874
|
});
|
|
676
875
|
return rec;
|
|
677
876
|
}`,
|
|
678
877
|
void 0,
|
|
679
878
|
e,
|
|
680
879
|
r,
|
|
681
|
-
|
|
880
|
+
c
|
|
682
881
|
),
|
|
683
882
|
!0
|
|
684
883
|
]);
|
|
685
884
|
}
|
|
686
|
-
function
|
|
885
|
+
function P(n, e) {
|
|
687
886
|
var t;
|
|
688
|
-
return
|
|
887
|
+
return S(n) && (t = n[e]) != null ? t : n;
|
|
689
888
|
}
|
|
690
|
-
function
|
|
691
|
-
return
|
|
889
|
+
function E(n, e, t) {
|
|
890
|
+
return W(n, e, t) ? [n.getProp(e, t), !0] : [e, !1];
|
|
692
891
|
}
|
|
693
|
-
function
|
|
694
|
-
return
|
|
892
|
+
function Be(n, e) {
|
|
893
|
+
return S(n) && !!n[e];
|
|
695
894
|
}
|
|
696
|
-
function
|
|
895
|
+
function W(n, e, t) {
|
|
697
896
|
return !!n.dump(
|
|
698
|
-
|
|
897
|
+
m(
|
|
699
898
|
n,
|
|
700
|
-
//
|
|
701
|
-
|
|
899
|
+
// Built-ins that must not be wrapped (internal slots / non-property access)
|
|
900
|
+
// report as "wrapped" so wrapHandle leaves them alone.
|
|
901
|
+
'(a, s) => (a instanceof Promise) || (a instanceof Date) || (a instanceof ArrayBuffer) || (ArrayBuffer.isView(a)) || (a instanceof Map) || (a instanceof Set) || (typeof a === "object" && a !== null || typeof a === "function") && !!a[s]',
|
|
702
902
|
void 0,
|
|
703
903
|
e,
|
|
704
904
|
t
|
|
705
905
|
)
|
|
706
906
|
);
|
|
707
907
|
}
|
|
708
|
-
class
|
|
908
|
+
class Fe {
|
|
709
909
|
/** Constructs a new Arena instance. It requires a quickjs-emscripten context initialized with `quickjs.newContext()`. */
|
|
710
910
|
constructor(e, t) {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
911
|
+
l(this, "context");
|
|
912
|
+
l(this, "_map");
|
|
913
|
+
l(this, "_registeredMap");
|
|
914
|
+
l(this, "_registeredMapDispose", /* @__PURE__ */ new Set());
|
|
915
|
+
// Handles with no owner: "json" copies and BigInt values. Unlike
|
|
916
|
+
// proxy-marshalled objects they are not identity-tracked in `_map`. A nested
|
|
917
|
+
// one is disposed by its parent consumer via `_disposeTransient` as soon as
|
|
918
|
+
// the value has been copied; this set is the fallback that frees any that
|
|
919
|
+
// were never nested (e.g. a top-level value before its caller consumes it) on
|
|
920
|
+
// dispose. Top-level handles are removed in `_marshal` since their caller
|
|
921
|
+
// disposes them via `mayConsume`.
|
|
922
|
+
l(this, "_transientHandles", /* @__PURE__ */ new Set());
|
|
923
|
+
l(this, "_sync", /* @__PURE__ */ new Set());
|
|
924
|
+
l(this, "_temporalSync", /* @__PURE__ */ new Set());
|
|
925
|
+
l(this, "_symbol", /* @__PURE__ */ Symbol());
|
|
926
|
+
l(this, "_symbolHandle");
|
|
927
|
+
l(this, "_options");
|
|
928
|
+
l(this, "_isMarshalable", (e) => {
|
|
721
929
|
var r, s;
|
|
722
930
|
const t = (r = this._options) == null ? void 0 : r.isMarshalable;
|
|
723
931
|
return (s = typeof t == "function" ? t(this._unwrap(e)) : t) != null ? s : "json";
|
|
724
932
|
});
|
|
725
|
-
|
|
726
|
-
var
|
|
933
|
+
l(this, "_marshalByReference", (e) => {
|
|
934
|
+
var t, r;
|
|
935
|
+
return !!((r = (t = this._options) == null ? void 0 : t.marshalByReference) != null && r.call(t, this._unwrap(e)));
|
|
936
|
+
});
|
|
937
|
+
// Register an opaque HostRef handle by its host value without wrapping it.
|
|
938
|
+
l(this, "_registerHostRef", (e, t) => {
|
|
939
|
+
const r = this._unwrap(e), s = this._map.get(r);
|
|
940
|
+
return s || (this._map.set(r, t), t);
|
|
941
|
+
});
|
|
942
|
+
l(this, "_marshalFind", (e) => {
|
|
943
|
+
var s, i, o;
|
|
727
944
|
const t = this._unwrap(e);
|
|
728
|
-
return (
|
|
945
|
+
return (o = (i = (s = this._registeredMap.get(e)) != null ? s : t !== e ? this._registeredMap.get(t) : void 0) != null ? i : this._map.get(e)) != null ? o : t !== e ? this._map.get(t) : void 0;
|
|
946
|
+
});
|
|
947
|
+
l(this, "_marshalPre", (e, t, r) => {
|
|
948
|
+
if (r === "json") {
|
|
949
|
+
this._registerTransient(C(t));
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
const s = this._register(e, C(t), this._map);
|
|
953
|
+
if (s) return s[1];
|
|
954
|
+
this._registeredMap.has(e) || this._registerTransient(C(t));
|
|
955
|
+
});
|
|
956
|
+
l(this, "_registerTransient", (e) => {
|
|
957
|
+
this._transientHandles.add(e);
|
|
729
958
|
});
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
if (r !== "json")
|
|
733
|
-
return (s = this._register(e, L(t), this._map)) == null ? void 0 : s[1];
|
|
959
|
+
l(this, "_disposeTransient", (e) => {
|
|
960
|
+
this._transientHandles.delete(e) && e.alive && e.dispose();
|
|
734
961
|
});
|
|
735
|
-
|
|
736
|
-
const s =
|
|
962
|
+
l(this, "_marshalPreApply", (e, t, r) => {
|
|
963
|
+
const s = S(t) ? this._unwrap(t) : void 0;
|
|
737
964
|
s && this._temporalSync.add(s);
|
|
738
965
|
try {
|
|
739
966
|
return e.apply(t, r);
|
|
@@ -741,49 +968,60 @@ class ve {
|
|
|
741
968
|
s && this._temporalSync.delete(s);
|
|
742
969
|
}
|
|
743
970
|
});
|
|
744
|
-
|
|
745
|
-
var
|
|
971
|
+
l(this, "_marshal", (e) => {
|
|
972
|
+
var o, f, a, u;
|
|
746
973
|
const t = this._registeredMap.get(e);
|
|
747
974
|
if (t)
|
|
748
975
|
return [t, !1];
|
|
749
|
-
const r =
|
|
976
|
+
const r = this._marshalByReference(e) ? this._unwrap(e) : (o = this._wrap(e)) != null ? o : e, s = U(r, {
|
|
750
977
|
ctx: this.context,
|
|
751
978
|
unmarshal: this._unmarshal,
|
|
752
979
|
isMarshalable: this._isMarshalable,
|
|
980
|
+
marshalByReference: this._marshalByReference,
|
|
981
|
+
registerHostRef: this._registerHostRef,
|
|
753
982
|
find: this._marshalFind,
|
|
754
983
|
pre: this._marshalPre,
|
|
984
|
+
registerTransient: this._registerTransient,
|
|
985
|
+
disposeTransient: this._disposeTransient,
|
|
755
986
|
preApply: this._marshalPreApply,
|
|
756
|
-
custom: (
|
|
987
|
+
custom: (f = this._options) == null ? void 0 : f.customMarshaller
|
|
757
988
|
});
|
|
758
|
-
|
|
989
|
+
this._transientHandles.delete(s);
|
|
990
|
+
const i = (u = (a = this._options) == null ? void 0 : a.syncEnabled) != null ? u : !0;
|
|
991
|
+
return [s, !i || !this._map.hasHandle(s)];
|
|
759
992
|
});
|
|
760
|
-
|
|
761
|
-
var r;
|
|
762
|
-
return (
|
|
993
|
+
l(this, "_preUnmarshal", (e, t) => {
|
|
994
|
+
var r, s, i;
|
|
995
|
+
return (i = this._register(e, t, void 0, (s = (r = this._options) == null ? void 0 : r.syncEnabled) != null ? s : !0)) == null ? void 0 : i[0];
|
|
763
996
|
});
|
|
764
|
-
|
|
997
|
+
l(this, "_unmarshalFind", (e) => {
|
|
765
998
|
var t;
|
|
766
999
|
return (t = this._registeredMap.getByHandle(e)) != null ? t : this._map.getByHandle(e);
|
|
767
1000
|
});
|
|
768
|
-
|
|
769
|
-
var s;
|
|
1001
|
+
l(this, "_unmarshal", (e) => {
|
|
1002
|
+
var s, i, o;
|
|
770
1003
|
const t = this._registeredMap.getByHandle(e);
|
|
771
1004
|
if (typeof t != "undefined")
|
|
772
1005
|
return t;
|
|
1006
|
+
if ((s = this._options) != null && s.marshalByReference) {
|
|
1007
|
+
const f = G(this.context, e);
|
|
1008
|
+
if (f) return f.value;
|
|
1009
|
+
}
|
|
773
1010
|
const [r] = this._wrapHandle(e);
|
|
774
|
-
return
|
|
1011
|
+
return Oe(r != null ? r : e, {
|
|
775
1012
|
ctx: this.context,
|
|
776
1013
|
marshal: this._marshal,
|
|
777
1014
|
find: this._unmarshalFind,
|
|
778
1015
|
pre: this._preUnmarshal,
|
|
779
|
-
custom: (
|
|
1016
|
+
custom: (i = this._options) == null ? void 0 : i.customUnmarshaller,
|
|
1017
|
+
hostRef: !!((o = this._options) != null && o.marshalByReference)
|
|
780
1018
|
});
|
|
781
1019
|
});
|
|
782
|
-
|
|
1020
|
+
l(this, "_syncMode", (e) => {
|
|
783
1021
|
const t = this._unwrap(e);
|
|
784
1022
|
return this._sync.has(t) || this._temporalSync.has(t) ? "both" : void 0;
|
|
785
1023
|
});
|
|
786
|
-
|
|
1024
|
+
l(this, "_unwrapIfNotSynced", (e) => {
|
|
787
1025
|
const t = this._unwrap(e);
|
|
788
1026
|
return t instanceof Promise || !this._sync.has(t) ? t : e;
|
|
789
1027
|
});
|
|
@@ -791,14 +1029,20 @@ class ve {
|
|
|
791
1029
|
t != null && t.compat && !("runtime" in e) && (e.runtime = {
|
|
792
1030
|
hasPendingJob: () => e.hasPendingJob(),
|
|
793
1031
|
executePendingJobs: (s) => e.executePendingJobs(s)
|
|
794
|
-
}), this.context = t != null && t.experimentalContextEx ?
|
|
1032
|
+
}), this.context = t != null && t.experimentalContextEx ? K(e) : e, Y(this.context), this._options = t, this._symbolHandle = e.unwrapResult(e.evalCode("Symbol()")), this._map = new I(e), this._registeredMap = new I(e), this.registerAll((r = t == null ? void 0 : t.registeredObjects) != null ? r : Q);
|
|
795
1033
|
}
|
|
796
1034
|
/**
|
|
797
1035
|
* Dispose of the arena and managed handles. This method won't dispose the VM itself, so the VM has to be disposed of manually.
|
|
798
1036
|
*/
|
|
799
1037
|
dispose() {
|
|
800
1038
|
var e, t;
|
|
801
|
-
|
|
1039
|
+
for (const r of this._transientHandles)
|
|
1040
|
+
r.alive && r.dispose();
|
|
1041
|
+
this._transientHandles.clear(), this._map.dispose(), this._registeredMap.dispose(), this._symbolHandle.dispose(), Z(this.context), (t = (e = this.context).disposeEx) == null || t.call(e);
|
|
1042
|
+
}
|
|
1043
|
+
/** Allows `using arena = new Arena(...)` to dispose the arena automatically. */
|
|
1044
|
+
[Symbol.dispose]() {
|
|
1045
|
+
this.dispose();
|
|
802
1046
|
}
|
|
803
1047
|
/**
|
|
804
1048
|
* Evaluate JS code in the VM and get the result as an object on the host side. It also converts and re-throws error objects when an error is thrown during evaluation.
|
|
@@ -850,7 +1094,7 @@ class ve {
|
|
|
850
1094
|
const t = this.context.runtime.executePendingJobs(e);
|
|
851
1095
|
if ("value" in t)
|
|
852
1096
|
return t.value;
|
|
853
|
-
throw this._unwrapIfNotSynced(t.error
|
|
1097
|
+
throw this._unwrapIfNotSynced(g(t.error, this._unmarshal));
|
|
854
1098
|
}
|
|
855
1099
|
/**
|
|
856
1100
|
* Set the max memory this runtime can allocate.
|
|
@@ -945,7 +1189,7 @@ class ve {
|
|
|
945
1189
|
*/
|
|
946
1190
|
expose(e) {
|
|
947
1191
|
for (const [t, r] of Object.entries(e))
|
|
948
|
-
|
|
1192
|
+
re(this._marshal(r), (s) => {
|
|
949
1193
|
this.context.setProp(this.context.global, t, s);
|
|
950
1194
|
});
|
|
951
1195
|
}
|
|
@@ -956,7 +1200,7 @@ class ve {
|
|
|
956
1200
|
*/
|
|
957
1201
|
sync(e) {
|
|
958
1202
|
const t = this._wrap(e);
|
|
959
|
-
return typeof t == "undefined" ? e : (
|
|
1203
|
+
return typeof t == "undefined" ? e : (N(t, (r) => {
|
|
960
1204
|
const s = this._unwrap(r);
|
|
961
1205
|
this._sync.add(s);
|
|
962
1206
|
}), t);
|
|
@@ -992,7 +1236,7 @@ class ve {
|
|
|
992
1236
|
this.unregister(r, t);
|
|
993
1237
|
}
|
|
994
1238
|
startSync(e) {
|
|
995
|
-
if (!
|
|
1239
|
+
if (!S(e)) return;
|
|
996
1240
|
const t = this._unwrap(e);
|
|
997
1241
|
this._sync.add(t);
|
|
998
1242
|
}
|
|
@@ -1002,68 +1246,89 @@ class ve {
|
|
|
1002
1246
|
_unwrapResult(e) {
|
|
1003
1247
|
if ("value" in e)
|
|
1004
1248
|
return e.value;
|
|
1005
|
-
throw this._unwrapIfNotSynced(e.error
|
|
1249
|
+
throw this._unwrapIfNotSynced(g(e.error, this._unmarshal));
|
|
1006
1250
|
}
|
|
1007
1251
|
_unwrapResultAndUnmarshal(e) {
|
|
1008
1252
|
if (e)
|
|
1009
|
-
return this._unwrapIfNotSynced(this._unwrapResult(e)
|
|
1253
|
+
return this._unwrapIfNotSynced(g(this._unwrapResult(e), this._unmarshal));
|
|
1010
1254
|
}
|
|
1011
1255
|
_register(e, t, r = this._map, s) {
|
|
1012
1256
|
if (this._registeredMap.has(e) || this._registeredMap.hasHandle(t))
|
|
1013
1257
|
return;
|
|
1014
|
-
let
|
|
1015
|
-
const [
|
|
1016
|
-
if (!
|
|
1017
|
-
|
|
1018
|
-
const
|
|
1019
|
-
if (r.set(o,
|
|
1020
|
-
s && this._sync.add(
|
|
1021
|
-
else throw
|
|
1022
|
-
return [
|
|
1258
|
+
let i = this._wrap(e);
|
|
1259
|
+
const [o] = this._wrapHandle(t), f = e instanceof Promise;
|
|
1260
|
+
if (!o || !i && !f) return;
|
|
1261
|
+
f && (i = e);
|
|
1262
|
+
const a = this._unwrap(e), [u, p] = this._unwrapHandle(t);
|
|
1263
|
+
if (r.set(i, o, a, u))
|
|
1264
|
+
s && this._sync.add(a);
|
|
1265
|
+
else throw p && u.dispose(), new Error("already registered");
|
|
1266
|
+
return [i, o];
|
|
1023
1267
|
}
|
|
1024
1268
|
_wrap(e) {
|
|
1025
|
-
var t;
|
|
1026
|
-
return
|
|
1269
|
+
var t, r, s;
|
|
1270
|
+
return Me(
|
|
1027
1271
|
this.context,
|
|
1028
1272
|
e,
|
|
1029
1273
|
this._symbol,
|
|
1030
1274
|
this._symbolHandle,
|
|
1031
1275
|
this._marshal,
|
|
1032
1276
|
this._syncMode,
|
|
1033
|
-
(t = this._options) == null ? void 0 : t.isWrappable
|
|
1277
|
+
(t = this._options) == null ? void 0 : t.isWrappable,
|
|
1278
|
+
(s = (r = this._options) == null ? void 0 : r.syncEnabled) != null ? s : !0
|
|
1034
1279
|
);
|
|
1035
1280
|
}
|
|
1036
1281
|
_unwrap(e) {
|
|
1037
|
-
return
|
|
1282
|
+
return P(e, this._symbol);
|
|
1038
1283
|
}
|
|
1039
1284
|
_wrapHandle(e) {
|
|
1040
|
-
var t;
|
|
1041
|
-
return
|
|
1285
|
+
var t, r, s;
|
|
1286
|
+
return Ce(
|
|
1042
1287
|
this.context,
|
|
1043
1288
|
e,
|
|
1044
1289
|
this._symbol,
|
|
1045
1290
|
this._symbolHandle,
|
|
1046
1291
|
this._unmarshal,
|
|
1047
1292
|
this._syncMode,
|
|
1048
|
-
(t = this._options) == null ? void 0 : t.isHandleWrappable
|
|
1293
|
+
(t = this._options) == null ? void 0 : t.isHandleWrappable,
|
|
1294
|
+
(s = (r = this._options) == null ? void 0 : r.syncEnabled) != null ? s : !0
|
|
1049
1295
|
);
|
|
1050
1296
|
}
|
|
1051
1297
|
_unwrapHandle(e) {
|
|
1052
|
-
return
|
|
1298
|
+
return E(this.context, e, this._symbolHandle);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
class Ne extends Fe {
|
|
1302
|
+
constructor(t, r) {
|
|
1303
|
+
super(t, r);
|
|
1304
|
+
l(this, "asyncContext");
|
|
1305
|
+
this.asyncContext = t;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Evaluate JS code asynchronously in the VM and get the result on the host
|
|
1309
|
+
* side. Like `evalCode`, it converts and re-throws errors thrown during
|
|
1310
|
+
* evaluation. Use this when the code awaits host-provided promises.
|
|
1311
|
+
*/
|
|
1312
|
+
evalCodeAsync(t, r) {
|
|
1313
|
+
return A(this, null, function* () {
|
|
1314
|
+
const s = yield this.asyncContext.evalCodeAsync(t, r);
|
|
1315
|
+
return this._unwrapResultAndUnmarshal(s);
|
|
1316
|
+
});
|
|
1053
1317
|
}
|
|
1054
1318
|
}
|
|
1055
1319
|
export {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1320
|
+
Fe as Arena,
|
|
1321
|
+
Ne as AsyncArena,
|
|
1322
|
+
I as VMMap,
|
|
1323
|
+
m as call,
|
|
1324
|
+
Ie as complexity,
|
|
1325
|
+
ne as consumeAll,
|
|
1326
|
+
Q as defaultRegisteredObjects,
|
|
1327
|
+
ce as isES2015Class,
|
|
1328
|
+
ee as isHandleObject,
|
|
1329
|
+
S as isObject,
|
|
1330
|
+
te as json,
|
|
1331
|
+
U as marshal,
|
|
1332
|
+
Oe as unmarshal,
|
|
1333
|
+
N as walkObject
|
|
1069
1334
|
};
|