toilscript 0.1.62 → 0.1.64
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/cli.generated.d.ts +6 -5
- package/dist/cli.js +288 -12
- package/dist/cli.js.map +2 -2
- package/dist/importmap.json +2 -2
- package/dist/toilscript.generated.d.ts +6 -5
- package/dist/toilscript.js +37 -37
- package/dist/toilscript.js.map +3 -3
- package/dist/web.js +3 -3
- package/package.json +8 -2
- package/std/assembly/bindings/toildb.ts +50 -0
- package/std/assembly/log.ts +14 -0
- package/std/assembly/toildb.ts +221 -9
- package/std/assembly/toilscript.d.ts +54 -3
package/dist/cli.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Copyright 2026 Daniel Wirtz / The ToilScript Authors
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
*/
|
|
7
|
-
var le=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var dn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(a){throw n=[a],a}};var nn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pe(t))!Ve.call(e,s)&&s!==n&&le(e,s,{get:()=>t[s],enumerable:!(a=Me(t,s))||a.enumerable});return e},In=(e,t,n)=>(se(e,t,"default"),n&&se(n,t,"default"));var ue={};nn(ue,{promises:()=>He});var He,fe=dn(()=>{"use strict";He={}});var ce={};nn(ce,{createRequire:()=>Ge});function Ge(){return function(t){throw new Error(`Cannot find module: '${t}'`)}}var de=dn(()=>{"use strict"});var
|
|
8
|
-
`,o={},c=[];Object.keys(e).forEach(b=>{var h=e[b];if(h.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,h.alias&&(g+=", -"+h.alias);g.length<a;)g+=" ";var y;!t.noCategories&&h.category?(y=o[h.category])||(o[h.category]=y=[]):y=c,Array.isArray(h.description)?y.push(g+h.description[0]+h.description.slice(1).map(m=>{for(let i=0;i<a;++i)m=" "+m;return s+m}).join("")):y.push(g+h.description)}});var d=[],x=!1;return Object.keys(o).forEach(b=>{x=!0,d.push(s+" "+Tn.gray(b)+s),d.push(o[b].join(s))}),x&&c.length&&d.push(s+" "+Tn.gray("Other")+s),d.push(c.join(s)),d.join(s)}function ye(e,t){if(e!=null)switch(t){case void 0:case"b":return!!e;case"i":return Math.trunc(e)||0;case"f":return Number(e)||0;case"s":return e===!0?"":e===!1?null:String(e);case"I":return Array.isArray(e)||(e=[e]),e.map(n=>Math.trunc(n)||0);case"F":return Array.isArray(e)||(e=[e]),e.map(n=>Number(n)||0);case"S":return Array.isArray(e)||(e=[e]),e.map(String)}}function Mn(e,t,n,a){let s={};for(let[o,{type:c,mutuallyExclusive:d,isPath:x,useNodeResolution:b,cliOnly:h}]of Object.entries(e)){let g=ye(t[o],c),y=ye(n[o],c);if(g==null){if(y!=null){if(h)continue;if(Array.isArray(y)){let m;x&&(y=y.map(i=>tn(i,a,b))),d!=null&&(m=t[d])?s[o]=y.filter(i=>!m.includes(i)):s[o]=y.slice()}else x&&(y=tn(y,a,b)),s[o]=y}}else if(y==null)Array.isArray(g)?s[o]=g.slice():s[o]=g;else if(Array.isArray(g)){if(h){s[o]=g.slice();continue}let m;x&&(y=y.map(i=>tn(i,a,b))),d!=null&&(m=t[d])?s[o]=[...g,...y.filter(i=>!g.includes(i)&&!m.includes(i))]:s[o]=[...g,...y.filter(i=>!g.includes(i))]}else s[o]=g}return s}function Et(e){let t=E.parse(e);return t.root||(t.root="./"),E.format(t)}function tn(e,t,n=!1){return E.isAbsolute(e)?e:n&&!e.startsWith(".")&&be.resolve?be.resolve(e,{paths:[t]}):Et(E.join(t,e))}function Pn(e,t){for(let[n,{default:a}]of Object.entries(e))t[n]==null&&a!=null&&(t[n]=a)}var Ee="0.1.62",Y={version:{category:"General",description:"Prints just the compiler's version and exits.",type:"b",alias:"v"},help:{category:"General",description:"Prints this message and exits.",type:"b",alias:"h"},config:{category:"General",description:"Configuration file to apply. CLI arguments take precedence.",type:"s",cliOnly:!0},target:{category:"General",description:"Configuration file target to use. Defaults to 'release'.",type:"s",cliOnly:!0},targetMode:{category:"General",description:"Toil compile surface mode: 'hot' (request/stream) or 'cold' (daemon). Omit for the default request artifact.",type:"s"},authUser:{category:"General",description:"Built-in auth: inject the reserved toilUserId + username fields into the single @user (used by the toiljs server.auth build when the app declares its own @user).",type:"b"},noConfigEntries:{category:"General",description:"Ignore the toilconfig 'entries' array and compile ONLY the entry files given on the command line. Used by the toiljs multi-artifact build, which hands each pass (request/stream/daemon) its own entry subset.",type:"b"},optimize:{category:"Optimization",description:["Optimizes the module. Typical shorthands are:",""," Default optimizations -O"," Make a release build -O --noAssert"," Make a debug build --debug"," Optimize for speed -Ospeed"," Optimize for size -Osize",""],type:"b",alias:"O"},optimizeLevel:{category:"Optimization",description:"How much to focus on optimizing code. [0-3]",type:"i"},shrinkLevel:{category:"Optimization",description:"How much to focus on shrinking code size. [0-2, s=1, z=2]",type:"i"},converge:{category:"Optimization",description:"Re-optimizes until no further improvements can be made.",type:"b",default:!1},noAssert:{category:"Optimization",description:"Replaces assertions with just their value without trapping.",type:"b",default:!1},outFile:{category:"Output",description:"Specifies the WebAssembly output file (.wasm).",type:"s",alias:"o",isPath:!0},textFile:{category:"Output",description:"Specifies the WebAssembly text output file (.wat).",type:"s",alias:"t",isPath:!0},rpcModule:{category:"Output",description:"Emits a .ts module: the @data codec + the typed client-callable Server surface.",type:"s",isPath:!0},rpcSurfaceFiles:{category:"Output",description:"Files parsed for the rpc module's @rest/@stream client surface but NOT compiled into this artifact (folds a sibling tier's @stream classes into the Server surface).",type:"S",isPath:!0},rpcRuntime:{category:"Output",description:"Import specifier for the DataWriter/DataReader codec in the emitted RPC module.",type:"s",default:"toiljs/io"},bindings:{category:"Output",description:["Specifies the bindings to generate (.js + .d.ts).",""," esm JavaScript bindings & typings for ESM integration."," raw Like esm, but exports just the instantiate function."," Useful where modules are meant to be instantiated"," multiple times or non-ESM imports must be provided."],type:"S",alias:"b"},sourceMap:{category:"Debugging",description:["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],type:"s"},uncheckedBehavior:{category:"Debugging",description:["Changes the behavior of unchecked() expressions.","Using this option can potentially cause breakage.",""," default The default behavior: unchecked operations are"," only used inside of unchecked()."," never Unchecked operations are never used, even when"," inside of unchecked()."," always Unchecked operations are always used if possible,"," whether or not unchecked() is used."],type:"s",default:"default"},debug:{category:"Debugging",description:"Enables debug information in emitted binaries.",type:"b",default:!1},importMemory:{category:"Features",description:"Imports the memory from 'env.memory'.",type:"b",default:!1},noExportMemory:{category:"Features",description:"Does not export the memory as 'memory'.",type:"b",default:!1},initialMemory:{category:"Features",description:"Sets the initial memory size in pages.",type:"i",default:0},maximumMemory:{category:"Features",description:"Sets the maximum memory size in pages.",type:"i",default:0},sharedMemory:{category:"Features",description:"Declare memory as shared. Requires maximumMemory.",type:"b",default:!1},zeroFilledMemory:{category:"Features",description:"Assume imported memory is zeroed. Requires importMemory.",type:"b",default:!1},importTable:{category:"Features",description:"Imports the function table from 'env.table'.",type:"b",default:!1},exportTable:{category:"Features",description:"Exports the function table as 'table'.",type:"b",default:!1},exportStart:{category:"Features",description:["Exports the start function using the specified name instead","of calling it implicitly. Useful to obtain the exported memory","before executing any code accessing it."],type:"s"},runtime:{category:"Features",description:["Specifies the runtime variant to include in the program.",""," incremental TLSF + incremental GC (default)"," minimal TLSF + lightweight GC invoked externally"," stub Minimal runtime stub (never frees)"," ... Path to a custom runtime implementation",""],type:"s",default:"incremental"},exportRuntime:{category:"Features",description:["Always exports the runtime helpers (__new, __collect, __pin etc.).","Automatically determined when generation of --bindings is enabled."],type:"b",default:!1},stackSize:{category:"Features",description:["Overrides the stack size. Only relevant for incremental GC","or when using a custom runtime that requires stack space.","Defaults to 0 without and to 32768 with incremental GC."],default:0,type:"i"},enable:{category:"Features",description:["Enables WebAssembly features being disabled by default.",""," threads Threading and atomic operations."," simd SIMD types and operations."," reference-types Reference types and operations."," gc Garbage collection (WIP)."," stringref String reference types."," relaxed-simd Relaxed SIMD operations.",""],TODO_doesNothingYet:[" exception-handling Exception handling."," tail-calls Tail call operations."," multi-value Multi value types."," memory64 Memory64 operations."," extended-const Extended const expressions."],type:"S",mutuallyExclusive:"disable"},disable:{category:"Features",description:["Disables WebAssembly features being enabled by default.",""," mutable-globals Mutable global imports and exports."," sign-extension Sign-extension operations"," nontrapping-f2i Non-trapping float to integer ops."," bulk-memory Bulk memory operations.",""],type:"S",mutuallyExclusive:"enable"},use:{category:"Features",description:["Aliases a global object under another name, e.g., to switch","the default 'Math' implementation used: --use Math=JSMath","Can also be used to introduce an integer constant."],type:"S",alias:"u"},lowMemoryLimit:{category:"Features",description:"Enforces very low (<64k) memory constraints.",default:0,type:"i"},memoryBase:{category:"Linking",description:"Sets the start offset of emitted memory segments.",type:"i",default:0},tableBase:{category:"Linking",description:"Sets the start offset of emitted table elements.",type:"i",default:0},transform:{category:"API",description:"Specifies the path to a custom transform to load.",type:"S",isPath:!0,useNodeResolution:!0},trapMode:{category:"Binaryen",description:["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],type:"s",default:"allow"},runPasses:{category:"Binaryen",description:["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],type:"s"},noValidate:{category:"Binaryen",description:"Skips validating the module using Binaryen.",type:"b",default:!1},baseDir:{description:"Specifies the base directory of input and output files.",type:"s",default:"."},noColors:{description:"Disables terminal colors.",type:"b",default:!1},noUnsafe:{description:["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],type:"b",default:!1},disableWarning:{description:["Disables warnings matching the given diagnostic code.","If no diagnostic code is given, all warnings are disabled."],type:"I"},noEmit:{description:"Performs compilation as usual but does not emit code.",type:"b",default:!1},showConfig:{description:"Print computed compiler options and exit.",type:"b",default:!1},stats:{description:"Prints statistics on I/O and compile times.",type:"b",default:!1},pedantic:{description:"Make yourself sad for no good reason.",type:"b",default:!1},lib:{description:["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],type:"S",isPath:!0},path:{description:["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an 'ascMain' entry in a package's","package.json and falls back to an inner 'assembly/' folder."],type:"S",isPath:!0},wasm:{description:"Uses the specified Wasm binary of the compiler.",type:"s"}," ...":{description:"Specifies node.js options (CLI only). See: node --help"},"-Os":{value:{optimizeLevel:0,shrinkLevel:1}},"-Oz":{value:{optimizeLevel:0,shrinkLevel:2}},"-O0":{value:{optimizeLevel:0,shrinkLevel:0}},"-O1":{value:{optimizeLevel:1,shrinkLevel:0}},"-O2":{value:{optimizeLevel:2,shrinkLevel:0}},"-O3":{value:{optimizeLevel:3,shrinkLevel:0}},"-O0s":{value:{optimizeLevel:0,shrinkLevel:1}},"-O1s":{value:{optimizeLevel:1,shrinkLevel:1}},"-O2s":{value:{optimizeLevel:2,shrinkLevel:1}},"-O3s":{value:{optimizeLevel:3,shrinkLevel:1}},"-O0z":{value:{optimizeLevel:0,shrinkLevel:2}},"-O1z":{value:{optimizeLevel:1,shrinkLevel:2}},"-O2z":{value:{optimizeLevel:2,shrinkLevel:2}},"-O3z":{value:{optimizeLevel:3,shrinkLevel:2}},"-Ospeed":{value:{optimizeLevel:3,shrinkLevel:0}},"-Osize":{value:{optimizeLevel:0,shrinkLevel:2,converge:!0}},"--measure":{value:{stats:!0}}},Ae="~lib/",_e={array:`/// <reference path="./rt/index.d.ts" />
|
|
7
|
+
var le=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var dn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(a){throw n=[a],a}};var nn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pe(t))!Ve.call(e,s)&&s!==n&&le(e,s,{get:()=>t[s],enumerable:!(a=Me(t,s))||a.enumerable});return e},In=(e,t,n)=>(se(e,t,"default"),n&&se(n,t,"default"));var ue={};nn(ue,{promises:()=>He});var He,fe=dn(()=>{"use strict";He={}});var ce={};nn(ce,{createRequire:()=>Ge});function Ge(){return function(t){throw new Error(`Cannot find module: '${t}'`)}}var de=dn(()=>{"use strict"});var Ln={};nn(Ln,{argv:()=>Xe,cwd:()=>kn,exit:()=>qe,hrtime:()=>Ye,platform:()=>je,umask:()=>Ke});function kn(){return"."}function Ke(){return 0}function qe(e=0){throw Error(`exit ${e}`)}function Ye(e){var t=We.call(he),n=Math.floor(t*.001),a=Math.floor(t*1e6-n*1e9);return e&&(n-=e[0],a-=e[1],a<0&&(n--,a+=1e9)),[n,a]}var je,Xe,he,We,On=dn(()=>{"use strict";je="linux";Xe=[];he=globalThis.performance||{},We=he.now||function(){return new Date().getTime()}});var Nn={};nn(Nn,{basename:()=>et,delimiter:()=>at,dirname:()=>nt,extname:()=>tt,format:()=>rt,isAbsolute:()=>Ze,join:()=>$e,normalize:()=>xe,parse:()=>it,relative:()=>Qe,resolve:()=>hn,sep:()=>Rn,win32:()=>ot});function H(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function pe(e,t){for(var n="",a=0,s=-1,o=0,c,d=0;d<=e.length;++d){if(d<e.length)c=e.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(s===d-1||o===1))if(s!==d-1&&o===2){if(n.length<2||a!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var x=n.lastIndexOf("/");if(x!==n.length-1){x===-1?(n="",a=0):(n=n.slice(0,x),a=n.length-1-n.lastIndexOf("/")),s=d,o=0;continue}}else if(n.length===2||n.length===1){n="",a=0,s=d,o=0;continue}}t&&(n.length>0?n+="/..":n="..",a=2)}else n.length>0?n+="/"+e.slice(s+1,d):n=e.slice(s+1,d),a=d-s-1;s=d,o=0}else c===46&&o!==-1?++o:o=-1}return n}function Je(e,t){var n=t.dir||t.root,a=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+a:n+e+a:a}function hn(){for(var e="",t=!1,n,a=arguments.length-1;a>=-1&&!t;a--){var s;a>=0?s=arguments[a]:(n===void 0&&(n=kn()),s=n),H(s),s.length!==0&&(e=s+"/"+e,t=s.charCodeAt(0)===47)}return e=pe(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."}function xe(e){if(H(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=pe(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e}function Ze(e){return H(e),e.length>0&&e.charCodeAt(0)===47}function $e(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];H(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":xe(e)}function Qe(e,t){if(H(e),H(t),e===t||(e=hn(e),t=hn(t),e===t))return"";if(e===".")return t;for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var a=e.length,s=a-n,o=1;o<t.length&&t.charCodeAt(o)===47;++o);for(var c=t.length,d=c-o,x=s<d?s:d,b=-1,h=0;h<=x;++h){if(h===x){if(d>x){if(t.charCodeAt(o+h)===47)return t.slice(o+h+1);if(h===0)return t.slice(o+h)}else s>x&&(e.charCodeAt(n+h)===47?b=h:h===0&&(b=0));break}var g=e.charCodeAt(n+h),y=t.charCodeAt(o+h);if(g!==y)break;g===47&&(b=h)}var m="";for(h=n+b+1;h<=a;++h)(h===a||e.charCodeAt(h)===47)&&(m.length===0?m+="..":m+="/..");return m.length>0?m+t.slice(o+b):(o+=b,t.charCodeAt(o)===47&&++o,t.slice(o))}function nt(e){if(H(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,a=-1,s=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!s){a=o;break}}else s=!1;return a===-1?n?"/":".":n&&a===1?"//":e.slice(0,a)}function et(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');H(e);var n=0,a=-1,s=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var c=t.length-1,d=-1;for(o=e.length-1;o>=0;--o){var x=e.charCodeAt(o);if(x===47){if(!s){n=o+1;break}}else d===-1&&(s=!1,d=o+1),c>=0&&(x===t.charCodeAt(c)?--c===-1&&(a=o):(c=-1,a=d))}return n===a?a=d:a===-1&&(a=e.length),e.slice(n,a)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!s){n=o+1;break}}else a===-1&&(s=!1,a=o+1);return a===-1?"":e.slice(n,a)}}function tt(e){H(e);for(var t=-1,n=0,a=-1,s=!0,o=0,c=e.length-1;c>=0;--c){var d=e.charCodeAt(c);if(d===47){if(!s){n=c+1;break}continue}a===-1&&(s=!1,a=c+1),d===46?t===-1?t=c:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||a===-1||o===0||o===1&&t===a-1&&t===n+1?"":e.slice(t,a)}function rt(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return Je("/",e)}function it(e){H(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),a=n===47,s;a?(t.root="/",s=1):s=0;for(var o=-1,c=0,d=-1,x=!0,b=e.length-1,h=0;b>=s;--b){if(n=e.charCodeAt(b),n===47){if(!x){c=b+1;break}continue}d===-1&&(x=!1,d=b+1),n===46?o===-1?o=b:h!==1&&(h=1):o!==-1&&(h=-1)}return o===-1||d===-1||h===0||h===1&&o===d-1&&o===c+1?d!==-1&&(c===0&&a?t.base=t.name=e.slice(1,d):t.base=t.name=e.slice(c,d)):(c===0&&a?(t.name=e.slice(1,o),t.base=e.slice(1,d)):(t.name=e.slice(c,o),t.base=e.slice(c,d)),t.ext=e.slice(o,d)),c>0?t.dir=e.slice(0,c-1):a&&(t.dir="/"),t}var Rn,at,ot,Un=dn(()=>{"use strict";On();Rn="/",at=":",ot=null});var ge={};nn(ge,{pathToFileURL:()=>lt});function st(e){return e.replace(/%/g,"%25").replace(/\\/g,"%5C").replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/\t/g,"%09")}function lt(e){let t=hn(e);e.charCodeAt(e.length-1)===47&&t[t.length-1]!==Rn&&(t+="/");let n=new URL("file://");return n.pathname=st(t),n}var me=dn(()=>{"use strict";Un()});var Yn={};nn(Yn,{Stats:()=>zn,checkDiagnostics:()=>mn,compileString:()=>Dt,configToArguments:()=>Wn,createMemoryStream:()=>Xn,default:()=>Yn,defaultOptimizeLevel:()=>we,defaultShrinkLevel:()=>Be,definitionFiles:()=>Bt,libraryFiles:()=>j,libraryPrefix:()=>V,main:()=>De,options:()=>wt,tscOptions:()=>It,version:()=>Kn});var ut=Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]",M,sn,E,P,pn;ut?(M=await import("fs"),sn=await import("module"),E=await import("path"),P=globalThis.process,pn=await import("url")):(M=await Promise.resolve().then(()=>(fe(),ue)),sn=await Promise.resolve().then(()=>(de(),ce)),E=await Promise.resolve().then(()=>(Un(),Nn)),P=await Promise.resolve().then(()=>(On(),Ln)),pn=await Promise.resolve().then(()=>(me(),ge)));var _n=typeof process<"u"&&process||{},ft=_n.env&&"CI"in _n.env,ct="\x1B[90m",dt="\x1B[91m",ht="\x1B[92m",pt="\x1B[93m",xt="\x1B[94m",gt="\x1B[95m",mt="\x1B[96m",bt="\x1B[97m",W="\x1B[0m",en=class{constructor(t){this.stream=t,this.enabled=!!(this.stream&&this.stream.isTTY||ft)}gray(t){return this.enabled?ct+t+W:t}red(t){return this.enabled?dt+t+W:t}green(t){return this.enabled?ht+t+W:t}yellow(t){return this.enabled?pt+t+W:t}blue(t){return this.enabled?xt+t+W:t}magenta(t){return this.enabled?gt+t+W:t}cyan(t){return this.enabled?mt+t+W:t}white(t){return this.enabled?bt+t+W:t}},Tn=new en(_n.stdout),Ot=new en(_n.stderr);function yt(e){for(var t=0,n=0,a=e.length;n<a;++n){let s=e.charCodeAt(n);s<128?t+=1:s<2048?t+=2:(s&64512)===55296&&n+1<a&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3}return t}function vt(e,t,n){var a=n-t;if(a<1)return"";for(var s=null,o=[],c=0,d;t<n;)d=e[t++],d<128?o[c++]=d:d>191&&d<224?o[c++]=(d&31)<<6|e[t++]&63:d>239&&d<365?(d=((d&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,o[c++]=55296+(d>>10),o[c++]=56320+(d&1023)):o[c++]=(d&15)<<12|(e[t++]&63)<<6|e[t++]&63,c>=8192&&((s||(s=[])).push(String.fromCharCode(...o)),c=0);return s?(c&&s.push(String.fromCharCode(...o.slice(0,c))),s.join("")):String.fromCharCode(...o.slice(0,c))}function Ft(e,t,n){for(var a=n,s=0,o=e.length;s<o;++s){let c=e.charCodeAt(s),d;c<128?t[n++]=c:c<2048?(t[n++]=c>>6|192,t[n++]=c&63|128):(c&64512)===55296&&s+1<o&&((d=e.charCodeAt(s+1))&64512)===56320?(c=65536+((c&1023)<<10)+(d&1023),++s,t[n++]=c>>18|240,t[n++]=c>>12&63|128,t[n++]=c>>6&63|128,t[n++]=c&63|128):(t[n++]=c>>12|224,t[n++]=c>>6&63|128,t[n++]=c&63|128)}return n-a}var Cn={length:yt,read:vt,write:Ft};var be=sn.createRequire(import.meta.url);function ve(e,t,n=!0){var a={},s=[],o=[],c=[],d={};Object.keys(t).forEach(h=>{if(!h.startsWith(" ")){var g=t[h];g.alias!=null&&(typeof g.alias=="string"?d[g.alias]=h:Array.isArray(g.alias)&&g.alias.forEach(y=>d[y]=h)),n&&g.default!=null&&(a[h]=g.default)}});for(var x=0,b=(e=e.slice()).length;x<b;++x){let h=e[x];if(h=="--"){++x;break}let g=/^(?:(-\w)(?:=(.*))?|(--\w{2,})(?:=(.*))?)$/.exec(h),y,m;if(g)t[h]?y=t[m=h]:g[1]!=null?(y=t[m=d[g[1].substring(1)]],y&&g[2]!=null&&(e[x--]=g[2])):g[3]!=null&&(y=t[m=g[3].substring(2)],y&&g[4]!=null&&(e[x--]=g[4]));else if(h.charCodeAt(0)==45)y=t[m=h];else{o.push(h);continue}if(y)if(y.value)Object.keys(y.value).forEach(r=>a[r]=y.value[r]);else if(y.type==null||y.type==="b")a[m]=!0;else if(x+1<e.length&&e[x+1].charCodeAt(0)!=45)switch(y.type){case"i":a[m]=parseInt(e[++x],10);break;case"I":a[m]=(a[m]||[]).concat(parseInt(e[++x],10));break;case"f":a[m]=parseFloat(e[++x]);break;case"F":a[m]=(a[m]||[]).concat(parseFloat(e[++x]));break;case"s":a[m]=String(e[++x]);break;case"S":a[m]=(a[m]||[]).concat(e[++x].split(","));break;default:s.push(h),--x}else switch(y.type){case"i":case"f":a[m]=y.default||0;break;case"s":a[m]=y.default||"";break;case"I":case"F":case"S":a[m]=y.default||[];break;default:s.push(h)}else s.push(h)}for(;x<b;)c.push(e[x++]);return n&&Pn(t,a),{options:a,unknown:s,arguments:o,trailing:c}}function Fe(e,t){t||(t={});var n=t.indent||2,a=t.padding||24,s=t.eol||`
|
|
8
|
+
`,o={},c=[];Object.keys(e).forEach(b=>{var h=e[b];if(h.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,h.alias&&(g+=", -"+h.alias);g.length<a;)g+=" ";var y;!t.noCategories&&h.category?(y=o[h.category])||(o[h.category]=y=[]):y=c,Array.isArray(h.description)?y.push(g+h.description[0]+h.description.slice(1).map(m=>{for(let r=0;r<a;++r)m=" "+m;return s+m}).join("")):y.push(g+h.description)}});var d=[],x=!1;return Object.keys(o).forEach(b=>{x=!0,d.push(s+" "+Tn.gray(b)+s),d.push(o[b].join(s))}),x&&c.length&&d.push(s+" "+Tn.gray("Other")+s),d.push(c.join(s)),d.join(s)}function ye(e,t){if(e!=null)switch(t){case void 0:case"b":return!!e;case"i":return Math.trunc(e)||0;case"f":return Number(e)||0;case"s":return e===!0?"":e===!1?null:String(e);case"I":return Array.isArray(e)||(e=[e]),e.map(n=>Math.trunc(n)||0);case"F":return Array.isArray(e)||(e=[e]),e.map(n=>Number(n)||0);case"S":return Array.isArray(e)||(e=[e]),e.map(String)}}function Mn(e,t,n,a){let s={};for(let[o,{type:c,mutuallyExclusive:d,isPath:x,useNodeResolution:b,cliOnly:h}]of Object.entries(e)){let g=ye(t[o],c),y=ye(n[o],c);if(g==null){if(y!=null){if(h)continue;if(Array.isArray(y)){let m;x&&(y=y.map(r=>tn(r,a,b))),d!=null&&(m=t[d])?s[o]=y.filter(r=>!m.includes(r)):s[o]=y.slice()}else x&&(y=tn(y,a,b)),s[o]=y}}else if(y==null)Array.isArray(g)?s[o]=g.slice():s[o]=g;else if(Array.isArray(g)){if(h){s[o]=g.slice();continue}let m;x&&(y=y.map(r=>tn(r,a,b))),d!=null&&(m=t[d])?s[o]=[...g,...y.filter(r=>!g.includes(r)&&!m.includes(r))]:s[o]=[...g,...y.filter(r=>!g.includes(r))]}else s[o]=g}return s}function Et(e){let t=E.parse(e);return t.root||(t.root="./"),E.format(t)}function tn(e,t,n=!1){return E.isAbsolute(e)?e:n&&!e.startsWith(".")&&be.resolve?be.resolve(e,{paths:[t]}):Et(E.join(t,e))}function Pn(e,t){for(let[n,{default:a}]of Object.entries(e))t[n]==null&&a!=null&&(t[n]=a)}var Ee="0.1.64",Y={version:{category:"General",description:"Prints just the compiler's version and exits.",type:"b",alias:"v"},help:{category:"General",description:"Prints this message and exits.",type:"b",alias:"h"},config:{category:"General",description:"Configuration file to apply. CLI arguments take precedence.",type:"s",cliOnly:!0},target:{category:"General",description:"Configuration file target to use. Defaults to 'release'.",type:"s",cliOnly:!0},targetMode:{category:"General",description:"Toil compile surface mode: 'hot' (request/stream) or 'cold' (daemon). Omit for the default request artifact.",type:"s"},authUser:{category:"General",description:"Built-in auth: inject the reserved toilUserId + username fields into the single @user (used by the toiljs server.auth build when the app declares its own @user).",type:"b"},noConfigEntries:{category:"General",description:"Ignore the toilconfig 'entries' array and compile ONLY the entry files given on the command line. Used by the toiljs multi-artifact build, which hands each pass (request/stream/daemon) its own entry subset.",type:"b"},optimize:{category:"Optimization",description:["Optimizes the module. Typical shorthands are:",""," Default optimizations -O"," Make a release build -O --noAssert"," Make a debug build --debug"," Optimize for speed -Ospeed"," Optimize for size -Osize",""],type:"b",alias:"O"},optimizeLevel:{category:"Optimization",description:"How much to focus on optimizing code. [0-3]",type:"i"},shrinkLevel:{category:"Optimization",description:"How much to focus on shrinking code size. [0-2, s=1, z=2]",type:"i"},converge:{category:"Optimization",description:"Re-optimizes until no further improvements can be made.",type:"b",default:!1},noAssert:{category:"Optimization",description:"Replaces assertions with just their value without trapping.",type:"b",default:!1},outFile:{category:"Output",description:"Specifies the WebAssembly output file (.wasm).",type:"s",alias:"o",isPath:!0},textFile:{category:"Output",description:"Specifies the WebAssembly text output file (.wat).",type:"s",alias:"t",isPath:!0},rpcModule:{category:"Output",description:"Emits a .ts module: the @data codec + the typed client-callable Server surface.",type:"s",isPath:!0},rpcSurfaceFiles:{category:"Output",description:"Files parsed for the rpc module's @rest/@stream client surface but NOT compiled into this artifact (folds a sibling tier's @stream classes into the Server surface).",type:"S",isPath:!0},rpcRuntime:{category:"Output",description:"Import specifier for the DataWriter/DataReader codec in the emitted RPC module.",type:"s",default:"toiljs/io"},bindings:{category:"Output",description:["Specifies the bindings to generate (.js + .d.ts).",""," esm JavaScript bindings & typings for ESM integration."," raw Like esm, but exports just the instantiate function."," Useful where modules are meant to be instantiated"," multiple times or non-ESM imports must be provided."],type:"S",alias:"b"},sourceMap:{category:"Debugging",description:["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],type:"s"},uncheckedBehavior:{category:"Debugging",description:["Changes the behavior of unchecked() expressions.","Using this option can potentially cause breakage.",""," default The default behavior: unchecked operations are"," only used inside of unchecked()."," never Unchecked operations are never used, even when"," inside of unchecked()."," always Unchecked operations are always used if possible,"," whether or not unchecked() is used."],type:"s",default:"default"},debug:{category:"Debugging",description:"Enables debug information in emitted binaries.",type:"b",default:!1},importMemory:{category:"Features",description:"Imports the memory from 'env.memory'.",type:"b",default:!1},noExportMemory:{category:"Features",description:"Does not export the memory as 'memory'.",type:"b",default:!1},initialMemory:{category:"Features",description:"Sets the initial memory size in pages.",type:"i",default:0},maximumMemory:{category:"Features",description:"Sets the maximum memory size in pages.",type:"i",default:0},sharedMemory:{category:"Features",description:"Declare memory as shared. Requires maximumMemory.",type:"b",default:!1},zeroFilledMemory:{category:"Features",description:"Assume imported memory is zeroed. Requires importMemory.",type:"b",default:!1},importTable:{category:"Features",description:"Imports the function table from 'env.table'.",type:"b",default:!1},exportTable:{category:"Features",description:"Exports the function table as 'table'.",type:"b",default:!1},exportStart:{category:"Features",description:["Exports the start function using the specified name instead","of calling it implicitly. Useful to obtain the exported memory","before executing any code accessing it."],type:"s"},runtime:{category:"Features",description:["Specifies the runtime variant to include in the program.",""," incremental TLSF + incremental GC (default)"," minimal TLSF + lightweight GC invoked externally"," stub Minimal runtime stub (never frees)"," ... Path to a custom runtime implementation",""],type:"s",default:"incremental"},exportRuntime:{category:"Features",description:["Always exports the runtime helpers (__new, __collect, __pin etc.).","Automatically determined when generation of --bindings is enabled."],type:"b",default:!1},stackSize:{category:"Features",description:["Overrides the stack size. Only relevant for incremental GC","or when using a custom runtime that requires stack space.","Defaults to 0 without and to 32768 with incremental GC."],default:0,type:"i"},enable:{category:"Features",description:["Enables WebAssembly features being disabled by default.",""," threads Threading and atomic operations."," simd SIMD types and operations."," reference-types Reference types and operations."," gc Garbage collection (WIP)."," stringref String reference types."," relaxed-simd Relaxed SIMD operations.",""],TODO_doesNothingYet:[" exception-handling Exception handling."," tail-calls Tail call operations."," multi-value Multi value types."," memory64 Memory64 operations."," extended-const Extended const expressions."],type:"S",mutuallyExclusive:"disable"},disable:{category:"Features",description:["Disables WebAssembly features being enabled by default.",""," mutable-globals Mutable global imports and exports."," sign-extension Sign-extension operations"," nontrapping-f2i Non-trapping float to integer ops."," bulk-memory Bulk memory operations.",""],type:"S",mutuallyExclusive:"enable"},use:{category:"Features",description:["Aliases a global object under another name, e.g., to switch","the default 'Math' implementation used: --use Math=JSMath","Can also be used to introduce an integer constant."],type:"S",alias:"u"},lowMemoryLimit:{category:"Features",description:"Enforces very low (<64k) memory constraints.",default:0,type:"i"},memoryBase:{category:"Linking",description:"Sets the start offset of emitted memory segments.",type:"i",default:0},tableBase:{category:"Linking",description:"Sets the start offset of emitted table elements.",type:"i",default:0},transform:{category:"API",description:"Specifies the path to a custom transform to load.",type:"S",isPath:!0,useNodeResolution:!0},trapMode:{category:"Binaryen",description:["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],type:"s",default:"allow"},runPasses:{category:"Binaryen",description:["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],type:"s"},noValidate:{category:"Binaryen",description:"Skips validating the module using Binaryen.",type:"b",default:!1},baseDir:{description:"Specifies the base directory of input and output files.",type:"s",default:"."},noColors:{description:"Disables terminal colors.",type:"b",default:!1},noUnsafe:{description:["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],type:"b",default:!1},disableWarning:{description:["Disables warnings matching the given diagnostic code.","If no diagnostic code is given, all warnings are disabled."],type:"I"},noEmit:{description:"Performs compilation as usual but does not emit code.",type:"b",default:!1},showConfig:{description:"Print computed compiler options and exit.",type:"b",default:!1},stats:{description:"Prints statistics on I/O and compile times.",type:"b",default:!1},pedantic:{description:"Make yourself sad for no good reason.",type:"b",default:!1},lib:{description:["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],type:"S",isPath:!0},path:{description:["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an 'ascMain' entry in a package's","package.json and falls back to an inner 'assembly/' folder."],type:"S",isPath:!0},wasm:{description:"Uses the specified Wasm binary of the compiler.",type:"s"}," ...":{description:"Specifies node.js options (CLI only). See: node --help"},"-Os":{value:{optimizeLevel:0,shrinkLevel:1}},"-Oz":{value:{optimizeLevel:0,shrinkLevel:2}},"-O0":{value:{optimizeLevel:0,shrinkLevel:0}},"-O1":{value:{optimizeLevel:1,shrinkLevel:0}},"-O2":{value:{optimizeLevel:2,shrinkLevel:0}},"-O3":{value:{optimizeLevel:3,shrinkLevel:0}},"-O0s":{value:{optimizeLevel:0,shrinkLevel:1}},"-O1s":{value:{optimizeLevel:1,shrinkLevel:1}},"-O2s":{value:{optimizeLevel:2,shrinkLevel:1}},"-O3s":{value:{optimizeLevel:3,shrinkLevel:1}},"-O0z":{value:{optimizeLevel:0,shrinkLevel:2}},"-O1z":{value:{optimizeLevel:1,shrinkLevel:2}},"-O2z":{value:{optimizeLevel:2,shrinkLevel:2}},"-O3z":{value:{optimizeLevel:3,shrinkLevel:2}},"-Ospeed":{value:{optimizeLevel:3,shrinkLevel:0}},"-Osize":{value:{optimizeLevel:0,shrinkLevel:2,converge:!0}},"--measure":{value:{stats:!0}}},Ae="~lib/",_e={array:`/// <reference path="./rt/index.d.ts" />
|
|
9
9
|
|
|
10
10
|
import { BLOCK_MAXSIZE } from "./rt/common";
|
|
11
11
|
import { Runtime } from "shared/runtime";
|
|
@@ -4724,6 +4724,24 @@ export namespace toildbHost {
|
|
|
4724
4724
|
idemPtr: usize
|
|
4725
4725
|
): i32;
|
|
4726
4726
|
|
|
4727
|
+
// Caller-observed byte CAS: expectedLen=-1 expects absence. 1 applied, 0 mismatch.
|
|
4728
|
+
// @ts-ignore: decorator
|
|
4729
|
+
@external("env", "data.compare_exchange")
|
|
4730
|
+
export declare function compareExchange(
|
|
4731
|
+
handle: u32, keyPtr: usize, keyLen: i32,
|
|
4732
|
+
expectedPtr: usize, expectedLen: i32, valPtr: usize, valLen: i32
|
|
4733
|
+
): i32;
|
|
4734
|
+
|
|
4735
|
+
// @ts-ignore: decorator
|
|
4736
|
+
@external("env", "data.compare_delete")
|
|
4737
|
+
export declare function compareDelete(
|
|
4738
|
+
handle: u32, keyPtr: usize, keyLen: i32, expectedPtr: usize, expectedLen: i32
|
|
4739
|
+
): i32;
|
|
4740
|
+
|
|
4741
|
+
// @ts-ignore: decorator
|
|
4742
|
+
@external("env", "data.get_current")
|
|
4743
|
+
export declare function getCurrent(handle: u32, keyPtr: usize, keyLen: i32): i32;
|
|
4744
|
+
|
|
4727
4745
|
// record.upsert -> 0 created | 1 updated | 2 @unique-conflict (not written) |
|
|
4728
4746
|
// negative error. A single blind last-writer-wins put: creates the row if
|
|
4729
4747
|
// absent, overwrites it if present, in ONE op (no create-then-patch round trip).
|
|
@@ -4794,6 +4812,11 @@ export namespace toildbHost {
|
|
|
4794
4812
|
idemPtr: usize
|
|
4795
4813
|
): i32;
|
|
4796
4814
|
|
|
4815
|
+
// Remove a view key (Action/Derive/Job), idempotently.
|
|
4816
|
+
// @ts-ignore: decorator
|
|
4817
|
+
@external("env", "data.view_delete")
|
|
4818
|
+
export declare function viewDelete(handle: u32, keyPtr: usize, keyLen: i32, idemPtr: usize): i32;
|
|
4819
|
+
|
|
4797
4820
|
// membership.contains -> 1 present | 0 absent | negative error.
|
|
4798
4821
|
// @ts-ignore: decorator
|
|
4799
4822
|
@external("env", "data.membership_contains")
|
|
@@ -4821,6 +4844,13 @@ export namespace toildbHost {
|
|
|
4821
4844
|
@external("env", "data.membership_list")
|
|
4822
4845
|
export declare function membershipList(handle: u32, setPtr: usize, setLen: i32, limit: i32): i32;
|
|
4823
4846
|
|
|
4847
|
+
// Ordered membership page: list frame + optional length-prefixed raw cursor.
|
|
4848
|
+
// @ts-ignore: decorator
|
|
4849
|
+
@external("env", "data.membership_page")
|
|
4850
|
+
export declare function membershipPage(
|
|
4851
|
+
handle: u32, setPtr: usize, setLen: i32, cursorPtr: usize, cursorLen: i32, limit: i32
|
|
4852
|
+
): i32;
|
|
4853
|
+
|
|
4824
4854
|
// capacity.set_total(total: i64) -> 0 ok | negative error (job/derive only).
|
|
4825
4855
|
// @ts-ignore: decorator
|
|
4826
4856
|
@external("env", "data.capacity_set_total")
|
|
@@ -4883,6 +4913,26 @@ export namespace toildbHost {
|
|
|
4883
4913
|
idemPtr: usize
|
|
4884
4914
|
): i32;
|
|
4885
4915
|
|
|
4916
|
+
// Point reads: stashed value length | -2 absent | typed negative error.
|
|
4917
|
+
// result_schema_version exposes the stored event's schema version.
|
|
4918
|
+
// @ts-ignore: decorator
|
|
4919
|
+
@external("env", "data.events_reference")
|
|
4920
|
+
export declare function eventsReference(handle: u32, keyPtr: usize, keyLen: i32, idPtr: usize, idLen: i32): i32;
|
|
4921
|
+
// @ts-ignore: decorator
|
|
4922
|
+
@external("env", "data.events_redact")
|
|
4923
|
+
export declare function eventsRedact(handle: u32, keyPtr: usize, keyLen: i32, sequence: u64, hlc: u64): i32;
|
|
4924
|
+
// @ts-ignore: decorator
|
|
4925
|
+
@external("env", "data.events_entries")
|
|
4926
|
+
export declare function eventsEntries(handle: u32, keyPtr: usize, keyLen: i32, limit: i32, after: u64): i32;
|
|
4927
|
+
|
|
4928
|
+
// @ts-ignore: decorator
|
|
4929
|
+
@external("env", "data.events_get")
|
|
4930
|
+
export declare function eventsGet(handle: u32, keyPtr: usize, keyLen: i32, evidPtr: usize, evidLen: i32): i32;
|
|
4931
|
+
|
|
4932
|
+
// @ts-ignore: decorator
|
|
4933
|
+
@external("env", "data.events_last")
|
|
4934
|
+
export declare function eventsLast(handle: u32, keyPtr: usize, keyLen: i32): i32;
|
|
4935
|
+
|
|
4886
4936
|
// events.latest(limit) -> framed-list length (stashed) | negative error.
|
|
4887
4937
|
// The blob is \`u32 count\` then per event \`u32 schema_version + u32 len + bytes\`,
|
|
4888
4938
|
// newest first.
|
|
@@ -11398,6 +11448,20 @@ function hexVal(c: i32): i32 {
|
|
|
11398
11448
|
if (c >= 0x41 && c <= 0x46) return c - 0x41 + 10;
|
|
11399
11449
|
return -1;
|
|
11400
11450
|
}
|
|
11451
|
+
`,log:`// Structured server logging, available to request, stream, and daemon code.
|
|
11452
|
+
@external("env", "server_log")
|
|
11453
|
+
declare function __serverLog(level: i32, ptr: usize, len: i32): i32;
|
|
11454
|
+
|
|
11455
|
+
@global
|
|
11456
|
+
export class Log {
|
|
11457
|
+
private static write(level: i32, message: string): bool {
|
|
11458
|
+
const bytes = Uint8Array.wrap(String.UTF8.encode(message));
|
|
11459
|
+
return __serverLog(level, bytes.dataStart, bytes.byteLength) == 1;
|
|
11460
|
+
}
|
|
11461
|
+
static info(message: string): bool { return Log.write(0, message); }
|
|
11462
|
+
static warn(message: string): bool { return Log.write(1, message); }
|
|
11463
|
+
static error(message: string): bool { return Log.write(2, message); }
|
|
11464
|
+
}
|
|
11401
11465
|
`,map:`/// <reference path="./rt/index.d.ts" />
|
|
11402
11466
|
|
|
11403
11467
|
import { HASH } from "./util/hash";
|
|
@@ -19393,7 +19457,8 @@ function __toildbMiss(status: i32): void {
|
|
|
19393
19457
|
/// }
|
|
19394
19458
|
/// \`\`\`
|
|
19395
19459
|
///
|
|
19396
|
-
///
|
|
19460
|
+
/// \`Documents.get\`, \`Documents.getDelete\`, \`View.get\`, \`Unique.lookup\`,
|
|
19461
|
+
/// \`Events.get\` and \`Events.last\`
|
|
19397
19462
|
/// record into this. Every other ToilDB op either succeeds or traps. The \`Analytics\`
|
|
19398
19463
|
/// reads also answer \`null\`, but on their own \`-2 absent\` / \`-3 forbidden\` statuses
|
|
19399
19464
|
/// rather than a \`TDLnnn\`, so they leave \`lastError()\` untouched: do not consult it
|
|
@@ -19439,6 +19504,14 @@ export enum UpsertResult {
|
|
|
19439
19504
|
Conflict = 2,
|
|
19440
19505
|
}
|
|
19441
19506
|
|
|
19507
|
+
/// An observed value plus its original storage bytes (before decoding/migration).
|
|
19508
|
+
/// Keep the snapshot unchanged while constructing a replacement value.
|
|
19509
|
+
@global
|
|
19510
|
+
export class DocumentSnapshot<V> {
|
|
19511
|
+
constructor(public value: V, public encoded: Uint8Array) {}
|
|
19512
|
+
}
|
|
19513
|
+
|
|
19514
|
+
@global
|
|
19442
19515
|
export class Documents<K, V> {
|
|
19443
19516
|
private __handle: u32;
|
|
19444
19517
|
|
|
@@ -19465,6 +19538,47 @@ export class Documents<K, V> {
|
|
|
19465
19538
|
return v;
|
|
19466
19539
|
}
|
|
19467
19540
|
|
|
19541
|
+
/// Read without rewrite-on-read. Retains the exact bytes for conditional writes,
|
|
19542
|
+
/// including records whose codec or schema migrated during decoding.
|
|
19543
|
+
getSnapshot(key: K): DocumentSnapshot<V> | null {
|
|
19544
|
+
const kb = key.encode();
|
|
19545
|
+
const status = toildbHost.get(this.__handle, kb.dataStart, kb.byteLength);
|
|
19546
|
+
if (status < 0) { __toildbMiss(status); return null; }
|
|
19547
|
+
const bytes = __toildbTake(status);
|
|
19548
|
+
const value = instantiate<V>();
|
|
19549
|
+
value.decodeInto(bytes);
|
|
19550
|
+
return new DocumentSnapshot<V>(value, bytes);
|
|
19551
|
+
}
|
|
19552
|
+
|
|
19553
|
+
/// Owner-authoritative snapshot, bypassing replica and request caches.
|
|
19554
|
+
getCurrentSnapshot(key: K): DocumentSnapshot<V> | null {
|
|
19555
|
+
const kb = key.encode();
|
|
19556
|
+
const status = toildbHost.getCurrent(this.__handle, kb.dataStart, kb.byteLength);
|
|
19557
|
+
if (status < 0) { __toildbMiss(status); return null; }
|
|
19558
|
+
const bytes = __toildbTake(status);
|
|
19559
|
+
const value = instantiate<V>();
|
|
19560
|
+
value.decodeInto(bytes);
|
|
19561
|
+
return new DocumentSnapshot<V>(value, bytes);
|
|
19562
|
+
}
|
|
19563
|
+
|
|
19564
|
+
compareExchangeSnapshot(key: K, expected: DocumentSnapshot<V> | null, value: V): bool {
|
|
19565
|
+
const kb = key.encode();
|
|
19566
|
+
const vb = value.encode();
|
|
19567
|
+
const eb = expected == null ? new Uint8Array(0) : expected.encoded;
|
|
19568
|
+
const status = toildbHost.compareExchange(this.__handle, kb.dataStart, kb.byteLength,
|
|
19569
|
+
eb.dataStart, expected == null ? -1 : eb.byteLength, vb.dataStart, vb.byteLength);
|
|
19570
|
+
if (status < 0) abort("ToilDB compareExchange failed: status " + status.toString(), "toildb", 0, 0);
|
|
19571
|
+
return status == 1;
|
|
19572
|
+
}
|
|
19573
|
+
|
|
19574
|
+
compareDeleteSnapshot(key: K, expected: DocumentSnapshot<V>): bool {
|
|
19575
|
+
const kb = key.encode();
|
|
19576
|
+
const eb = expected.encoded;
|
|
19577
|
+
const status = toildbHost.compareDelete(this.__handle, kb.dataStart, kb.byteLength, eb.dataStart, eb.byteLength);
|
|
19578
|
+
if (status < 0) abort("ToilDB compareDelete failed: status " + status.toString(), "toildb", 0, 0);
|
|
19579
|
+
return status == 1;
|
|
19580
|
+
}
|
|
19581
|
+
|
|
19468
19582
|
/// Like \`get\`, but traps if the record is absent.
|
|
19469
19583
|
require(key: K): V {
|
|
19470
19584
|
const v = this.get(key);
|
|
@@ -19482,7 +19596,13 @@ export class Documents<K, V> {
|
|
|
19482
19596
|
}
|
|
19483
19597
|
const blob = w.toBytes();
|
|
19484
19598
|
const status = toildbHost.getMany(this.__handle, blob.dataStart, blob.byteLength);
|
|
19485
|
-
if (status < 0)
|
|
19599
|
+
if (status < 0) {
|
|
19600
|
+
__toildbMiss(status);
|
|
19601
|
+
abort("ToilDB getMany failed: status " + status.toString() +
|
|
19602
|
+
"; DbError=" + (<i32>Db.lastError()).toString() +
|
|
19603
|
+
"; keys=" + keys.length.toString() +
|
|
19604
|
+
". Query accepts 32 keys, Action 64, background 1024; split larger batches.", "toildb", 0, 0);
|
|
19605
|
+
}
|
|
19486
19606
|
const out = __toildbTake(status);
|
|
19487
19607
|
const results = new Array<V | null>();
|
|
19488
19608
|
let off: i32 = 0;
|
|
@@ -19532,8 +19652,9 @@ export class Documents<K, V> {
|
|
|
19532
19652
|
/// conflict or retry - the later one wins and overwrites the earlier. Correct
|
|
19533
19653
|
/// for writing a whole value (a profile, a settings blob); wrong for a
|
|
19534
19654
|
/// read-modify-write of accumulating state (a balance, a like count), where a
|
|
19535
|
-
/// concurrent write would be lost - use \`counter.add\` or
|
|
19536
|
-
///
|
|
19655
|
+
/// concurrent write would be lost - use \`counter.add\` or a caller-observed
|
|
19656
|
+
/// conditional write there. A lost write is a data-integrity concern, not a
|
|
19657
|
+
/// boundary one:
|
|
19537
19658
|
/// the key is tenant-scoped, so a race is only ever one tenant's own concurrent
|
|
19538
19659
|
/// writes, and \`@unique\` stays race-safe (claim-once at the value's home).
|
|
19539
19660
|
upsert(key: K, value: V): UpsertResult {
|
|
@@ -19559,19 +19680,40 @@ export class Documents<K, V> {
|
|
|
19559
19680
|
return v;
|
|
19560
19681
|
}
|
|
19561
19682
|
|
|
19562
|
-
///
|
|
19563
|
-
///
|
|
19564
|
-
|
|
19683
|
+
/// Replace only if the stored bytes equal \`expected\`; null expects absence.
|
|
19684
|
+
/// Returns false on a mismatch. Routed to the owner; @unique values are rejected.
|
|
19685
|
+
compareExchange(key: K, expected: V | null, value: V): bool {
|
|
19686
|
+
const kb = key.encode();
|
|
19687
|
+
const vb = value.encode();
|
|
19688
|
+
const eb = expected == null ? new Uint8Array(0) : expected.encode();
|
|
19689
|
+
const status = toildbHost.compareExchange(
|
|
19690
|
+
this.__handle, kb.dataStart, kb.byteLength,
|
|
19691
|
+
eb.dataStart, expected == null ? -1 : eb.byteLength,
|
|
19692
|
+
vb.dataStart, vb.byteLength
|
|
19693
|
+
);
|
|
19694
|
+
if (status < 0) abort("ToilDB compareExchange failed: status " + status.toString(), "toildb", 0, 0);
|
|
19695
|
+
return status == 1;
|
|
19696
|
+
}
|
|
19697
|
+
|
|
19698
|
+
/// Submit a replacement of an EXISTING record: true when accepted, false on
|
|
19699
|
+
/// absence or rejection. The ABI carries no caller-observed version or value,
|
|
19700
|
+
/// so this cannot protect a read-modify-write based on an earlier application read.
|
|
19565
19701
|
enqueue(key: K, value: V): bool {
|
|
19566
19702
|
const kb = key.encode();
|
|
19567
19703
|
const vb = value.encode();
|
|
19568
19704
|
return toildbHost.enqueue(this.__handle, kb.dataStart, kb.byteLength, vb.dataStart, vb.byteLength, 0) == 0;
|
|
19569
19705
|
}
|
|
19570
19706
|
|
|
19707
|
+
/// Delete only when the stored bytes still equal the caller's expectation.
|
|
19708
|
+
compareDelete(key: K, expected: V): bool {
|
|
19709
|
+
return this.compareDeleteSnapshot(key, new DocumentSnapshot<V>(expected, expected.encode()));
|
|
19710
|
+
}
|
|
19711
|
+
|
|
19571
19712
|
/// Delete the record (idempotent).
|
|
19572
19713
|
delete(key: K): void {
|
|
19573
19714
|
const kb = key.encode();
|
|
19574
|
-
toildbHost.del(this.__handle, kb.dataStart, kb.byteLength, 0);
|
|
19715
|
+
const status = toildbHost.del(this.__handle, kb.dataStart, kb.byteLength, 0);
|
|
19716
|
+
if (status < 0) abort("ToilDB delete failed: status " + status.toString(), "toildb", 0, 0);
|
|
19575
19717
|
}
|
|
19576
19718
|
|
|
19577
19719
|
/// Atomic fetch-and-delete (consume-once); returns the prior value or \`null\`.
|
|
@@ -19614,14 +19756,22 @@ export class View<K, V> {
|
|
|
19614
19756
|
return v!;
|
|
19615
19757
|
}
|
|
19616
19758
|
|
|
19759
|
+
/// Remove a projection key. Delete its source personal data before rebuilding.
|
|
19760
|
+
delete(key: K): void {
|
|
19761
|
+
const kb = key.encode();
|
|
19762
|
+
const status = toildbHost.viewDelete(this.__handle, kb.dataStart, kb.byteLength, 0);
|
|
19763
|
+
if (status < 0) abort("ToilDB view.delete failed: status " + status.toString(), "toildb", 0, 0);
|
|
19764
|
+
}
|
|
19765
|
+
|
|
19617
19766
|
/// Publish (overwrite) the view for \`key\`. Derive/job only; the host assigns
|
|
19618
19767
|
/// the version so a later publish always supersedes an earlier one.
|
|
19619
19768
|
publish(key: K, value: V): void {
|
|
19620
19769
|
const kb = key.encode();
|
|
19621
19770
|
const vb = value.encode();
|
|
19622
|
-
toildbHost.viewPublish(
|
|
19771
|
+
const status = toildbHost.viewPublish(
|
|
19623
19772
|
this.__handle, kb.dataStart, kb.byteLength, vb.dataStart, vb.byteLength, 0
|
|
19624
19773
|
);
|
|
19774
|
+
if (status < 0) abort("ToilDB view.publish failed: status " + status.toString(), "toildb", 0, 0);
|
|
19625
19775
|
}
|
|
19626
19776
|
}
|
|
19627
19777
|
|
|
@@ -19653,6 +19803,12 @@ export class Unique<K, V> {
|
|
|
19653
19803
|
return v;
|
|
19654
19804
|
}
|
|
19655
19805
|
|
|
19806
|
+
/// Bounded owner lookup in input order, with null for each unclaimed key.
|
|
19807
|
+
/// Uses one read operation; the host enforces the per-request batch limit.
|
|
19808
|
+
lookupMany(keys: K[]): Array<V | null> {
|
|
19809
|
+
return new Documents<K, V>(this.__handle).getMany(keys);
|
|
19810
|
+
}
|
|
19811
|
+
|
|
19656
19812
|
/// Claim \`key\` for \`value\`. Returns whether the caller owns it, and (when
|
|
19657
19813
|
/// another owns it) who.
|
|
19658
19814
|
claim(key: K, value: V): ClaimResult<V> {
|
|
@@ -19682,6 +19838,17 @@ export class Unique<K, V> {
|
|
|
19682
19838
|
}
|
|
19683
19839
|
}
|
|
19684
19840
|
|
|
19841
|
+
/// A page in encoded-member order; pass cursor to listPage to continue.
|
|
19842
|
+
@global
|
|
19843
|
+
export class MembershipPage<M> {
|
|
19844
|
+
members: M[];
|
|
19845
|
+
cursor: Uint8Array | null;
|
|
19846
|
+
constructor(members: M[], cursor: Uint8Array | null) {
|
|
19847
|
+
this.members = members;
|
|
19848
|
+
this.cursor = cursor;
|
|
19849
|
+
}
|
|
19850
|
+
}
|
|
19851
|
+
|
|
19685
19852
|
/// An unordered set (spec 7.3): followers, tags, ACLs, room members. \`M\` is the
|
|
19686
19853
|
/// \`@data\` member type, \`K\` the \`@data\` set-key type.
|
|
19687
19854
|
@global
|
|
@@ -19719,6 +19886,36 @@ export class Membership<K, M> {
|
|
|
19719
19886
|
);
|
|
19720
19887
|
}
|
|
19721
19888
|
|
|
19889
|
+
/// Read members strictly after an opaque cursor. A full page may require an
|
|
19890
|
+
/// empty final page to establish the end. Pagination is not a snapshot.
|
|
19891
|
+
listPage(key: K, limit: i32, cursor: Uint8Array | null = null): MembershipPage<M> {
|
|
19892
|
+
const kb = key.encode();
|
|
19893
|
+
const cb = cursor == null ? new Uint8Array(0) : cursor;
|
|
19894
|
+
const status = toildbHost.membershipPage(
|
|
19895
|
+
this.__handle, kb.dataStart, kb.byteLength, cb.dataStart,
|
|
19896
|
+
cursor == null ? -1 : cb.byteLength, limit
|
|
19897
|
+
);
|
|
19898
|
+
if (status < 0) abort("ToilDB membership.listPage failed: status " + status.toString(), "toildb", 0, 0);
|
|
19899
|
+
const blob = __toildbTake(status);
|
|
19900
|
+
const out = new Array<M>();
|
|
19901
|
+
let off: i32 = 4;
|
|
19902
|
+
const count = load<u32>(blob.dataStart);
|
|
19903
|
+
for (let i: u32 = 0; i < count; i++) {
|
|
19904
|
+
const version = <i64>load<u32>(blob.dataStart + off); off += 4;
|
|
19905
|
+
const len = <i32>load<u32>(blob.dataStart + off); off += 4;
|
|
19906
|
+
const member = instantiate<M>();
|
|
19907
|
+
member.decodeIntoVersioned(blob.subarray(off, off + len), version);
|
|
19908
|
+
out.push(member); off += len;
|
|
19909
|
+
}
|
|
19910
|
+
const hasCursor = load<u8>(blob.dataStart + off); off++;
|
|
19911
|
+
let next: Uint8Array | null = null;
|
|
19912
|
+
if (hasCursor != 0) {
|
|
19913
|
+
const len = <i32>load<u32>(blob.dataStart + off); off += 4;
|
|
19914
|
+
next = blob.slice(off, off + len);
|
|
19915
|
+
}
|
|
19916
|
+
return new MembershipPage<M>(out, next);
|
|
19917
|
+
}
|
|
19918
|
+
|
|
19722
19919
|
/// Up to \`limit\` members of the set. Decodes each framed member into an \`M\`.
|
|
19723
19920
|
list(key: K, limit: i32): M[] {
|
|
19724
19921
|
const kb = key.encode();
|
|
@@ -20143,6 +20340,21 @@ export class Analytics {
|
|
|
20143
20340
|
/// An append-only event log (spec 7.5): activity feeds, audit trails, the
|
|
20144
20341
|
/// fact stream a \`@derive\` consumes. \`V\` is the \`@data\` event type, \`K\` the
|
|
20145
20342
|
/// \`@data\` stream-key type.
|
|
20343
|
+
@global
|
|
20344
|
+
export class EventRef {
|
|
20345
|
+
constructor(public sequence: u64 = 0, public hlc: u64 = 0) {}
|
|
20346
|
+
}
|
|
20347
|
+
|
|
20348
|
+
@global
|
|
20349
|
+
export class EventEntry<V> {
|
|
20350
|
+
constructor(public reference: EventRef, public value: V) {}
|
|
20351
|
+
}
|
|
20352
|
+
|
|
20353
|
+
@global
|
|
20354
|
+
export class EventPage<V> {
|
|
20355
|
+
constructor(public entries: Array<EventEntry<V>>, public cursor: u64, public hasMore: bool) {}
|
|
20356
|
+
}
|
|
20357
|
+
|
|
20146
20358
|
@global
|
|
20147
20359
|
export class Events<K, V> {
|
|
20148
20360
|
private __handle: u32;
|
|
@@ -20151,6 +20363,70 @@ export class Events<K, V> {
|
|
|
20151
20363
|
this.__handle = handle;
|
|
20152
20364
|
}
|
|
20153
20365
|
|
|
20366
|
+
/// Read an appendOnce reference, including during pending cleanup. No payload is returned.
|
|
20367
|
+
reference(key: K, eventId: string): EventRef | null {
|
|
20368
|
+
const kb = key.encode();
|
|
20369
|
+
const id = Uint8Array.wrap(String.UTF8.encode(eventId));
|
|
20370
|
+
const status = toildbHost.eventsReference(this.__handle, kb.dataStart, kb.byteLength, id.dataStart, id.byteLength);
|
|
20371
|
+
if (status < 0) { __toildbMiss(status); return null; }
|
|
20372
|
+
const reader = new DataReader(__toildbTake(status));
|
|
20373
|
+
const reference = new EventRef(reader.readU64(), reader.readU64());
|
|
20374
|
+
if (!reader.ok) abort("Invalid event reference", "toildb", 0, 0);
|
|
20375
|
+
return reference;
|
|
20376
|
+
}
|
|
20377
|
+
|
|
20378
|
+
/// Erase this entry and one bounded page of recovery copies. Repeat in later
|
|
20379
|
+
/// background calls until true. The payload is hidden from the first successful call.
|
|
20380
|
+
redact(key: K, reference: EventRef): bool {
|
|
20381
|
+
const kb = key.encode();
|
|
20382
|
+
const status = toildbHost.eventsRedact(this.__handle, kb.dataStart, kb.byteLength, reference.sequence, reference.hlc);
|
|
20383
|
+
if (status < 0) abort("ToilDB events.redact failed: status " + status.toString(), "toildb", 0, 0);
|
|
20384
|
+
return status == 1;
|
|
20385
|
+
}
|
|
20386
|
+
|
|
20387
|
+
/// Bounded, oldest-first page with references for ordinary and appendOnce events.
|
|
20388
|
+
/// Keep the opaque cursor and use hasMore even if an erased page is empty.
|
|
20389
|
+
entries(key: K, limit: i32 = 128, after: u64 = 0): EventPage<V> {
|
|
20390
|
+
const kb = key.encode();
|
|
20391
|
+
const status = toildbHost.eventsEntries(this.__handle, kb.dataStart, kb.byteLength, limit, after);
|
|
20392
|
+
if (status < 0) abort("ToilDB events.entries failed: status " + status.toString(), "toildb", 0, 0);
|
|
20393
|
+
const reader = new DataReader(__toildbTake(status));
|
|
20394
|
+
const count = reader.readU32();
|
|
20395
|
+
const entries = new Array<EventEntry<V>>();
|
|
20396
|
+
for (let i: u32 = 0; i < count; i++) {
|
|
20397
|
+
const reference = new EventRef(reader.readU64(), reader.readU64());
|
|
20398
|
+
const version = <i64>reader.readU32();
|
|
20399
|
+
const bytes = reader.readBytes();
|
|
20400
|
+
const value = instantiate<V>(); value.decodeIntoVersioned(bytes, version);
|
|
20401
|
+
entries.push(new EventEntry<V>(reference, value));
|
|
20402
|
+
}
|
|
20403
|
+
const hasMore = reader.readU8() != 0;
|
|
20404
|
+
const cursor: u64 = hasMore ? reader.readU64() : 0;
|
|
20405
|
+
if (!reader.ok) abort("Invalid event page", "toildb", 0, 0);
|
|
20406
|
+
return new EventPage<V>(entries, cursor, hasMore);
|
|
20407
|
+
}
|
|
20408
|
+
|
|
20409
|
+
/// Read an event by its appendOnce eventId, or null if absent. Bounded request-path read.
|
|
20410
|
+
get(key: K, eventId: string): V | null {
|
|
20411
|
+
const kb = key.encode();
|
|
20412
|
+
const idb = Uint8Array.wrap(String.UTF8.encode(eventId));
|
|
20413
|
+
const status = toildbHost.eventsGet(this.__handle, kb.dataStart, kb.byteLength, idb.dataStart, idb.byteLength);
|
|
20414
|
+
if (status < 0) { __toildbMiss(status); return null; }
|
|
20415
|
+
const v = instantiate<V>();
|
|
20416
|
+
v.decodeInto(__toildbTake(status));
|
|
20417
|
+
return v;
|
|
20418
|
+
}
|
|
20419
|
+
|
|
20420
|
+
/// Read the newest appended event, or null for an empty stream. Does not scan.
|
|
20421
|
+
last(key: K): V | null {
|
|
20422
|
+
const kb = key.encode();
|
|
20423
|
+
const status = toildbHost.eventsLast(this.__handle, kb.dataStart, kb.byteLength);
|
|
20424
|
+
if (status < 0) { __toildbMiss(status); return null; }
|
|
20425
|
+
const v = instantiate<V>();
|
|
20426
|
+
v.decodeInto(__toildbTake(status));
|
|
20427
|
+
return v;
|
|
20428
|
+
}
|
|
20429
|
+
|
|
20154
20430
|
/// Append an event to the stream.
|
|
20155
20431
|
append(key: K, event: V): void {
|
|
20156
20432
|
const kb = key.encode();
|
|
@@ -31297,5 +31573,5 @@ declare function offsetof<T>(fieldName?: string): usize;
|
|
|
31297
31573
|
declare function idof<T>(): u32;
|
|
31298
31574
|
`};var xn={};nn(xn,{default:()=>gn});In(xn,Vt);import*as Vt from"binaryen";import{default as gn}from"binaryen";import*as Tt from"toilscript";var p=Tt,Vn=P.argv.indexOf("--wasm");if(~Vn){let e=String(P.argv[Vn+1]);P.argv.splice(Vn,2),p=await import(new URL(e,pn.pathToFileURL(P.cwd()+"/")))}var Hn=sn.createRequire(import.meta.url),qn=P.platform==="win32",T=qn?`\r
|
|
31299
31575
|
`:`
|
|
31300
|
-
`,Gn=qn?"\\":"/",_=".ts",Ct=`.d${_}`,ln=new RegExp("\\"+_+"$"),zt=new RegExp("^(?!.*\\.d\\"+_+"$).*\\"+_+"$");function Ce(e){return e.replace(/-/g,"_").toUpperCase()}function St(e){return typeof e=="string"&&e!==""}var Kn=Ee,wt=Y,V=Ae,j=_e,Bt=Te,we=3,Be=0;function Wn(e,t=[]){return Object.keys(e||{}).forEach(n=>{let a=e[n],s=Y[n];s&&s.type==="b"?a&&t.push(`--${n}`):Array.isArray(a)?a.forEach(o=>{t.push(`--${n}`,String(o))}):t.push(`--${n}`,String(a))}),t}async function Dt(e,t={}){typeof e=="string"&&(e={[`input${_}`]:e});let n=["--outFile","binary","--textFile","text"];Wn(t,n);let a={},s=await De(n.concat(Object.keys(e)),{readFile:o=>Object.prototype.hasOwnProperty.call(e,o)?e[o]:null,writeFile:(o,c)=>{a[o]=c},listFiles:()=>[]});return Object.assign(s,a)}async function De(e,t){Array.isArray(e)||(e=Wn(e)),t||(t={});let n=t.stats||new zn,a=n.begin(),s=0,o=0,c=0,d=(Kn||"").split(".");d.length===3&&(o=parseInt(d[0])|0,s=parseInt(d[1])|0,c=parseInt(d[2])|0);let x=t.stdout||Xn(),b=t.stderr||Xn(),h=t.readFile||te,g=t.writeFile||ie,y=t.listFiles||re,m=ve(e,Y,!1),i=m.options;e=m.arguments;let Sn=new en(x),G=new en(b);i.noColors&&(Sn.enabled=!1,G.enabled=!1);let Jn=m.unknown;Jn.length&&Jn.forEach(r=>{b.write(`${G.yellow("WARNING ")}Unknown option '${r}'${T}`)});let Zn=m.trailing;Zn.length&&b.write(`${G.yellow("WARNING ")}Unsupported trailing arguments: ${Zn.join(" ")}${T}`);let K=null,R=null,z=(r,l={})=>(r&&b.write(`${G.red("FAILURE ")}${r.stack.replace(/^ERROR: /i,"")}${T}`),R&&R.dispose(),n.total||(n.total=n.end(a)),Object.assign({error:r,stdout:x,stderr:b,stats:n},l));if(i.version)return x.write(`Version ${Kn}${T}`),z(null);let S=E.normalize(i.baseDir||"."),X=tn(i.config||"toilconfig.json",S),wn=E.basename(X),J=E.dirname(X),N=await ze(wn,J,h),Ie=N!=null&&Array.isArray(N.entries)&&N.entries.length;if(i.help||!e.length&&!Ie){let r=i.help?x:b,l=i.help?Sn:G;return r.write([l.white("SYNTAX")," "+l.cyan("toilscript")+" [entryFile ...] [options]","",l.white("EXAMPLES")," "+l.cyan("toilscript")+" hello"+_," "+l.cyan("toilscript")+" hello"+_+" -o hello.wasm -t hello.wat"," "+l.cyan("toilscript")+" hello1"+_+" hello2"+_+" -o -O > hello.wasm"," "+l.cyan("toilscript")+" --config toilconfig.json --target release","",l.white("OPTIONS")].concat(Fe(Y,24,T)).join(T)+T),z(null)}if(!(M.promises&&M.promises.readFile)){if(h===te)throw Error("'options.readFile' must be specified");if(g===ie)throw Error("'options.writeFile' must be specified");if(y===re)throw Error("'options.listFiles' must be specified")}let Bn=new Set;Bn.add(X);let Le=!!i.noConfigEntries,ke=i.target||"release";for(;N;){if(N.targets){let l=N.targets[ke];l&&(i=Mn(Y,i,l,J))}let r=N.options;if(r&&(i=Mn(Y,i,r,J)),N.entries&&!Le)for(let l of N.entries)e.push(tn(l,J));if(N.extends){if(X=tn(N.extends,J,!0),wn=E.basename(X),J=E.dirname(X),Bn.has(X))break;Bn.add(X),N=await ze(wn,J,h)}else break}if(Pn(Y,i),i.showConfig)return b.write(JSON.stringify({options:i,entries:e},null,2)),z(null);function $n(r){return[...new Set(r)]}let w,rn,bn,C=p.newOptions();switch(i.runtime){case"stub":rn=0;break;case"minimal":rn=1;break;case"memory":rn=3;break;default:rn=2;break}switch(i.uncheckedBehavior){default:bn=0;break;case"never":bn=1;break;case"always":bn=2;break}let un=null;if(i.targetMode!=null&&String(i.targetMode).length>0&&(un=String(i.targetMode),un!=="hot"&&un!=="cold"))return z(Error(`Target mode '${un}' is invalid; expected 'hot' or 'cold'.`));if(p.setTargetMode(C,un),p.setAuthUser(C,!!i.authUser),p.setTarget(C,0),p.setDebugInfo(C,!!i.debug),p.setRuntime(C,rn),p.setNoAssert(C,i.noAssert),p.setExportMemory(C,!i.noExportMemory),p.setImportMemory(C,i.importMemory),p.setInitialMemory(C,i.initialMemory>>>0),p.setMaximumMemory(C,i.maximumMemory>>>0),p.setSharedMemory(C,i.sharedMemory),p.setImportTable(C,i.importTable),p.setExportTable(C,i.exportTable),i.exportStart!=null&&p.setExportStart(C,St(i.exportStart)?i.exportStart:"_start"),p.setMemoryBase(C,i.memoryBase>>>0),p.setTableBase(C,i.tableBase>>>0),p.setSourceMap(C,i.sourceMap!=null),p.setUncheckedBehavior(C,bn),p.setNoUnsafe(C,i.noUnsafe),p.setPedantic(C,i.pedantic),p.setLowMemoryLimit(C,i.lowMemoryLimit>>>0),p.setExportRuntime(C,i.exportRuntime),p.setBundleVersion(C,o,s,c),!i.stackSize&&rn===2&&(i.stackSize=p.DEFAULT_STACK_SIZE),p.setStackSize(C,i.stackSize),p.setBindingsHint(C,i.bindings&&i.bindings.length>0),i.use){let r=i.use;for(let l=0,f=r.length;l<f;++l){let u=r[l],v=u.indexOf("=");if(v<0)return z(Error(`Global alias '${u}' is invalid.`));let F=u.substring(0,v).trim(),A=u.substring(v+1).trim();if(!F.length)return z(Error(`Global alias '${u}' is invalid.`));p.addGlobalAlias(C,F,A)}}let U;if((U=i.disable)!=null){typeof U=="string"&&(U=U.split(","));for(let r=0,l=U.length;r<l;++r){let f=U[r].trim(),u=p[`FEATURE_${Ce(f)}`];if(!u)return z(Error(`Feature '${f}' is unknown.`));p.setFeature(C,u,!1)}}if((U=i.enable)!=null){typeof U=="string"&&(U=U.split(","));for(let r=0,l=U.length;r<l;++r){let f=U[r].trim(),u=p[`FEATURE_${Ce(f)}`];if(!u)return z(Error(`Feature '${f}' is unknown.`));p.setFeature(C,u,!0)}}let Z=0,$=0;i.optimize&&(Z=we,$=Be),typeof i.optimizeLevel=="number"&&(Z=i.optimizeLevel),typeof i.shrinkLevel=="number"&&($=i.shrinkLevel),Z=Math.min(Math.max(Z,0),3),$=Math.min(Math.max($,0),2),p.setOptimizeLevelHints(C,Z,$),w=p.newProgram(C);let an=[];if(Array.isArray(t.transforms)&&an.push(...t.transforms),i.transform){let r=$n(i.transform);for(let l=0,f=r.length;l<f;++l){let u=r[l].trim(),v,F;if(Hn.resolve)try{v=Hn.resolve(u,{paths:[P.cwd(),S]}),F=await import(pn.pathToFileURL(v)),F.default&&(F=F.default)}catch(A){try{F=Hn(v)}catch{return z(A)}}else try{F=await import(new URL(u,import.meta.url)),F.default&&(F=F.default)}catch(A){return z(A)}if(!F||typeof F!="function"&&typeof F!="object")return z(Error("not a transform: "+r[l]));an.push(F)}}try{an=an.map(r=>(typeof r=="function"&&(Object.assign(r.prototype,{program:w,binaryen:gn,baseDir:S,stdout:x,stderr:b,log:console.error,readFile:h,writeFile:g,listFiles:y}),r=new r),r))}catch(r){return z(r)}async function Dn(r,...l){for(let f=0,u=an.length;f<u;++f){let v=an[f];if(typeof v[r]=="function")try{let F=n.begin();n.transformCount++,await v[r](...l),n.transformTime+=n.end(F)}catch(F){return F}}}Object.keys(j).forEach(r=>{if(r.includes("/"))return;let l=n.begin();n.parseCount++,p.parse(w,j[r],V+r+_,!1),n.parseTime+=n.end(l)});let on=[];if(i.lib){let r=i.lib;typeof r=="string"&&(r=r.split(",")),on.push(...r.map(l=>l.trim())),on=$n(on);for(let l=0,f=on.length;l<f;++l){let u=on[l],v;u.endsWith(_)?(v=[E.basename(u)],u=E.dirname(u)):v=await y(u,S)||[];for(let F of v){let A=await h(F,u);if(A==null)return z(Error(`Library file '${F}' not found.`));j[F.replace(ln,"")]=A;let L=n.begin();n.parseCount++,p.parse(w,A,V+F,!1),n.parseTime+=n.end(L)}}}i.path=i.path||[];let yn=new Map;async function Oe(r,l){let f=null,u=null;if(!r.startsWith(V))(f=await h(u=r+_,S))==null&&(f=await h(u=r+"/index"+_,S))==null&&(u=r+_,f=await h(r+Ct,S));else{let v=r.substring(V.length),F=`${v}/index`;if(Object.prototype.hasOwnProperty.call(j,v))f=j[v],u=V+v+_;else if(Object.prototype.hasOwnProperty.call(j,F))f=j[F],u=V+F+_;else{for(let A of on)if((f=await h(v+_,A))!=null){u=V+v+_;break}else if((f=await h(F+_,A))!=null){u=V+F+_;break}if(f==null){let A=r.match(/^~lib\/((?:@[^/]+\/)?[^/]+)(?:\/(.+))?/);if(A){let L=A[1],q=A[2]||"index",En=yn.has(l)?yn.get(l):".",k=[],D=E.resolve(S,En).split(Gn);for(let B=D.length,O=qn?1:0;B>=O;--B)D[B-1]!=="node_modules"&&k.push(`${D.slice(0,B).join(Gn)}${Gn}node_modules`);k.push(...i.path);for(let B of k.map(O=>E.relative(S,O))){let O=q;if((f=await h(E.join(B,L,O+_),S))!=null){u=`${V}${L}/${O}${_}`,yn.set(u.replace(ln,""),E.join(B,L));break}let cn=`${q}/index`;if((f=await h(E.join(B,L,cn+_),S))!=null){u=`${V}${L}/${cn}${_}`,yn.set(u.replace(ln,""),E.join(B,L));break}}}}}}return f==null?null:{sourceText:f,sourcePath:u}}function Re(r=[]){do{let l=p.nextFile(w);if(l==null)break;r.push(l)}while(!0);return r}async function Qn(){let r;for(;(r=Re()).length;){let f=[];for(let u of r){let v=p.getDependee(w,u);f.push(Oe(u,v))}f=await Promise.all(f);for(let u=0,v=r.length;u<v;++u){let F=r[u],A=f[u],L=n.begin();n.parseCount++,A?p.parse(w,A.sourceText,A.sourcePath,!1):p.parse(w,null,F+_,!1),n.parseTime+=n.end(L)}}let l=mn(w,b,i.disableWarning,t.reportDiagnostic,G.enabled);if(l){let f=Error(`${l} parse error(s)`);return f.stack=f.message,z(f)}}{let r=String(i.runtime),l=`rt/index-${r}`,f=j[l];if(f==null){if(l=r,f=await h(l+_,S),f==null)return z(Error(`Runtime '${E.resolve(S,l+_)}' is not found.`))}else l=`~lib/${l}`;let u=n.begin();n.parseCount++,p.parse(w,f,l+_,!0),n.parseTime+=n.end(u)}for(let r=0,l=e.length;r<l;++r){let f=String(e[r]),u=E.isAbsolute(f)?E.relative(S,f):E.normalize(f);u=u.replace(/\\/g,"/").replace(ln,"").replace(/\/$/,"");let v=await h(u+_,S);if(v==null){let A=`${u}/index${_}`;v=await h(A,S),v!=null?u=A:u+=_}else u+=_;let F=n.begin();n.parseCount++,p.parse(w,v,u,!0),n.parseTime+=n.end(F)}if(i.rpcSurfaceFiles!=null&&i.rpcSurfaceFiles.length)for(let r=0,l=i.rpcSurfaceFiles.length;r<l;++r){let f=String(i.rpcSurfaceFiles[r]),u=E.isAbsolute(f)?E.relative(S,f):E.normalize(f);u=u.replace(/\\/g,"/").replace(ln,"").replace(/\/$/,"");let v=await h(u+_,S);if(v==null){let F=`${u}/index${_}`;v=await h(F,S),v!=null?u=F:u+=_}else u+=_;v!=null?(n.parseCount++,p.parse(w,v,u,!1)):p.parse(w,null,u,!1)}if(M.promises&&M.promises.readdir){let r=[],l=async(f,u)=>{let v;try{v=await M.promises.readdir(f,{withFileTypes:!0})}catch{return}for(let F of v){let A=F.name;if(F.isDirectory()){if(A==="node_modules"||A==="build"||A==="dist"||A.charAt(0)===".")continue;await l(E.join(f,A),u?u+"/"+A:A)}else A.endsWith(".migration"+_)&&r.push(u?u+"/"+A:A)}};await l(E.resolve(S),"");for(let f of r){let u=f.replace(/\\/g,"/"),v=await h(u,S);v!=null&&(n.parseCount++,p.parse(w,v,u,!1))}}{let r=await Qn();if(r)return r}{let r=await Dn("afterParse",w.parser);if(r)return z(r)}{let r=await Qn();if(r)return r}{let r=n.begin();n.initializeCount++;try{p.initializeProgram(w)}catch(l){I("initialize",l)}n.initializeTime+=n.end(r)}{let r=await Dn("afterInitialize",w);if(r)return z(r)}{let r=n.begin();n.compileCount++;try{K=p.compile(w)}catch(l){let f=mn(w,b,i.disableWarning,t.reportDiagnostic,G.enabled);if(f){let u=Error(`${f} compile error(s)`);return u.stack=u.message,z(u)}I("compile",l)}n.compileTime+=n.end(r)}R=gn.wrapModule(typeof K=="number"||K instanceof Number?p.getBinaryenModuleRef(K):K.ref);let fn=mn(w,b,i.disableWarning,t.reportDiagnostic,G.enabled);if(fn){let r=Error(`${fn} compile error(s)`);return r.stack=r.message,z(r)}{let r=await Dn("afterCompile",R);if(r)return z(r)}if(fn=mn(w,b,i.disableWarning,t.reportDiagnostic,G.enabled),fn){let r=Error(`${fn} afterCompile error(s)`);return r.stack=r.message,z(r)}if(!i.noValidate){let r=n.begin();n.validateCount++;let l=p.validate(K);if(n.validateTime+=n.end(r),!l)return z(Error("validate error"))}if(i.trapMode==="clamp"||i.trapMode==="js"){let r=n.begin();try{R.runPasses([`trap-mode-${i.trapMode}`])}catch(l){I("runPasses",l)}n.compileTime+=n.end(r)}else if(i.trapMode!=="allow")return z(Error("Unsupported trap mode"));let ne=i.debug,Ne=i.converge,ee=i.importMemory?i.zeroFilledMemory:!1,vn=[];i.runPasses&&(typeof i.runPasses=="string"&&(i.runPasses=i.runPasses.split(",")),i.runPasses.length&&i.runPasses.forEach(r=>{vn.includes(r=r.trim())||vn.push(r)}));{let r=n.begin();try{n.optimizeCount++,p.optimize(K,Z,$,ne,ee)}catch(l){I("optimize",l)}try{R.runPasses(vn)}catch(l){I("runPasses",l)}if(Ne){let l;try{let f=n.begin();n.emitCount++,l=R.emitBinary(),n.emitTime+=n.end(f)}catch(f){I("emitBinary (converge)",f)}do{try{n.optimizeCount++,p.optimize(K,Z,$,ne,ee)}catch(u){I("optimize (converge)",u)}try{R.runPasses(vn)}catch(u){I("runPasses (converge)",u)}let f;try{let u=n.begin();n.emitCount++,f=R.emitBinary(),n.emitTime+=n.end(u)}catch(u){I("emitBinary (converge)",u)}if(f.length>=l.length){f.length>l.length&&b.write(`Last converge was suboptimal.${T}`);break}l=f}while(!0)}n.optimizeTime+=n.end(r)}let Q=[];if(!i.noEmit){if(i.binaryFile)return z(Error("Usage of the --binaryFile compiler option is no longer supported. Use --outFile instead."));let r=i.bindings||[],l=!1,f=i.outFile!=null,u=i.textFile!=null,v=f||u,F=f&&i.outFile.length>0||u&&i.textFile.length>0,A=F?(i.outFile||i.textFile).replace(/\.\w+$/,""):null,L=F?E.basename(A):"output";if(p.setBasenameHint(C,L),i.outFile!=null){let k=i.sourceMap!=null?i.sourceMap.length?i.sourceMap:`./${L}.wasm.map`:null,D=n.begin();n.emitCount++;let B;try{B=R.emitBinary(k)}catch(O){I("emitBinary",O)}if(n.emitTime+=n.end(D),i.outFile.length?Q.push(g(i.outFile,B.binary,S)):(l=!0,Fn(B.binary)),B.sourceMap!="")if(i.outFile.length){let O=JSON.parse(B.sourceMap);O.sourceRoot=`./${L}`;let cn=[];for(let An=0,Ue=O.sources.length;An<Ue;++An){let ae=O.sources[An],oe=p.getSource(w,ae.replace(ln,""));if(oe==null)return z(Error(`Source of file '${ae}' not found.`));cn[An]=oe}O.sourcesContent=cn,Q.push(g(E.join(E.dirname(i.outFile),E.basename(k)).replace(/^\.\//,""),JSON.stringify(O),S))}else b.write(`Skipped source map (no output path)${T}`)}if(i.textFile!=null||!v){let k=n.begin();n.emitCount++;let D;try{gn.setOptimizeStackIR(!0),D=i.textFile?.endsWith(".wast")?R.emitText():R.emitStackIR()}catch(B){I("emitText",B)}n.emitTime+=n.end(k),i.textFile!=null&&i.textFile.length?Q.push(g(i.textFile,D,S)):l||Fn(D)}let q=r.includes("esm"),En=!q&&r.includes("raw");if(q||En)if(A){let k=n.begin();n.emitCount++;let D;try{D=p.buildTSD(w,q)}catch(B){I("buildTSD",B)}n.emitTime+=n.end(k),Q.push(g(A+".d.ts",D,S))}else b.write(`Skipped TypeScript binding (no output path)${T}`);if(q||En)if(A){let k=n.begin();n.emitCount++;let D;try{D=p.buildJS(w,q)}catch(B){I("buildJS",B)}n.emitTime+=n.end(k),Q.push(g(A+".js",D,S))}else b.write(`Skipped JavaScript binding (no output path)${T}`);if(i.rpcModule!=null&&i.rpcModule.length){let k=n.begin();n.emitCount++;let D;try{D=p.buildServerModule(w,i.rpcRuntime||"toiljs/io")}catch(B){I("buildServerModule",B)}n.emitTime+=n.end(k),D!=null&&Q.push(g(i.rpcModule,D,S))}}try{await Promise.all(Q)}catch(r){return z(r)}return n.total=n.end(a),i.stats&&b.write(n.toString()),z(null);async function te(r,l){let f=E.resolve(l,r);try{return n.readCount++,await M.promises.readFile(f,"utf8")}catch{return null}}async function ie(r,l,f){try{n.writeCount++;let u=E.resolve(f,E.dirname(r)),v=E.join(u,E.basename(r));return await M.promises.mkdir(u,{recursive:!0}),await M.promises.writeFile(v,l),!0}catch{return!1}}async function re(r,l){try{return n.readCount++,(await M.promises.readdir(E.join(l,r))).filter(f=>zt.test(f))}catch{return null}}function Fn(r){Fn.used||(Fn.used=!0,n.writeCount++),x.write(r)}function I(r,l){let f=Sn.red("\u258C ");console.error([T,f,"Whoops, the ToilScript compiler has crashed during ",r," :-(",T,f,T,(typeof l.stack=="string"?[f,"Here is the stack trace hinting at the problem, perhaps it's useful?",T,f,T,l.stack.replace(/^/mg,f),T]:[f,"There is no stack trace. Perhaps a Binaryen exception above / in console?",T,f,T,f,"> "+l.stack,T]).join(""),f,T,f,"If you see where the error is, feel free to send us a pull request. If not,",T,f,"please let us know: https://github.com/dacely-cloud/toilscript/issues",T,f,T,f,"Thank you!",T].join("")),P.exit(1)}}function jn(e){return Object.prototype.toString.call(e)==="[object Object]"}async function ze(e,t,n){let a=await n(e,t),s=E.join(t,e);if(!a)return null;let o;try{o=JSON.parse(a)}catch(c){throw new Error(`Toilconfig is not valid json: ${s}`,{cause:c})}if(o.options&&!jn(o.options))throw new Error(`Toilconfig.options is not an object: ${s}`);if(o.include&&!Array.isArray(o.include))throw new Error(`Toilconfig.include is not an array: ${s}`);if(o.targets){if(!jn(o.targets))throw new Error(`Toilconfig.targets is not an object: ${s}`);let c=Object.keys(o.targets);for(let d=0;d<c.length;d++){let x=c[d];if(!jn(o.targets[x]))throw new Error(`Toilconfig.targets.${x} is not an object: ${s}`)}}if(o.extends&&typeof o.extends!="string")throw new Error(`Toilconfig.extends is not a string: ${s}`);return o}function mn(e,t,n,a,s){typeof s>"u"&&t&&(s=t.isTTY);let o=0;do{let x=p.nextDiagnostic(e);if(!x)break;if(t){let b=h=>{if(n==null)return!1;if(!n.length)return!0;let g=p.getDiagnosticCode(h);return n.includes(g)};(p.isError(x)||!b(x))&&t.write(p.formatDiagnostic(x,s,!0)+T+T)}if(a){let b=function(g){return g&&{start:p.getRangeStart(g),end:p.getRangeEnd(g),source:h(p.getRangeSource(g))}||null},h=function(g){return g&&{normalizedPath:p.getSourceNormalizedPath(g)}||null};var c=b,d=h;a({message:p.getDiagnosticMessage(x),code:p.getDiagnosticCode(x),category:p.getDiagnosticCategory(x),range:b(p.getDiagnosticRange(x)),relatedRange:b(p.getDiagnosticRelatedRange(x))})}p.isError(x)&&++o}while(!0);return o}var zn=class{readCount=0;writeCount=0;parseTime=0;parseCount=0;initializeTime=0;initializeCount=0;compileTime=0;compileCount=0;emitTime=0;emitCount=0;validateTime=0;validateCount=0;optimizeTime=0;optimizeCount=0;transformTime=0;transformCount=0;begin(){return P.hrtime()}end(t){let n=P.hrtime(t);return n[0]*1e9+n[1]}toString(){let t=m=>m?`${(m/1e6).toFixed(3)} ms`:"n/a",n=Object.keys(this).filter(m=>m.endsWith("Time")).map(m=>m.substring(0,m.length-4)),a=n.map(m=>t(this[`${m}Time`])),s=n.map(m=>this[`${m}Count`].toString()),o=n.reduce((m,i)=>Math.max(i.length,m),0),c=a.reduce((m,i)=>Math.max(i.length,m),0),d=s.reduce((m,i)=>Math.max(i.length,m),0),x=o+c+d+6,b=[];b.push(`\u256D\u2500${"\u2500".repeat(x)}\u2500\u256E${T}`);let h="Stats";b.push(`\u2502 ${h}${" ".repeat(x-h.length)} \u2502${T}`),b.push(`\u255E\u2550${"\u2550".repeat(o)}\u2550\u2564\u2550${"\u2550".repeat(c)}\u2550\u2564\u2550${"\u2550".repeat(d)}\u2550\u2561${T}`);for(let m=0,i=n.length;m<i;++m)b.push(`\u2502 ${n[m].padEnd(o)} \u2502 ${a[m].padStart(c)} \u2502 ${s[m].padStart(d)} \u2502${T}`);b.push(`\u251C\u2500${"\u2500".repeat(o)}\u2500\u2534\u2500${"\u2500".repeat(c)}\u2500\u2534\u2500${"\u2500".repeat(d)}\u2500\u2524${T}`);let g=`Took ${t(this.total)}`;b.push(`\u2502 ${g}${" ".repeat(x-g.length)} \u2502${T}`);let y=`${this.readCount} reads, ${this.writeCount} writes`;return b.push(`\u2502 ${y}${" ".repeat(x-y.length)} \u2502${T}`),b.push(`\u2570\u2500${"\u2500".repeat(x)}\u2500\u256F${T}`),b.join("")}},Se=typeof global<"u"&&global.Buffer?global.Buffer.allocUnsafe||(e=>new global.Buffer(e)):e=>new Uint8Array(e);function Xn(e){let t=[];return t.write=function(n){if(e&&e(n),typeof n=="string"){let a=Se(Cn.length(n));Cn.write(n,a,0),n=a}this.push(n)},t.reset=function(){t.length=0},t.toBuffer=function(){let n=0,a=0,s=this.length;for(;a<s;)n+=this[a++].length;let o=Se(n);for(n=a=0;a<s;)o.set(this[a],n),n+=this[a].length,++a;return o},t.toString=function(){let n=this.toBuffer();return Cn.read(n,0,n.length)},t}var It={alwaysStrict:!0,strictNullChecks:!0,noImplicitAny:!0,noImplicitReturns:!0,noImplicitThis:!0,noEmitOnError:!0,noPropertyAccessFromIndexSignature:!0,experimentalDecorators:!0,target:"esnext",noLib:!0,types:[],allowJs:!1};export{zn as Stats,mn as checkDiagnostics,Dt as compileString,Wn as configToArguments,Xn as createMemoryStream,Yn as default,we as defaultOptimizeLevel,Be as defaultShrinkLevel,Bt as definitionFiles,j as libraryFiles,V as libraryPrefix,De as main,wt as options,It as tscOptions,Kn as version};
|
|
31576
|
+
`,Gn=qn?"\\":"/",_=".ts",Ct=`.d${_}`,ln=new RegExp("\\"+_+"$"),zt=new RegExp("^(?!.*\\.d\\"+_+"$).*\\"+_+"$");function Ce(e){return e.replace(/-/g,"_").toUpperCase()}function St(e){return typeof e=="string"&&e!==""}var Kn=Ee,wt=Y,V=Ae,j=_e,Bt=Te,we=3,Be=0;function Wn(e,t=[]){return Object.keys(e||{}).forEach(n=>{let a=e[n],s=Y[n];s&&s.type==="b"?a&&t.push(`--${n}`):Array.isArray(a)?a.forEach(o=>{t.push(`--${n}`,String(o))}):t.push(`--${n}`,String(a))}),t}async function Dt(e,t={}){typeof e=="string"&&(e={[`input${_}`]:e});let n=["--outFile","binary","--textFile","text"];Wn(t,n);let a={},s=await De(n.concat(Object.keys(e)),{readFile:o=>Object.prototype.hasOwnProperty.call(e,o)?e[o]:null,writeFile:(o,c)=>{a[o]=c},listFiles:()=>[]});return Object.assign(s,a)}async function De(e,t){Array.isArray(e)||(e=Wn(e)),t||(t={});let n=t.stats||new zn,a=n.begin(),s=0,o=0,c=0,d=(Kn||"").split(".");d.length===3&&(o=parseInt(d[0])|0,s=parseInt(d[1])|0,c=parseInt(d[2])|0);let x=t.stdout||Xn(),b=t.stderr||Xn(),h=t.readFile||te,g=t.writeFile||re,y=t.listFiles||ie,m=ve(e,Y,!1),r=m.options;e=m.arguments;let Sn=new en(x),G=new en(b);r.noColors&&(Sn.enabled=!1,G.enabled=!1);let Jn=m.unknown;Jn.length&&Jn.forEach(i=>{b.write(`${G.yellow("WARNING ")}Unknown option '${i}'${T}`)});let Zn=m.trailing;Zn.length&&b.write(`${G.yellow("WARNING ")}Unsupported trailing arguments: ${Zn.join(" ")}${T}`);let K=null,R=null,z=(i,l={})=>(i&&b.write(`${G.red("FAILURE ")}${i.stack.replace(/^ERROR: /i,"")}${T}`),R&&R.dispose(),n.total||(n.total=n.end(a)),Object.assign({error:i,stdout:x,stderr:b,stats:n},l));if(r.version)return x.write(`Version ${Kn}${T}`),z(null);let S=E.normalize(r.baseDir||"."),X=tn(r.config||"toilconfig.json",S),wn=E.basename(X),J=E.dirname(X),N=await ze(wn,J,h),Ie=N!=null&&Array.isArray(N.entries)&&N.entries.length;if(r.help||!e.length&&!Ie){let i=r.help?x:b,l=r.help?Sn:G;return i.write([l.white("SYNTAX")," "+l.cyan("toilscript")+" [entryFile ...] [options]","",l.white("EXAMPLES")," "+l.cyan("toilscript")+" hello"+_," "+l.cyan("toilscript")+" hello"+_+" -o hello.wasm -t hello.wat"," "+l.cyan("toilscript")+" hello1"+_+" hello2"+_+" -o -O > hello.wasm"," "+l.cyan("toilscript")+" --config toilconfig.json --target release","",l.white("OPTIONS")].concat(Fe(Y,24,T)).join(T)+T),z(null)}if(!(M.promises&&M.promises.readFile)){if(h===te)throw Error("'options.readFile' must be specified");if(g===re)throw Error("'options.writeFile' must be specified");if(y===ie)throw Error("'options.listFiles' must be specified")}let Bn=new Set;Bn.add(X);let ke=!!r.noConfigEntries,Le=r.target||"release";for(;N;){if(N.targets){let l=N.targets[Le];l&&(r=Mn(Y,r,l,J))}let i=N.options;if(i&&(r=Mn(Y,r,i,J)),N.entries&&!ke)for(let l of N.entries)e.push(tn(l,J));if(N.extends){if(X=tn(N.extends,J,!0),wn=E.basename(X),J=E.dirname(X),Bn.has(X))break;Bn.add(X),N=await ze(wn,J,h)}else break}if(Pn(Y,r),r.showConfig)return b.write(JSON.stringify({options:r,entries:e},null,2)),z(null);function $n(i){return[...new Set(i)]}let w,rn,bn,C=p.newOptions();switch(r.runtime){case"stub":rn=0;break;case"minimal":rn=1;break;case"memory":rn=3;break;default:rn=2;break}switch(r.uncheckedBehavior){default:bn=0;break;case"never":bn=1;break;case"always":bn=2;break}let un=null;if(r.targetMode!=null&&String(r.targetMode).length>0&&(un=String(r.targetMode),un!=="hot"&&un!=="cold"))return z(Error(`Target mode '${un}' is invalid; expected 'hot' or 'cold'.`));if(p.setTargetMode(C,un),p.setAuthUser(C,!!r.authUser),p.setTarget(C,0),p.setDebugInfo(C,!!r.debug),p.setRuntime(C,rn),p.setNoAssert(C,r.noAssert),p.setExportMemory(C,!r.noExportMemory),p.setImportMemory(C,r.importMemory),p.setInitialMemory(C,r.initialMemory>>>0),p.setMaximumMemory(C,r.maximumMemory>>>0),p.setSharedMemory(C,r.sharedMemory),p.setImportTable(C,r.importTable),p.setExportTable(C,r.exportTable),r.exportStart!=null&&p.setExportStart(C,St(r.exportStart)?r.exportStart:"_start"),p.setMemoryBase(C,r.memoryBase>>>0),p.setTableBase(C,r.tableBase>>>0),p.setSourceMap(C,r.sourceMap!=null),p.setUncheckedBehavior(C,bn),p.setNoUnsafe(C,r.noUnsafe),p.setPedantic(C,r.pedantic),p.setLowMemoryLimit(C,r.lowMemoryLimit>>>0),p.setExportRuntime(C,r.exportRuntime),p.setBundleVersion(C,o,s,c),!r.stackSize&&rn===2&&(r.stackSize=p.DEFAULT_STACK_SIZE),p.setStackSize(C,r.stackSize),p.setBindingsHint(C,r.bindings&&r.bindings.length>0),r.use){let i=r.use;for(let l=0,f=i.length;l<f;++l){let u=i[l],v=u.indexOf("=");if(v<0)return z(Error(`Global alias '${u}' is invalid.`));let F=u.substring(0,v).trim(),A=u.substring(v+1).trim();if(!F.length)return z(Error(`Global alias '${u}' is invalid.`));p.addGlobalAlias(C,F,A)}}let U;if((U=r.disable)!=null){typeof U=="string"&&(U=U.split(","));for(let i=0,l=U.length;i<l;++i){let f=U[i].trim(),u=p[`FEATURE_${Ce(f)}`];if(!u)return z(Error(`Feature '${f}' is unknown.`));p.setFeature(C,u,!1)}}if((U=r.enable)!=null){typeof U=="string"&&(U=U.split(","));for(let i=0,l=U.length;i<l;++i){let f=U[i].trim(),u=p[`FEATURE_${Ce(f)}`];if(!u)return z(Error(`Feature '${f}' is unknown.`));p.setFeature(C,u,!0)}}let Z=0,$=0;r.optimize&&(Z=we,$=Be),typeof r.optimizeLevel=="number"&&(Z=r.optimizeLevel),typeof r.shrinkLevel=="number"&&($=r.shrinkLevel),Z=Math.min(Math.max(Z,0),3),$=Math.min(Math.max($,0),2),p.setOptimizeLevelHints(C,Z,$),w=p.newProgram(C);let an=[];if(Array.isArray(t.transforms)&&an.push(...t.transforms),r.transform){let i=$n(r.transform);for(let l=0,f=i.length;l<f;++l){let u=i[l].trim(),v,F;if(Hn.resolve)try{v=Hn.resolve(u,{paths:[P.cwd(),S]}),F=await import(pn.pathToFileURL(v)),F.default&&(F=F.default)}catch(A){try{F=Hn(v)}catch{return z(A)}}else try{F=await import(new URL(u,import.meta.url)),F.default&&(F=F.default)}catch(A){return z(A)}if(!F||typeof F!="function"&&typeof F!="object")return z(Error("not a transform: "+i[l]));an.push(F)}}try{an=an.map(i=>(typeof i=="function"&&(Object.assign(i.prototype,{program:w,binaryen:gn,baseDir:S,stdout:x,stderr:b,log:console.error,readFile:h,writeFile:g,listFiles:y}),i=new i),i))}catch(i){return z(i)}async function Dn(i,...l){for(let f=0,u=an.length;f<u;++f){let v=an[f];if(typeof v[i]=="function")try{let F=n.begin();n.transformCount++,await v[i](...l),n.transformTime+=n.end(F)}catch(F){return F}}}Object.keys(j).forEach(i=>{if(i.includes("/"))return;let l=n.begin();n.parseCount++,p.parse(w,j[i],V+i+_,!1),n.parseTime+=n.end(l)});let on=[];if(r.lib){let i=r.lib;typeof i=="string"&&(i=i.split(",")),on.push(...i.map(l=>l.trim())),on=$n(on);for(let l=0,f=on.length;l<f;++l){let u=on[l],v;u.endsWith(_)?(v=[E.basename(u)],u=E.dirname(u)):v=await y(u,S)||[];for(let F of v){let A=await h(F,u);if(A==null)return z(Error(`Library file '${F}' not found.`));j[F.replace(ln,"")]=A;let k=n.begin();n.parseCount++,p.parse(w,A,V+F,!1),n.parseTime+=n.end(k)}}}r.path=r.path||[];let yn=new Map;async function Oe(i,l){let f=null,u=null;if(!i.startsWith(V))(f=await h(u=i+_,S))==null&&(f=await h(u=i+"/index"+_,S))==null&&(u=i+_,f=await h(i+Ct,S));else{let v=i.substring(V.length),F=`${v}/index`;if(Object.prototype.hasOwnProperty.call(j,v))f=j[v],u=V+v+_;else if(Object.prototype.hasOwnProperty.call(j,F))f=j[F],u=V+F+_;else{for(let A of on)if((f=await h(v+_,A))!=null){u=V+v+_;break}else if((f=await h(F+_,A))!=null){u=V+F+_;break}if(f==null){let A=i.match(/^~lib\/((?:@[^/]+\/)?[^/]+)(?:\/(.+))?/);if(A){let k=A[1],q=A[2]||"index",En=yn.has(l)?yn.get(l):".",L=[],D=E.resolve(S,En).split(Gn);for(let B=D.length,O=qn?1:0;B>=O;--B)D[B-1]!=="node_modules"&&L.push(`${D.slice(0,B).join(Gn)}${Gn}node_modules`);L.push(...r.path);for(let B of L.map(O=>E.relative(S,O))){let O=q;if((f=await h(E.join(B,k,O+_),S))!=null){u=`${V}${k}/${O}${_}`,yn.set(u.replace(ln,""),E.join(B,k));break}let cn=`${q}/index`;if((f=await h(E.join(B,k,cn+_),S))!=null){u=`${V}${k}/${cn}${_}`,yn.set(u.replace(ln,""),E.join(B,k));break}}}}}}return f==null?null:{sourceText:f,sourcePath:u}}function Re(i=[]){do{let l=p.nextFile(w);if(l==null)break;i.push(l)}while(!0);return i}async function Qn(){let i;for(;(i=Re()).length;){let f=[];for(let u of i){let v=p.getDependee(w,u);f.push(Oe(u,v))}f=await Promise.all(f);for(let u=0,v=i.length;u<v;++u){let F=i[u],A=f[u],k=n.begin();n.parseCount++,A?p.parse(w,A.sourceText,A.sourcePath,!1):p.parse(w,null,F+_,!1),n.parseTime+=n.end(k)}}let l=mn(w,b,r.disableWarning,t.reportDiagnostic,G.enabled);if(l){let f=Error(`${l} parse error(s)`);return f.stack=f.message,z(f)}}{let i=String(r.runtime),l=`rt/index-${i}`,f=j[l];if(f==null){if(l=i,f=await h(l+_,S),f==null)return z(Error(`Runtime '${E.resolve(S,l+_)}' is not found.`))}else l=`~lib/${l}`;let u=n.begin();n.parseCount++,p.parse(w,f,l+_,!0),n.parseTime+=n.end(u)}for(let i=0,l=e.length;i<l;++i){let f=String(e[i]),u=E.isAbsolute(f)?E.relative(S,f):E.normalize(f);u=u.replace(/\\/g,"/").replace(ln,"").replace(/\/$/,"");let v=await h(u+_,S);if(v==null){let A=`${u}/index${_}`;v=await h(A,S),v!=null?u=A:u+=_}else u+=_;let F=n.begin();n.parseCount++,p.parse(w,v,u,!0),n.parseTime+=n.end(F)}if(r.rpcSurfaceFiles!=null&&r.rpcSurfaceFiles.length)for(let i=0,l=r.rpcSurfaceFiles.length;i<l;++i){let f=String(r.rpcSurfaceFiles[i]),u=E.isAbsolute(f)?E.relative(S,f):E.normalize(f);u=u.replace(/\\/g,"/").replace(ln,"").replace(/\/$/,"");let v=await h(u+_,S);if(v==null){let F=`${u}/index${_}`;v=await h(F,S),v!=null?u=F:u+=_}else u+=_;v!=null?(n.parseCount++,p.parse(w,v,u,!1)):p.parse(w,null,u,!1)}if(M.promises&&M.promises.readdir){let i=[],l=async(f,u)=>{let v;try{v=await M.promises.readdir(f,{withFileTypes:!0})}catch{return}for(let F of v){let A=F.name;if(F.isDirectory()){if(A==="node_modules"||A==="build"||A==="dist"||A.charAt(0)===".")continue;await l(E.join(f,A),u?u+"/"+A:A)}else A.endsWith(".migration"+_)&&i.push(u?u+"/"+A:A)}};await l(E.resolve(S),"");for(let f of i){let u=f.replace(/\\/g,"/"),v=await h(u,S);v!=null&&(n.parseCount++,p.parse(w,v,u,!1))}}{let i=await Qn();if(i)return i}{let i=await Dn("afterParse",w.parser);if(i)return z(i)}{let i=await Qn();if(i)return i}{let i=n.begin();n.initializeCount++;try{p.initializeProgram(w)}catch(l){I("initialize",l)}n.initializeTime+=n.end(i)}{let i=await Dn("afterInitialize",w);if(i)return z(i)}{let i=n.begin();n.compileCount++;try{K=p.compile(w)}catch(l){let f=mn(w,b,r.disableWarning,t.reportDiagnostic,G.enabled);if(f){let u=Error(`${f} compile error(s)`);return u.stack=u.message,z(u)}I("compile",l)}n.compileTime+=n.end(i)}R=gn.wrapModule(typeof K=="number"||K instanceof Number?p.getBinaryenModuleRef(K):K.ref);let fn=mn(w,b,r.disableWarning,t.reportDiagnostic,G.enabled);if(fn){let i=Error(`${fn} compile error(s)`);return i.stack=i.message,z(i)}{let i=await Dn("afterCompile",R);if(i)return z(i)}if(fn=mn(w,b,r.disableWarning,t.reportDiagnostic,G.enabled),fn){let i=Error(`${fn} afterCompile error(s)`);return i.stack=i.message,z(i)}if(!r.noValidate){let i=n.begin();n.validateCount++;let l=p.validate(K);if(n.validateTime+=n.end(i),!l)return z(Error("validate error"))}if(r.trapMode==="clamp"||r.trapMode==="js"){let i=n.begin();try{R.runPasses([`trap-mode-${r.trapMode}`])}catch(l){I("runPasses",l)}n.compileTime+=n.end(i)}else if(r.trapMode!=="allow")return z(Error("Unsupported trap mode"));let ne=r.debug,Ne=r.converge,ee=r.importMemory?r.zeroFilledMemory:!1,vn=[];r.runPasses&&(typeof r.runPasses=="string"&&(r.runPasses=r.runPasses.split(",")),r.runPasses.length&&r.runPasses.forEach(i=>{vn.includes(i=i.trim())||vn.push(i)}));{let i=n.begin();try{n.optimizeCount++,p.optimize(K,Z,$,ne,ee)}catch(l){I("optimize",l)}try{R.runPasses(vn)}catch(l){I("runPasses",l)}if(Ne){let l;try{let f=n.begin();n.emitCount++,l=R.emitBinary(),n.emitTime+=n.end(f)}catch(f){I("emitBinary (converge)",f)}do{try{n.optimizeCount++,p.optimize(K,Z,$,ne,ee)}catch(u){I("optimize (converge)",u)}try{R.runPasses(vn)}catch(u){I("runPasses (converge)",u)}let f;try{let u=n.begin();n.emitCount++,f=R.emitBinary(),n.emitTime+=n.end(u)}catch(u){I("emitBinary (converge)",u)}if(f.length>=l.length){f.length>l.length&&b.write(`Last converge was suboptimal.${T}`);break}l=f}while(!0)}n.optimizeTime+=n.end(i)}let Q=[];if(!r.noEmit){if(r.binaryFile)return z(Error("Usage of the --binaryFile compiler option is no longer supported. Use --outFile instead."));let i=r.bindings||[],l=!1,f=r.outFile!=null,u=r.textFile!=null,v=f||u,F=f&&r.outFile.length>0||u&&r.textFile.length>0,A=F?(r.outFile||r.textFile).replace(/\.\w+$/,""):null,k=F?E.basename(A):"output";if(p.setBasenameHint(C,k),r.outFile!=null){let L=r.sourceMap!=null?r.sourceMap.length?r.sourceMap:`./${k}.wasm.map`:null,D=n.begin();n.emitCount++;let B;try{B=R.emitBinary(L)}catch(O){I("emitBinary",O)}if(n.emitTime+=n.end(D),r.outFile.length?Q.push(g(r.outFile,B.binary,S)):(l=!0,Fn(B.binary)),B.sourceMap!="")if(r.outFile.length){let O=JSON.parse(B.sourceMap);O.sourceRoot=`./${k}`;let cn=[];for(let An=0,Ue=O.sources.length;An<Ue;++An){let ae=O.sources[An],oe=p.getSource(w,ae.replace(ln,""));if(oe==null)return z(Error(`Source of file '${ae}' not found.`));cn[An]=oe}O.sourcesContent=cn,Q.push(g(E.join(E.dirname(r.outFile),E.basename(L)).replace(/^\.\//,""),JSON.stringify(O),S))}else b.write(`Skipped source map (no output path)${T}`)}if(r.textFile!=null||!v){let L=n.begin();n.emitCount++;let D;try{gn.setOptimizeStackIR(!0),D=r.textFile?.endsWith(".wast")?R.emitText():R.emitStackIR()}catch(B){I("emitText",B)}n.emitTime+=n.end(L),r.textFile!=null&&r.textFile.length?Q.push(g(r.textFile,D,S)):l||Fn(D)}let q=i.includes("esm"),En=!q&&i.includes("raw");if(q||En)if(A){let L=n.begin();n.emitCount++;let D;try{D=p.buildTSD(w,q)}catch(B){I("buildTSD",B)}n.emitTime+=n.end(L),Q.push(g(A+".d.ts",D,S))}else b.write(`Skipped TypeScript binding (no output path)${T}`);if(q||En)if(A){let L=n.begin();n.emitCount++;let D;try{D=p.buildJS(w,q)}catch(B){I("buildJS",B)}n.emitTime+=n.end(L),Q.push(g(A+".js",D,S))}else b.write(`Skipped JavaScript binding (no output path)${T}`);if(r.rpcModule!=null&&r.rpcModule.length){let L=n.begin();n.emitCount++;let D;try{D=p.buildServerModule(w,r.rpcRuntime||"toiljs/io")}catch(B){I("buildServerModule",B)}n.emitTime+=n.end(L),D!=null&&Q.push(g(r.rpcModule,D,S))}}try{await Promise.all(Q)}catch(i){return z(i)}return n.total=n.end(a),r.stats&&b.write(n.toString()),z(null);async function te(i,l){let f=E.resolve(l,i);try{return n.readCount++,await M.promises.readFile(f,"utf8")}catch{return null}}async function re(i,l,f){try{n.writeCount++;let u=E.resolve(f,E.dirname(i)),v=E.join(u,E.basename(i));return await M.promises.mkdir(u,{recursive:!0}),await M.promises.writeFile(v,l),!0}catch{return!1}}async function ie(i,l){try{return n.readCount++,(await M.promises.readdir(E.join(l,i))).filter(f=>zt.test(f))}catch{return null}}function Fn(i){Fn.used||(Fn.used=!0,n.writeCount++),x.write(i)}function I(i,l){let f=Sn.red("\u258C ");console.error([T,f,"Whoops, the ToilScript compiler has crashed during ",i," :-(",T,f,T,(typeof l.stack=="string"?[f,"Here is the stack trace hinting at the problem, perhaps it's useful?",T,f,T,l.stack.replace(/^/mg,f),T]:[f,"There is no stack trace. Perhaps a Binaryen exception above / in console?",T,f,T,f,"> "+l.stack,T]).join(""),f,T,f,"If you see where the error is, feel free to send us a pull request. If not,",T,f,"please let us know: https://github.com/dacely-cloud/toilscript/issues",T,f,T,f,"Thank you!",T].join("")),P.exit(1)}}function jn(e){return Object.prototype.toString.call(e)==="[object Object]"}async function ze(e,t,n){let a=await n(e,t),s=E.join(t,e);if(!a)return null;let o;try{o=JSON.parse(a)}catch(c){throw new Error(`Toilconfig is not valid json: ${s}`,{cause:c})}if(o.options&&!jn(o.options))throw new Error(`Toilconfig.options is not an object: ${s}`);if(o.include&&!Array.isArray(o.include))throw new Error(`Toilconfig.include is not an array: ${s}`);if(o.targets){if(!jn(o.targets))throw new Error(`Toilconfig.targets is not an object: ${s}`);let c=Object.keys(o.targets);for(let d=0;d<c.length;d++){let x=c[d];if(!jn(o.targets[x]))throw new Error(`Toilconfig.targets.${x} is not an object: ${s}`)}}if(o.extends&&typeof o.extends!="string")throw new Error(`Toilconfig.extends is not a string: ${s}`);return o}function mn(e,t,n,a,s){typeof s>"u"&&t&&(s=t.isTTY);let o=0;do{let x=p.nextDiagnostic(e);if(!x)break;if(t){let b=h=>{if(n==null)return!1;if(!n.length)return!0;let g=p.getDiagnosticCode(h);return n.includes(g)};(p.isError(x)||!b(x))&&t.write(p.formatDiagnostic(x,s,!0)+T+T)}if(a){let b=function(g){return g&&{start:p.getRangeStart(g),end:p.getRangeEnd(g),source:h(p.getRangeSource(g))}||null},h=function(g){return g&&{normalizedPath:p.getSourceNormalizedPath(g)}||null};var c=b,d=h;a({message:p.getDiagnosticMessage(x),code:p.getDiagnosticCode(x),category:p.getDiagnosticCategory(x),range:b(p.getDiagnosticRange(x)),relatedRange:b(p.getDiagnosticRelatedRange(x))})}p.isError(x)&&++o}while(!0);return o}var zn=class{readCount=0;writeCount=0;parseTime=0;parseCount=0;initializeTime=0;initializeCount=0;compileTime=0;compileCount=0;emitTime=0;emitCount=0;validateTime=0;validateCount=0;optimizeTime=0;optimizeCount=0;transformTime=0;transformCount=0;begin(){return P.hrtime()}end(t){let n=P.hrtime(t);return n[0]*1e9+n[1]}toString(){let t=m=>m?`${(m/1e6).toFixed(3)} ms`:"n/a",n=Object.keys(this).filter(m=>m.endsWith("Time")).map(m=>m.substring(0,m.length-4)),a=n.map(m=>t(this[`${m}Time`])),s=n.map(m=>this[`${m}Count`].toString()),o=n.reduce((m,r)=>Math.max(r.length,m),0),c=a.reduce((m,r)=>Math.max(r.length,m),0),d=s.reduce((m,r)=>Math.max(r.length,m),0),x=o+c+d+6,b=[];b.push(`\u256D\u2500${"\u2500".repeat(x)}\u2500\u256E${T}`);let h="Stats";b.push(`\u2502 ${h}${" ".repeat(x-h.length)} \u2502${T}`),b.push(`\u255E\u2550${"\u2550".repeat(o)}\u2550\u2564\u2550${"\u2550".repeat(c)}\u2550\u2564\u2550${"\u2550".repeat(d)}\u2550\u2561${T}`);for(let m=0,r=n.length;m<r;++m)b.push(`\u2502 ${n[m].padEnd(o)} \u2502 ${a[m].padStart(c)} \u2502 ${s[m].padStart(d)} \u2502${T}`);b.push(`\u251C\u2500${"\u2500".repeat(o)}\u2500\u2534\u2500${"\u2500".repeat(c)}\u2500\u2534\u2500${"\u2500".repeat(d)}\u2500\u2524${T}`);let g=`Took ${t(this.total)}`;b.push(`\u2502 ${g}${" ".repeat(x-g.length)} \u2502${T}`);let y=`${this.readCount} reads, ${this.writeCount} writes`;return b.push(`\u2502 ${y}${" ".repeat(x-y.length)} \u2502${T}`),b.push(`\u2570\u2500${"\u2500".repeat(x)}\u2500\u256F${T}`),b.join("")}},Se=typeof global<"u"&&global.Buffer?global.Buffer.allocUnsafe||(e=>new global.Buffer(e)):e=>new Uint8Array(e);function Xn(e){let t=[];return t.write=function(n){if(e&&e(n),typeof n=="string"){let a=Se(Cn.length(n));Cn.write(n,a,0),n=a}this.push(n)},t.reset=function(){t.length=0},t.toBuffer=function(){let n=0,a=0,s=this.length;for(;a<s;)n+=this[a++].length;let o=Se(n);for(n=a=0;a<s;)o.set(this[a],n),n+=this[a].length,++a;return o},t.toString=function(){let n=this.toBuffer();return Cn.read(n,0,n.length)},t}var It={alwaysStrict:!0,strictNullChecks:!0,noImplicitAny:!0,noImplicitReturns:!0,noImplicitThis:!0,noEmitOnError:!0,noPropertyAccessFromIndexSignature:!0,experimentalDecorators:!0,target:"esnext",noLib:!0,types:[],allowJs:!1};export{zn as Stats,mn as checkDiagnostics,Dt as compileString,Wn as configToArguments,Xn as createMemoryStream,Yn as default,we as defaultOptimizeLevel,Be as defaultShrinkLevel,Bt as definitionFiles,j as libraryFiles,V as libraryPrefix,De as main,wt as options,It as tscOptions,Kn as version};
|
|
31301
31577
|
//# sourceMappingURL=cli.js.map
|