@mcpcloud/runtime 0.7.1 → 0.12.1
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/dist/adapters/codeModeHost.d.ts +25 -0
- package/dist/compat-stdio.js +48 -23
- package/dist/compat-worker.js +58 -89
- package/dist/container-host.js +12 -2
- package/dist/engine/emscripten-module.cloudflare.cjs +21 -0
- package/dist/engine/emscripten-module.cloudflare.d.cts +3 -0
- package/dist/engine/emscripten-module.d.mts +3 -0
- package/dist/engine/emscripten-module.d.ts +11 -0
- package/dist/engine/emscripten-module.mjs +26 -0
- package/dist/engine/emscripten-module.wasm +0 -0
- package/dist/engine/ffi.d.mts +4 -0
- package/dist/engine/ffi.d.ts +85 -0
- package/dist/engine/ffi.mjs +1 -0
- package/dist/engine/manifest.json +51 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +71 -85
- package/dist/node.js +12 -2
- package/dist/projection.d.ts +9 -0
- package/dist/sandbox/bindings.d.ts +116 -0
- package/dist/sandbox/codeModeTool.d.ts +114 -0
- package/dist/sandbox/console.d.ts +51 -0
- package/dist/sandbox/createSandbox.d.ts +16 -1
- package/dist/sandbox/nodeEngine.d.ts +30 -0
- package/dist/sandbox/shape.d.ts +68 -0
- package/dist/sandbox/types.d.ts +80 -2
- package/dist/server.d.ts +13 -0
- package/dist/stdio.js +59 -24
- package/dist/validation.d.ts +16 -0
- package/package.json +1 -1
package/dist/container-host.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.
|
|
2
|
-
|
|
1
|
+
/*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
|
+
var _9=Object.create;var{getPrototypeOf:w9,defineProperty:$8,getOwnPropertyNames:P9}=Object;var N9=Object.prototype.hasOwnProperty;function E9(Z){return this[Z]}var S9,I9,x9=(Z,$,X)=>{var Y=Z!=null&&typeof Z==="object";if(Y){var B=$?S9??=new WeakMap:I9??=new WeakMap,C=B.get(Z);if(C)return C}X=Z!=null?_9(w9(Z)):{};let U=$||!Z||!Z.__esModule?$8(X,"default",{value:Z,enumerable:!0}):X;for(let z of P9(Z))if(!N9.call(U,z))$8(U,z,{get:E9.bind(Z,z),enumerable:!0});if(Y)B.set(Z,U);return U};var A9=(Z,$)=>()=>($||Z(($={exports:{}}).exports,$),$.exports);var b9=(Z)=>Z;function T9(Z,$){this[Z]=b9.bind(null,$)}var f9=(Z,$)=>{for(var X in $)$8(Z,X,{get:$[X],enumerable:!0,configurable:!0,set:T9.bind($,X)})};var X8=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var k,W8,l,h,c;var i=X8(()=>{k={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},W8={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},l={Pending:0,Fulfilled:1,Rejected:2},h={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},c={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function m(...Z){B8&&console.log("quickjs-emscripten:",...Z)}function*K9(Z){return yield Z}function m9(Z){return K9(q8(Z))}function u8(Z,$){return(...X)=>{let Y=$.call(Z,J8,...X);return q8(Y)}}function d9(Z,$){let X=$.call(Z,J8);return q8(X)}function q8(Z){function $(X){return X.done?X.value:X.value instanceof Promise?X.value.then((Y)=>$(Z.next(Y)),(Y)=>$(Z.throw(Y))):$(Z.next(X.value))}return $(Z.next())}function K8(Z,$){let X;try{Z.dispose()}catch(Y){X=Y}if($&&X)throw Object.assign($,{message:`${$.message}
|
|
3
|
+
Then, failed to dispose scope: ${X.message}`,disposeError:X}),$;if($||X)throw $||X}function p9(Z){let $=Z?Array.from(Z):[];function X(){return $.forEach((B)=>B.alive?B.dispose():void 0)}function Y(){return $.some((B)=>B.alive)}return Object.defineProperty($,G8,{configurable:!0,enumerable:!1,value:X}),Object.defineProperty($,"dispose",{configurable:!0,enumerable:!1,value:X}),Object.defineProperty($,"alive",{configurable:!0,enumerable:!1,get:Y}),$}function n(Z){return!!(Z&&(typeof Z=="object"||typeof Z=="function")&&("alive"in Z)&&typeof Z.alive=="boolean"&&("dispose"in Z)&&typeof Z.dispose=="function")}function o9(Z){if(!Z)return 0;let $=0;for(let[X,Y]of Object.entries(Z)){if(!(X in W8))throw new Z9(X);Y&&($|=W8[X])}return $}function n9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{type:$,strict:X,strip:Y,compileOnly:B,backtraceBarrier:C}=Z,U=0;return $==="global"&&(U|=k.JS_EVAL_TYPE_GLOBAL),$==="module"&&(U|=k.JS_EVAL_TYPE_MODULE),X&&(U|=k.JS_EVAL_FLAG_STRICT),Y&&(U|=k.JS_EVAL_FLAG_STRIP),B&&(U|=k.JS_EVAL_FLAG_COMPILE_ONLY),C&&(U|=k.JS_EVAL_FLAG_BACKTRACE_BARRIER),U}function a9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{strings:$,symbols:X,quickjsPrivate:Y,onlyEnumerable:B,numbers:C,numbersAsStrings:U}=Z,z=0;return $&&(z|=h.JS_GPN_STRING_MASK),X&&(z|=h.JS_GPN_SYMBOL_MASK),Y&&(z|=h.JS_GPN_PRIVATE_MASK),B&&(z|=h.JS_GPN_ENUM_ONLY),C&&(z|=h.QTS_GPN_NUMBER_MASK),U&&(z|=h.QTS_STANDARD_COMPLIANT_NUMBER),z}function s9(...Z){let $=[];for(let X of Z)X!==void 0&&($=$.concat(X));return $}function z8(Z){return Z>>8}function H8(Z,$){$.interruptHandler&&Z.setInterruptHandler($.interruptHandler),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes)}function j8(Z,$){$.moduleLoader&&Z.setModuleLoader($.moduleLoader),$.shouldInterrupt&&Z.setInterruptHandler($.shouldInterrupt),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes)}var k9,h9=(Z,$)=>{for(var X in $)k9(Z,X,{get:$[X],enumerable:!0})},B8=!1,v9,Y8,s8,Q8,t8,r8,e8,g9,c9,Z9,$9,X9,W9,f,J8,A,G8,l8,w,v,i8,I,C8,u9,l9,g,i9,z9=class{constructor(Z){this.module=Z}toPointerArray(Z){let $=new Int32Array(Z.map((B)=>B.value)),X=$.length*$.BYTES_PER_ELEMENT,Y=this.module._malloc(X);return new Uint8Array(this.module.HEAPU8.buffer,Y,X).set(new Uint8Array($.buffer)),new w(Y,void 0,(B)=>this.module._free(B))}newTypedArray(Z,$){let X=new Z(Array($).fill(0)),Y=X.length*X.BYTES_PER_ELEMENT,B=this.module._malloc(Y),C=new Z(this.module.HEAPU8.buffer,B,$);return C.set(X),new w({typedArray:C,ptr:B},void 0,(U)=>this.module._free(U.ptr))}newMutablePointerArray(Z){return this.newTypedArray(Int32Array,Z)}newHeapCharPointer(Z){let $=this.module.lengthBytesUTF8(Z),X=$+1,Y=this.module._malloc(X);return this.module.stringToUTF8(Z,Y,X),new w({ptr:Y,strlen:$},void 0,(B)=>this.module._free(B.ptr))}newHeapBufferPointer(Z){let $=Z.byteLength,X=this.module._malloc($);return this.module.HEAPU8.set(Z,X),new w({pointer:X,numBytes:$},void 0,(Y)=>this.module._free(Y.pointer))}consumeHeapCharPointer(Z){let $=this.module.UTF8ToString(Z);return this.module._free(Z),$}},fZ,yZ,t9,o8=-2147483648,n8=2147483647,o=0,r9=class{constructor(){this.nextId=o8,this.freelist=[],this.groups=new Map}put(Z){let $=this.allocateId(),X=z8($),Y=this.groups.get(X);return Y||(Y=new Map,this.groups.set(X,Y)),Y.set($,Z),$}get(Z){if(Z===o)throw new f("no host reference id defined");let $=z8(Z),X=this.groups.get($);if(!X)throw new f(`host reference id ${Z} is not defined`);let Y=X.get(Z);if(!Y)throw new f(`host reference id ${Z} is not defined`);return Y}delete(Z){if(Z===o)throw new f("no host reference id defined");let $=z8(Z),X=this.groups.get($);if(!X)throw new f(`host reference id ${Z} is not defined`);X.delete(Z),X.size===0&&this.groups.delete($),this.freelist.push(Z)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===o&&this.nextId++,this.nextId>n8)throw new W9(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${n8-o8}`);return this.nextId++}},a8,e9,ZZ,$Z,XZ=class{constructor(Z){this.freeHostRef=Z.freeHostRef,this.callFunction=Z.callFunction,this.shouldInterrupt=Z.shouldInterrupt,this.loadModuleSource=Z.loadModuleSource,this.normalizeModule=Z.normalizeModule}},U8=class{constructor(Z){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new XZ({freeHostRef:($,X,Y)=>{let B=this.runtimeCallbacks.get(X);if(!B)throw Error(`QuickJSRuntime(rt = ${X}) not found when trying to free HostRef(id = ${Y})`);B.freeHostRef(X,Y)},callFunction:($,X,Y,B,C,U)=>this.handleAsyncify($,()=>{try{let z=this.contextCallbacks.get(X);if(!z)throw Error(`QuickJSContext(ctx = ${X}) not found for C function call "${U}"`);return z.callFunction(X,Y,B,C,U)}catch(z){return console.error("[C to host error: returning null]",z),0}}),shouldInterrupt:($,X)=>this.handleAsyncify($,()=>{try{let Y=this.runtimeCallbacks.get(X);if(!Y)throw Error(`QuickJSRuntime(rt = ${X}) not found for C interrupt`);return Y.shouldInterrupt(X)}catch(Y){return console.error("[C to host interrupt: returning error]",Y),1}}),loadModuleSource:($,X,Y,B)=>this.handleAsyncify($,()=>{try{let C=this.runtimeCallbacks.get(X);if(!C)throw Error(`QuickJSRuntime(rt = ${X}) not found for C module loader`);let U=C.loadModuleSource;if(!U)throw Error(`QuickJSRuntime(rt = ${X}) does not support module loading`);return U(X,Y,B)}catch(C){return console.error("[C to host module loader error: returning null]",C),0}}),normalizeModule:($,X,Y,B,C)=>this.handleAsyncify($,()=>{try{let U=this.runtimeCallbacks.get(X);if(!U)throw Error(`QuickJSRuntime(rt = ${X}) not found for C module loader`);let z=U.normalizeModule;if(!z)throw Error(`QuickJSRuntime(rt = ${X}) does not support module loading`);return z(X,Y,B,C)}catch(U){return console.error("[C to host module loader error: returning null]",U),0}})}),this.module=Z,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(Z,$){this.runtimeCallbacks.set(Z,$)}deleteRuntime(Z){this.runtimeCallbacks.delete(Z)}setContextCallbacks(Z,$){this.contextCallbacks.set(Z,$)}deleteContext(Z){this.contextCallbacks.delete(Z)}handleAsyncify(Z,$){if(Z)return Z.handleSleep((Y)=>{try{let B=$();if(!(B instanceof Promise)){m("asyncify.handleSleep: not suspending:",B),Y(B);return}if(this.suspended)throw new r8(`Already suspended at: ${this.suspended.stack}
|
|
4
|
+
Attempted to suspend at:`);this.suspended=new e8(`(${this.suspendedCount++})`),m("asyncify.handleSleep: suspending:",this.suspended),B.then((C)=>{this.suspended=void 0,m("asyncify.handleSleep: resolved:",C),Y(C)},(C)=>{m("asyncify.handleSleep: rejected:",C),console.error("QuickJS: cannot handle error in suspended function",C),this.suspended=void 0})}catch(B){throw m("asyncify.handleSleep: error:",B),this.suspended=void 0,B}});let X=$();if(X instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return X}},Y9=class{constructor(Z,$){this.module=Z,this.ffi=$,this.callbacks=new U8(Z)}newRuntime(Z={}){let $=new w(this.ffi.QTS_NewRuntime(),void 0,(Y)=>{this.ffi.QTS_FreeRuntime(Y),this.callbacks.deleteRuntime(Y)}),X=new $Z({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:$});return H8(X,Z),Z.moduleLoader&&X.setModuleLoader(Z.moduleLoader),X}newContext(Z={}){let $=this.newRuntime(),X=$.newContext({...Z,ownedLifetimes:s9($,Z.ownedLifetimes)});return $.context=X,X}evalCode(Z,$={}){return I.withScope((X)=>{let Y=X.manage(this.newContext());j8(Y.runtime,$);let B=Y.evalCode(Z,"eval.js");if($.memoryLimitBytes!==void 0&&Y.runtime.setMemoryLimit(-1),B.error)throw Y.dump(X.manage(B.error));return Y.dump(X.manage(B.value))})}getWasmMemory(){let Z=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!Z)throw Error("Variant does not support getting WebAssembly.Memory");return Z}getFFI(){return this.ffi}};var Q9=X8(()=>{i();i();k9=Object.defineProperty;v9={};h9(v9,{QuickJSAsyncifyError:()=>r8,QuickJSAsyncifySuspended:()=>e8,QuickJSEmptyGetOwnPropertyNames:()=>X9,QuickJSEmscriptenModuleError:()=>c9,QuickJSHostRefInvalid:()=>f,QuickJSHostRefRangeExceeded:()=>W9,QuickJSMemoryLeakDetected:()=>g9,QuickJSNotImplemented:()=>t8,QuickJSPromisePending:()=>$9,QuickJSUnknownIntrinsic:()=>Z9,QuickJSUnwrapError:()=>Y8,QuickJSUseAfterFree:()=>Q8,QuickJSWrongOwner:()=>s8});Y8=class extends Error{constructor(Z,$){let X=typeof Z=="object"&&Z&&"message"in Z?String(Z.message):String(Z);super(X);this.cause=Z,this.context=$,this.name="QuickJSUnwrapError"}},s8=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},Q8=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},t8=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},r8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},e8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},g9=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},c9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},Z9=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},$9=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},X9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},W9=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},f=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};J8=K9;J8.of=m9;A=class{[Symbol.dispose](){return this.dispose()}},G8=Symbol.dispose??Symbol.for("Symbol.dispose"),l8=A.prototype;l8[G8]||(l8[G8]=function(){return this.dispose()});w=class Z extends A{constructor($,X,Y,B){super();this._value=$,this.copier=X,this.disposer=Y,this._owner=B,this._alive=!0,this._constructorStack=B8?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new Z(this.copier(this._value),this.copier,this.disposer,this._owner)}consume($){this.assertAlive();let X=$(this);return this.dispose(),X}map($){return this.assertAlive(),$(this)}tap($){return $(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new Q8(`Lifetime not alive
|
|
5
|
+
${this._constructorStack}
|
|
6
|
+
Lifetime used`):new Q8("Lifetime not alive")}},v=class extends w{constructor(Z,$){super(Z,void 0,void 0,$)}get dupable(){return!0}dup(){return this}dispose(){}},i8=class extends w{constructor(Z,$,X,Y){super(Z,$,X,Y)}dispose(){this._alive=!1}};I=class Z extends A{constructor(){super(...arguments);this._disposables=new w(new Set),this.manage=($)=>(this._disposables.value.add($),$)}static withScope($){let X=new Z,Y;try{return $(X)}catch(B){throw Y=B,B}finally{K8(X,Y)}}static withScopeMaybeAsync($,X){return d9(void 0,function*(Y){let B=new Z,C;try{return yield*Y.of(X.call($,Y,B))}catch(U){throw C=U,U}finally{K8(B,C)}})}static async withScopeAsync($){let X=new Z,Y;try{return await $(X)}catch(B){throw Y=B,B}finally{K8(X,Y)}}get alive(){return this._disposables.alive}dispose(){let $=Array.from(this._disposables.value.values()).reverse();for(let X of $)X.alive&&X.dispose();this._disposables.dispose()}};C8=class Z extends A{static success($){return new u9($)}static fail($,X){return new l9($,X)}static is($){return $ instanceof Z}},u9=class extends C8{constructor(Z){super();this.value=Z}get alive(){return n(this.value)?this.value.alive:!0}dispose(){n(this.value)&&this.value.dispose()}unwrap(){return this.value}unwrapOr(Z){return this.value}},l9=class extends C8{constructor(Z,$){super();this.error=Z,this.onUnwrap=$}get alive(){return n(this.error)?this.error.alive:!0}dispose(){n(this.error)&&this.error.dispose()}unwrap(){throw this.onUnwrap(this),this.error}unwrapOr(Z){return Z}},g=C8,i9=class extends A{constructor(Z){super();this.resolve=($)=>{this.resolveHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.resolveHandle,this.context.undefined,$||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.reject=($)=>{this.rejectHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.rejectHandle,this.context.undefined,$||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.dispose=()=>{this.handle.alive&&this.handle.dispose(),this.disposeResolvers()},this.context=Z.context,this.owner=Z.context.runtime,this.handle=Z.promiseHandle,this.settled=new Promise(($)=>{this.onSettled=$}),this.resolveHandle=Z.resolveHandle,this.rejectHandle=Z.rejectHandle}get alive(){return this.handle.alive||this.resolveHandle.alive||this.rejectHandle.alive}disposeResolvers(){this.resolveHandle.alive&&this.resolveHandle.dispose(),this.rejectHandle.alive&&this.rejectHandle.dispose()}},fZ=Symbol("Unstable"),yZ=Object.freeze({BaseObjects:!0,Date:!0,Eval:!0,StringNormalize:!0,RegExp:!0,JSON:!0,Proxy:!0,MapSet:!0,TypedArrays:!0,Promise:!0});t9=class extends A{constructor(Z,$){super();this.handle=Z,this.context=$,this._isDone=!1,this.owner=$.runtime}[Symbol.iterator](){return this}next(Z){if(!this.alive||this._isDone)return{done:!0,value:void 0};let $=this._next??(this._next=this.context.getProp(this.handle,"next"));return this.callIteratorMethod($,Z)}return(Z){if(!this.alive)return{done:!0,value:void 0};let $=this.context.getProp(this.handle,"return");if($===this.context.undefined&&Z===void 0)return this.dispose(),{done:!0,value:void 0};let X=this.callIteratorMethod($,Z);return $.dispose(),this.dispose(),X}throw(Z){if(!this.alive)return{done:!0,value:void 0};let $=Z instanceof w?Z:this.context.newError(Z),X=this.context.getProp(this.handle,"throw"),Y=this.callIteratorMethod(X,Z);return $.alive&&$.dispose(),X.dispose(),this.dispose(),Y}get alive(){return this.handle.alive}dispose(){this._isDone=!0,this.handle.dispose(),this._next?.dispose()}callIteratorMethod(Z,$){let X=$?this.context.callFunction(Z,this.handle,$):this.context.callFunction(Z,this.handle);if(X.error)return this.dispose(),{value:X};let Y=this.context.getProp(X.value,"done").consume((C)=>this.context.dump(C)),B=this.context.getProp(X.value,"value");return X.value.dispose(),Y&&this.dispose(),{value:g.success(B),done:Y}}};a8=class extends A{constructor(Z,$,X){if(X===o)throw new f("cannot create HostRef with undefined id");super();this.runtime=Z,this.handle=$,this.id=X}get alive(){return this.handle.alive}dispose(){this.handle.dispose()}get value(){return this.runtime.hostRefs.get(this.id)}},e9=class extends z9{constructor(Z){super(Z.module);this.scope=new I,this.copyJSValue=($)=>this.ffi.QTS_DupValuePointer(this.ctx.value,$),this.freeJSValue=($)=>{this.ffi.QTS_FreeValuePointer(this.ctx.value,$)},Z.ownedLifetimes?.forEach(($)=>this.scope.manage($)),this.owner=Z.owner,this.module=Z.module,this.ffi=Z.ffi,this.rt=Z.rt,this.ctx=this.scope.manage(Z.ctx)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}[Symbol.dispose](){return this.dispose()}manage(Z){return this.scope.manage(Z)}consumeJSCharPointer(Z){let $=this.module.UTF8ToString(Z);return this.ffi.QTS_FreeCString(this.ctx.value,Z),$}heapValueHandle(Z,$){let X=$?(Y)=>{$(),this.freeJSValue(Y)}:this.freeJSValue;return new w(Z,this.copyJSValue,X,this.owner)}staticHeapValueHandle(Z){return this.manage(this.heapValueHandle(Z)),new v(Z,this.owner)}},ZZ=class extends A{constructor(Z){super();this._undefined=void 0,this._null=void 0,this._false=void 0,this._true=void 0,this._global=void 0,this._BigInt=void 0,this._Symbol=void 0,this._SymbolIterator=void 0,this._SymbolAsyncIterator=void 0,this.cToHostCallbacks={callFunction:($,X,Y,B,C)=>{if($!==this.ctx.value)throw Error("QuickJSContext instance received C -> JS call with mismatched ctx");let U=this.getFunction(C);return I.withScopeMaybeAsync(this,function*(z,D){let P=D.manage(new i8(X,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime)),x=Array(Y);for(let M=0;M<Y;M++){let b=this.ffi.QTS_ArgvGetJSValueConstPointer(B,M);x[M]=D.manage(new i8(b,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime))}try{let M=yield*z(U.apply(P,x));if(M){if("error"in M&&M.error)throw this.runtime.debugLog("throw error",M.error),M.error;let b=D.manage(M instanceof w?M:M.value);return this.ffi.QTS_DupValuePointer(this.ctx.value,b.value)}return 0}catch(M){return this.errorToHandle(M).consume((b)=>this.ffi.QTS_Throw(this.ctx.value,b.value))}})}},this.runtime=Z.runtime,this.module=Z.module,this.ffi=Z.ffi,this.rt=Z.rt,this.ctx=Z.ctx,this.memory=new e9({...Z,owner:this.runtime}),Z.callbacks.setContextCallbacks(this.ctx.value,this.cToHostCallbacks),this.dump=this.dump.bind(this),this.getString=this.getString.bind(this),this.getNumber=this.getNumber.bind(this),this.resolvePromise=this.resolvePromise.bind(this),this.uint32Out=this.memory.manage(this.memory.newTypedArray(Uint32Array,1))}get alive(){return this.memory.alive}dispose(){this.memory.dispose()}get undefined(){if(this._undefined)return this._undefined;let Z=this.ffi.QTS_GetUndefined();return this._undefined=new v(Z)}get null(){if(this._null)return this._null;let Z=this.ffi.QTS_GetNull();return this._null=new v(Z)}get true(){if(this._true)return this._true;let Z=this.ffi.QTS_GetTrue();return this._true=new v(Z)}get false(){if(this._false)return this._false;let Z=this.ffi.QTS_GetFalse();return this._false=new v(Z)}get global(){if(this._global)return this._global;let Z=this.ffi.QTS_GetGlobalObject(this.ctx.value);return this._global=this.memory.staticHeapValueHandle(Z),this._global}newNumber(Z){return this.memory.heapValueHandle(this.ffi.QTS_NewFloat64(this.ctx.value,Z))}newString(Z){let $=this.memory.newHeapCharPointer(Z).consume((X)=>this.ffi.QTS_NewString(this.ctx.value,X.value.ptr));return this.memory.heapValueHandle($)}newUniqueSymbol(Z){let $=(typeof Z=="symbol"?Z.description:Z)??"",X=this.memory.newHeapCharPointer($).consume((Y)=>this.ffi.QTS_NewSymbol(this.ctx.value,Y.value.ptr,0));return this.memory.heapValueHandle(X)}newSymbolFor(Z){let $=(typeof Z=="symbol"?Z.description:Z)??"",X=this.memory.newHeapCharPointer($).consume((Y)=>this.ffi.QTS_NewSymbol(this.ctx.value,Y.value.ptr,1));return this.memory.heapValueHandle(X)}getWellKnownSymbol(Z){return this._Symbol??(this._Symbol=this.memory.manage(this.getProp(this.global,"Symbol"))),this.getProp(this._Symbol,Z)}newBigInt(Z){if(!this._BigInt){let Y=this.getProp(this.global,"BigInt");this.memory.manage(Y),this._BigInt=new v(Y.value,this.runtime)}let $=this._BigInt,X=String(Z);return this.newString(X).consume((Y)=>this.unwrapResult(this.callFunction($,this.undefined,Y)))}newObject(Z){Z&&this.runtime.assertOwned(Z);let $=Z?this.ffi.QTS_NewObjectProto(this.ctx.value,Z.value):this.ffi.QTS_NewObject(this.ctx.value);return this.memory.heapValueHandle($)}newArray(){let Z=this.ffi.QTS_NewArray(this.ctx.value);return this.memory.heapValueHandle(Z)}newArrayBuffer(Z){let $=new Uint8Array(Z),X=this.memory.newHeapBufferPointer($),Y=this.ffi.QTS_NewArrayBuffer(this.ctx.value,X.value.pointer,$.length);return this.memory.heapValueHandle(Y)}newPromise(Z){let $=I.withScope((X)=>{let Y=X.manage(this.memory.newMutablePointerArray(2)),B=this.ffi.QTS_NewPromiseCapability(this.ctx.value,Y.value.ptr),C=this.memory.heapValueHandle(B),[U,z]=Array.from(Y.value.typedArray).map((D)=>this.memory.heapValueHandle(D));return new i9({context:this,promiseHandle:C,resolveHandle:U,rejectHandle:z})});return Z&&typeof Z=="function"&&(Z=new Promise(Z)),Z&&Promise.resolve(Z).then($.resolve,(X)=>X instanceof w?$.reject(X):this.newError(X).consume($.reject)),$}newFunction(Z,$){let X=typeof Z=="function"?Z:$;if(!X)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof Z=="string"?Z:void 0,length:X.length,isConstructor:!1,fn:X})}newConstructorFunction(Z,$){let X=typeof Z=="function"?Z:$;if(!X)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof Z=="string"?Z:void 0,length:X.length,isConstructor:!0,fn:X})}newFunctionWithOptions(Z){let{name:$,length:X,isConstructor:Y,fn:B}=Z,C=this.runtime.hostRefs.put(B);try{return this.memory.heapValueHandle(this.ffi.QTS_NewFunction(this.ctx.value,$??"",X,Y,C))}catch(U){throw this.runtime.hostRefs.delete(C),U}}newError(Z){let $=this.memory.heapValueHandle(this.ffi.QTS_NewError(this.ctx.value));return Z&&typeof Z=="object"?(Z.name!==void 0&&this.newString(Z.name).consume((X)=>this.setProp($,"name",X)),Z.message!==void 0&&this.newString(Z.message).consume((X)=>this.setProp($,"message",X))):typeof Z=="string"?this.newString(Z).consume((X)=>this.setProp($,"message",X)):Z!==void 0&&this.newString(String(Z)).consume((X)=>this.setProp($,"message",X)),$}newHostRef(Z){let $=this.runtime.hostRefs.put(Z);try{let X=this.memory.heapValueHandle(this.ffi.QTS_NewHostRef(this.ctx.value,$));return new a8(this.runtime,X,$)}catch(X){throw this.runtime.hostRefs.delete($),X}}toHostRef(Z){let $=this.ffi.QTS_GetHostRefId(Z.value);if($!==0)return this.runtime.hostRefs.get($),new a8(this.runtime,Z.dup(),$)}unwrapHostRef(Z){let $=this.ffi.QTS_GetHostRefId(Z.value);if($===0)throw new f("handle is not a HostRef");return this.runtime.hostRefs.get($)}typeof(Z){return this.runtime.assertOwned(Z),this.memory.consumeHeapCharPointer(this.ffi.QTS_Typeof(this.ctx.value,Z.value))}getNumber(Z){return this.runtime.assertOwned(Z),this.ffi.QTS_GetFloat64(this.ctx.value,Z.value)}getString(Z){return this.runtime.assertOwned(Z),this.memory.consumeJSCharPointer(this.ffi.QTS_GetString(this.ctx.value,Z.value))}getSymbol(Z){this.runtime.assertOwned(Z);let $=this.memory.consumeJSCharPointer(this.ffi.QTS_GetSymbolDescriptionOrKey(this.ctx.value,Z.value));return this.ffi.QTS_IsGlobalSymbol(this.ctx.value,Z.value)?Symbol.for($):Symbol($)}getBigInt(Z){this.runtime.assertOwned(Z);let $=this.getString(Z);return BigInt($)}getArrayBuffer(Z){this.runtime.assertOwned(Z);let $=this.ffi.QTS_GetArrayBufferLength(this.ctx.value,Z.value),X=this.ffi.QTS_GetArrayBuffer(this.ctx.value,Z.value);if(!X)throw Error("Couldn't allocate memory to get ArrayBuffer");return new w(this.module.HEAPU8.subarray(X,X+$),void 0,()=>this.module._free(X))}getPromiseState(Z){this.runtime.assertOwned(Z);let $=this.ffi.QTS_PromiseState(this.ctx.value,Z.value);if($<0)return{type:"fulfilled",value:Z,notAPromise:!0};if($===l.Pending)return{type:"pending",get error(){return new $9("Cannot unwrap a pending promise")}};let X=this.ffi.QTS_PromiseResult(this.ctx.value,Z.value),Y=this.memory.heapValueHandle(X);if($===l.Fulfilled)return{type:"fulfilled",value:Y};if($===l.Rejected)return{type:"rejected",error:Y};throw Y.dispose(),Error(`Unknown JSPromiseStateEnum: ${$}`)}resolvePromise(Z){this.runtime.assertOwned(Z);let $=I.withScope((X)=>{let Y=X.manage(this.getProp(this.global,"Promise")),B=X.manage(this.getProp(Y,"resolve"));return this.callFunction(B,Y,Z)});return $.error?Promise.resolve($):new Promise((X)=>{I.withScope((Y)=>{let B=Y.manage(this.newFunction("resolve",(D)=>{X(this.success(D&&D.dup()))})),C=Y.manage(this.newFunction("reject",(D)=>{X(this.fail(D&&D.dup()))})),U=Y.manage($.value),z=Y.manage(this.getProp(U,"then"));this.callFunction(z,U,B,C).unwrap().dispose()})})}isEqual(Z,$,X=c.IsStrictlyEqual){if(Z===$)return!0;this.runtime.assertOwned(Z),this.runtime.assertOwned($);let Y=this.ffi.QTS_IsEqual(this.ctx.value,Z.value,$.value,X);if(Y===-1)throw new t8("WASM variant does not expose equality");return!!Y}eq(Z,$){return this.isEqual(Z,$,c.IsStrictlyEqual)}sameValue(Z,$){return this.isEqual(Z,$,c.IsSameValue)}sameValueZero(Z,$){return this.isEqual(Z,$,c.IsSameValueZero)}getProp(Z,$){this.runtime.assertOwned(Z);let X;return typeof $=="number"&&$>=0?X=this.ffi.QTS_GetPropNumber(this.ctx.value,Z.value,$):X=this.borrowPropertyKey($).consume((Y)=>this.ffi.QTS_GetProp(this.ctx.value,Z.value,Y.value)),this.memory.heapValueHandle(X)}getLength(Z){if(this.runtime.assertOwned(Z),!(this.ffi.QTS_GetLength(this.ctx.value,this.uint32Out.value.ptr,Z.value)<0))return this.uint32Out.value.typedArray[0]}getOwnPropertyNames(Z,$={strings:!0,numbersAsStrings:!0}){this.runtime.assertOwned(Z),Z.value;let X=a9($);if(X===0)throw new X9("No options set, will return an empty array");return I.withScope((Y)=>{let B=Y.manage(this.memory.newMutablePointerArray(1)),C=this.ffi.QTS_GetOwnPropertyNames(this.ctx.value,B.value.ptr,this.uint32Out.value.ptr,Z.value,X);if(C)return this.fail(this.memory.heapValueHandle(C));let U=this.uint32Out.value.typedArray[0],z=B.value.typedArray[0],D=new Uint32Array(this.module.HEAP8.buffer,z,U),P=Array.from(D).map((x)=>this.memory.heapValueHandle(x));return this.ffi.QTS_FreeVoidPointer(this.ctx.value,z),this.success(p9(P))})}getIterator(Z){let $=this._SymbolIterator??(this._SymbolIterator=this.memory.manage(this.getWellKnownSymbol("iterator")));return I.withScope((X)=>{let Y=X.manage(this.getProp(Z,$)),B=this.callFunction(Y,Z);return B.error?B:this.success(new t9(B.value,this))})}setProp(Z,$,X){this.runtime.assertOwned(Z),this.borrowPropertyKey($).consume((Y)=>this.ffi.QTS_SetProp(this.ctx.value,Z.value,Y.value,X.value))}defineProp(Z,$,X){this.runtime.assertOwned(Z),I.withScope((Y)=>{let B=Y.manage(this.borrowPropertyKey($)),C=X.value||this.undefined,U=!!X.configurable,z=!!X.enumerable,D=!!X.value,P=X.get?Y.manage(this.newFunction(X.get.name,X.get)):this.undefined,x=X.set?Y.manage(this.newFunction(X.set.name,X.set)):this.undefined;this.ffi.QTS_DefineProp(this.ctx.value,Z.value,B.value,C.value,P.value,x.value,U,z,D)})}callFunction(Z,$,...X){this.runtime.assertOwned(Z);let Y,B=X[0];B===void 0||Array.isArray(B)?Y=B??[]:Y=X;let C=this.memory.toPointerArray(Y).consume((z)=>this.ffi.QTS_Call(this.ctx.value,Z.value,$.value,Y.length,z.value)),U=this.ffi.QTS_ResolveException(this.ctx.value,C);return U?(this.ffi.QTS_FreeValuePointer(this.ctx.value,C),this.fail(this.memory.heapValueHandle(U))):this.success(this.memory.heapValueHandle(C))}callMethod(Z,$,X=[]){return this.getProp(Z,$).consume((Y)=>this.callFunction(Y,Z,X))}evalCode(Z,$="eval.js",X){let Y=X===void 0?1:0,B=n9(X),C=this.memory.newHeapCharPointer(Z).consume((z)=>this.ffi.QTS_Eval(this.ctx.value,z.value.ptr,z.value.strlen,$,Y,B)),U=this.ffi.QTS_ResolveException(this.ctx.value,C);return U?(this.ffi.QTS_FreeValuePointer(this.ctx.value,C),this.fail(this.memory.heapValueHandle(U))):this.success(this.memory.heapValueHandle(C))}throw(Z){return this.errorToHandle(Z).consume(($)=>this.ffi.QTS_Throw(this.ctx.value,$.value))}borrowPropertyKey(Z){return typeof Z=="number"?this.newNumber(Z):typeof Z=="string"?this.newString(Z):new v(Z.value,this.runtime)}getMemory(Z){if(Z===this.rt.value)return this.memory;throw Error("Private API. Cannot get memory from a different runtime")}dump(Z){this.runtime.assertOwned(Z);let $=this.typeof(Z);if($==="string")return this.getString(Z);if($==="number")return this.getNumber(Z);if($==="bigint")return this.getBigInt(Z);if($==="undefined")return;if($==="symbol")return this.getSymbol(Z);let X=this.getPromiseState(Z);if(X.type==="fulfilled"&&!X.notAPromise)return Z.dispose(),{type:X.type,value:X.value.consume(this.dump)};if(X.type==="pending")return Z.dispose(),{type:X.type};if(X.type==="rejected")return Z.dispose(),{type:X.type,error:X.error.consume(this.dump)};let Y=this.memory.consumeJSCharPointer(this.ffi.QTS_Dump(this.ctx.value,Z.value));try{return JSON.parse(Y)}catch{return Y}}unwrapResult(Z){if(Z.error){let $="context"in Z.error?Z.error.context:this,X=Z.error.consume((Y)=>this.dump(Y));if(X&&typeof X=="object"&&typeof X.message=="string"){let{message:Y,name:B,stack:C,...U}=X,z=new Y8(X,$);typeof B=="string"&&(z.name=X.name),z.message=Y;let D=z.stack;throw typeof C=="string"&&(z.stack=`${B}: ${Y}
|
|
7
|
+
${X.stack}Host: ${D}`),Object.assign(z,U),z}throw new Y8(X)}return Z.value}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { ctx: ${this.ctx.value} rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getFunction(Z){let $=this.runtime.hostRefs.get(Z);if(typeof $!="function")throw Error(`Host reference ${Z} is not a function`);return $}errorToHandle(Z){return Z instanceof w?Z:this.newError(Z)}encodeBinaryJSON(Z){let $=this.ffi.QTS_bjson_encode(this.ctx.value,Z.value);return this.memory.heapValueHandle($)}decodeBinaryJSON(Z){let $=this.ffi.QTS_bjson_decode(this.ctx.value,Z.value);return this.memory.heapValueHandle($)}success(Z){return g.success(Z)}fail(Z){return g.fail(Z,($)=>this.unwrapResult($))}},$Z=class extends A{constructor(Z){super();this.scope=new I,this.contextMap=new Map,this.hostRefs=new r9,this._debugMode=!1,this.cToHostCallbacks={freeHostRef:($,X)=>{if($!==this.rt.value)throw Error("Runtime pointer mismatch");this.hostRefs.delete(X)},shouldInterrupt:($)=>{if($!==this.rt.value)throw Error("QuickJSContext instance received C -> JS interrupt with mismatched rt");let X=this.interruptHandler;if(!X)throw Error("QuickJSContext had no interrupt handler");return X(this)?1:0},loadModuleSource:u8(this,function*($,X,Y,B){let C=this.moduleLoader;if(!C)throw Error("Runtime has no module loader");if(X!==this.rt.value)throw Error("Runtime pointer mismatch");let U=this.contextMap.get(Y)??this.newContext({contextPointer:Y});try{let z=yield*$(C(B,U));if(typeof z=="object"&&"error"in z&&z.error)throw this.debugLog("cToHostLoadModule: loader returned error",z.error),z.error;let D=typeof z=="string"?z:("value"in z)?z.value:z;return this.memory.newHeapCharPointer(D).value.ptr}catch(z){return this.debugLog("cToHostLoadModule: caught error",z),U.throw(z),0}}),normalizeModule:u8(this,function*($,X,Y,B,C){let U=this.moduleNormalizer;if(!U)throw Error("Runtime has no module normalizer");if(X!==this.rt.value)throw Error("Runtime pointer mismatch");let z=this.contextMap.get(Y)??this.newContext({contextPointer:Y});try{let D=yield*$(U(B,C,z));if(typeof D=="object"&&"error"in D&&D.error)throw this.debugLog("cToHostNormalizeModule: normalizer returned error",D.error),D.error;let P=typeof D=="string"?D:D.value;return z.getMemory(this.rt.value).newHeapCharPointer(P).value.ptr}catch(D){return this.debugLog("normalizeModule: caught error",D),z.throw(D),0}})},Z.ownedLifetimes?.forEach(($)=>this.scope.manage($)),this.module=Z.module,this.memory=new z9(this.module),this.ffi=Z.ffi,this.rt=Z.rt,this.callbacks=Z.callbacks,this.scope.manage(this.rt),this.callbacks.setRuntimeCallbacks(this.rt.value,this.cToHostCallbacks),this.executePendingJobs=this.executePendingJobs.bind(this),B8&&this.setDebugMode(!0)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}newContext(Z={}){let $=o9(Z.intrinsics),X=new w(Z.contextPointer||this.ffi.QTS_NewContext(this.rt.value,$),void 0,(B)=>{this.contextMap.delete(B),this.callbacks.deleteContext(B),this.ffi.QTS_FreeContext(B)}),Y=new ZZ({module:this.module,ctx:X,ffi:this.ffi,rt:this.rt,ownedLifetimes:Z.ownedLifetimes,runtime:this,callbacks:this.callbacks});return this.contextMap.set(X.value,Y),Y}setModuleLoader(Z,$){this.moduleLoader=Z,this.moduleNormalizer=$,this.ffi.QTS_RuntimeEnableModuleLoader(this.rt.value,this.moduleNormalizer?1:0)}removeModuleLoader(){this.moduleLoader=void 0,this.ffi.QTS_RuntimeDisableModuleLoader(this.rt.value)}hasPendingJob(){return!!this.ffi.QTS_IsJobPending(this.rt.value)}setInterruptHandler(Z){let $=this.interruptHandler;this.interruptHandler=Z,$||this.ffi.QTS_RuntimeEnableInterruptHandler(this.rt.value)}removeInterruptHandler(){this.interruptHandler&&(this.ffi.QTS_RuntimeDisableInterruptHandler(this.rt.value),this.interruptHandler=void 0)}executePendingJobs(Z=-1){let $=this.memory.newMutablePointerArray(1),X=this.ffi.QTS_ExecutePendingJob(this.rt.value,Z??-1,$.value.ptr),Y=$.value.typedArray[0];if($.dispose(),Y===0)return this.ffi.QTS_FreeValuePointerRuntime(this.rt.value,X),g.success(0);let B=this.contextMap.get(Y)??this.newContext({contextPointer:Y}),C=B.getMemory(this.rt.value).heapValueHandle(X);if(B.typeof(C)==="number"){let U=B.getNumber(C);return C.dispose(),g.success(U)}else{let U=Object.assign(C,{context:B});return g.fail(U,(z)=>B.unwrapResult(z))}}setMemoryLimit(Z){if(Z<0&&Z!==-1)throw Error("Cannot set memory limit to negative number. To unset, pass -1");this.ffi.QTS_RuntimeSetMemoryLimit(this.rt.value,Z)}computeMemoryUsage(){let Z=this.getSystemContext().getMemory(this.rt.value);return Z.heapValueHandle(this.ffi.QTS_RuntimeComputeMemoryUsage(this.rt.value,Z.ctx.value))}dumpMemoryUsage(){return this.memory.consumeHeapCharPointer(this.ffi.QTS_RuntimeDumpMemoryUsage(this.rt.value))}setMaxStackSize(Z){if(Z<0)throw Error("Cannot set memory limit to negative number. To unset, pass 0.");this.ffi.QTS_RuntimeSetMaxStackSize(this.rt.value,Z)}assertOwned(Z){if(Z.owner&&Z.owner.rt!==this.rt)throw new s8(`Handle is not owned by this runtime: ${Z.owner.rt.value} != ${this.rt.value}`)}setDebugMode(Z){this._debugMode=Z,this.ffi.DEBUG&&this.rt.alive&&this.ffi.QTS_SetDebugLogEnabled(this.rt.value,Z?1:0)}isDebugMode(){return this._debugMode}debugLog(...Z){this._debugMode&&console.log("quickjs-emscripten:",...Z)}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getSystemContext(){return this.context||(this.context=this.scope.manage(this.newContext())),this.context}}});var G9={};f9(G9,{applyModuleEvalRuntimeOptions:()=>j8,applyBaseRuntimeOptions:()=>H8,QuickJSWASMModule:()=>Y9,QuickJSModuleCallbacks:()=>U8});var B9=X8(()=>{Q9()});var j9=A9((a,H9)=>{(function(Z,$){typeof a==="object"&&typeof H9<"u"?$(a):typeof define==="function"&&define.amd?define(["exports"],$):(Z=typeof globalThis<"u"?globalThis:Z||self,$(Z.jmespath={}))})(a,function(Z){let $=(W)=>{return W!==null&&Object.prototype.toString.call(W)==="[object Object]"},X=(W,K)=>{if(W===K)return!0;if(typeof W!==typeof K)return!1;if(Array.isArray(W)&&Array.isArray(K)){if(W.length!==K.length)return!1;for(let Q=0;Q<W.length;Q+=1)if(!X(W[Q],K[Q]))return!1;return!0}if($(W)&&$(K)){let Q=Object.entries(W),G=new Set(Object.keys(K));if(Q.length!==G.size)return!1;for(let[q,H]of Q){if(!X(H,K[q]))return!1;G.delete(q)}return G.size===0}return!1},Y=(W)=>{if(W===""||W===!1||W===null||W===void 0)return!0;if(Array.isArray(W)&&W.length===0)return!0;if($(W)){for(let K in W)if(W.hasOwnProperty(K))return!1;return!0}return!1},B=(W)=>{return W>="a"&&W<="z"||W>="A"&&W<="Z"||W==="_"},C=(W)=>{return W>="0"&&W<="9"||W==="-"},U=(W)=>{return W>="a"&&W<="z"||W>="A"&&W<="Z"||W>="0"&&W<="9"||W==="_"};var z;(function(W){W.TOK_EOF="EOF",W.TOK_UNQUOTEDIDENTIFIER="UnquotedIdentifier",W.TOK_QUOTEDIDENTIFIER="QuotedIdentifier",W.TOK_RBRACKET="Rbracket",W.TOK_RPAREN="Rparen",W.TOK_COMMA="Comma",W.TOK_COLON="Colon",W.TOK_RBRACE="Rbrace",W.TOK_NUMBER="Number",W.TOK_CURRENT="Current",W.TOK_ROOT="Root",W.TOK_EXPREF="Expref",W.TOK_PIPE="Pipe",W.TOK_OR="Or",W.TOK_AND="And",W.TOK_EQ="EQ",W.TOK_GT="GT",W.TOK_LT="LT",W.TOK_GTE="GTE",W.TOK_LTE="LTE",W.TOK_NE="NE",W.TOK_FLATTEN="Flatten",W.TOK_STAR="Star",W.TOK_FILTER="Filter",W.TOK_DOT="Dot",W.TOK_NOT="Not",W.TOK_LBRACE="Lbrace",W.TOK_LBRACKET="Lbracket",W.TOK_LPAREN="Lparen",W.TOK_LITERAL="Literal"})(z||(z={}));let D={"(":z.TOK_LPAREN,")":z.TOK_RPAREN,"*":z.TOK_STAR,",":z.TOK_COMMA,".":z.TOK_DOT,":":z.TOK_COLON,"@":z.TOK_CURRENT,["$"]:z.TOK_ROOT,"]":z.TOK_RBRACKET,"{":z.TOK_LBRACE,"}":z.TOK_RBRACE},P={"!":!0,"<":!0,"=":!0,">":!0},x={"\t":!0,"\n":!0,"\r":!0," ":!0};class M{constructor(){this._current=0}tokenize(W){let K=[];this._current=0;let Q,G,q;while(this._current<W.length)if(B(W[this._current]))Q=this._current,G=this.consumeUnquotedIdentifier(W),K.push({start:Q,type:z.TOK_UNQUOTEDIDENTIFIER,value:G});else if(D[W[this._current]]!==void 0)K.push({start:this._current,type:D[W[this._current]],value:W[this._current]}),this._current+=1;else if(C(W[this._current]))q=this.consumeNumber(W),K.push(q);else if(W[this._current]==="[")q=this.consumeLBracket(W),K.push(q);else if(W[this._current]==='"')Q=this._current,G=this.consumeQuotedIdentifier(W),K.push({start:Q,type:z.TOK_QUOTEDIDENTIFIER,value:G});else if(W[this._current]==="'")Q=this._current,G=this.consumeRawStringLiteral(W),K.push({start:Q,type:z.TOK_LITERAL,value:G});else if(W[this._current]==="`"){Q=this._current;let H=this.consumeLiteral(W);K.push({start:Q,type:z.TOK_LITERAL,value:H})}else if(P[W[this._current]]!==void 0)q=this.consumeOperator(W),q&&K.push(q);else if(x[W[this._current]]!==void 0)this._current+=1;else if(W[this._current]==="&")if(Q=this._current,this._current+=1,W[this._current]==="&")this._current+=1,K.push({start:Q,type:z.TOK_AND,value:"&&"});else K.push({start:Q,type:z.TOK_EXPREF,value:"&"});else if(W[this._current]==="|")if(Q=this._current,this._current+=1,W[this._current]==="|")this._current+=1,K.push({start:Q,type:z.TOK_OR,value:"||"});else K.push({start:Q,type:z.TOK_PIPE,value:"|"});else{let H=Error(`Unknown character: ${W[this._current]}`);throw H.name="LexerError",H}return K}consumeUnquotedIdentifier(W){let K=this._current;this._current+=1;while(this._current<W.length&&U(W[this._current]))this._current+=1;return W.slice(K,this._current)}consumeQuotedIdentifier(W){let K=this._current;this._current+=1;let Q=W.length;while(W[this._current]!=='"'&&this._current<Q){let G=this._current;if(W[G]==="\\"&&(W[G+1]==="\\"||W[G+1]==='"'))G+=2;else G+=1;this._current=G}return this._current+=1,JSON.parse(W.slice(K,this._current))}consumeRawStringLiteral(W){let K=this._current;this._current+=1;let Q=W.length;while(W[this._current]!=="'"&&this._current<Q){let q=this._current;if(W[q]==="\\"&&(W[q+1]==="\\"||W[q+1]==="'"))q+=2;else q+=1;this._current=q}return this._current+=1,W.slice(K+1,this._current-1).replace("\\'","'")}consumeNumber(W){let K=this._current;this._current+=1;let Q=W.length;while(C(W[this._current])&&this._current<Q)this._current+=1;let G=parseInt(W.slice(K,this._current),10);return{start:K,value:G,type:z.TOK_NUMBER}}consumeLBracket(W){let K=this._current;if(this._current+=1,W[this._current]==="?")return this._current+=1,{start:K,type:z.TOK_FILTER,value:"[?"};if(W[this._current]==="]")return this._current+=1,{start:K,type:z.TOK_FLATTEN,value:"[]"};return{start:K,type:z.TOK_LBRACKET,value:"["}}consumeOperator(W){let K=this._current,Q=W[K];if(this._current+=1,Q==="!"){if(W[this._current]==="=")return this._current+=1,{start:K,type:z.TOK_NE,value:"!="};return{start:K,type:z.TOK_NOT,value:"!"}}if(Q==="<"){if(W[this._current]==="=")return this._current+=1,{start:K,type:z.TOK_LTE,value:"<="};return{start:K,type:z.TOK_LT,value:"<"}}if(Q===">"){if(W[this._current]==="=")return this._current+=1,{start:K,type:z.TOK_GTE,value:">="};return{start:K,type:z.TOK_GT,value:">"}}if(Q==="="&&W[this._current]==="=")return this._current+=1,{start:K,type:z.TOK_EQ,value:"=="}}consumeLiteral(W){this._current+=1;let K=this._current,Q=W.length;while(W[this._current]!=="`"&&this._current<Q){let H=this._current;if(W[H]==="\\"&&(W[H+1]==="\\"||W[H+1]==="`"))H+=2;else H+=1;this._current=H}let G=W.slice(K,this._current).trimLeft();G=G.replace("\\`","`");let q=this.looksLikeJSON(G)?JSON.parse(G):JSON.parse(`"${G}"`);return this._current+=1,q}looksLikeJSON(W){let Q=["true","false","null"],G="-0123456789";if(W==="")return!1;if('[{"'.includes(W[0]))return!0;if(Q.includes(W))return!0;if("-0123456789".includes(W[0]))try{return JSON.parse(W),!0}catch(q){return!1}return!1}}let b=new M,_={[z.TOK_EOF]:0,[z.TOK_UNQUOTEDIDENTIFIER]:0,[z.TOK_QUOTEDIDENTIFIER]:0,[z.TOK_RBRACKET]:0,[z.TOK_RPAREN]:0,[z.TOK_COMMA]:0,[z.TOK_RBRACE]:0,[z.TOK_NUMBER]:0,[z.TOK_CURRENT]:0,[z.TOK_EXPREF]:0,[z.TOK_ROOT]:0,[z.TOK_PIPE]:1,[z.TOK_OR]:2,[z.TOK_AND]:3,[z.TOK_EQ]:5,[z.TOK_GT]:5,[z.TOK_LT]:5,[z.TOK_GTE]:5,[z.TOK_LTE]:5,[z.TOK_NE]:5,[z.TOK_FLATTEN]:9,[z.TOK_STAR]:20,[z.TOK_FILTER]:21,[z.TOK_DOT]:40,[z.TOK_NOT]:45,[z.TOK_LBRACE]:50,[z.TOK_LBRACKET]:55,[z.TOK_LPAREN]:60};class O8{constructor(){this.index=0,this.tokens=[]}parse(W){this.loadTokens(W),this.index=0;let K=this.expression(0);if(this.lookahead(0)!==z.TOK_EOF){let Q=this.lookaheadToken(0);this.errorToken(Q,`Unexpected token type: ${Q.type}, value: ${Q.value}`)}return K}loadTokens(W){this.tokens=[...b.tokenize(W),{type:z.TOK_EOF,value:"",start:W.length}]}expression(W){let K=this.lookaheadToken(0);this.advance();let Q=this.nud(K),G=this.lookahead(0);while(W<_[G])this.advance(),Q=this.led(G,Q),G=this.lookahead(0);return Q}lookahead(W){return this.tokens[this.index+W].type}lookaheadToken(W){return this.tokens[this.index+W]}advance(){this.index+=1}nud(W){let K,Q,G;switch(W.type){case z.TOK_LITERAL:return{type:"Literal",value:W.value};case z.TOK_UNQUOTEDIDENTIFIER:return{type:"Field",name:W.value};case z.TOK_QUOTEDIDENTIFIER:let q={type:"Field",name:W.value};if(this.lookahead(0)===z.TOK_LPAREN)throw Error("Quoted identifier not allowed for function names.");else return q;case z.TOK_NOT:return Q=this.expression(_.Not),{type:"NotExpression",children:[Q]};case z.TOK_STAR:return K={type:"Identity"},Q=this.lookahead(0)===z.TOK_RBRACKET&&{type:"Identity"}||this.parseProjectionRHS(_.Star),{type:"ValueProjection",children:[K,Q]};case z.TOK_FILTER:return this.led(W.type,{type:"Identity"});case z.TOK_LBRACE:return this.parseMultiselectHash();case z.TOK_FLATTEN:return K={type:z.TOK_FLATTEN,children:[{type:"Identity"}]},Q=this.parseProjectionRHS(_.Flatten),{type:"Projection",children:[K,Q]};case z.TOK_LBRACKET:if(this.lookahead(0)===z.TOK_NUMBER||this.lookahead(0)===z.TOK_COLON)return Q=this.parseIndexExpression(),this.projectIfSlice({type:"Identity"},Q);if(this.lookahead(0)===z.TOK_STAR&&this.lookahead(1)===z.TOK_RBRACKET)return this.advance(),this.advance(),Q=this.parseProjectionRHS(_.Star),{children:[{type:"Identity"},Q],type:"Projection"};return this.parseMultiselectList();case z.TOK_CURRENT:return{type:z.TOK_CURRENT};case z.TOK_ROOT:return{type:z.TOK_ROOT};case z.TOK_EXPREF:return G=this.expression(_.Expref),{type:"ExpressionReference",children:[G]};case z.TOK_LPAREN:let H=[];while(this.lookahead(0)!==z.TOK_RPAREN){if(this.lookahead(0)===z.TOK_CURRENT)G={type:z.TOK_CURRENT},this.advance();else G=this.expression(0);H.push(G)}return this.match(z.TOK_RPAREN),H[0];default:this.errorToken(W)}}led(W,K){let Q;switch(W){case z.TOK_DOT:let G=_.Dot;if(this.lookahead(0)!==z.TOK_STAR)return Q=this.parseDotRHS(G),{type:"Subexpression",children:[K,Q]};return this.advance(),Q=this.parseProjectionRHS(G),{type:"ValueProjection",children:[K,Q]};case z.TOK_PIPE:return Q=this.expression(_.Pipe),{type:z.TOK_PIPE,children:[K,Q]};case z.TOK_OR:return Q=this.expression(_.Or),{type:"OrExpression",children:[K,Q]};case z.TOK_AND:return Q=this.expression(_.And),{type:"AndExpression",children:[K,Q]};case z.TOK_LPAREN:let q=K.name,H=[],L;while(this.lookahead(0)!==z.TOK_RPAREN){if(this.lookahead(0)===z.TOK_CURRENT)L={type:z.TOK_CURRENT},this.advance();else L=this.expression(0);if(this.lookahead(0)===z.TOK_COMMA)this.match(z.TOK_COMMA);H.push(L)}return this.match(z.TOK_RPAREN),{name:q,type:"Function",children:H};case z.TOK_FILTER:let O=this.expression(0);return this.match(z.TOK_RBRACKET),Q=this.lookahead(0)===z.TOK_FLATTEN&&{type:"Identity"}||this.parseProjectionRHS(_.Filter),{type:"FilterProjection",children:[K,Q,O]};case z.TOK_FLATTEN:let N={type:z.TOK_FLATTEN,children:[K]},R=this.parseProjectionRHS(_.Flatten);return{type:"Projection",children:[N,R]};case z.TOK_EQ:case z.TOK_NE:case z.TOK_GT:case z.TOK_GTE:case z.TOK_LT:case z.TOK_LTE:return this.parseComparator(K,W);case z.TOK_LBRACKET:let j=this.lookaheadToken(0);if(j.type===z.TOK_NUMBER||j.type===z.TOK_COLON)return Q=this.parseIndexExpression(),this.projectIfSlice(K,Q);return this.match(z.TOK_STAR),this.match(z.TOK_RBRACKET),Q=this.parseProjectionRHS(_.Star),{type:"Projection",children:[K,Q]};default:return this.errorToken(this.lookaheadToken(0))}}match(W){if(this.lookahead(0)===W){this.advance();return}else{let K=this.lookaheadToken(0);this.errorToken(K,`Expected ${W}, got: ${K.type}`)}}errorToken(W,K=""){let Q=Error(K||`Invalid token (${W.type}): "${W.value}"`);throw Q.name="ParserError",Q}parseIndexExpression(){if(this.lookahead(0)===z.TOK_COLON||this.lookahead(1)===z.TOK_COLON)return this.parseSliceExpression();let W={type:"Index",value:this.lookaheadToken(0).value};return this.advance(),this.match(z.TOK_RBRACKET),W}projectIfSlice(W,K){let Q={type:"IndexExpression",children:[W,K]};if(K.type==="Slice")return{children:[Q,this.parseProjectionRHS(_.Star)],type:"Projection"};return Q}parseSliceExpression(){let W=[null,null,null],K=0,Q=this.lookahead(0);while(Q!==z.TOK_RBRACKET&&K<3){if(Q===z.TOK_COLON)K+=1,this.advance();else if(Q===z.TOK_NUMBER)W[K]=this.lookaheadToken(0).value,this.advance();else{let G=this.lookaheadToken(0);this.errorToken(G,`Syntax error, unexpected token: ${G.value}(${G.type})`)}Q=this.lookahead(0)}return this.match(z.TOK_RBRACKET),{children:W,type:"Slice"}}parseComparator(W,K){let Q=this.expression(_[K]);return{type:"Comparator",name:K,children:[W,Q]}}parseDotRHS(W){let K=this.lookahead(0);if([z.TOK_UNQUOTEDIDENTIFIER,z.TOK_QUOTEDIDENTIFIER,z.TOK_STAR].includes(K))return this.expression(W);if(K===z.TOK_LBRACKET)return this.match(z.TOK_LBRACKET),this.parseMultiselectList();if(K===z.TOK_LBRACE)return this.match(z.TOK_LBRACE),this.parseMultiselectHash();let G=this.lookaheadToken(0);this.errorToken(G,`Syntax error, unexpected token: ${G.value}(${G.type})`)}parseProjectionRHS(W){if(_[this.lookahead(0)]<10)return{type:"Identity"};if(this.lookahead(0)===z.TOK_LBRACKET)return this.expression(W);if(this.lookahead(0)===z.TOK_FILTER)return this.expression(W);if(this.lookahead(0)===z.TOK_DOT)return this.match(z.TOK_DOT),this.parseDotRHS(W);let K=this.lookaheadToken(0);this.errorToken(K,`Syntax error, unexpected token: ${K.value}(${K.type})`)}parseMultiselectList(){let W=[];while(this.lookahead(0)!==z.TOK_RBRACKET){let K=this.expression(0);if(W.push(K),this.lookahead(0)===z.TOK_COMMA){if(this.match(z.TOK_COMMA),this.lookahead(0)===z.TOK_RBRACKET)throw Error("Unexpected token Rbracket")}}return this.match(z.TOK_RBRACKET),{type:"MultiSelectList",children:W}}parseMultiselectHash(){let W=[],K=[z.TOK_UNQUOTEDIDENTIFIER,z.TOK_QUOTEDIDENTIFIER],Q,G,q;for(;;){if(Q=this.lookaheadToken(0),!K.includes(Q.type))throw Error(`Expecting an identifier token, got: ${Q.type}`);if(G=Q.value,this.advance(),this.match(z.TOK_COLON),q=this.expression(0),W.push({value:q,type:"KeyValuePair",name:G}),this.lookahead(0)===z.TOK_COMMA)this.match(z.TOK_COMMA);else if(this.lookahead(0)===z.TOK_RBRACE){this.match(z.TOK_RBRACE);break}}return{type:"MultiSelectHash",children:W}}}let R8=new O8;var J;(function(W){W[W.TYPE_NUMBER=0]="TYPE_NUMBER",W[W.TYPE_ANY=1]="TYPE_ANY",W[W.TYPE_STRING=2]="TYPE_STRING",W[W.TYPE_ARRAY=3]="TYPE_ARRAY",W[W.TYPE_OBJECT=4]="TYPE_OBJECT",W[W.TYPE_BOOLEAN=5]="TYPE_BOOLEAN",W[W.TYPE_EXPREF=6]="TYPE_EXPREF",W[W.TYPE_NULL=7]="TYPE_NULL",W[W.TYPE_ARRAY_NUMBER=8]="TYPE_ARRAY_NUMBER",W[W.TYPE_ARRAY_STRING=9]="TYPE_ARRAY_STRING"})(J||(J={}));class M8{constructor(W){this.TYPE_NAME_TABLE={[J.TYPE_NUMBER]:"number",[J.TYPE_ANY]:"any",[J.TYPE_STRING]:"string",[J.TYPE_ARRAY]:"array",[J.TYPE_OBJECT]:"object",[J.TYPE_BOOLEAN]:"boolean",[J.TYPE_EXPREF]:"expression",[J.TYPE_NULL]:"null",[J.TYPE_ARRAY_NUMBER]:"Array<number>",[J.TYPE_ARRAY_STRING]:"Array<string>"},this.functionAbs=([K])=>{return Math.abs(K)},this.functionAvg=([K])=>{let Q=0;for(let G=0;G<K.length;G+=1)Q+=K[G];return Q/K.length},this.functionCeil=([K])=>{return Math.ceil(K)},this.functionContains=(K)=>{let[Q,G]=K;return Q.includes(G)},this.functionEndsWith=(K)=>{let[Q,G]=K;return Q.includes(G,Q.length-G.length)},this.functionFloor=([K])=>{return Math.floor(K)},this.functionJoin=(K)=>{let[Q,G]=K;return G.join(Q)},this.functionKeys=([K])=>{return Object.keys(K)},this.functionLength=([K])=>{if(!$(K))return K.length;return Object.keys(K).length},this.functionMap=(K)=>{if(!this._interpreter)return[];let Q=[],G=this._interpreter,q=K[0],H=K[1];for(let L=0;L<H.length;L+=1)Q.push(G.visit(q,H[L]));return Q},this.functionMax=([K])=>{if(!K.length)return null;if(this.getTypeName(K[0])===J.TYPE_NUMBER)return Math.max(...K);let G=K,q=G[0];for(let H=1;H<G.length;H+=1)if(q.localeCompare(G[H])<0)q=G[H];return q},this.functionMaxBy=(K)=>{let Q=K[1],G=K[0],q=this.createKeyFunction(Q,[J.TYPE_NUMBER,J.TYPE_STRING]),H=-1/0,L,F;for(let O=0;O<G.length;O+=1)if(F=q&&q(G[O]),F!==void 0&&F>H)H=F,L=G[O];return L},this.functionMerge=(K)=>{let Q={};for(let G=0;G<K.length;G+=1){let q=K[G];Q=Object.assign(Q,q)}return Q},this.functionMin=([K])=>{if(!K.length)return null;if(this.getTypeName(K[0])===J.TYPE_NUMBER)return Math.min(...K);let G=K,q=G[0];for(let H=1;H<G.length;H+=1)if(G[H].localeCompare(q)<0)q=G[H];return q},this.functionMinBy=(K)=>{let Q=K[1],G=K[0],q=this.createKeyFunction(Q,[J.TYPE_NUMBER,J.TYPE_STRING]),H=1/0,L,F;for(let O=0;O<G.length;O+=1)if(F=q&&q(G[O]),F!==void 0&&F<H)H=F,L=G[O];return L},this.functionNotNull=(K)=>{for(let Q=0;Q<K.length;Q+=1)if(this.getTypeName(K[Q])!==J.TYPE_NULL)return K[Q];return null},this.functionReverse=([K])=>{if(this.getTypeName(K)===J.TYPE_STRING){let q=K,H="";for(let L=q.length-1;L>=0;L-=1)H+=q[L];return H}let G=K.slice(0);return G.reverse(),G},this.functionSort=([K])=>{return[...K].sort()},this.functionSortBy=(K)=>{if(!this._interpreter)return[];let Q=K[0].slice(0);if(Q.length===0)return Q;let G=this._interpreter,q=K[1],H=this.getTypeName(G.visit(q,Q[0]));if(H!==void 0&&![J.TYPE_NUMBER,J.TYPE_STRING].includes(H))throw Error(`TypeError: unexpected type (${this.TYPE_NAME_TABLE[H]})`);let L=[];for(let F=0;F<Q.length;F+=1)L.push([F,Q[F]]);L.sort((F,O)=>{let N=G.visit(q,F[1]),R=G.visit(q,O[1]);if(this.getTypeName(N)!==H)throw Error(`TypeError: expected (${this.TYPE_NAME_TABLE[H]}), received ${this.TYPE_NAME_TABLE[this.getTypeName(N)]}`);else if(this.getTypeName(R)!==H)throw Error(`TypeError: expected (${this.TYPE_NAME_TABLE[H]}), received ${this.TYPE_NAME_TABLE[this.getTypeName(R)]}`);if(N>R)return 1;return N<R?-1:F[0]-O[0]});for(let F=0;F<L.length;F+=1)Q[F]=L[F][1];return Q},this.functionStartsWith=([K,Q])=>{return K.startsWith(Q)},this.functionSum=([K])=>{return K.reduce((Q,G)=>Q+G,0)},this.functionToArray=([K])=>{if(this.getTypeName(K)===J.TYPE_ARRAY)return K;return[K]},this.functionToNumber=([K])=>{let Q=this.getTypeName(K),G;if(Q===J.TYPE_NUMBER)return K;if(Q===J.TYPE_STRING){if(G=+K,!isNaN(G))return G}return null},this.functionToString=([K])=>{if(this.getTypeName(K)===J.TYPE_STRING)return K;return JSON.stringify(K)},this.functionType=([K])=>{switch(this.getTypeName(K)){case J.TYPE_NUMBER:return"number";case J.TYPE_STRING:return"string";case J.TYPE_ARRAY:return"array";case J.TYPE_OBJECT:return"object";case J.TYPE_BOOLEAN:return"boolean";case J.TYPE_EXPREF:return"expref";case J.TYPE_NULL:return"null";default:return}},this.functionValues=([K])=>{return Object.values(K)},this.functionTable={abs:{_func:this.functionAbs,_signature:[{types:[J.TYPE_NUMBER]}]},avg:{_func:this.functionAvg,_signature:[{types:[J.TYPE_ARRAY_NUMBER]}]},ceil:{_func:this.functionCeil,_signature:[{types:[J.TYPE_NUMBER]}]},contains:{_func:this.functionContains,_signature:[{types:[J.TYPE_STRING,J.TYPE_ARRAY]},{types:[J.TYPE_ANY]}]},ends_with:{_func:this.functionEndsWith,_signature:[{types:[J.TYPE_STRING]},{types:[J.TYPE_STRING]}]},floor:{_func:this.functionFloor,_signature:[{types:[J.TYPE_NUMBER]}]},join:{_func:this.functionJoin,_signature:[{types:[J.TYPE_STRING]},{types:[J.TYPE_ARRAY_STRING]}]},keys:{_func:this.functionKeys,_signature:[{types:[J.TYPE_OBJECT]}]},length:{_func:this.functionLength,_signature:[{types:[J.TYPE_STRING,J.TYPE_ARRAY,J.TYPE_OBJECT]}]},map:{_func:this.functionMap,_signature:[{types:[J.TYPE_EXPREF]},{types:[J.TYPE_ARRAY]}]},max:{_func:this.functionMax,_signature:[{types:[J.TYPE_ARRAY_NUMBER,J.TYPE_ARRAY_STRING]}]},max_by:{_func:this.functionMaxBy,_signature:[{types:[J.TYPE_ARRAY]},{types:[J.TYPE_EXPREF]}]},merge:{_func:this.functionMerge,_signature:[{types:[J.TYPE_OBJECT],variadic:!0}]},min:{_func:this.functionMin,_signature:[{types:[J.TYPE_ARRAY_NUMBER,J.TYPE_ARRAY_STRING]}]},min_by:{_func:this.functionMinBy,_signature:[{types:[J.TYPE_ARRAY]},{types:[J.TYPE_EXPREF]}]},not_null:{_func:this.functionNotNull,_signature:[{types:[J.TYPE_ANY],variadic:!0}]},reverse:{_func:this.functionReverse,_signature:[{types:[J.TYPE_STRING,J.TYPE_ARRAY]}]},sort:{_func:this.functionSort,_signature:[{types:[J.TYPE_ARRAY_STRING,J.TYPE_ARRAY_NUMBER]}]},sort_by:{_func:this.functionSortBy,_signature:[{types:[J.TYPE_ARRAY]},{types:[J.TYPE_EXPREF]}]},starts_with:{_func:this.functionStartsWith,_signature:[{types:[J.TYPE_STRING]},{types:[J.TYPE_STRING]}]},sum:{_func:this.functionSum,_signature:[{types:[J.TYPE_ARRAY_NUMBER]}]},to_array:{_func:this.functionToArray,_signature:[{types:[J.TYPE_ANY]}]},to_number:{_func:this.functionToNumber,_signature:[{types:[J.TYPE_ANY]}]},to_string:{_func:this.functionToString,_signature:[{types:[J.TYPE_ANY]}]},type:{_func:this.functionType,_signature:[{types:[J.TYPE_ANY]}]},values:{_func:this.functionValues,_signature:[{types:[J.TYPE_OBJECT]}]}},this._interpreter=W}registerFunction(W,K,Q){if(W in this.functionTable)throw Error(`Function already defined: ${W}()`);this.functionTable[W]={_func:K.bind(this),_signature:Q}}callFunction(W,K){let Q=this.functionTable[W];if(Q===void 0)throw Error(`Unknown function: ${W}()`);return this.validateArgs(W,K,Q._signature),Q._func.call(this,K)}validateInputSignatures(W,K){for(let Q=0;Q<K.length;Q+=1)if("variadic"in K[Q]&&Q!==K.length-1)throw Error(`ArgumentError: ${W}() 'variadic' argument ${Q+1} must occur last`)}validateArgs(W,K,Q){var G,q;let H;this.validateInputSignatures(W,Q);let L=Q.filter((E)=>{var S;return(S=!E.optional)!==null&&S!==void 0?S:!1}).length,F=(q=(G=Q[Q.length-1])===null||G===void 0?void 0:G.variadic)!==null&&q!==void 0?q:!1,O=K.length<L,N=K.length>Q.length,R=O&&(!F&&L>1||F)?"at least ":"";if(F&&O||!F&&(O||N))throw H=Q.length>1,Error(`ArgumentError: ${W}() takes ${R}${L} argument${H&&"s"||""} but received ${K.length}`);let j,V,T;for(let E=0;E<Q.length;E+=1){T=!1,j=Q[E].types,V=this.getTypeName(K[E]);let S;for(S=0;S<j.length;S+=1)if(V!==void 0&&this.typeMatches(V,j[S],K[E])){T=!0;break}if(!T&&V!==void 0){let d=j.map((p)=>{return this.TYPE_NAME_TABLE[p]}).join(" | ");throw Error(`TypeError: ${W}() expected argument ${E+1} to be type (${d}) but received type ${this.TYPE_NAME_TABLE[V]} instead.`)}}}typeMatches(W,K,Q){if(K===J.TYPE_ANY)return!0;if(K===J.TYPE_ARRAY_STRING||K===J.TYPE_ARRAY_NUMBER||K===J.TYPE_ARRAY){if(K===J.TYPE_ARRAY)return W===J.TYPE_ARRAY;if(W===J.TYPE_ARRAY){let G;if(K===J.TYPE_ARRAY_NUMBER)G=J.TYPE_NUMBER;else if(K===J.TYPE_ARRAY_STRING)G=J.TYPE_STRING;for(let q=0;q<Q.length;q+=1){let H=this.getTypeName(Q[q]);if(H!==void 0&&G!==void 0&&!this.typeMatches(H,G,Q[q]))return!1}return!0}}else return W===K;return!1}getTypeName(W){switch(Object.prototype.toString.call(W)){case"[object String]":return J.TYPE_STRING;case"[object Number]":return J.TYPE_NUMBER;case"[object Array]":return J.TYPE_ARRAY;case"[object Boolean]":return J.TYPE_BOOLEAN;case"[object Null]":return J.TYPE_NULL;case"[object Object]":if(W.jmespathType===z.TOK_EXPREF)return J.TYPE_EXPREF;return J.TYPE_OBJECT;default:return}}createKeyFunction(W,K){if(!this._interpreter)return;let Q=this._interpreter;return(q)=>{let H=Q.visit(W,q);if(!K.includes(this.getTypeName(H))){let L=`TypeError: expected one of (${K.map((F)=>this.TYPE_NAME_TABLE[F]).join(" | ")}), received ${this.TYPE_NAME_TABLE[this.getTypeName(H)]}`;throw Error(L)}return H}}}class V8{constructor(){this._rootValue=null,this.runtime=new M8(this)}search(W,K){return this._rootValue=K,this.visit(W,K)}visit(W,K){let Q,G,q,H,L,F,O,N,R,j,V;switch(W.type){case"Field":if(K===null)return null;if($(K)){if(F=K[W.name],F===void 0)return null;return F}return null;case"Subexpression":q=this.visit(W.children[0],K);for(j=1;j<W.children.length;j+=1)if(q=this.visit(W.children[1],q),q===null)return null;return q;case"IndexExpression":return O=this.visit(W.children[0],K),N=this.visit(W.children[1],O),N;case"Index":if(!Array.isArray(K))return null;let T=W.value;if(T<0)T=K.length+T;if(q=K[T],q===void 0)q=null;return q;case"Slice":if(!Array.isArray(K))return null;let E=[...W.children],S=this.computeSliceParams(K.length,E),[d,p,t]=S;if(q=[],t>0)for(j=d;j<p;j+=t)q.push(K[j]);else for(j=d;j>p;j+=t)q.push(K[j]);return q;case"Projection":if(V=this.visit(W.children[0],K),!Array.isArray(V))return null;R=[];for(j=0;j<V.length;j+=1)if(G=this.visit(W.children[1],V[j]),G!==null)R.push(G);return R;case"ValueProjection":if(V=this.visit(W.children[0],K),!$(V))return null;R=[];let g8=Object.values(V);for(j=0;j<g8.length;j+=1)if(G=this.visit(W.children[1],g8[j]),G!==null)R.push(G);return R;case"FilterProjection":if(V=this.visit(W.children[0],K),!Array.isArray(V))return null;let r=[],c8=[];for(j=0;j<V.length;j+=1)if(Q=this.visit(W.children[2],V[j]),!Y(Q))r.push(V[j]);for(let y=0;y<r.length;y+=1)if(G=this.visit(W.children[1],r[y]),G!==null)c8.push(G);return c8;case"Comparator":switch(H=this.visit(W.children[0],K),L=this.visit(W.children[1],K),W.name){case z.TOK_EQ:q=X(H,L);break;case z.TOK_NE:q=!X(H,L);break;case z.TOK_GT:q=H>L;break;case z.TOK_GTE:q=H>=L;break;case z.TOK_LT:q=H<L;break;case z.TOK_LTE:q=H<=L;break;default:throw Error(`Unknown comparator: ${W.name}`)}return q;case z.TOK_FLATTEN:let e=this.visit(W.children[0],K);if(!Array.isArray(e))return null;let u=[];for(j=0;j<e.length;j+=1)if(G=e[j],Array.isArray(G))u=[...u,...G];else u.push(G);return u;case"Identity":return K;case"MultiSelectList":if(K===null)return null;R=[];for(j=0;j<W.children.length;j+=1)R.push(this.visit(W.children[j],K));return R;case"MultiSelectHash":if(K===null)return null;R={};let Z8;for(j=0;j<W.children.length;j+=1)Z8=W.children[j],R[Z8.name]=this.visit(Z8.value,K);return R;case"OrExpression":if(Q=this.visit(W.children[0],K),Y(Q))Q=this.visit(W.children[1],K);return Q;case"AndExpression":if(H=this.visit(W.children[0],K),Y(H))return H;return this.visit(W.children[1],K);case"NotExpression":return H=this.visit(W.children[0],K),Y(H);case"Literal":return W.value;case z.TOK_PIPE:return O=this.visit(W.children[0],K),this.visit(W.children[1],O);case z.TOK_CURRENT:return K;case z.TOK_ROOT:return this._rootValue;case"Function":let m8=[];for(let y=0;y<W.children.length;y+=1)m8.push(this.visit(W.children[y],K));return this.runtime.callFunction(W.name,m8);case"ExpressionReference":let d8=W.children[0];return d8.jmespathType=z.TOK_EXPREF,d8;default:throw Error(`Unknown node type: ${W.type}`)}}computeSliceParams(W,K){let[Q,G,q]=K;if(q===null)q=1;else if(q===0){let L=Error("Invalid slice, step cannot be 0");throw L.name="RuntimeError",L}let H=q<0?!0:!1;return Q=Q===null?H?W-1:0:this.capSliceRange(W,Q,q),G=G===null?H?-1:W:this.capSliceRange(W,G,q),[Q,G,q]}capSliceRange(W,K,Q){let G=K;if(G<0){if(G+=W,G<0)G=Q<0?-1:0}else if(G>=W)G=Q<0?W-1:W;return G}}let s=new V8,_8=J.TYPE_ANY,w8=J.TYPE_ARRAY,P8=J.TYPE_ARRAY_NUMBER,N8=J.TYPE_ARRAY_STRING,E8=J.TYPE_BOOLEAN,S8=J.TYPE_EXPREF,I8=J.TYPE_NULL,x8=J.TYPE_NUMBER,A8=J.TYPE_OBJECT,b8=J.TYPE_STRING;function T8(W){return R8.parse(W)}function f8(W){return b.tokenize(W)}let y8=(W,K,Q)=>{s.runtime.registerFunction(W,K,Q)};function k8(W,K){let Q=R8.parse(K);return s.search(Q,W)}let h8=s,v8={compile:T8,registerFunction:y8,search:k8,tokenize:f8,TreeInterpreter:h8,TYPE_ANY:_8,TYPE_ARRAY_NUMBER:P8,TYPE_ARRAY_STRING:N8,TYPE_ARRAY:w8,TYPE_BOOLEAN:E8,TYPE_EXPREF:S8,TYPE_NULL:I8,TYPE_NUMBER:x8,TYPE_OBJECT:A8,TYPE_STRING:b8};Z.TYPE_ANY=_8,Z.TYPE_ARRAY=w8,Z.TYPE_ARRAY_NUMBER=P8,Z.TYPE_ARRAY_STRING=N8,Z.TYPE_BOOLEAN=E8,Z.TYPE_EXPREF=S8,Z.TYPE_NULL=I8,Z.TYPE_NUMBER=x8,Z.TYPE_OBJECT=A8,Z.TYPE_STRING=b8,Z.TreeInterpreter=h8,Z.compile=T8,Z.default=v8,Z.jmespath=v8,Z.registerFunction=y8,Z.search=k8,Z.tokenize=f8,Object.defineProperty(Z,"__esModule",{value:!0})})});import{mkdirSync as RZ,mkdtempSync as MZ,writeFileSync as VZ}from"node:fs";import{tmpdir as _Z}from"node:os";import{dirname as wZ,join as L8}from"node:path";import{pathToFileURL as PZ}from"node:url";import{timingSafeEqual as UZ}from"node:crypto";import{createServer as HZ}from"node:http";import{Readable as jZ}from"node:stream";function y9(){return typeof process>"u"?{}:process.env}function p8(Z=y9()){return Z.MCP_BEARER_TOKEN?.trim()||null}import{existsSync as qZ}from"node:fs";i();async function J9(Z){let $=D8(await Z),[X,Y,{QuickJSWASMModule:B}]=await Promise.all([$.importModuleLoader().then(D8),$.importFFI(),Promise.resolve().then(() => (B9(),G9)).then(D8)]),C=await X();C.type="sync";let U=new Y(C);return new B(C,U)}function D8(Z){return Z&&"default"in Z&&Z.default?Z.default&&"default"in Z.default&&Z.default.default?Z.default.default:Z.default:Z}var C9="engine";function WZ(Z){let $=(X)=>new URL(X,Z).href;return{type:"sync",importFFI:()=>import($("ffi.mjs")).then((X)=>X.QuickJSFFI),importModuleLoader:()=>import($("emscripten-module.mjs")).then((X)=>X.default)}}var q9=null;function U9(Z){return()=>{return q9??=J9(WZ(Z)),q9}}var KZ=x9(j9(),1);var YZ="__mcpcloud_call_tool",_1=`globalThis.tool = (name, args) =>
|
|
8
|
+
globalThis.${YZ}(String(name), JSON.stringify(args ?? {}))
|
|
9
|
+
.then((json) => JSON.parse(json));`;var QZ=6,GZ=["log","warn","error","info","debug"],BZ="__mcpcloud_console",N1=`globalThis.console = {
|
|
10
|
+
${GZ.map((Z)=>` ${Z}: (...args) => globalThis.${BZ}(${JSON.stringify(Z)}, JSON.stringify(args.slice(0, ${QZ}).map((value) => (value instanceof Error ? { __mcpcloudError: value.name + ': ' + value.message } : value)))),`).join(`
|
|
11
|
+
`)}
|
|
12
|
+
};`;var JZ=null;function D9(Z){JZ=Z}var L9=[`./${C9}/`,"../engine/vendor/","../../engine/vendor/"];function CZ(Z=new URL(import.meta.url)){for(let $ of L9){let X=new URL($,Z);if(qZ(new URL("emscripten-module.wasm",X)))return X}throw Error(`Code Mode engine not found. Looked for emscripten-module.wasm in: ${L9.join(", ")} (relative to ${Z.href}).`)}function F9(){D9(()=>U9(CZ())())}function DZ(Z,$){let X=Buffer.from(Z),Y=Buffer.from($);return X.length===Y.length&&UZ(X,Y)}function LZ(Z,$){let X=p8($);if(!X)return null;if(new URL(Z.url).pathname==="/health")return null;let Y=Z.headers.get("authorization")??"",B=/^Bearer\s+(.+)$/i.exec(Y.trim());if(B&&DZ(B[1].trim(),X))return null;return Response.json({error:"unauthorized",message:"This MCP endpoint requires a bearer token (set in Authorization: Bearer <token>)."},{status:401,headers:{"www-authenticate":"Bearer"}})}function FZ(Z,$){let X=new URL(Z.url??"/",$),Y=new Headers;for(let[U,z]of Object.entries(Z.headers))if(Array.isArray(z))for(let D of z)Y.append(U,D);else if(typeof z==="string")Y.set(U,z);let B=Z.method??"GET",C=B==="GET"||B==="HEAD"?void 0:jZ.toWeb(Z);return new Request(X,{method:B,headers:Y,body:C,...C?{duplex:"half"}:{}})}async function OZ(Z,$){if($.statusCode=Z.status,Z.headers.forEach((Y,B)=>{$.setHeader(B,Y)}),!Z.body){$.end();return}let X=Z.body.getReader();for(;;){let{done:Y,value:B}=await X.read();if(Y)break;$.write(B)}$.end()}function O9(Z,$={}){F9();let X=$.port??Number(process.env.PORT??8080),Y=$.hostname??"0.0.0.0",B=HZ((C,U)=>{let z=`http://${C.headers.host??`${Y}:${X}`}`,D=FZ(C,z),P=LZ(D,$.env);(P?Promise.resolve(P):Z.handleRequest(D,$.env)).then((M)=>OZ(M,U)).catch(()=>{U.statusCode=500,U.end(JSON.stringify({error:"internal_error"}))})});return B.listen(X,Y),B}var F8=1;function R9(Z=process.env){let $=Z.BUNDLE_URL?.trim(),X=Z.BUNDLE_SHA256?.trim();if(!$)throw Error("BUNDLE_URL is not set; the runtime host has no code to run.");if(!X)throw Error("BUNDLE_SHA256 is not set; refusing to boot unverified code.");let Y=Number(Z.PORT??8080);if(!Number.isInteger(Y)||Y<=0)throw Error(`Invalid PORT: ${String(Z.PORT)}`);return{bundleUrl:$,bundleSha256:X,port:Y}}async function NZ(Z){let $=Z.buffer.slice(Z.byteOffset,Z.byteOffset+Z.byteLength),X=await crypto.subtle.digest("SHA-256",$);return Array.from(new Uint8Array(X)).map((Y)=>Y.toString(16).padStart(2,"0")).join("")}function EZ(Z){let $=JSON.parse(new TextDecoder().decode(Z));if(!$||typeof $!=="object")throw Error("Boot artifact must be a JSON object.");let X=$;if(X.schemaVersion!==F8)throw Error(`Unsupported boot artifact schemaVersion: ${String(X.schemaVersion)}.`);if(typeof X.runtimeVersion!=="string"||typeof X.mainEntry!=="string"||!Array.isArray(X.files))throw Error("Boot artifact is malformed.");let Y=X.files.map((B)=>{if(!B||typeof B!=="object"||typeof B.path!=="string"||typeof B.content!=="string")throw Error("Boot artifact files must be { path, content }.");let C=B;return{path:C.path,content:C.content}});return{schemaVersion:F8,runtimeVersion:X.runtimeVersion,mainEntry:X.mainEntry,files:Y}}async function M9(Z,$=fetch){let X=await $(Z.bundleUrl);if(!X.ok)throw Error(`Bundle fetch failed (HTTP ${X.status}).`);let Y=new Uint8Array(await X.arrayBuffer()),B=await NZ(Y);if(B!==Z.bundleSha256.toLowerCase())throw Error(`Bundle sha256 mismatch (expected ${Z.bundleSha256}, got ${B}).`);return EZ(Y)}function V9(Z,$){for(let X of Z.files){let Y=L8($,X.path);RZ(wZ(Y),{recursive:!0}),VZ(Y,X.content)}return{entryPath:L8($,Z.mainEntry)}}async function SZ(Z={}){let $=Z.bootConfig??R9(),X=await M9($,Z.fetchImpl),Y=Z.workDir??MZ(L8(_Z(),"mcpcloud-server-")),{entryPath:B}=V9(X,Y),C=await import(PZ(B).href),U=C.server??C.default;if(!U)throw Error(`Boot module ${X.mainEntry} does not export a \`server\`.`);let z={port:$.port,...Z.hostname?{hostname:Z.hostname}:{},...Z.env?{env:Z.env}:{}};return O9(U,z)}export{SZ as serveFromBundle,R9 as resolveBootConfig,V9 as materializeBundle,M9 as fetchAndVerifyBundle,F8 as BOOT_ARTIFACT_SCHEMA_VERSION};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var QuickJSRaw=(()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var c=moduleArg;function n(a){a={log:a||function(){}};for(const d of n.Qa)d(a);return c.quickJSEmscriptenExtensions=a}n.Qa=[];c.quickjsEmscriptenInit=n;n.Qa.push(a=>{a.getWasmMemory=function(){return q}});var r="./this.program",t="",u;try{t=(new URL(".",_scriptName)).href}catch{}u=async a=>{a=await fetch(a,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+" : "+a.url);};var v=console.log.bind(console),w=console.error.bind(console),y,z=!1,A,B,C,D,E,F,G,H,I=!1;
|
|
2
|
+
function J(){var a=q.buffer;c.HEAP8=D=new Int8Array(a);new Int16Array(a);c.HEAPU8=E=new Uint8Array(a);new Uint16Array(a);F=new Int32Array(a);G=new Uint32Array(a);new Float32Array(a);new Float64Array(a);H=new BigInt64Array(a);new BigUint64Array(a)}function K(a){c.onAbort?.(a);a="Aborted("+a+")";w(a);z=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");C?.(a);throw a;}var L;
|
|
3
|
+
async function aa(a){if(!y)try{var d=await u(a);return new Uint8Array(d)}catch{}if(a==L&&y)a=new Uint8Array(y);else throw"both async and sync fetching of the wasm failed";return a}async function ba(a,d){try{var b=await aa(a);return await WebAssembly.instantiate(b,d)}catch(e){w(`failed to asynchronously prepare wasm: ${e}`),K(e)}}
|
|
4
|
+
async function ca(a){var d=L;if(!y)try{var b=fetch(d,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(b,a)}catch(e){w(`wasm streaming compile failed: ${e}`),w("falling back to ArrayBuffer instantiation")}return ba(d,a)}class M{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
|
|
5
|
+
var N=a=>{for(;0<a.length;)a.shift()(c)},O=[],P=[],da=()=>{var a=c.preRun.shift();P.push(a)},Q=!0,q,ea=new TextDecoder,fa=(a,d,b,e)=>{b=d+b;if(e)return b;for(;a[d]&&!(d>=b);)++d;return d},R=(a,d,b)=>a?ea.decode(E.subarray(a,fa(E,a,d,b))):"",S=0,ha=[0,31,60,91,121,152,182,213,244,274,305,335],ia=[0,31,59,90,120,151,181,212,243,273,304,334],T={},ja=a=>{if(!(a instanceof M||"unwind"==a))throw a;},ka=a=>{A=a;Q||0<S||(c.onExit?.(a),z=!0);throw new M(a);},la=a=>{if(!z)try{a()}catch(d){ja(d)}finally{if(!(Q||
|
|
6
|
+
0<S))try{A=a=A,ka(a)}catch(d){ja(d)}}},U=(a,d,b)=>{var e=E;if(!(0<b))return 0;var f=d;b=d+b-1;for(var g=0;g<a.length;++g){var h=a.codePointAt(g);if(127>=h){if(d>=b)break;e[d++]=h}else if(2047>=h){if(d+1>=b)break;e[d++]=192|h>>6;e[d++]=128|h&63}else if(65535>=h){if(d+2>=b)break;e[d++]=224|h>>12;e[d++]=128|h>>6&63;e[d++]=128|h&63}else{if(d+3>=b)break;e[d++]=240|h>>18;e[d++]=128|h>>12&63;e[d++]=128|h>>6&63;e[d++]=128|h&63;g++}}e[d]=0;return d-f},V={},ma=()=>{if(!W){var a={USER:"web_user",LOGNAME:"web_user",
|
|
7
|
+
PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:r||"./this.program"},d;for(d in V)void 0===V[d]?delete a[d]:a[d]=V[d];var b=[];for(d in a)b.push(`${d}=${a[d]}`);W=b}return W},W,X=a=>{for(var d=0,b=0;b<a.length;++b){var e=a.charCodeAt(b);127>=e?d++:2047>=e?d+=2:55296<=e&&57343>=e?(d+=4,++b):d+=3}return d},na=[null,[],[]],qa=(a,d,b,e)=>{var f={string:k=>{var l=0;if(null!==k&&void 0!==k&&0!==k){l=X(k)+1;var p=Y(l);U(k,p,l);l=p}return l},array:k=>
|
|
8
|
+
{var l=Y(k.length);D.set(k,l);return l}};a=c["_"+a];var g=[],h=0;if(e)for(var m=0;m<e.length;m++){var x=f[b[m]];x?(0===h&&(h=oa()),g[m]=x(e[m])):g[m]=e[m]}b=a(...g);return b=function(k){0!==h&&pa(h);return"string"===d?R(k):"boolean"===d?!!k:k}(b)};c.wasmMemory?q=c.wasmMemory:q=new WebAssembly.Memory({initial:(c.INITIAL_MEMORY||16777216)/65536,maximum:32768});J();c.noExitRuntime&&(Q=c.noExitRuntime);c.print&&(v=c.print);c.printErr&&(w=c.printErr);c.wasmBinary&&(y=c.wasmBinary);c.thisProgram&&(r=c.thisProgram);
|
|
9
|
+
if(c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.shift()();c.cwrap=(a,d,b,e)=>{var f=!b||b.every(g=>"number"===g||"boolean"===g);return"string"!==d&&f&&!e?c["_"+a]:(...g)=>qa(a,d,b,g)};c.UTF8ToString=R;c.stringToUTF8=(a,d,b)=>U(a,d,b);c.lengthBytesUTF8=X;
|
|
10
|
+
var ra,pa,Y,oa,sa={b:(a,d,b,e)=>K(`Assertion failed: ${R(a)}, at: `+[d?R(d):"unknown filename",b,e?R(e):"unknown function"]),r:()=>K(""),l:()=>{Q=!1;S=0},m:function(a,d){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);a=new Date(1E3*a);F[d>>2]=a.getSeconds();F[d+4>>2]=a.getMinutes();F[d+8>>2]=a.getHours();F[d+12>>2]=a.getDate();F[d+16>>2]=a.getMonth();F[d+20>>2]=a.getFullYear()-1900;F[d+24>>2]=a.getDay();var b=a.getFullYear();F[d+28>>2]=(0!==b%4||0===b%100&&0!==b%400?ia:ha)[a.getMonth()]+
|
|
11
|
+
a.getDate()-1|0;F[d+36>>2]=-(60*a.getTimezoneOffset());b=(new Date(a.getFullYear(),6,1)).getTimezoneOffset();var e=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();F[d+32>>2]=(b!=e&&a.getTimezoneOffset()==Math.min(e,b))|0},j:(a,d)=>{T[a]&&(clearTimeout(T[a].id),delete T[a]);if(!d)return 0;var b=setTimeout(()=>{delete T[a];la(()=>ra(a,performance.now()))},d);T[a]={id:b,Ra:d};return 0},n:(a,d,b,e)=>{var f=(new Date).getFullYear(),g=(new Date(f,0,1)).getTimezoneOffset();f=(new Date(f,6,1)).getTimezoneOffset();
|
|
12
|
+
G[a>>2]=60*Math.max(g,f);F[d>>2]=Number(g!=f);d=h=>{var m=Math.abs(h);return`UTC${0<=h?"-":"+"}${String(Math.floor(m/60)).padStart(2,"0")}${String(m%60).padStart(2,"0")}`};a=d(g);d=d(f);f<g?(U(a,b,17),U(d,e,17)):(U(a,e,17),U(d,b,17))},q:function(a,d,b){if(!(0<=a&&3>=a))return 28;H[b>>3]=BigInt(Math.round(1E6*(0===a?Date.now():performance.now())));return 0},p:()=>Date.now(),k:a=>{var d=E.length;a>>>=0;if(2147483648<a)return!1;for(var b=1;4>=b;b*=2){var e=d*(1+.2/b);e=Math.min(e,a+100663296);a:{e=(Math.min(2147483648,
|
|
13
|
+
65536*Math.ceil(Math.max(a,e)/65536))-q.buffer.byteLength+65535)/65536|0;try{q.grow(e);J();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},e:(a,d)=>{var b=0,e=0,f;for(f of ma()){var g=d+b;G[a+e>>2]=g;b+=U(f,g,Infinity)+1;e+=4}return 0},f:(a,d)=>{var b=ma();G[a>>2]=b.length;a=0;for(var e of b)a+=X(e)+1;G[d>>2]=a;return 0},d:()=>52,o:function(){return 70},c:(a,d,b,e)=>{for(var f=0,g=0;g<b;g++){var h=G[d>>2],m=G[d+4>>2];d+=8;for(var x=0;x<m;x++){var k=a,l=E[h+x],p=na[k];0===l||10===l?(k=1===
|
|
14
|
+
k?v:w,l=fa(p,0),l=ea.decode(p.buffer?p.subarray(0,l):new Uint8Array(p.slice(0,l))),k(l),p.length=0):p.push(l)}f+=m}G[e>>2]=f;return 0},a:q,s:ka,t:function(a,d,b,e,f){return c.callbacks.callFunction(void 0,a,d,b,e,f)},i:function(a){return c.callbacks.shouldInterrupt(void 0,a)},h:function(a,d,b){b=R(b);return c.callbacks.loadModuleSource(void 0,a,d,b)},g:function(a,d,b,e){b=R(b);e=R(e);return c.callbacks.normalizeModule(void 0,a,d,b,e)},u:function(a,d){c.callbacks.freeHostRef(void 0,a,d)}},Z;
|
|
15
|
+
Z=await (async function(){function a(b){b=Z=b.exports;c._malloc=b.w;c._QTS_Throw=b.x;c._QTS_NewError=b.y;c._QTS_RuntimeSetMemoryLimit=b.z;c._QTS_RuntimeComputeMemoryUsage=b.A;c._QTS_RuntimeDumpMemoryUsage=b.B;c._QTS_RecoverableLeakCheck=b.C;c._QTS_BuildIsSanitizeLeak=b.D;c._QTS_RuntimeSetMaxStackSize=b.E;c._QTS_GetUndefined=b.F;c._QTS_GetNull=b.G;c._QTS_GetFalse=b.H;c._QTS_GetTrue=b.I;c._QTS_NewHostRef=b.J;c._QTS_GetHostRefId=b.K;c._QTS_NewRuntime=b.L;c._QTS_FreeRuntime=b.M;c._free=b.N;
|
|
16
|
+
c._QTS_NewContext=b.O;c._QTS_FreeContext=b.P;c._QTS_FreeValuePointer=b.Q;c._QTS_FreeValuePointerRuntime=b.R;c._QTS_FreeVoidPointer=b.S;c._QTS_FreeCString=b.T;c._QTS_DupValuePointer=b.U;c._QTS_NewObject=b.V;c._QTS_NewObjectProto=b.W;c._QTS_NewArray=b.X;c._QTS_NewArrayBuffer=b.Y;c._QTS_NewFloat64=b.Z;c._QTS_GetFloat64=b._;c._QTS_NewString=b.$;c._QTS_GetString=b.aa;c._QTS_GetArrayBuffer=b.ba;c._QTS_GetArrayBufferLength=b.ca;c._QTS_NewSymbol=b.da;c._QTS_GetSymbolDescriptionOrKey=b.ea;c._QTS_IsGlobalSymbol=
|
|
17
|
+
b.fa;c._QTS_IsJobPending=b.ga;c._QTS_ExecutePendingJob=b.ha;c._QTS_GetProp=b.ia;c._QTS_GetPropNumber=b.ja;c._QTS_SetProp=b.ka;c._QTS_DefineProp=b.la;c._QTS_GetOwnPropertyNames=b.ma;c._QTS_Call=b.na;c._QTS_ResolveException=b.oa;c._QTS_Dump=b.pa;c._QTS_Eval=b.qa;c._QTS_GetModuleNamespace=b.ra;c._QTS_Typeof=b.sa;c._QTS_GetLength=b.ta;c._QTS_IsEqual=b.ua;c._QTS_GetGlobalObject=b.va;c._QTS_NewPromiseCapability=b.wa;c._QTS_PromiseState=b.xa;c._QTS_PromiseResult=b.ya;c._QTS_TestStringArg=b.za;c._QTS_GetDebugLogEnabled=
|
|
18
|
+
b.Aa;c._QTS_SetDebugLogEnabled=b.Ba;c._QTS_BuildIsDebug=b.Ca;c._QTS_BuildIsAsyncify=b.Da;c._QTS_NewFunction=b.Ea;c._QTS_ArgvGetJSValueConstPointer=b.Fa;c._QTS_RuntimeEnableInterruptHandler=b.Ga;c._QTS_RuntimeDisableInterruptHandler=b.Ha;c._QTS_RuntimeEnableModuleLoader=b.Ia;c._QTS_RuntimeDisableModuleLoader=b.Ja;c._QTS_bjson_encode=b.Ka;c._QTS_bjson_decode=b.La;ra=b.Ma;pa=b.Na;Y=b.Oa;oa=b.Pa;return Z}var d={a:sa};if(c.instantiateWasm)return new Promise(b=>{c.instantiateWasm(d,(e,f)=>{b(a(e,f))})});
|
|
19
|
+
L??=c.locateFile?c.locateFile("emscripten-module.wasm",t):t+"emscripten-module.wasm";return a((await ca(d)).instance)}());
|
|
20
|
+
(function(){function a(){c.calledRun=!0;if(!z){I=!0;Z.v();B?.(c);c.onRuntimeInitialized?.();if(c.postRun)for("function"==typeof c.postRun&&(c.postRun=[c.postRun]);c.postRun.length;){var d=c.postRun.shift();O.push(d)}N(O)}}if(c.preRun)for("function"==typeof c.preRun&&(c.preRun=[c.preRun]);c.preRun.length;)da();N(P);c.setStatus?(c.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>c.setStatus(""),1);a()},1)):a()})();I?moduleRtn=c:moduleRtn=new Promise((a,d)=>{B=a;C=d});
|
|
21
|
+
;return moduleRtn}})();if(typeof exports==="object"&&typeof module==="object"){module.exports=QuickJSRaw;module.exports.default=QuickJSRaw}else if(typeof define==="function"&&define["amd"])define([],()=>QuickJSRaw);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Generated from upstream/templates/emscripten-module.SYNC.d.ts
|
|
2
|
+
import type { EmscriptenModuleLoader, QuickJSEmscriptenModule } from "@jitl/quickjs-ffi-types"
|
|
3
|
+
/**
|
|
4
|
+
* Emscripten module built from the unmodified [`quickjs/quickjs.h`](../quickjs/quickjs.h)
|
|
5
|
+
* and our FFI support functions [c/interface.c](../c/interface.c).
|
|
6
|
+
*
|
|
7
|
+
* Note that emscripten modules returned by a `MODULARIZE=1` emscripten build
|
|
8
|
+
* (like this one) load asynchronously.
|
|
9
|
+
*/
|
|
10
|
+
declare const ModuleLoader: EmscriptenModuleLoader<QuickJSEmscriptenModule>
|
|
11
|
+
export default ModuleLoader
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
async function QuickJSRaw(moduleArg={}){var moduleRtn;var d=moduleArg,aa=!!globalThis.window,n=!!globalThis.WorkerGlobalScope,q=globalThis.process?.versions?.node&&"renderer"!=globalThis.process?.type;if(q){const {createRequire:a}=await import("node:module");var require=a(import.meta.url)}function r(a){a={log:a||function(){}};for(const c of r.Qa)c(a);return d.quickJSEmscriptenExtensions=a}r.Qa=[];d.quickjsEmscriptenInit=r;r.Qa.push(a=>{a.getWasmMemory=function(){return t}});
|
|
2
|
+
var u="./this.program",v=(a,c)=>{throw c;},w=import.meta.url,y="",z,A;
|
|
3
|
+
if(q){var fs=require("node:fs");w.startsWith("file:")&&(y=require("node:path").dirname(require("node:url").fileURLToPath(w))+"/");A=a=>{a=B(a)?new URL(a):a;return fs.readFileSync(a)};z=async a=>{a=B(a)?new URL(a):a;return fs.readFileSync(a,void 0)};1<process.argv.length&&(u=process.argv[1].replace(/\\/g,"/"));process.argv.slice(2);v=(a,c)=>{process.exitCode=a;throw c;}}else if(aa||n){try{y=(new URL(".",w)).href}catch{}n&&(A=a=>{var c=new XMLHttpRequest;c.open("GET",a,!1);c.responseType="arraybuffer";
|
|
4
|
+
c.send(null);return new Uint8Array(c.response)});z=async a=>{if(B(a))return new Promise((b,e)=>{var f=new XMLHttpRequest;f.open("GET",a,!0);f.responseType="arraybuffer";f.onload=()=>{200==f.status||0==f.status&&f.response?b(f.response):e(f.status)};f.onerror=e;f.send(null)});var c=await fetch(a,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw Error(c.status+" : "+c.url);}}
|
|
5
|
+
var C=console.log.bind(console),D=console.error.bind(console),E,F=!1,G,B=a=>a.startsWith("file://"),H,I,J,K,L,M,ba,ca=!1;function da(){var a=t.buffer;d.HEAP8=J=new Int8Array(a);new Int16Array(a);d.HEAPU8=K=new Uint8Array(a);new Uint16Array(a);L=new Int32Array(a);M=new Uint32Array(a);new Float32Array(a);new Float64Array(a);ba=new BigInt64Array(a);new BigUint64Array(a)}
|
|
6
|
+
function N(a){d.onAbort?.(a);a="Aborted("+a+")";D(a);F=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");I?.(a);throw a;}var O;async function ea(a){if(!E)try{var c=await z(a);return new Uint8Array(c)}catch{}if(a==O&&E)a=new Uint8Array(E);else if(A)a=A(a);else throw"both async and sync fetching of the wasm failed";return a}
|
|
7
|
+
async function fa(a,c){try{var b=await ea(a);return await WebAssembly.instantiate(b,c)}catch(e){D(`failed to asynchronously prepare wasm: ${e}`),N(e)}}async function ha(a){var c=O;if(!E&&!B(c)&&!q)try{var b=fetch(c,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(b,a)}catch(e){D(`wasm streaming compile failed: ${e}`),D("falling back to ArrayBuffer instantiation")}return fa(c,a)}
|
|
8
|
+
class P{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
|
|
9
|
+
var ia=a=>{for(;0<a.length;)a.shift()(d)},ja=[],ka=[],la=()=>{var a=d.preRun.shift();ka.push(a)},Q=!0,t,ma=new TextDecoder,na=(a,c,b,e)=>{b=c+b;if(e)return b;for(;a[c]&&!(c>=b);)++c;return c},R=(a,c,b)=>a?ma.decode(K.subarray(a,na(K,a,c,b))):"",S=0,oa=[0,31,60,91,121,152,182,213,244,274,305,335],pa=[0,31,59,90,120,151,181,212,243,273,304,334],T={},qa=a=>{G=a;Q||0<S||(d.onExit?.(a),F=!0);v(a,new P(a))},ra=a=>{if(!F)try{a()}catch(c){c instanceof P||"unwind"==c||v(1,c)}finally{if(!(Q||0<S))try{G=a=G,
|
|
10
|
+
qa(a)}catch(c){c instanceof P||"unwind"==c||v(1,c)}}},U=(a,c,b)=>{var e=K;if(!(0<b))return 0;var f=c;b=c+b-1;for(var g=0;g<a.length;++g){var h=a.codePointAt(g);if(127>=h){if(c>=b)break;e[c++]=h}else if(2047>=h){if(c+1>=b)break;e[c++]=192|h>>6;e[c++]=128|h&63}else if(65535>=h){if(c+2>=b)break;e[c++]=224|h>>12;e[c++]=128|h>>6&63;e[c++]=128|h&63}else{if(c+3>=b)break;e[c++]=240|h>>18;e[c++]=128|h>>12&63;e[c++]=128|h>>6&63;e[c++]=128|h&63;g++}}e[c]=0;return c-f},V={},sa=()=>{if(!W){var a={USER:"web_user",
|
|
11
|
+
LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:u||"./this.program"},c;for(c in V)void 0===V[c]?delete a[c]:a[c]=V[c];var b=[];for(c in a)b.push(`${c}=${a[c]}`);W=b}return W},W,X=a=>{for(var c=0,b=0;b<a.length;++b){var e=a.charCodeAt(b);127>=e?c++:2047>=e?c+=2:55296<=e&&57343>=e?(c+=4,++b):c+=3}return c},ta=[null,[],[]],wa=(a,c,b,e)=>{var f={string:k=>{var l=0;if(null!==k&&void 0!==k&&0!==k){l=X(k)+1;var p=Y(l);U(k,p,
|
|
12
|
+
l);l=p}return l},array:k=>{var l=Y(k.length);J.set(k,l);return l}};a=d["_"+a];var g=[],h=0;if(e)for(var m=0;m<e.length;m++){var x=f[b[m]];x?(0===h&&(h=ua()),g[m]=x(e[m])):g[m]=e[m]}b=a(...g);return b=function(k){0!==h&&va(h);return"string"===c?R(k):"boolean"===c?!!k:k}(b)};d.wasmMemory?t=d.wasmMemory:t=new WebAssembly.Memory({initial:(d.INITIAL_MEMORY||16777216)/65536,maximum:32768});da();d.noExitRuntime&&(Q=d.noExitRuntime);d.print&&(C=d.print);d.printErr&&(D=d.printErr);d.wasmBinary&&(E=d.wasmBinary);
|
|
13
|
+
d.thisProgram&&(u=d.thisProgram);if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.shift()();d.cwrap=(a,c,b,e)=>{var f=!b||b.every(g=>"number"===g||"boolean"===g);return"string"!==c&&f&&!e?d["_"+a]:(...g)=>wa(a,c,b,g)};d.UTF8ToString=R;d.stringToUTF8=(a,c,b)=>U(a,c,b);d.lengthBytesUTF8=X;
|
|
14
|
+
var xa,va,Y,ua,ya={b:(a,c,b,e)=>N(`Assertion failed: ${R(a)}, at: `+[c?R(c):"unknown filename",b,e?R(e):"unknown function"]),r:()=>N(""),l:()=>{Q=!1;S=0},m:function(a,c){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);a=new Date(1E3*a);L[c>>2]=a.getSeconds();L[c+4>>2]=a.getMinutes();L[c+8>>2]=a.getHours();L[c+12>>2]=a.getDate();L[c+16>>2]=a.getMonth();L[c+20>>2]=a.getFullYear()-1900;L[c+24>>2]=a.getDay();var b=a.getFullYear();L[c+28>>2]=(0!==b%4||0===b%100&&0!==b%400?pa:oa)[a.getMonth()]+
|
|
15
|
+
a.getDate()-1|0;L[c+36>>2]=-(60*a.getTimezoneOffset());b=(new Date(a.getFullYear(),6,1)).getTimezoneOffset();var e=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();L[c+32>>2]=(b!=e&&a.getTimezoneOffset()==Math.min(e,b))|0},j:(a,c)=>{T[a]&&(clearTimeout(T[a].id),delete T[a]);if(!c)return 0;var b=setTimeout(()=>{delete T[a];ra(()=>xa(a,performance.now()))},c);T[a]={id:b,Ra:c};return 0},n:(a,c,b,e)=>{var f=(new Date).getFullYear(),g=(new Date(f,0,1)).getTimezoneOffset();f=(new Date(f,6,1)).getTimezoneOffset();
|
|
16
|
+
M[a>>2]=60*Math.max(g,f);L[c>>2]=Number(g!=f);c=h=>{var m=Math.abs(h);return`UTC${0<=h?"-":"+"}${String(Math.floor(m/60)).padStart(2,"0")}${String(m%60).padStart(2,"0")}`};a=c(g);c=c(f);f<g?(U(a,b,17),U(c,e,17)):(U(a,e,17),U(c,b,17))},q:function(a,c,b){if(!(0<=a&&3>=a))return 28;ba[b>>3]=BigInt(Math.round(1E6*(0===a?Date.now():performance.now())));return 0},p:()=>Date.now(),k:a=>{var c=K.length;a>>>=0;if(2147483648<a)return!1;for(var b=1;4>=b;b*=2){var e=c*(1+.2/b);e=Math.min(e,a+100663296);a:{e=
|
|
17
|
+
(Math.min(2147483648,65536*Math.ceil(Math.max(a,e)/65536))-t.buffer.byteLength+65535)/65536|0;try{t.grow(e);da();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},e:(a,c)=>{var b=0,e=0,f;for(f of sa()){var g=c+b;M[a+e>>2]=g;b+=U(f,g,Infinity)+1;e+=4}return 0},f:(a,c)=>{var b=sa();M[a>>2]=b.length;a=0;for(var e of b)a+=X(e)+1;M[c>>2]=a;return 0},d:()=>52,o:function(){return 70},c:(a,c,b,e)=>{for(var f=0,g=0;g<b;g++){var h=M[c>>2],m=M[c+4>>2];c+=8;for(var x=0;x<m;x++){var k=a,l=K[h+x],p=ta[k];
|
|
18
|
+
0===l||10===l?(k=1===k?C:D,l=na(p,0),l=ma.decode(p.buffer?p.subarray(0,l):new Uint8Array(p.slice(0,l))),k(l),p.length=0):p.push(l)}f+=m}M[e>>2]=f;return 0},a:t,s:qa,t:function(a,c,b,e,f){return d.callbacks.callFunction(void 0,a,c,b,e,f)},i:function(a){return d.callbacks.shouldInterrupt(void 0,a)},h:function(a,c,b){b=R(b);return d.callbacks.loadModuleSource(void 0,a,c,b)},g:function(a,c,b,e){b=R(b);e=R(e);return d.callbacks.normalizeModule(void 0,a,c,b,e)},u:function(a,c){d.callbacks.freeHostRef(void 0,
|
|
19
|
+
a,c)}},Z;
|
|
20
|
+
Z=await (async function(){function a(b){b=Z=b.exports;d._malloc=b.w;d._QTS_Throw=b.x;d._QTS_NewError=b.y;d._QTS_RuntimeSetMemoryLimit=b.z;d._QTS_RuntimeComputeMemoryUsage=b.A;d._QTS_RuntimeDumpMemoryUsage=b.B;d._QTS_RecoverableLeakCheck=b.C;d._QTS_BuildIsSanitizeLeak=b.D;d._QTS_RuntimeSetMaxStackSize=b.E;d._QTS_GetUndefined=b.F;d._QTS_GetNull=b.G;d._QTS_GetFalse=b.H;d._QTS_GetTrue=b.I;d._QTS_NewHostRef=b.J;d._QTS_GetHostRefId=b.K;d._QTS_NewRuntime=b.L;d._QTS_FreeRuntime=b.M;d._free=b.N;
|
|
21
|
+
d._QTS_NewContext=b.O;d._QTS_FreeContext=b.P;d._QTS_FreeValuePointer=b.Q;d._QTS_FreeValuePointerRuntime=b.R;d._QTS_FreeVoidPointer=b.S;d._QTS_FreeCString=b.T;d._QTS_DupValuePointer=b.U;d._QTS_NewObject=b.V;d._QTS_NewObjectProto=b.W;d._QTS_NewArray=b.X;d._QTS_NewArrayBuffer=b.Y;d._QTS_NewFloat64=b.Z;d._QTS_GetFloat64=b._;d._QTS_NewString=b.$;d._QTS_GetString=b.aa;d._QTS_GetArrayBuffer=b.ba;d._QTS_GetArrayBufferLength=b.ca;d._QTS_NewSymbol=b.da;d._QTS_GetSymbolDescriptionOrKey=b.ea;d._QTS_IsGlobalSymbol=
|
|
22
|
+
b.fa;d._QTS_IsJobPending=b.ga;d._QTS_ExecutePendingJob=b.ha;d._QTS_GetProp=b.ia;d._QTS_GetPropNumber=b.ja;d._QTS_SetProp=b.ka;d._QTS_DefineProp=b.la;d._QTS_GetOwnPropertyNames=b.ma;d._QTS_Call=b.na;d._QTS_ResolveException=b.oa;d._QTS_Dump=b.pa;d._QTS_Eval=b.qa;d._QTS_GetModuleNamespace=b.ra;d._QTS_Typeof=b.sa;d._QTS_GetLength=b.ta;d._QTS_IsEqual=b.ua;d._QTS_GetGlobalObject=b.va;d._QTS_NewPromiseCapability=b.wa;d._QTS_PromiseState=b.xa;d._QTS_PromiseResult=b.ya;d._QTS_TestStringArg=b.za;d._QTS_GetDebugLogEnabled=
|
|
23
|
+
b.Aa;d._QTS_SetDebugLogEnabled=b.Ba;d._QTS_BuildIsDebug=b.Ca;d._QTS_BuildIsAsyncify=b.Da;d._QTS_NewFunction=b.Ea;d._QTS_ArgvGetJSValueConstPointer=b.Fa;d._QTS_RuntimeEnableInterruptHandler=b.Ga;d._QTS_RuntimeDisableInterruptHandler=b.Ha;d._QTS_RuntimeEnableModuleLoader=b.Ia;d._QTS_RuntimeDisableModuleLoader=b.Ja;d._QTS_bjson_encode=b.Ka;d._QTS_bjson_decode=b.La;xa=b.Ma;va=b.Na;Y=b.Oa;ua=b.Pa;return Z}var c={a:ya};if(d.instantiateWasm)return new Promise(b=>{d.instantiateWasm(c,(e,f)=>{b(a(e,f))})});
|
|
24
|
+
O??=d.locateFile?d.locateFile?d.locateFile("emscripten-module.wasm",y):y+"emscripten-module.wasm":(new URL("emscripten-module.wasm",import.meta.url)).href;return a((await ha(c)).instance)}());
|
|
25
|
+
(function(){function a(){d.calledRun=!0;if(!F){ca=!0;Z.v();H?.(d);d.onRuntimeInitialized?.();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var c=d.postRun.shift();ja.push(c)}ia(ja)}}if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)la();ia(ka);d.setStatus?(d.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>d.setStatus(""),1);a()},1)):a()})();ca?moduleRtn=d:moduleRtn=new Promise((a,c)=>{H=a;I=c});
|
|
26
|
+
;return moduleRtn}export default QuickJSRaw;
|
|
Binary file
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { QuickJSEmscriptenModule, JSContextPointer, JSValuePointer, JSValueConstPointer, JSRuntimePointer, OwnedHeapCharPointer, HostRefId, IntrinsicsFlags, JSVoidPointer, JSBorrowedCharPointer, BorrowedHeapCharPointer, JSContextPointerPointer, JSValuePointerPointerPointer, UInt32Pointer, JSValueConstPointerPointer, EvalDetectModule, EvalFlags, IsEqualOp, JSValuePointerPointer, JSPromiseStateEnum } from '@jitl/quickjs-ffi-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Low-level FFI bindings to QuickJS's Emscripten module.
|
|
5
|
+
* See instead {@link QuickJSContext}, the public Javascript interface exposed by this
|
|
6
|
+
* library.
|
|
7
|
+
*
|
|
8
|
+
* @unstable The FFI interface is considered private and may change.
|
|
9
|
+
*/
|
|
10
|
+
declare class QuickJSFFI {
|
|
11
|
+
private module;
|
|
12
|
+
constructor(module: QuickJSEmscriptenModule);
|
|
13
|
+
/** Set at compile time. */
|
|
14
|
+
readonly DEBUG = false;
|
|
15
|
+
QTS_Throw: (ctx: JSContextPointer, error: JSValuePointer | JSValueConstPointer) => JSValuePointer;
|
|
16
|
+
QTS_NewError: (ctx: JSContextPointer) => JSValuePointer;
|
|
17
|
+
QTS_RuntimeSetMemoryLimit: (rt: JSRuntimePointer, limit: number) => void;
|
|
18
|
+
QTS_RuntimeComputeMemoryUsage: (rt: JSRuntimePointer, ctx: JSContextPointer) => JSValuePointer;
|
|
19
|
+
QTS_RuntimeDumpMemoryUsage: (rt: JSRuntimePointer) => OwnedHeapCharPointer;
|
|
20
|
+
QTS_RecoverableLeakCheck: () => number;
|
|
21
|
+
QTS_BuildIsSanitizeLeak: () => number;
|
|
22
|
+
QTS_RuntimeSetMaxStackSize: (rt: JSRuntimePointer, stack_size: number) => void;
|
|
23
|
+
QTS_GetUndefined: () => JSValueConstPointer;
|
|
24
|
+
QTS_GetNull: () => JSValueConstPointer;
|
|
25
|
+
QTS_GetFalse: () => JSValueConstPointer;
|
|
26
|
+
QTS_GetTrue: () => JSValueConstPointer;
|
|
27
|
+
QTS_NewHostRef: (ctx: JSContextPointer, id: HostRefId) => JSValuePointer;
|
|
28
|
+
QTS_GetHostRefId: (value: JSValuePointer | JSValueConstPointer) => HostRefId;
|
|
29
|
+
QTS_NewRuntime: () => JSRuntimePointer;
|
|
30
|
+
QTS_FreeRuntime: (rt: JSRuntimePointer) => void;
|
|
31
|
+
QTS_NewContext: (rt: JSRuntimePointer, intrinsics: IntrinsicsFlags) => JSContextPointer;
|
|
32
|
+
QTS_FreeContext: (ctx: JSContextPointer) => void;
|
|
33
|
+
QTS_FreeValuePointer: (ctx: JSContextPointer, value: JSValuePointer) => void;
|
|
34
|
+
QTS_FreeValuePointerRuntime: (rt: JSRuntimePointer, value: JSValuePointer) => void;
|
|
35
|
+
QTS_FreeVoidPointer: (ctx: JSContextPointer, ptr: JSVoidPointer) => void;
|
|
36
|
+
QTS_FreeCString: (ctx: JSContextPointer, str: JSBorrowedCharPointer) => void;
|
|
37
|
+
QTS_DupValuePointer: (ctx: JSContextPointer, val: JSValuePointer | JSValueConstPointer) => JSValuePointer;
|
|
38
|
+
QTS_NewObject: (ctx: JSContextPointer) => JSValuePointer;
|
|
39
|
+
QTS_NewObjectProto: (ctx: JSContextPointer, proto: JSValuePointer | JSValueConstPointer) => JSValuePointer;
|
|
40
|
+
QTS_NewArray: (ctx: JSContextPointer) => JSValuePointer;
|
|
41
|
+
QTS_NewArrayBuffer: (ctx: JSContextPointer, buffer: JSVoidPointer, length: number) => JSValuePointer;
|
|
42
|
+
QTS_NewFloat64: (ctx: JSContextPointer, num: number) => JSValuePointer;
|
|
43
|
+
QTS_GetFloat64: (ctx: JSContextPointer, value: JSValuePointer | JSValueConstPointer) => number;
|
|
44
|
+
QTS_NewString: (ctx: JSContextPointer, string: BorrowedHeapCharPointer) => JSValuePointer;
|
|
45
|
+
QTS_GetString: (ctx: JSContextPointer, value: JSValuePointer | JSValueConstPointer) => JSBorrowedCharPointer;
|
|
46
|
+
QTS_GetArrayBuffer: (ctx: JSContextPointer, data: JSValuePointer | JSValueConstPointer) => JSVoidPointer;
|
|
47
|
+
QTS_GetArrayBufferLength: (ctx: JSContextPointer, data: JSValuePointer | JSValueConstPointer) => number;
|
|
48
|
+
QTS_NewSymbol: (ctx: JSContextPointer, description: BorrowedHeapCharPointer, isGlobal: number) => JSValuePointer;
|
|
49
|
+
QTS_GetSymbolDescriptionOrKey: (ctx: JSContextPointer, value: JSValuePointer | JSValueConstPointer) => JSBorrowedCharPointer;
|
|
50
|
+
QTS_IsGlobalSymbol: (ctx: JSContextPointer, value: JSValuePointer | JSValueConstPointer) => number;
|
|
51
|
+
QTS_IsJobPending: (rt: JSRuntimePointer) => number;
|
|
52
|
+
QTS_ExecutePendingJob: (rt: JSRuntimePointer, maxJobsToExecute: number, lastJobContext: JSContextPointerPointer) => JSValuePointer;
|
|
53
|
+
QTS_GetProp: (ctx: JSContextPointer, this_val: JSValuePointer | JSValueConstPointer, prop_name: JSValuePointer | JSValueConstPointer) => JSValuePointer;
|
|
54
|
+
QTS_GetPropNumber: (ctx: JSContextPointer, this_val: JSValuePointer | JSValueConstPointer, prop_name: number) => JSValuePointer;
|
|
55
|
+
QTS_SetProp: (ctx: JSContextPointer, this_val: JSValuePointer | JSValueConstPointer, prop_name: JSValuePointer | JSValueConstPointer, prop_value: JSValuePointer | JSValueConstPointer) => void;
|
|
56
|
+
QTS_DefineProp: (ctx: JSContextPointer, this_val: JSValuePointer | JSValueConstPointer, prop_name: JSValuePointer | JSValueConstPointer, prop_value: JSValuePointer | JSValueConstPointer, get: JSValuePointer | JSValueConstPointer, set: JSValuePointer | JSValueConstPointer, configurable: boolean, enumerable: boolean, has_value: boolean) => void;
|
|
57
|
+
QTS_GetOwnPropertyNames: (ctx: JSContextPointer, out_ptrs: JSValuePointerPointerPointer, out_len: UInt32Pointer, obj: JSValuePointer | JSValueConstPointer, flags: number) => JSValuePointer;
|
|
58
|
+
QTS_Call: (ctx: JSContextPointer, func_obj: JSValuePointer | JSValueConstPointer, this_obj: JSValuePointer | JSValueConstPointer, argc: number, argv_ptrs: JSValueConstPointerPointer) => JSValuePointer;
|
|
59
|
+
QTS_ResolveException: (ctx: JSContextPointer, maybe_exception: JSValuePointer) => JSValuePointer;
|
|
60
|
+
QTS_Dump: (ctx: JSContextPointer, obj: JSValuePointer | JSValueConstPointer) => JSBorrowedCharPointer;
|
|
61
|
+
QTS_Eval: (ctx: JSContextPointer, js_code: BorrowedHeapCharPointer, js_code_length: number, filename: string, detectModule: EvalDetectModule, evalFlags: EvalFlags) => JSValuePointer;
|
|
62
|
+
QTS_GetModuleNamespace: (ctx: JSContextPointer, module_func_obj: JSValuePointer | JSValueConstPointer) => JSValuePointer;
|
|
63
|
+
QTS_Typeof: (ctx: JSContextPointer, value: JSValuePointer | JSValueConstPointer) => OwnedHeapCharPointer;
|
|
64
|
+
QTS_GetLength: (ctx: JSContextPointer, out_len: UInt32Pointer, value: JSValuePointer | JSValueConstPointer) => number;
|
|
65
|
+
QTS_IsEqual: (ctx: JSContextPointer, a: JSValuePointer | JSValueConstPointer, b: JSValuePointer | JSValueConstPointer, op: IsEqualOp) => number;
|
|
66
|
+
QTS_GetGlobalObject: (ctx: JSContextPointer) => JSValuePointer;
|
|
67
|
+
QTS_NewPromiseCapability: (ctx: JSContextPointer, resolve_funcs_out: JSValuePointerPointer) => JSValuePointer;
|
|
68
|
+
QTS_PromiseState: (ctx: JSContextPointer, promise: JSValuePointer | JSValueConstPointer) => JSPromiseStateEnum;
|
|
69
|
+
QTS_PromiseResult: (ctx: JSContextPointer, promise: JSValuePointer | JSValueConstPointer) => JSValuePointer;
|
|
70
|
+
QTS_TestStringArg: (string: string) => void;
|
|
71
|
+
QTS_GetDebugLogEnabled: (rt: JSRuntimePointer) => number;
|
|
72
|
+
QTS_SetDebugLogEnabled: (rt: JSRuntimePointer, is_enabled: number) => void;
|
|
73
|
+
QTS_BuildIsDebug: () => number;
|
|
74
|
+
QTS_BuildIsAsyncify: () => number;
|
|
75
|
+
QTS_NewFunction: (ctx: JSContextPointer, name: string, arg_length: number, is_constructor: boolean, host_ref_id: HostRefId) => JSValuePointer;
|
|
76
|
+
QTS_ArgvGetJSValueConstPointer: (argv: JSValuePointer | JSValueConstPointer, index: number) => JSValueConstPointer;
|
|
77
|
+
QTS_RuntimeEnableInterruptHandler: (rt: JSRuntimePointer) => void;
|
|
78
|
+
QTS_RuntimeDisableInterruptHandler: (rt: JSRuntimePointer) => void;
|
|
79
|
+
QTS_RuntimeEnableModuleLoader: (rt: JSRuntimePointer, use_custom_normalize: number) => void;
|
|
80
|
+
QTS_RuntimeDisableModuleLoader: (rt: JSRuntimePointer) => void;
|
|
81
|
+
QTS_bjson_encode: (ctx: JSContextPointer, val: JSValuePointer | JSValueConstPointer) => JSValuePointer;
|
|
82
|
+
QTS_bjson_decode: (ctx: JSContextPointer, data: JSValuePointer | JSValueConstPointer) => JSValuePointer;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { QuickJSFFI };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var QuickJSFFI=class{constructor(module){this.module=module;this.DEBUG=!1;this.QTS_Throw=this.module.cwrap("QTS_Throw","number",["number","number"]);this.QTS_NewError=this.module.cwrap("QTS_NewError","number",["number"]);this.QTS_RuntimeSetMemoryLimit=this.module.cwrap("QTS_RuntimeSetMemoryLimit",null,["number","number"]);this.QTS_RuntimeComputeMemoryUsage=this.module.cwrap("QTS_RuntimeComputeMemoryUsage","number",["number","number"]);this.QTS_RuntimeDumpMemoryUsage=this.module.cwrap("QTS_RuntimeDumpMemoryUsage","number",["number"]);this.QTS_RecoverableLeakCheck=this.module.cwrap("QTS_RecoverableLeakCheck","number",[]);this.QTS_BuildIsSanitizeLeak=this.module.cwrap("QTS_BuildIsSanitizeLeak","number",[]);this.QTS_RuntimeSetMaxStackSize=this.module.cwrap("QTS_RuntimeSetMaxStackSize",null,["number","number"]);this.QTS_GetUndefined=this.module.cwrap("QTS_GetUndefined","number",[]);this.QTS_GetNull=this.module.cwrap("QTS_GetNull","number",[]);this.QTS_GetFalse=this.module.cwrap("QTS_GetFalse","number",[]);this.QTS_GetTrue=this.module.cwrap("QTS_GetTrue","number",[]);this.QTS_NewHostRef=this.module.cwrap("QTS_NewHostRef","number",["number","number"]);this.QTS_GetHostRefId=this.module.cwrap("QTS_GetHostRefId","number",["number"]);this.QTS_NewRuntime=this.module.cwrap("QTS_NewRuntime","number",[]);this.QTS_FreeRuntime=this.module.cwrap("QTS_FreeRuntime",null,["number"]);this.QTS_NewContext=this.module.cwrap("QTS_NewContext","number",["number","number"]);this.QTS_FreeContext=this.module.cwrap("QTS_FreeContext",null,["number"]);this.QTS_FreeValuePointer=this.module.cwrap("QTS_FreeValuePointer",null,["number","number"]);this.QTS_FreeValuePointerRuntime=this.module.cwrap("QTS_FreeValuePointerRuntime",null,["number","number"]);this.QTS_FreeVoidPointer=this.module.cwrap("QTS_FreeVoidPointer",null,["number","number"]);this.QTS_FreeCString=this.module.cwrap("QTS_FreeCString",null,["number","number"]);this.QTS_DupValuePointer=this.module.cwrap("QTS_DupValuePointer","number",["number","number"]);this.QTS_NewObject=this.module.cwrap("QTS_NewObject","number",["number"]);this.QTS_NewObjectProto=this.module.cwrap("QTS_NewObjectProto","number",["number","number"]);this.QTS_NewArray=this.module.cwrap("QTS_NewArray","number",["number"]);this.QTS_NewArrayBuffer=this.module.cwrap("QTS_NewArrayBuffer","number",["number","number","number"]);this.QTS_NewFloat64=this.module.cwrap("QTS_NewFloat64","number",["number","number"]);this.QTS_GetFloat64=this.module.cwrap("QTS_GetFloat64","number",["number","number"]);this.QTS_NewString=this.module.cwrap("QTS_NewString","number",["number","number"]);this.QTS_GetString=this.module.cwrap("QTS_GetString","number",["number","number"]);this.QTS_GetArrayBuffer=this.module.cwrap("QTS_GetArrayBuffer","number",["number","number"]);this.QTS_GetArrayBufferLength=this.module.cwrap("QTS_GetArrayBufferLength","number",["number","number"]);this.QTS_NewSymbol=this.module.cwrap("QTS_NewSymbol","number",["number","number","number"]);this.QTS_GetSymbolDescriptionOrKey=this.module.cwrap("QTS_GetSymbolDescriptionOrKey","number",["number","number"]);this.QTS_IsGlobalSymbol=this.module.cwrap("QTS_IsGlobalSymbol","number",["number","number"]);this.QTS_IsJobPending=this.module.cwrap("QTS_IsJobPending","number",["number"]);this.QTS_ExecutePendingJob=this.module.cwrap("QTS_ExecutePendingJob","number",["number","number","number"]);this.QTS_GetProp=this.module.cwrap("QTS_GetProp","number",["number","number","number"]);this.QTS_GetPropNumber=this.module.cwrap("QTS_GetPropNumber","number",["number","number","number"]);this.QTS_SetProp=this.module.cwrap("QTS_SetProp",null,["number","number","number","number"]);this.QTS_DefineProp=this.module.cwrap("QTS_DefineProp",null,["number","number","number","number","number","number","boolean","boolean","boolean"]);this.QTS_GetOwnPropertyNames=this.module.cwrap("QTS_GetOwnPropertyNames","number",["number","number","number","number","number"]);this.QTS_Call=this.module.cwrap("QTS_Call","number",["number","number","number","number","number"]);this.QTS_ResolveException=this.module.cwrap("QTS_ResolveException","number",["number","number"]);this.QTS_Dump=this.module.cwrap("QTS_Dump","number",["number","number"]);this.QTS_Eval=this.module.cwrap("QTS_Eval","number",["number","number","number","string","number","number"]);this.QTS_GetModuleNamespace=this.module.cwrap("QTS_GetModuleNamespace","number",["number","number"]);this.QTS_Typeof=this.module.cwrap("QTS_Typeof","number",["number","number"]);this.QTS_GetLength=this.module.cwrap("QTS_GetLength","number",["number","number","number"]);this.QTS_IsEqual=this.module.cwrap("QTS_IsEqual","number",["number","number","number","number"]);this.QTS_GetGlobalObject=this.module.cwrap("QTS_GetGlobalObject","number",["number"]);this.QTS_NewPromiseCapability=this.module.cwrap("QTS_NewPromiseCapability","number",["number","number"]);this.QTS_PromiseState=this.module.cwrap("QTS_PromiseState","number",["number","number"]);this.QTS_PromiseResult=this.module.cwrap("QTS_PromiseResult","number",["number","number"]);this.QTS_TestStringArg=this.module.cwrap("QTS_TestStringArg",null,["string"]);this.QTS_GetDebugLogEnabled=this.module.cwrap("QTS_GetDebugLogEnabled","number",["number"]);this.QTS_SetDebugLogEnabled=this.module.cwrap("QTS_SetDebugLogEnabled",null,["number","number"]);this.QTS_BuildIsDebug=this.module.cwrap("QTS_BuildIsDebug","number",[]);this.QTS_BuildIsAsyncify=this.module.cwrap("QTS_BuildIsAsyncify","number",[]);this.QTS_NewFunction=this.module.cwrap("QTS_NewFunction","number",["number","string","number","boolean","number"]);this.QTS_ArgvGetJSValueConstPointer=this.module.cwrap("QTS_ArgvGetJSValueConstPointer","number",["number","number"]);this.QTS_RuntimeEnableInterruptHandler=this.module.cwrap("QTS_RuntimeEnableInterruptHandler",null,["number"]);this.QTS_RuntimeDisableInterruptHandler=this.module.cwrap("QTS_RuntimeDisableInterruptHandler",null,["number"]);this.QTS_RuntimeEnableModuleLoader=this.module.cwrap("QTS_RuntimeEnableModuleLoader",null,["number","number"]);this.QTS_RuntimeDisableModuleLoader=this.module.cwrap("QTS_RuntimeDisableModuleLoader",null,["number"]);this.QTS_bjson_encode=this.module.cwrap("QTS_bjson_encode","number",["number","number"]);this.QTS_bjson_decode=this.module.cwrap("QTS_bjson_decode","number",["number","number"])}};export{QuickJSFFI};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"engine": "quickjs-ng",
|
|
3
|
+
"engineVersion": "0.16.0",
|
|
4
|
+
"minimumSafeVersion": "0.16.0",
|
|
5
|
+
"builtWith": "packages/runtime/engine/build-quickjs-ng.sh (inputs vendored under engine/upstream)",
|
|
6
|
+
"emsdk": "5.0.1",
|
|
7
|
+
"carriedPatches": [
|
|
8
|
+
"patches/engine-call-depth.patch (ours)",
|
|
9
|
+
"patches/upstream-module-detection.patch (upstream\u2019s, vendored)"
|
|
10
|
+
],
|
|
11
|
+
"upstreamIssue": "https://github.com/justjake/quickjs-emscripten/issues/268",
|
|
12
|
+
"note": "Upstream filenames are preserved deliberately \u2014 the emscripten glue resolves emscripten-module.wasm by name. ffi.mjs compiles byte-identically to the packaged variant's; it is vendored from our own build for provenance, and so the vulnerable @jitl/quickjs-ng-wasmfile-release-sync package is not a dependency.",
|
|
13
|
+
"files": {
|
|
14
|
+
"emscripten-module.cloudflare.cjs": {
|
|
15
|
+
"sha256": "9d429ca460e9b885c3d0ad3468e8bd1d3bda3464c5786cd640d644d40c82ae32",
|
|
16
|
+
"bytes": 9440
|
|
17
|
+
},
|
|
18
|
+
"emscripten-module.cloudflare.d.cts": {
|
|
19
|
+
"sha256": "23f76bee99ce1c9636c08bbcddff5252fcb2b345b6c84f4429c226241b3976d8",
|
|
20
|
+
"bytes": 151
|
|
21
|
+
},
|
|
22
|
+
"emscripten-module.d.mts": {
|
|
23
|
+
"sha256": "619a5e36d8cd5dfd1efb111f9580c23e99838d71e99b31f7f7497e9d03dfdd97",
|
|
24
|
+
"bytes": 158
|
|
25
|
+
},
|
|
26
|
+
"emscripten-module.d.ts": {
|
|
27
|
+
"sha256": "8e0faf6e05ab8926d6cc4fa5d66abdc689ea45437397929204d86e18776bc432",
|
|
28
|
+
"bytes": 554
|
|
29
|
+
},
|
|
30
|
+
"emscripten-module.mjs": {
|
|
31
|
+
"sha256": "99ac0fd11ad35554d685a33c8b1e9796821aa392b5af09ca5e5e3f1d0b949945",
|
|
32
|
+
"bytes": 10341
|
|
33
|
+
},
|
|
34
|
+
"emscripten-module.wasm": {
|
|
35
|
+
"sha256": "79ef2ca187b0fbe7f2f64ff74a46f17de91b4b95199f6ea5ba600eea6687e2f4",
|
|
36
|
+
"bytes": 572226
|
|
37
|
+
},
|
|
38
|
+
"ffi.d.mts": {
|
|
39
|
+
"sha256": "892d8ce15f14e3cb5da577bc7be7ca464c90f8029bf53993d6566c459a5affa1",
|
|
40
|
+
"bytes": 247
|
|
41
|
+
},
|
|
42
|
+
"ffi.d.ts": {
|
|
43
|
+
"sha256": "4aad6025f46424783cc19c3127b7c8fae72eaf39109cc108a70987af7fea02ce",
|
|
44
|
+
"bytes": 7575
|
|
45
|
+
},
|
|
46
|
+
"ffi.mjs": {
|
|
47
|
+
"sha256": "30010810780f1a7167def5a35b25729985d0f8e30f1f23695c01cd13870d9139",
|
|
48
|
+
"bytes": 6337
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export { defineServer } from './server';
|
|
|
23
23
|
export type { DefineServerOptions, GeneratedServer, RegisteredTool, ToolHandler, } from './server';
|
|
24
24
|
export { classifyToolError, isRetryableUpstreamStatus, runToolHandler, ToolInputError, toToolErrorResult, UpstreamHttpError, } from './tool-errors';
|
|
25
25
|
export type { ToolErrorClass, ToolErrorMeta } from './tool-errors';
|
|
26
|
+
export { runInSandbox, DEFAULT_SANDBOX_LIMITS } from './sandbox/createSandbox';
|
|
27
|
+
export { buildFailureDigest, effectClassFromAnnotations, codeModeDescription, shouldRegisterCodeMode, CODE_MODE_TOOL_NAME, } from './sandbox/codeModeTool';
|
|
28
|
+
export type { CodeModeMode, CodeModeOptions } from './sandbox/codeModeTool';
|
|
29
|
+
export { summarizeShape, describeDistribution } from './sandbox/shape';
|
|
30
|
+
export type { SandboxBindings, SandboxEffectClass } from './sandbox/bindings';
|
|
31
|
+
export type { SandboxLimits, SandboxResult, SandboxSpan, SandboxFailureKind, } from './sandbox/types';
|
|
26
32
|
export { toWorkerHandler } from './adapters/worker';
|
|
27
33
|
export { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
28
34
|
export { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|