compressed-script-loader 1.2.7 → 1.2.10
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 +47 -28
- package/bin/cslpack.js +16 -15
- package/index.d.ts +6 -4
- package/package.json +2 -2
- package/umd/index.js +11 -10
- package/unzip-sync.d.ts +1 -1
- package/webpack/index.js +9 -9
- package/webpack-esm/index.mjs +8 -8
package/README.md
CHANGED
|
@@ -5,36 +5,27 @@
|
|
|
5
5
|

|
|
6
6
|
|
|
7
7
|
[1]:https://github.com/101arrowz/fflate
|
|
8
|
+
[2]:https://www.w3.org/TR/SRI/
|
|
8
9
|
|
|
9
10
|
# compressed-script-loader
|
|
10
11
|
|
|
12
|
+
Reduces network traffic for huge source files built by webpack etc.
|
|
13
|
+
|
|
14
|
+
## Motivation
|
|
15
|
+
|
|
16
|
+
Today's web server hosts support compression transfer with `content-encoding`,
|
|
17
|
+
but for some servers that do not perform compression transfer, this module can be expected to significantly reduce network traffic.
|
|
18
|
+
|
|
11
19
|
## Details
|
|
12
20
|
|
|
13
21
|
+ Use code with **comment** extraction feature added to `unzipSync` of [`fflate`][1].
|
|
14
|
-
+ **comment** is used to embed **SRI
|
|
15
|
-
If comment is omitted or does not pass to verify process that it is **SRI
|
|
22
|
+
+ **comment** is used to embed [**SRI**][2]. (`script.integrity`)
|
|
23
|
+
If comment is omitted or does not pass to verify process that it is [**SRI**][2],
|
|
16
24
|
the unziped code will be bound to the `text` property of `script` element.
|
|
17
|
-
You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the prefix `sha###-` is omit able because the hash method is automatically detected by the length of the **SRI
|
|
25
|
+
You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the prefix `sha###-` is omit able because the hash method is automatically detected by the length of the [**SRI**][2].
|
|
18
26
|
+ [SRI online tool](https://www.srihash.org/)
|
|
19
27
|
|
|
20
|
-
+ **`cslpack`** - simple zip tool is available (since v1.2.x)
|
|
21
|
-
uses [fflate][1]'s `zip` feature
|
|
22
|
-
|
|
23
|
-
`$ cslpack <js file> <js file> ... [-(d|dest) <output zip path>]`
|
|
24
|
-
|
|
25
|
-
+ option `-(d|dest)` - output zip path. when omited will be output to **`./dist/bundle.zip`**
|
|
26
|
-
+ This tool uses the `sha384` method
|
|
27
|
-
|
|
28
|
-
**example:**
|
|
29
|
-
|
|
30
|
-
```shell
|
|
31
|
-
# apply just `sha384`
|
|
32
|
-
cslpack -d dist/lib/bundle.zip build/{bundle,data}.js
|
|
33
|
-
# or
|
|
34
|
-
cslpack build/{cjs,esm}/* -dest dist/lib/bundle.zip
|
|
35
|
-
# will be output to "./dist/bundle.zip"
|
|
36
|
-
cslpack build/{cjs,esm}/*
|
|
37
|
-
```
|
|
28
|
+
+ [**`cslpack`**](#cslpack-cli-since-v12x) cli - simple zip tool is available (since v1.2.x)
|
|
38
29
|
|
|
39
30
|
## Use for SPA
|
|
40
31
|
|
|
@@ -111,20 +102,48 @@ You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the pref
|
|
|
111
102
|
</script>
|
|
112
103
|
```
|
|
113
104
|
|
|
114
|
-
|
|
105
|
+
## `cslpack` cli (since v1.2.x)
|
|
106
|
+
|
|
107
|
+
uses [fflate][1]'s `zipSync` feature
|
|
108
|
+
|
|
109
|
+
`$ cslpack <jspath> <jspath>... [-(d|dest) <output zip path>] [-sha <256|384|512>]`
|
|
110
|
+
|
|
111
|
+
+ options
|
|
112
|
+
* `-(d|dest)` - output zip path. when omited will be output to **`./dist/bundle.zip`**
|
|
113
|
+
+ `-sha` - [256|384|512] when omited use 384 "sha384" (since v1.2.8)
|
|
114
|
+
|
|
115
|
+
**example:**
|
|
116
|
+
|
|
117
|
+
```shell
|
|
118
|
+
# apply just `sha384`
|
|
119
|
+
$ cslpack -d dist/lib/bundle.zip build/{bundle,data}.js
|
|
120
|
+
# or
|
|
121
|
+
$ cslpack build/{cjs,esm}/* -dest dist/lib/bundle.zip -sha 512
|
|
122
|
+
# will be output to "./dist/bundle.zip"
|
|
123
|
+
$ cslpack build/{cjs,esm}/*
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
> NOTE: \`cslpack\` does not keep directory path
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## Loader API
|
|
115
130
|
|
|
116
131
|
```ts
|
|
117
132
|
declare global {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
var cslCallback: (() => void) | undefined;
|
|
134
|
+
interface Window {
|
|
135
|
+
cslCallback: (() => void) | undefined;
|
|
136
|
+
}
|
|
122
137
|
}
|
|
123
138
|
export interface UnzipFileInfo {
|
|
124
139
|
name: string;
|
|
125
140
|
size: number;
|
|
126
141
|
originalSize: number;
|
|
127
142
|
compression: number;
|
|
143
|
+
/**
|
|
144
|
+
* @since v1.2.9
|
|
145
|
+
*/
|
|
146
|
+
comment?: string;
|
|
128
147
|
}
|
|
129
148
|
export declare type UnzipFileFilter = (file: UnzipFileInfo) => boolean;
|
|
130
149
|
export interface UnzipOptions {
|
|
@@ -143,7 +162,7 @@ You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the pref
|
|
|
143
162
|
callback?: keyof Window;
|
|
144
163
|
};
|
|
145
164
|
|
|
146
|
-
declare
|
|
165
|
+
declare var NsLoader: {
|
|
147
166
|
unzipSync: (data: Uint8Array, opts?: UnzipOptions) => Unzipped;
|
|
148
167
|
cleanUp: () => void;
|
|
149
168
|
setConfig: (base: string, insertionSelector?: string | undefined) => void;
|
|
@@ -151,7 +170,7 @@ You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the pref
|
|
|
151
170
|
readonly version: string;
|
|
152
171
|
};
|
|
153
172
|
declare interface Window {
|
|
154
|
-
|
|
173
|
+
NsLoader: typeof NsLoader;
|
|
155
174
|
}
|
|
156
175
|
```
|
|
157
176
|
|
package/bin/cslpack.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*! For license information please see cslpack.js.LICENSE.txt */
|
|
3
|
-
(()=>{var _wm_={274:module=>{function
|
|
4
|
-
|
|
5
|
-
;var a=Uint8Array,o=Uint16Array,i=Uint32Array,
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
;var c=n[0],l=n[1],u=0,v=1,
|
|
9
|
-
for(;i>138;i-=138)
|
|
10
|
-
var
|
|
11
|
-
},
|
|
12
|
-
;if(W>2&&
|
|
13
|
-
return~e}}},
|
|
14
|
-
;var o=e.length,i=new a(e.length+(e.length>>1)),
|
|
15
|
-
;var v=new Date(null==n.mtime?Date.now():n.mtime),
|
|
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,
|
|
17
|
-
u:v
|
|
3
|
+
(()=>{var _wm_={274:module=>{function tinArgs(acfg,dbg=!1){dbg&&console.log("process.argv: ",process.argv),acfg=acfg||{};const pfix=acfg.prefix||"-",vIdx=pfix.length,eIdx=acfg.startIndex||2,pms={};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(pfix)){let v=cArgs[idx];void 0===v||v.startsWith(pfix)?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++),pms[opt.substring(vIdx)]=v}else(pms.args||(pms.args=[])).push(opt)}}return pms}module.exports=tinArgs}},_wmc_={};function _wr_(e){var r=_wmc_[e]
|
|
4
|
+
;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,s=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]),f=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 s=n[t];s<n[t+1];++s)a[s]=s-n[t]<<5|t;return[n,a]},u=l(s,2),v=u[0],p=u[1];v[28]=258,p[258]=28;for(var d=l(f,0),h=(d[0],d[1]),g=new o(32768),_=0;_<32768;++_){var m=(43690&_)>>>1|(21845&_)<<1;m=(61680&(m=(52428&m)>>>2|(13107&m)<<2))>>>4|(3855&m)<<4,g[_]=((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 s,f=new o(r);for(a=0;a<r;++a)f[a]=f[a-1]+i[a-1]<<1;if(n){
|
|
6
|
+
s=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=f[e[a]-1]++<<u,p=v|(1<<u)-1;v<=p;++v)s[g[v]>>>c]=l}else for(s=new o(t),a=0;a<t;++a)e[a]&&(s[a]=g[f[e[a]-1]++]>>>15-e[a]);return s},b=new a(288);for(_=0;_<144;++_)b[_]=8;for(_=144;_<256;++_)b[_]=9;for(_=256;_<280;++_)b[_]=7;for(_=280;_<288;++_)b[_]=8;var x=new a(32);for(_=0;_<32;++_)x[_]=5;var y=w(b,9,0),k=w(x,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
|
+
},z=['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||z[e]);if(t.code=e,Error.captureStackTrace&&Error.captureStackTrace(t,T),!n)throw t;return t},A=function(e,r,n){n<<=7&r;var t=r/8|0;e[t]|=n,e[t+1]|=n>>>8},S=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},j=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,s=n.slice();if(!i)return[R,0];if(1==i){var f=new a(n[0].s+1);return f[n[0].s]=1,[f,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,p=2;for(n[0]={s:-1,f:c.f+l.f,l:c,r:l};v!=i-1;)c=n[n[u].f<n[p].f?u++:p++],l=n[u!=v&&n[u].f<n[p].f?u++:p++],n[v++]={s:-1,f:c.f+l.f,l:c,r:l};var d=s[0].s;for(t=1;t<i;++t)s[t].s>d&&(d=s[t].s);var h=new o(d+1),g=q(n[v-1],h,0);if(g>r){t=0;var _=0,m=g-r,w=1<<m;for(s.sort((function(e,r){return h[r.s]-h[e.s]||e.f-r.f}));t<i;++t){var b=s[t].s;if(!(h[b]>r))break;_+=w-(1<<g-h[b]),h[b]=r}for(_>>>=m;_>0;){var x=s[t].s;h[x]<r?_-=1<<r-h[x]++-1:++t}for(;t>=0&&_;--t){var y=s[t].s;h[y]==r&&(--h[y],++_)}g=r}return[new a(h),g]},q=function(e,r,n){return-1==e.s?Math.max(q(e.l,r,n+1),q(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,s=function(e){n[t++]=e},f=1;f<=r;++f)if(e[f]==a&&f!=r)++i;else{if(!a&&i>2){
|
|
9
|
+
for(;i>138;i-=138)s(32754);i>2&&(s(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(s(a),--i;i>6;i-=6)s(8304);i>2&&(s(i-3<<5|8208),i=0)}for(;i--;)s(a);i=1,a=e[f]}return[n.subarray(0,t),r]},$=function(e,r){for(var n=0,t=0;t<r.length;++t)n+=e[t]*r[t];return n},I=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,p,d){A(r,d++,n),++a[256];for(var h=j(a,15),g=h[0],_=h[1],m=j(i,15),E=m[0],M=m[1],z=O(g),T=z[0],q=z[1],F=O(E),D=F[0],R=F[1],P=new o(19),U=0;U<T.length;++U)P[31&T[U]]++;for(U=0;U<D.length;++U)P[31&D[U]]++;for(var C=j(P,7),N=C[0],Y=C[1],B=19;B>4&&!N[c[B-1]];--B);
|
|
10
|
+
var L,W,H,G,J=p+5<<3,K=$(a,b)+$(i,x)+l,Q=$(a,g)+$(i,E)+l+14+3*B+$(P,N)+(2*P[16]+3*P[17]+7*P[18]);if(J<=K&&J<=Q)return I(r,d,e.subarray(v,v+p));if(A(r,d,1+(Q<K)),d+=2,Q<K){L=w(g,_,0),W=g,H=w(E,M,0),G=E;var V=w(N,Y,0);A(r,d,q-257),A(r,d+5,R-1),A(r,d+10,B-4),d+=14;for(U=0;U<B;++U)A(r,d+3*U,N[c[U]]);d+=3*B;for(var X=[T,D],Z=0;Z<2;++Z){var ee=X[Z];for(U=0;U<ee.length;++U){var re=31&ee[U];A(r,d,V[re]),d+=N[re],re>15&&(A(r,d,ee[U]>>>5&127),d+=ee[U]>>>12)}}}else L=y,W=b,H=k,G=x;for(U=0;U<u;++U)if(t[U]>255){re=t[U]>>>18&31;S(r,d,L[re+257]),d+=W[re+257],re>7&&(A(r,d,t[U]>>>23&31),d+=s[re]);var ne=31&t[U];S(r,d,H[ne]),d+=G[ne],ne>3&&(S(r,d,t[U]>>>5&8191),d+=f[ne])}else S(r,d,L[t[U]]),d+=W[t[U]];return S(r,d,L[256]),d+W[256]
|
|
11
|
+
},D=new i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),R=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),d=v.subarray(t,v.length-c),g=0;if(!r||u<8)for(var _=0;_<=u;_+=65535){var m=_+65535;m>=u&&(d[g>>3]=l),g=I(d,g+1,e.subarray(_,m))}else{for(var w=D[r-1],b=w>>>13,x=8191&w,y=(1<<n)-1,k=new o(32768),z=new o(y+1),T=Math.ceil(n/3),A=2*T,S=function(r){return(e[r]^e[r+1]<<T^e[r+2]<<A)&y},j=new i(25e3),q=new o(288),O=new o(32),$=0,P=0,U=(_=0,0),C=0,N=0;_<u;++_){var Y=S(_),B=32767&_,L=z[Y];if(k[B]=L,z[Y]=B,C<=_){var W=u-_;if(($>7e3||U>24576)&&W>423){g=F(e,d,0,j,q,O,P,U,N,_-N,g),U=$=P=0,N=_;for(var H=0;H<286;++H)q[H]=0;for(H=0;H<30;++H)O[H]=0}var G=2,J=0,K=x,Q=B-L&32767
|
|
12
|
+
;if(W>2&&Y==S(_-Q))for(var V=Math.min(b,W)-1,X=Math.min(32767,_),Z=Math.min(258,W);Q<=X&&--K&&B!=L;){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,L=te)}}}Q+=(B=L)-(L=k[B])+32768&32767}if(J){j[U++]=268435456|p[G]<<18|h[J];var oe=31&p[G],ie=31&h[J];P+=s[oe]+f[ie],++q[257+oe],++O[ie],C=_+G,++$}else j[U++]=e[_],++q[e[_]]}}g=F(e,d,l,j,q,O,P,U,N,_-N,g),!l&&7&g&&(g=I(d,g+1,R))}return M(v,0,t+E(g)+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}(),C=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}}},N=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)},Y=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},B=function(e,r,n){for(;n;++r)e[r]=n,n>>>=8};function L(e,r){return N(e,r||{},0,0)}var W=function(e,r,n,t){for(var o in e){var i=e[o],s=r+o,f=t;Array.isArray(i)&&(f=Y(t,i[1]),i=i[0]),i instanceof a?n[s]=[i,f]:(n[s+='/']=[new a(0),f],W(i,s,n,t))}},H='undefined'!=typeof TextEncoder&&new TextEncoder,G='undefined'!=typeof TextDecoder&&new TextDecoder;try{G.decode(R,{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)),s=0,f=function(e){i[s++]=e};for(t=0;t<o;++t){if(s+5>i.length){var c=new a(s+8+(o-t<<1));c.set(i),i=c}var l=e.charCodeAt(t);l<128||r?f(l):l<2048?(f(192|l>>6),f(128|63&l)):l>55295&&l<57344?(f(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++t))>>18),f(128|l>>12&63),f(128|l>>6&63),f(128|63&l)):(f(224|l>>12),f(128|l>>6&63),f(128|63&l))}return M(i,0,s)}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,s){var f=t.length,c=n.extra,l=s&&s.length,u=K(c);B(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),p=v.getFullYear()-1980;if((p<0||p>119)&&T(10),B(e,r,p<<25|v.getMonth()+1<<21|v.getDate()<<16|v.getHours()<<11|v.getMinutes()<<5|v.getSeconds()>>>1),r+=4,null!=o&&(B(e,r,n.crc),B(e,r+4,o),B(e,r+8,n.size)),B(e,r+12,f),B(e,r+14,u),r+=16,null!=i&&(B(e,r,l),B(e,r+6,n.attrs),B(e,r+10,i),r+=14),e.set(t,r),r+=f,u)for(var d in c){var h=c[d],g=h.length;B(e,r,+d),B(e,r+2,g),e.set(h,r+4),r+=4+g}return l&&(e.set(s,r),r+=l),r},V=function(e,r,n,t,a){B(e,r,101010256),B(e,r+8,n),B(e,r+10,n),B(e,r+12,t),B(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),Object.keys(re).length&&re.args||(console.log("\n> ERROR: the file to pack is required\n\n$ cslpack <jspath> <jspath>... [-(d|dest) <output zip path>] [-sha <256|384|512>]\n\n -(d|dest) : zip output path. when omited will be output to ./dist/bundle.zip\n -sha : [256|384|512] when omited use 384 \"sha384\"\n\n NOTE: `cslpack` does not keep directory path\n"),process.exit(0));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,
|
|
17
|
+
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 s in n){var f=n[s],c=f[0],l=f[1],u=0==l.level?0:8,v=(E=J(s)).length,p=l.comment,d=p&&J(p),h=d&&d.length,g=K(l.extra);v>65535&&T(11);var _=u?L(c,l):c,m=_.length,w=C();w.p(c),t.push(Y(l,{size:c.length,crc:w.d(),c:_,f:E,m:d,u:v!=s.length||d&&p.length!=h,o,compression:u})),o+=30+v+g+m,i+=76+2*(v+g)+(h||0)+m}for(var b=new a(i+22),x=o,y=i-o,k=0;k<t.length;++k){var E=t[k];Q(b,E.o,E,E.f,E.u,E.c.length);var M=30+E.f.length+K(E.extra);b.set(E.c,E.o+M),Q(b,o,E,E.f,E.u,E.c.length,E.o,E.m),o+=16+M+(E.m?E.m.length:0)}return V(b,o,t.length,y,x),b}(this.zipObj,{});(r=>{const n=t.dirname(r);e.existsSync(n)||e.mkdirSync(n,{recursive:!0})})(r),
|
|
18
|
+
e.writeFile(r,o,"binary",(()=>{console.timeEnd(n),this.zipObj={}}))}clear(){this.zipObj={}}};let te=re.sha;/256|384|512/.test(te)||(te="384");for(const n of re.args){if(e.statSync(n).isFile()){const e=r.execSync(`bash -c "echo -n $(openssl dgst -sha${te} -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
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
7
|
*/
|
|
8
8
|
import * as Uz from "./unzip-sync";
|
|
9
|
+
export type { UnzipFileFilter, FlateError, UnzipFileInfo, UnzipOptions, Unzipped } from "./unzip-sync";
|
|
9
10
|
declare global {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
var NsLoader: typeof import("./umd");
|
|
12
|
+
var cslCallback: TCSLCallbak;
|
|
12
13
|
interface Window {
|
|
13
|
-
cslCallback:
|
|
14
|
+
cslCallback: TCSLCallbak;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
export declare type TCSLCallbak = (() => void) | undefined;
|
|
16
18
|
export declare type TCSLConfig = {
|
|
17
19
|
base: string;
|
|
18
20
|
selector?: string;
|
|
@@ -23,5 +25,5 @@ declare let unzipSync: typeof Uz.unzipSync;
|
|
|
23
25
|
declare let cleanUp: () => void;
|
|
24
26
|
declare let setConfig: (base: string, insertionSelector?: string | undefined) => void;
|
|
25
27
|
declare let loadCompressedScript: (baseName: string, log?: (msg: string) => void) => Promise<void>;
|
|
26
|
-
declare const version = "v1.2.
|
|
28
|
+
declare const version = "v1.2.10";
|
|
27
29
|
export { setConfig, loadCompressedScript, cleanUp, unzipSync, version };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compressed-script-loader",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.10",
|
|
4
|
+
"description": "Reduces network traffic for huge source files built by webpack etc.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./webpack/index.js",
|
|
7
7
|
"module": "./webpack-esm/index.mjs",
|
package/umd/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
|
|
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]),
|
|
4
|
-
;if(n){
|
|
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
|
|
6
|
-
|
|
7
|
-
;if(o>264){const t=o-257,r=c[t];n=v(e,y,(1<<r)-1)+
|
|
8
|
-
for(;1!=E(e,t);t+=4+E(e,t+2));return[
|
|
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
|
|
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){
|
|
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
|
|
2
|
+
((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
|
+
;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]),i=(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]},[a,f]=i(c,2);a[28]=258,f[258]=28;const[d,u]=i(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 i
|
|
4
|
+
;if(n){i=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)i[p[s]>>>n]=o}}else for(i=new o(r),c=0;c<r;++c)e[c]&&(i[c]=p[l[e[c]-1]++]>>>15-e[c]);return i},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 i=!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
|
+
i&&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 i=w(s),a=(1<<i)-1,f=g(s,i,1);for(let t=0;t<r;){const n=f[v(e,y,a)];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}}i&&u(h+131072);const k=(1<<j)-1,O=(1<<E)-1;let z=y;for(;;z=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){z=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)+a[t],y+=r}const r=x[S(e,y)&O],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}i&&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=z,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,O=(e,t)=>T(e,t)+4294967296*T(e,t+4),z=(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),[i,a,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),i,a,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[O(e,t+12),O(e,t+4),O(e,t+20)]};let A;const L=new n(0);try{const e=new TextDecoder;e.decode(L,{stream:!0}),A=e}catch{}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 i=t&&t.filter;for(let t=0;t<c;++t){const[t,r,c,a,f,d,u]=U(e,s,l),p=z(e,d);if(s=f,!i||i({name:a,size:r,originalSize:c,compression:t,comment:u})){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[a]={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{3}-)?([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.crossOrigin="anonymous",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){
|
|
11
|
+
t(`loaded ${n}, decompressing binary...`),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,o=0;t=n[o++];){const n=e[t];J(_.decode(n.data,{stream:!1}),t,r,D(n.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)
|
|
12
|
+
;const H="v1.2.10";return t})()));
|
package/unzip-sync.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function strFromU8(dat: Uint8Array, latin1?: boolean): string;
|
|
2
1
|
export interface FlateError extends Error {
|
|
3
2
|
code: number;
|
|
4
3
|
}
|
|
@@ -7,6 +6,7 @@ export interface UnzipFileInfo {
|
|
|
7
6
|
size: number;
|
|
8
7
|
originalSize: number;
|
|
9
8
|
compression: number;
|
|
9
|
+
comment?: string;
|
|
10
10
|
}
|
|
11
11
|
export declare type UnzipFileFilter = (file: UnzipFileInfo) => boolean;
|
|
12
12
|
export interface UnzipOptions {
|
package/webpack/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
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
|
-
;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
|
|
4
|
-
;for(let e=280;e<288;++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,
|
|
6
|
-
;const o=n>>>4;if(o<16)c[t++]=o;else{let n=0,r=0;for(16===o?(r=3+v(e,
|
|
7
|
-
o.n=
|
|
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!=
|
|
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
|
|
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
|
|
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.
|
|
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 y=(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},h=new n(288);for(let e=0;e<144;++e)h[e]=8;for(let e=144;e<256;++e)h[e]=9;for(let e=256;e<280;++e)h[e]=7
|
|
4
|
+
;for(let e=280;e<288;++e)h[e]=8;const p=new n(32);for(let e=0;e<32;++e)p[e]=5;const m=y(h,9,1),b=y(p,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,h=o.p||0,p=o.b||0,C=o.l,$=o.d,x=o.m,O=o.n;const T=8*r;do{if(!C){g=v(e,h,1);const c=v(e,h+1,3);if(h+=3,!c){const n=4+((h+7)/8|0),c=e[n-4]|e[n-3]<<8,s=n+c;if(s>r){f&&E(0);break}a&&u(p+c),t.set(e.subarray(n,s),p),o.b=p+=c,o.p=h=8*s,o.f=g;continue}if(1===c)C=m,$=b,x=9,O=5;else if(2===c){const t=v(e,h,31)+257,o=v(e,h+10,15)+4,r=t+v(e,h+5,31)+1;h+=14;const c=new n(r),s=new n(19);for(let t=0;t<o;++t)s[l[t]]=v(e,h+3*t,7);h+=3*o;const a=w(s),i=(1<<a)-1,f=y(s,a,1);for(let t=0;t<r;){const n=f[v(e,h,i)];h+=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,h,3),h+=2,n=c[t-1]):17===o?(r=3+v(e,h,7),h+=3):18===o&&(r=11+v(e,h,127),h+=7);r--;)c[t++]=n}}const d=c.subarray(0,t),u=c.subarray(t);x=w(d),O=w(u),C=y(d,x,1),$=y(u,O,1)}else E(1);if(h>T){f&&E(0);break}}a&&u(p+131072);const k=(1<<x)-1,z=(1<<O)-1;let j=h;for(;;j=h){const n=C[S(e,h)&k],o=n>>>4;if(h+=15&n,h>T){f&&E(0);break}if(n||E(2),o<256)t[p++]=o;else{if(256===o){j=h,C=void 0;break}{let n=o-254;if(o>264){const t=o-257,r=c[t];n=v(e,h,(1<<r)-1)+i[t],h+=r}const r=$[S(e,h)&z],l=r>>>4;r||E(3),h+=15&r;let g=d[l];if(l>3){const t=s[l];g+=S(e,h)&(1<<t)-1,h+=t}if(h>T){f&&E(0);break}a&&u(p+131072);const y=p+n;for(;p<y;p+=4)t[p]=t[p-g],t[p+1]=t[p+1-g],t[p+2]=t[p+2-g],t[p+3]=t[p+3-g];p=y}}}o.l=C,o.p=j,o.b=p,o.f=g,C&&(g=1,o.m=x,o.d=$,
|
|
7
|
+
o.n=O)}while(!g);return p===t.length?t:k(t,0,p)},O=(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),j=(e,t)=>t+30+O(e,t+26)+O(e,t+28),U=(e,t,n)=>{const o=!(2048&O(e,t+8)),r=O(e,t+28),c=L(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+O(e,t+30);return[O(e,t+10),a,i,c,s+O(e,t+30)+O(e,t+32),f,L(e.subarray(d,d+O(e,t+32)),o)]},P=(e,t)=>{for(;1!=O(e,t);t+=4+O(e,t+2));return[z(e,t+12),z(e,t+4),z(e,t+20)]};let A;const M=new n(0);try{const e=new TextDecoder;e.decode(M,{stream:!0}),A=e}catch{}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!=T(e,r);--r)(!r||e.length-r>65558)&&E(13);let c=O(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)&&E(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),g=j(e,d);if(s=f,!a||a({name:i,size:r,originalSize:c,compression:t,comment:u
|
|
9
|
+
})){let s;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{3}-)?([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.crossOrigin="anonymous",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,o=0;t=n[o++];){const n=e[t];J(B.decode(n.data,{stream:!1}),t,r,F(n.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.10";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
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
|
|
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 m=h(p,9,1),b=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
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
|
|
6
|
-
l&&u(y+131072);const S=(1<<E)-1,
|
|
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=
|
|
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!=
|
|
9
|
-
F=q=void 0},F=e=>{const t=/^(?:sha\d
|
|
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
|
|
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.
|
|
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 O=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=m,x=b,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>O){f&&$(0);break}}
|
|
6
|
+
l&&u(y+131072);const S=(1<<E)-1,T=(1<<z)-1;let U=p;for(;;U=p){const n=k[C(e,p)&S],o=n>>>4;if(p+=15&n,p>O){f&&$(0);break}if(n||$(2),o<256)t[y++]=o;else{if(256===o){U=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)&T],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>O){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=U,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,O=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,T=(e,t)=>O(e,t)+4294967296*O(e,t+4),U=(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=O(e,t+20),[l,i,f]=n&&4294967295===a?A(e,s):[a,O(e,t+24),O(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[T(e,t+12),T(e,t+4),T(e,t+20)]};let L;const P=new n(0);try{const e=new TextDecoder;e.decode(P,{stream:!0}),L=e}catch{}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!=O(e,r);--r)(!r||e.length-r>65558)&&$(13);let c=z(e,r+8);if(!c)return{};let s=O(e,r+16);const a=4294967295===s;a&&(r=O(e,r-12),101075792!=O(e,r)&&$(13),c=O(e,r+32),s=O(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=U(e,d);if(s=f,!l||l({name:i,size:r,originalSize:c,compression:t,comment:u})){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,
|
|
9
|
+
R=B=void 0,F=q=void 0},F=e=>{const t=/^(?:sha\d{3}-)?([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.crossOrigin="anonymous",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
|
|
10
|
+
;const s=new Uint8Array(r);let a=0;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,o=0;t=n[o++];){const n=e[t];Z(M.decode(n.data,{stream:!1}),t,r,F(n.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),
|
|
11
|
+
n=e.load):n=Array.isArray(e)?e:"string"==typeof e?[e]:[];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.10";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};
|