@areb0s/scip.js 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/scip.min.js CHANGED
@@ -1,30 +1,16 @@
1
1
 
2
- // Polyfill for import.meta.url in IIFE context (supports Worker)
2
+ // Polyfill for import.meta.url in IIFE context
3
+ // Always use CDN as the base URL for WASM loading
3
4
  var __importMetaUrl = (function() {
4
- // Worker environment
5
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
6
- // Check if SCIP_WASM_BASE_URL is defined (user can set this before loading)
7
- if (typeof SCIP_WASM_BASE_URL !== 'undefined') {
8
- return SCIP_WASM_BASE_URL;
9
- }
10
- // Fallback to self.location
11
- return self.location.href;
5
+ var CDN_BASE = 'https://cdn.jsdelivr.net/gh/areb0s/scip.js/dist/scip.min.js';
6
+
7
+ // Check for explicit SCIP_BASE_URL first
8
+ if (typeof SCIP_BASE_URL !== 'undefined' && SCIP_BASE_URL) {
9
+ return SCIP_BASE_URL + (SCIP_BASE_URL.endsWith('/') ? '' : '/') + 'scip.min.js';
12
10
  }
13
- // Browser main thread
14
- if (typeof document !== 'undefined') {
15
- if (document.currentScript && document.currentScript.src) {
16
- return document.currentScript.src;
17
- }
18
- var scripts = document.getElementsByTagName('script');
19
- for (var i = scripts.length - 1; i >= 0; i--) {
20
- var src = scripts[i].src;
21
- if (src && (src.includes('scip') && src.includes('.js'))) {
22
- return src;
23
- }
24
- }
25
- return window.location.href;
26
- }
27
- return '';
11
+
12
+ // Always return CDN - this ensures WASM is loaded from CDN
13
+ return CDN_BASE;
28
14
  })();
29
15
 
30
16
  var SCIPModule=(()=>{var je=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var zt=(d,y)=>()=>(d&&(y=d(d=0)),y);var vr=(d,y)=>{for(var u in y)je(d,u,{get:y[u],enumerable:!0})},Lt=(d,y,u,z)=>{if(y&&typeof y=="object"||typeof y=="function")for(let F of xt(y))!It.call(d,F)&&F!==u&&je(d,F,{get:()=>y[F],enumerable:!(z=Ct(y,F))||z.enumerable});return d};var Ut=d=>Lt(je({},"__esModule",{value:!0}),d);var hr={};vr(hr,{default:()=>Bt});var Ot,Bt,pr=zt(()=>{Ot=(()=>{var d=__importMetaUrl;return function(y={}){var u=y,z,F;u.ready=new Promise((e,r)=>{z=e,F=r});var O=Object.assign({},u),ne=[],B="./this.program",q=(e,r)=>{throw r},L=typeof window=="object",V=typeof importScripts=="function",Ae=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",R="";function Re(e){return u.locateFile?u.locateFile(e,R):R+e}var se,ve,le;(L||V)&&(V?R=self.location.href:typeof document<"u"&&document.currentScript&&(R=document.currentScript.src),d&&(R=d),R.startsWith("blob:")?R="":R=R.substr(0,R.replace(/[?#].*/,"").lastIndexOf("/")+1),se=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},V&&(le=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),ve=(e,r,t)=>{var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.onload=()=>{if(o.status==200||o.status==0&&o.response){r(o.response);return}t()},o.onerror=t,o.send(null)});var ue=u.print||console.log.bind(console),W=u.printErr||console.error.bind(console);Object.assign(u,O),O=null,u.arguments&&(ne=u.arguments),u.thisProgram&&(B=u.thisProgram),u.quit&&(q=u.quit);var K;u.wasmBinary&&(K=u.wasmBinary);var Q,fe=!1,he,I,ee,pe,wr,_,M,yr,_r;function $e(){var e=Q.buffer;u.HEAP8=I=new Int8Array(e),u.HEAP16=pe=new Int16Array(e),u.HEAPU8=ee=new Uint8Array(e),u.HEAPU16=wr=new Uint16Array(e),u.HEAP32=_=new Int32Array(e),u.HEAPU32=M=new Uint32Array(e),u.HEAPF32=yr=new Float32Array(e),u.HEAPF64=_r=new Float64Array(e)}var qe=[],Xe=[],gr=[],Ge=[],Er=!1;function kr(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)Dr(u.preRun.shift());ye(qe)}function Sr(){Er=!0,!u.noFSInit&&!n.init.initialized&&n.init(),n.ignorePermissions=!1,J.init(),ye(Xe)}function br(){ye(gr)}function Fr(){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)Mr(u.postRun.shift());ye(Ge)}function Dr(e){qe.unshift(e)}function Pr(e){Xe.unshift(e)}function Mr(e){Ge.unshift(e)}var re=0,Te=null,ce=null;function Vt(e){return e}function we(e){re++,u.monitorRunDependencies?.(re)}function de(e){if(re--,u.monitorRunDependencies?.(re),re==0&&(Te!==null&&(clearInterval(Te),Te=null),ce)){var r=ce;ce=null,r()}}function Ne(e){u.onAbort?.(e),e="Aborted("+e+")",W(e),fe=!0,he=1,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw F(r),r}var Ar="data:application/octet-stream;base64,",Ve=e=>e.startsWith(Ar),te;u.locateFile?(te="scip.wasm",Ve(te)||(te=Re(te))):te=new URL("scip.wasm",__importMetaUrl).href;function Ke(e){if(e==te&&K)return new Uint8Array(K);if(le)return le(e);throw"both async and sync fetching of the wasm failed"}function Rr(e){return!K&&(L||V)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw`failed to load wasm binary file at '${e}'`;return r.arrayBuffer()}).catch(()=>Ke(e)):Promise.resolve().then(()=>Ke(e))}function Je(e,r,t){return Rr(e).then(o=>WebAssembly.instantiate(o,r)).then(t,o=>{W(`failed to asynchronously prepare wasm: ${o}`),Ne(o)})}function Tr(e,r,t,o){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!Ve(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(a=>{var i=WebAssembly.instantiateStreaming(a,t);return i.then(o,function(s){return W(`wasm streaming compile failed: ${s}`),W("falling back to ArrayBuffer instantiation"),Je(r,t,o)})}):Je(r,t,o)}function Nr(){var e={a:Tt};function r(o,a){return G=o.exports,Q=G.y,$e(),Pr(G.z),de("wasm-instantiate"),G}we("wasm-instantiate");function t(o){r(o.instance)}if(u.instantiateWasm)try{return u.instantiateWasm(e,r)}catch(o){W(`Module.instantiateWasm callback failed with error: ${o}`),F(o)}return Tr(K,te,e,t).catch(F),{}}var g,N;function Ze(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var ye=e=>{for(;e.length>0;)e.shift()(u)},Cr=u.noExitRuntime||!0;class xr{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){M[this.ptr+4>>2]=r}get_type(){return M[this.ptr+4>>2]}set_destructor(r){M[this.ptr+8>>2]=r}get_destructor(){return M[this.ptr+8>>2]}set_caught(r){r=r?1:0,I[this.ptr+12]=r}get_caught(){return I[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,I[this.ptr+13]=r}get_rethrown(){return I[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){M[this.ptr+16>>2]=r}get_adjusted_ptr(){return M[this.ptr+16>>2]}get_exception_ptr(){var r=fr(this.get_type());if(r)return M[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Qe=0,Ir=0,zr=(e,r,t)=>{var o=new xr(e);throw o.init(r,t),Qe=e,Ir++,Qe},D={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,o=e.length-1;o>=0;o--){var a=e[o];a==="."?e.splice(o,1):a===".."?(e.splice(o,1),t++):t&&(e.splice(o,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=D.isAbs(e),t=e.substr(-1)==="/";return e=D.normalizeArray(e.split("/").filter(o=>!!o),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=D.splitPath(e),t=r[0],o=r[1];return!t&&!o?".":(o&&(o=o.substr(0,o.length-1)),t+o)},basename:e=>{if(e==="/")return"/";e=D.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>D.normalize(e.join("/")),join2:(e,r)=>D.normalize(e+"/"+r)},Lr=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);Ne("initRandomDevice")},er=e=>(er=Lr())(e),X={resolve:(...e)=>{for(var r="",t=!1,o=e.length-1;o>=-1&&!t;o--){var a=o>=0?e[o]:n.cwd();if(typeof a!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!a)return"";r=a+"/"+r,t=D.isAbs(a)}return r=D.normalizeArray(r.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=X.resolve(e).substr(1),r=X.resolve(r).substr(1);function t(p){for(var k=0;k<p.length&&p[k]==="";k++);for(var b=p.length-1;b>=0&&p[b]==="";b--);return k>b?[]:p.slice(k,b-k+1)}for(var o=t(e.split("/")),a=t(r.split("/")),i=Math.min(o.length,a.length),s=i,l=0;l<i;l++)if(o[l]!==a[l]){s=l;break}for(var c=[],l=s;l<o.length;l++)c.push("..");return c=c.concat(a.slice(s)),c.join("/")}},rr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,oe=(e,r,t)=>{for(var o=r+t,a=r;e[a]&&!(a>=o);)++a;if(a-r>16&&e.buffer&&rr)return rr.decode(e.subarray(r,a));for(var i="";r<a;){var s=e[r++];if(!(s&128)){i+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|l);continue}var c=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|c:s=(s&7)<<18|l<<12|c<<6|e[r++]&63,s<65536)i+=String.fromCharCode(s);else{var p=s-65536;i+=String.fromCharCode(55296|p>>10,56320|p&1023)}}return i},Ce=[],xe=e=>{for(var r=0,t=0;t<e.length;++t){var o=e.charCodeAt(t);o<=127?r++:o<=2047?r+=2:o>=55296&&o<=57343?(r+=4,++t):r+=3}return r},Ie=(e,r,t,o)=>{if(!(o>0))return 0;for(var a=t,i=t+o-1,s=0;s<e.length;++s){var l=e.charCodeAt(s);if(l>=55296&&l<=57343){var c=e.charCodeAt(++s);l=65536+((l&1023)<<10)|c&1023}if(l<=127){if(t>=i)break;r[t++]=l}else if(l<=2047){if(t+1>=i)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=i)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=i)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63}}return r[t]=0,t-a};function _e(e,r,t){var o=t>0?t:xe(e)+1,a=new Array(o),i=Ie(e,a,0,a.length);return r&&(a.length=i),a}var Ur=()=>{if(!Ce.length){var e=null;if(typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`