compressed-script-loader 1.2.6 → 1.2.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/README.md +6 -5
- package/bin/cslpack.js +15 -15
- package/index.d.ts +2 -1
- package/package.json +1 -1
- package/umd/index.js +9 -10
- package/unzip-sync.d.ts +0 -1
- package/webpack/index.js +9 -9
- package/webpack-esm/index.mjs +10 -10
package/README.md
CHANGED
|
@@ -65,12 +65,13 @@ You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the pref
|
|
|
65
65
|
"callback": "onLoadDone"
|
|
66
66
|
}'
|
|
67
67
|
type="text/javascript"
|
|
68
|
-
src="https://cdn.jsdelivr.net/npm/compressed-script-loader
|
|
68
|
+
src="https://cdn.jsdelivr.net/npm/compressed-script-loader/umd/index.js"
|
|
69
69
|
></script>
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
+ Supports simple `data-csl-config` (since v1.2.6)
|
|
73
|
-
+ In this case, the packed zip file must be deployed in the same directory as the page and
|
|
73
|
+
+ In this case, the packed zip file must be deployed in the same directory as the page and
|
|
74
|
+
If need a callback, define it as `cslCallback`.
|
|
74
75
|
|
|
75
76
|
```html
|
|
76
77
|
<script
|
|
@@ -87,16 +88,16 @@ You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the pref
|
|
|
87
88
|
> #### Load manually
|
|
88
89
|
|
|
89
90
|
```html
|
|
90
|
-
<script src="https://cdn.jsdelivr.net/npm/compressed-script-loader
|
|
91
|
+
<script src="https://cdn.jsdelivr.net/npm/compressed-script-loader/umd/index.js"></script>
|
|
91
92
|
<script>
|
|
92
93
|
// global variable `NsLoader` is available (umd)
|
|
93
94
|
(async () => {
|
|
94
|
-
const
|
|
95
|
+
const ZIPNAME = "system-coordinate-map-mini";
|
|
95
96
|
// If the packed zip file is located in the same directory as the page
|
|
96
97
|
// and you don't care where the script is inserted, you can skip this step.
|
|
97
98
|
NsLoader.setConfig("./libs"/*, "script[src*=css-2d-renderer]"*/);
|
|
98
99
|
|
|
99
|
-
await NsLoader.loadCompressedScript(
|
|
100
|
+
await NsLoader.loadCompressedScript(ZIPNAME);
|
|
100
101
|
// If you don't use it anymore, this step will destroy the loader api
|
|
101
102
|
NsLoader.cleanUp();
|
|
102
103
|
|
package/bin/cslpack.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*! For license information please see cslpack.js.LICENSE.txt */
|
|
3
|
-
(()=>{var _wm_={274:module=>{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
;
|
|
9
|
-
for(
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
;if(W>2&&L==z(_-Q))for(var V=Math.min(x,W)-1,X=Math.min(32767,_),Z=Math.min(258,W);Q<=X&&--K&&N!=R;){if(e[_+G]==e[_+G-Q]){for(var ee=0;ee<Z&&e[_+ee]==e[_+ee-Q];++ee);if(ee>G){if(G=ee,J=Q,ee>V)break;var re=Math.min(Q,ee-2),ne=0;for(H=0;H<re;++H){var te=_-Q+H+32768&32767,ae=te-k[te]+32768&32767;ae>ne&&(ne=ae,R=te)}}}Q+=(N=R)-(R=k[N])+32768&32767}if(J){
|
|
13
|
-
return~e}}},B=function(e,r,n,t,a){return P(e,null==r.level?6:r.level,null==r.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+r.mem,n,t,!a)},L=function(e,r){var n={};for(var t in e)n[t]=e[t];for(var t in r)n[t]=r[t];return n},N=function(e,r,n){for(;n;++r)e[r]=n,n>>>=8};function R(e,r){return B(e,r||{},0,0)}var W=function(e,r,n,t){for(var o in e){var i=e[o],f=r+o,s=t;Array.isArray(i)&&(s=L(t,i[1]),i=i[0]),i instanceof a?n[f]=[i,s]:(n[f+='/']=[new a(0),s],W(i,f,n,t))}},H='undefined'!=typeof TextEncoder&&new TextEncoder,G='undefined'!=typeof TextDecoder&&new TextDecoder;try{G.decode(
|
|
14
|
-
;var o=e.length,i=new a(e.length+(e.length>>1)),f=0,s=function(e){i[f++]=e};for(t=0;t<o;++t){if(f+5>i.length){var
|
|
15
|
-
;var v=new Date(null==n.mtime?Date.now():n.mtime),g=v.getFullYear()-1980;if((g<0||g>119)&&T(10),N(e,r,g<<25|v.getMonth()+1<<21|v.getDate()<<16|v.getHours()<<11|v.getMinutes()<<5|v.getSeconds()>>>1),r+=4,null!=o&&(N(e,r,n.crc),N(e,r+4,o),N(e,r+8,n.size)),N(e,r+12,s),N(e,r+14,
|
|
16
|
-
;const X=require("util"),Z=["zip","gz","png","jpg","jpeg","pdf","doc","docx","ppt","pptx","xls","xlsx","heic","heif","7z","bz2","rar","gif","webp","webm","mp4","mov","mp3","aifc"],ee=new X.TextEncoder;const re=n();console.log(re);const ne=new class{zipObj={};add(r,n){const a=t.parse(r),o=`${a.dir}/${a.base}`,i=ee.encode(e.readFileSync(o,"utf8"));i&&(this.zipObj[a.base]=[i,{level:-1===Z.indexOf(a.ext)?6:0,comment:n}])}emit(r){const n=`[fflate.zip:${r}]`;console.time(n);const o=function(e,r){r||(r={});var n={},t=[];W(e,'',n,r);var o=0,i=0;for(var f in n){var s=n[f],
|
|
17
|
-
u:v!=f.length||
|
|
3
|
+
(()=>{var _wm_={274:module=>{function getExtraArgs(argsConfig,debug=!1){debug&&console.log("process.argv: ",process.argv);let cfg=argsConfig||{};cfg=Object.assign({startIndex:2,prefix:"-"},cfg);const vIdx=cfg.prefix.length,eIdx=cfg.startIndex||2,params={};if(process.argv.length>eIdx){const cArgs=process.argv;for(let idx=eIdx;idx<cArgs.length;){const opt=cArgs[idx++];if(opt)if(opt.startsWith(cfg.prefix)){let v=cArgs[idx];void 0===v||v.startsWith(cfg.prefix)?v=!0:(/^\[.+\]$/.test(v)||/^\/[^/]+\/[gimuys]{0,6}$/.test(v)?v=eval(v):/\\,/.test(v)?v=v.replace(/\\,/g,","):/,/.test(v)?v=v.split(","):/^(?:-?\.?\d+(?:\.\d*)?|0x[\da-f]+)$/i.test(v)&&(v=+v),idx++),params[opt.substring(vIdx)]=v}else{let e=params.args;!e&&(params.args=e=[]),e.push(opt)}}}return params}
|
|
4
|
+
module.exports=getExtraArgs}},_wmc_={};function _wr_(e){var r=_wmc_[e];if(void 0!==r)return r.exports;var n=_wmc_[e]={exports:{}};return _wm_[e](n,n.exports,_wr_),n.exports}_wr_.r=e=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})};var _we_={};(()=>{"use strict";_wr_.r(_we_);const e=require("fs"),r=require("child_process");var n=_wr_(274);const t=require("path")
|
|
5
|
+
;var a=Uint8Array,o=Uint16Array,i=Uint32Array,f=new a([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new a([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),c=new a([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=function(e,r){for(var n=new o(31),t=0;t<31;++t)n[t]=r+=1<<e[t-1];var a=new i(n[30]);for(t=1;t<30;++t)for(var f=n[t];f<n[t+1];++f)a[f]=f-n[t]<<5|t;return[n,a]},u=l(f,2),v=u[0],g=u[1];v[28]=258,g[258]=28;for(var p=l(s,0),d=(p[0],p[1]),h=new o(32768),_=0;_<32768;++_){var m=(43690&_)>>>1|(21845&_)<<1;m=(61680&(m=(52428&m)>>>2|(13107&m)<<2))>>>4|(3855&m)<<4,h[_]=((65280&m)>>>8|(255&m)<<8)>>>1}var w=function(e,r,n){for(var t=e.length,a=0,i=new o(r);a<t;++a)e[a]&&++i[e[a]-1];var f,s=new o(r);for(a=0;a<r;++a)s[a]=s[a-1]+i[a-1]<<1;if(n){
|
|
6
|
+
f=new o(1<<r);var c=15-r;for(a=0;a<t;++a)if(e[a])for(var l=a<<4|e[a],u=r-e[a],v=s[e[a]-1]++<<u,g=v|(1<<u)-1;v<=g;++v)f[h[v]>>>c]=l}else for(f=new o(t),a=0;a<t;++a)e[a]&&(f[a]=h[s[e[a]-1]++]>>>15-e[a]);return f},x=new a(288);for(_=0;_<144;++_)x[_]=8;for(_=144;_<256;++_)x[_]=9;for(_=256;_<280;++_)x[_]=7;for(_=280;_<288;++_)x[_]=8;var b=new a(32);for(_=0;_<32;++_)b[_]=5;var y=w(x,9,0),k=w(b,5,0),E=function(e){return(e+7)/8|0},M=function(e,r,n){(null==r||r<0)&&(r=0),(null==n||n>e.length)&&(n=e.length);var t=new(2==e.BYTES_PER_ELEMENT?o:4==e.BYTES_PER_ELEMENT?i:a)(n-r);return t.set(e.subarray(r,n)),t
|
|
7
|
+
},A=['unexpected EOF','invalid block type','invalid length/literal','invalid distance','stream finished','no stream handler',,'no callback','invalid UTF-8 data','extra field too long','date not in range 1980-2099','filename too long','stream finishing','invalid zip data'],T=function(e,r,n){var t=new Error(r||A[e]);if(t.code=e,Error.captureStackTrace&&Error.captureStackTrace(t,T),!n)throw t;return t},S=function(e,r,n){n<<=7&r;var t=r/8|0;e[t]|=n,e[t+1]|=n>>>8},z=function(e,r,n){n<<=7&r;var t=r/8|0;e[t]|=n,e[t+1]|=n>>>8,e[t+2]|=n>>>16},q=function(e,r){for(var n=[],t=0;t<e.length;++t)e[t]&&n.push({s:t,f:e[t]});var i=n.length,f=n.slice();if(!i)return[D,0];if(1==i){var s=new a(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort((function(e,r){return e.f-r.f})),n.push({s:-1,f:25001})
|
|
8
|
+
;var c=n[0],l=n[1],u=0,v=1,g=2;for(n[0]={s:-1,f:c.f+l.f,l:c,r:l};v!=i-1;)c=n[n[u].f<n[g].f?u++:g++],l=n[u!=v&&n[u].f<n[g].f?u++:g++],n[v++]={s:-1,f:c.f+l.f,l:c,r:l};var p=f[0].s;for(t=1;t<i;++t)f[t].s>p&&(p=f[t].s);var d=new o(p+1),h=j(n[v-1],d,0);if(h>r){t=0;var _=0,m=h-r,w=1<<m;for(f.sort((function(e,r){return d[r.s]-d[e.s]||e.f-r.f}));t<i;++t){var x=f[t].s;if(!(d[x]>r))break;_+=w-(1<<h-d[x]),d[x]=r}for(_>>>=m;_>0;){var b=f[t].s;d[b]<r?_-=1<<r-d[b]++-1:++t}for(;t>=0&&_;--t){var y=f[t].s;d[y]==r&&(--d[y],++_)}h=r}return[new a(d),h]},j=function(e,r,n){return-1==e.s?Math.max(j(e.l,r,n+1),j(e.r,r,n+1)):r[e.s]=n},O=function(e){for(var r=e.length;r&&!e[--r];);for(var n=new o(++r),t=0,a=e[0],i=1,f=function(e){n[t++]=e},s=1;s<=r;++s)if(e[s]==a&&s!=r)++i;else{if(!a&&i>2){
|
|
9
|
+
for(;i>138;i-=138)f(32754);i>2&&(f(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(f(a),--i;i>6;i-=6)f(8304);i>2&&(f(i-3<<5|8208),i=0)}for(;i--;)f(a);i=1,a=e[s]}return[n.subarray(0,t),r]},I=function(e,r){for(var n=0,t=0;t<r.length;++t)n+=e[t]*r[t];return n},$=function(e,r,n){var t=n.length,a=E(r+2);e[a]=255&t,e[a+1]=t>>>8,e[a+2]=255^e[a],e[a+3]=255^e[a+1];for(var o=0;o<t;++o)e[a+o+4]=n[o];return 8*(a+4+t)},F=function(e,r,n,t,a,i,l,u,v,g,p){S(r,p++,n),++a[256];for(var d=q(a,15),h=d[0],_=d[1],m=q(i,15),E=m[0],M=m[1],A=O(h),T=A[0],j=A[1],F=O(E),C=F[0],D=F[1],P=new o(19),U=0;U<T.length;++U)P[31&T[U]]++;for(U=0;U<C.length;++U)P[31&C[U]]++;for(var Y=q(P,7),B=Y[0],L=Y[1],N=19;N>4&&!B[c[N-1]];--N);
|
|
10
|
+
var R,W,H,G,J=g+5<<3,K=I(a,x)+I(i,b)+l,Q=I(a,h)+I(i,E)+l+14+3*N+I(P,B)+(2*P[16]+3*P[17]+7*P[18]);if(J<=K&&J<=Q)return $(r,p,e.subarray(v,v+g));if(S(r,p,1+(Q<K)),p+=2,Q<K){R=w(h,_,0),W=h,H=w(E,M,0),G=E;var V=w(B,L,0);S(r,p,j-257),S(r,p+5,D-1),S(r,p+10,N-4),p+=14;for(U=0;U<N;++U)S(r,p+3*U,B[c[U]]);p+=3*N;for(var X=[T,C],Z=0;Z<2;++Z){var ee=X[Z];for(U=0;U<ee.length;++U){var re=31&ee[U];S(r,p,V[re]),p+=B[re],re>15&&(S(r,p,ee[U]>>>5&127),p+=ee[U]>>>12)}}}else R=y,W=x,H=k,G=b;for(U=0;U<u;++U)if(t[U]>255){re=t[U]>>>18&31;z(r,p,R[re+257]),p+=W[re+257],re>7&&(S(r,p,t[U]>>>23&31),p+=f[re]);var ne=31&t[U];z(r,p,H[ne]),p+=G[ne],ne>3&&(z(r,p,t[U]>>>5&8191),p+=s[ne])}else z(r,p,R[t[U]]),p+=W[t[U]];return z(r,p,R[256]),p+W[256]
|
|
11
|
+
},C=new i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),D=new a(0),P=function(e,r,n,t,c,l){var u=e.length,v=new a(t+u+5*(1+Math.ceil(u/7e3))+c),p=v.subarray(t,v.length-c),h=0;if(!r||u<8)for(var _=0;_<=u;_+=65535){var m=_+65535;m>=u&&(p[h>>3]=l),h=$(p,h+1,e.subarray(_,m))}else{for(var w=C[r-1],x=w>>>13,b=8191&w,y=(1<<n)-1,k=new o(32768),A=new o(y+1),T=Math.ceil(n/3),S=2*T,z=function(r){return(e[r]^e[r+1]<<T^e[r+2]<<S)&y},q=new i(25e3),j=new o(288),O=new o(32),I=0,P=0,U=(_=0,0),Y=0,B=0;_<u;++_){var L=z(_),N=32767&_,R=A[L];if(k[N]=R,A[L]=N,Y<=_){var W=u-_;if((I>7e3||U>24576)&&W>423){h=F(e,p,0,q,j,O,P,U,B,_-B,h),U=I=P=0,B=_;for(var H=0;H<286;++H)j[H]=0;for(H=0;H<30;++H)O[H]=0}var G=2,J=0,K=b,Q=N-R&32767
|
|
12
|
+
;if(W>2&&L==z(_-Q))for(var V=Math.min(x,W)-1,X=Math.min(32767,_),Z=Math.min(258,W);Q<=X&&--K&&N!=R;){if(e[_+G]==e[_+G-Q]){for(var ee=0;ee<Z&&e[_+ee]==e[_+ee-Q];++ee);if(ee>G){if(G=ee,J=Q,ee>V)break;var re=Math.min(Q,ee-2),ne=0;for(H=0;H<re;++H){var te=_-Q+H+32768&32767,ae=te-k[te]+32768&32767;ae>ne&&(ne=ae,R=te)}}}Q+=(N=R)-(R=k[N])+32768&32767}if(J){q[U++]=268435456|g[G]<<18|d[J];var oe=31&g[G],ie=31&d[J];P+=f[oe]+s[ie],++j[257+oe],++O[ie],Y=_+G,++I}else q[U++]=e[_],++j[e[_]]}}h=F(e,p,l,q,j,O,P,U,B,_-B,h),!l&&7&h&&(h=$(p,h+1,D))}return M(v,0,t+E(h)+c)},U=function(){for(var e=new Int32Array(256),r=0;r<256;++r){for(var n=r,t=9;--t;)n=(1&n&&-306674912)^n>>>1;e[r]=n}return e}(),Y=function(){var e=-1;return{p:function(r){for(var n=e,t=0;t<r.length;++t)n=U[255&n^r[t]]^n>>>8;e=n},d:function(){
|
|
13
|
+
return~e}}},B=function(e,r,n,t,a){return P(e,null==r.level?6:r.level,null==r.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+r.mem,n,t,!a)},L=function(e,r){var n={};for(var t in e)n[t]=e[t];for(var t in r)n[t]=r[t];return n},N=function(e,r,n){for(;n;++r)e[r]=n,n>>>=8};function R(e,r){return B(e,r||{},0,0)}var W=function(e,r,n,t){for(var o in e){var i=e[o],f=r+o,s=t;Array.isArray(i)&&(s=L(t,i[1]),i=i[0]),i instanceof a?n[f]=[i,s]:(n[f+='/']=[new a(0),s],W(i,f,n,t))}},H='undefined'!=typeof TextEncoder&&new TextEncoder,G='undefined'!=typeof TextDecoder&&new TextDecoder;try{G.decode(D,{stream:!0}),1}catch(e){}function J(e,r){if(r){for(var n=new a(e.length),t=0;t<e.length;++t)n[t]=e.charCodeAt(t);return n}if(H)return H.encode(e)
|
|
14
|
+
;var o=e.length,i=new a(e.length+(e.length>>1)),f=0,s=function(e){i[f++]=e};for(t=0;t<o;++t){if(f+5>i.length){var c=new a(f+8+(o-t<<1));c.set(i),i=c}var l=e.charCodeAt(t);l<128||r?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++t))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return M(i,0,f)}var K=function(e){var r=0;if(e)for(var n in e){var t=e[n].length;t>65535&&T(9),r+=t+4}return r},Q=function(e,r,n,t,a,o,i,f){var s=t.length,c=n.extra,l=f&&f.length,u=K(c);N(e,r,null!=i?33639248:67324752),r+=4,null!=i&&(e[r++]=20,e[r++]=n.os),e[r]=20,r+=2,e[r++]=n.flag<<1|(null==o&&8),e[r++]=a&&8,e[r++]=255&n.compression,e[r++]=n.compression>>8
|
|
15
|
+
;var v=new Date(null==n.mtime?Date.now():n.mtime),g=v.getFullYear()-1980;if((g<0||g>119)&&T(10),N(e,r,g<<25|v.getMonth()+1<<21|v.getDate()<<16|v.getHours()<<11|v.getMinutes()<<5|v.getSeconds()>>>1),r+=4,null!=o&&(N(e,r,n.crc),N(e,r+4,o),N(e,r+8,n.size)),N(e,r+12,s),N(e,r+14,u),r+=16,null!=i&&(N(e,r,l),N(e,r+6,n.attrs),N(e,r+10,i),r+=14),e.set(t,r),r+=s,u)for(var p in c){var d=c[p],h=d.length;N(e,r,+p),N(e,r+2,h),e.set(d,r+4),r+=4+h}return l&&(e.set(f,r),r+=l),r},V=function(e,r,n,t,a){N(e,r,101010256),N(e,r+8,n),N(e,r+10,n),N(e,r+12,t),N(e,r+16,a)};'function'==typeof queueMicrotask?queueMicrotask:'function'==typeof setTimeout&&setTimeout
|
|
16
|
+
;const X=require("util"),Z=["zip","gz","png","jpg","jpeg","pdf","doc","docx","ppt","pptx","xls","xlsx","heic","heif","7z","bz2","rar","gif","webp","webm","mp4","mov","mp3","aifc"],ee=new X.TextEncoder;const re=n();console.log(re);const ne=new class{zipObj={};add(r,n){const a=t.parse(r),o=`${a.dir}/${a.base}`,i=ee.encode(e.readFileSync(o,"utf8"));i&&(this.zipObj[a.base]=[i,{level:-1===Z.indexOf(a.ext)?6:0,comment:n}])}emit(r){const n=`[fflate.zip:${r}]`;console.time(n);const o=function(e,r){r||(r={});var n={},t=[];W(e,'',n,r);var o=0,i=0;for(var f in n){var s=n[f],c=s[0],l=s[1],u=0==l.level?0:8,v=(E=J(f)).length,g=l.comment,p=g&&J(g),d=p&&p.length,h=K(l.extra);v>65535&&T(11);var _=u?R(c,l):c,m=_.length,w=Y();w.p(c),t.push(L(l,{size:c.length,crc:w.d(),c:_,f:E,m:p,
|
|
17
|
+
u:v!=f.length||p&&g.length!=d,o,compression:u})),o+=30+v+h+m,i+=76+2*(v+h)+(d||0)+m}for(var x=new a(i+22),b=o,y=i-o,k=0;k<t.length;++k){var E=t[k];Q(x,E.o,E,E.f,E.u,E.c.length);var M=30+E.f.length+K(E.extra);x.set(E.c,E.o+M),Q(x,o,E,E.f,E.u,E.c.length,E.o,E.m),o+=16+M+(E.m?E.m.length:0)}return V(x,o,t.length,y,b),x}(this.zipObj,{});(r=>{const n=t.dirname(r);e.existsSync(n)||e.mkdirSync(n,{recursive:!0})})(r),e.writeFile(r,o,"binary",(()=>{console.timeEnd(n),this.zipObj={}}))}clear(){this.zipObj={}}};for(const n of re.args){if(e.statSync(n).isFile()){const e=r.execSync(`bash -c "echo -n $(openssl dgst -sha384 -binary ${n} | openssl base64 -A)"`,{encoding:"utf8"});ne.add(n,e)}}ne.emit(re.d||re.dest||"./dist/bundle.zip")})(),module.exports=_we_})();
|
package/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as Uz from "./unzip-sync";
|
|
9
9
|
declare global {
|
|
10
|
+
const NsLoader: typeof import("./umd");
|
|
10
11
|
let cslCallback: (() => void) | undefined;
|
|
11
12
|
interface Window {
|
|
12
13
|
cslCallback: (() => void) | undefined;
|
|
@@ -22,5 +23,5 @@ declare let unzipSync: typeof Uz.unzipSync;
|
|
|
22
23
|
declare let cleanUp: () => void;
|
|
23
24
|
declare let setConfig: (base: string, insertionSelector?: string | undefined) => void;
|
|
24
25
|
declare let loadCompressedScript: (baseName: string, log?: (msg: string) => void) => Promise<void>;
|
|
25
|
-
declare const version = "v1.2.
|
|
26
|
+
declare const version = "v1.2.7";
|
|
26
27
|
export { setConfig, loadCompressedScript, cleanUp, unzipSync, version };
|
package/package.json
CHANGED
package/umd/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t():'function'==typeof define&&define.amd?define([],t):'object'==typeof exports?exports.NsLoader=t():e.NsLoader=t()}(globalThis,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})}},t={};e.r(t),e.d(t,{cleanUp:()=>
|
|
2
|
+
!function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t():'function'==typeof define&&define.amd?define([],t):'object'==typeof exports?exports.NsLoader=t():e.NsLoader=t()}(globalThis,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})}},t={};e.r(t),e.d(t,{cleanUp:()=>q,loadCompressedScript:()=>Y,setConfig:()=>F,unzipSync:()=>B,version:()=>H})
|
|
3
3
|
;const n=Uint8Array,o=Uint16Array,r=Uint32Array,c=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=(e,t)=>{const n=new o(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];const c=new r(n[30]);for(let e=1;e<30;++e)for(let t=n[e];t<n[e+1];++t)c[t]=t-n[e]<<5|e;return[n,c]},[i,f]=a(c,2);i[28]=258,f[258]=28;const[d,u]=a(s,0),p=new o(32768);for(let e=0;e<32768;++e){let t=(43690&e)>>>1|(21845&e)<<1;t=(52428&t)>>>2|(13107&t)<<2,t=(61680&t)>>>4|(3855&t)<<4,p[e]=((65280&t)>>>8|(255&t)<<8)>>>1}const g=(e,t,n)=>{const r=e.length;let c=0;const s=new o(t);for(;c<r;++c)e[c]&&++s[e[c]-1];const l=new o(t);for(c=0;c<t;++c)l[c]=l[c-1]+s[c-1]<<1;let a
|
|
4
|
-
;if(n){a=new o(1<<t);const n=15-t;for(c=0;c<r;++c)if(e[c]){const o=c<<4|e[c],r=t-e[c];let s=l[e[c]-1]++<<r;for(const e=s|(1<<r)-1;s<=e;++s)a[p[s]>>>n]=o}}else for(a=new o(r),c=0;c<r;++c)e[c]&&(a[c]=p[l[e[c]-1]++]>>>15-e[c]);return a},y=new n(288);for(let e=0;e<144;++e)y[e]=8;for(let e=144;e<256;++e)y[e]=9;for(let e=256;e<280;++e)y[e]=7;for(let e=280;e<288;++e)y[e]=8;const h=new n(32);for(let e=0;e<32;++e)h[e]=5;const b=g(y,9,1),m=g(h,5,1),w=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},v=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},S=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},C=(e,t,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
;"function"==typeof t&&t(),B()}))}catch(e){console.error(e)}}}};setTimeout(J,250);const G="v1.2.6";return t})()));
|
|
4
|
+
;if(n){a=new o(1<<t);const n=15-t;for(c=0;c<r;++c)if(e[c]){const o=c<<4|e[c],r=t-e[c];let s=l[e[c]-1]++<<r;for(const e=s|(1<<r)-1;s<=e;++s)a[p[s]>>>n]=o}}else for(a=new o(r),c=0;c<r;++c)e[c]&&(a[c]=p[l[e[c]-1]++]>>>15-e[c]);return a},y=new n(288);for(let e=0;e<144;++e)y[e]=8;for(let e=144;e<256;++e)y[e]=9;for(let e=256;e<280;++e)y[e]=7;for(let e=280;e<288;++e)y[e]=8;const h=new n(32);for(let e=0;e<32;++e)h[e]=5;const b=g(y,9,1),m=g(h,5,1),w=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},v=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},S=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},C=[,n,o,,r],k=(e,t,n)=>{(!t||t<0)&&(t=0),(!n||n>e.length)&&(n=e.length);const o=new C[e.BYTES_PER_ELEMENT](n-t);return o.set(e.subarray(t,n)),o
|
|
5
|
+
},x=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$=(e,t,n)=>{const o=new Error(t||x[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,$),!n)throw o;return o},j=(e,t,o)=>{const r=e.length;if(!r||o&&o.f&&!o.l)return t||new n(0);const a=!t||!!o,f=!o||o.i;!o&&(o={}),!t&&(t=new n(3*r));const u=e=>{let o=t.length;if(e>o){const r=new n(Math.max(2*o,e));r.set(t),t=r}};let p=o.f||0,y=o.p||0,h=o.b||0,C=o.l,x=o.d,j=o.m,E=o.n;const T=8*r;do{if(!C){p=v(e,y,1);const c=v(e,y+1,3);if(y+=3,!c){const n=4+((y+7)/8|0),c=e[n-4]|e[n-3]<<8,s=n+c;if(s>r){f&&$(0);break}
|
|
6
|
+
a&&u(h+c),t.set(e.subarray(n,s),h),o.b=h+=c,o.p=y=8*s,o.f=p;continue}if(1===c)C=b,x=m,j=9,E=5;else if(2===c){const t=v(e,y,31)+257,o=v(e,y+10,15)+4,r=t+v(e,y+5,31)+1;y+=14;const c=new n(r),s=new n(19);for(let t=0;t<o;++t)s[l[t]]=v(e,y+3*t,7);y+=3*o;const a=w(s),i=(1<<a)-1,f=g(s,a,1);for(let t=0;t<r;){const n=f[v(e,y,i)];y+=15&n;const o=n>>>4;if(o<16)c[t++]=o;else{let n=0,r=0;for(16===o?(r=3+v(e,y,3),y+=2,n=c[t-1]):17===o?(r=3+v(e,y,7),y+=3):18===o&&(r=11+v(e,y,127),y+=7);r--;)c[t++]=n}}const d=c.subarray(0,t),u=c.subarray(t);j=w(d),E=w(u),C=g(d,j,1),x=g(u,E,1)}else $(1);if(y>T){f&&$(0);break}}a&&u(h+131072);const k=(1<<j)-1,z=(1<<E)-1;let O=y;for(;;O=y){const n=C[S(e,y)&k],o=n>>>4;if(y+=15&n,y>T){f&&$(0);break}if(n||$(2),o<256)t[h++]=o;else{if(256===o){O=y,C=void 0;break}{let n=o-254
|
|
7
|
+
;if(o>264){const t=o-257,r=c[t];n=v(e,y,(1<<r)-1)+i[t],y+=r}const r=x[S(e,y)&z],l=r>>>4;r||$(3),y+=15&r;let p=d[l];if(l>3){const t=s[l];p+=S(e,y)&(1<<t)-1,y+=t}if(y>T){f&&$(0);break}a&&u(h+131072);const g=h+n;for(;h<g;h+=4)t[h]=t[h-p],t[h+1]=t[h+1-p],t[h+2]=t[h+2-p],t[h+3]=t[h+3-p];h=g}}}o.l=C,o.p=O,o.b=h,o.f=p,C&&(p=1,o.m=j,o.d=x,o.n=E)}while(!p);return h===t.length?t:k(t,0,h)},E=(e,t)=>e[t]|e[t+1]<<8,T=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,z=(e,t)=>T(e,t)+4294967296*T(e,t+4),O=(e,t)=>t+30+E(e,t+26)+E(e,t+28),U=(e,t,n)=>{const o=!(2048&E(e,t+8)),r=E(e,t+28),c=M(e.subarray(t+46,t+46+r),o),s=t+46+r,l=T(e,t+20),[a,i,f]=n&&4294967295===l?P(e,s):[l,T(e,t+24),T(e,t+42)],d=s+E(e,t+30);return[E(e,t+10),a,i,c,s+E(e,t+30)+E(e,t+32),f,M(e.subarray(d,d+E(e,t+32)),o)]},P=(e,t)=>{
|
|
8
|
+
for(;1!=E(e,t);t+=4+E(e,t+2));return[z(e,t+12),z(e,t+4),z(e,t+20)]};let A;const L=new n(0);try{const e=new TextDecoder;e.decode(L,{stream:!0}),A=e}catch(e){}function M(e,t){if(t){let t="";for(let n=0;n<e.length;n+=16384)t+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return t}if(A)return A.decode(e);{const[t,n]=(e=>{for(let t="",n=0;;){let o=e[n++];const r=+(o>127)+ +(o>223)+ +(o>239);if(n+r>e.length)return[t,k(e,n-1)];r?3===r?(o=((15&o)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|o>>10,56320|1023&o)):t+=1&r?String.fromCharCode((31&o)<<6|63&e[n++]):String.fromCharCode((15&o)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(o)}})(e);return n.length&&$(8),t}}let N,R,_=new TextDecoder,B=function(e,t){const o={};let r=e.length-22
|
|
9
|
+
;for(;101010256!=T(e,r);--r)(!r||e.length-r>65558)&&$(13);let c=E(e,r+8);if(!c)return{};let s=T(e,r+16);const l=4294967295===s;l&&(r=T(e,r-12),101075792!=T(e,r)&&$(13),c=T(e,r+32),s=T(e,r+48));const a=t&&t.filter;for(let t=0;t<c;++t){const[t,r,c,i,f,d,u]=U(e,s,l),p=O(e,d);if(s=f,!a||a({name:i,size:r,originalSize:c,compression:t})){let s;t?8===t?s=j(e.subarray(p,p+r),new n(c)):$(14,"unknown compression type "+t):s=k(e,p,p+r),s&&(o[i]={data:s,comment:u})}}return o},q=()=>{_=void 0,J=F=Y=q=void 0,N=R=void 0,D=B=void 0},D=e=>{const t=/^(?:sha\d\d\d-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){const n=(e=t[1]).length;if(88===n||64===n||44===n)return`sha${64===n?384:88===n?512:256}-${e}`}},F=(e,t)=>{N=e,R=t||""},J=(e,t,n,o)=>{const r=()=>{n(),console.log(`script ${t} is ready`)}
|
|
10
|
+
;let c=R?document.querySelector(R).nextSibling:void 0;const s=document.head[c?"insertBefore":"appendChild"](document.createElement("script"),c);if(s.id=t,o){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));s.integrity=o,s.onload=r,s.src=t}else s.text=e,r()},Y=async(e,t=console.log)=>{const n=e+".zip",o=await fetch(`${N||"."}/${n}`).then((async e=>{const n=!!e.headers.get("content-encoding"),o=e.body.getReader(),r=(c=+e.headers.get("content-length"),n?1.3*c|0:c);var c;const s=new Uint8Array(r);let l=0;for(;;){const e=await o.read();if(e.done)break;s.set(e.value,l),l+=e.value.length,t(`loading zip: ${l.toLocaleString()} bytes(${Math.round(l/r*100)}%)`)}return n?s.slice(0,l):s})).catch((e=>(console.error(e),null)));if(o&&o.length){t(`loaded ${n}, decompressing binary...`),
|
|
11
|
+
console.time(`unzip: ${n}`);const e=B(o);return console.timeEnd(`unzip: ${n}`),t(`${n} decompressed 😃`),new Promise((t=>{const n=Object.keys(e);let o=n.length;const r=()=>{!--o&&t()};for(let t=0;t<n.length;){const o=n[t++],c=e[o];J(_.decode(c.data,{stream:!1}),o,r,D(c.comment))}}))}},G=()=>{G=void 0;const e=document.querySelector("script[data-csl-config]");if(e){const t=e.dataset.cslConfig;if(t){const e=JSON.parse(t);let n;"object"==typeof e?(F(e.base,e.selector),n=e.load):n=Array.isArray(e)?e:"string"==typeof e?[e]:[];try{const t=[];for(const e of n)t.push(Y(e));Promise.all(t).then((()=>{const t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"];"function"==typeof t&&t(),q()}))}catch(e){console.error(e)}}}};setTimeout(G,250);const H="v1.2.7";return t})()));
|
package/unzip-sync.d.ts
CHANGED
package/webpack/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})}},t={};e.r(t),e.d(t,{cleanUp:()=>
|
|
2
|
+
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})}},t={};e.r(t),e.d(t,{cleanUp:()=>D,loadCompressedScript:()=>Y,setConfig:()=>N,unzipSync:()=>q,version:()=>H});const n=Uint8Array,o=Uint16Array,r=Uint32Array,c=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=(e,t)=>{const n=new o(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];const c=new r(n[30])
|
|
3
3
|
;for(let e=1;e<30;++e)for(let t=n[e];t<n[e+1];++t)c[t]=t-n[e]<<5|e;return[n,c]},[i,f]=a(c,2);i[28]=258,f[258]=28;const[d,u]=a(s,0),g=new o(32768);for(let e=0;e<32768;++e){let t=(43690&e)>>>1|(21845&e)<<1;t=(52428&t)>>>2|(13107&t)<<2,t=(61680&t)>>>4|(3855&t)<<4,g[e]=((65280&t)>>>8|(255&t)<<8)>>>1}const h=(e,t,n)=>{const r=e.length;let c=0;const s=new o(t);for(;c<r;++c)e[c]&&++s[e[c]-1];const l=new o(t);for(c=0;c<t;++c)l[c]=l[c-1]+s[c-1]<<1;let a;if(n){a=new o(1<<t);const n=15-t;for(c=0;c<r;++c)if(e[c]){const o=c<<4|e[c],r=t-e[c];let s=l[e[c]-1]++<<r;for(const e=s|(1<<r)-1;s<=e;++s)a[g[s]>>>n]=o}}else for(a=new o(r),c=0;c<r;++c)e[c]&&(a[c]=g[l[e[c]-1]++]>>>15-e[c]);return a},p=new n(288);for(let e=0;e<144;++e)p[e]=8;for(let e=144;e<256;++e)p[e]=9;for(let e=256;e<280;++e)p[e]=7
|
|
4
|
-
;for(let e=280;e<288;++e)p[e]=8;const y=new n(32);for(let e=0;e<32;++e)y[e]=5;const b=h(p,9,1),m=h(y,5,1),w=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},v=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},S=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},C=(e,t,
|
|
5
|
-
Error.captureStackTrace&&Error.captureStackTrace(o,E),!n)throw o;return o},
|
|
6
|
-
;const o=n>>>4;if(o<16)c[t++]=o;else{let n=0,r=0;for(16
|
|
7
|
-
}while(!g);return y
|
|
8
|
-
let o=e[n++];const r=+(o>127)+ +(o>223)+ +(o>239);if(n+r>e.length)return[t,
|
|
9
|
-
;t?8===t?s=
|
|
10
|
-
const n=e+".zip",o=await fetch(`${
|
|
11
|
-
;const e=document.querySelector("script[data-csl-config]");if(e){const t=e.dataset.cslConfig;if(t){const e=JSON.parse(t);let n;"object"==typeof e?(
|
|
4
|
+
;for(let e=280;e<288;++e)p[e]=8;const y=new n(32);for(let e=0;e<32;++e)y[e]=5;const b=h(p,9,1),m=h(y,5,1),w=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},v=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},S=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},C=[,n,o,,r],k=(e,t,n)=>{(!t||t<0)&&(t=0),(!n||n>e.length)&&(n=e.length);const o=new C[e.BYTES_PER_ELEMENT](n-t);return o.set(e.subarray(t,n)),o},$=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],E=(e,t,n)=>{const o=new Error(t||$[e]);if(o.code=e,
|
|
5
|
+
Error.captureStackTrace&&Error.captureStackTrace(o,E),!n)throw o;return o},x=(e,t,o)=>{const r=e.length;if(!r||o&&o.f&&!o.l)return t||new n(0);const a=!t||!!o,f=!o||o.i;!o&&(o={}),!t&&(t=new n(3*r));const u=e=>{let o=t.length;if(e>o){const r=new n(Math.max(2*o,e));r.set(t),t=r}};let g=o.f||0,p=o.p||0,y=o.b||0,C=o.l,$=o.d,x=o.m,T=o.n;const z=8*r;do{if(!C){g=v(e,p,1);const c=v(e,p+1,3);if(p+=3,!c){const n=4+((p+7)/8|0),c=e[n-4]|e[n-3]<<8,s=n+c;if(s>r){f&&E(0);break}a&&u(y+c),t.set(e.subarray(n,s),y),o.b=y+=c,o.p=p=8*s,o.f=g;continue}if(1===c)C=b,$=m,x=9,T=5;else if(2===c){const t=v(e,p,31)+257,o=v(e,p+10,15)+4,r=t+v(e,p+5,31)+1;p+=14;const c=new n(r),s=new n(19);for(let t=0;t<o;++t)s[l[t]]=v(e,p+3*t,7);p+=3*o;const a=w(s),i=(1<<a)-1,f=h(s,a,1);for(let t=0;t<r;){const n=f[v(e,p,i)];p+=15&n
|
|
6
|
+
;const o=n>>>4;if(o<16)c[t++]=o;else{let n=0,r=0;for(16===o?(r=3+v(e,p,3),p+=2,n=c[t-1]):17===o?(r=3+v(e,p,7),p+=3):18===o&&(r=11+v(e,p,127),p+=7);r--;)c[t++]=n}}const d=c.subarray(0,t),u=c.subarray(t);x=w(d),T=w(u),C=h(d,x,1),$=h(u,T,1)}else E(1);if(p>z){f&&E(0);break}}a&&u(y+131072);const k=(1<<x)-1,O=(1<<T)-1;let j=p;for(;;j=p){const n=C[S(e,p)&k],o=n>>>4;if(p+=15&n,p>z){f&&E(0);break}if(n||E(2),o<256)t[y++]=o;else{if(256===o){j=p,C=void 0;break}{let n=o-254;if(o>264){const t=o-257,r=c[t];n=v(e,p,(1<<r)-1)+i[t],p+=r}const r=$[S(e,p)&O],l=r>>>4;r||E(3),p+=15&r;let g=d[l];if(l>3){const t=s[l];g+=S(e,p)&(1<<t)-1,p+=t}if(p>z){f&&E(0);break}a&&u(y+131072);const h=y+n;for(;y<h;y+=4)t[y]=t[y-g],t[y+1]=t[y+1-g],t[y+2]=t[y+2-g],t[y+3]=t[y+3-g];y=h}}}o.l=C,o.p=j,o.b=y,o.f=g,C&&(g=1,o.m=x,o.d=$,
|
|
7
|
+
o.n=T)}while(!g);return y===t.length?t:k(t,0,y)},T=(e,t)=>e[t]|e[t+1]<<8,z=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,O=(e,t)=>z(e,t)+4294967296*z(e,t+4),j=(e,t)=>t+30+T(e,t+26)+T(e,t+28),U=(e,t,n)=>{const o=!(2048&T(e,t+8)),r=T(e,t+28),c=L(e.subarray(t+46,t+46+r),o),s=t+46+r,l=z(e,t+20),[a,i,f]=n&&4294967295===l?P(e,s):[l,z(e,t+24),z(e,t+42)],d=s+T(e,t+30);return[T(e,t+10),a,i,c,s+T(e,t+30)+T(e,t+32),f,L(e.subarray(d,d+T(e,t+32)),o)]},P=(e,t)=>{for(;1!=T(e,t);t+=4+T(e,t+2));return[O(e,t+12),O(e,t+4),O(e,t+20)]};let A;const M=new n(0);try{const e=new TextDecoder;e.decode(M,{stream:!0}),A=e}catch(e){}function L(e,t){if(t){let t="";for(let n=0;n<e.length;n+=16384)t+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return t}if(A)return A.decode(e);{const[t,n]=(e=>{
|
|
8
|
+
for(let t="",n=0;;){let o=e[n++];const r=+(o>127)+ +(o>223)+ +(o>239);if(n+r>e.length)return[t,k(e,n-1)];r?3===r?(o=((15&o)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|o>>10,56320|1023&o)):t+=1&r?String.fromCharCode((31&o)<<6|63&e[n++]):String.fromCharCode((15&o)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(o)}})(e);return n.length&&E(8),t}}let R,_,B=new TextDecoder,q=function(e,t){const o={};let r=e.length-22;for(;101010256!=z(e,r);--r)(!r||e.length-r>65558)&&E(13);let c=T(e,r+8);if(!c)return{};let s=z(e,r+16);const l=4294967295===s;l&&(r=z(e,r-12),101075792!=z(e,r)&&E(13),c=z(e,r+32),s=z(e,r+48));const a=t&&t.filter;for(let t=0;t<c;++t){const[t,r,c,i,f,d,u]=U(e,s,l),g=j(e,d);if(s=f,!a||a({name:i,size:r,originalSize:c,compression:t})){let s
|
|
9
|
+
;t?8===t?s=x(e.subarray(g,g+r),new n(c)):E(14,"unknown compression type "+t):s=k(e,g,g+r),s&&(o[i]={data:s,comment:u})}}return o},D=()=>{B=void 0,J=N=Y=D=void 0,R=_=void 0,F=q=void 0},F=e=>{const t=/^(?:sha\d\d\d-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){const n=(e=t[1]).length;if(88===n||64===n||44===n)return`sha${64===n?384:88===n?512:256}-${e}`}},N=(e,t)=>{R=e,_=t||""},J=(e,t,n,o)=>{const r=()=>{n(),console.log(`script ${t} is ready`)};let c=_?document.querySelector(_).nextSibling:void 0;const s=document.head[c?"insertBefore":"appendChild"](document.createElement("script"),c);if(s.id=t,o){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));s.integrity=o,s.onload=r,s.src=t}else s.text=e,r()},Y=async(e,t=console.log)=>{
|
|
10
|
+
const n=e+".zip",o=await fetch(`${R||"."}/${n}`).then((async e=>{const n=!!e.headers.get("content-encoding"),o=e.body.getReader(),r=(c=+e.headers.get("content-length"),n?1.3*c|0:c);var c;const s=new Uint8Array(r);let l=0;for(;;){const e=await o.read();if(e.done)break;s.set(e.value,l),l+=e.value.length,t(`loading zip: ${l.toLocaleString()} bytes(${Math.round(l/r*100)}%)`)}return n?s.slice(0,l):s})).catch((e=>(console.error(e),null)));if(o&&o.length){t(`loaded ${n}, decompressing binary...`),console.time(`unzip: ${n}`);const e=q(o);return console.timeEnd(`unzip: ${n}`),t(`${n} decompressed 😃`),new Promise((t=>{const n=Object.keys(e);let o=n.length;const r=()=>{!--o&&t()};for(let t=0;t<n.length;){const o=n[t++],c=e[o];J(B.decode(c.data,{stream:!1}),o,r,F(c.comment))}}))}},G=()=>{G=void 0
|
|
11
|
+
;const e=document.querySelector("script[data-csl-config]");if(e){const t=e.dataset.cslConfig;if(t){const e=JSON.parse(t);let n;"object"==typeof e?(N(e.base,e.selector),n=e.load):n=Array.isArray(e)?e:"string"==typeof e?[e]:[];try{const t=[];for(const e of n)t.push(Y(e));Promise.all(t).then((()=>{const t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"];"function"==typeof t&&t(),D()}))}catch(e){console.error(e)}}}};setTimeout(G,250);const H="v1.2.7";module.exports=t})();
|
package/webpack-esm/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*! For license information please see index.mjs.LICENSE.txt */
|
|
2
|
-
var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{Lx:()=>
|
|
3
|
-
t=(61680&t)>>>4|(3855&t)<<4,g[e]=((65280&t)>>>8|(255&t)<<8)>>>1}const h=(e,t,n)=>{const r=e.length;let c=0;const s=new o(t);for(;c<r;++c)e[c]&&++s[e[c]-1];const
|
|
4
|
-
const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},S=(e,t,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const o=!(2048
|
|
8
|
-
t+=String.fromCharCode(55296|o>>10,56320|1023&o)):t+=1&r?String.fromCharCode((31&o)<<6|63&e[n++]):String.fromCharCode((15&o)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(o)}})(e);return n.length
|
|
9
|
-
q=
|
|
10
|
-
;for(;;){const e=await o.read();if(e.done)break;s.set(e.value,
|
|
11
|
-
;try{const t=[];for(const e of n)t.push(
|
|
2
|
+
var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{Lx:()=>D,aN:()=>_,v6:()=>G,GZ:()=>q,i8:()=>Y});const n=Uint8Array,o=Uint16Array,r=Uint32Array,c=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=(e,t)=>{const n=new o(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];const c=new r(n[30]);for(let e=1;e<30;++e)for(let t=n[e];t<n[e+1];++t)c[t]=t-n[e]<<5|e;return[n,c]},[i,f]=l(c,2);i[28]=258,f[258]=28;const[d,u]=l(s,0),g=new o(32768);for(let e=0;e<32768;++e){let t=(43690&e)>>>1|(21845&e)<<1;t=(52428&t)>>>2|(13107&t)<<2,
|
|
3
|
+
t=(61680&t)>>>4|(3855&t)<<4,g[e]=((65280&t)>>>8|(255&t)<<8)>>>1}const h=(e,t,n)=>{const r=e.length;let c=0;const s=new o(t);for(;c<r;++c)e[c]&&++s[e[c]-1];const a=new o(t);for(c=0;c<t;++c)a[c]=a[c-1]+s[c-1]<<1;let l;if(n){l=new o(1<<t);const n=15-t;for(c=0;c<r;++c)if(e[c]){const o=c<<4|e[c],r=t-e[c];let s=a[e[c]-1]++<<r;for(const e=s|(1<<r)-1;s<=e;++s)l[g[s]>>>n]=o}}else for(l=new o(r),c=0;c<r;++c)e[c]&&(l[c]=g[a[e[c]-1]++]>>>15-e[c]);return l},p=new n(288);for(let e=0;e<144;++e)p[e]=8;for(let e=144;e<256;++e)p[e]=9;for(let e=256;e<280;++e)p[e]=7;for(let e=280;e<288;++e)p[e]=8;const y=new n(32);for(let e=0;e<32;++e)y[e]=5;const b=h(p,9,1),m=h(y,5,1),w=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},v=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},C=(e,t)=>{
|
|
4
|
+
const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},k=[,n,o,,r],S=(e,t,n)=>{(!t||t<0)&&(t=0),(!n||n>e.length)&&(n=e.length);const o=new k[e.BYTES_PER_ELEMENT](n-t);return o.set(e.subarray(t,n)),o},x=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$=(e,t,n)=>{const o=new Error(t||x[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,$),!n)throw o;return o},E=(e,t,o)=>{const r=e.length;if(!r||o&&o.f&&!o.l)return t||new n(0);const l=!t||!!o,f=!o||o.i;!o&&(o={}),!t&&(t=new n(3*r));const u=e=>{let o=t.length;if(e>o){const r=new n(Math.max(2*o,e));r.set(t),t=r
|
|
5
|
+
}};let g=o.f||0,p=o.p||0,y=o.b||0,k=o.l,x=o.d,E=o.m,z=o.n;const T=8*r;do{if(!k){g=v(e,p,1);const c=v(e,p+1,3);if(p+=3,!c){const n=4+((p+7)/8|0),c=e[n-4]|e[n-3]<<8,s=n+c;if(s>r){f&&$(0);break}l&&u(y+c),t.set(e.subarray(n,s),y),o.b=y+=c,o.p=p=8*s,o.f=g;continue}if(1===c)k=b,x=m,E=9,z=5;else if(2===c){const t=v(e,p,31)+257,o=v(e,p+10,15)+4,r=t+v(e,p+5,31)+1;p+=14;const c=new n(r),s=new n(19);for(let t=0;t<o;++t)s[a[t]]=v(e,p+3*t,7);p+=3*o;const l=w(s),i=(1<<l)-1,f=h(s,l,1);for(let t=0;t<r;){const n=f[v(e,p,i)];p+=15&n;const o=n>>>4;if(o<16)c[t++]=o;else{let n=0,r=0;for(16===o?(r=3+v(e,p,3),p+=2,n=c[t-1]):17===o?(r=3+v(e,p,7),p+=3):18===o&&(r=11+v(e,p,127),p+=7);r--;)c[t++]=n}}const d=c.subarray(0,t),u=c.subarray(t);E=w(d),z=w(u),k=h(d,E,1),x=h(u,z,1)}else $(1);if(p>T){f&&$(0);break}}
|
|
6
|
+
l&&u(y+131072);const S=(1<<E)-1,U=(1<<z)-1;let O=p;for(;;O=p){const n=k[C(e,p)&S],o=n>>>4;if(p+=15&n,p>T){f&&$(0);break}if(n||$(2),o<256)t[y++]=o;else{if(256===o){O=p,k=void 0;break}{let n=o-254;if(o>264){const t=o-257,r=c[t];n=v(e,p,(1<<r)-1)+i[t],p+=r}const r=x[C(e,p)&U],a=r>>>4;r||$(3),p+=15&r;let g=d[a];if(a>3){const t=s[a];g+=C(e,p)&(1<<t)-1,p+=t}if(p>T){f&&$(0);break}l&&u(y+131072);const h=y+n;for(;y<h;y+=4)t[y]=t[y-g],t[y+1]=t[y+1-g],t[y+2]=t[y+2-g],t[y+3]=t[y+3-g];y=h}}}o.l=k,o.p=O,o.b=y,o.f=g,k&&(g=1,o.m=E,o.d=x,o.n=z)}while(!g);return y===t.length?t:S(t,0,y)},z=(e,t)=>e[t]|e[t+1]<<8,T=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,U=(e,t)=>T(e,t)+4294967296*T(e,t+4),O=(e,t)=>t+30+z(e,t+26)+z(e,t+28),j=(e,t,n)=>{
|
|
7
|
+
const o=!(2048&z(e,t+8)),r=z(e,t+28),c=N(e.subarray(t+46,t+46+r),o),s=t+46+r,a=T(e,t+20),[l,i,f]=n&&4294967295===a?A(e,s):[a,T(e,t+24),T(e,t+42)],d=s+z(e,t+30);return[z(e,t+10),l,i,c,s+z(e,t+30)+z(e,t+32),f,N(e.subarray(d,d+z(e,t+32)),o)]},A=(e,t)=>{for(;1!=z(e,t);t+=4+z(e,t+2));return[U(e,t+12),U(e,t+4),U(e,t+20)]};let L;const P=new n(0);try{const e=new TextDecoder;e.decode(P,{stream:!0}),L=e}catch(e){}function N(e,t){if(t){let t="";for(let n=0;n<e.length;n+=16384)t+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return t}if(L)return L.decode(e);{const[t,n]=(e=>{for(let t="",n=0;;){let o=e[n++];const r=+(o>127)+ +(o>223)+ +(o>239);if(n+r>e.length)return[t,S(e,n-1)];r?3===r?(o=((15&o)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,
|
|
8
|
+
t+=String.fromCharCode(55296|o>>10,56320|1023&o)):t+=1&r?String.fromCharCode((31&o)<<6|63&e[n++]):String.fromCharCode((15&o)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(o)}})(e);return n.length&&$(8),t}}let R,B,M=new TextDecoder,q=function(e,t){const o={};let r=e.length-22;for(;101010256!=T(e,r);--r)(!r||e.length-r>65558)&&$(13);let c=z(e,r+8);if(!c)return{};let s=T(e,r+16);const a=4294967295===s;a&&(r=T(e,r-12),101075792!=T(e,r)&&$(13),c=T(e,r+32),s=T(e,r+48));const l=t&&t.filter;for(let t=0;t<c;++t){const[t,r,c,i,f,d,u]=j(e,s,a),g=O(e,d);if(s=f,!l||l({name:i,size:r,originalSize:c,compression:t})){let s;t?8===t?s=E(e.subarray(g,g+r),new n(c)):$(14,"unknown compression type "+t):s=S(e,g,g+r),s&&(o[i]={data:s,comment:u})}}return o},D=()=>{M=void 0,Z=G=_=D=void 0,R=B=void 0,
|
|
9
|
+
F=q=void 0},F=e=>{const t=/^(?:sha\d\d\d-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){const n=(e=t[1]).length;if(88===n||64===n||44===n)return`sha${64===n?384:88===n?512:256}-${e}`}},G=(e,t)=>{R=e,B=t||""},Z=(e,t,n,o)=>{const r=()=>{n(),console.log(`script ${t} is ready`)};let c=B?document.querySelector(B).nextSibling:void 0;const s=document.head[c?"insertBefore":"appendChild"](document.createElement("script"),c);if(s.id=t,o){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));s.integrity=o,s.onload=r,s.src=t}else s.text=e,r()},_=async(e,t=console.log)=>{const n=e+".zip",o=await fetch(`${R||"."}/${n}`).then((async e=>{const n=!!e.headers.get("content-encoding"),o=e.body.getReader(),r=(c=+e.headers.get("content-length"),n?1.3*c|0:c);var c;const s=new Uint8Array(r);let a=0
|
|
10
|
+
;for(;;){const e=await o.read();if(e.done)break;s.set(e.value,a),a+=e.value.length,t(`loading zip: ${a.toLocaleString()} bytes(${Math.round(a/r*100)}%)`)}return n?s.slice(0,a):s})).catch((e=>(console.error(e),null)));if(o&&o.length){t(`loaded ${n}, decompressing binary...`),console.time(`unzip: ${n}`);const e=q(o);return console.timeEnd(`unzip: ${n}`),t(`${n} decompressed 😃`),new Promise((t=>{const n=Object.keys(e);let o=n.length;const r=()=>{!--o&&t()};for(let t=0;t<n.length;){const o=n[t++],c=e[o];Z(M.decode(c.data,{stream:!1}),o,r,F(c.comment))}}))}},J=()=>{J=void 0;const e=document.querySelector("script[data-csl-config]");if(e){const t=e.dataset.cslConfig;if(t){const e=JSON.parse(t);let n;"object"==typeof e?(G(e.base,e.selector),n=e.load):n=Array.isArray(e)?e:"string"==typeof e?[e]:[]
|
|
11
|
+
;try{const t=[];for(const e of n)t.push(_(e));Promise.all(t).then((()=>{const t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"];"function"==typeof t&&t(),D()}))}catch(e){console.error(e)}}}};setTimeout(J,250);const Y="v1.2.7";var H=t.Lx,I=t.aN,K=t.v6,Q=t.GZ,V=t.i8;export{H as cleanUp,I as loadCompressedScript,K as setConfig,Q as unzipSync,V as version};
|