mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
Bug: none Change-Id: I7b92e1d3c7e14729d99fb8b540d93d9d0be0ecba Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4756724 Auto-Submit: Randolf Jung <jrandolf@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org>
49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
import { QuickJSContext } from "./context";
|
|
import { QuickJSAsyncEmscriptenModule } from "./emscripten-types";
|
|
import { QuickJSAsyncFFI } from "./variants";
|
|
import { JSRuntimePointer } from "./types-ffi";
|
|
import { Lifetime } from "./lifetime";
|
|
import { QuickJSModuleCallbacks } from "./module";
|
|
import { QuickJSAsyncRuntime } from "./runtime-asyncify";
|
|
import { ContextEvalOptions, QuickJSHandle } from "./types";
|
|
import { VmCallResult } from "./vm-interface";
|
|
export type AsyncFunctionImplementation = (this: QuickJSHandle, ...args: QuickJSHandle[]) => Promise<QuickJSHandle | VmCallResult<QuickJSHandle> | void>;
|
|
/**
|
|
* Asyncified version of [[QuickJSContext]].
|
|
*
|
|
* *Asyncify* allows normally synchronous code to wait for asynchronous Promises
|
|
* or callbacks. The asyncified version of QuickJSContext can wait for async
|
|
* host functions as though they were synchronous.
|
|
*/
|
|
export declare class QuickJSAsyncContext extends QuickJSContext {
|
|
runtime: QuickJSAsyncRuntime;
|
|
/** @private */
|
|
protected module: QuickJSAsyncEmscriptenModule;
|
|
/** @private */
|
|
protected ffi: QuickJSAsyncFFI;
|
|
/** @private */
|
|
protected rt: Lifetime<JSRuntimePointer>;
|
|
/** @private */
|
|
protected callbacks: QuickJSModuleCallbacks;
|
|
/**
|
|
* Asyncified version of [[evalCode]].
|
|
*/
|
|
evalCodeAsync(code: string, filename?: string,
|
|
/** See [[EvalFlags]] for number semantics */
|
|
options?: number | ContextEvalOptions): Promise<VmCallResult<QuickJSHandle>>;
|
|
/**
|
|
* Similar to [[newFunction]].
|
|
* Convert an async host Javascript function into a synchronous QuickJS function value.
|
|
*
|
|
* Whenever QuickJS calls this function, the VM's stack will be unwound while
|
|
* waiting the async function to complete, and then restored when the returned
|
|
* promise resolves.
|
|
*
|
|
* Asyncified functions must never call other asyncified functions or
|
|
* `import`, even indirectly, because the stack cannot be unwound twice.
|
|
*
|
|
* See [Emscripten's docs on Asyncify](https://emscripten.org/docs/porting/asyncify.html).
|
|
*/
|
|
newAsyncifiedFunction(name: string, fn: AsyncFunctionImplementation): QuickJSHandle;
|
|
}
|