@yabgu_gm/tensionscript 0.13.1 → 0.14.0

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/asc.js CHANGED
@@ -4,8 +4,8 @@
4
4
  * Copyright 2026 Daniel Wirtz / The AssemblyScript 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 cn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var nn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,r)=>{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:!(r=Me(t,s))||r.enumerable});return e},Dn=(e,t,n)=>(se(e,t,"default"),n&&se(n,t,"default"));var ue={};nn(ue,{promises:()=>je});var je,fe=cn(()=>{"use strict";je={}});var ce={};nn(ce,{createRequire:()=>Ge});function Ge(){return function(t){throw new Error(`Cannot find module: '${t}'`)}}var de=cn(()=>{"use strict"});var kn={};nn(kn,{argv:()=>Ke,cwd:()=>In,exit:()=>qe,hrtime:()=>Ye,platform:()=>Xe,umask:()=>He});function In(){return"."}function He(){return 0}function qe(e=0){throw Error(`exit ${e}`)}function Ye(e){var t=We.call(xe),n=Math.floor(t*.001),r=Math.floor(t*1e6-n*1e9);return e&&(n-=e[0],r-=e[1],r<0&&(n--,r+=1e9)),[n,r]}var Xe,Ke,xe,We,On=cn(()=>{"use strict";Xe="linux";Ke=[];xe=globalThis.performance||{},We=xe.now||function(){return new Date().getTime()}});var Rn={};nn(Rn,{basename:()=>et,delimiter:()=>at,dirname:()=>nt,extname:()=>tt,format:()=>it,isAbsolute:()=>Ze,join:()=>Je,normalize:()=>he,parse:()=>rt,relative:()=>Qe,resolve:()=>dn,sep:()=>Ln,win32:()=>ot});function j(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function pe(e,t){for(var n="",r=0,s=-1,o=0,f,c=0;c<=e.length;++c){if(c<e.length)f=e.charCodeAt(c);else{if(f===47)break;f=47}if(f===47){if(!(s===c-1||o===1))if(s!==c-1&&o===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var p=n.lastIndexOf("/");if(p!==n.length-1){p===-1?(n="",r=0):(n=n.slice(0,p),r=n.length-1-n.lastIndexOf("/")),s=c,o=0;continue}}else if(n.length===2||n.length===1){n="",r=0,s=c,o=0;continue}}t&&(n.length>0?n+="/..":n="..",r=2)}else n.length>0?n+="/"+e.slice(s+1,c):n=e.slice(s+1,c),r=c-s-1;s=c,o=0}else f===46&&o!==-1?++o:o=-1}return n}function $e(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+e+r:r}function dn(){for(var e="",t=!1,n,r=arguments.length-1;r>=-1&&!t;r--){var s;r>=0?s=arguments[r]:(n===void 0&&(n=In()),s=n),j(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 he(e){if(j(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 j(e),e.length>0&&e.charCodeAt(0)===47}function Je(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];j(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":he(e)}function Qe(e,t){if(j(e),j(t),e===t||(e=dn(e),t=dn(t),e===t))return"";if(e===".")return t;for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var r=e.length,s=r-n,o=1;o<t.length&&t.charCodeAt(o)===47;++o);for(var f=t.length,c=f-o,p=s<c?s:c,b=-1,d=0;d<=p;++d){if(d===p){if(c>p){if(t.charCodeAt(o+d)===47)return t.slice(o+d+1);if(d===0)return t.slice(o+d)}else s>p&&(e.charCodeAt(n+d)===47?b=d:d===0&&(b=0));break}var g=e.charCodeAt(n+d),y=t.charCodeAt(o+d);if(g!==y)break;g===47&&(b=d)}var m="";for(d=n+b+1;d<=r;++d)(d===r||e.charCodeAt(d)===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(j(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,r=-1,s=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!s){r=o;break}}else s=!1;return r===-1?n?"/":".":n&&r===1?"//":e.slice(0,r)}function et(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');j(e);var n=0,r=-1,s=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var f=t.length-1,c=-1;for(o=e.length-1;o>=0;--o){var p=e.charCodeAt(o);if(p===47){if(!s){n=o+1;break}}else c===-1&&(s=!1,c=o+1),f>=0&&(p===t.charCodeAt(f)?--f===-1&&(r=o):(f=-1,r=c))}return n===r?r=c:r===-1&&(r=e.length),e.slice(n,r)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!s){n=o+1;break}}else r===-1&&(s=!1,r=o+1);return r===-1?"":e.slice(n,r)}}function tt(e){j(e);for(var t=-1,n=0,r=-1,s=!0,o=0,f=e.length-1;f>=0;--f){var c=e.charCodeAt(f);if(c===47){if(!s){n=f+1;break}continue}r===-1&&(s=!1,r=f+1),c===46?t===-1?t=f:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||r===-1||o===0||o===1&&t===r-1&&t===n+1?"":e.slice(t,r)}function it(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return $e("/",e)}function rt(e){j(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),r=n===47,s;r?(t.root="/",s=1):s=0;for(var o=-1,f=0,c=-1,p=!0,b=e.length-1,d=0;b>=s;--b){if(n=e.charCodeAt(b),n===47){if(!p){f=b+1;break}continue}c===-1&&(p=!1,c=b+1),n===46?o===-1?o=b:d!==1&&(d=1):o!==-1&&(d=-1)}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===f+1?c!==-1&&(f===0&&r?t.base=t.name=e.slice(1,c):t.base=t.name=e.slice(f,c)):(f===0&&r?(t.name=e.slice(1,o),t.base=e.slice(1,c)):(t.name=e.slice(f,o),t.base=e.slice(f,c)),t.ext=e.slice(o,c)),f>0?t.dir=e.slice(0,f-1):r&&(t.dir="/"),t}var Ln,at,ot,Nn=cn(()=>{"use strict";On();Ln="/",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=dn(e);e.charCodeAt(e.length-1)===47&&t[t.length-1]!==Ln&&(t+="/");let n=new URL("file://");return n.pathname=st(t),n}var me=cn(()=>{"use strict";Nn()});var Wn={};nn(Wn,{Stats:()=>Cn,checkDiagnostics:()=>Tn,compileString:()=>Dt,configToArguments:()=>qn,createMemoryStream:()=>Hn,default:()=>Wn,defaultOptimizeLevel:()=>we,defaultShrinkLevel:()=>Se,definitionFiles:()=>St,libraryFiles:()=>G,libraryPrefix:()=>L,main:()=>De,options:()=>wt,tscOptions:()=>It,version:()=>Xn});var ut=Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]",X,sn,v,P,xn;ut?(X=await import("fs"),sn=await import("module"),v=await import("path"),P=globalThis.process,xn=await import("url")):(X=await Promise.resolve().then(()=>(fe(),ue)),sn=await Promise.resolve().then(()=>(de(),ce)),v=await Promise.resolve().then(()=>(Nn(),Rn)),P=await Promise.resolve().then(()=>(On(),kn)),xn=await Promise.resolve().then(()=>(me(),ge)));var En=typeof process<"u"&&process||{},ft=En.env&&"CI"in En.env,ct="\x1B[90m",dt="\x1B[91m",xt="\x1B[92m",pt="\x1B[93m",ht="\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?xt+t+W:t}yellow(t){return this.enabled?pt+t+W:t}blue(t){return this.enabled?ht+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}},An=new en(En.stdout),Lt=new en(En.stderr);function yt(e){for(var t=0,n=0,r=e.length;n<r;++n){let s=e.charCodeAt(n);s<128?t+=1:s<2048?t+=2:(s&64512)===55296&&n+1<r&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3}return t}function Ft(e,t,n){var r=n-t;if(r<1)return"";for(var s=null,o=[],f=0,c;t<n;)c=e[t++],c<128?o[f++]=c:c>191&&c<224?o[f++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,o[f++]=55296+(c>>10),o[f++]=56320+(c&1023)):o[f++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,f>=8192&&((s||(s=[])).push(String.fromCharCode(...o)),f=0);return s?(f&&s.push(String.fromCharCode(...o.slice(0,f))),s.join("")):String.fromCharCode(...o.slice(0,f))}function vt(e,t,n){for(var r=n,s=0,o=e.length;s<o;++s){let f=e.charCodeAt(s),c;f<128?t[n++]=f:f<2048?(t[n++]=f>>6|192,t[n++]=f&63|128):(f&64512)===55296&&s+1<o&&((c=e.charCodeAt(s+1))&64512)===56320?(f=65536+((f&1023)<<10)+(c&1023),++s,t[n++]=f>>18|240,t[n++]=f>>12&63|128,t[n++]=f>>6&63|128,t[n++]=f&63|128):(t[n++]=f>>12|224,t[n++]=f>>6&63|128,t[n++]=f&63|128)}return n-r}var _n={length:yt,read:Ft,write:vt};var be=sn.createRequire(import.meta.url);function Fe(e,t,n=!0){var r={},s=[],o=[],f=[],c={};Object.keys(t).forEach(d=>{if(!d.startsWith(" ")){var g=t[d];g.alias!=null&&(typeof g.alias=="string"?c[g.alias]=d:Array.isArray(g.alias)&&g.alias.forEach(y=>c[y]=d)),n&&g.default!=null&&(r[d]=g.default)}});for(var p=0,b=(e=e.slice()).length;p<b;++p){let d=e[p];if(d=="--"){++p;break}let g=/^(?:(-\w)(?:=(.*))?|(--\w{2,})(?:=(.*))?)$/.exec(d),y,m;if(g)t[d]?y=t[m=d]:g[1]!=null?(y=t[m=c[g[1].substring(1)]],y&&g[2]!=null&&(e[p--]=g[2])):g[3]!=null&&(y=t[m=g[3].substring(2)],y&&g[4]!=null&&(e[p--]=g[4]));else if(d.charCodeAt(0)==45)y=t[m=d];else{o.push(d);continue}if(y)if(y.value)Object.keys(y.value).forEach(a=>r[a]=y.value[a]);else if(y.type==null||y.type==="b")r[m]=!0;else if(p+1<e.length&&e[p+1].charCodeAt(0)!=45)switch(y.type){case"i":r[m]=parseInt(e[++p],10);break;case"I":r[m]=(r[m]||[]).concat(parseInt(e[++p],10));break;case"f":r[m]=parseFloat(e[++p]);break;case"F":r[m]=(r[m]||[]).concat(parseFloat(e[++p]));break;case"s":r[m]=String(e[++p]);break;case"S":r[m]=(r[m]||[]).concat(e[++p].split(","));break;default:s.push(d),--p}else switch(y.type){case"i":case"f":r[m]=y.default||0;break;case"s":r[m]=y.default||"";break;case"I":case"F":case"S":r[m]=y.default||[];break;default:s.push(d)}else s.push(d)}for(;p<b;)f.push(e[p++]);return n&&Mn(t,r),{options:r,unknown:s,arguments:o,trailing:f}}function ve(e,t){t||(t={});var n=t.indent||2,r=t.padding||24,s=t.eol||`
8
- `,o={},f=[];Object.keys(e).forEach(b=>{var d=e[b];if(d.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,d.alias&&(g+=", -"+d.alias);g.length<r;)g+=" ";var y;!t.noCategories&&d.category?(y=o[d.category])||(o[d.category]=y=[]):y=f,Array.isArray(d.description)?y.push(g+d.description[0]+d.description.slice(1).map(m=>{for(let a=0;a<r;++a)m=" "+m;return s+m}).join("")):y.push(g+d.description)}});var c=[],p=!1;return Object.keys(o).forEach(b=>{p=!0,c.push(s+" "+An.gray(b)+s),c.push(o[b].join(s))}),p&&f.length&&c.push(s+" "+An.gray("Other")+s),c.push(f.join(s)),c.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 Un(e,t,n,r){let s={};for(let[o,{type:f,mutuallyExclusive:c,isPath:p,useNodeResolution:b,cliOnly:d}]of Object.entries(e)){let g=ye(t[o],f),y=ye(n[o],f);if(g==null){if(y!=null){if(d)continue;if(Array.isArray(y)){let m;p&&(y=y.map(a=>tn(a,r,b))),c!=null&&(m=t[c])?s[o]=y.filter(a=>!m.includes(a)):s[o]=y.slice()}else p&&(y=tn(y,r,b)),s[o]=y}}else if(y==null)Array.isArray(g)?s[o]=g.slice():s[o]=g;else if(Array.isArray(g)){if(d){s[o]=g.slice();continue}let m;p&&(y=y.map(a=>tn(a,r,b))),c!=null&&(m=t[c])?s[o]=[...g,...y.filter(a=>!g.includes(a)&&!m.includes(a))]:s[o]=[...g,...y.filter(a=>!g.includes(a))]}else s[o]=g}return s}function Et(e){let t=v.parse(e);return t.root||(t.root="./"),v.format(t)}function tn(e,t,n=!1){return v.isAbsolute(e)?e:n&&!e.startsWith(".")&&be.resolve?be.resolve(e,{paths:[t]}):Et(v.join(t,e))}function Mn(e,t){for(let[n,{default:r}]of Object.entries(e))t[n]==null&&r!=null&&(t[n]=r)}var Ee="0.13.1",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},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},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 ue=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var je=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 en=(e,t)=>{for(var n in t)ue(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ve(t))!je.call(e,s)&&s!==n&&ue(e,s,{get:()=>t[s],enumerable:!(a=Pe(t,s))||a.enumerable});return e},Dn=(e,t,n)=>(le(e,t,"default"),n&&le(n,t,"default"));var fe={};en(fe,{promises:()=>Ge});var Ge,ce=dn(()=>{"use strict";Ge={}});var de={};en(de,{createRequire:()=>Xe});function Xe(){return function(t){throw new Error(`Cannot find module: '${t}'`)}}var xe=dn(()=>{"use strict"});var kn={};en(kn,{argv:()=>qe,cwd:()=>In,exit:()=>We,hrtime:()=>$e,platform:()=>He,umask:()=>Ke});function In(){return"."}function Ke(){return 0}function We(e=0){throw Error(`exit ${e}`)}function $e(e){var t=Ye.call(pe),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 He,qe,pe,Ye,On=dn(()=>{"use strict";He="linux";qe=[];pe=globalThis.performance||{},Ye=pe.now||function(){return new Date().getTime()}});var Rn={};en(Rn,{basename:()=>tt,delimiter:()=>ot,dirname:()=>et,extname:()=>it,format:()=>rt,isAbsolute:()=>Je,join:()=>Qe,normalize:()=>ge,parse:()=>at,relative:()=>nt,resolve:()=>xn,sep:()=>Ln,win32:()=>st});function j(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function he(e,t){for(var n="",a=0,s=-1,o=0,f,c=0;c<=e.length;++c){if(c<e.length)f=e.charCodeAt(c);else{if(f===47)break;f=47}if(f===47){if(!(s===c-1||o===1))if(s!==c-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 p=n.lastIndexOf("/");if(p!==n.length-1){p===-1?(n="",a=0):(n=n.slice(0,p),a=n.length-1-n.lastIndexOf("/")),s=c,o=0;continue}}else if(n.length===2||n.length===1){n="",a=0,s=c,o=0;continue}}t&&(n.length>0?n+="/..":n="..",a=2)}else n.length>0?n+="/"+e.slice(s+1,c):n=e.slice(s+1,c),a=c-s-1;s=c,o=0}else f===46&&o!==-1?++o:o=-1}return n}function Ze(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 xn(){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=In()),s=n),j(s),s.length!==0&&(e=s+"/"+e,t=s.charCodeAt(0)===47)}return e=he(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."}function ge(e){if(j(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=he(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e}function Je(e){return j(e),e.length>0&&e.charCodeAt(0)===47}function Qe(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];j(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":ge(e)}function nt(e,t){if(j(e),j(t),e===t||(e=xn(e),t=xn(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 f=t.length,c=f-o,p=s<c?s:c,b=-1,d=0;d<=p;++d){if(d===p){if(c>p){if(t.charCodeAt(o+d)===47)return t.slice(o+d+1);if(d===0)return t.slice(o+d)}else s>p&&(e.charCodeAt(n+d)===47?b=d:d===0&&(b=0));break}var g=e.charCodeAt(n+d),y=t.charCodeAt(o+d);if(g!==y)break;g===47&&(b=d)}var m="";for(d=n+b+1;d<=a;++d)(d===a||e.charCodeAt(d)===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 et(e){if(j(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 tt(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');j(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 f=t.length-1,c=-1;for(o=e.length-1;o>=0;--o){var p=e.charCodeAt(o);if(p===47){if(!s){n=o+1;break}}else c===-1&&(s=!1,c=o+1),f>=0&&(p===t.charCodeAt(f)?--f===-1&&(a=o):(f=-1,a=c))}return n===a?a=c: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 it(e){j(e);for(var t=-1,n=0,a=-1,s=!0,o=0,f=e.length-1;f>=0;--f){var c=e.charCodeAt(f);if(c===47){if(!s){n=f+1;break}continue}a===-1&&(s=!1,a=f+1),c===46?t===-1?t=f: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 Ze("/",e)}function at(e){j(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,f=0,c=-1,p=!0,b=e.length-1,d=0;b>=s;--b){if(n=e.charCodeAt(b),n===47){if(!p){f=b+1;break}continue}c===-1&&(p=!1,c=b+1),n===46?o===-1?o=b:d!==1&&(d=1):o!==-1&&(d=-1)}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===f+1?c!==-1&&(f===0&&a?t.base=t.name=e.slice(1,c):t.base=t.name=e.slice(f,c)):(f===0&&a?(t.name=e.slice(1,o),t.base=e.slice(1,c)):(t.name=e.slice(f,o),t.base=e.slice(f,c)),t.ext=e.slice(o,c)),f>0?t.dir=e.slice(0,f-1):a&&(t.dir="/"),t}var Ln,ot,st,Nn=dn(()=>{"use strict";On();Ln="/",ot=":",st=null});var me={};en(me,{pathToFileURL:()=>ut});function lt(e){return e.replace(/%/g,"%25").replace(/\\/g,"%5C").replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/\t/g,"%09")}function ut(e){let t=xn(e);e.charCodeAt(e.length-1)===47&&t[t.length-1]!==Ln&&(t+="/");let n=new URL("file://");return n.pathname=lt(t),n}var be=dn(()=>{"use strict";Nn()});var Yn={};en(Yn,{Stats:()=>Cn,checkDiagnostics:()=>Tn,compileString:()=>Dt,configToArguments:()=>Wn,createMemoryStream:()=>Hn,default:()=>Yn,defaultOptimizeLevel:()=>Se,defaultShrinkLevel:()=>De,definitionFiles:()=>St,libraryFiles:()=>G,libraryPrefix:()=>R,main:()=>Ie,options:()=>wt,tscOptions:()=>It,version:()=>Xn});var ft=Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]",H,un,v,L,pn;ft?(H=await import("fs"),un=await import("module"),v=await import("path"),L=globalThis.process,pn=await import("url")):(H=await Promise.resolve().then(()=>(ce(),fe)),un=await Promise.resolve().then(()=>(xe(),de)),v=await Promise.resolve().then(()=>(Nn(),Rn)),L=await Promise.resolve().then(()=>(On(),kn)),pn=await Promise.resolve().then(()=>(be(),me)));var En=typeof process<"u"&&process||{},ct=En.env&&"CI"in En.env,dt="\x1B[90m",xt="\x1B[91m",pt="\x1B[92m",ht="\x1B[93m",gt="\x1B[94m",mt="\x1B[95m",bt="\x1B[96m",yt="\x1B[97m",W="\x1B[0m",tn=class{constructor(t){this.stream=t,this.enabled=!!(this.stream&&this.stream.isTTY||ct)}gray(t){return this.enabled?dt+t+W:t}red(t){return this.enabled?xt+t+W:t}green(t){return this.enabled?pt+t+W:t}yellow(t){return this.enabled?ht+t+W:t}blue(t){return this.enabled?gt+t+W:t}magenta(t){return this.enabled?mt+t+W:t}cyan(t){return this.enabled?bt+t+W:t}white(t){return this.enabled?yt+t+W:t}},An=new tn(En.stdout),Lt=new tn(En.stderr);function Ft(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=[],f=0,c;t<n;)c=e[t++],c<128?o[f++]=c:c>191&&c<224?o[f++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,o[f++]=55296+(c>>10),o[f++]=56320+(c&1023)):o[f++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,f>=8192&&((s||(s=[])).push(String.fromCharCode(...o)),f=0);return s?(f&&s.push(String.fromCharCode(...o.slice(0,f))),s.join("")):String.fromCharCode(...o.slice(0,f))}function Et(e,t,n){for(var a=n,s=0,o=e.length;s<o;++s){let f=e.charCodeAt(s),c;f<128?t[n++]=f:f<2048?(t[n++]=f>>6|192,t[n++]=f&63|128):(f&64512)===55296&&s+1<o&&((c=e.charCodeAt(s+1))&64512)===56320?(f=65536+((f&1023)<<10)+(c&1023),++s,t[n++]=f>>18|240,t[n++]=f>>12&63|128,t[n++]=f>>6&63|128,t[n++]=f&63|128):(t[n++]=f>>12|224,t[n++]=f>>6&63|128,t[n++]=f&63|128)}return n-a}var _n={length:Ft,read:vt,write:Et};var ye=un.createRequire(import.meta.url);function ve(e,t,n=!0){var a={},s=[],o=[],f=[],c={};Object.keys(t).forEach(d=>{if(!d.startsWith(" ")){var g=t[d];g.alias!=null&&(typeof g.alias=="string"?c[g.alias]=d:Array.isArray(g.alias)&&g.alias.forEach(y=>c[y]=d)),n&&g.default!=null&&(a[d]=g.default)}});for(var p=0,b=(e=e.slice()).length;p<b;++p){let d=e[p];if(d=="--"){++p;break}let g=/^(?:(-\w)(?:=(.*))?|(--\w{2,})(?:=(.*))?)$/.exec(d),y,m;if(g)t[d]?y=t[m=d]:g[1]!=null?(y=t[m=c[g[1].substring(1)]],y&&g[2]!=null&&(e[p--]=g[2])):g[3]!=null&&(y=t[m=g[3].substring(2)],y&&g[4]!=null&&(e[p--]=g[4]));else if(d.charCodeAt(0)==45)y=t[m=d];else{o.push(d);continue}if(y)if(y.value)Object.keys(y.value).forEach(i=>a[i]=y.value[i]);else if(y.type==null||y.type==="b")a[m]=!0;else if(p+1<e.length&&e[p+1].charCodeAt(0)!=45)switch(y.type){case"i":a[m]=parseInt(e[++p],10);break;case"I":a[m]=(a[m]||[]).concat(parseInt(e[++p],10));break;case"f":a[m]=parseFloat(e[++p]);break;case"F":a[m]=(a[m]||[]).concat(parseFloat(e[++p]));break;case"s":a[m]=String(e[++p]);break;case"S":a[m]=(a[m]||[]).concat(e[++p].split(","));break;default:s.push(d),--p}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(d)}else s.push(d)}for(;p<b;)f.push(e[p++]);return n&&Mn(t,a),{options:a,unknown:s,arguments:o,trailing:f}}function Ee(e,t){t||(t={});var n=t.indent||2,a=t.padding||24,s=t.eol||`
8
+ `,o={},f=[];Object.keys(e).forEach(b=>{var d=e[b];if(d.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,d.alias&&(g+=", -"+d.alias);g.length<a;)g+=" ";var y;!t.noCategories&&d.category?(y=o[d.category])||(o[d.category]=y=[]):y=f,Array.isArray(d.description)?y.push(g+d.description[0]+d.description.slice(1).map(m=>{for(let i=0;i<a;++i)m=" "+m;return s+m}).join("")):y.push(g+d.description)}});var c=[],p=!1;return Object.keys(o).forEach(b=>{p=!0,c.push(s+" "+An.gray(b)+s),c.push(o[b].join(s))}),p&&f.length&&c.push(s+" "+An.gray("Other")+s),c.push(f.join(s)),c.join(s)}function Fe(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 Un(e,t,n,a){let s={};for(let[o,{type:f,mutuallyExclusive:c,isPath:p,useNodeResolution:b,cliOnly:d}]of Object.entries(e)){let g=Fe(t[o],f),y=Fe(n[o],f);if(g==null){if(y!=null){if(d)continue;if(Array.isArray(y)){let m;p&&(y=y.map(i=>rn(i,a,b))),c!=null&&(m=t[c])?s[o]=y.filter(i=>!m.includes(i)):s[o]=y.slice()}else p&&(y=rn(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(d){s[o]=g.slice();continue}let m;p&&(y=y.map(i=>rn(i,a,b))),c!=null&&(m=t[c])?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 At(e){let t=v.parse(e);return t.root||(t.root="./"),v.format(t)}function rn(e,t,n=!1){return v.isAbsolute(e)?e:n&&!e.startsWith(".")&&ye.resolve?ye.resolve(e,{paths:[t]}):At(v.join(t,e))}function Mn(e,t){for(let[n,{default:a}]of Object.entries(e))t[n]==null&&a!=null&&(t[n]=a)}var Ae="0.14.0",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},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},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"},compDir:{category:"Debugging",description:["The compile directory written as DWARF `DW_AT_comp_dir`, the base","every source path in the line table is relative to. Defaults to the","working directory. Resolved to an absolute path, as clang writes it.","Only used when DWARF is emitted (--debug with --sourceMap)."],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}}},_e="~lib/",Te={array:`/// <reference path="./rt/index.d.ts" />
9
9
 
10
10
  import { BLOCK_MAXSIZE } from "./rt/common";
11
11
  import { Runtime } from "shared/runtime";
@@ -20339,7 +20339,7 @@ function loadHex(src: usize, offset: usize): u32 {
20339
20339
  @final @unmanaged
20340
20340
  export abstract class V128 {
20341
20341
  }
20342
- `},Te={assembly:`/**
20342
+ `},Ce={assembly:`/**
20343
20343
  * Environment definitions for compiling TensionScript to WebAssembly using asc.
20344
20344
  * @module std/assembly
20345
20345
  *//***/
@@ -23524,7 +23524,7 @@ declare interface Float64Array {
23524
23524
  // FIXME: remove
23525
23525
  declare function offsetof<T>(fieldName?: string): usize;
23526
23526
  declare function idof<T>(): u32;
23527
- `};var pn={};nn(pn,{default:()=>hn});Dn(pn,Vt);import*as Vt from"binaryen";import{default as hn}from"binaryen";import*as Tt from"@yabgu_gm/tensionscript";var h=Tt,Pn=P.argv.indexOf("--wasm");if(~Pn){let e=String(P.argv[Pn+1]);P.argv.splice(Pn,2),h=await import(new URL(e,xn.pathToFileURL(P.cwd()+"/")))}var Vn=sn.createRequire(import.meta.url),Kn=P.platform==="win32",E=Kn?`\r
23527
+ `};var hn={};en(hn,{default:()=>gn});Dn(hn,Vt);import*as Vt from"binaryen";import{default as gn}from"binaryen";import*as Kn from"@yabgu_gm/tensionscript";var h=Kn,Pn=L.argv.indexOf("--wasm");if(~Pn){let e=String(L.argv[Pn+1]);L.argv.splice(Pn,2),h=await import(new URL(e,pn.pathToFileURL(L.cwd()+"/")))}var Vn=un.createRequire(import.meta.url),qn=L.platform==="win32",E=qn?`\r
23528
23528
  `:`
23529
- `,jn=Kn?"\\":"/",_=".ts",Ct=`.d${_}`,gn=new RegExp("\\"+_+"$"),zt=new RegExp("^(?!.*\\.d\\"+_+"$).*\\"+_+"$");function Ce(e){return e.replace(/-/g,"_").toUpperCase()}function Bt(e){return typeof e=="string"&&e!==""}var Xn=Ee,wt=Y,L=Ae,G=_e,St=Te,we=3,Se=0;function qn(e,t=[]){return Object.keys(e||{}).forEach(n=>{let r=e[n],s=Y[n];s&&s.type==="b"?r&&t.push(`--${n}`):Array.isArray(r)?r.forEach(o=>{t.push(`--${n}`,String(o))}):t.push(`--${n}`,String(r))}),t}async function Dt(e,t={}){typeof e=="string"&&(e={[`input${_}`]:e});let n=["--outFile","binary","--textFile","text"];qn(t,n);let r={},s=await De(n.concat(Object.keys(e)),{readFile:o=>Object.prototype.hasOwnProperty.call(e,o)?e[o]:null,writeFile:(o,f)=>{r[o]=f},listFiles:()=>[]});return Object.assign(s,r)}async function De(e,t){Array.isArray(e)||(e=qn(e)),t||(t={});let n=t.stats||new Cn,r=n.begin(),s=0,o=0,f=0,c=(Xn||"").split(".");c.length===3&&(o=parseInt(c[0])|0,s=parseInt(c[1])|0,f=parseInt(c[2])|0);let p=t.stdout||Hn(),b=t.stderr||Hn(),d=t.readFile||te,g=t.writeFile||ie,y=t.listFiles||re,m=Fe(e,Y,!1),a=m.options;e=m.arguments;let zn=new en(p),H=new en(b);a.noColors&&(zn.enabled=!1,H.enabled=!1);let Yn=m.unknown;Yn.length&&Yn.forEach(i=>{b.write(`${H.yellow("WARNING ")}Unknown option '${i}'${E}`)});let $n=m.trailing;$n.length&&b.write(`${H.yellow("WARNING ")}Unsupported trailing arguments: ${$n.join(" ")}${E}`);let K=null,R=null,B=(i,l={})=>(i&&b.write(`${H.red("FAILURE ")}${i.stack.replace(/^ERROR: /i,"")}${E}`),R&&R.dispose(),n.total||(n.total=n.end(r)),Object.assign({error:i,stdout:p,stderr:b,stats:n},l));if(a.version)return p.write(`Version ${Xn}${E}`),B(null);let w=v.normalize(a.baseDir||"."),q=tn(a.config||"asconfig.json",w),Bn=v.basename(q),$=v.dirname(q),N=await ze(Bn,$,d),Ie=N!=null&&Array.isArray(N.entries)&&N.entries.length;if(a.help||!e.length&&!Ie){let i=a.help?p:b,l=a.help?zn:H;return i.write([l.white("SYNTAX")," "+l.cyan("tensionscript")+" [entryFile ...] [options]","",l.white("EXAMPLES")," "+l.cyan("tensionscript")+" hello"+_," "+l.cyan("tensionscript")+" hello"+_+" -o hello.wasm -t hello.wat"," "+l.cyan("tensionscript")+" hello1"+_+" hello2"+_+" -o -O > hello.wasm"," "+l.cyan("tensionscript")+" --config asconfig.json --target release","",l.white("OPTIONS")].concat(ve(Y,24,E)).join(E)+E),B(null)}if(!(X.promises&&X.promises.readFile)){if(d===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 wn=new Set;wn.add(q);let ke=a.target||"release";for(;N;){if(N.targets){let l=N.targets[ke];l&&(a=Un(Y,a,l,$))}let i=N.options;if(i&&(a=Un(Y,a,i,$)),N.entries)for(let l of N.entries)e.push(tn(l,$));if(N.extends){if(q=tn(N.extends,$,!0),Bn=v.basename(q),$=v.dirname(q),wn.has(q))break;wn.add(q),N=await ze(Bn,$,d)}else break}if(Mn(Y,a),a.showConfig)return b.write(JSON.stringify({options:a,entries:e},null,2)),B(null);function Zn(i){return[...new Set(i)]}let z,ln,mn,T=h.newOptions();switch(a.runtime){case"stub":ln=0;break;case"minimal":ln=1;break;default:ln=2;break}switch(a.uncheckedBehavior){default:mn=0;break;case"never":mn=1;break;case"always":mn=2;break}if(h.setTarget(T,0),h.setDebugInfo(T,!!a.debug),h.setRuntime(T,ln),h.setNoAssert(T,a.noAssert),h.setExportMemory(T,!a.noExportMemory),h.setImportMemory(T,a.importMemory),h.setInitialMemory(T,a.initialMemory>>>0),h.setMaximumMemory(T,a.maximumMemory>>>0),h.setSharedMemory(T,a.sharedMemory),h.setImportTable(T,a.importTable),h.setExportTable(T,a.exportTable),a.exportStart!=null&&h.setExportStart(T,Bt(a.exportStart)?a.exportStart:"_start"),h.setMemoryBase(T,a.memoryBase>>>0),h.setTableBase(T,a.tableBase>>>0),h.setSourceMap(T,a.sourceMap!=null),h.setUncheckedBehavior(T,mn),h.setNoUnsafe(T,a.noUnsafe),h.setPedantic(T,a.pedantic),h.setLowMemoryLimit(T,a.lowMemoryLimit>>>0),h.setExportRuntime(T,a.exportRuntime),h.setBundleVersion(T,o,s,f),!a.stackSize&&ln===2&&(a.stackSize=h.DEFAULT_STACK_SIZE),h.setStackSize(T,a.stackSize),h.setBindingsHint(T,a.bindings&&a.bindings.length>0),a.use){let i=a.use;for(let l=0,u=i.length;l<u;++l){let x=i[l],A=x.indexOf("=");if(A<0)return B(Error(`Global alias '${x}' is invalid.`));let F=x.substring(0,A).trim(),C=x.substring(A+1).trim();if(!F.length)return B(Error(`Global alias '${x}' is invalid.`));h.addGlobalAlias(T,F,C)}}let U;if((U=a.disable)!=null){typeof U=="string"&&(U=U.split(","));for(let i=0,l=U.length;i<l;++i){let u=U[i].trim(),x=h[`FEATURE_${Ce(u)}`];if(!x)return B(Error(`Feature '${u}' is unknown.`));h.setFeature(T,x,!1)}}if((U=a.enable)!=null){typeof U=="string"&&(U=U.split(","));for(let i=0,l=U.length;i<l;++i){let u=U[i].trim(),x=h[`FEATURE_${Ce(u)}`];if(!x)return B(Error(`Feature '${u}' is unknown.`));h.setFeature(T,x,!0)}}let Z=0,J=0;a.optimize&&(Z=we,J=Se),typeof a.optimizeLevel=="number"&&(Z=a.optimizeLevel),typeof a.shrinkLevel=="number"&&(J=a.shrinkLevel),Z=Math.min(Math.max(Z,0),3),J=Math.min(Math.max(J,0),2),h.setOptimizeLevelHints(T,Z,J),z=h.newProgram(T);let Q=[];if(Array.isArray(t.transforms)&&Q.push(...t.transforms),a.transform){let i=Zn(a.transform);for(let l=0,u=i.length;l<u;++l){let x=i[l].trim(),A,F;if(Vn.resolve)try{A=Vn.resolve(x,{paths:[P.cwd(),w]}),F=await import(xn.pathToFileURL(A)),F.default&&(F=F.default)}catch(C){try{F=Vn(A)}catch{return B(C)}}else try{F=await import(new URL(x,import.meta.url)),F.default&&(F=F.default)}catch(C){return B(C)}if(!F||typeof F!="function"&&typeof F!="object")return B(Error("not a transform: "+i[l]));Q.push(F)}}Q.push({afterParse:()=>h.applyInTreeTransforms(z)});try{Q=Q.map(i=>(typeof i=="function"&&(Object.assign(i.prototype,{program:z,binaryen:hn,baseDir:w,stdout:p,stderr:b,log:console.error,readFile:d,writeFile:g,listFiles:y}),i=new i),i))}catch(i){return B(i)}async function Sn(i,...l){for(let u=0,x=Q.length;u<x;++u){let A=Q[u];if(typeof A[i]=="function")try{let F=n.begin();n.transformCount++,await A[i](...l),n.transformTime+=n.end(F)}catch(F){return F}}}let Oe=new Set(Object.keys(G));function Jn(i){let l=z.sources;if(l)for(let u=i,x=l.length;u<x;++u)z.stdSources.add(l[u])}Object.keys(G).forEach(i=>{if(i.includes("/"))return;let l=n.begin();n.parseCount++;let u=z.sources?z.sources.length:0;h.parse(z,G[i],L+i+_,!1),Jn(u),n.parseTime+=n.end(l)});let rn=[];if(a.lib){let i=a.lib;typeof i=="string"&&(i=i.split(",")),rn.push(...i.map(l=>l.trim())),rn=Zn(rn);for(let l=0,u=rn.length;l<u;++l){let x=rn[l],A;x.endsWith(_)?(A=[v.basename(x)],x=v.dirname(x)):A=await y(x,w)||[];for(let F of A){let C=await d(F,x);if(C==null)return B(Error(`Library file '${F}' not found.`));G[F.replace(gn,"")]=C;let I=n.begin();n.parseCount++,h.parse(z,C,L+F,!1),n.parseTime+=n.end(I)}}}a.path=a.path||[];let bn=new Map;async function Le(i,l){let u=null,x=null;if(!i.startsWith(L))(u=await d(x=i+_,w))==null&&(u=await d(x=i+"/index"+_,w))==null&&(x=i+_,u=await d(i+Ct,w));else{let A=i.substring(L.length),F=`${A}/index`;if(Object.prototype.hasOwnProperty.call(G,A))u=G[A],x=L+A+_;else if(Object.prototype.hasOwnProperty.call(G,F))u=G[F],x=L+F+_;else{for(let C of rn)if((u=await d(A+_,C))!=null){x=L+A+_;break}else if((u=await d(F+_,C))!=null){x=L+F+_;break}if(u==null){let C=i.match(/^~lib\/((?:@[^/]+\/)?[^/]+)(?:\/(.+))?/);if(C){let I=C[1],V=C[2]||"index",on=bn.has(l)?bn.get(l):".",M=[],D=v.resolve(w,on).split(jn);for(let S=D.length,k=Kn?1:0;S>=k;--S)D[S-1]!=="node_modules"&&M.push(`${D.slice(0,S).join(jn)}${jn}node_modules`);M.push(...a.path);for(let S of M.map(k=>v.relative(w,k))){let k=V;if((u=await d(v.join(S,I,k+_),w))!=null){x=`${L}${I}/${k}${_}`,bn.set(x.replace(gn,""),v.join(S,I));break}let fn=`${V}/index`;if((u=await d(v.join(S,I,fn+_),w))!=null){x=`${L}${I}/${fn}${_}`,bn.set(x.replace(gn,""),v.join(S,I));break}}}}}}return u==null?null:{sourceText:u,sourcePath:x}}function Re(i=[]){do{let l=h.nextFile(z);if(l==null)break;i.push(l)}while(!0);return i}async function Qn(){let i;for(;(i=Re()).length;){let u=[];for(let x of i){let A=h.getDependee(z,x);u.push(Le(x,A))}u=await Promise.all(u);for(let x=0,A=i.length;x<A;++x){let F=i[x],C=u[x],I=n.begin();n.parseCount++;let V=z.sources?z.sources.length:0;if(C){if(h.parse(z,C.sourceText,C.sourcePath,!1),F.startsWith(L)){let on=F.substring(L.length);Oe.has(on)&&Jn(V)}}else h.parse(z,null,F+_,!1);n.parseTime+=n.end(I)}}let l=Tn(z,b,a.disableWarning,t.reportDiagnostic,H.enabled);if(l){let u=Error(`${l} parse error(s)`);return u.stack=u.message,B(u)}}{let i=String(a.runtime),l=`rt/index-${i}`,u=G[l];if(u==null){if(l=i,u=await d(l+_,w),u==null)return B(Error(`Runtime '${v.resolve(w,l+_)}' is not found.`))}else l=`~lib/${l}`;let x=n.begin();n.parseCount++,h.parse(z,u,l+_,!0),n.parseTime+=n.end(x)}for(let i=0,l=e.length;i<l;++i){let u=String(e[i]),x=v.isAbsolute(u)?v.relative(w,u):v.normalize(u);x=x.replace(/\\/g,"/").replace(gn,"").replace(/\/$/,"");let A=await d(x+_,w);if(A==null){let C=`${x}/index${_}`;A=await d(C,w),A!=null?x=C:x+=_}else x+=_;let F=n.begin();n.parseCount++,h.parse(z,A,x,!0),n.parseTime+=n.end(F)}{let i=await Qn();if(i)return i}{let i=await Sn("afterParse",z.parser);if(i)return B(i)}{let i=await Qn();if(i)return i}{let i=n.begin();n.initializeCount++;try{h.initializeProgram(z)}catch(l){O("initialize",l)}n.initializeTime+=n.end(i)}{let i=await Sn("afterInitialize",z);if(i)return B(i)}{let i=n.begin();n.compileCount++;try{K=h.compile(z)}catch(l){O("compile",l)}n.compileTime+=n.end(i)}R=hn.wrapModule(typeof K=="number"||K instanceof Number?h.getBinaryenModuleRef(K):K.ref);let un=Tn(z,b,a.disableWarning,t.reportDiagnostic,H.enabled);if(un){let i=Error(`${un} compile error(s)`);return i.stack=i.message,B(i)}{let i=await Sn("afterCompile",R);if(i)return B(i)}if(un=Tn(z,b,a.disableWarning,t.reportDiagnostic,H.enabled),un){let i=Error(`${un} afterCompile error(s)`);return i.stack=i.message,B(i)}if(!a.noValidate){let i=n.begin();n.validateCount++;let l=h.validate(K);if(n.validateTime+=n.end(i),!l)return B(Error("validate error"))}if(a.trapMode==="clamp"||a.trapMode==="js"){let i=n.begin();try{R.runPasses([`trap-mode-${a.trapMode}`])}catch(l){O("runPasses",l)}n.compileTime+=n.end(i)}else if(a.trapMode!=="allow")return B(Error("Unsupported trap mode"));let ne=a.debug,Ne=a.converge,ee=a.importMemory?a.zeroFilledMemory:!1,yn=[];a.runPasses&&(typeof a.runPasses=="string"&&(a.runPasses=a.runPasses.split(",")),a.runPasses.length&&a.runPasses.forEach(i=>{yn.includes(i=i.trim())||yn.push(i)}));{let i=n.begin();try{n.optimizeCount++,h.optimize(K,Z,J,ne,ee)}catch(l){O("optimize",l)}try{R.runPasses(yn)}catch(l){O("runPasses",l)}if(Ne){let l;try{let u=n.begin();n.emitCount++,l=R.emitBinary(),n.emitTime+=n.end(u)}catch(u){O("emitBinary (converge)",u)}do{try{n.optimizeCount++,h.optimize(K,Z,J,ne,ee)}catch(x){O("optimize (converge)",x)}try{R.runPasses(yn)}catch(x){O("runPasses (converge)",x)}let u;try{let x=n.begin();n.emitCount++,u=R.emitBinary(),n.emitTime+=n.end(x)}catch(x){O("emitBinary (converge)",x)}if(u.length>=l.length){u.length>l.length&&b.write(`Last converge was suboptimal.${E}`);break}l=u}while(!0)}n.optimizeTime+=n.end(i)}let an=[];if(!a.noEmit){if(a.binaryFile)return B(Error("Usage of the --binaryFile compiler option is no longer supported. Use --outFile instead."));let i=a.bindings||[],l=!1,u=a.outFile!=null,x=a.textFile!=null,A=u||x,F=u&&a.outFile.length>0||x&&a.textFile.length>0,C=F?(a.outFile||a.textFile).replace(/\.\w+$/,""):null,I=F?v.basename(C):"output";if(h.setBasenameHint(T,I),a.outFile!=null){let M=a.sourceMap!=null?a.sourceMap.length?a.sourceMap:`./${I}.wasm.map`:null,D=n.begin();n.emitCount++;let S;try{S=R.emitBinary(M)}catch(k){O("emitBinary",k)}if(n.emitTime+=n.end(D),a.outFile.length?an.push(g(a.outFile,S.binary,w)):(l=!0,Fn(S.binary)),S.sourceMap!="")if(a.outFile.length){let k=JSON.parse(S.sourceMap);k.sourceRoot=`./${I}`;let fn=[];for(let vn=0,Ue=k.sources.length;vn<Ue;++vn){let ae=k.sources[vn],oe=h.getSource(z,ae.replace(gn,""));if(oe==null)return B(Error(`Source of file '${ae}' not found.`));fn[vn]=oe}k.sourcesContent=fn,an.push(g(v.join(v.dirname(a.outFile),v.basename(M)).replace(/^\.\//,""),JSON.stringify(k),w))}else b.write(`Skipped source map (no output path)${E}`)}if(a.textFile!=null||!A){let M=n.begin();n.emitCount++;let D;try{hn.setOptimizeStackIR(!0),D=a.textFile?.endsWith(".wast")?R.emitText():R.emitStackIR()}catch(S){O("emitText",S)}n.emitTime+=n.end(M),a.textFile!=null&&a.textFile.length?an.push(g(a.textFile,D,w)):l||Fn(D)}let V=i.includes("esm"),on=!V&&i.includes("raw");if(V||on)if(C){let M=n.begin();n.emitCount++;let D;try{D=h.buildTSD(z,V)}catch(S){O("buildTSD",S)}n.emitTime+=n.end(M),an.push(g(C+".d.ts",D,w))}else b.write(`Skipped TypeScript binding (no output path)${E}`);if(V||on)if(C){let M=n.begin();n.emitCount++;let D;try{D=h.buildJS(z,V)}catch(S){O("buildJS",S)}n.emitTime+=n.end(M),an.push(g(C+".js",D,w))}else b.write(`Skipped JavaScript binding (no output path)${E}`)}try{await Promise.all(an)}catch(i){return B(i)}return n.total=n.end(r),a.stats&&b.write(n.toString()),B(null);async function te(i,l){let u=v.resolve(l,i);try{return n.readCount++,await X.promises.readFile(u,"utf8")}catch{return null}}async function ie(i,l,u){try{n.writeCount++;let x=v.resolve(u,v.dirname(i)),A=v.join(x,v.basename(i));return await X.promises.mkdir(x,{recursive:!0}),await X.promises.writeFile(A,l),!0}catch{return!1}}async function re(i,l){try{return n.readCount++,(await X.promises.readdir(v.join(l,i))).filter(u=>zt.test(u))}catch{return null}}function Fn(i){Fn.used||(Fn.used=!0,n.writeCount++),p.write(i)}function O(i,l){let u=zn.red("\u258C ");console.error([E,u,"Whoops, the TensionScript compiler has crashed during ",i," :-(",E,u,E,(typeof l.stack=="string"?[u,"Here is the stack trace hinting at the problem, perhaps it's useful?",E,u,E,l.stack.replace(/^/mg,u),E]:[u,"There is no stack trace. Perhaps a Binaryen exception above / in console?",E,u,E,u,"> "+l.stack,E]).join(""),u,E,u,"If you see where the error is, feel free to send us a pull request. If not,",E,u,"please let us know: https://github.com/Yabgu/TensionScript/issues",E,u,E,u,"Thank you!",E].join("")),P.exit(1)}}function Gn(e){return Object.prototype.toString.call(e)==="[object Object]"}async function ze(e,t,n){let r=await n(e,t),s=v.join(t,e);if(!r)return null;let o;try{o=JSON.parse(r)}catch(f){throw new Error(`Asconfig is not valid json: ${s}`,{cause:f})}if(o.options&&!Gn(o.options))throw new Error(`Asconfig.options is not an object: ${s}`);if(o.include&&!Array.isArray(o.include))throw new Error(`Asconfig.include is not an array: ${s}`);if(o.targets){if(!Gn(o.targets))throw new Error(`Asconfig.targets is not an object: ${s}`);let f=Object.keys(o.targets);for(let c=0;c<f.length;c++){let p=f[c];if(!Gn(o.targets[p]))throw new Error(`Asconfig.targets.${p} is not an object: ${s}`)}}if(o.extends&&typeof o.extends!="string")throw new Error(`Asconfig.extends is not a string: ${s}`);return o}function Tn(e,t,n,r,s){typeof s>"u"&&t&&(s=t.isTTY);let o=0;do{let p=h.nextDiagnostic(e);if(!p)break;if(t){let b=d=>{if(n==null)return!1;if(!n.length)return!0;let g=h.getDiagnosticCode(d);return n.includes(g)};(h.isError(p)||!b(p))&&t.write(h.formatDiagnostic(p,s,!0)+E+E)}if(r){let b=function(g){return g&&{start:h.getRangeStart(g),end:h.getRangeEnd(g),source:d(h.getRangeSource(g))}||null},d=function(g){return g&&{normalizedPath:h.getSourceNormalizedPath(g)}||null};var f=b,c=d;r({message:h.getDiagnosticMessage(p),code:h.getDiagnosticCode(p),category:h.getDiagnosticCategory(p),range:b(h.getDiagnosticRange(p)),relatedRange:b(h.getDiagnosticRelatedRange(p))})}h.isError(p)&&++o}while(!0);return o}var Cn=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)),r=n.map(m=>t(this[`${m}Time`])),s=n.map(m=>this[`${m}Count`].toString()),o=n.reduce((m,a)=>Math.max(a.length,m),0),f=r.reduce((m,a)=>Math.max(a.length,m),0),c=s.reduce((m,a)=>Math.max(a.length,m),0),p=o+f+c+6,b=[];b.push(`\u256D\u2500${"\u2500".repeat(p)}\u2500\u256E${E}`);let d="Stats";b.push(`\u2502 ${d}${" ".repeat(p-d.length)} \u2502${E}`),b.push(`\u255E\u2550${"\u2550".repeat(o)}\u2550\u2564\u2550${"\u2550".repeat(f)}\u2550\u2564\u2550${"\u2550".repeat(c)}\u2550\u2561${E}`);for(let m=0,a=n.length;m<a;++m)b.push(`\u2502 ${n[m].padEnd(o)} \u2502 ${r[m].padStart(f)} \u2502 ${s[m].padStart(c)} \u2502${E}`);b.push(`\u251C\u2500${"\u2500".repeat(o)}\u2500\u2534\u2500${"\u2500".repeat(f)}\u2500\u2534\u2500${"\u2500".repeat(c)}\u2500\u2524${E}`);let g=`Took ${t(this.total)}`;b.push(`\u2502 ${g}${" ".repeat(p-g.length)} \u2502${E}`);let y=`${this.readCount} reads, ${this.writeCount} writes`;return b.push(`\u2502 ${y}${" ".repeat(p-y.length)} \u2502${E}`),b.push(`\u2570\u2500${"\u2500".repeat(p)}\u2500\u256F${E}`),b.join("")}},Be=typeof global<"u"&&global.Buffer?global.Buffer.allocUnsafe||(e=>new global.Buffer(e)):e=>new Uint8Array(e);function Hn(e){let t=[];return t.write=function(n){if(e&&e(n),typeof n=="string"){let r=Be(_n.length(n));_n.write(n,r,0),n=r}this.push(n)},t.reset=function(){t.length=0},t.toBuffer=function(){let n=0,r=0,s=this.length;for(;r<s;)n+=this[r++].length;let o=Be(n);for(n=r=0;r<s;)o.set(this[r],n),n+=this[r].length,++r;return o},t.toString=function(){let n=this.toBuffer();return _n.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{Cn as Stats,Tn as checkDiagnostics,Dt as compileString,qn as configToArguments,Hn as createMemoryStream,Wn as default,we as defaultOptimizeLevel,Se as defaultShrinkLevel,St as definitionFiles,G as libraryFiles,L as libraryPrefix,De as main,wt as options,It as tscOptions,Xn as version};
23529
+ `,jn=qn?"\\":"/",_=".ts",Ct=`.d${_}`,mn=new RegExp("\\"+_+"$"),zt=new RegExp("^(?!.*\\.d\\"+_+"$).*\\"+_+"$");function ze(e){return e.replace(/-/g,"_").toUpperCase()}function Bt(e){return typeof e=="string"&&e!==""}var Xn=Ae,wt=Y,R=_e,G=Te,St=Ce,Se=3,De=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 Ie(n.concat(Object.keys(e)),{readFile:o=>Object.prototype.hasOwnProperty.call(e,o)?e[o]:null,writeFile:(o,f)=>{a[o]=f},listFiles:()=>[]});return Object.assign(s,a)}async function Ie(e,t){Array.isArray(e)||(e=Wn(e)),t||(t={});let n=t.stats||new Cn,a=n.begin(),s=0,o=0,f=0,c=(Xn||"").split(".");c.length===3&&(o=parseInt(c[0])|0,s=parseInt(c[1])|0,f=parseInt(c[2])|0);let p=t.stdout||Hn(),b=t.stderr||Hn(),d=t.readFile||ie,g=t.writeFile||re,y=t.listFiles||ae,m=ve(e,Y,!1),i=m.options;e=m.arguments;let zn=new tn(p),X=new tn(b);i.noColors&&(zn.enabled=!1,X.enabled=!1);let $n=m.unknown;$n.length&&$n.forEach(r=>{b.write(`${X.yellow("WARNING ")}Unknown option '${r}'${E}`)});let Zn=m.trailing;Zn.length&&b.write(`${X.yellow("WARNING ")}Unsupported trailing arguments: ${Zn.join(" ")}${E}`);let K=null,N=null,B=(r,l={})=>(r&&b.write(`${X.red("FAILURE ")}${r.stack.replace(/^ERROR: /i,"")}${E}`),N&&N.dispose(),n.total||(n.total=n.end(a)),Object.assign({error:r,stdout:p,stderr:b,stats:n},l));if(i.version)return p.write(`Version ${Xn}${E}`),B(null);let S=v.normalize(i.baseDir||"."),q=rn(i.config||"asconfig.json",S),Bn=v.basename(q),$=v.dirname(q),U=await Be(Bn,$,d),ke=U!=null&&Array.isArray(U.entries)&&U.entries.length;if(i.help||!e.length&&!ke){let r=i.help?p:b,l=i.help?zn:X;return r.write([l.white("SYNTAX")," "+l.cyan("tensionscript")+" [entryFile ...] [options]","",l.white("EXAMPLES")," "+l.cyan("tensionscript")+" hello"+_," "+l.cyan("tensionscript")+" hello"+_+" -o hello.wasm -t hello.wat"," "+l.cyan("tensionscript")+" hello1"+_+" hello2"+_+" -o -O > hello.wasm"," "+l.cyan("tensionscript")+" --config asconfig.json --target release","",l.white("OPTIONS")].concat(Ee(Y,24,E)).join(E)+E),B(null)}if(!(H.promises&&H.promises.readFile)){if(d===ie)throw Error("'options.readFile' must be specified");if(g===re)throw Error("'options.writeFile' must be specified");if(y===ae)throw Error("'options.listFiles' must be specified")}let wn=new Set;wn.add(q);let Oe=i.target||"release";for(;U;){if(U.targets){let l=U.targets[Oe];l&&(i=Un(Y,i,l,$))}let r=U.options;if(r&&(i=Un(Y,i,r,$)),U.entries)for(let l of U.entries)e.push(rn(l,$));if(U.extends){if(q=rn(U.extends,$,!0),Bn=v.basename(q),$=v.dirname(q),wn.has(q))break;wn.add(q),U=await Be(Bn,$,d)}else break}if(Mn(Y,i),i.showConfig)return b.write(JSON.stringify({options:i,entries:e},null,2)),B(null);function Jn(r){return[...new Set(r)]}let z,fn,bn,T=h.newOptions();switch(i.runtime){case"stub":fn=0;break;case"minimal":fn=1;break;default:fn=2;break}switch(i.uncheckedBehavior){default:bn=0;break;case"never":bn=1;break;case"always":bn=2;break}if(h.setTarget(T,0),h.setDebugInfo(T,!!i.debug),h.setRuntime(T,fn),h.setNoAssert(T,i.noAssert),h.setExportMemory(T,!i.noExportMemory),h.setImportMemory(T,i.importMemory),h.setInitialMemory(T,i.initialMemory>>>0),h.setMaximumMemory(T,i.maximumMemory>>>0),h.setSharedMemory(T,i.sharedMemory),h.setImportTable(T,i.importTable),h.setExportTable(T,i.exportTable),i.exportStart!=null&&h.setExportStart(T,Bt(i.exportStart)?i.exportStart:"_start"),h.setMemoryBase(T,i.memoryBase>>>0),h.setTableBase(T,i.tableBase>>>0),h.setSourceMap(T,i.sourceMap!=null),h.setUncheckedBehavior(T,bn),h.setNoUnsafe(T,i.noUnsafe),h.setPedantic(T,i.pedantic),h.setLowMemoryLimit(T,i.lowMemoryLimit>>>0),h.setExportRuntime(T,i.exportRuntime),h.setBundleVersion(T,o,s,f),!i.stackSize&&fn===2&&(i.stackSize=h.DEFAULT_STACK_SIZE),h.setStackSize(T,i.stackSize),h.setBindingsHint(T,i.bindings&&i.bindings.length>0),i.use){let r=i.use;for(let l=0,u=r.length;l<u;++l){let x=r[l],A=x.indexOf("=");if(A<0)return B(Error(`Global alias '${x}' is invalid.`));let F=x.substring(0,A).trim(),C=x.substring(A+1).trim();if(!F.length)return B(Error(`Global alias '${x}' is invalid.`));h.addGlobalAlias(T,F,C)}}let M;if((M=i.disable)!=null){typeof M=="string"&&(M=M.split(","));for(let r=0,l=M.length;r<l;++r){let u=M[r].trim(),x=h[`FEATURE_${ze(u)}`];if(!x)return B(Error(`Feature '${u}' is unknown.`));h.setFeature(T,x,!1)}}if((M=i.enable)!=null){typeof M=="string"&&(M=M.split(","));for(let r=0,l=M.length;r<l;++r){let u=M[r].trim(),x=h[`FEATURE_${ze(u)}`];if(!x)return B(Error(`Feature '${u}' is unknown.`));h.setFeature(T,x,!0)}}let Z=0,J=0;i.optimize&&(Z=Se,J=De),typeof i.optimizeLevel=="number"&&(Z=i.optimizeLevel),typeof i.shrinkLevel=="number"&&(J=i.shrinkLevel),Z=Math.min(Math.max(Z,0),3),J=Math.min(Math.max(J,0),2),h.setOptimizeLevelHints(T,Z,J),z=h.newProgram(T);let Q=[];if(Array.isArray(t.transforms)&&Q.push(...t.transforms),i.transform){let r=Jn(i.transform);for(let l=0,u=r.length;l<u;++l){let x=r[l].trim(),A,F;if(Vn.resolve)try{A=Vn.resolve(x,{paths:[L.cwd(),S]}),F=await import(pn.pathToFileURL(A)),F.default&&(F=F.default)}catch(C){try{F=Vn(A)}catch{return B(C)}}else try{F=await import(new URL(x,import.meta.url)),F.default&&(F=F.default)}catch(C){return B(C)}if(!F||typeof F!="function"&&typeof F!="object")return B(Error("not a transform: "+r[l]));Q.push(F)}}Q.push({afterParse:()=>h.applyInTreeTransforms(z)});try{Q=Q.map(r=>(typeof r=="function"&&(Object.assign(r.prototype,{program:z,binaryen:gn,baseDir:S,stdout:p,stderr:b,log:console.error,readFile:d,writeFile:g,listFiles:y}),r=new r),r))}catch(r){return B(r)}async function Sn(r,...l){for(let u=0,x=Q.length;u<x;++u){let A=Q[u];if(typeof A[r]=="function")try{let F=n.begin();n.transformCount++,await A[r](...l),n.transformTime+=n.end(F)}catch(F){return F}}}let Le=new Set(Object.keys(G));function Qn(r){let l=z.sources;if(l)for(let u=r,x=l.length;u<x;++u)z.stdSources.add(l[u])}Object.keys(G).forEach(r=>{if(r.includes("/"))return;let l=n.begin();n.parseCount++;let u=z.sources?z.sources.length:0;h.parse(z,G[r],R+r+_,!1),Qn(u),n.parseTime+=n.end(l)});let an=[];if(i.lib){let r=i.lib;typeof r=="string"&&(r=r.split(",")),an.push(...r.map(l=>l.trim())),an=Jn(an);for(let l=0,u=an.length;l<u;++l){let x=an[l],A;x.endsWith(_)?(A=[v.basename(x)],x=v.dirname(x)):A=await y(x,S)||[];for(let F of A){let C=await d(F,x);if(C==null)return B(Error(`Library file '${F}' not found.`));G[F.replace(mn,"")]=C;let k=n.begin();n.parseCount++,h.parse(z,C,R+F,!1),n.parseTime+=n.end(k)}}}i.path=i.path||[];let yn=new Map;async function Re(r,l){let u=null,x=null;if(!r.startsWith(R))(u=await d(x=r+_,S))==null&&(u=await d(x=r+"/index"+_,S))==null&&(x=r+_,u=await d(r+Ct,S));else{let A=r.substring(R.length),F=`${A}/index`;if(Object.prototype.hasOwnProperty.call(G,A))u=G[A],x=R+A+_;else if(Object.prototype.hasOwnProperty.call(G,F))u=G[F],x=R+F+_;else{for(let C of an)if((u=await d(A+_,C))!=null){x=R+A+_;break}else if((u=await d(F+_,C))!=null){x=R+F+_;break}if(u==null){let C=r.match(/^~lib\/((?:@[^/]+\/)?[^/]+)(?:\/(.+))?/);if(C){let k=C[1],V=C[2]||"index",sn=yn.has(l)?yn.get(l):".",P=[],I=v.resolve(S,sn).split(jn);for(let w=I.length,D=qn?1:0;w>=D;--w)I[w-1]!=="node_modules"&&P.push(`${I.slice(0,w).join(jn)}${jn}node_modules`);P.push(...i.path);for(let w of P.map(D=>v.relative(S,D))){let D=V;if((u=await d(v.join(w,k,D+_),S))!=null){x=`${R}${k}/${D}${_}`,yn.set(x.replace(mn,""),v.join(w,k));break}let nn=`${V}/index`;if((u=await d(v.join(w,k,nn+_),S))!=null){x=`${R}${k}/${nn}${_}`,yn.set(x.replace(mn,""),v.join(w,k));break}}}}}}return u==null?null:{sourceText:u,sourcePath:x}}function Ne(r=[]){do{let l=h.nextFile(z);if(l==null)break;r.push(l)}while(!0);return r}async function ne(){let r;for(;(r=Ne()).length;){let u=[];for(let x of r){let A=h.getDependee(z,x);u.push(Re(x,A))}u=await Promise.all(u);for(let x=0,A=r.length;x<A;++x){let F=r[x],C=u[x],k=n.begin();n.parseCount++;let V=z.sources?z.sources.length:0;if(C){if(h.parse(z,C.sourceText,C.sourcePath,!1),F.startsWith(R)){let sn=F.substring(R.length);Le.has(sn)&&Qn(V)}}else h.parse(z,null,F+_,!1);n.parseTime+=n.end(k)}}let l=Tn(z,b,i.disableWarning,t.reportDiagnostic,X.enabled);if(l){let u=Error(`${l} parse error(s)`);return u.stack=u.message,B(u)}}{let r=String(i.runtime),l=`rt/index-${r}`,u=G[l];if(u==null){if(l=r,u=await d(l+_,S),u==null)return B(Error(`Runtime '${v.resolve(S,l+_)}' is not found.`))}else l=`~lib/${l}`;let x=n.begin();n.parseCount++,h.parse(z,u,l+_,!0),n.parseTime+=n.end(x)}for(let r=0,l=e.length;r<l;++r){let u=String(e[r]),x=v.isAbsolute(u)?v.relative(S,u):v.normalize(u);x=x.replace(/\\/g,"/").replace(mn,"").replace(/\/$/,"");let A=await d(x+_,S);if(A==null){let C=`${x}/index${_}`;A=await d(C,S),A!=null?x=C:x+=_}else x+=_;let F=n.begin();n.parseCount++,h.parse(z,A,x,!0),n.parseTime+=n.end(F)}{let r=await ne();if(r)return r}{let r=await Sn("afterParse",z.parser);if(r)return B(r)}{let r=await ne();if(r)return r}{let r=n.begin();n.initializeCount++;try{h.initializeProgram(z)}catch(l){O("initialize",l)}n.initializeTime+=n.end(r)}{let r=await Sn("afterInitialize",z);if(r)return B(r)}{let r=n.begin();n.compileCount++;try{K=h.compile(z)}catch(l){O("compile",l)}n.compileTime+=n.end(r)}N=gn.wrapModule(typeof K=="number"||K instanceof Number?h.getBinaryenModuleRef(K):K.ref);let cn=Tn(z,b,i.disableWarning,t.reportDiagnostic,X.enabled);if(cn){let r=Error(`${cn} compile error(s)`);return r.stack=r.message,B(r)}{let r=await Sn("afterCompile",N);if(r)return B(r)}if(cn=Tn(z,b,i.disableWarning,t.reportDiagnostic,X.enabled),cn){let r=Error(`${cn} afterCompile error(s)`);return r.stack=r.message,B(r)}if(!i.noValidate){let r=n.begin();n.validateCount++;let l=h.validate(K);if(n.validateTime+=n.end(r),!l)return B(Error("validate error"))}if(i.trapMode==="clamp"||i.trapMode==="js"){let r=n.begin();try{N.runPasses([`trap-mode-${i.trapMode}`])}catch(l){O("runPasses",l)}n.compileTime+=n.end(r)}else if(i.trapMode!=="allow")return B(Error("Unsupported trap mode"));let ee=i.debug,Ue=i.converge,te=i.importMemory?i.zeroFilledMemory:!1,Fn=[];i.runPasses&&(typeof i.runPasses=="string"&&(i.runPasses=i.runPasses.split(",")),i.runPasses.length&&i.runPasses.forEach(r=>{Fn.includes(r=r.trim())||Fn.push(r)}));{let r=n.begin();try{n.optimizeCount++,h.optimize(K,Z,J,ee,te)}catch(l){O("optimize",l)}try{N.runPasses(Fn)}catch(l){O("runPasses",l)}if(Ue){let l;try{let u=n.begin();n.emitCount++,l=N.emitBinary(),n.emitTime+=n.end(u)}catch(u){O("emitBinary (converge)",u)}do{try{n.optimizeCount++,h.optimize(K,Z,J,ee,te)}catch(x){O("optimize (converge)",x)}try{N.runPasses(Fn)}catch(x){O("runPasses (converge)",x)}let u;try{let x=n.begin();n.emitCount++,u=N.emitBinary(),n.emitTime+=n.end(x)}catch(x){O("emitBinary (converge)",x)}if(u.length>=l.length){u.length>l.length&&b.write(`Last converge was suboptimal.${E}`);break}l=u}while(!0)}n.optimizeTime+=n.end(r)}let on=[];if(!i.noEmit){if(i.binaryFile)return B(Error("Usage of the --binaryFile compiler option is no longer supported. Use --outFile instead."));let r=i.bindings||[],l=!1,u=i.outFile!=null,x=i.textFile!=null,A=u||x,F=u&&i.outFile.length>0||x&&i.textFile.length>0,C=F?(i.outFile||i.textFile).replace(/\.\w+$/,""):null,k=F?v.basename(C):"output";if(h.setBasenameHint(T,k),i.outFile!=null){let P=i.sourceMap!=null?i.sourceMap.length?i.sourceMap:`./${k}.wasm.map`:null,I=n.begin();n.emitCount++;let w;try{w=N.emitBinary(P)}catch(D){O("emitBinary",D)}if(n.emitTime+=n.end(I),i.debug&&i.sourceMap!=null&&w.sourceMap){let D=i.outFile.length?v.basename(i.outFile):"guest.wasm",nn=i.compDir!=null&&i.compDir.length?v.resolve(S,i.compDir):L.cwd();try{w.binary=Kn.synthesizeDwarf(w.binary,w.sourceMap,nn,D)}catch(ln){b.write(`${X.yellow("WARNING ")}DWARF emission failed: ${ln.message}${E}`)}}if(i.outFile.length?on.push(g(i.outFile,w.binary,S)):(l=!0,vn(w.binary)),w.sourceMap!="")if(i.outFile.length){let D=JSON.parse(w.sourceMap);D.sourceRoot=`./${k}`;let nn=[];for(let ln=0,Me=D.sources.length;ln<Me;++ln){let oe=D.sources[ln],se=h.getSource(z,oe.replace(mn,""));if(se==null)return B(Error(`Source of file '${oe}' not found.`));nn[ln]=se}D.sourcesContent=nn,on.push(g(v.join(v.dirname(i.outFile),v.basename(P)).replace(/^\.\//,""),JSON.stringify(D),S))}else b.write(`Skipped source map (no output path)${E}`)}if(i.textFile!=null||!A){let P=n.begin();n.emitCount++;let I;try{gn.setOptimizeStackIR(!0),I=i.textFile?.endsWith(".wast")?N.emitText():N.emitStackIR()}catch(w){O("emitText",w)}n.emitTime+=n.end(P),i.textFile!=null&&i.textFile.length?on.push(g(i.textFile,I,S)):l||vn(I)}let V=r.includes("esm"),sn=!V&&r.includes("raw");if(V||sn)if(C){let P=n.begin();n.emitCount++;let I;try{I=h.buildTSD(z,V)}catch(w){O("buildTSD",w)}n.emitTime+=n.end(P),on.push(g(C+".d.ts",I,S))}else b.write(`Skipped TypeScript binding (no output path)${E}`);if(V||sn)if(C){let P=n.begin();n.emitCount++;let I;try{I=h.buildJS(z,V)}catch(w){O("buildJS",w)}n.emitTime+=n.end(P),on.push(g(C+".js",I,S))}else b.write(`Skipped JavaScript binding (no output path)${E}`)}try{await Promise.all(on)}catch(r){return B(r)}return n.total=n.end(a),i.stats&&b.write(n.toString()),B(null);async function ie(r,l){let u=v.resolve(l,r);try{return n.readCount++,await H.promises.readFile(u,"utf8")}catch{return null}}async function re(r,l,u){try{n.writeCount++;let x=v.resolve(u,v.dirname(r)),A=v.join(x,v.basename(r));return await H.promises.mkdir(x,{recursive:!0}),await H.promises.writeFile(A,l),!0}catch{return!1}}async function ae(r,l){try{return n.readCount++,(await H.promises.readdir(v.join(l,r))).filter(u=>zt.test(u))}catch{return null}}function vn(r){vn.used||(vn.used=!0,n.writeCount++),p.write(r)}function O(r,l){let u=zn.red("\u258C ");console.error([E,u,"Whoops, the TensionScript compiler has crashed during ",r," :-(",E,u,E,(typeof l.stack=="string"?[u,"Here is the stack trace hinting at the problem, perhaps it's useful?",E,u,E,l.stack.replace(/^/mg,u),E]:[u,"There is no stack trace. Perhaps a Binaryen exception above / in console?",E,u,E,u,"> "+l.stack,E]).join(""),u,E,u,"If you see where the error is, feel free to send us a pull request. If not,",E,u,"please let us know: https://github.com/Yabgu/TensionScript/issues",E,u,E,u,"Thank you!",E].join("")),L.exit(1)}}function Gn(e){return Object.prototype.toString.call(e)==="[object Object]"}async function Be(e,t,n){let a=await n(e,t),s=v.join(t,e);if(!a)return null;let o;try{o=JSON.parse(a)}catch(f){throw new Error(`Asconfig is not valid json: ${s}`,{cause:f})}if(o.options&&!Gn(o.options))throw new Error(`Asconfig.options is not an object: ${s}`);if(o.include&&!Array.isArray(o.include))throw new Error(`Asconfig.include is not an array: ${s}`);if(o.targets){if(!Gn(o.targets))throw new Error(`Asconfig.targets is not an object: ${s}`);let f=Object.keys(o.targets);for(let c=0;c<f.length;c++){let p=f[c];if(!Gn(o.targets[p]))throw new Error(`Asconfig.targets.${p} is not an object: ${s}`)}}if(o.extends&&typeof o.extends!="string")throw new Error(`Asconfig.extends is not a string: ${s}`);return o}function Tn(e,t,n,a,s){typeof s>"u"&&t&&(s=t.isTTY);let o=0;do{let p=h.nextDiagnostic(e);if(!p)break;if(t){let b=d=>{if(n==null)return!1;if(!n.length)return!0;let g=h.getDiagnosticCode(d);return n.includes(g)};(h.isError(p)||!b(p))&&t.write(h.formatDiagnostic(p,s,!0)+E+E)}if(a){let b=function(g){return g&&{start:h.getRangeStart(g),end:h.getRangeEnd(g),source:d(h.getRangeSource(g))}||null},d=function(g){return g&&{normalizedPath:h.getSourceNormalizedPath(g)}||null};var f=b,c=d;a({message:h.getDiagnosticMessage(p),code:h.getDiagnosticCode(p),category:h.getDiagnosticCategory(p),range:b(h.getDiagnosticRange(p)),relatedRange:b(h.getDiagnosticRelatedRange(p))})}h.isError(p)&&++o}while(!0);return o}var Cn=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 L.hrtime()}end(t){let n=L.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),f=a.reduce((m,i)=>Math.max(i.length,m),0),c=s.reduce((m,i)=>Math.max(i.length,m),0),p=o+f+c+6,b=[];b.push(`\u256D\u2500${"\u2500".repeat(p)}\u2500\u256E${E}`);let d="Stats";b.push(`\u2502 ${d}${" ".repeat(p-d.length)} \u2502${E}`),b.push(`\u255E\u2550${"\u2550".repeat(o)}\u2550\u2564\u2550${"\u2550".repeat(f)}\u2550\u2564\u2550${"\u2550".repeat(c)}\u2550\u2561${E}`);for(let m=0,i=n.length;m<i;++m)b.push(`\u2502 ${n[m].padEnd(o)} \u2502 ${a[m].padStart(f)} \u2502 ${s[m].padStart(c)} \u2502${E}`);b.push(`\u251C\u2500${"\u2500".repeat(o)}\u2500\u2534\u2500${"\u2500".repeat(f)}\u2500\u2534\u2500${"\u2500".repeat(c)}\u2500\u2524${E}`);let g=`Took ${t(this.total)}`;b.push(`\u2502 ${g}${" ".repeat(p-g.length)} \u2502${E}`);let y=`${this.readCount} reads, ${this.writeCount} writes`;return b.push(`\u2502 ${y}${" ".repeat(p-y.length)} \u2502${E}`),b.push(`\u2570\u2500${"\u2500".repeat(p)}\u2500\u256F${E}`),b.join("")}},we=typeof global<"u"&&global.Buffer?global.Buffer.allocUnsafe||(e=>new global.Buffer(e)):e=>new Uint8Array(e);function Hn(e){let t=[];return t.write=function(n){if(e&&e(n),typeof n=="string"){let a=we(_n.length(n));_n.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=we(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 _n.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{Cn as Stats,Tn as checkDiagnostics,Dt as compileString,Wn as configToArguments,Hn as createMemoryStream,Yn as default,Se as defaultOptimizeLevel,De as defaultShrinkLevel,St as definitionFiles,G as libraryFiles,R as libraryPrefix,Ie as main,wt as options,It as tscOptions,Xn as version};
23530
23530
  //# sourceMappingURL=asc.js.map