quickjs-emscripten-sync 1.9.1 → 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
@@ -211,6 +211,7 @@ export declare class Arena {
211
211
  _disposeTransient: (handle: QuickJSHandle) => void;
212
212
  _marshalPreApply: (target: (...args: any[]) => any, that: unknown, args: unknown[]) => void;
213
213
  _marshal: (target: any) => [QuickJSHandle, boolean];
214
+ _prepareMarshalReturn: (h: QuickJSHandle) => QuickJSHandle;
214
215
  _preUnmarshal: (t: any, h: QuickJSHandle) => Wrapped<any>;
215
216
  _unmarshalFind: (h: QuickJSHandle) => unknown;
216
217
  _unmarshal: (handle: QuickJSHandle) => any;
@@ -303,6 +304,7 @@ declare type Options_2 = {
303
304
  disposeTransient?: (handle: QuickJSHandle) => void;
304
305
  pre: (target: unknown, handle: QuickJSHandle | QuickJSDeferredPromise, mode: true | "json" | undefined) => QuickJSHandle | undefined;
305
306
  preApply?: (target: (...args: any[]) => any, thisArg: unknown, args: unknown[]) => any;
307
+ prepareReturn?: (handle: QuickJSHandle) => QuickJSHandle;
306
308
  custom?: Iterable<(obj: unknown, ctx: QuickJSContext) => QuickJSHandle | undefined>;
307
309
  };
308
310