@tailwindcss/oxide-wasm32-wasi 0.0.0-insiders.d801d8d

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.
Files changed (113) hide show
  1. package/README.md +3 -0
  2. package/node_modules/@emnapi/core/LICENSE +21 -0
  3. package/node_modules/@emnapi/core/README.md +1 -0
  4. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +6661 -0
  5. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +363 -0
  6. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -0
  7. package/node_modules/@emnapi/core/dist/emnapi-core.d.mts +363 -0
  8. package/node_modules/@emnapi/core/dist/emnapi-core.d.ts +365 -0
  9. package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +7411 -0
  10. package/node_modules/@emnapi/core/dist/emnapi-core.js +8390 -0
  11. package/node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +363 -0
  12. package/node_modules/@emnapi/core/dist/emnapi-core.min.js +1 -0
  13. package/node_modules/@emnapi/core/dist/emnapi-core.min.mjs +1 -0
  14. package/node_modules/@emnapi/core/dist/emnapi-core.mjs +6650 -0
  15. package/node_modules/@emnapi/core/index.js +5 -0
  16. package/node_modules/@emnapi/core/package.json +49 -0
  17. package/node_modules/@emnapi/runtime/LICENSE +21 -0
  18. package/node_modules/@emnapi/runtime/README.md +1 -0
  19. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +1347 -0
  20. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +663 -0
  21. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -0
  22. package/node_modules/@emnapi/runtime/dist/emnapi.d.mts +663 -0
  23. package/node_modules/@emnapi/runtime/dist/emnapi.d.ts +665 -0
  24. package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +1403 -0
  25. package/node_modules/@emnapi/runtime/dist/emnapi.iife.d.ts +420 -0
  26. package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +1474 -0
  27. package/node_modules/@emnapi/runtime/dist/emnapi.js +1475 -0
  28. package/node_modules/@emnapi/runtime/dist/emnapi.min.d.mts +663 -0
  29. package/node_modules/@emnapi/runtime/dist/emnapi.min.js +1 -0
  30. package/node_modules/@emnapi/runtime/dist/emnapi.min.mjs +1 -0
  31. package/node_modules/@emnapi/runtime/dist/emnapi.mjs +1316 -0
  32. package/node_modules/@emnapi/runtime/index.js +5 -0
  33. package/node_modules/@emnapi/runtime/package.json +48 -0
  34. package/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
  35. package/node_modules/@emnapi/wasi-threads/README.md +203 -0
  36. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +881 -0
  37. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +214 -0
  38. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -0
  39. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.mts +214 -0
  40. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +216 -0
  41. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +929 -0
  42. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +941 -0
  43. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +214 -0
  44. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -0
  45. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -0
  46. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +876 -0
  47. package/node_modules/@emnapi/wasi-threads/index.js +5 -0
  48. package/node_modules/@emnapi/wasi-threads/package.json +50 -0
  49. package/node_modules/@napi-rs/wasm-runtime/LICENSE +43 -0
  50. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +23712 -0
  51. package/node_modules/@napi-rs/wasm-runtime/dist/runtime.js +12269 -0
  52. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.cjs +193 -0
  53. package/node_modules/@napi-rs/wasm-runtime/package.json +60 -0
  54. package/node_modules/@napi-rs/wasm-runtime/runtime.cjs +15 -0
  55. package/node_modules/@tybys/wasm-util/README.md +193 -0
  56. package/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
  57. package/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +417 -0
  58. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2738 -0
  59. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2738 -0
  60. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
  61. package/node_modules/@tybys/wasm-util/dist/wasm-util.js +2760 -0
  62. package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
  63. package/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
  64. package/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
  65. package/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
  66. package/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
  67. package/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
  68. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
  69. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
  70. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
  71. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +194 -0
  72. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +174 -0
  73. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1544 -0
  74. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
  75. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
  76. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
  77. package/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
  78. package/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
  79. package/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
  80. package/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
  81. package/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
  82. package/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
  83. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
  84. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
  85. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
  86. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +188 -0
  87. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +168 -0
  88. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1539 -0
  89. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
  90. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
  91. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
  92. package/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
  93. package/node_modules/@tybys/wasm-util/package.json +58 -0
  94. package/node_modules/tslib/CopyrightNotice.txt +15 -0
  95. package/node_modules/tslib/LICENSE.txt +12 -0
  96. package/node_modules/tslib/README.md +164 -0
  97. package/node_modules/tslib/SECURITY.md +41 -0
  98. package/node_modules/tslib/modules/index.d.ts +38 -0
  99. package/node_modules/tslib/modules/index.js +70 -0
  100. package/node_modules/tslib/modules/package.json +3 -0
  101. package/node_modules/tslib/package.json +47 -0
  102. package/node_modules/tslib/tslib.d.ts +460 -0
  103. package/node_modules/tslib/tslib.es6.html +1 -0
  104. package/node_modules/tslib/tslib.es6.js +393 -0
  105. package/node_modules/tslib/tslib.es6.mjs +392 -0
  106. package/node_modules/tslib/tslib.html +1 -0
  107. package/node_modules/tslib/tslib.js +475 -0
  108. package/package.json +45 -0
  109. package/tailwindcss-oxide.wasi-browser.js +63 -0
  110. package/tailwindcss-oxide.wasi.cjs +88 -0
  111. package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
  112. package/wasi-worker-browser.mjs +39 -0
  113. package/wasi-worker.mjs +63 -0
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).wasmUtil={})}(this,(function(t){"use strict";const e="undefined"!=typeof WebAssembly?WebAssembly:"undefined"!=typeof WXWebAssembly?WXWebAssembly:void 0;if(!e)throw new Error("WebAssembly is not supported in this environment");function n(t,e){if(null===t||"object"!=typeof t)throw new TypeError(`${e} must be an object. Received ${null===t?"null":typeof t}`)}function r(t,e){if("string"!=typeof t)throw new TypeError(`${e} must be a string. Received ${null===t?"null":typeof t}`)}function i(t,e){if("function"!=typeof t)throw new TypeError(`${e} must be a function. Received ${null===t?"null":typeof t}`)}function s(t,e){if(void 0!==t)throw new TypeError(`${e} must be undefined. Received ${null===t?"null":typeof t}`)}function o(t){return!(!t||"object"!=typeof t&&"function"!=typeof t||"function"!=typeof t.then)}function a(t,e){const n=Object.create(null);return Object.keys(t).forEach((r=>{const i=t[r];Object.defineProperty(n,r,{enumerable:!0,value:e(i,r)})})),n}function c(t,e,n){return"function"==typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer||"[object SharedArrayBuffer]"===Object.prototype.toString.call(t.buffer.constructor)?t.slice(e,n):t.subarray(e,n)}const u=["asyncify_get_state","asyncify_start_rewind","asyncify_start_unwind","asyncify_stop_rewind","asyncify_stop_unwind"];function f(t,e,n,r){if("function"!=typeof t.exports[r]||n<=0)return{wasm64:e,dataPtr:16,start:e?32:24,end:1024};const i=t.exports[r],s=e?Number(i(BigInt(16)+BigInt(n))):i(8+n);if(0===s)throw new Error("Allocate asyncify data failed");return e?{wasm64:e,dataPtr:s,start:s+16,end:s+16+n}:{wasm64:e,dataPtr:s,start:s+8,end:s+8+n}}class h{constructor(){this.value=void 0,this.exports=void 0,this.dataPtr=0}init(t,n,r){var i,s;if(this.exports)throw new Error("Asyncify has been initialized");if(!(t instanceof e.Memory))throw new TypeError("Require WebAssembly.Memory object");const o=n.exports;for(let t=0;t<u.length;++t)if("function"!=typeof o[u[t]])throw new TypeError("Invalid asyncify wasm");let a;const c=Boolean(r.wasm64);a=r.tryAllocate?!0===r.tryAllocate?f(n,c,4096,"malloc"):f(n,c,null!==(i=r.tryAllocate.size)&&void 0!==i?i:4096,null!==(s=r.tryAllocate.name)&&void 0!==s?s:"malloc"):{wasm64:c,dataPtr:16,start:c?32:24,end:1024},this.dataPtr=a.dataPtr,c?new BigInt64Array(t.buffer,this.dataPtr).set([BigInt(a.start),BigInt(a.end)]):new Int32Array(t.buffer,this.dataPtr).set([a.start,a.end]),this.exports=this.wrapExports(o,r.wrapExports);const h=Object.create(e.Instance.prototype);return Object.defineProperty(h,"exports",{value:this.exports}),h}assertState(){if(0!==this.exports.asyncify_get_state())throw new Error("Asyncify state error")}wrapImportFunction(t){const e=this;return function(){for(;2===e.exports.asyncify_get_state();)return e.exports.asyncify_stop_rewind(),e.value;e.assertState();const n=t.apply(this,arguments);if(!o(n))return n;e.exports.asyncify_start_unwind(e.dataPtr),e.value=n}}wrapImports(t){const e={};return Object.keys(t).forEach((n=>{const r=t[n],i={};Object.keys(r).forEach((t=>{const e=r[t];i[t]="function"==typeof e?this.wrapImportFunction(e):e})),e[n]=i})),e}wrapExportFunction(t){const e=this;return async function(){e.assertState();let n=t.apply(this,arguments);for(;1===e.exports.asyncify_get_state();)e.exports.asyncify_stop_unwind(),e.value=await e.value,e.assertState(),e.exports.asyncify_start_rewind(e.dataPtr),n=t.call(this);return e.assertState(),n}}wrapExports(t,e){return a(t,((t,n)=>{let r=-1!==u.indexOf(n)||"function"!=typeof t;return Array.isArray(e)&&(r=r||-1===e.indexOf(n)),r?t:this.wrapExportFunction(t)}))}}function d(t){if(t&&"object"!=typeof t)throw new TypeError("imports must be an object or undefined")}function g(t,n){return"undefined"!=typeof wx&&"undefined"!=typeof __wxConfig?e.instantiate(t,n):fetch(t).then((t=>t.arrayBuffer())).then((t=>e.instantiate(t,n)))}function l(t,n){let r;if(d(n),n=null!=n?n:{},t instanceof ArrayBuffer||ArrayBuffer.isView(t))return e.instantiate(t,n);if(t instanceof e.Module)return e.instantiate(t,n).then((e=>({instance:e,module:t})));if("string"!=typeof t&&!(t instanceof URL))throw new TypeError("Invalid source");if("function"==typeof e.instantiateStreaming){let i;try{i=fetch(t),r=e.instantiateStreaming(i,n).catch((()=>g(t,n)))}catch(e){r=g(t,n)}}else r=g(t,n);return r}function _(t,n){let r;if(d(n),n=null!=n?n:{},t instanceof ArrayBuffer||ArrayBuffer.isView(t))r=new e.Module(t);else{if(!(t instanceof WebAssembly.Module))throw new TypeError("Invalid source");r=t}return{instance:new e.Instance(r,n),module:r}}const y=46,p=47;function E(t){return t===p}function I(...t){let e="",n=!1;for(let i=t.length-1;i>=-1&&!n;i--){const s=i>=0?t[i]:"/";r(s,"path"),0!==s.length&&(e=`${s}/${e}`,n=s.charCodeAt(0)===p)}return e=function(t,e,n,r){let i="",s=0,o=-1,a=0,c=0;for(let u=0;u<=t.length;++u){if(u<t.length)c=t.charCodeAt(u);else{if(r(c))break;c=p}if(r(c)){if(o===u-1||1===a);else if(2===a){if(i.length<2||2!==s||i.charCodeAt(i.length-1)!==y||i.charCodeAt(i.length-2)!==y){if(i.length>2){const t=i.indexOf(n);-1===t?(i="",s=0):(i=i.slice(0,t),s=i.length-1-i.indexOf(n)),o=u,a=0;continue}if(0!==i.length){i="",s=0,o=u,a=0;continue}}e&&(i+=i.length>0?`${n}..`:"..",s=2)}else i.length>0?i+=`${n}${t.slice(o+1,u)}`:i=t.slice(o+1,u),s=u-o-1;o=u,a=0}else c===y&&-1!==a?++a:a=-1}return i}(e,!n,"/",E),n?`/${e}`:e.length>0?e:"."}const m={FD_DATASYNC:BigInt(1)<<BigInt(0),FD_READ:BigInt(1)<<BigInt(1),FD_SEEK:BigInt(1)<<BigInt(2),FD_FDSTAT_SET_FLAGS:BigInt(1)<<BigInt(3),FD_SYNC:BigInt(1)<<BigInt(4),FD_TELL:BigInt(1)<<BigInt(5),FD_WRITE:BigInt(1)<<BigInt(6),FD_ADVISE:BigInt(1)<<BigInt(7),FD_ALLOCATE:BigInt(1)<<BigInt(8),PATH_CREATE_DIRECTORY:BigInt(1)<<BigInt(9),PATH_CREATE_FILE:BigInt(1)<<BigInt(10),PATH_LINK_SOURCE:BigInt(1)<<BigInt(11),PATH_LINK_TARGET:BigInt(1)<<BigInt(12),PATH_OPEN:BigInt(1)<<BigInt(13),FD_READDIR:BigInt(1)<<BigInt(14),PATH_READLINK:BigInt(1)<<BigInt(15),PATH_RENAME_SOURCE:BigInt(1)<<BigInt(16),PATH_RENAME_TARGET:BigInt(1)<<BigInt(17),PATH_FILESTAT_GET:BigInt(1)<<BigInt(18),PATH_FILESTAT_SET_SIZE:BigInt(1)<<BigInt(19),PATH_FILESTAT_SET_TIMES:BigInt(1)<<BigInt(20),FD_FILESTAT_GET:BigInt(1)<<BigInt(21),FD_FILESTAT_SET_SIZE:BigInt(1)<<BigInt(22),FD_FILESTAT_SET_TIMES:BigInt(1)<<BigInt(23),PATH_SYMLINK:BigInt(1)<<BigInt(24),PATH_REMOVE_DIRECTORY:BigInt(1)<<BigInt(25),PATH_UNLINK_FILE:BigInt(1)<<BigInt(26),POLL_FD_READWRITE:BigInt(1)<<BigInt(27),SOCK_SHUTDOWN:BigInt(1)<<BigInt(28),SOCK_ACCEPT:BigInt(1)<<BigInt(29)};class A extends Error{constructor(t,e){super(t),this.errno=e}getErrorMessage(){return function(t){switch(t){case 0:return"Success";case 1:return"Argument list too long";case 2:return"Permission denied";case 3:return"Address in use";case 4:return"Address not available";case 5:return"Address family not supported by protocol";case 6:return"Resource temporarily unavailable";case 7:return"Operation already in progress";case 8:return"Bad file descriptor";case 9:return"Bad message";case 10:return"Resource busy";case 11:return"Operation canceled";case 12:return"No child process";case 13:return"Connection aborted";case 14:return"Connection refused";case 15:return"Connection reset by peer";case 16:return"Resource deadlock would occur";case 17:return"Destination address required";case 18:return"Domain error";case 19:return"Quota exceeded";case 20:return"File exists";case 21:return"Bad address";case 22:return"File too large";case 23:return"Host is unreachable";case 24:return"Identifier removed";case 25:return"Illegal byte sequence";case 26:return"Operation in progress";case 27:return"Interrupted system call";case 28:return"Invalid argument";case 29:return"I/O error";case 30:return"Socket is connected";case 31:return"Is a directory";case 32:return"Symbolic link loop";case 33:return"No file descriptors available";case 34:return"Too many links";case 35:return"Message too large";case 36:return"Multihop attempted";case 37:return"Filename too long";case 38:return"Network is down";case 39:return"Connection reset by network";case 40:return"Network unreachable";case 41:return"Too many files open in system";case 42:return"No buffer space available";case 43:return"No such device";case 44:return"No such file or directory";case 45:return"Exec format error";case 46:return"No locks available";case 47:return"Link has been severed";case 48:return"Out of memory";case 49:return"No message of the desired type";case 50:return"Protocol not available";case 51:return"No space left on device";case 52:return"Function not implemented";case 53:return"Socket not connected";case 54:return"Not a directory";case 55:return"Directory not empty";case 56:return"State not recoverable";case 57:return"Not a socket";case 58:return"Not supported";case 59:return"Not a tty";case 60:return"No such device or address";case 61:return"Value too large for data type";case 62:return"Previous owner died";case 63:return"Operation not permitted";case 64:return"Broken pipe";case 65:return"Protocol error";case 66:return"Protocol not supported";case 67:return"Protocol wrong type for socket";case 68:return"Result not representable";case 69:return"Read-only file system";case 70:return"Invalid seek";case 71:return"No such process";case 72:return"Stale file handle";case 73:return"Operation timed out";case 74:return"Text file busy";case 75:return"Cross-device link";case 76:return"Capabilities insufficient";default:return"Unknown error"}}(this.errno)}}Object.defineProperty(A.prototype,"name",{configurable:!0,writable:!0,value:"WasiError"});const b=m.FD_DATASYNC|m.FD_READ|m.FD_SEEK|m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_TELL|m.FD_WRITE|m.FD_ADVISE|m.FD_ALLOCATE|m.PATH_CREATE_DIRECTORY|m.PATH_CREATE_FILE|m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET|m.PATH_OPEN|m.FD_READDIR|m.PATH_READLINK|m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET|m.PATH_FILESTAT_GET|m.PATH_FILESTAT_SET_SIZE|m.PATH_FILESTAT_SET_TIMES|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_TIMES|m.FD_FILESTAT_SET_SIZE|m.PATH_SYMLINK|m.PATH_UNLINK_FILE|m.PATH_REMOVE_DIRECTORY|m.POLL_FD_READWRITE|m.SOCK_SHUTDOWN|m.SOCK_ACCEPT,T=b,w=b,B=b,N=b,S=m.FD_DATASYNC|m.FD_READ|m.FD_SEEK|m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_TELL|m.FD_WRITE|m.FD_ADVISE|m.FD_ALLOCATE|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_SIZE|m.FD_FILESTAT_SET_TIMES|m.POLL_FD_READWRITE,P=BigInt(0),D=m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_ADVISE|m.PATH_CREATE_DIRECTORY|m.PATH_CREATE_FILE|m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET|m.PATH_OPEN|m.FD_READDIR|m.PATH_READLINK|m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET|m.PATH_FILESTAT_GET|m.PATH_FILESTAT_SET_SIZE|m.PATH_FILESTAT_SET_TIMES|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_TIMES|m.PATH_SYMLINK|m.PATH_UNLINK_FILE|m.PATH_REMOVE_DIRECTORY|m.POLL_FD_READWRITE,F=D|S,U=m.FD_READ|m.FD_FDSTAT_SET_FLAGS|m.FD_WRITE|m.FD_FILESTAT_GET|m.POLL_FD_READWRITE|m.SOCK_SHUTDOWN,v=b,R=m.FD_READ|m.FD_FDSTAT_SET_FLAGS|m.FD_WRITE|m.FD_FILESTAT_GET|m.POLL_FD_READWRITE,L=BigInt(0);function H(t,e,n,r){const i={base:BigInt(0),inheriting:BigInt(0)};if(0===r)throw new A("Unknown file type",28);switch(r){case 4:i.base=S,i.inheriting=P;break;case 3:i.base=D,i.inheriting=F;break;case 6:case 5:i.base=U,i.inheriting=v;break;case 2:-1!==t.indexOf(e)?(i.base=R,i.inheriting=L):(i.base=B,i.inheriting=N);break;case 1:i.base=T,i.inheriting=w;break;default:i.base=BigInt(0),i.inheriting=BigInt(0)}const s=3&n;return 0===s?i.base&=~m.FD_WRITE:1===s&&(i.base&=~m.FD_READ),i}function O(t,e){let n=0;if("number"==typeof e&&e>=0)n=e;else for(let e=0;e<t.length;e++){n+=t[e].length}let r=0;const i=new Uint8Array(n);for(let e=0;e<t.length;e++){const n=t[e];i.set(n,r),r+=n.length}return i}class k{constructor(t,e,n,r,i,s,o,a){this.id=t,this.fd=e,this.path=n,this.realPath=r,this.type=i,this.rightsBase=s,this.rightsInheriting=o,this.preopen=a,this.pos=BigInt(0),this.size=BigInt(0)}seek(t,e){if(0===e)this.pos=BigInt(t);else if(1===e)this.pos+=BigInt(t);else{if(2!==e)throw new A("Unknown whence",29);this.pos=BigInt(this.size)-BigInt(t)}return this.pos}}class C extends k{constructor(t,e,n,r,i,s,o,a,c){super(e,n,r,i,s,o,a,c),this._log=t,this._buf=null}write(t){const e=t;if(this._buf&&(t=O([this._buf,t]),this._buf=null),-1===t.indexOf(10))return this._buf=t,e.byteLength;let n,r=0,i=0;for(;-1!==(n=t.indexOf(10,r));){const e=(new TextDecoder).decode(t.subarray(i,n));this._log(e),r+=n-i+1,i=n+1}return r<t.length&&(this._buf=t.slice(r)),e.byteLength}}function x(t){return t.isBlockDevice()?1:t.isCharacterDevice()?2:t.isDirectory()?3:t.isSocket()?6:t.isFile()?4:t.isSymbolicLink()?7:0}function M(t,e,n){t.setBigUint64(e,n.dev,!0),t.setBigUint64(e+8,n.ino,!0),t.setBigUint64(e+16,BigInt(x(n)),!0),t.setBigUint64(e+24,n.nlink,!0),t.setBigUint64(e+32,n.size,!0),t.setBigUint64(e+40,n.atimeMs*BigInt(1e6),!0),t.setBigUint64(e+48,n.mtimeMs*BigInt(1e6),!0),t.setBigUint64(e+56,n.ctimeMs*BigInt(1e6),!0)}class W{constructor(t){this.used=0,this.size=t.size,this.fds=Array(t.size),this.stdio=[t.in,t.out,t.err],this.print=t.print,this.printErr=t.printErr,this.insertStdio(t.in,0,"<stdin>"),this.insertStdio(t.out,1,"<stdout>"),this.insertStdio(t.err,2,"<stderr>")}insertStdio(t,e,n){const{base:r,inheriting:i}=H(this.stdio,t,2,2),s=this.insert(t,n,n,2,r,i,0);if(s.id!==e)throw new A(`id: ${s.id} !== expected: ${e}`,8);return s}insert(t,e,n,r,i,s,o){var a,c;let u,f=-1;if(this.used>=this.size){const t=2*this.size;this.fds.length=t,f=this.size,this.size=t}else for(let t=0;t<this.size;++t)if(null==this.fds[t]){f=t;break}return u="<stdout>"===e?new C(null!==(a=this.print)&&void 0!==a?a:console.log,f,t,e,n,r,i,s,o):"<stderr>"===e?new C(null!==(c=this.printErr)&&void 0!==c?c:console.error,f,t,e,n,r,i,s,o):new k(f,t,e,n,r,i,s,o),this.fds[f]=u,this.used++,u}get(t,e,n){if(t>=this.size)throw new A("Invalid fd",8);const r=this.fds[t];if(!r||r.id!==t)throw new A("Bad file descriptor",8);if((~r.rightsBase&e)!==BigInt(0)||(~r.rightsInheriting&n)!==BigInt(0))throw new A("Capabilities insufficient",76);return r}remove(t){if(t>=this.size)throw new A("Invalid fd",8);const e=this.fds[t];if(!e||e.id!==t)throw new A("Bad file descriptor",8);this.fds[t]=void 0,this.used--}}class K extends W{constructor(t){super(t),this.fs=t.fs}getFileTypeByFd(t){return x(this.fs.fstatSync(t,{bigint:!0}))}insertPreopen(t,e,n){const r=this.getFileTypeByFd(t);if(3!==r)throw new A(`Preopen not dir: ["${e}", "${n}"]`,54);const i=H(this.stdio,t,0,r);return this.insert(t,e,n,r,i.base,i.inheriting,1)}renumber(t,e){if(t===e)return;if(t>=this.size||e>=this.size)throw new A("Invalid fd",8);const n=this.fds[t],r=this.fds[e];if(!n||!r||n.id!==t||r.id!==e)throw new A("Invalid fd",8);this.fs.closeSync(n.fd),this.fds[t]=this.fds[e],this.fds[t].id=t,this.fds[e]=void 0,this.used--}}class z extends W{constructor(t){super(t)}async getFileTypeByFd(t){return x(await t.stat({bigint:!0}))}async insertPreopen(t,e,n){const r=await this.getFileTypeByFd(t);if(3!==r)throw new A(`Preopen not dir: ["${e}", "${n}"]`,54);const i=H(this.stdio,t.fd,0,r);return this.insert(t,e,n,r,i.base,i.inheriting,1)}async renumber(t,e){if(t===e)return;if(t>=this.size||e>=this.size)throw new A("Invalid fd",8);const n=this.fds[t],r=this.fds[e];if(!n||!r||n.id!==t||r.id!==e)throw new A("Invalid fd",8);await n.fd.close(),this.fds[t]=this.fds[e],this.fds[t].id=t,this.fds[e]=void 0,this.used--}}const j=function(){return e.Memory}();class G extends j{constructor(t){super(t)}get HEAP8(){return new Int8Array(super.buffer)}get HEAPU8(){return new Uint8Array(super.buffer)}get HEAP16(){return new Int16Array(super.buffer)}get HEAPU16(){return new Uint16Array(super.buffer)}get HEAP32(){return new Int32Array(super.buffer)}get HEAPU32(){return new Uint32Array(super.buffer)}get HEAP64(){return new BigInt64Array(super.buffer)}get HEAPU64(){return new BigUint64Array(super.buffer)}get HEAPF32(){return new Float32Array(super.buffer)}get HEAPF64(){return new Float64Array(super.buffer)}get view(){return new DataView(super.buffer)}}function Y(t){return Object.getPrototypeOf(t)===e.Memory.prototype&&Object.setPrototypeOf(t,G.prototype),t}function $(){const t=e.Function;if("function"!=typeof t)throw new Error('WebAssembly.Function is not supported in this environment. If you are using V8 based browser like Chrome, try to specify --js-flags="--wasm-staging --experimental-wasm-stack-switching"');return t}function V(t,e,n){const r=$();if("function"!=typeof t)throw new TypeError("Function required");const i=e.slice(0);return i.unshift("externref"),new r({parameters:i,results:n},t,{suspending:"first"})}function Z(t){const e=$();if("function"!=typeof t)throw new TypeError("Function required");return new e({parameters:[...e.type(t).parameters.slice(1)],results:["externref"]},t,{promising:"first"})}function q(t,e){if(0===t.length||0===e.length)return 0;let n=0,r=e.length-n;for(let i=0;i<t.length;++i){const s=t[i];if(r<s.length)return s.set(e.subarray(n,n+r),0),n+=r,r=0,n;s.set(e.subarray(n,n+s.length),0),n+=s.length,r-=s.length}return n}const X=new WeakMap,Q=new WeakMap,J=new WeakMap;function tt(t){return X.get(t)}function et(t){const e=J.get(t);if(!e)throw new Error("filesystem is unavailable");return e}function nt(t){if(t instanceof A)return t.errno;switch(t.code){case"ENOENT":return 44;case"EBADF":return 8;case"EINVAL":return 28;case"EPERM":return 63;case"EPROTO":return 65;case"EEXIST":return 20;case"ENOTDIR":return 54;case"EMFILE":return 33;case"EACCES":return 2;case"EISDIR":return 31;case"ENOTEMPTY":return 55;case"ENOSYS":return 52}throw t}function rt(t,e,n){return function(t,e){return Object.defineProperty(e,"name",{value:t}),e}(e,(function(){let e;try{e=n.apply(t,arguments)}catch(t){return nt(t)}return o(e)?e.then((t=>t),nt):e}))}function it(t,e,n,r){let i=I(e.realPath,n);if(1==(1&r))try{i=t.readlinkSync(i)}catch(t){if("EINVAL"!==t.code&&"ENOENT"!==t.code)throw t}return i}async function st(t,e,n,r){let i=I(e.realPath,n);if(1==(1&r))try{i=await t.promises.readlink(i)}catch(t){if("EINVAL"!==t.code&&"ENOENT"!==t.code)throw t}return i}const ot=new TextEncoder,at=new TextDecoder,ct=(BigInt(1)<<BigInt(63))-BigInt(1);function ut(){const t=window.prompt();if(null===t)return new Uint8Array;return(new TextEncoder).encode(t+"\n")}function ft(t){return Boolean(-16&t)||3==(3&t)||12==(12&t)}class ht{constructor(t,n,r,i,s,o){this.args_get=rt(this,"args_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{HEAPU8:n,view:r}=tt(this),i=Q.get(this).args;for(let s=0;s<i.length;++s){const o=i[s];r.setInt32(t,e,!0),t+=4;const a=ot.encode(o+"\0");n.set(a,e),e+=a.length}return 0})),this.args_sizes_get=rt(this,"args_sizes_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{view:n}=tt(this),r=Q.get(this).args;return n.setUint32(t,r.length,!0),n.setUint32(e,ot.encode(r.join("\0")+"\0").length,!0),0})),this.environ_get=rt(this,"environ_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{HEAPU8:n,view:r}=tt(this),i=Q.get(this).env;for(let s=0;s<i.length;++s){const o=i[s];r.setInt32(t,e,!0),t+=4;const a=ot.encode(o+"\0");n.set(a,e),e+=a.length}return 0})),this.environ_sizes_get=rt(this,"environ_sizes_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{view:n}=tt(this),r=Q.get(this);return n.setUint32(t,r.env.length,!0),n.setUint32(e,ot.encode(r.env.join("\0")+"\0").length,!0),0})),this.clock_res_get=rt(this,"clock_res_get",(function(t,e){if(0===(e=Number(e)))return 28;const{view:n}=tt(this);switch(t){case 0:return n.setBigUint64(e,BigInt(1e6),!0),0;case 1:case 2:case 3:return n.setBigUint64(e,BigInt(1e3),!0),0;default:return 28}})),this.clock_time_get=rt(this,"clock_time_get",(function(t,e,n){if(0===(n=Number(n)))return 28;const{view:r}=tt(this);switch(t){case 0:return r.setBigUint64(n,BigInt(Date.now())*BigInt(1e6),!0),0;case 1:case 2:case 3:{const t=performance.now(),e=Math.trunc(t),i=Math.floor(1e3*(t-e)),s=BigInt(e)*BigInt(1e9)+BigInt(i)*BigInt(1e6);return r.setBigUint64(n,s,!0),0}default:return 28}})),this.fd_advise=rt(this,"fd_advise",(function(t,e,n,r){return 52})),this.fd_fdstat_get=rt(this,"fd_fdstat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,BigInt(0),BigInt(0)),{view:r}=tt(this);return r.setUint16(e,n.type,!0),r.setUint16(e+2,0,!0),r.setBigUint64(e+8,n.rightsBase,!0),r.setBigUint64(e+16,n.rightsInheriting,!0),0})),this.fd_fdstat_set_flags=rt(this,"fd_fdstat_set_flags",(function(t,e){return 52})),this.fd_fdstat_set_rights=rt(this,"fd_fdstat_set_rights",(function(t,e,n){const r=Q.get(this).fds.get(t,BigInt(0),BigInt(0));return(e|r.rightsBase)>r.rightsBase||(n|r.rightsInheriting)>r.rightsInheriting?76:(r.rightsBase=e,r.rightsInheriting=n,0)})),this.fd_prestat_get=rt(this,"fd_prestat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this);let r;try{r=n.fds.get(t,BigInt(0),BigInt(0))}catch(t){if(t instanceof A)return t.errno;throw t}if(1!==r.preopen)return 28;const{view:i}=tt(this);return i.setUint32(e,0,!0),i.setUint32(e+4,ot.encode(r.path).length,!0),0})),this.fd_prestat_dir_name=rt(this,"fd_prestat_dir_name",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const r=Q.get(this).fds.get(t,BigInt(0),BigInt(0));if(1!==r.preopen)return 8;const i=ot.encode(r.path);if(i.length>n)return 42;const{HEAPU8:s}=tt(this);return s.set(i,e),0})),this.fd_seek=rt(this,"fd_seek",(function(t,e,n,r){if(0===(r=Number(r)))return 28;if(0===t||1===t||2===t)return 0;const i=Q.get(this).fds.get(t,m.FD_SEEK,BigInt(0)).seek(e,n),{view:s}=tt(this);return s.setBigUint64(r,i,!0),0})),this.fd_tell=rt(this,"fd_tell",(function(t,e){const n=Q.get(this).fds.get(t,m.FD_TELL,BigInt(0)),r=BigInt(n.pos),{view:i}=tt(this);return i.setBigUint64(Number(e),r,!0),0})),this.poll_oneoff=rt(this,"poll_oneoff",(function(t,e,n,r){if(t=Number(t),e=Number(e),r=Number(r),n=Number(n),n>>>=0,0===t||0===e||0===n||0===r)return 28;const{view:i}=tt(this);i.setUint32(r,0,!0);let s,o=0,a=BigInt(0),c=BigInt(0),u=0,f=BigInt(0);const h=Array(n);for(o=0;o<n;o++){s=t+48*o;const e=i.getBigUint64(s,!0),n=i.getUint8(s+8),r=i.getUint32(s+16,!0),a=i.getBigUint64(s+24,!0),c=i.getBigUint64(s+32,!0),u=i.getUint16(s+40,!0);h[o]={userdata:e,type:n,u:{clock:{clock_id:r,timeout:a,precision:c,flags:u},fd_readwrite:{fd:r}}}}const d=[];for(o=0;o<n;o++)switch(s=h[o],s.type){case 0:if(1===s.u.clock.flags){const t=BigInt(Date.now())*BigInt(1e6);c=s.u.clock.timeout-t}else c=s.u.clock.timeout;(0===u||c<f)&&(f=c,a=s.userdata,u=1);break;case 1:case 2:d.push(s);break;default:return 28}if(d.length>0){for(o=0;o<d.length;o++){const t=d[o],n=e+32*o;i.setBigUint64(n,t.userdata,!0),i.setUint32(n+8,52,!0),i.setUint32(n+12,t.type,!0),i.setBigUint64(n+16,BigInt(0),!0),i.setUint16(n+24,0,!0),i.setUint32(r,1,!0)}return i.setUint32(r,d.length,!0),0}if(u){!function(t,e){const n=Date.now()+t;let r=!1;for(;Date.now()<n;)if(e()){r=!0;break}}(Number(f/BigInt(1e6)),(()=>!1));const t=e;i.setBigUint64(t,a,!0),i.setUint32(t+8,0,!0),i.setUint32(t+12,0,!0),i.setUint32(r,1,!0)}return 0})),this.proc_exit=rt(this,"proc_exit",(function(t){return"object"==typeof process&&null!==process&&"function"==typeof process.exit&&process.exit(t),0})),this.proc_raise=rt(this,"proc_raise",(function(t){return 52})),this.sched_yield=rt(this,"sched_yield",(function(){return 0})),this.random_get="undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues?rt(this,"random_get",(function(t,e){if(0===(t=Number(t)))return 28;e=Number(e);const{HEAPU8:n,view:r}=tt(this);if("function"==typeof SharedArrayBuffer&&n.buffer instanceof SharedArrayBuffer||"[object SharedArrayBuffer]"===Object.prototype.toString.call(n.buffer)){for(let n=t;n<t+e;++n)r.setUint8(n,Math.floor(256*Math.random()));return 0}let i;const s=65536;for(i=0;i+s<e;i+=s)crypto.getRandomValues(n.subarray(t+i,t+i+s));return crypto.getRandomValues(n.subarray(t+i,t+e)),0})):rt(this,"random_get",(function(t,e){if(0===(t=Number(t)))return 28;e=Number(e);const{view:n}=tt(this);for(let r=t;r<t+e;++r)n.setUint8(r,Math.floor(256*Math.random()));return 0})),this.sock_recv=rt(this,"sock_recv",(function(){return 58})),this.sock_send=rt(this,"sock_send",(function(){return 58})),this.sock_shutdown=rt(this,"sock_shutdown",(function(){return 58})),this.sock_accept=rt(this,"sock_accept",(function(){return 58})),Q.set(this,{fds:r,args:t,env:n}),s&&J.set(this,s);const a=this;function u(t,e,n,r,s){a[t]=i?o?o.wrapImportFunction(rt(a,t,n)):V(rt(a,t,n),r,s):rt(a,t,e)}function f(t,e,n,r){const i=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_TIMES,BigInt(0));return 2==(2&r)&&(e=BigInt(1e6*Date.now())),8==(8&r)&&(n=BigInt(1e6*Date.now())),{fileDescriptor:i,atim:e,mtim:n}}function h(t,e,n,r){const i=(e&(m.FD_READ|m.FD_READDIR))!==BigInt(0),s=(e&(m.FD_DATASYNC|m.FD_WRITE|m.FD_ALLOCATE|m.FD_FILESTAT_SET_SIZE))!==BigInt(0);let o=s?i?2:1:0,a=m.PATH_OPEN,c=e|n;return 0!=(1&t)&&(o|=64,a|=m.PATH_CREATE_FILE),0!=(2&t)&&(o|=65536),0!=(4&t)&&(o|=128),0!=(8&t)&&(o|=512,a|=m.PATH_FILESTAT_SET_SIZE),0!=(1&r)&&(o|=1024),0!=(2&r)&&(c|=m.FD_DATASYNC),0!=(4&r)&&(o|=2048),0!=(8&r)&&(o|=1052672,c|=m.FD_SYNC),0!=(16&r)&&(o|=1052672,c|=m.FD_SYNC),s&&0==(1536&o)&&(c|=m.FD_SEEK),{flags:o,needed_base:a,needed_inheriting:c}}u("fd_allocate",(function(t,e,n){const r=Q.get(this),i=et(this),s=r.fds.get(t,m.FD_ALLOCATE,BigInt(0));return i.fstatSync(s.fd,{bigint:!0}).size<e+n&&i.ftruncateSync(s.fd,Number(e+n)),0}),(async function(t,e,n){const r=Q.get(this).fds.get(t,m.FD_ALLOCATE,BigInt(0)).fd;return(await r.stat({bigint:!0})).size<e+n&&await r.truncate(Number(e+n)),0}),["i32","i64","f64"],["i32"]),u("fd_close",(function(t){const e=Q.get(this),n=e.fds.get(t,BigInt(0),BigInt(0));return et(this).closeSync(n.fd),e.fds.remove(t),0}),(async function(t){const e=Q.get(this),n=e.fds.get(t,BigInt(0),BigInt(0));return await n.fd.close(),e.fds.remove(t),0}),["i32"],["i32"]),u("fd_datasync",(function(t){const e=Q.get(this).fds.get(t,m.FD_DATASYNC,BigInt(0));return et(this).fdatasyncSync(e.fd),0}),(async function(t){const e=Q.get(this).fds.get(t,m.FD_DATASYNC,BigInt(0));return await e.fd.datasync(),0}),["i32"],["i32"]),u("fd_filestat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,m.FD_FILESTAT_GET,BigInt(0)),r=et(this).fstatSync(n.fd,{bigint:!0}),{view:i}=tt(this);return M(i,e,r),0}),(async function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,m.FD_FILESTAT_GET,BigInt(0)).fd,r=await n.stat({bigint:!0}),{view:i}=tt(this);return M(i,e,r),0}),["i32","i32"],["i32"]),u("fd_filestat_set_size",(function(t,e){const n=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_SIZE,BigInt(0));return et(this).ftruncateSync(n.fd,Number(e)),0}),(async function(t,e){const n=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_SIZE,BigInt(0)).fd;return await n.truncate(Number(e)),0}),["i32","i64"],["i32"]),u("fd_filestat_set_times",(function(t,e,n,r){if(ft(r))return 28;const{fileDescriptor:i,atim:s,mtim:o}=f.call(this,t,e,n,r);return et(this).futimesSync(i.fd,Number(s),Number(o)),0}),(async function(t,e,n,r){if(ft(r))return 28;const{fileDescriptor:i,atim:s,mtim:o}=f.call(this,t,e,n,r),a=i.fd;return await a.utimes(Number(s),Number(o)),0}),["i32","i64","i64","i32"],["i32"]),u("fd_pread",(function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_READ|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;let c=0;const u=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return c+=a,s.subarray(i,i+a)}));let f=0;const h=(()=>{try{return new Uint8Array(new SharedArrayBuffer(c))}catch(t){return new Uint8Array(c)}})();h._isBuffer=!0;const d=et(this).readSync(a.fd,h,0,h.length,Number(r));return f=h?q(u,h.subarray(0,d)):0,o.setUint32(i,f,!0),0}),(async function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_READ|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;let c=0;const u=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return c+=a,s.subarray(i,i+a)}));let f=0;const h=new Uint8Array(c);h._isBuffer=!0;const{bytesRead:d}=await a.fd.read(h,0,h.length,Number(r));return f=h?q(u,h.subarray(0,d)):0,o.setUint32(i,f,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_pwrite",(function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_WRITE|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;const c=O(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return s.subarray(i,i+a)}))),u=et(this).writeSync(a.fd,c,0,c.length,Number(r));return o.setUint32(i,u,!0),0}),(async function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_WRITE|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;const c=O(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return s.subarray(i,i+a)}))),{bytesWritten:u}=await a.fd.write(c,0,c.length,Number(r));return o.setUint32(i,u,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_read",(function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_READ,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;let a=0;const c=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),c=s.getUint32(r+4,!0);return a+=c,i.subarray(o,o+c)}));let u,f=0;if(0===t){if("undefined"==typeof window||"function"!=typeof window.prompt)return 58;u=ut(),f=u?q(c,u):0}else{u=(()=>{try{return new Uint8Array(new SharedArrayBuffer(a))}catch(t){return new Uint8Array(a)}})(),u._isBuffer=!0;const t=et(this).readSync(o.fd,u,0,u.length,Number(o.pos));f=u?q(c,u.subarray(0,t)):0,o.pos+=BigInt(f)}return s.setUint32(r,f,!0),0}),(async function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_READ,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;let a=0;const c=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),c=s.getUint32(r+4,!0);return a+=c,i.subarray(o,o+c)}));let u,f=0;if(0===t){if("undefined"==typeof window||"function"!=typeof window.prompt)return 58;u=ut(),f=u?q(c,u):0}else{u=new Uint8Array(a),u._isBuffer=!0;const{bytesRead:t}=await o.fd.read(u,0,u.length,Number(o.pos));f=u?q(c,u.subarray(0,t)):0,o.pos+=BigInt(f)}return s.setUint32(r,f,!0),0}),["i32","i32","i32","i32"],["i32"]),u("fd_readdir",(function(t,e,n,r,i){if(e=Number(e),n=Number(n),i=Number(i),0===e||0===i)return 0;const s=Q.get(this).fds.get(t,m.FD_READDIR,BigInt(0)),o=et(this),a=o.readdirSync(s.realPath,{withFileTypes:!0}),{HEAPU8:c,view:u}=tt(this);let f=0;for(let t=Number(r);t<a.length;t++){const r=ot.encode(a[t].name),i=o.statSync(I(s.realPath,a[t].name),{bigint:!0}),u=new Uint8Array(24+r.byteLength),h=new DataView(u.buffer);let d;h.setBigUint64(0,BigInt(t+1),!0),h.setBigUint64(8,BigInt(i.ino?i.ino:0),!0),h.setUint32(16,r.byteLength,!0),d=a[t].isFile()?4:a[t].isDirectory()?3:a[t].isSymbolicLink()?7:a[t].isCharacterDevice()?2:a[t].isBlockDevice()?1:a[t].isSocket()?6:0,h.setUint8(20,d),u.set(r,24);const g=u.slice(0,Math.min(u.length,n-f));c.set(g,e+f),f+=g.byteLength}return u.setUint32(i,f,!0),0}),(async function(t,e,n,r,i){if(e=Number(e),n=Number(n),i=Number(i),0===e||0===i)return 0;const s=Q.get(this).fds.get(t,m.FD_READDIR,BigInt(0)),o=et(this),a=await o.promises.readdir(s.realPath,{withFileTypes:!0}),{HEAPU8:c,view:u}=tt(this);let f=0;for(let t=Number(r);t<a.length;t++){const r=ot.encode(a[t].name),i=await o.promises.stat(I(s.realPath,a[t].name),{bigint:!0}),u=new Uint8Array(24+r.byteLength),h=new DataView(u.buffer);let d;h.setBigUint64(0,BigInt(t+1),!0),h.setBigUint64(8,BigInt(i.ino?i.ino:0),!0),h.setUint32(16,r.byteLength,!0),d=a[t].isFile()?4:a[t].isDirectory()?3:a[t].isSymbolicLink()?7:a[t].isCharacterDevice()?2:a[t].isBlockDevice()?1:a[t].isSocket()?6:0,h.setUint8(20,d),u.set(r,24);const g=u.slice(0,Math.min(u.length,n-f));c.set(g,e+f),f+=g.byteLength}return u.setUint32(i,f,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_renumber",(function(t,e){return Q.get(this).fds.renumber(e,t),0}),(async function(t,e){const n=Q.get(this);return await n.fds.renumber(e,t),0}),["i32","i32"],["i32"]),u("fd_sync",(function(t){const e=Q.get(this).fds.get(t,m.FD_SYNC,BigInt(0));return et(this).fsyncSync(e.fd),0}),(async function(t){const e=Q.get(this).fds.get(t,m.FD_SYNC,BigInt(0));return await e.fd.sync(),0}),["i32"],["i32"]),u("fd_write",(function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_WRITE,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;const a=O(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),a=s.getUint32(r+4,!0);return i.subarray(o,o+a)})));let c;if(1===t||2===t)c=o.write(a);else{c=et(this).writeSync(o.fd,a,0,a.length,Number(o.pos)),o.pos+=BigInt(c)}return s.setUint32(r,c,!0),0}),(async function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_WRITE,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;const a=O(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),a=s.getUint32(r+4,!0);return i.subarray(o,o+a)})));let c;return 1===t||2===t?c=o.write(a):(c=await(await o.fd.write(a,0,a.length,Number(o.pos))).bytesWritten,o.pos+=BigInt(c)),s.setUint32(r,c,!0),0}),["i32","i32","i32","i32"],["i32"]),u("path_create_directory",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_CREATE_DIRECTORY,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);return et(this).mkdirSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_CREATE_DIRECTORY,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);const o=et(this);return await o.promises.mkdir(s),0}),["i32","i32","i32"],["i32"]),u("path_filestat_get",(function(t,e,n,r,i){if(n=Number(n),r=Number(r),i=Number(i),0===n||0===i)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.PATH_FILESTAT_GET,BigInt(0));let u=at.decode(c(s,n,n+r));const f=et(this);let h;return u=I(a.realPath,u),h=1==(1&e)?f.statSync(u,{bigint:!0}):f.lstatSync(u,{bigint:!0}),M(o,i,h),0}),(async function(t,e,n,r,i){if(n=Number(n),r=Number(r),i=Number(i),0===n||0===i)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.PATH_FILESTAT_GET,BigInt(0));let u=at.decode(c(s,n,n+r));const f=et(this);let h;return u=I(a.realPath,u),h=1==(1&e)?await f.promises.stat(u,{bigint:!0}):await f.promises.lstat(u,{bigint:!0}),M(o,i,h),0}),["i32","i32","i32","i32","i32"],["i32"]),u("path_filestat_set_times",(function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),0===n)return 28;const{HEAPU8:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_FILESTAT_SET_TIMES,BigInt(0));if(ft(o))return 28;const f=et(this),h=it(f,u,at.decode(c(a,n,n+r)),e);return 2==(2&o)&&(i=BigInt(1e6*Date.now())),8==(8&o)&&(s=BigInt(1e6*Date.now())),f.utimesSync(h,Number(i),Number(s)),0}),(async function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),0===n)return 28;const{HEAPU8:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_FILESTAT_SET_TIMES,BigInt(0));if(ft(o))return 28;const f=et(this),h=await st(f,u,at.decode(c(a,n,n+r)),e);return 2==(2&o)&&(i=BigInt(1e6*Date.now())),8==(8&o)&&(s=BigInt(1e6*Date.now())),await f.promises.utimes(h,Number(i),Number(s)),0}),["i32","i32","i32","i32","i64","i64","i32"],["i32"]),u("path_link",(function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),s=Number(s),o=Number(o),0===n||0===s)return 28;const a=Q.get(this);let u,f;t===i?u=f=a.fds.get(t,m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET,BigInt(0)):(u=a.fds.get(t,m.PATH_LINK_SOURCE,BigInt(0)),f=a.fds.get(i,m.PATH_LINK_TARGET,BigInt(0)));const{HEAPU8:h}=tt(this),d=et(this),g=it(d,u,at.decode(c(h,n,n+r)),e),l=I(f.realPath,at.decode(c(h,s,s+o)));return d.linkSync(g,l),0}),(async function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),s=Number(s),o=Number(o),0===n||0===s)return 28;const a=Q.get(this);let u,f;t===i?u=f=a.fds.get(t,m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET,BigInt(0)):(u=a.fds.get(t,m.PATH_LINK_SOURCE,BigInt(0)),f=a.fds.get(i,m.PATH_LINK_TARGET,BigInt(0)));const{HEAPU8:h}=tt(this),d=et(this),g=await st(d,u,at.decode(c(h,n,n+r)),e),l=I(f.realPath,at.decode(c(h,s,s+o)));return await d.promises.link(g,l),0}),["i32","i32","i32","i32","i32","i32","i32"],["i32"]),u("path_open",(function(t,e,n,r,i,s,o,a,u){if(n=Number(n),u=Number(u),0===n||0===u)return 28;r=Number(r),s=BigInt(s),o=BigInt(o);const{flags:f,needed_base:d,needed_inheriting:g}=h(i,s,o,a),l=Q.get(this),_=l.fds.get(t,d,g),y=tt(this),p=y.HEAPU8,E=at.decode(c(p,n,n+r)),I=et(this),m=it(I,_,E,e),A=I.openSync(m,f,438),b=l.fds.getFileTypeByFd(A);if(0!=(2&i)&&3!==b)return 54;const{base:T,inheriting:w}=H(l.fds.stdio,A,f,b),B=l.fds.insert(A,m,m,b,s&T,o&w,0),N=I.fstatSync(A,{bigint:!0});N.isFile()&&(B.size=N.size,0!=(1024&f)&&(B.pos=N.size));return y.view.setInt32(u,B.id,!0),0}),(async function(t,e,n,r,i,s,o,a,u){if(n=Number(n),u=Number(u),0===n||0===u)return 28;r=Number(r),s=BigInt(s),o=BigInt(o);const{flags:f,needed_base:d,needed_inheriting:g}=h(i,s,o,a),l=Q.get(this),_=l.fds.get(t,d,g),y=tt(this),p=y.HEAPU8,E=at.decode(c(p,n,n+r)),I=et(this),m=await st(I,_,E,e),A=await I.promises.open(m,f,438),b=await l.fds.getFileTypeByFd(A);if(0!=(2&i)&&3!==b)return 54;const{base:T,inheriting:w}=H(l.fds.stdio,A.fd,f,b),B=l.fds.insert(A,m,m,b,s&T,o&w,0),N=await A.stat({bigint:!0});N.isFile()&&(B.size=N.size,0!=(1024&f)&&(B.pos=N.size));return y.view.setInt32(u,B.id,!0),0}),["i32","i32","i32","i32","i32","i64","i64","i32","i32"],["i32"]),u("path_readlink",(function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),r=Number(r),i=Number(i),s=Number(s),0===e||0===r||0===s)return 28;const{HEAPU8:o,view:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_READLINK,BigInt(0));let f=at.decode(c(o,e,e+n));f=I(u.realPath,f);const h=et(this).readlinkSync(f),d=ot.encode(h),g=Math.min(d.length,i);return g>=i?42:(o.set(d.subarray(0,g),r),o[r+g]=0,a.setUint32(s,g,!0),0)}),(async function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),r=Number(r),i=Number(i),s=Number(s),0===e||0===r||0===s)return 28;const{HEAPU8:o,view:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_READLINK,BigInt(0));let f=at.decode(c(o,e,e+n));f=I(u.realPath,f);const h=et(this),d=await h.promises.readlink(f),g=ot.encode(d),l=Math.min(g.length,i);return l>=i?42:(o.set(g.subarray(0,l),r),o[r+l]=0,a.setUint32(s,l,!0),0)}),["i32","i32","i32","i32","i32","i32"],["i32"]),u("path_remove_directory",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_REMOVE_DIRECTORY,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);return et(this).rmdirSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_REMOVE_DIRECTORY,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);const o=et(this);return await o.promises.rmdir(s),0}),["i32","i32","i32"],["i32"]),u("path_rename",(function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),i=Number(i),s=Number(s),0===e||0===i)return 28;const o=Q.get(this);let a,u;t===r?a=u=o.fds.get(t,m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET,BigInt(0)):(a=o.fds.get(t,m.PATH_RENAME_SOURCE,BigInt(0)),u=o.fds.get(r,m.PATH_RENAME_TARGET,BigInt(0)));const{HEAPU8:f}=tt(this),h=I(a.realPath,at.decode(c(f,e,e+n))),d=I(u.realPath,at.decode(c(f,i,i+s)));return et(this).renameSync(h,d),0}),(async function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),i=Number(i),s=Number(s),0===e||0===i)return 28;const o=Q.get(this);let a,u;t===r?a=u=o.fds.get(t,m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET,BigInt(0)):(a=o.fds.get(t,m.PATH_RENAME_SOURCE,BigInt(0)),u=o.fds.get(r,m.PATH_RENAME_TARGET,BigInt(0)));const{HEAPU8:f}=tt(this),h=I(a.realPath,at.decode(c(f,e,e+n))),d=I(u.realPath,at.decode(c(f,i,i+s))),g=et(this);return await g.promises.rename(h,d),0}),["i32","i32","i32","i32","i32","i32"],["i32"]),u("path_symlink",(function(t,e,n,r,i){if(t=Number(t),e=Number(e),r=Number(r),i=Number(i),0===t||0===r)return 28;const{HEAPU8:s}=tt(this),o=Q.get(this).fds.get(n,m.PATH_SYMLINK,BigInt(0)),a=at.decode(c(s,t,t+e));let u=at.decode(c(s,r,r+i));u=I(o.realPath,u);return et(this).symlinkSync(a,u),0}),(async function(t,e,n,r,i){if(t=Number(t),e=Number(e),r=Number(r),i=Number(i),0===t||0===r)return 28;const{HEAPU8:s}=tt(this),o=Q.get(this).fds.get(n,m.PATH_SYMLINK,BigInt(0)),a=at.decode(c(s,t,t+e));let u=at.decode(c(s,r,r+i));u=I(o.realPath,u);const f=et(this);return await f.promises.symlink(a,u),0}),["i32","i32","i32","i32","i32"],["i32"]),u("path_unlink_file",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_UNLINK_FILE,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);return et(this).unlinkSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_UNLINK_FILE,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);const o=et(this);return await o.promises.unlink(s),0}),["i32","i32","i32"],["i32"]),this._setMemory=function(t){if(!(t instanceof e.Memory))throw new TypeError('"instance.exports.memory" property must be a WebAssembly.Memory');X.set(a,Y(t))}}static createSync(t,e,n,r,i,s,o){const a=new K({size:3,in:r[0],out:r[1],err:r[2],fs:i,print:s,printErr:o}),c=new ht(t,e,a,!1,i);if(n.length>0)for(let t=0;t<n.length;++t){const e=i.realpathSync(n[t].realPath,"utf8"),r=i.openSync(e,"r",438);a.insertPreopen(r,n[t].mappedPath,e)}return c}static async createAsync(t,e,n,r,i,s,o,a){const c=new z({size:3,in:r[0],out:r[1],err:r[2],print:s,printErr:o}),u=new ht(t,e,c,!0,i,a);if(n.length>0)for(let t=0;t<n.length;++t){const e=n[t],r=await i.promises.realpath(e.realPath),s=await i.promises.open(r,"r",438);await c.insertPreopen(s,e.mappedPath,r)}return u}}const dt=Object.freeze(Object.create(null)),gt=Symbol("kExitCode"),lt=Symbol("kSetMemory"),_t=Symbol("kStarted"),yt=Symbol("kInstance"),pt=Symbol("kBindingName");function Et(t,e){n(e,"instance"),n(e.exports,"instance.exports"),t[yt]=e,t[lt](e.exports.memory)}function It(t){var e;let s;if(n(t,"options"),void 0!==t.version)switch(r(t.version,"options.version"),t.version){case"unstable":s=ht,this[pt]="wasi_unstable";break;case"preview1":s=ht,this[pt]="wasi_snapshot_preview1";break;default:throw new TypeError(`unsupported WASI version "${t.version}"`)}else s=ht,this[pt]="wasi_snapshot_preview1";void 0!==t.args&&function(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array. Received ${null===t?"null":typeof t}`)}(t.args,"options.args");const o=(null!==(e=t.args)&&void 0!==e?e:[]).map(String),a=[];void 0!==t.env&&(n(t.env,"options.env"),Object.entries(t.env).forEach((({0:t,1:e})=>{void 0!==e&&a.push(`${t}=${e}`)})));const c=[];if(void 0!==t.preopens&&(n(t.preopens,"options.preopens"),Object.entries(t.preopens).forEach((({0:t,1:e})=>c.push({mappedPath:String(t),realPath:String(e)})))),c.length>0){if(void 0===t.fs)throw new Error("filesystem is disabled, can not preopen directory");try{n(t.fs,"options.fs")}catch(t){throw new TypeError("Node.js fs like implementation is not provided")}}void 0!==t.print&&i(t.print,"options.print"),void 0!==t.printErr&&i(t.printErr,"options.printErr"),void 0!==t.returnOnExit&&function(t,e){if("boolean"!=typeof t)throw new TypeError(`${e} must be a boolean. Received ${null===t?"null":typeof t}`)}(t.returnOnExit,"options.returnOnExit");return{args:o,env:a,preopens:c,stdio:[0,1,2],_WASI:s}}function mt(t,e){this[lt]=t,this.wasiImport=e,this[_t]=!1,this[gt]=0,this[yt]=void 0}class At{constructor(t=dt){const{args:e,env:n,preopens:r,stdio:i,_WASI:s}=It.call(this,t),o=s.createSync(e,n,r,i,t.fs,t.print,t.printErr),a=o._setMemory;delete o._setMemory,mt.call(this,a,o),t.returnOnExit&&(o.proc_exit=bt.bind(this))}start(t){if(this[_t])throw new Error("WASI instance has already started");this[_t]=!0,Et(this,t);const{_start:e,_initialize:n}=this[yt].exports;let r;i(e,"instance.exports._start"),s(n,"instance.exports._initialize");try{r=e()}catch(t){if(t!==gt)throw t}return r instanceof Promise?r.then((()=>this[gt]),(t=>{if(t!==gt)throw t;return this[gt]})):this[gt]}initialize(t){if(this[_t])throw new Error("WASI instance has already started");this[_t]=!0,Et(this,t);const{_start:e,_initialize:n}=this[yt].exports;if(s(e,"instance.exports._start"),void 0!==n)return i(n,"instance.exports._initialize"),n()}getImportObject(){return{[this[pt]]:this.wasiImport}}}function bt(t){throw this[gt]=t,gt}t.Asyncify=h,t.Memory=G,t.WASI=At,t.WebAssemblyMemory=j,t.asyncifyLoad=function(t,e,n){d(n),n=null!=n?n:{};const r=new h;return l(e,n=r.wrapImports(n)).then((e=>{var i;const s=e.instance.exports.memory||(null===(i=n.env)||void 0===i?void 0:i.memory);return{module:e.module,instance:r.init(s,e.instance,t)}}))},t.asyncifyLoadSync=function(t,e,n){var r;d(n),n=null!=n?n:{};const i=new h,s=_(e,n=i.wrapImports(n)),o=s.instance.exports.memory||(null===(r=n.env)||void 0===r?void 0:r.memory);return{module:s.module,instance:i.init(o,s.instance,t)}},t.createAsyncWASI=async function(t=dt){const e=Object.create(At.prototype),{args:r,env:s,preopens:o,stdio:a,_WASI:c}=It.call(e,t);void 0!==t.asyncify&&(n(t.asyncify,"options.asyncify"),i(t.asyncify.wrapImportFunction,"options.asyncify.wrapImportFunction"));const u=await c.createAsync(r,s,o,a,t.fs,t.print,t.printErr,t.asyncify),f=u._setMemory;return delete u._setMemory,mt.call(e,f,u),t.returnOnExit&&(u.proc_exit=bt.bind(e)),e},t.extendMemory=Y,t.load=l,t.loadSync=_,t.wrapAsyncExport=Z,t.wrapAsyncImport=V,t.wrapExports=function(t,e){return a(t,((t,n)=>{let r="function"!=typeof t;return Array.isArray(e)&&(r=r||-1===e.indexOf(n)),r?t:Z(t)}))},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Asyncify = void 0;
4
+ const webassembly_1 = require("./webassembly");
5
+ const util_1 = require("./wasi/util");
6
+ const ignoreNames = [
7
+ 'asyncify_get_state',
8
+ 'asyncify_start_rewind',
9
+ 'asyncify_start_unwind',
10
+ 'asyncify_stop_rewind',
11
+ 'asyncify_stop_unwind'
12
+ ];
13
+ // const wrappedExports = new WeakMap<WebAssembly.Exports, WebAssembly.Exports>()
14
+ var AsyncifyState;
15
+ (function (AsyncifyState) {
16
+ AsyncifyState[AsyncifyState["NONE"] = 0] = "NONE";
17
+ AsyncifyState[AsyncifyState["UNWINDING"] = 1] = "UNWINDING";
18
+ AsyncifyState[AsyncifyState["REWINDING"] = 2] = "REWINDING";
19
+ })(AsyncifyState || (AsyncifyState = {}));
20
+ function tryAllocate(instance, wasm64, size, mallocName) {
21
+ if (typeof instance.exports[mallocName] !== 'function' || size <= 0) {
22
+ return {
23
+ wasm64,
24
+ dataPtr: 16,
25
+ start: wasm64 ? 32 : 24,
26
+ end: 1024
27
+ };
28
+ }
29
+ const malloc = instance.exports[mallocName];
30
+ const dataPtr = wasm64 ? Number(malloc(BigInt(16) + BigInt(size))) : malloc(8 + size);
31
+ if (dataPtr === 0) {
32
+ throw new Error('Allocate asyncify data failed');
33
+ }
34
+ return wasm64
35
+ ? { wasm64, dataPtr, start: dataPtr + 16, end: dataPtr + 16 + size }
36
+ : { wasm64, dataPtr, start: dataPtr + 8, end: dataPtr + 8 + size };
37
+ }
38
+ /** @public */
39
+ class Asyncify {
40
+ constructor() {
41
+ this.value = undefined;
42
+ this.exports = undefined;
43
+ this.dataPtr = 0;
44
+ }
45
+ init(memory, instance, options) {
46
+ var _a, _b;
47
+ if (this.exports) {
48
+ throw new Error('Asyncify has been initialized');
49
+ }
50
+ if (!(memory instanceof webassembly_1._WebAssembly.Memory)) {
51
+ throw new TypeError('Require WebAssembly.Memory object');
52
+ }
53
+ const exports = instance.exports;
54
+ for (let i = 0; i < ignoreNames.length; ++i) {
55
+ if (typeof exports[ignoreNames[i]] !== 'function') {
56
+ throw new TypeError('Invalid asyncify wasm');
57
+ }
58
+ }
59
+ let address;
60
+ const wasm64 = Boolean(options.wasm64);
61
+ if (!options.tryAllocate) {
62
+ address = {
63
+ wasm64,
64
+ dataPtr: 16,
65
+ start: wasm64 ? 32 : 24,
66
+ end: 1024
67
+ };
68
+ }
69
+ else {
70
+ if (options.tryAllocate === true) {
71
+ address = tryAllocate(instance, wasm64, 4096, 'malloc');
72
+ }
73
+ else {
74
+ address = tryAllocate(instance, wasm64, (_a = options.tryAllocate.size) !== null && _a !== void 0 ? _a : 4096, (_b = options.tryAllocate.name) !== null && _b !== void 0 ? _b : 'malloc');
75
+ }
76
+ }
77
+ this.dataPtr = address.dataPtr;
78
+ if (wasm64) {
79
+ new BigInt64Array(memory.buffer, this.dataPtr).set([BigInt(address.start), BigInt(address.end)]);
80
+ }
81
+ else {
82
+ new Int32Array(memory.buffer, this.dataPtr).set([address.start, address.end]);
83
+ }
84
+ this.exports = this.wrapExports(exports, options.wrapExports);
85
+ const asyncifiedInstance = Object.create(webassembly_1._WebAssembly.Instance.prototype);
86
+ Object.defineProperty(asyncifiedInstance, 'exports', { value: this.exports });
87
+ // Object.setPrototypeOf(instance, Instance.prototype)
88
+ return asyncifiedInstance;
89
+ }
90
+ assertState() {
91
+ if (this.exports.asyncify_get_state() !== AsyncifyState.NONE) {
92
+ throw new Error('Asyncify state error');
93
+ }
94
+ }
95
+ wrapImportFunction(f) {
96
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
97
+ const _this = this;
98
+ return (function () {
99
+ // eslint-disable-next-line no-unreachable-loop
100
+ while (_this.exports.asyncify_get_state() === AsyncifyState.REWINDING) {
101
+ _this.exports.asyncify_stop_rewind();
102
+ return _this.value;
103
+ }
104
+ _this.assertState();
105
+ const v = f.apply(this, arguments);
106
+ if (!(0, util_1.isPromiseLike)(v))
107
+ return v;
108
+ _this.exports.asyncify_start_unwind(_this.dataPtr);
109
+ _this.value = v;
110
+ });
111
+ }
112
+ wrapImports(imports) {
113
+ const importObject = {};
114
+ Object.keys(imports).forEach(k => {
115
+ const mod = imports[k];
116
+ const newModule = {};
117
+ Object.keys(mod).forEach(name => {
118
+ const importValue = mod[name];
119
+ if (typeof importValue === 'function') {
120
+ newModule[name] = this.wrapImportFunction(importValue);
121
+ }
122
+ else {
123
+ newModule[name] = importValue;
124
+ }
125
+ });
126
+ importObject[k] = newModule;
127
+ });
128
+ return importObject;
129
+ }
130
+ wrapExportFunction(f) {
131
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
132
+ const _this = this;
133
+ return (async function () {
134
+ _this.assertState();
135
+ let ret = f.apply(this, arguments);
136
+ while (_this.exports.asyncify_get_state() === AsyncifyState.UNWINDING) {
137
+ _this.exports.asyncify_stop_unwind();
138
+ _this.value = await _this.value;
139
+ _this.assertState();
140
+ _this.exports.asyncify_start_rewind(_this.dataPtr);
141
+ ret = f.call(this);
142
+ }
143
+ _this.assertState();
144
+ return ret;
145
+ });
146
+ }
147
+ wrapExports(exports, needWrap) {
148
+ return (0, util_1.wrapInstanceExports)(exports, (exportValue, name) => {
149
+ let ignore = ignoreNames.indexOf(name) !== -1 || typeof exportValue !== 'function';
150
+ if (Array.isArray(needWrap)) {
151
+ ignore = ignore || (needWrap.indexOf(name) === -1);
152
+ }
153
+ return ignore ? exportValue : this.wrapExportFunction(exportValue);
154
+ });
155
+ }
156
+ }
157
+ exports.Asyncify = Asyncify;
158
+ //# sourceMappingURL=asyncify.js.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * @packageDocumentation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tslib_1 = require("tslib");
7
+ tslib_1.__exportStar(require("./asyncify"), exports);
8
+ tslib_1.__exportStar(require("./load"), exports);
9
+ tslib_1.__exportStar(require("./wasi/index"), exports);
10
+ tslib_1.__exportStar(require("./memory"), exports);
11
+ tslib_1.__exportStar(require("./jspi"), exports);
12
+ tslib_1.__exportStar(require("./wasi/fs"), exports);
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapExports = exports.wrapAsyncExport = exports.wrapAsyncImport = void 0;
4
+ const util_1 = require("./wasi/util");
5
+ const webassembly_1 = require("./webassembly");
6
+ function checkWebAssemblyFunction() {
7
+ const WebAssemblyFunction = webassembly_1._WebAssembly.Function;
8
+ if (typeof WebAssemblyFunction !== 'function') {
9
+ throw new Error('WebAssembly.Function is not supported in this environment.' +
10
+ ' If you are using V8 based browser like Chrome, try to specify' +
11
+ ' --js-flags="--wasm-staging --experimental-wasm-stack-switching"');
12
+ }
13
+ return WebAssemblyFunction;
14
+ }
15
+ /** @public */
16
+ function wrapAsyncImport(f, parameterType, returnType) {
17
+ const WebAssemblyFunction = checkWebAssemblyFunction();
18
+ if (typeof f !== 'function') {
19
+ throw new TypeError('Function required');
20
+ }
21
+ const parameters = parameterType.slice(0);
22
+ parameters.unshift('externref');
23
+ return new WebAssemblyFunction({ parameters, results: returnType }, f, { suspending: 'first' });
24
+ }
25
+ exports.wrapAsyncImport = wrapAsyncImport;
26
+ /** @public */
27
+ function wrapAsyncExport(f) {
28
+ const WebAssemblyFunction = checkWebAssemblyFunction();
29
+ if (typeof f !== 'function') {
30
+ throw new TypeError('Function required');
31
+ }
32
+ return new WebAssemblyFunction({ parameters: [...WebAssemblyFunction.type(f).parameters.slice(1)], results: ['externref'] }, f, { promising: 'first' });
33
+ }
34
+ exports.wrapAsyncExport = wrapAsyncExport;
35
+ /** @public */
36
+ function wrapExports(exports, needWrap) {
37
+ return (0, util_1.wrapInstanceExports)(exports, (exportValue, name) => {
38
+ let ignore = typeof exportValue !== 'function';
39
+ if (Array.isArray(needWrap)) {
40
+ ignore = ignore || (needWrap.indexOf(name) === -1);
41
+ }
42
+ return ignore ? exportValue : wrapAsyncExport(exportValue);
43
+ });
44
+ }
45
+ exports.wrapExports = wrapExports;
46
+ //# sourceMappingURL=jspi.js.map
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asyncifyLoadSync = exports.loadSync = exports.asyncifyLoad = exports.load = void 0;
4
+ const webassembly_1 = require("./webassembly");
5
+ const asyncify_1 = require("./asyncify");
6
+ function validateImports(imports) {
7
+ if (imports && typeof imports !== 'object') {
8
+ throw new TypeError('imports must be an object or undefined');
9
+ }
10
+ }
11
+ function fetchWasm(urlOrBuffer, imports) {
12
+ if (typeof wx !== 'undefined' && typeof __wxConfig !== 'undefined') {
13
+ return webassembly_1._WebAssembly.instantiate(urlOrBuffer, imports);
14
+ }
15
+ return fetch(urlOrBuffer)
16
+ .then(response => response.arrayBuffer())
17
+ .then(buffer => webassembly_1._WebAssembly.instantiate(buffer, imports));
18
+ }
19
+ /** @public */
20
+ function load(wasmInput, imports) {
21
+ validateImports(imports);
22
+ imports = imports !== null && imports !== void 0 ? imports : {};
23
+ let source;
24
+ if (wasmInput instanceof ArrayBuffer || ArrayBuffer.isView(wasmInput)) {
25
+ return webassembly_1._WebAssembly.instantiate(wasmInput, imports);
26
+ }
27
+ if (wasmInput instanceof webassembly_1._WebAssembly.Module) {
28
+ return webassembly_1._WebAssembly.instantiate(wasmInput, imports).then((instance) => {
29
+ return { instance, module: wasmInput };
30
+ });
31
+ }
32
+ if (typeof wasmInput !== 'string' && !(wasmInput instanceof URL)) {
33
+ throw new TypeError('Invalid source');
34
+ }
35
+ if (typeof webassembly_1._WebAssembly.instantiateStreaming === 'function') {
36
+ let responsePromise;
37
+ try {
38
+ responsePromise = fetch(wasmInput);
39
+ source = webassembly_1._WebAssembly.instantiateStreaming(responsePromise, imports).catch(() => {
40
+ return fetchWasm(wasmInput, imports);
41
+ });
42
+ }
43
+ catch (_) {
44
+ source = fetchWasm(wasmInput, imports);
45
+ }
46
+ }
47
+ else {
48
+ source = fetchWasm(wasmInput, imports);
49
+ }
50
+ return source;
51
+ }
52
+ exports.load = load;
53
+ /** @public */
54
+ function asyncifyLoad(asyncify, urlOrBuffer, imports) {
55
+ validateImports(imports);
56
+ imports = imports !== null && imports !== void 0 ? imports : {};
57
+ const asyncifyHelper = new asyncify_1.Asyncify();
58
+ imports = asyncifyHelper.wrapImports(imports);
59
+ return load(urlOrBuffer, imports).then(source => {
60
+ var _a;
61
+ const memory = source.instance.exports.memory || ((_a = imports.env) === null || _a === void 0 ? void 0 : _a.memory);
62
+ return { module: source.module, instance: asyncifyHelper.init(memory, source.instance, asyncify) };
63
+ });
64
+ }
65
+ exports.asyncifyLoad = asyncifyLoad;
66
+ /** @public */
67
+ function loadSync(wasmInput, imports) {
68
+ validateImports(imports);
69
+ imports = imports !== null && imports !== void 0 ? imports : {};
70
+ let module;
71
+ if ((wasmInput instanceof ArrayBuffer) || ArrayBuffer.isView(wasmInput)) {
72
+ module = new webassembly_1._WebAssembly.Module(wasmInput);
73
+ }
74
+ else if (wasmInput instanceof WebAssembly.Module) {
75
+ module = wasmInput;
76
+ }
77
+ else {
78
+ throw new TypeError('Invalid source');
79
+ }
80
+ const instance = new webassembly_1._WebAssembly.Instance(module, imports);
81
+ const source = { instance, module };
82
+ return source;
83
+ }
84
+ exports.loadSync = loadSync;
85
+ /** @public */
86
+ function asyncifyLoadSync(asyncify, buffer, imports) {
87
+ var _a;
88
+ validateImports(imports);
89
+ imports = imports !== null && imports !== void 0 ? imports : {};
90
+ const asyncifyHelper = new asyncify_1.Asyncify();
91
+ imports = asyncifyHelper.wrapImports(imports);
92
+ const source = loadSync(buffer, imports);
93
+ const memory = source.instance.exports.memory || ((_a = imports.env) === null || _a === void 0 ? void 0 : _a.memory);
94
+ return { module: source.module, instance: asyncifyHelper.init(memory, source.instance, asyncify) };
95
+ }
96
+ exports.asyncifyLoadSync = asyncifyLoadSync;
97
+ //# sourceMappingURL=load.js.map
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extendMemory = exports.Memory = exports.WebAssemblyMemory = void 0;
4
+ /* eslint-disable spaced-comment */
5
+ const webassembly_1 = require("./webassembly");
6
+ /** @public */
7
+ exports.WebAssemblyMemory = (function () { return webassembly_1._WebAssembly.Memory; })();
8
+ /** @public */
9
+ class Memory extends exports.WebAssemblyMemory {
10
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
11
+ constructor(descriptor) {
12
+ super(descriptor);
13
+ }
14
+ get HEAP8() { return new Int8Array(super.buffer); }
15
+ get HEAPU8() { return new Uint8Array(super.buffer); }
16
+ get HEAP16() { return new Int16Array(super.buffer); }
17
+ get HEAPU16() { return new Uint16Array(super.buffer); }
18
+ get HEAP32() { return new Int32Array(super.buffer); }
19
+ get HEAPU32() { return new Uint32Array(super.buffer); }
20
+ get HEAP64() { return new BigInt64Array(super.buffer); }
21
+ get HEAPU64() { return new BigUint64Array(super.buffer); }
22
+ get HEAPF32() { return new Float32Array(super.buffer); }
23
+ get HEAPF64() { return new Float64Array(super.buffer); }
24
+ get view() { return new DataView(super.buffer); }
25
+ }
26
+ exports.Memory = Memory;
27
+ /** @public */
28
+ function extendMemory(memory) {
29
+ if (Object.getPrototypeOf(memory) === webassembly_1._WebAssembly.Memory.prototype) {
30
+ Object.setPrototypeOf(memory, Memory.prototype);
31
+ }
32
+ return memory;
33
+ }
34
+ exports.extendMemory = extendMemory;
35
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WasiError = exports.strerror = void 0;
4
+ const types_1 = require("./types");
5
+ function strerror(errno) {
6
+ switch (errno) {
7
+ case types_1.WasiErrno.ESUCCESS: return 'Success';
8
+ case types_1.WasiErrno.E2BIG: return 'Argument list too long';
9
+ case types_1.WasiErrno.EACCES: return 'Permission denied';
10
+ case types_1.WasiErrno.EADDRINUSE: return 'Address in use';
11
+ case types_1.WasiErrno.EADDRNOTAVAIL: return 'Address not available';
12
+ case types_1.WasiErrno.EAFNOSUPPORT: return 'Address family not supported by protocol';
13
+ case types_1.WasiErrno.EAGAIN: return 'Resource temporarily unavailable';
14
+ case types_1.WasiErrno.EALREADY: return 'Operation already in progress';
15
+ case types_1.WasiErrno.EBADF: return 'Bad file descriptor';
16
+ case types_1.WasiErrno.EBADMSG: return 'Bad message';
17
+ case types_1.WasiErrno.EBUSY: return 'Resource busy';
18
+ case types_1.WasiErrno.ECANCELED: return 'Operation canceled';
19
+ case types_1.WasiErrno.ECHILD: return 'No child process';
20
+ case types_1.WasiErrno.ECONNABORTED: return 'Connection aborted';
21
+ case types_1.WasiErrno.ECONNREFUSED: return 'Connection refused';
22
+ case types_1.WasiErrno.ECONNRESET: return 'Connection reset by peer';
23
+ case types_1.WasiErrno.EDEADLK: return 'Resource deadlock would occur';
24
+ case types_1.WasiErrno.EDESTADDRREQ: return 'Destination address required';
25
+ case types_1.WasiErrno.EDOM: return 'Domain error';
26
+ case types_1.WasiErrno.EDQUOT: return 'Quota exceeded';
27
+ case types_1.WasiErrno.EEXIST: return 'File exists';
28
+ case types_1.WasiErrno.EFAULT: return 'Bad address';
29
+ case types_1.WasiErrno.EFBIG: return 'File too large';
30
+ case types_1.WasiErrno.EHOSTUNREACH: return 'Host is unreachable';
31
+ case types_1.WasiErrno.EIDRM: return 'Identifier removed';
32
+ case types_1.WasiErrno.EILSEQ: return 'Illegal byte sequence';
33
+ case types_1.WasiErrno.EINPROGRESS: return 'Operation in progress';
34
+ case types_1.WasiErrno.EINTR: return 'Interrupted system call';
35
+ case types_1.WasiErrno.EINVAL: return 'Invalid argument';
36
+ case types_1.WasiErrno.EIO: return 'I/O error';
37
+ case types_1.WasiErrno.EISCONN: return 'Socket is connected';
38
+ case types_1.WasiErrno.EISDIR: return 'Is a directory';
39
+ case types_1.WasiErrno.ELOOP: return 'Symbolic link loop';
40
+ case types_1.WasiErrno.EMFILE: return 'No file descriptors available';
41
+ case types_1.WasiErrno.EMLINK: return 'Too many links';
42
+ case types_1.WasiErrno.EMSGSIZE: return 'Message too large';
43
+ case types_1.WasiErrno.EMULTIHOP: return 'Multihop attempted';
44
+ case types_1.WasiErrno.ENAMETOOLONG: return 'Filename too long';
45
+ case types_1.WasiErrno.ENETDOWN: return 'Network is down';
46
+ case types_1.WasiErrno.ENETRESET: return 'Connection reset by network';
47
+ case types_1.WasiErrno.ENETUNREACH: return 'Network unreachable';
48
+ case types_1.WasiErrno.ENFILE: return 'Too many files open in system';
49
+ case types_1.WasiErrno.ENOBUFS: return 'No buffer space available';
50
+ case types_1.WasiErrno.ENODEV: return 'No such device';
51
+ case types_1.WasiErrno.ENOENT: return 'No such file or directory';
52
+ case types_1.WasiErrno.ENOEXEC: return 'Exec format error';
53
+ case types_1.WasiErrno.ENOLCK: return 'No locks available';
54
+ case types_1.WasiErrno.ENOLINK: return 'Link has been severed';
55
+ case types_1.WasiErrno.ENOMEM: return 'Out of memory';
56
+ case types_1.WasiErrno.ENOMSG: return 'No message of the desired type';
57
+ case types_1.WasiErrno.ENOPROTOOPT: return 'Protocol not available';
58
+ case types_1.WasiErrno.ENOSPC: return 'No space left on device';
59
+ case types_1.WasiErrno.ENOSYS: return 'Function not implemented';
60
+ case types_1.WasiErrno.ENOTCONN: return 'Socket not connected';
61
+ case types_1.WasiErrno.ENOTDIR: return 'Not a directory';
62
+ case types_1.WasiErrno.ENOTEMPTY: return 'Directory not empty';
63
+ case types_1.WasiErrno.ENOTRECOVERABLE: return 'State not recoverable';
64
+ case types_1.WasiErrno.ENOTSOCK: return 'Not a socket';
65
+ case types_1.WasiErrno.ENOTSUP: return 'Not supported';
66
+ case types_1.WasiErrno.ENOTTY: return 'Not a tty';
67
+ case types_1.WasiErrno.ENXIO: return 'No such device or address';
68
+ case types_1.WasiErrno.EOVERFLOW: return 'Value too large for data type';
69
+ case types_1.WasiErrno.EOWNERDEAD: return 'Previous owner died';
70
+ case types_1.WasiErrno.EPERM: return 'Operation not permitted';
71
+ case types_1.WasiErrno.EPIPE: return 'Broken pipe';
72
+ case types_1.WasiErrno.EPROTO: return 'Protocol error';
73
+ case types_1.WasiErrno.EPROTONOSUPPORT: return 'Protocol not supported';
74
+ case types_1.WasiErrno.EPROTOTYPE: return 'Protocol wrong type for socket';
75
+ case types_1.WasiErrno.ERANGE: return 'Result not representable';
76
+ case types_1.WasiErrno.EROFS: return 'Read-only file system';
77
+ case types_1.WasiErrno.ESPIPE: return 'Invalid seek';
78
+ case types_1.WasiErrno.ESRCH: return 'No such process';
79
+ case types_1.WasiErrno.ESTALE: return 'Stale file handle';
80
+ case types_1.WasiErrno.ETIMEDOUT: return 'Operation timed out';
81
+ case types_1.WasiErrno.ETXTBSY: return 'Text file busy';
82
+ case types_1.WasiErrno.EXDEV: return 'Cross-device link';
83
+ case types_1.WasiErrno.ENOTCAPABLE: return 'Capabilities insufficient';
84
+ default: return 'Unknown error';
85
+ }
86
+ }
87
+ exports.strerror = strerror;
88
+ class WasiError extends Error {
89
+ constructor(message, errno) {
90
+ super(message);
91
+ this.errno = errno;
92
+ }
93
+ getErrorMessage() {
94
+ return strerror(this.errno);
95
+ }
96
+ }
97
+ exports.WasiError = WasiError;
98
+ Object.defineProperty(WasiError.prototype, 'name', {
99
+ configurable: true,
100
+ writable: true,
101
+ value: 'WasiError'
102
+ });
103
+ //# sourceMappingURL=error.js.map