{"version":3,"sources":["../src/ffi-types.ts"],"sourcesContent":["/**\n * C pointer to type `CType`. Pointer types are used internally for FFI, but\n * are not intended for external use.\n *\n * @unstable This type is considered private and may change.\n */\ntype Pointer<CType extends string> = number & { ctype: CType }\n\ntype Brand<T, B> = T & { brand: B }\n\n/**\n * `JSRuntime*`.\n */\nexport type JSRuntimePointer = Pointer<\"JSRuntime\">\n\n/**\n * `JSContext*`.\n */\nexport type JSContextPointer = Pointer<\"JSContext\">\n\n/**\n * `JSContext**`. Used internally for execute pending jobs.\n */\nexport type JSContextPointerPointer = Pointer<\"JSContext\">\n\n/**\n * `JSModuleDef*`.\n */\nexport type JSModuleDefPointer = Pointer<\"JSModuleDef\">\n\n/**\n * `JSValue*`.\n * See {@link JSValue}.\n */\nexport type JSValuePointer = Pointer<\"JSValue\">\n\n/**\n * `JSValueConst*\n * See {@link JSValueConst} and {@link StaticJSValue}.\n */\nexport type JSValueConstPointer = Pointer<\"JSValueConst\">\n\n/**\n * Used internally for Javascript-to-C function calls.\n */\nexport type JSValuePointerPointer = Pointer<\"JSValue[]\">\n\n/**\n * Used internally for Javascript-to-C function calls.\n */\nexport type JSValuePointerPointerPointer = Pointer<\"*JSValue[]\">\n\n/**\n * Used internally for Javascript-to-C function calls.\n */\nexport type JSValueConstPointerPointer = Pointer<\"JSValueConst[]\">\n\n/**\n * Used internally for C-to-Javascript function calls.\n */\n// type JSCFunctionPointer = Pointer<'JSCFunction'>\n\n/**\n * Used internally for C-to-Javascript function calls.\n */\nexport type QTS_C_To_HostCallbackFuncPointer = Pointer<\"C_To_HostCallbackFunc\">\n\n/**\n * Used internally for C-to-Javascript interrupt handlers.\n */\nexport type QTS_C_To_HostInterruptFuncPointer = Pointer<\"C_To_HostInterruptFunc\">\n\n/**\n * Used internally for C-to-Javascript module loading.\n */\nexport type QTS_C_To_HostLoadModuleFuncPointer = Pointer<\"C_To_HostLoadModuleFunc\">\n\n/**\n * Used internally for Javascript-to-C calls that may contain strings too large\n * for the Emscripten stack.\n */\nexport type BorrowedHeapCharPointer = Pointer<\"const char\" | \"char\" | \"js const char\">\n\n/**\n * Used internally for Javascript-to-C calls that may contain strings too large\n * for the Emscripten stack.\n */\nexport type OwnedHeapCharPointer = Pointer<\"char\">\n\n/**\n * Used internally for Javascript-to-C calls that may contain strings too large\n * for the Emscripten stack.\n */\nexport type JSBorrowedCharPointer = Pointer<\"js const char\">\n\n/**\n * Opaque pointer that was allocated by js_malloc.\n */\nexport type JSVoidPointer = Pointer<any>\n\nexport type UInt32Pointer = Pointer<\"uint32_t\">\n\n/**\n * @private\n */\nexport type EvalFlags = Brand<number, \"EvalFlags\">\n\n/**\n * @private\n */\nexport type IntrinsicsFlags = Brand<number, \"IntrinsicsFlags\">\n\n/**\n * @private\n */\nexport type EvalDetectModule = Brand<number, \"EvalDetectModule\">\n\n/**\n * @private\n */\nexport type GetOwnPropertyNamesFlags = Brand<number, \"GetOwnPropertyNamesFlags\">\n\n/**\n * @private\n */\nexport type IsEqualOp = Brand<number, \"IsEqualOp\">\n\n/**\n * @private\n */\nexport type HostRefId = Brand<number, \"HostRefId\">\n\n/**\n * State of a promise.\n */\nexport type JSPromiseStateEnum = Brand<\n  (typeof JSPromiseStateEnum)[keyof typeof JSPromiseStateEnum],\n  \"JSPromiseStateEnum\"\n>\n\nexport function assertSync<Args extends any[], R>(fn: (...args: Args) => R): (...args: Args) => R {\n  return function mustBeSync(...args: Args): R {\n    const result = fn(...args)\n    if (result && typeof result === \"object\" && result instanceof Promise) {\n      throw new Error(\"Function unexpectedly returned a Promise\")\n    }\n    return result\n  }\n}\n\n/** Bitfield options for JS_Eval() C function. */\nexport const EvalFlags = {\n  /** global code (default) */\n  JS_EVAL_TYPE_GLOBAL: 0 << 0,\n  /** module code */\n  JS_EVAL_TYPE_MODULE: 1 << 0,\n  /** direct call (internal use) */\n  JS_EVAL_TYPE_DIRECT: 2 << 0,\n  /** indirect call (internal use) */\n  JS_EVAL_TYPE_INDIRECT: 3 << 0,\n  JS_EVAL_TYPE_MASK: 3 << 0,\n  /** force 'strict' mode */\n  JS_EVAL_FLAG_STRICT: 1 << 3,\n  /** force 'strip' mode */\n  JS_EVAL_FLAG_STRIP: 1 << 4,\n  /**\n   * compile but do not run. The result is an object with a\n   * JS_TAG_FUNCTION_BYTECODE or JS_TAG_MODULE tag. It can be executed\n   * with JS_EvalFunction().\n   */\n  JS_EVAL_FLAG_COMPILE_ONLY: 1 << 5,\n  /** don't include the stack frames before this eval in the Error() backtraces */\n  JS_EVAL_FLAG_BACKTRACE_BARRIER: 1 << 6,\n} as const\n\n/** Bitfield options for QTS_NewContext intrinsics */\nexport const IntrinsicsFlags = {\n  BaseObjects: 1 << 0,\n  Date: 1 << 1,\n  Eval: 1 << 2,\n  StringNormalize: 1 << 3,\n  RegExp: 1 << 4,\n  RegExpCompiler: 1 << 5,\n  JSON: 1 << 6,\n  Proxy: 1 << 7,\n  MapSet: 1 << 8,\n  TypedArrays: 1 << 9,\n  Promise: 1 << 10,\n  BigInt: 1 << 11,\n  BigFloat: 1 << 12,\n  BigDecimal: 1 << 13,\n  OperatorOverloading: 1 << 14,\n  BignumExt: 1 << 15,\n} as const\n\nexport const JSPromiseStateEnum = {\n  Pending: 0,\n  Fulfilled: 1,\n  Rejected: 2,\n} as const\n\n/** Bitfield options for QTS_GetOwnPropertyNames */\nexport const GetOwnPropertyNamesFlags = {\n  JS_GPN_STRING_MASK: 1 << 0,\n  JS_GPN_SYMBOL_MASK: 1 << 1,\n  JS_GPN_PRIVATE_MASK: 1 << 2,\n  /* only include the enumerable properties */\n  JS_GPN_ENUM_ONLY: 1 << 4,\n  /* set theJSPropertyEnum.is_enumerable field */\n  JS_GPN_SET_ENUM: 1 << 5,\n  /* include numbers. when only this is set, we filter out strings */\n  QTS_GPN_NUMBER_MASK: 1 << 6,\n  /* Treat numbers as strings */\n  QTS_STANDARD_COMPLIANT_NUMBER: 1 << 7,\n}\n\nexport const IsEqualOp = {\n  IsStrictlyEqual: 0 as IsEqualOp,\n  IsSameValue: 1 as IsEqualOp,\n  IsSameValueZero: 2 as IsEqualOp,\n}\n"],"mappings":"AA4IO,SAAS,WAAkC,GAAgD,CAChG,OAAO,YAAuB,KAAe,CAC3C,IAAM,OAAS,GAAG,GAAG,IAAI,EACzB,GAAI,QAAU,OAAO,QAAW,UAAY,kBAAkB,QAC5D,MAAM,IAAI,MAAM,0CAA0C,EAE5D,OAAO,MACT,CACF,CAGO,IAAM,UAAY,CAEvB,oBAAqB,EAErB,oBAAqB,EAErB,oBAAqB,EAErB,sBAAuB,EACvB,kBAAmB,EAEnB,oBAAqB,EAErB,mBAAoB,GAMpB,0BAA2B,GAE3B,+BAAgC,EAClC,EAGa,gBAAkB,CAC7B,YAAa,EACb,KAAM,EACN,KAAM,EACN,gBAAiB,EACjB,OAAQ,GACR,eAAgB,GAChB,KAAM,GACN,MAAO,IACP,OAAQ,IACR,YAAa,IACb,QAAS,KACT,OAAQ,KACR,SAAU,KACV,WAAY,KACZ,oBAAqB,MACrB,UAAW,KACb,EAEa,mBAAqB,CAChC,QAAS,EACT,UAAW,EACX,SAAU,CACZ,EAGa,yBAA2B,CACtC,mBAAoB,EACpB,mBAAoB,EACpB,oBAAqB,EAErB,iBAAkB,GAElB,gBAAiB,GAEjB,oBAAqB,GAErB,8BAA+B,GACjC,EAEa,UAAY,CACvB,gBAAiB,EACjB,YAAa,EACb,gBAAiB,CACnB","names":[]}