quickjs-emscripten-sync 1.9.0 → 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.
@@ -1,40 +1,40 @@
1
- var W = Object.defineProperty;
2
- var C = Object.getOwnPropertySymbols;
3
- var z = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
4
- var M = (n, e, t) => e in n ? W(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, B = (n, e) => {
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
5
  for (var t in e || (e = {}))
6
- z.call(e, t) && M(n, t, e[t]);
7
- if (C)
8
- for (var t of C(e))
9
- $.call(e, t) && M(n, t, e[t]);
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
10
  return n;
11
11
  };
12
12
  var l = (n, e, t) => M(n, typeof e != "symbol" ? e + "" : e, t);
13
- var F = (n, e, t) => new Promise((r, s) => {
14
- var o = (u) => {
13
+ var A = (n, e, t) => new Promise((r, s) => {
14
+ var i = (a) => {
15
15
  try {
16
- a(t.next(u));
17
- } catch (f) {
18
- s(f);
16
+ f(t.next(a));
17
+ } catch (u) {
18
+ s(u);
19
19
  }
20
- }, i = (u) => {
20
+ }, o = (a) => {
21
21
  try {
22
- a(t.throw(u));
23
- } catch (f) {
24
- s(f);
22
+ f(t.throw(a));
23
+ } catch (u) {
24
+ s(u);
25
25
  }
26
- }, a = (u) => u.done ? r(u.value) : Promise.resolve(u.value).then(o, i);
27
- a((t = t.apply(n, e)).next());
26
+ }, f = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(i, o);
27
+ f((t = t.apply(n, e)).next());
28
28
  });
29
- const L = (n) => {
30
- const e = new K(n);
29
+ const K = (n) => {
30
+ const e = new q(n);
31
31
  return new Proxy(n, {
32
32
  get(t, r, s) {
33
33
  return r in e ? e[r] : Reflect.get(t, r, s);
34
34
  }
35
35
  });
36
36
  };
37
- class K {
37
+ class q {
38
38
  constructor(e) {
39
39
  l(this, "context");
40
40
  l(this, "fn");
@@ -59,9 +59,9 @@ class K {
59
59
  this.context = e;
60
60
  const t = this.fnMap;
61
61
  this.fn = this.context.newFunction("", function(r, ...s) {
62
- const o = e.getNumber(r), i = t.get(o);
63
- if (!i) throw new Error("function is not registered");
64
- return i.call(this, ...s);
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);
65
65
  }), this.fnGenerator = e.unwrapResult(
66
66
  e.evalCode(`((name, length, id, f) => {
67
67
  const fn = function(...args) {
@@ -77,7 +77,7 @@ class K {
77
77
  this.fnGenerator.dispose(), this.fn.dispose();
78
78
  }
79
79
  }
80
- const q = [
80
+ const Q = [
81
81
  // basic objects
82
82
  [Symbol, "Symbol"],
83
83
  [Symbol.prototype, "Symbol.prototype"],
@@ -109,13 +109,13 @@ const q = [
109
109
  // built-in symbols
110
110
  ...Object.getOwnPropertyNames(Symbol).filter((n) => typeof Symbol[n] == "symbol").map((n) => [Symbol[n], `Symbol.${n}`])
111
111
  ];
112
- function S(n, e) {
112
+ function T(n, e) {
113
113
  if ("error" in e && e.error) {
114
114
  const { error: t } = e;
115
115
  let r;
116
116
  try {
117
117
  r = n.dump(t);
118
- } catch (o) {
118
+ } catch (i) {
119
119
  } finally {
120
120
  t.alive && t.dispose();
121
121
  }
@@ -126,56 +126,56 @@ function S(n, e) {
126
126
  }
127
127
  return e.value;
128
128
  }
129
- function Q(n, e) {
130
- const t = S(n, n.evalCode(e)), r = (o, ...i) => S(n, n.callFunction(t, o != null ? o : n.undefined, ...i)), s = () => t.dispose();
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
131
  return r.dispose = s, r[Symbol.dispose] = s, Object.defineProperty(r, "alive", {
132
132
  get: () => t.alive
133
133
  }), r;
134
134
  }
135
- const k = /* @__PURE__ */ new WeakMap();
136
- function X(n) {
137
- k.has(n) || k.set(n, /* @__PURE__ */ new Map());
138
- }
135
+ const H = /* @__PURE__ */ new WeakMap();
139
136
  function Y(n) {
140
- const e = k.get(n);
137
+ H.has(n) || H.set(n, /* @__PURE__ */ new Map());
138
+ }
139
+ function Z(n) {
140
+ const e = H.get(n);
141
141
  if (e) {
142
142
  for (const t of e.values())
143
143
  t.alive && t.dispose();
144
- k.delete(n);
144
+ H.delete(n);
145
145
  }
146
146
  }
147
147
  function m(n, e, t, ...r) {
148
- const s = k.get(n);
148
+ const s = H.get(n);
149
149
  if (!s) {
150
- const i = Q(n, e);
150
+ const o = X(n, e);
151
151
  try {
152
- return i(t, ...r);
152
+ return o(t, ...r);
153
153
  } finally {
154
- i.dispose();
154
+ o.dispose();
155
155
  }
156
156
  }
157
- let o = s.get(e);
158
- return (!o || !o.alive) && (o = S(n, n.evalCode(e)), s.set(e, o)), S(n, n.callFunction(o, t != null ? t : n.undefined, ...r));
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));
159
159
  }
160
- function Z(n, e, t) {
160
+ function x(n, e, t) {
161
161
  return n.dump(m(n, "(a, b) => a instanceof b", void 0, e, t));
162
162
  }
163
- function x(n, e) {
163
+ function ee(n, e) {
164
164
  const t = n.typeof(e);
165
165
  return t === "function" || t === "object" && !n.sameValue(e, n.null);
166
166
  }
167
- function ee(n, e) {
167
+ function te(n, e) {
168
168
  const t = JSON.stringify(e);
169
- return t ? m(n, "JSON.parse", void 0, n.newString(t)) : n.undefined;
169
+ return t ? n.newString(t).consume((r) => m(n, "JSON.parse", void 0, r)) : n.undefined;
170
170
  }
171
- function w(n, e) {
171
+ function g(n, e) {
172
172
  try {
173
173
  return e(n);
174
174
  } finally {
175
175
  n.alive && n.dispose();
176
176
  }
177
177
  }
178
- function te(n, e) {
178
+ function ne(n, e) {
179
179
  try {
180
180
  return e(n);
181
181
  } finally {
@@ -183,14 +183,14 @@ function te(n, e) {
183
183
  t.alive && t.dispose();
184
184
  }
185
185
  }
186
- function ne([n, e], t) {
186
+ function re([n, e], t) {
187
187
  try {
188
188
  return t(n);
189
189
  } finally {
190
190
  e && n.dispose();
191
191
  }
192
192
  }
193
- function O(n, e) {
193
+ function R(n, e) {
194
194
  try {
195
195
  return e(...n.map((t) => t[0]));
196
196
  } finally {
@@ -198,20 +198,20 @@ function O(n, e) {
198
198
  r && t.dispose();
199
199
  }
200
200
  }
201
- function re(n) {
201
+ function se(n) {
202
202
  return "handle" in n;
203
203
  }
204
- function se(n) {
205
- return re(n) ? n.handle : n;
204
+ function C(n) {
205
+ return se(n) ? n.handle : n;
206
206
  }
207
- function oe(n, e, t, r) {
208
- var o;
207
+ function ie(n, e, t, r) {
208
+ var i;
209
209
  let s;
210
- for (const i of r)
211
- if (s = i(e, n), s) break;
212
- return s ? (o = t(e, s)) != null ? o : s : void 0;
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;
213
213
  }
214
- function ie(n, e) {
214
+ function oe(n, e) {
215
215
  return typeof n != "symbol" ? void 0 : m(
216
216
  e,
217
217
  "d => Symbol(d)",
@@ -227,39 +227,39 @@ function ae(n, e) {
227
227
  return e.newArrayBuffer(n.slice(0));
228
228
  if (ArrayBuffer.isView(n)) {
229
229
  const t = new Uint8Array(n.buffer, n.byteOffset, n.byteLength).slice();
230
- return te(
230
+ return ne(
231
231
  [e.newArrayBuffer(t.buffer), e.newString(n.constructor.name)],
232
232
  ([r, s]) => m(e, "(buf, name) => new globalThis[name](buf)", void 0, r, s)
233
233
  );
234
234
  }
235
235
  }
236
- const fe = [ie, ue, ae];
236
+ const fe = [oe, ue, ae];
237
237
  function ce(n) {
238
238
  return typeof n == "function" && /^class\s/.test(Function.prototype.toString.call(n));
239
239
  }
240
- function P(n) {
240
+ function S(n) {
241
241
  return typeof n == "function" || typeof n == "object" && n !== null;
242
242
  }
243
- function I(n, e) {
243
+ function N(n, e) {
244
244
  const t = /* @__PURE__ */ new Set(), r = (s) => {
245
- if (!(!P(s) || t.has(s) || (e == null ? void 0 : e(s, t)) === !1)) {
245
+ if (!(!S(s) || t.has(s) || (e == null ? void 0 : e(s, t)) === !1)) {
246
246
  if (t.add(s), Array.isArray(s)) {
247
- for (const o of s)
248
- r(o);
247
+ for (const i of s)
248
+ r(i);
249
249
  return;
250
250
  }
251
251
  if (typeof s == "object") {
252
- const o = Object.getPrototypeOf(s);
253
- o && o !== Object.prototype && r(o);
252
+ const i = Object.getPrototypeOf(s);
253
+ i && i !== Object.prototype && r(i);
254
254
  }
255
- for (const o of Object.values(Object.getOwnPropertyDescriptors(s)))
256
- "value" in o && r(o.value), "get" in o && r(o.get), "set" in o && r(o.set);
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);
257
257
  }
258
258
  };
259
259
  return r(n), t;
260
260
  }
261
261
  function Ie(n, e) {
262
- return I(n, e ? (t, r) => r.size < e : void 0).size;
262
+ return N(n, e ? (t, r) => r.size < e : void 0).size;
263
263
  }
264
264
  function pe() {
265
265
  let n = () => {
@@ -273,37 +273,41 @@ function pe() {
273
273
  reject: e
274
274
  };
275
275
  }
276
- function N(n, e, t, r) {
277
- const s = n.newObject(), o = (i, a) => {
278
- const u = r(i), f = typeof a.value == "undefined" ? void 0 : r(a.value), d = typeof a.get == "undefined" ? void 0 : r(a.get), y = typeof a.set == "undefined" ? void 0 : r(a.set);
279
- n.newObject().consume((h) => {
280
- Object.entries(a).forEach(([c, p]) => {
281
- const v = c === "value" ? f : c === "get" ? d : c === "set" ? y : p ? n.true : n.false;
282
- v && n.setProp(h, c, v);
283
- }), n.setProp(s, u, h);
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);
284
285
  });
285
286
  };
286
287
  try {
287
- const i = Object.getOwnPropertyDescriptors(e);
288
- Object.entries(i).forEach(([a, u]) => o(a, u)), Object.getOwnPropertySymbols(i).forEach((a) => o(a, i[a])), m(n, "Object.defineProperties", void 0, t, s).dispose();
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);
289
291
  } finally {
290
- s.dispose();
292
+ i.dispose();
291
293
  }
292
294
  }
293
- function le(n, e, t, r, s, o) {
295
+ function le(n, e, t, r, s, i, o = () => {
296
+ }) {
294
297
  var u;
295
298
  if (typeof e != "function") return;
296
- const i = n.newFunction(e.name, function(...f) {
297
- const d = r(this), y = f.map((h) => r(h));
298
- if (ce(e) && P(d)) {
299
- const h = new e(...y);
300
- return Object.entries(h).forEach(([c, p]) => {
301
- n.setProp(this, c, t(p));
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);
302
306
  }), this;
303
307
  }
304
- return t(o ? o(e, d, y) : e.apply(d, y));
308
+ return t(i ? i(e, y, h) : e.apply(y, h));
305
309
  }).consume(
306
- (f) => (
310
+ (p) => (
307
311
  // fucntions created by vm.newFunction are not callable as a class constrcutor
308
312
  m(
309
313
  n,
@@ -314,41 +318,47 @@ function le(n, e, t, r, s, o) {
314
318
  return fn;
315
319
  }`,
316
320
  void 0,
317
- f
321
+ p
318
322
  )
319
323
  )
320
- ), a = (u = s(e, i)) != null ? u : i;
321
- return N(n, e, i, t), a;
324
+ ), a = (u = s(e, f)) != null ? u : f;
325
+ return D(n, e, f, t, o), a;
322
326
  }
323
327
  function de(n, e, t) {
324
328
  if (!(typeof e != "object" && typeof e != "function") && e !== null)
325
329
  return t(e, n.newHostRef(e).handle);
326
330
  }
327
331
  function ye(n, e, t) {
328
- var o;
329
- const r = ee(n, e);
330
- return (o = t(e, r)) != null ? o : r;
332
+ var i;
333
+ const r = te(n, e);
334
+ return (i = t(e, r)) != null ? i : r;
331
335
  }
332
- function he(n, e, t, r) {
333
- var s, o;
336
+ function he(n, e, t, r, s = () => {
337
+ }) {
338
+ var i, o;
334
339
  if (e instanceof Map) {
335
- const i = m(n, "() => new Map()"), a = (s = r(e, i)) != null ? s : i;
336
- for (const [u, f] of e)
337
- m(n, "(m, k, v) => m.set(k, v)", void 0, i, t(u), t(f)).dispose();
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
+ }
338
345
  return a;
339
346
  }
340
347
  if (e instanceof Set) {
341
- const i = m(n, "() => new Set()"), a = (o = r(e, i)) != null ? o : i;
342
- for (const u of e)
343
- m(n, "(s, v) => s.add(v)", void 0, i, t(u)).dispose();
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
+ }
344
353
  return a;
345
354
  }
346
355
  }
347
- function me(n, e, t, r) {
356
+ function me(n, e, t, r, s = () => {
357
+ }) {
348
358
  var u;
349
359
  if (typeof e != "object" || e === null) return;
350
- const s = Array.isArray(e) ? n.newArray() : n.newObject(), o = (u = r(e, s)) != null ? u : s, i = Object.getPrototypeOf(e), a = i && i !== Object.prototype && i !== Array.prototype ? t(i) : void 0;
351
- return a && m(n, "Object.setPrototypeOf", void 0, o, a).dispose(), N(n, e, s, t), o;
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;
352
362
  }
353
363
  function _e(n, e) {
354
364
  switch (typeof e) {
@@ -367,45 +377,45 @@ function _e(n, e) {
367
377
  }
368
378
  }
369
379
  function ve(n, e, t, r) {
370
- var o;
380
+ var i;
371
381
  if (!(e instanceof Promise)) return;
372
382
  const s = n.newPromise();
373
383
  return e.then(
374
- (i) => s.resolve(t(i)),
375
- (i) => s.reject(t(i))
376
- ), (o = r(e, s)) != null ? o : s.handle;
384
+ (o) => s.resolve(t(o)),
385
+ (o) => s.reject(t(o))
386
+ ), (i = r(e, s)) != null ? i : s.handle;
377
387
  }
378
- function D(n, e) {
379
- var d, y, h, c, p, v, b;
380
- const { ctx: t, unmarshal: r, isMarshalable: s, find: o, pre: i } = e;
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;
381
391
  {
382
- const _ = _e(t, n);
383
- if (_)
384
- return _;
392
+ const w = _e(t, n);
393
+ if (w)
394
+ return typeof n == "bigint" && ((y = e.registerTransient) == null || y.call(e, w)), w;
385
395
  }
386
396
  {
387
- const _ = o(n);
388
- if (_) return _;
397
+ const w = i(n);
398
+ if (w) return w;
389
399
  }
390
- if ((d = e.marshalByReference) != null && d.call(e, n) && e.registerHostRef) {
391
- const _ = de(t, n, e.registerHostRef);
392
- if (_) return _;
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;
393
403
  }
394
- const a = s == null ? void 0 : s(n);
395
- if (a === !1)
404
+ const f = s == null ? void 0 : s(n);
405
+ if (f === !1)
396
406
  return t.undefined;
397
- const u = (_, g) => i(_, g, a);
398
- if (a === "json")
399
- return ye(t, n, u);
400
- const f = (_) => D(_, e);
401
- return (b = (v = (p = (c = (h = oe(t, n, u, [...fe, ...(y = e.custom) != null ? y : []])) != null ? h : ve(t, n, f, u)) != null ? c : le(t, n, f, r, u, e.preApply)) != null ? p : he(t, n, f, u)) != null ? v : me(t, n, f, u)) != null ? b : t.undefined;
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;
402
412
  }
403
413
  function be(n, e, t, r) {
404
- var o;
414
+ var i;
405
415
  let s;
406
- for (const i of r)
407
- if (s = i(e, n), s) break;
408
- return s ? (o = t(s, e)) != null ? o : s : void 0;
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;
409
419
  }
410
420
  function we(n, e) {
411
421
  if (e.typeof(n) !== "symbol") return;
@@ -413,19 +423,19 @@ function we(n, e) {
413
423
  return Symbol(t);
414
424
  }
415
425
  function ge(n, e) {
416
- if (!w(m(e, "a => a instanceof Date", void 0, n), (r) => e.dump(r))) return;
417
- const t = w(m(e, "a => a.getTime()", void 0, n), (r) => e.getNumber(r));
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));
418
428
  return new Date(t);
419
429
  }
420
430
  function je(n, e) {
421
- if (w(m(e, "a => a instanceof ArrayBuffer", void 0, n), (t) => e.dump(t))) {
431
+ if (g(m(e, "a => a instanceof ArrayBuffer", void 0, n), (t) => e.dump(t))) {
422
432
  const t = e.getArrayBuffer(n), r = t.value.slice();
423
433
  return t.dispose(), r.buffer;
424
434
  }
425
- if (w(m(e, "a => ArrayBuffer.isView(a)", void 0, n), (t) => e.dump(t))) {
426
- const t = w(
435
+ if (g(m(e, "a => ArrayBuffer.isView(a)", void 0, n), (t) => e.dump(t))) {
436
+ const t = g(
427
437
  m(e, "a => a.constructor.name", void 0, n),
428
- (a) => e.getString(a)
438
+ (f) => e.getString(f)
429
439
  ), r = globalThis[t];
430
440
  if (typeof r != "function") return;
431
441
  const s = m(
@@ -433,33 +443,33 @@ function je(n, e) {
433
443
  "a => a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength)",
434
444
  void 0,
435
445
  n
436
- ), o = e.getArrayBuffer(s), i = o.value.slice();
437
- return o.dispose(), s.dispose(), new r(i.buffer);
446
+ ), i = e.getArrayBuffer(s), o = i.value.slice();
447
+ return i.dispose(), s.dispose(), new r(o.buffer);
438
448
  }
439
449
  }
440
450
  const Pe = [we, ge, je];
441
- function U(n, e, t, r) {
442
- w(
443
- n.newFunction("", (s, o) => {
444
- const [i] = r(s);
445
- if (typeof i != "string" && typeof i != "number" && typeof i != "symbol")
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")
446
456
  return;
447
- const a = [
457
+ const f = [
448
458
  ["value", !0],
449
459
  ["get", !0],
450
460
  ["set", !0],
451
461
  ["configurable", !1],
452
462
  ["enumerable", !1],
453
463
  ["writable", !1]
454
- ].reduce((u, [f, d]) => {
455
- const y = n.getProp(o, f), h = n.typeof(y);
456
- if (h === "undefined") return u;
457
- if (!d && h === "boolean")
458
- return u[f] = n.dump(n.getProp(o, f)), u;
459
- const [c, p] = r(y);
460
- return p && y.dispose(), u[f] = c, u;
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;
461
471
  }, {});
462
- Object.defineProperty(t, i, a);
472
+ Object.defineProperty(t, o, f);
463
473
  }),
464
474
  (s) => {
465
475
  m(
@@ -477,26 +487,26 @@ function U(n, e, t, r) {
477
487
  );
478
488
  }
479
489
  function Se(n, e, t, r, s) {
480
- var a;
490
+ var f;
481
491
  if (n.typeof(e) !== "function") return;
482
- const o = function(...u) {
483
- return O(
484
- [t(this), ...u.map((f) => t(f))],
485
- (f, ...d) => {
492
+ const i = function(...a) {
493
+ return R(
494
+ [t(this), ...a.map((u) => t(u))],
495
+ (u, ...p) => {
486
496
  if (new.target) {
487
- const [p] = r(
488
- m(n, "(Cls, ...args) => new Cls(...args)", f, e, ...d)
497
+ const [d] = r(
498
+ m(n, "(Cls, ...args) => new Cls(...args)", u, e, ...p)
489
499
  );
490
- return Object.defineProperties(this, Object.getOwnPropertyDescriptors(p)), this;
500
+ return Object.defineProperties(this, Object.getOwnPropertyDescriptors(d)), this;
491
501
  }
492
- const y = S(n, n.callFunction(e, f, ...d)), [h, c] = r(y);
502
+ const y = T(n, n.callFunction(e, u, ...p)), [h, c] = r(y);
493
503
  return c && y.dispose(), h;
494
504
  }
495
505
  );
496
- }, i = (a = s(o, e)) != null ? a : o;
497
- return U(n, e, o, r), i;
506
+ }, o = (f = s(i, e)) != null ? f : i;
507
+ return V(n, e, i, r), o;
498
508
  }
499
- function V(n, e) {
509
+ function G(n, e) {
500
510
  const t = n.toHostRef(e);
501
511
  if (t)
502
512
  try {
@@ -506,31 +516,31 @@ function V(n, e) {
506
516
  }
507
517
  }
508
518
  function ke(n, e, t, r) {
509
- const s = w(m(n, "a => a instanceof Map", void 0, e), (u) => n.dump(u)), o = !s && w(m(n, "a => a instanceof Set", void 0, e), (u) => n.dump(u));
510
- if (!s && !o) return;
511
- const i = s ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
512
- r(i, e);
513
- const a = n.unwrapResult(n.getIterator(e));
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));
514
524
  try {
515
- for (const u of a) {
516
- const f = n.unwrapResult(u);
525
+ for (const a of f) {
526
+ const u = n.unwrapResult(a);
517
527
  if (s) {
518
- const d = n.getProp(f, 0), y = n.getProp(f, 1), [h, c] = t(d), [p, v] = t(y);
519
- c && d.dispose(), v && y.dispose(), i.set(h, p), f.dispose();
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();
520
530
  } else {
521
- const [d, y] = t(f);
522
- y && f.dispose(), i.add(d);
531
+ const [p, y] = t(u);
532
+ y && u.dispose(), o.add(p);
523
533
  }
524
534
  }
525
535
  } finally {
526
- a.alive && a.dispose();
536
+ f.alive && f.dispose();
527
537
  }
528
- return i;
538
+ return o;
529
539
  }
530
- function Re(n, e, t, r) {
531
- var a;
540
+ function Te(n, e, t, r) {
541
+ var f;
532
542
  if (n.typeof(e) !== "object" || n.sameValue(e, n.null)) return;
533
- const s = w(m(n, "Array.isArray", void 0, e), (u) => n.dump(u)) ? [] : {}, o = (a = r(s, e)) != null ? a : s, i = w(
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(
534
544
  m(
535
545
  n,
536
546
  `o => {
@@ -540,54 +550,54 @@ function Re(n, e, t, r) {
540
550
  void 0,
541
551
  e
542
552
  ),
543
- (u) => {
544
- if (n.typeof(u) === "undefined") return;
545
- const [f] = t(u);
546
- return f;
553
+ (a) => {
554
+ if (n.typeof(a) === "undefined") return;
555
+ const [u] = t(a);
556
+ return u;
547
557
  }
548
558
  );
549
- return typeof i == "object" && Object.setPrototypeOf(o, i), U(n, e, s, t), o;
559
+ return typeof o == "object" && Object.setPrototypeOf(i, o), V(n, e, s, t), i;
550
560
  }
551
- function Ee(n, e) {
561
+ function He(n, e) {
552
562
  const t = n.typeof(e);
553
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];
554
564
  }
555
- function Oe(n, e, t, r) {
556
- var f;
557
- if (!Te(n, e)) return;
558
- const s = pe(), [o, i] = t(s.resolve), [a, u] = t(s.reject);
559
- return m(n, "(p, res, rej) => { p.then(res, rej); }", void 0, e, o, a), i && o.dispose(), u && a.dispose(), (f = r(s.promise, e)) != null ? f : s.promise;
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;
560
570
  }
561
- function Te(n, e) {
562
- return e.owner ? n.unwrapResult(n.evalCode("Promise")).consume((t) => e.owner ? Z(n, e, t) : !1) : !1;
571
+ function Ee(n, e) {
572
+ return e.owner ? n.unwrapResult(n.evalCode("Promise")).consume((t) => e.owner ? x(n, e, t) : !1) : !1;
563
573
  }
564
- function He(n, e) {
565
- const [t] = G(n, e);
574
+ function Oe(n, e) {
575
+ const [t] = J(n, e);
566
576
  return t;
567
577
  }
568
- function G(n, e) {
569
- var d, y, h;
570
- const { ctx: t, marshal: r, find: s, pre: o } = e;
578
+ function J(n, e) {
579
+ var p, y, h;
580
+ const { ctx: t, marshal: r, find: s, pre: i } = e;
571
581
  {
572
- const [c, p] = Ee(t, n);
573
- if (p) return [c, !1];
582
+ const [c, d] = He(t, n);
583
+ if (d) return [c, !1];
574
584
  }
575
585
  {
576
586
  const c = s(n);
577
587
  if (c)
578
588
  return [c, !0];
579
589
  }
580
- const i = (c) => G(c, e);
590
+ const o = (c) => J(c, e);
581
591
  if (e.hostRef) {
582
- const c = V(t, n);
592
+ const c = G(t, n);
583
593
  if (c) return [c.value, !0];
584
594
  }
585
- const a = be(t, n, o, [...Pe, ...(d = e.custom) != null ? d : []]);
586
- if (a) return [a, !0];
587
- const u = ke(t, n, i, o);
588
- return u ? [u, !0] : [(h = (y = Oe(t, n, r, o)) != null ? y : Se(t, n, r, i, o)) != null ? h : Re(t, n, i, o), !1];
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];
589
599
  }
590
- class A {
600
+ class I {
591
601
  constructor(e) {
592
602
  l(this, "ctx");
593
603
  l(this, "_keyToId", /* @__PURE__ */ new Map());
@@ -632,14 +642,14 @@ class A {
632
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);
633
643
  }
634
644
  set(e, t, r, s) {
635
- var a;
645
+ var f;
636
646
  if (!t.alive || s && !s.alive) return !1;
637
- const o = (a = this.get(e)) != null ? a : this.get(r);
638
- if (o)
639
- return o === t || o === s;
640
- const i = this._nextId++;
641
- return this._keyToId.set(e, i), this._idToHandle.set(i, t), this._idToKey.set(i, e), r && (this._key2ToId.set(r, i), this._idToKey2.set(i, r), s && this._idToHandle2.set(i, s)), this.ctx.newNumber(i).consume((u) => {
642
- this._call(this._mapSet, void 0, t, u, s != null ? s : this.ctx.undefined);
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);
643
653
  }), !0;
644
654
  }
645
655
  merge(e) {
@@ -672,17 +682,17 @@ class A {
672
682
  return this._keyToId.keys();
673
683
  }
674
684
  delete(e, t) {
675
- var u;
676
- const r = (u = this._keyToId.get(e)) != null ? u : this._key2ToId.get(e);
685
+ var a;
686
+ const r = (a = this._keyToId.get(e)) != null ? a : this._key2ToId.get(e);
677
687
  if (typeof r == "undefined") return;
678
- const s = this._idToHandle.get(r), o = this._idToHandle2.get(r);
688
+ const s = this._idToHandle.get(r), i = this._idToHandle2.get(r);
679
689
  this._call(
680
690
  this._mapDelete,
681
691
  void 0,
682
- ...[s, o].filter((f) => !!(f != null && f.alive))
692
+ ...[s, i].filter((u) => !!(u != null && u.alive))
683
693
  );
684
- const i = this._idToKey.get(r), a = this._idToKey2.get(r);
685
- typeof i != "undefined" && this._keyToId.delete(i), typeof a != "undefined" && this._key2ToId.delete(a), this._idToHandle.delete(r), this._idToHandle2.delete(r), this._idToKey.delete(r), this._idToKey2.delete(r), t && (s != null && s.alive && s.dispose(), o != null && o.alive && o.dispose());
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());
686
696
  }
687
697
  deleteByHandle(e, t) {
688
698
  const r = this.getByHandle(e);
@@ -712,16 +722,16 @@ class A {
712
722
  if (t.done) return { value: void 0, done: !0 };
713
723
  const r = this._keyToId.get(t.value);
714
724
  if (typeof r == "undefined") continue;
715
- const s = this._idToHandle.get(r), o = this._idToHandle2.get(r);
725
+ const s = this._idToHandle.get(r), i = this._idToHandle2.get(r);
716
726
  if (!s) continue;
717
- const i = this._idToKey2.get(r);
718
- return { value: [t.value, s, i, o], done: !1 };
727
+ const o = this._idToKey2.get(r);
728
+ return { value: [t.value, s, o, i], done: !1 };
719
729
  }
720
730
  }
721
731
  };
722
732
  }
723
733
  _call(e, t, ...r) {
724
- return S(
734
+ return T(
725
735
  this.ctx,
726
736
  this.ctx.callFunction(
727
737
  e,
@@ -731,99 +741,99 @@ class A {
731
741
  );
732
742
  }
733
743
  }
734
- function Me(n, e, t, r, s, o, i, a = !0) {
735
- if (!P(e) || e instanceof Promise || e instanceof Date || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || e instanceof Map || e instanceof Set || i && !i(e))
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))
736
746
  return;
737
- if (Be(e, t) || !a) return e;
738
- const u = new Proxy(e, {
739
- get(f, d) {
740
- return d === t ? f : Reflect.get(f, d);
747
+ if (Be(e, t) || !f) return e;
748
+ const a = new Proxy(e, {
749
+ get(u, p) {
750
+ return p === t ? u : Reflect.get(u, p);
741
751
  },
742
- set(f, d, y, h) {
743
- var v;
744
- const c = j(y, t), p = (v = o == null ? void 0 : o(h)) != null ? v : "host";
745
- return p !== "vm" && !Reflect.set(f, d, c) || p === "host" || !n.alive || O(
746
- [s(h), s(d), s(c)],
747
- (b, _, g) => {
748
- const [R, E] = T(n, b, r);
749
- E ? R.consume((H) => n.setProp(H, _, g)) : n.setProp(R, _, g);
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);
750
760
  }
751
761
  ), !0;
752
762
  },
753
- deleteProperty(f, d) {
763
+ deleteProperty(u, p) {
754
764
  var h;
755
- const y = (h = o == null ? void 0 : o(u)) != null ? h : "host";
756
- return O([s(u), s(d)], (c, p) => {
757
- const [v, b] = T(n, c, r);
758
- if (y === "vm" || Reflect.deleteProperty(f, d)) {
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)) {
759
769
  if (y === "host" || !n.alive) return !0;
760
- b ? v.consume((_) => m(n, "(a, b) => delete a[b]", void 0, _, p)) : m(n, "(a, b) => delete a[b]", void 0, v, p);
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);
761
771
  }
762
772
  return !0;
763
773
  });
764
774
  },
765
- defineProperty(f, d, y) {
766
- var p;
767
- const h = (p = o == null ? void 0 : o(u)) != null ? p : "host", c = B({}, y);
768
- return "value" in c && (c.value = j(c.value, t)), typeof c.get == "function" && (c.get = j(c.get, t)), typeof c.set == "function" && (c.set = j(c.set, t)), h !== "vm" && !Reflect.defineProperty(f, d, c) ? !1 : (h === "host" || !n.alive || O(
769
- [s(u), s(d), s(c)],
770
- (v, b, _) => {
771
- const [g, R] = T(n, v, r), E = (H) => m(
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(
772
782
  n,
773
783
  "(o, k, d) => { Object.defineProperty(o, k, d); }",
774
784
  void 0,
775
- H,
776
- b,
777
- _
785
+ O,
786
+ v,
787
+ b
778
788
  ).dispose();
779
- R ? g.consume(E) : E(g);
789
+ w ? j.consume(k) : k(j);
780
790
  }
781
791
  ), !0);
782
792
  }
783
793
  });
784
- return u;
794
+ return a;
785
795
  }
786
- function Ce(n, e, t, r, s, o, i, a = !0) {
787
- if (!x(n, e) || i && !i(e, n))
796
+ function Ce(n, e, t, r, s, i, o, f = !0) {
797
+ if (!ee(n, e) || o && !o(e, n))
788
798
  return [void 0, !1];
789
- if (J(n, e, r)) return [e, !1];
790
- if (!a) return [e, !1];
791
- const u = (c) => {
792
- const p = o == null ? void 0 : o(s(c));
793
- return typeof p == "string" ? n.newString(p) : n.undefined;
794
- }, f = (c, p, v) => {
795
- const b = s(c);
796
- if (!b) return;
797
- const _ = s(p);
798
- if (_ === "__proto__") return;
799
- const g = s(v);
800
- j(b, t)[_] = g;
801
- }, d = (c, p) => {
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, _) => {
802
805
  const v = s(c);
803
806
  if (!v) return;
804
- const b = s(p);
805
- Reflect.deleteProperty(j(v, t), b);
806
- }, y = (c, p, v) => {
807
- const b = s(c);
808
- if (!b) return;
809
- const _ = s(p);
810
- if (_ === "__proto__") return;
811
- const g = s(v);
812
- Object.defineProperty(j(b, t), _, g);
813
- }, h = n.newFunction("proxyFuncs", (c, ...p) => {
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) => {
814
824
  switch (n.getNumber(c)) {
815
825
  case 1:
816
- return u(p[0]);
826
+ return a(d[0]);
817
827
  case 2:
818
- return f(p[0], p[1], p[2]);
828
+ return u(d[0], d[1], d[2]);
819
829
  case 3:
820
- return d(p[0], p[1]);
830
+ return p(d[0], d[1]);
821
831
  case 4:
822
- return y(p[0], p[1], p[2]);
832
+ return y(d[0], d[1], d[2]);
823
833
  }
824
834
  return n.undefined;
825
835
  });
826
- return w(h, (c) => [
836
+ return g(h, (c) => [
827
837
  m(
828
838
  n,
829
839
  `(target, sym, proxyFuncs) => {
@@ -872,17 +882,17 @@ function Ce(n, e, t, r, s, o, i, a = !0) {
872
882
  !0
873
883
  ]);
874
884
  }
875
- function j(n, e) {
885
+ function P(n, e) {
876
886
  var t;
877
- return P(n) && (t = n[e]) != null ? t : n;
887
+ return S(n) && (t = n[e]) != null ? t : n;
878
888
  }
879
- function T(n, e, t) {
880
- return J(n, e, t) ? [n.getProp(e, t), !0] : [e, !1];
889
+ function E(n, e, t) {
890
+ return W(n, e, t) ? [n.getProp(e, t), !0] : [e, !1];
881
891
  }
882
892
  function Be(n, e) {
883
- return P(n) && !!n[e];
893
+ return S(n) && !!n[e];
884
894
  }
885
- function J(n, e, t) {
895
+ function W(n, e, t) {
886
896
  return !!n.dump(
887
897
  m(
888
898
  n,
@@ -902,6 +912,14 @@ class Fe {
902
912
  l(this, "_map");
903
913
  l(this, "_registeredMap");
904
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());
905
923
  l(this, "_sync", /* @__PURE__ */ new Set());
906
924
  l(this, "_temporalSync", /* @__PURE__ */ new Set());
907
925
  l(this, "_symbol", /* @__PURE__ */ Symbol());
@@ -922,17 +940,27 @@ class Fe {
922
940
  return s || (this._map.set(r, t), t);
923
941
  });
924
942
  l(this, "_marshalFind", (e) => {
925
- var s, o, i;
943
+ var s, i, o;
926
944
  const t = this._unwrap(e);
927
- return (i = (o = (s = this._registeredMap.get(e)) != null ? s : t !== e ? this._registeredMap.get(t) : void 0) != null ? o : this._map.get(e)) != null ? i : t !== e ? this._map.get(t) : void 0;
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;
928
946
  });
929
947
  l(this, "_marshalPre", (e, t, r) => {
930
- var s;
931
- if (r !== "json")
932
- return (s = this._register(e, se(t), this._map)) == null ? void 0 : s[1];
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);
958
+ });
959
+ l(this, "_disposeTransient", (e) => {
960
+ this._transientHandles.delete(e) && e.alive && e.dispose();
933
961
  });
934
962
  l(this, "_marshalPreApply", (e, t, r) => {
935
- const s = P(t) ? this._unwrap(t) : void 0;
963
+ const s = S(t) ? this._unwrap(t) : void 0;
936
964
  s && this._temporalSync.add(s);
937
965
  try {
938
966
  return e.apply(t, r);
@@ -941,11 +969,11 @@ class Fe {
941
969
  }
942
970
  });
943
971
  l(this, "_marshal", (e) => {
944
- var i, a, u, f;
972
+ var o, f, a, u;
945
973
  const t = this._registeredMap.get(e);
946
974
  if (t)
947
975
  return [t, !1];
948
- const r = this._marshalByReference(e) ? this._unwrap(e) : (i = this._wrap(e)) != null ? i : e, s = D(r, {
976
+ const r = this._marshalByReference(e) ? this._unwrap(e) : (o = this._wrap(e)) != null ? o : e, s = U(r, {
949
977
  ctx: this.context,
950
978
  unmarshal: this._unmarshal,
951
979
  isMarshalable: this._isMarshalable,
@@ -953,36 +981,40 @@ class Fe {
953
981
  registerHostRef: this._registerHostRef,
954
982
  find: this._marshalFind,
955
983
  pre: this._marshalPre,
984
+ registerTransient: this._registerTransient,
985
+ disposeTransient: this._disposeTransient,
956
986
  preApply: this._marshalPreApply,
957
- custom: (a = this._options) == null ? void 0 : a.customMarshaller
958
- }), o = (f = (u = this._options) == null ? void 0 : u.syncEnabled) != null ? f : !0;
959
- return [s, !o || !this._map.hasHandle(s)];
987
+ custom: (f = this._options) == null ? void 0 : f.customMarshaller
988
+ });
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)];
960
992
  });
961
993
  l(this, "_preUnmarshal", (e, t) => {
962
- var r, s, o;
963
- return (o = this._register(e, t, void 0, (s = (r = this._options) == null ? void 0 : r.syncEnabled) != null ? s : !0)) == null ? void 0 : o[0];
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];
964
996
  });
965
997
  l(this, "_unmarshalFind", (e) => {
966
998
  var t;
967
999
  return (t = this._registeredMap.getByHandle(e)) != null ? t : this._map.getByHandle(e);
968
1000
  });
969
1001
  l(this, "_unmarshal", (e) => {
970
- var s, o, i;
1002
+ var s, i, o;
971
1003
  const t = this._registeredMap.getByHandle(e);
972
1004
  if (typeof t != "undefined")
973
1005
  return t;
974
1006
  if ((s = this._options) != null && s.marshalByReference) {
975
- const a = V(this.context, e);
976
- if (a) return a.value;
1007
+ const f = G(this.context, e);
1008
+ if (f) return f.value;
977
1009
  }
978
1010
  const [r] = this._wrapHandle(e);
979
- return He(r != null ? r : e, {
1011
+ return Oe(r != null ? r : e, {
980
1012
  ctx: this.context,
981
1013
  marshal: this._marshal,
982
1014
  find: this._unmarshalFind,
983
1015
  pre: this._preUnmarshal,
984
- custom: (o = this._options) == null ? void 0 : o.customUnmarshaller,
985
- hostRef: !!((i = this._options) != null && i.marshalByReference)
1016
+ custom: (i = this._options) == null ? void 0 : i.customUnmarshaller,
1017
+ hostRef: !!((o = this._options) != null && o.marshalByReference)
986
1018
  });
987
1019
  });
988
1020
  l(this, "_syncMode", (e) => {
@@ -997,14 +1029,16 @@ class Fe {
997
1029
  t != null && t.compat && !("runtime" in e) && (e.runtime = {
998
1030
  hasPendingJob: () => e.hasPendingJob(),
999
1031
  executePendingJobs: (s) => e.executePendingJobs(s)
1000
- }), this.context = t != null && t.experimentalContextEx ? L(e) : e, X(this.context), this._options = t, this._symbolHandle = e.unwrapResult(e.evalCode("Symbol()")), this._map = new A(e), this._registeredMap = new A(e), this.registerAll((r = t == null ? void 0 : t.registeredObjects) != null ? r : q);
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);
1001
1033
  }
1002
1034
  /**
1003
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.
1004
1036
  */
1005
1037
  dispose() {
1006
1038
  var e, t;
1007
- this._map.dispose(), this._registeredMap.dispose(), this._symbolHandle.dispose(), Y(this.context), (t = (e = this.context).disposeEx) == null || t.call(e);
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);
1008
1042
  }
1009
1043
  /** Allows `using arena = new Arena(...)` to dispose the arena automatically. */
1010
1044
  [Symbol.dispose]() {
@@ -1060,7 +1094,7 @@ class Fe {
1060
1094
  const t = this.context.runtime.executePendingJobs(e);
1061
1095
  if ("value" in t)
1062
1096
  return t.value;
1063
- throw this._unwrapIfNotSynced(w(t.error, this._unmarshal));
1097
+ throw this._unwrapIfNotSynced(g(t.error, this._unmarshal));
1064
1098
  }
1065
1099
  /**
1066
1100
  * Set the max memory this runtime can allocate.
@@ -1155,7 +1189,7 @@ class Fe {
1155
1189
  */
1156
1190
  expose(e) {
1157
1191
  for (const [t, r] of Object.entries(e))
1158
- ne(this._marshal(r), (s) => {
1192
+ re(this._marshal(r), (s) => {
1159
1193
  this.context.setProp(this.context.global, t, s);
1160
1194
  });
1161
1195
  }
@@ -1166,7 +1200,7 @@ class Fe {
1166
1200
  */
1167
1201
  sync(e) {
1168
1202
  const t = this._wrap(e);
1169
- return typeof t == "undefined" ? e : (I(t, (r) => {
1203
+ return typeof t == "undefined" ? e : (N(t, (r) => {
1170
1204
  const s = this._unwrap(r);
1171
1205
  this._sync.add(s);
1172
1206
  }), t);
@@ -1202,7 +1236,7 @@ class Fe {
1202
1236
  this.unregister(r, t);
1203
1237
  }
1204
1238
  startSync(e) {
1205
- if (!P(e)) return;
1239
+ if (!S(e)) return;
1206
1240
  const t = this._unwrap(e);
1207
1241
  this._sync.add(t);
1208
1242
  }
@@ -1212,24 +1246,24 @@ class Fe {
1212
1246
  _unwrapResult(e) {
1213
1247
  if ("value" in e)
1214
1248
  return e.value;
1215
- throw this._unwrapIfNotSynced(w(e.error, this._unmarshal));
1249
+ throw this._unwrapIfNotSynced(g(e.error, this._unmarshal));
1216
1250
  }
1217
1251
  _unwrapResultAndUnmarshal(e) {
1218
1252
  if (e)
1219
- return this._unwrapIfNotSynced(w(this._unwrapResult(e), this._unmarshal));
1253
+ return this._unwrapIfNotSynced(g(this._unwrapResult(e), this._unmarshal));
1220
1254
  }
1221
1255
  _register(e, t, r = this._map, s) {
1222
1256
  if (this._registeredMap.has(e) || this._registeredMap.hasHandle(t))
1223
1257
  return;
1224
- let o = this._wrap(e);
1225
- const [i] = this._wrapHandle(t), a = e instanceof Promise;
1226
- if (!i || !o && !a) return;
1227
- a && (o = e);
1228
- const u = this._unwrap(e), [f, d] = this._unwrapHandle(t);
1229
- if (r.set(o, i, u, f))
1230
- s && this._sync.add(u);
1231
- else throw d && f.dispose(), new Error("already registered");
1232
- return [o, i];
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];
1233
1267
  }
1234
1268
  _wrap(e) {
1235
1269
  var t, r, s;
@@ -1245,7 +1279,7 @@ class Fe {
1245
1279
  );
1246
1280
  }
1247
1281
  _unwrap(e) {
1248
- return j(e, this._symbol);
1282
+ return P(e, this._symbol);
1249
1283
  }
1250
1284
  _wrapHandle(e) {
1251
1285
  var t, r, s;
@@ -1261,7 +1295,7 @@ class Fe {
1261
1295
  );
1262
1296
  }
1263
1297
  _unwrapHandle(e) {
1264
- return T(this.context, e, this._symbolHandle);
1298
+ return E(this.context, e, this._symbolHandle);
1265
1299
  }
1266
1300
  }
1267
1301
  class Ne extends Fe {
@@ -1276,7 +1310,7 @@ class Ne extends Fe {
1276
1310
  * evaluation. Use this when the code awaits host-provided promises.
1277
1311
  */
1278
1312
  evalCodeAsync(t, r) {
1279
- return F(this, null, function* () {
1313
+ return A(this, null, function* () {
1280
1314
  const s = yield this.asyncContext.evalCodeAsync(t, r);
1281
1315
  return this._unwrapResultAndUnmarshal(s);
1282
1316
  });
@@ -1285,16 +1319,16 @@ class Ne extends Fe {
1285
1319
  export {
1286
1320
  Fe as Arena,
1287
1321
  Ne as AsyncArena,
1288
- A as VMMap,
1322
+ I as VMMap,
1289
1323
  m as call,
1290
1324
  Ie as complexity,
1291
- te as consumeAll,
1292
- q as defaultRegisteredObjects,
1325
+ ne as consumeAll,
1326
+ Q as defaultRegisteredObjects,
1293
1327
  ce as isES2015Class,
1294
- x as isHandleObject,
1295
- P as isObject,
1296
- ee as json,
1297
- D as marshal,
1298
- He as unmarshal,
1299
- I as walkObject
1328
+ ee as isHandleObject,
1329
+ S as isObject,
1330
+ te as json,
1331
+ U as marshal,
1332
+ Oe as unmarshal,
1333
+ N as walkObject
1300
1334
  };