diff --git a/samples/polyfills/fs/.edge/.env b/samples/polyfills/fs/.edge/.env new file mode 100644 index 00000000..e69de29b diff --git a/samples/polyfills/fs/.edge/manifest.json b/samples/polyfills/fs/.edge/manifest.json new file mode 100644 index 00000000..cd7b9e31 --- /dev/null +++ b/samples/polyfills/fs/.edge/manifest.json @@ -0,0 +1,11 @@ +{ + "routes": [ + { + "from": "/", + "to": ".edge/worker.js", + "priority": 1, + "type": "compute" + } + ], + "fs": [] +} \ No newline at end of file diff --git a/samples/polyfills/fs/.edge/worker.js b/samples/polyfills/fs/.edge/worker.js new file mode 100644 index 00000000..98d54ffa --- /dev/null +++ b/samples/polyfills/fs/.edge/worker.js @@ -0,0 +1,2 @@ +/*! For license information please see worker.js.LICENSE.txt */ +globalThis.navigator={userAgent:"runtime"};let loadTime=Date.now();globalThis.performance=new Proxy({},{get:(t,e)=>"now"===e?()=>{const t=Date.now()-loadTime;return loadTime=Date.now(),t}:()=>{const t=Date.now()-loadTime;return loadTime=Date.now(),t}}),globalThis.vulcan={},globalThis.vulcan.FS_PATH_PREFIX_TO_REMOVE="",globalThis.vulcan.__FILES__={"/static-html/index.html":{content:"PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KCTxzdHlsZT4KCQlib2R5IHsKCQkJYmFja2dyb3VuZC1jb2xvcjogYmxhY2s7CgkJCWNvbG9yOiBvcmFuZ2U7CgkJCWZvbnQtZmFtaWx5OiBtb25vc3BhY2U7CgkJCWZvbnQtc2l6ZTogMTJweDsKCQkJdGV4dC1hbGlnbjogY2VudGVyOwoJCQltYXJnaW46IDA7CgkJCXBhZGRpbmc6IDUwcHg7CgkJfQoJCQoJCXByZSB7CgkJCXdoaXRlLXNwYWNlOiBwcmU7CgkJfQoJPC9zdHlsZT4KPC9oZWFkPgo8Ym9keT4KPC9ib2R5Pgo8L2h0bWw+CjwhRE9DVFlQRSBodG1sPgo8aHRtbD4KPGhlYWQ+Cgk8c3R5bGU+CgkJYm9keSB7CgkJCWJhY2tncm91bmQtY29sb3I6IGJsYWNrOwoJCQljb2xvcjogb3JhbmdlOwoJCQlmb250LWZhbWlseTogbW9ub3NwYWNlOwoJCQlmb250LXNpemU6IDEycHg7CgkJCXRleHQtYWxpZ246IGNlbnRlcjsKCQkJbWFyZ2luOiAwOwoJCQlwYWRkaW5nOiA1MHB4OwoJCX0KCQkKCQlwcmUgewoJCQl3aGl0ZS1zcGFjZTogcHJlOwoJCX0KCTwvc3R5bGU+CjwvaGVhZD4KPGJvZHk+Cgk8cHJlPgoKICAgICMgICAgIyAgIyMjIyAgIyAgICAjICMjIyMjIyAgICAjIyMjIyAgIyMjIyAgICAgIyMjIyMgIyAgICAjICMjIyMjIyAgICAjIyMjIyMgIyMjIyMgICAjIyMjICAjIyMjIyMgCiAgICAjIyAgIyMgIyAgICAjICMgICAgIyAjICAgICAgICAgICAjICAgIyAgICAjICAgICAgIyAgICMgICAgIyAjICAgICAgICAgIyAgICAgICMgICAgIyAjICAgICMgIyAgICAgIAogICAgIyAjIyAjICMgICAgIyAjICAgICMgIyMjIyMgICAgICAgIyAgICMgICAgIyAgICAgICMgICAjIyMjIyMgIyMjIyMgICAgICMjIyMjICAjICAgICMgIyAgICAgICMjIyMjICAKICAgICMgICAgIyAjICAgICMgIyAgICAjICMgICAgICAgICAgICMgICAjICAgICMgICAgICAjICAgIyAgICAjICMgICAgICAgICAjICAgICAgIyAgICAjICMgICMjIyAjICAgICAgCiAgICAjICAgICMgIyAgICAjICAjICAjICAjICAgICAgICAgICAjICAgIyAgICAjICAgICAgIyAgICMgICAgIyAjICAgICAgICAgIyAgICAgICMgICAgIyAjICAgICMgIyAgICAgIAogICAgIyAgICAjICAjIyMjICAgICMjICAgIyMjIyMjICAgICAgIyAgICAjIyMjICAgICAgICMgICAjICAgICMgIyMjIyMjICAgICMjIyMjIyAjIyMjIyAgICMjIyMgICMjIyMjIyAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAKCTwvcHJlPgo8L2JvZHk+CjwvaHRtbD4K"}},(()=>{var t={477:(t,e)=>{"use strict";e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=s(t),f=i[0],u=i[1],h=new o(function(t,e,r){return 3*(e+r)/4-r}(0,f,u)),c=0,a=u>0?f-4:f;for(r=0;r>16&255,h[c++]=e>>8&255,h[c++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,h[c++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e),h},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],f=16383,s=0,h=n-o;sh?h:s+f));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0;f<64;++f)r[f]=i[f],n[i.charCodeAt(f)]=f;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var o,i,f=[],s=e;s>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return f.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},426:(t,e,r)=>{"use strict";const n=r(477),o=r(281),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const f=2147483647;function s(t){if(t>f)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return h(t,e,r)}function h(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(K(t,Uint8Array)){const e=new Uint8Array(t);return g(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(K(t,ArrayBuffer)||t&&K(t.buffer,ArrayBuffer))return g(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(K(t,SharedArrayBuffer)||t&&K(t.buffer,SharedArrayBuffer)))return g(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|p(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?s(0):l(t):"Buffer"===t.type&&Array.isArray(t.data)?l(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return c(t),s(t<0?0:0|p(t))}function l(t){const e=t.length<0?0:0|p(t.length),r=s(e);for(let n=0;n=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||K(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Q(t).length;default:if(o)return n?-1:Y(t).length;e=(""+e).toLowerCase(),o=!0}}function I(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function A(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:C(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):C(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function C(t,e,r,n,o){let i,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;f=2,s/=2,u/=2,r/=2}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(o){let n=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let f;for(n>i/2&&(n=i/2),f=0;f>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function B(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],s=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,f=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=f}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(K(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const s=Math.min(i,f),h=this.slice(n,o),c=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":case"latin1":case"binary":return m(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function M(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function S(t,e,r,n,o){W(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function x(t,e,r,n,o){W(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function k(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,n,i){return e=+e,r>>>=0,i||k(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||k(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||_(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||_(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||_(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||_(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=X((function(t){D(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||_(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||_(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||_(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=X((function(t){D(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||_(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||_(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||_(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||_(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||L(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||L(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=X((function(t,e=0){return S(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=X((function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);L(this,t,e,r,n-1,-n)}let o=0,i=1,f=0;for(this[e]=255&t;++o>0)-f&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);L(this,t,e,r,n-1,-n)}let o=r-1,i=1,f=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===f&&0!==this[e+o+1]&&(f=1),this[e+o]=(t/i>>0)-f&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=X((function(t,e=0){return S(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=X((function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function W(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){D(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1))}(n,o,i)}function D(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw D(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}J("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),J("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),J("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=$(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=$(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const H=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let f=0;f55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function Q(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function K(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}const z=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function X(t){return"undefined"==typeof BigInt?q:t}function q(){throw new Error("BigInt not supported")}},281:(t,e)=>{e.read=function(t,e,r,n,o){var i,f,s=8*o-n-1,u=(1<>1,c=-7,a=r?o-1:0,l=r?-1:1,g=t[e+a];for(a+=l,i=g&(1<<-c)-1,g>>=-c,c+=s;c>0;i=256*i+t[e+a],a+=l,c-=8);for(f=i&(1<<-c)-1,i>>=-c,c+=n;c>0;f=256*f+t[e+a],a+=l,c-=8);if(0===i)i=1-h;else{if(i===u)return f?NaN:1/0*(g?-1:1);f+=Math.pow(2,n),i-=h}return(g?-1:1)*f*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var f,s,u,h=8*i-o-1,c=(1<>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:i-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=c):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+a>=1?l/u:l*Math.pow(2,1-a))*u>=2&&(f++,u/=2),f+a>=c?(s=0,f=c):f+a>=1?(s=(e*u-1)*Math.pow(2,o),f+=a):(s=e*Math.pow(2,a-1)*Math.pow(2,o),f=0));o>=8;t[r+g]=255&s,g+=p,s/=256,o-=8);for(f=f<0;t[r+g]=255&f,g+=p,f/=256,h-=8);t[r+g-p]|=128*y}},239:(t,e,r)=>{"use strict";var n=r(845);function o(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}function i(t,e){for(var r,n="",o=0,i=-1,f=0,s=0;s<=t.length;++s){if(s2){var u=n.lastIndexOf("/");if(u!==n.length-1){-1===u?(n="",o=0):o=(n=n.slice(0,u)).length-1-n.lastIndexOf("/"),i=s,f=0;continue}}else if(2===n.length||1===n.length){n="",o=0,i=s,f=0;continue}e&&(n.length>0?n+="/..":n="..",o=2)}else n.length>0?n+="/"+t.slice(i+1,s):n=t.slice(i+1,s),o=s-i-1;i=s,f=0}else 46===r&&-1!==f?++f:f=-1}return n}var f={resolve:function(){for(var t,e="",r=!1,f=arguments.length-1;f>=-1&&!r;f--){var s;f>=0?s=arguments[f]:(void 0===t&&(t=n.cwd()),s=t),o(s),0!==s.length&&(e=s+"/"+e,r=47===s.charCodeAt(0))}return e=i(e,!r),r?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(t){if(o(t),0===t.length)return".";var e=47===t.charCodeAt(0),r=47===t.charCodeAt(t.length-1);return 0!==(t=i(t,!e)).length||e||(t="."),t.length>0&&r&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return o(t),t.length>0&&47===t.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var t,e=0;e0&&(void 0===t?t=r:t+="/"+r)}return void 0===t?".":f.normalize(t)},relative:function(t,e){if(o(t),o(e),t===e)return"";if((t=f.resolve(t))===(e=f.resolve(e)))return"";for(var r=1;rh){if(47===e.charCodeAt(s+a))return e.slice(s+a+1);if(0===a)return e.slice(s+a)}else i>h&&(47===t.charCodeAt(r+a)?c=a:0===a&&(c=0));break}var l=t.charCodeAt(r+a);if(l!==e.charCodeAt(s+a))break;47===l&&(c=a)}var g="";for(a=r+c+1;a<=n;++a)a!==n&&47!==t.charCodeAt(a)||(0===g.length?g+="..":g+="/..");return g.length>0?g+e.slice(s+c):(s+=c,47===e.charCodeAt(s)&&++s,e.slice(s))},_makeLong:function(t){return t},dirname:function(t){if(o(t),0===t.length)return".";for(var e=t.charCodeAt(0),r=47===e,n=-1,i=!0,f=t.length-1;f>=1;--f)if(47===(e=t.charCodeAt(f))){if(!i){n=f;break}}else i=!1;return-1===n?r?"/":".":r&&1===n?"//":t.slice(0,n)},basename:function(t,e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('"ext" argument must be a string');o(t);var r,n=0,i=-1,f=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var s=e.length-1,u=-1;for(r=t.length-1;r>=0;--r){var h=t.charCodeAt(r);if(47===h){if(!f){n=r+1;break}}else-1===u&&(f=!1,u=r+1),s>=0&&(h===e.charCodeAt(s)?-1==--s&&(i=r):(s=-1,i=u))}return n===i?i=u:-1===i&&(i=t.length),t.slice(n,i)}for(r=t.length-1;r>=0;--r)if(47===t.charCodeAt(r)){if(!f){n=r+1;break}}else-1===i&&(f=!1,i=r+1);return-1===i?"":t.slice(n,i)},extname:function(t){o(t);for(var e=-1,r=0,n=-1,i=!0,f=0,s=t.length-1;s>=0;--s){var u=t.charCodeAt(s);if(47!==u)-1===n&&(i=!1,n=s+1),46===u?-1===e?e=s:1!==f&&(f=1):-1!==e&&(f=-1);else if(!i){r=s+1;break}}return-1===e||-1===n||0===f||1===f&&e===n-1&&e===r+1?"":t.slice(e,n)},format:function(t){if(null===t||"object"!=typeof t)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return function(t,e){var r=e.dir||e.root,n=e.base||(e.name||"")+(e.ext||"");return r?r===e.root?r+n:r+"/"+n:n}(0,t)},parse:function(t){o(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;var r,n=t.charCodeAt(0),i=47===n;i?(e.root="/",r=1):r=0;for(var f=-1,s=0,u=-1,h=!0,c=t.length-1,a=0;c>=r;--c)if(47!==(n=t.charCodeAt(c)))-1===u&&(h=!1,u=c+1),46===n?-1===f?f=c:1!==a&&(a=1):-1!==f&&(a=-1);else if(!h){s=c+1;break}return-1===f||-1===u||0===a||1===a&&f===u-1&&f===s+1?-1!==u&&(e.base=e.name=0===s&&i?t.slice(1,u):t.slice(s,u)):(0===s&&i?(e.name=t.slice(1,f),e.base=t.slice(1,u)):(e.name=t.slice(s,f),e.base=t.slice(s,u)),e.ext=t.slice(f,u)),s>0?e.dir=t.slice(0,s-1):i&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};f.posix=f,t.exports=f},845:(t,e,r)=>{"use strict";let n,o;function i(){throw new Error("setTimeout has not been defined")}function f(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}r.r(e),r.d(e,{addListener:()=>v,argv:()=>C,binding:()=>L,browser:()=>A,chdir:()=>x,cwd:()=>S,default:()=>N,emit:()=>U,env:()=>d,listeners:()=>_,nextTick:()=>p,off:()=>j,on:()=>E,once:()=>B,prependListener:()=>R,prependOnceListener:()=>O,removeAllListeners:()=>M,removeListener:()=>T,title:()=>I,umask:()=>k,version:()=>w,versions:()=>b}),function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{o="function"==typeof clearTimeout?clearTimeout:f}catch(t){o=f}}();let u,h=[],c=!1,a=-1;function l(){if(c)return;const t=s(g);c=!0;let e=h.length;for(;e;){for(u=h,h=[];++a1)for(let t=1;t{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";r(239);var t=r(426);const e=globalThis.vulcan.__FILES__;function n(t){return globalThis.vulcan.FS_PATHS_CHANGED||""===globalThis.vulcan.FS_PATH_PREFIX_TO_REMOVE||Object.keys(e).forEach((t=>{const r=t.replace(globalThis.vulcan.FS_PATH_PREFIX_TO_REMOVE,"");e[r]=e[t],delete e[t]})),globalThis.vulcan.FS_PATHS_CHANGED=!0,e[t]}globalThis.vulcan.FS_PATHS_CHANGED=!1,Symbol("type"),Symbol("stats");const o={__proto__:null};function i(e,r){e=function(t){return t.endsWith("/")&&(t=t.slice(0,-1)),t.startsWith("/")||(t=`/${t}`),t}(e),r=function(e,r=o){if(null==e||"function"==typeof e)return r;if("string"==typeof e)(r={...r}).encoding=e,e=r;else if("object"!=typeof e)throw new Error("Invalid options!");return"buffer"!==e.encoding&&function(e){if(e&&!t.lW.isEncoding(e))throw new Error("Invalid encoding!")}(e.encoding),e.signal,e}(r,{flag:"r"});const i=n(e);if(void 0!==i){let e;return e=function(e,r=!0){const n=t.lW.from(e.content,"base64");return r?n:n.toString("utf8")}(i,"utf-8"!==r?.encoding),e}{const t=new Error(`ENOENT: no such file or directory, fs.readFileSync call for path '${e}'`);throw t.code="ENOENT",t}}addEventListener("fetch",(t=>{t.respondWith(async function(){try{const t=i("static-html/index.html","utf8");return new Response(t,{headers:{"content-type":"text/html;charset=UTF-8"}})}catch(t){return new Response(t.message||t.toString(),{status:500})}}())}))})()})(); \ No newline at end of file diff --git a/samples/polyfills/fs/.edge/worker.js.LICENSE.txt b/samples/polyfills/fs/.edge/worker.js.LICENSE.txt new file mode 100644 index 00000000..df537c53 --- /dev/null +++ b/samples/polyfills/fs/.edge/worker.js.LICENSE.txt @@ -0,0 +1,8 @@ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ diff --git a/samples/polyfills/fs/.vulcan b/samples/polyfills/fs/.vulcan new file mode 100644 index 00000000..98482e21 --- /dev/null +++ b/samples/polyfills/fs/.vulcan @@ -0,0 +1,6 @@ +preset=javascript +builder=webpack +entry=main.js +mode=compute +useNodePolyfills=true +useOwnWorker=false diff --git a/samples/polyfills/fs/azion/args.json b/samples/polyfills/fs/azion/args.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/samples/polyfills/fs/azion/args.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/samples/polyfills/fs/azion/azion.json b/samples/polyfills/fs/azion/azion.json new file mode 100644 index 00000000..7a73a41b --- /dev/null +++ b/samples/polyfills/fs/azion/azion.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/samples/polyfills/fs/main.js b/samples/polyfills/fs/main.js new file mode 100644 index 00000000..e01572da --- /dev/null +++ b/samples/polyfills/fs/main.js @@ -0,0 +1,12 @@ +import { readFileSync } from 'fs'; + +export default function myWorker(event) { + const data = readFileSync('static-html/index.html','utf8') + + return new Response(data, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }); +} + diff --git a/samples/polyfills/fs/static-html/index.html b/samples/polyfills/fs/static-html/index.html new file mode 100644 index 00000000..22faa880 --- /dev/null +++ b/samples/polyfills/fs/static-html/index.html @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + +
+
+    #    #  ####  #    # ######    #####  ####     ##### #    # ######    ###### #####   ####  ###### 
+    ##  ## #    # #    # #           #   #    #      #   #    # #         #      #    # #    # #      
+    # ## # #    # #    # #####       #   #    #      #   ###### #####     #####  #    # #      #####  
+    #    # #    # #    # #           #   #    #      #   #    # #         #      #    # #  ### #      
+    #    # #    #  #  #  #           #   #    #      #   #    # #         #      #    # #    # #      
+    #    #  ####    ##   ######      #    ####       #   #    # ######    ###### #####   ####  ###### 
+                                                                                                      
+    
+	
+ + diff --git a/samples/polyfills/fs/vulcan.config.js b/samples/polyfills/fs/vulcan.config.js new file mode 100644 index 00000000..5ec0a77f --- /dev/null +++ b/samples/polyfills/fs/vulcan.config.js @@ -0,0 +1,8 @@ +module.exports = { + entry: 'main.js', + builder: 'webpack', + useNodePolyfills: true, + memoryFS:{ + injectionDirs: ['static-html'], + } +} \ No newline at end of file