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AAG,EAAmD,CAAA;YAClE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;SAC/B;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACjC,CAAC;IAiDO,aAAa,CAAC,KAA4B;QAChD,IAAI,KAAK,YAAY,mBAAQ,EAAE;YAC7B,OAAO,KAAK,CAAA;SACb;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC7B,CAAC;CACF;AA5xBD,wCA4xBC","sourcesContent":["import { debugLog } from \"./debug\"\nimport { QuickJSDeferredPromise } from \"./deferred-promise\"\nimport type { EitherModule } from \"./emscripten-types\"\nimport { QuickJSUnwrapError } from \"./errors\"\nimport {\n EvalDetectModule,\n EvalFlags,\n JSBorrowedCharPointer,\n JSContextPointer,\n JSModuleDefPointer,\n JSRuntimePointer,\n JSValueConstPointer,\n JSValuePointer,\n JSValuePointerPointer,\n JSVoidPointer,\n} from \"./types-ffi\"\nimport { Disposable, Lifetime, Scope, StaticLifetime, WeakLifetime } from \"./lifetime\"\nimport { ModuleMemory } from \"./memory\"\nimport { ContextCallbacks, QuickJSModuleCallbacks } from \"./module\"\nimport { QuickJSRuntime } from \"./runtime\"\nimport {\n ContextEvalOptions,\n EitherFFI,\n evalOptionsToFlags,\n JSValue,\n PromiseExecutor,\n QuickJSHandle,\n} from \"./types\"\nimport {\n LowLevelJavascriptVm,\n SuccessOrFail,\n VmCallResult,\n VmFunctionImplementation,\n VmPropertyDescriptor,\n} from \"./vm-interface\"\n\n/**\n * Property key for getting or setting a property on a handle with\n * [[QuickJSContext.getProp]], [[QuickJSContext.setProp]], or [[QuickJSContext.defineProp]].\n */\nexport type QuickJSPropertyKey = number | string | QuickJSHandle\n\n/**\n * @private\n */\nclass ContextMemory extends ModuleMemory implements Disposable {\n readonly owner: QuickJSRuntime\n readonly ctx: Lifetime<JSContextPointer>\n readonly rt: Lifetime<JSRuntimePointer>\n readonly module: EitherModule\n readonly ffi: EitherFFI\n readonly scope = new Scope()\n\n /** @private */\n constructor(args: {\n owner: QuickJSRuntime\n module: EitherModule\n ffi: EitherFFI\n ctx: Lifetime<JSContextPointer>\n rt: Lifetime<JSRuntimePointer>\n ownedLifetimes?: Disposable[]\n }) {\n super(args.module)\n args.ownedLifetimes?.forEach((lifetime) => this.scope.manage(lifetime))\n this.owner = args.owner\n this.module = args.module\n this.ffi = args.ffi\n this.rt = args.rt\n this.ctx = this.scope.manage(args.ctx)\n }\n\n get alive() {\n return this.scope.alive\n }\n\n dispose() {\n return this.scope.dispose()\n }\n\n /**\n * Track `lifetime` so that it is disposed when this scope is disposed.\n */\n manage<T extends Disposable>(lifetime: T): T {\n return this.scope.manage(lifetime)\n }\n\n copyJSValue = (ptr: JSValuePointer | JSValueConstPointer) => {\n return this.ffi.QTS_DupValuePointer(this.ctx.value, ptr)\n }\n\n freeJSValue = (ptr: JSValuePointer) => {\n this.ffi.QTS_FreeValuePointer(this.ctx.value, ptr)\n }\n\n consumeJSCharPointer(ptr: JSBorrowedCharPointer): string {\n const str = this.module.UTF8ToString(ptr)\n this.ffi.QTS_FreeCString(this.ctx.value, ptr)\n return str\n }\n\n heapValueHandle(ptr: JSValuePointer): JSValue {\n return new Lifetime(ptr, this.copyJSValue, this.freeJSValue, this.owner)\n }\n}\n\n/**\n * QuickJSContext wraps a QuickJS Javascript context (JSContext*) within a\n * runtime. The contexts within the same runtime may exchange objects freely.\n * You can think of separate runtimes like different domains in a browser, and\n * the contexts within a runtime like the different windows open to the same\n * domain. The {@link runtime} references the context's runtime.\n *\n * This class's methods return {@link QuickJSHandle}, which wrap C pointers (JSValue*).\n * It's the caller's responsibility to call `.dispose()` on any\n * handles you create to free memory once you're done with the handle.\n *\n * Use {@link QuickJSRuntime.newContext} or {@link QuickJSWASMModule.newContext}\n * to create a new QuickJSContext.\n *\n * Create QuickJS values inside the interpreter with methods like\n * [[newNumber]], [[newString]], [[newArray]], [[newObject]],\n * [[newFunction]], and [[newPromise]].\n *\n * Call [[setProp]] or [[defineProp]] to customize objects. Use those methods\n * with [[global]] to expose the values you create to the interior of the\n * interpreter, so they can be used in [[evalCode]].\n *\n * Use [[evalCode]] or [[callFunction]] to execute Javascript inside the VM. If\n * you're using asynchronous code inside the QuickJSContext, you may need to also\n * call [[executePendingJobs]]. Executing code inside the runtime returns a\n * result object representing successful execution or an error. You must dispose\n * of any such results to avoid leaking memory inside the VM.\n *\n * Implement memory and CPU constraints at the runtime level, using [[runtime]].\n * See {@link QuickJSRuntime} for more information.\n *\n */\n// TODO: Manage own callback registration\nexport class QuickJSContext implements LowLevelJavascriptVm<QuickJSHandle>, Disposable {\n /**\n * The runtime that created this context.\n */\n public readonly runtime: QuickJSRuntime\n\n /** @private */\n protected readonly ctx: Lifetime<JSContextPointer>\n /** @private */\n protected readonly rt: Lifetime<JSRuntimePointer>\n /** @private */\n protected readonly module: EitherModule\n /** @private */\n protected readonly ffi: EitherFFI\n /** @private */\n protected memory: ContextMemory\n\n /** @private */\n protected _undefined: QuickJSHandle | undefined = undefined\n /** @private */\n protected _null: QuickJSHandle | undefined = undefined\n /** @private */\n protected _false: QuickJSHandle | undefined = undefined\n /** @private */\n protected _true: QuickJSHandle | undefined = undefined\n /** @private */\n protected _global: QuickJSHandle | undefined = undefined\n /** @private */\n protected _BigInt: QuickJSHandle | undefined = undefined\n\n /**\n * Use {@link QuickJS.createVm} to create a QuickJSContext instance.\n */\n constructor(args: {\n module: EitherModule\n ffi: EitherFFI\n ctx: Lifetime<JSContextPointer>\n rt: Lifetime<JSRuntimePointer>\n runtime: QuickJSRuntime\n ownedLifetimes?: Disposable[]\n callbacks: QuickJSModuleCallbacks\n }) {\n this.runtime = args.runtime\n this.module = args.module\n this.ffi = args.ffi\n this.rt = args.rt\n this.ctx = args.ctx\n this.memory = new ContextMemory({\n ...args,\n owner: this.runtime,\n })\n args.callbacks.setContextCallbacks(this.ctx.value, this.cToHostCallbacks)\n this.dump = this.dump.bind(this)\n this.getString = this.getString.bind(this)\n this.getNumber = this.getNumber.bind(this)\n this.resolvePromise = this.resolvePromise.bind(this)\n }\n\n // @implement Disposable ----------------------------------------------------\n\n get alive() {\n return this.memory.alive\n }\n\n /**\n * Dispose of this VM's underlying resources.\n *\n * @throws Calling this method without disposing of all created handles\n * will result in an error.\n */\n dispose() {\n this.memory.dispose()\n }\n\n // Globals ------------------------------------------------------------------\n\n /**\n * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined).\n */\n get undefined(): QuickJSHandle {\n if (this._undefined) {\n return this._undefined\n }\n\n // Undefined is a constant, immutable value in QuickJS.\n const ptr = this.ffi.QTS_GetUndefined()\n return (this._undefined = new StaticLifetime(ptr))\n }\n\n /**\n * [`null`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null).\n */\n get null(): QuickJSHandle {\n if (this._null) {\n return this._null\n }\n\n // Null is a constant, immutable value in QuickJS.\n const ptr = this.ffi.QTS_GetNull()\n return (this._null = new StaticLifetime(ptr))\n }\n\n /**\n * [`true`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/true).\n */\n get true(): QuickJSHandle {\n if (this._true) {\n return this._true\n }\n\n // True is a constant, immutable value in QuickJS.\n const ptr = this.ffi.QTS_GetTrue()\n return (this._true = new StaticLifetime(ptr))\n }\n\n /**\n * [`false`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/false).\n */\n get false(): QuickJSHandle {\n if (this._false) {\n return this._false\n }\n\n // False is a constant, immutable value in QuickJS.\n const ptr = this.ffi.QTS_GetFalse()\n return (this._false = new StaticLifetime(ptr))\n }\n\n /**\n * [`global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects).\n * A handle to the global object inside the interpreter.\n * You can set properties to create global variables.\n */\n get global(): QuickJSHandle {\n if (this._global) {\n return this._global\n }\n\n // The global is a JSValue, but since it's lifetime is as long as the VM's,\n // we should manage it.\n const ptr = this.ffi.QTS_GetGlobalObject(this.ctx.value)\n\n // Automatically clean up this reference when we dispose\n this.memory.manage(this.memory.heapValueHandle(ptr))\n\n // This isn't technically a static lifetime, but since it has the same\n // lifetime as the VM, it's okay to fake one since when the VM is\n // disposed, no other functions will accept the value.\n this._global = new StaticLifetime(ptr, this.runtime)\n return this._global\n }\n\n // New values ---------------------------------------------------------------\n\n /**\n * Converts a Javascript number into a QuickJS value.\n */\n newNumber(num: number): QuickJSHandle {\n return this.memory.heapValueHandle(this.ffi.QTS_NewFloat64(this.ctx.value, num))\n }\n\n /**\n * Create a QuickJS [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) value.\n */\n newString(str: string): QuickJSHandle {\n const ptr = this.memory\n .newHeapCharPointer(str)\n .consume((charHandle) => this.ffi.QTS_NewString(this.ctx.value, charHandle.value))\n return this.memory.heapValueHandle(ptr)\n }\n\n /**\n * Create a QuickJS [symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) value.\n * No two symbols created with this function will be the same value.\n */\n newUniqueSymbol(description: string | symbol): QuickJSHandle {\n const key = (typeof description === \"symbol\" ? description.description : description) ?? \"\"\n const ptr = this.memory\n .newHeapCharPointer(key)\n .consume((charHandle) => this.ffi.QTS_NewSymbol(this.ctx.value, charHandle.value, 0))\n return this.memory.heapValueHandle(ptr)\n }\n\n /**\n * Get a symbol from the [global registry](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#shared_symbols_in_the_global_symbol_registry) for the given key.\n * All symbols created with the same key will be the same value.\n */\n newSymbolFor(key: string | symbol): QuickJSHandle {\n const description = (typeof key === \"symbol\" ? key.description : key) ?? \"\"\n const ptr = this.memory\n .newHeapCharPointer(description)\n .consume((charHandle) => this.ffi.QTS_NewSymbol(this.ctx.value, charHandle.value, 1))\n return this.memory.heapValueHandle(ptr)\n }\n\n /**\n * Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) value.\n */\n newBigInt(num: bigint): QuickJSHandle {\n if (!this._BigInt) {\n const bigIntHandle = this.getProp(this.global, \"BigInt\")\n this.memory.manage(bigIntHandle)\n this._BigInt = new StaticLifetime(bigIntHandle.value as JSValueConstPointer, this.runtime)\n }\n\n const bigIntHandle = this._BigInt\n const asString = String(num)\n return this.newString(asString).consume((handle) =>\n this.unwrapResult(this.callFunction(bigIntHandle, this.undefined, handle))\n )\n }\n\n /**\n * `{}`.\n * Create a new QuickJS [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer).\n *\n * @param prototype - Like [`Object.create`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create).\n */\n newObject(prototype?: QuickJSHandle): QuickJSHandle {\n if (prototype) {\n this.runtime.assertOwned(prototype)\n }\n const ptr = prototype\n ? this.ffi.QTS_NewObjectProto(this.ctx.value, prototype.value)\n : this.ffi.QTS_NewObject(this.ctx.value)\n return this.memory.heapValueHandle(ptr)\n }\n\n /**\n * `[]`.\n * Create a new QuickJS [array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).\n */\n newArray(): QuickJSHandle {\n const ptr = this.ffi.QTS_NewArray(this.ctx.value)\n return this.memory.heapValueHandle(ptr)\n }\n\n /**\n * Create a new [[QuickJSDeferredPromise]]. Use `deferred.resolve(handle)` and\n * `deferred.reject(handle)` to fulfill the promise handle available at `deferred.handle`.\n * Note that you are responsible for calling `deferred.dispose()` to free the underlying\n * resources; see the documentation on [[QuickJSDeferredPromise]] for details.\n */\n newPromise(): QuickJSDeferredPromise\n /**\n * Create a new [[QuickJSDeferredPromise]] that resolves when the\n * given native Promise<QuickJSHandle> resolves. Rejections will be coerced\n * to a QuickJS error.\n *\n * You can still resolve/reject the created promise \"early\" using its methods.\n */\n newPromise(promise: Promise<QuickJSHandle>): QuickJSDeferredPromise\n /**\n * Construct a new native Promise<QuickJSHandle>, and then convert it into a\n * [[QuickJSDeferredPromise]].\n *\n * You can still resolve/reject the created promise \"early\" using its methods.\n */\n newPromise(\n newPromiseFn: PromiseExecutor<QuickJSHandle, Error | QuickJSHandle>\n ): QuickJSDeferredPromise\n newPromise(\n value?: PromiseExecutor<QuickJSHandle, Error | QuickJSHandle> | Promise<QuickJSHandle>\n ): QuickJSDeferredPromise {\n const deferredPromise = Scope.withScope((scope) => {\n const mutablePointerArray = scope.manage(\n this.memory.newMutablePointerArray<JSValuePointerPointer>(2)\n )\n const promisePtr = this.ffi.QTS_NewPromiseCapability(\n this.ctx.value,\n mutablePointerArray.value.ptr\n )\n const promiseHandle = this.memory.heapValueHandle(promisePtr)\n const [resolveHandle, rejectHandle] = Array.from(mutablePointerArray.value.typedArray).map(\n (jsvaluePtr) => this.memory.heapValueHandle(jsvaluePtr as any)\n )\n return new QuickJSDeferredPromise({\n context: this,\n promiseHandle,\n resolveHandle,\n rejectHandle,\n })\n })\n\n if (value && typeof value === \"function\") {\n value = new Promise(value)\n }\n\n if (value) {\n Promise.resolve(value).then(deferredPromise.resolve, (error) =>\n error instanceof Lifetime\n ? deferredPromise.reject(error)\n : this.newError(error).consume(deferredPromise.reject)\n )\n }\n\n return deferredPromise\n }\n\n /**\n * Convert a Javascript function into a QuickJS function value.\n * See [[VmFunctionImplementation]] for more details.\n *\n * A [[VmFunctionImplementation]] should not free its arguments or its return\n * value. A VmFunctionImplementation should also not retain any references to\n * its return value.\n *\n * To implement an async function, create a promise with [[newPromise]], then\n * return the deferred promise handle from `deferred.handle` from your\n * function implementation:\n *\n * ```\n * const deferred = vm.newPromise()\n * someNativeAsyncFunction().then(deferred.resolve)\n * return deferred.handle\n * ```\n */\n newFunction(name: string, fn: VmFunctionImplementation<QuickJSHandle>): QuickJSHandle {\n const fnId = ++this.fnNextId\n this.setFunction(fnId, fn)\n return this.memory.heapValueHandle(this.ffi.QTS_NewFunction(this.ctx.value, fnId, name))\n }\n\n newError(error: { name: string; message: string }): QuickJSHandle\n newError(message: string): QuickJSHandle\n newError(): QuickJSHandle\n newError(error?: string | { name: string; message: string }): QuickJSHandle {\n const errorHandle = this.memory.heapValueHandle(this.ffi.QTS_NewError(this.ctx.value))\n\n if (error && typeof error === \"object\") {\n if (error.name !== undefined) {\n this.newString(error.name).consume((handle) => this.setProp(errorHandle, \"name\", handle))\n }\n\n if (error.message !== undefined) {\n this.newString(error.message).consume((handle) =>\n this.setProp(errorHandle, \"message\", handle)\n )\n }\n } else if (typeof error === \"string\") {\n this.newString(error).consume((handle) => this.setProp(errorHandle, \"message\", handle))\n } else if (error !== undefined) {\n // This isn't supported in the type signature but maybe it will make life easier.\n this.newString(String(error)).consume((handle) =>\n this.setProp(errorHandle, \"message\", handle)\n )\n }\n\n return errorHandle\n }\n\n // Read values --------------------------------------------------------------\n\n /**\n * `typeof` operator. **Not** [standards compliant](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof).\n *\n * @remarks\n * Does not support BigInt values correctly.\n */\n typeof(handle: QuickJSHandle) {\n this.runtime.assertOwned(handle)\n return this.memory.consumeHeapCharPointer(this.ffi.QTS_Typeof(this.ctx.value, handle.value))\n }\n\n /**\n * Converts `handle` into a Javascript number.\n * @returns `NaN` on error, otherwise a `number`.\n */\n getNumber(handle: QuickJSHandle): number {\n this.runtime.assertOwned(handle)\n return this.ffi.QTS_GetFloat64(this.ctx.value, handle.value)\n }\n\n /**\n * Converts `handle` to a Javascript string.\n */\n getString(handle: QuickJSHandle): string {\n this.runtime.assertOwned(handle)\n return this.memory.consumeJSCharPointer(this.ffi.QTS_GetString(this.ctx.value, handle.value))\n }\n\n /**\n * Converts `handle` into a Javascript symbol. If the symbol is in the global\n * registry in the guest, it will be created with Symbol.for on the host.\n */\n getSymbol(handle: QuickJSHandle): symbol {\n this.runtime.assertOwned(handle)\n const key = this.memory.consumeJSCharPointer(\n this.ffi.QTS_GetSymbolDescriptionOrKey(this.ctx.value, handle.value)\n )\n const isGlobal = this.ffi.QTS_IsGlobalSymbol(this.ctx.value, handle.value)\n return isGlobal ? Symbol.for(key) : Symbol(key)\n }\n\n /**\n * Converts `handle` to a Javascript bigint.\n */\n getBigInt(handle: QuickJSHandle): bigint {\n this.runtime.assertOwned(handle)\n const asString = this.getString(handle)\n return BigInt(asString)\n }\n\n /**\n * `Promise.resolve(value)`.\n * Convert a handle containing a Promise-like value inside the VM into an\n * actual promise on the host.\n *\n * @remarks\n * You may need to call [[executePendingJobs]] to ensure that the promise is resolved.\n *\n * @param promiseLikeHandle - A handle to a Promise-like value with a `.then(onSuccess, onError)` method.\n */\n resolvePromise(promiseLikeHandle: QuickJSHandle): Promise<VmCallResult<QuickJSHandle>> {\n this.runtime.assertOwned(promiseLikeHandle)\n const vmResolveResult = Scope.withScope((scope) => {\n const vmPromise = scope.manage(this.getProp(this.global, \"Promise\"))\n const vmPromiseResolve = scope.manage(this.getProp(vmPromise, \"resolve\"))\n return this.callFunction(vmPromiseResolve, vmPromise, promiseLikeHandle)\n })\n if (vmResolveResult.error) {\n return Promise.resolve(vmResolveResult)\n }\n\n return new Promise<VmCallResult<QuickJSHandle>>((resolve) => {\n Scope.withScope((scope) => {\n const resolveHandle = scope.manage(\n this.newFunction(\"resolve\", (value) => {\n resolve({ value: value && value.dup() })\n })\n )\n\n const rejectHandle = scope.manage(\n this.newFunction(\"reject\", (error) => {\n resolve({ error: error && error.dup() })\n })\n )\n\n const promiseHandle = scope.manage(vmResolveResult.value)\n const promiseThenHandle = scope.manage(this.getProp(promiseHandle, \"then\"))\n this.unwrapResult(\n this.callFunction(promiseThenHandle, promiseHandle, resolveHandle, rejectHandle)\n ).dispose()\n })\n })\n }\n\n // Properties ---------------------------------------------------------------\n\n /**\n * `handle[key]`.\n * Get a property from a JSValue.\n *\n * @param key - The property may be specified as a JSValue handle, or as a\n * Javascript string (which will be converted automatically).\n */\n getProp(handle: QuickJSHandle, key: QuickJSPropertyKey): QuickJSHandle {\n this.runtime.assertOwned(handle)\n const ptr = this.borrowPropertyKey(key).consume((quickJSKey) =>\n this.ffi.QTS_GetProp(this.ctx.value, handle.value, quickJSKey.value)\n )\n const result = this.memory.heapValueHandle(ptr)\n\n return result\n }\n\n /**\n * `handle[key] = value`.\n * Set a property on a JSValue.\n *\n * @remarks\n * Note that the QuickJS authors recommend using [[defineProp]] to define new\n * properties.\n *\n * @param key - The property may be specified as a JSValue handle, or as a\n * Javascript string or number (which will be converted automatically to a JSValue).\n */\n setProp(handle: QuickJSHandle, key: QuickJSPropertyKey, value: QuickJSHandle) {\n this.runtime.assertOwned(handle)\n // free newly allocated value if key was a string or number. No-op if string was already\n // a QuickJS handle.\n this.borrowPropertyKey(key).consume((quickJSKey) =>\n this.ffi.QTS_SetProp(this.ctx.value, handle.value, quickJSKey.value, value.value)\n )\n }\n\n /**\n * [`Object.defineProperty(handle, key, descriptor)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty).\n *\n * @param key - The property may be specified as a JSValue handle, or as a\n * Javascript string or number (which will be converted automatically to a JSValue).\n */\n defineProp(\n handle: QuickJSHandle,\n key: QuickJSPropertyKey,\n descriptor: VmPropertyDescriptor<QuickJSHandle>\n ): void {\n this.runtime.assertOwned(handle)\n Scope.withScope((scope) => {\n const quickJSKey = scope.manage(this.borrowPropertyKey(key))\n\n const value = descriptor.value || this.undefined\n const configurable = Boolean(descriptor.configurable)\n const enumerable = Boolean(descriptor.enumerable)\n const hasValue = Boolean(descriptor.value)\n const get = descriptor.get\n ? scope.manage(this.newFunction(descriptor.get.name, descriptor.get))\n : this.undefined\n const set = descriptor.set\n ? scope.manage(this.newFunction(descriptor.set.name, descriptor.set))\n : this.undefined\n\n this.ffi.QTS_DefineProp(\n this.ctx.value,\n handle.value,\n quickJSKey.value,\n value.value,\n get.value,\n set.value,\n configurable,\n enumerable,\n hasValue\n )\n })\n }\n\n // Evaluation ---------------------------------------------------------------\n\n /**\n * [`func.call(thisVal, ...args)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call).\n * Call a JSValue as a function.\n *\n * See [[unwrapResult]], which will throw if the function returned an error, or\n * return the result handle directly. If evaluation returned a handle containing\n * a promise, use [[resolvePromise]] to convert it to a native promise and\n * [[executePendingJobs]] to finish evaluating the promise.\n *\n * @returns A result. If the function threw synchronously, `result.error` be a\n * handle to the exception. Otherwise `result.value` will be a handle to the\n * value.\n */\n callFunction(\n func: QuickJSHandle,\n thisVal: QuickJSHandle,\n ...args: QuickJSHandle[]\n ): VmCallResult<QuickJSHandle> {\n this.runtime.assertOwned(func)\n const resultPtr = this.memory\n .toPointerArray(args)\n .consume((argsArrayPtr) =>\n this.ffi.QTS_Call(\n this.ctx.value,\n func.value,\n thisVal.value,\n args.length,\n argsArrayPtr.value\n )\n )\n\n const errorPtr = this.ffi.QTS_ResolveException(this.ctx.value, resultPtr)\n if (errorPtr) {\n this.ffi.QTS_FreeValuePointer(this.ctx.value, resultPtr)\n return { error: this.memory.heapValueHandle(errorPtr) }\n }\n\n return { value: this.memory.heapValueHandle(resultPtr) }\n }\n\n /**\n * Like [`eval(code)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#Description).\n * Evaluates the Javascript source `code` in the global scope of this VM.\n * When working with async code, you many need to call [[executePendingJobs]]\n * to execute callbacks pending after synchronous evaluation returns.\n *\n * See [[unwrapResult]], which will throw if the function returned an error, or\n * return the result handle directly. If evaluation returned a handle containing\n * a promise, use [[resolvePromise]] to convert it to a native promise and\n * [[executePendingJobs]] to finish evaluating the promise.\n *\n * *Note*: to protect against infinite loops, provide an interrupt handler to\n * [[setInterruptHandler]]. You can use [[shouldInterruptAfterDeadline]] to\n * create a time-based deadline.\n *\n * @returns The last statement's value. If the code threw synchronously,\n * `result.error` will be a handle to the exception. If execution was\n * interrupted, the error will have name `InternalError` and message\n * `interrupted`.\n */\n evalCode(\n code: string,\n filename: string = \"eval.js\",\n /**\n * If no options are passed, a heuristic will be used to detect if `code` is\n * an ES module.\n *\n * See [[EvalFlags]] for number semantics.\n */\n options?: number | ContextEvalOptions\n ): VmCallResult<QuickJSHandle> {\n const detectModule = (options === undefined ? 1 : 0) as EvalDetectModule\n const flags = evalOptionsToFlags(options) as EvalFlags\n const resultPtr = this.memory\n .newHeapCharPointer(code)\n .consume((charHandle) =>\n this.ffi.QTS_Eval(this.ctx.value, charHandle.value, filename, detectModule, flags)\n )\n const errorPtr = this.ffi.QTS_ResolveException(this.ctx.value, resultPtr)\n if (errorPtr) {\n this.ffi.QTS_FreeValuePointer(this.ctx.value, resultPtr)\n return { error: this.memory.heapValueHandle(errorPtr) }\n }\n return { value: this.memory.heapValueHandle(resultPtr) }\n }\n\n /**\n * Throw an error in the VM, interrupted whatever current execution is in progress when execution resumes.\n * @experimental\n */\n throw(error: Error | QuickJSHandle) {\n return this.errorToHandle(error).consume((handle) =>\n this.ffi.QTS_Throw(this.ctx.value, handle.value)\n )\n }\n\n /**\n * @private\n */\n protected borrowPropertyKey(key: QuickJSPropertyKey): QuickJSHandle {\n if (typeof key === \"number\") {\n return this.newNumber(key)\n }\n\n if (typeof key === \"string\") {\n return this.newString(key)\n }\n\n // key is already a JSValue, but we're borrowing it. Return a static handle\n // for internal use only.\n return new StaticLifetime(key.value as JSValueConstPointer, this.runtime)\n }\n\n /**\n * @private\n */\n getMemory(rt: JSRuntimePointer): ContextMemory {\n if (rt === this.rt.value) {\n return this.memory\n } else {\n throw new Error(\"Private API. Cannot get memory from a different runtime\")\n }\n }\n\n // Utilities ----------------------------------------------------------------\n\n /**\n * Dump a JSValue to Javascript in a best-effort fashion.\n * Returns `handle.toString()` if it cannot be serialized to JSON.\n */\n dump(handle: QuickJSHandle) {\n this.runtime.assertOwned(handle)\n const type = this.typeof(handle)\n if (type === \"string\") {\n return this.getString(handle)\n } else if (type === \"number\") {\n return this.getNumber(handle)\n } else if (type === \"bigint\") {\n return this.getBigInt(handle)\n } else if (type === \"undefined\") {\n return undefined\n } else if (type === \"symbol\") {\n return this.getSymbol(handle)\n }\n\n const str = this.memory.consumeJSCharPointer(this.ffi.QTS_Dump(this.ctx.value, handle.value))\n try {\n return JSON.parse(str)\n } catch (err) {\n return str\n }\n }\n\n /**\n * Unwrap a SuccessOrFail result such as a [[VmCallResult]] or a\n * [[ExecutePendingJobsResult]], where the fail branch contains a handle to a QuickJS error value.\n * If the result is a success, returns the value.\n * If the result is an error, converts the error to a native object and throws the error.\n */\n unwrapResult<T>(result: SuccessOrFail<T, QuickJSHandle>): T {\n if (result.error) {\n const context: QuickJSContext =\n \"context\" in result.error ? (result.error as { context: QuickJSContext }).context : this\n const cause = result.error.consume((error) => this.dump(error))\n\n if (cause && typeof cause === \"object\" && typeof cause.message === \"string\") {\n const { message, name, stack } = cause\n const exception = new QuickJSUnwrapError(\"\")\n const hostStack = exception.stack\n\n if (typeof name === \"string\") {\n exception.name = cause.name\n }\n\n if (typeof stack === \"string\") {\n exception.stack = `${name}: ${message}\\n${cause.stack}Host: ${hostStack}`\n }\n\n Object.assign(exception, { cause, context, message })\n throw exception\n }\n\n throw new QuickJSUnwrapError(cause, context)\n }\n\n return result.value\n }\n\n /** @private */\n protected fnNextId = -32768 // min value of signed 16bit int used by Quickjs\n /** @private */\n protected fnMaps = new Map<number, Map<number, VmFunctionImplementation<QuickJSHandle>>>()\n\n /** @private */\n protected getFunction(fn_id: number): VmFunctionImplementation<QuickJSHandle> | undefined {\n const map_id = fn_id >> 8\n const fnMap = this.fnMaps.get(map_id)\n if (!fnMap) {\n return undefined\n }\n return fnMap.get(fn_id)\n }\n\n /** @private */\n protected setFunction(fn_id: number, handle: VmFunctionImplementation<QuickJSHandle>) {\n const map_id = fn_id >> 8\n let fnMap = this.fnMaps.get(map_id)\n if (!fnMap) {\n fnMap = new Map<number, VmFunctionImplementation<QuickJSHandle>>()\n this.fnMaps.set(map_id, fnMap)\n }\n return fnMap.set(fn_id, handle)\n }\n\n /**\n * @hidden\n */\n private cToHostCallbacks: ContextCallbacks = {\n callFunction: (ctx, this_ptr, argc, argv, fn_id) => {\n if (ctx !== this.ctx.value) {\n throw new Error(\"QuickJSContext instance received C -> JS call with mismatched ctx\")\n }\n\n const fn = this.getFunction(fn_id)\n if (!fn) {\n // this \"throw\" is not catch-able from the TS side. could we somehow handle this higher up?\n throw new Error(`QuickJSContext had no callback with id ${fn_id}`)\n }\n\n return Scope.withScopeMaybeAsync(this, function* (awaited, scope) {\n const thisHandle = scope.manage(\n new WeakLifetime(this_ptr, this.memory.copyJSValue, this.memory.freeJSValue, this.runtime)\n )\n const argHandles = new Array<QuickJSHandle>(argc)\n for (let i = 0; i < argc; i++) {\n const ptr = this.ffi.QTS_ArgvGetJSValueConstPointer(argv, i)\n argHandles[i] = scope.manage(\n new WeakLifetime(ptr, this.memory.copyJSValue, this.memory.freeJSValue, this.runtime)\n )\n }\n\n try {\n const result = yield* awaited(fn.apply(thisHandle, argHandles))\n if (result) {\n if (\"error\" in result && result.error) {\n debugLog(\"throw error\", result.error)\n throw result.error\n }\n const handle = scope.manage(result instanceof Lifetime ? result : result.value)\n return this.ffi.QTS_DupValuePointer(this.ctx.value, handle.value)\n }\n return 0 as JSValuePointer\n } catch (error) {\n return this.errorToHandle(error as Error).consume((errorHandle) =>\n this.ffi.QTS_Throw(this.ctx.value, errorHandle.value)\n )\n }\n }) as JSValuePointer\n },\n }\n\n private errorToHandle(error: Error | QuickJSHandle): QuickJSHandle {\n if (error instanceof Lifetime) {\n return error\n }\n\n return this.newError(error)\n }\n}\n"]}