quickjs-emscripten-sync 1.9.0 → 1.10.0

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 CHANGED
@@ -402,6 +402,15 @@ Only the `set`, `deleteProperty`, and `defineProperty` operations on objects are
402
402
 
403
403
  `Date`, `Map`, `Set`, `ArrayBuffer`, and typed arrays are marshalled by value (a snapshot copy is created on the other side). They are not proxied, so later mutations are not synchronized, and self-referential `Map`/`Set` are not supported.
404
404
 
405
+ ### `this` on plain calls
406
+
407
+ When an exposed host function is called plainly from the VM (`fn()`, not `obj.fn()`), the host function receives `this === undefined`. This differs from plain JavaScript, where a non-strict function called this way would see `this === globalThis`. The VM global object is intentionally **not** marshalled to the host: doing so would eagerly deep-copy the entire global graph on the first call and would leak `globalThis` across the boundary. Method calls are unaffected — `obj.fn()` still receives `obj` as `this`.
408
+
409
+ ```js
410
+ arena.expose({ whoAmI() { return this; } });
411
+ arena.evalCode(`whoAmI()`); // undefined (not globalThis)
412
+ ```
413
+
405
414
  ## License
406
415
 
407
416
  [MIT License](LICENSE)
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare class Arena {
14
14
  _map: VMMap;
15
15
  _registeredMap: VMMap;
16
16
  _registeredMapDispose: Set<any>;
17
+ _transientHandles: Set<QuickJSHandle>;
17
18
  _sync: Set<any>;
18
19
  _temporalSync: Set<any>;
19
20
  _symbol: symbol;
@@ -206,8 +207,11 @@ export declare class Arena {
206
207
  _registerHostRef: (t: unknown, handle: QuickJSHandle) => QuickJSHandle;
207
208
  _marshalFind: (t: unknown) => QuickJSHandle | undefined;
208
209
  _marshalPre: (t: unknown, h: QuickJSHandle | QuickJSDeferredPromise, mode: true | "json" | undefined) => Wrapped<QuickJSHandle> | undefined;
210
+ _registerTransient: (handle: QuickJSHandle) => void;
211
+ _disposeTransient: (handle: QuickJSHandle) => void;
209
212
  _marshalPreApply: (target: (...args: any[]) => any, that: unknown, args: unknown[]) => void;
210
213
  _marshal: (target: any) => [QuickJSHandle, boolean];
214
+ _prepareMarshalReturn: (h: QuickJSHandle) => QuickJSHandle;
211
215
  _preUnmarshal: (t: any, h: QuickJSHandle) => Wrapped<any>;
212
216
  _unmarshalFind: (h: QuickJSHandle) => unknown;
213
217
  _unmarshal: (handle: QuickJSHandle) => any;
@@ -296,8 +300,11 @@ declare type Options_2 = {
296
300
  marshalByReference?: (target: unknown) => boolean;
297
301
  registerHostRef?: (target: unknown, handle: QuickJSHandle) => QuickJSHandle;
298
302
  find: (target: unknown) => QuickJSHandle | undefined;
303
+ registerTransient?: (handle: QuickJSHandle) => void;
304
+ disposeTransient?: (handle: QuickJSHandle) => void;
299
305
  pre: (target: unknown, handle: QuickJSHandle | QuickJSDeferredPromise, mode: true | "json" | undefined) => QuickJSHandle | undefined;
300
306
  preApply?: (target: (...args: any[]) => any, thisArg: unknown, args: unknown[]) => any;
307
+ prepareReturn?: (handle: QuickJSHandle) => QuickJSHandle;
301
308
  custom?: Iterable<(obj: unknown, ctx: QuickJSContext) => QuickJSHandle | undefined>;
302
309
  };
303
310