compressed-script-loader 1.1.3 → 1.2.3

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 CHANGED
@@ -1,8 +1,22 @@
1
1
  ![LICENSE](https://img.shields.io/badge/Lisence-MIT-blue.svg)
2
+ [![Node.js CI](https://github.com/jeffy-g/compressed-script-loader/actions/workflows/node.js.yml/badge.svg)](https://github.com/jeffy-g/compressed-script-loader/actions/workflows/node.js.yml)
2
3
 
3
4
  # compressed-script-loader
4
5
 
5
- + Use code with comment extraction feature added to `unzipSync` of `fflate`.
6
+ + Use code with **comment** extraction feature added to `unzipSync` of `fflate`.
7
+ + **comment** is used to embed **SRI**. (`script.integrity`)
8
+ If comment is omitted or does not pass to verify process that it is **SRI**,
9
+ the unziped code will be bound to the `text` property of `script` element.
10
+ 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**.
11
+ + [SRI online tool](https://www.srihash.org/)
12
+
13
+ + simple zip tool is available (since v1.2.x)
14
+ apply just `sha384`
15
+ ```shell
16
+ # example
17
+ cslpack -dest dist/lib/bundle.zip build/{bundle,data}.js
18
+ cslpack -dest dist/lib/bundle.zip build/{cjs,esm}/*
19
+ ```
6
20
 
7
21
  ## Use for SPA
8
22
 
package/bin/cslpack.js ADDED
@@ -0,0 +1,16 @@
1
+ /*! For license information please see cslpack.js.LICENSE.txt */
2
+ (()=>{var __wm__={274:module=>{const ArgsConfig={startIndex:2,prefix:"-"};function getExtraArgs(args_config,debug=!1){debug&&console.log("process.argv: ",process.argv);let actualConfig=args_config||{};actualConfig=Object.assign(ArgsConfig,actualConfig);const varIndex=actualConfig.prefix.length,extra_index=actualConfig.startIndex||2,params={};if(process.argv.length>extra_index){const cmdArgs=process.argv;for(let index=extra_index;index<cmdArgs.length;){const opt=cmdArgs[index++];if(opt)if(opt.startsWith(actualConfig.prefix)){let value=cmdArgs[index]
3
+ ;void 0===value||value.startsWith(actualConfig.prefix)?value=!0:(/^\[.+\]$/.test(value)||/^\/[^/]+\/[gimuys]{0,6}$/.test(value)?value=eval(value):/\\,/.test(value)?value=value.replace(/\\,/g,","):/,/.test(value)?value=value.split(","):/^(?:-?\.?\d+(?:\.\d*)?|0x[\da-f]+)$/i.test(value)&&(value=+value),index++),params[opt.substring(varIndex)]=value}else{let e=params.args;!e&&(params.args=e=[]),e.push(opt)}}}return params}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=>{
4
+ 'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})};var __webpack_exports__={};(()=>{"use strict";__wr__.r(__webpack_exports__);const e=require("fs"),r=require("child_process");var n=__wr__(274);const t=require("path");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]),l=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]),s=new a([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=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]},c=u(f,2),v=c[0],g=c[1]
5
+ ;v[28]=258,g[258]=28;for(var p=u(l,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,l=new o(r);for(a=0;a<r;++a)l[a]=l[a-1]+i[a-1]<<1;if(n){f=new o(1<<r);var s=15-r;for(a=0;a<t;++a)if(e[a])for(var u=a<<4|e[a],c=r-e[a],v=l[e[a]-1]++<<c,g=v|(1<<c)-1;v<=g;++v)f[h[v]>>>s]=u}else for(f=new o(t),a=0;a<t;++a)e[a]&&(f[a]=h[l[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){
6
+ (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},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},z=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},C=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()
7
+ ;if(!i)return[I,0];if(1==i){var l=new a(n[0].s+1);return l[n[0].s]=1,[l,1]}n.sort((function(e,r){return e.f-r.f})),n.push({s:-1,f:25001});var s=n[0],u=n[1],c=0,v=1,g=2;for(n[0]={s:-1,f:s.f+u.f,l:s,r:u};v!=i-1;)s=n[n[c].f<n[g].f?c++:g++],u=n[c!=v&&n[c].f<n[g].f?c++:g++],n[v++]={s:-1,f:s.f+u.f,l:s,r:u};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=q(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]},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},j=function(e){
8
+ 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},l=1;l<=r;++l)if(e[l]==a&&l!=r)++i;else{if(!a&&i>2){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[l]}return[n.subarray(0,t),r]},O=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,u,c,v,g,p){z(r,p++,n),++a[256];for(var d=C(a,15),h=d[0],_=d[1],m=C(i,15),E=m[0],M=m[1],A=j(h),T=A[0],q=A[1],F=j(E),D=F[0],I=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]]++
9
+ ;for(var Y=C(P,7),B=Y[0],L=Y[1],N=19;N>4&&!B[s[N-1]];--N);var R,W,H,G,J=g+5<<3,K=O(a,x)+O(i,b)+u,Q=O(a,h)+O(i,E)+u+14+3*N+O(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(z(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);z(r,p,q-257),z(r,p+5,I-1),z(r,p+10,N-4),p+=14;for(U=0;U<N;++U)z(r,p+3*U,B[s[U]]);p+=3*N;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];z(r,p,V[re]),p+=B[re],re>15&&(z(r,p,ee[U]>>>5&127),p+=ee[U]>>>12)}}}else R=y,W=x,H=k,G=b;for(U=0;U<c;++U)if(t[U]>255){re=t[U]>>>18&31;S(r,p,R[re+257]),p+=W[re+257],re>7&&(z(r,p,t[U]>>>23&31),p+=f[re]);var ne=31&t[U];S(r,p,H[ne]),p+=G[ne],ne>3&&(S(r,p,t[U]>>>5&8191),p+=l[ne])}else S(r,p,R[t[U]]),p+=W[t[U]];return S(r,p,R[256]),p+W[256]
10
+ },D=new i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),I=new a(0),P=function(e,r,n,t,s,u){var c=e.length,v=new a(t+c+5*(1+Math.ceil(c/7e3))+s),p=v.subarray(t,v.length-s),h=0;if(!r||c<8)for(var _=0;_<=c;_+=65535){var m=_+65535;m>=c&&(p[h>>3]=u),h=$(p,h+1,e.subarray(_,m))}else{for(var w=D[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),z=2*T,S=function(r){return(e[r]^e[r+1]<<T^e[r+2]<<z)&y},C=new i(25e3),q=new o(288),j=new o(32),O=0,P=0,U=(_=0,0),Y=0,B=0;_<c;++_){var L=S(_),N=32767&_,R=A[L];if(k[N]=R,A[L]=N,Y<=_){var W=c-_;if((O>7e3||U>24576)&&W>423){h=F(e,p,0,C,q,j,P,U,B,_-B,h),U=O=P=0,B=_;for(var H=0;H<286;++H)q[H]=0;for(H=0;H<30;++H)j[H]=0}var G=2,J=0,K=b,Q=N-R&32767
11
+ ;if(W>2&&L==S(_-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){C[U++]=268435456|g[G]<<18|d[J];var oe=31&g[G],ie=31&d[J];P+=f[oe]+l[ie],++q[257+oe],++j[ie],Y=_+G,++O}else C[U++]=e[_],++q[e[_]]}}h=F(e,p,u,C,q,j,P,U,B,_-B,h),!u&&7&h&&(h=$(p,h+1,I))}return M(v,0,t+E(h)+s)},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(){
12
+ 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,l=t;Array.isArray(i)&&(l=L(t,i[1]),i=i[0]),i instanceof a?n[f]=[i,l]:(n[f+='/']=[new a(0),l],W(i,f,n,t))}},H='undefined'!=typeof TextEncoder&&new TextEncoder,G='undefined'!=typeof TextDecoder&&new TextDecoder;try{G.decode(I,{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)
13
+ ;var o=e.length,i=new a(e.length+(e.length>>1)),f=0,l=function(e){i[f++]=e};for(t=0;t<o;++t){if(f+5>i.length){var s=new a(f+8+(o-t<<1));s.set(i),i=s}var u=e.charCodeAt(t);u<128||r?l(u):u<2048?(l(192|u>>6),l(128|63&u)):u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++t))>>18),l(128|u>>12&63),l(128|u>>6&63),l(128|63&u)):(l(224|u>>12),l(128|u>>6&63),l(128|63&u))}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 l=t.length,s=n.extra,u=f&&f.length,c=K(s);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
14
+ ;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,l),N(e,r+14,c),r+=16,null!=i&&(N(e,r,u),N(e,r+6,n.attrs),N(e,r+10,i),r+=14),e.set(t,r),r+=l,c)for(var p in s){var d=s[p],h=d.length;N(e,r,+p),N(e,r+2,h),e.set(d,r+4),r+=4+h}return u&&(e.set(f,r),r+=u),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
15
+ ;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=(0,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 t=function(e,r){r||(r={});var n={},t=[];W(e,'',n,r);var o=0,i=0;for(var f in n){var l=n[f],s=l[0],u=l[1],c=0==u.level?0:8,v=(E=J(f)).length,g=u.comment,p=g&&J(g),d=p&&p.length,h=K(u.extra);v>65535&&T(11);var _=c?R(s,u):s,m=_.length,w=Y();w.p(s),t.push(L(u,{size:s.length,crc:w.d(),c:_,f:E,m:p,
16
+ u:v!=f.length||p&&g.length!=d,o,compression:c})),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,{});e.writeFile(r,t,"binary",(()=>{console.timeEnd(n),this.zipObj={}}))}clear(){this.zipObj={}}};for(const n of re.args){if(e.statSync(n).isFile()){const e=(0,r.execSync)(`bash -c "echo -n $(openssl dgst -sha384 -binary ${n} | openssl base64 -A)"`,{encoding:"utf8"});ne.add(n,e)}}ne.emit(re.dest)})(),module.exports=__webpack_exports__})();
@@ -0,0 +1,7 @@
1
+ /*!
2
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ Copyright (C) 2022 jeffy-g <hirotom1107@gmail.com>
4
+ Released under the MIT license
5
+ https://opensource.org/licenses/mit-license.php
6
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
@@ -7,12 +7,12 @@
7
7
  */
8
8
  import * as Uz from "./unzip-sync";
9
9
  declare global {
10
- let cslCallback: () => void;
10
+ let cslCallback: (() => void) | undefined;
11
11
  interface Window {
12
- cslCallback: () => void;
12
+ cslCallback: (() => void) | undefined;
13
13
  }
14
14
  }
15
- export declare type TCSLLoaderConfig = {
15
+ export declare type TCSLConfig = {
16
16
  base: string;
17
17
  selector?: string;
18
18
  load: string[];
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "compressed-script-loader",
3
- "version": "1.1.3",
3
+ "version": "1.2.3",
4
4
  "description": "A lightweight module project",
5
5
  "private": false,
6
6
  "main": "./webpack/index.js",
7
7
  "module": "./webpack-esm/index.mjs",
8
8
  "unpkg": "./umd/index.js",
9
+ "bin": {
10
+ "cslpack": "./bin/cslpack.js"
11
+ },
9
12
  "sideEffects": false,
10
- "types": "./compressed-script-loader.d.ts",
13
+ "types": "./index.d.ts",
11
14
  "author": "jeffy-g",
12
15
  "license": "MIT",
13
16
  "bugs": {
@@ -22,6 +25,7 @@
22
25
  "package.json",
23
26
  "README.md",
24
27
  "LICENSE",
28
+ "bin",
25
29
  "umd",
26
30
  "webpack",
27
31
  "webpack-esm",
package/umd/index.js CHANGED
@@ -1,11 +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:()=>B,loadCompressedScript:()=>F,setConfig:()=>q,unzipSync:()=>A})
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 b=new n(32);for(let e=0;e<32;++e)b[e]=5;const m=g(y,9,1),h=g(b,5,1),w=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},S=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},v=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},C=(e,t,c)=>{(null==t||t<0)&&(t=0),(null==c||c>e.length)&&(c=e.length);const s=new(2==e.BYTES_PER_ELEMENT?o:4==e.BYTES_PER_ELEMENT?r:n)(c-t)
5
- ;return s.set(e.subarray(t,c)),s},E=['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'],k=(e,t,n)=>{const o=new Error(t||E[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,k),!n)throw o;return o},T=(e,t)=>e[t]|e[t+1]<<8,x=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,j=(e,t)=>x(e,t)+4294967296*x(e,t+4),O=(e,t)=>t+30+T(e,t+26)+T(e,t+28),$=(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=x(e,t+20),[a,i,f]=n&&4294967295==l?P(e,s):[l,x(e,t+24),x(e,t+42)],d=s+T(e,t+30)
6
- ;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[j(e,t+12),j(e,t+4),j(e,t+20)]};let U;const z=new n(0);try{const e=new TextDecoder;e.decode(z,{stream:!0}),U=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(U)return U.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,C(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)
7
- ;return n.length&&k(8),t}}function M(e,t){return((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,b=o.b||0,E=o.l,T=o.d,x=o.m,j=o.n;const O=8*r;do{if(!E){p=S(e,y,1);const c=S(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&&k(0);break}a&&u(b+c),t.set(e.subarray(n,s),b),o.b=b+=c,o.p=y=8*s,o.f=p;continue}if(1==c)E=m,T=h,x=9,j=5;else if(2==c){const t=S(e,y,31)+257,o=S(e,y+10,15)+4,r=t+S(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]]=S(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[S(e,y,i)];y+=15&n;const o=n>>>4;if(o<16)c[t++]=o;else{
8
- let n=0,r=0;for(16==o?(r=3+S(e,y,3),y+=2,n=c[t-1]):17==o?(r=3+S(e,y,7),y+=3):18==o&&(r=11+S(e,y,127),y+=7);r--;)c[t++]=n}}const d=c.subarray(0,t),u=c.subarray(t);x=w(d),j=w(u),E=g(d,x,1),T=g(u,j,1)}else k(1);if(y>O){f&&k(0);break}}a&&u(b+131072);const C=(1<<x)-1,$=(1<<j)-1;let P=y;for(;;P=y){const n=E[v(e,y)&C],o=n>>>4;if(y+=15&n,y>O){f&&k(0);break}if(n||k(2),o<256)t[b++]=o;else{if(256==o){P=y,E=void 0;break}{let n=o-254;if(o>264){const t=o-257,r=c[t];n=S(e,y,(1<<r)-1)+i[t],y+=r}const r=T[v(e,y)&$],l=r>>>4;r||k(3),y+=15&r;let p=d[l];if(l>3){const t=s[l];p+=v(e,y)&(1<<t)-1,y+=t}if(y>O){f&&k(0);break}a&&u(b+131072);const g=b+n;for(;b<g;b+=4)t[b]=t[b-p],t[b+1]=t[b+1-p],t[b+2]=t[b+2-p],t[b+3]=t[b+3-p];b=g}}}o.l=E,o.p=P,o.b=b,o.f=p,E&&(p=1,o.m=x,o.d=T,o.n=j)}while(!p)
9
- ;return b==t.length?t:C(t,0,b)})(e,t)}let _,N,R=new TextDecoder,A=function(e,t){const o={};let r=e.length-22;for(;101010256!=x(e,r);--r)(!r||e.length-r>65558)&&k(13);let c=T(e,r+8);if(!c)return{};let s=x(e,r+16);const l=4294967295==s;l&&(r=x(e,r-12),101075792!=x(e,r)&&k(13),c=x(e,r+32),s=x(e,r+48));const a=t&&t.filter;for(let t=0;t<c;++t){const[t,r,c,i,f,d,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=M(e.subarray(p,p+r),new n(c)):k(14,'unknown compression type '+t):s=C(e,p,p+r),s&&(o[i]={data:s,comment:u})}}return o},B=()=>{R=void 0,D=q=F=B=void 0,_=N=void 0,A=void 0},q=(e,t)=>{_=e,N=t||""},D=(e,t,n,o)=>{const r=document.createElement("script"),c=N?document.querySelector(N).nextSibling:document.head.lastElementChild
10
- ;document.head.insertBefore(r,c),r.id=t;const s=()=>{n(),console.log(`script ${t} is ready`)};if(o){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));r.integrity=o,r.src=t,r.onload=s}else r.text=e,s()},F=async(e,t=console.log)=>{const n=e+".js",o=await fetch(`${_}/${e}.zip`).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 script: ${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 script ${n}, decompressing binary...`),console.time(`unzip: ${n}`);const e=A(o)
11
- ;return console.timeEnd(`unzip: ${n}`),t(`${n} decompressed 😃`),new Promise((t=>{const n=Object.keys(e)[0],o=e[n];D(R.decode(o.data,{stream:!1}),n,t,o.comment)}))}},Y=()=>{Y=void 0;const e=document.querySelector("script[data-csl-config]");if(e){const t=e.dataset.cslConfig;if(t){const e=JSON.parse(t);q(e.base,e.selector);const n=[];for(const t of e.load)n.push(F(t));try{Promise.all(n).then((()=>{let t;t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"],"function"==typeof t&&t(),B()}))}catch(e){console.error(e)}}}};return setTimeout(Y,250),t})()));
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:()=>B,loadCompressedScript:()=>Y,setConfig:()=>D,unzipSync:()=>A})
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]),l=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]),s=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(l,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 p=(e,t,n)=>{const r=e.length;let c=0;const l=new o(t);for(;c<r;++c)e[c]&&++l[e[c]-1];const s=new o(t);for(c=0;c<t;++c)s[c]=s[c-1]+l[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 l=s[e[c]-1]++<<r;for(const e=l|(1<<r)-1;l<=e;++l)a[g[l]>>>n]=o}}else for(a=new o(r),c=0;c<r;++c)e[c]&&(a[c]=g[s[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;for(let e=280;e<288;++e)h[e]=8;const y=new n(32);for(let e=0;e<32;++e)y[e]=5;const b=p(h,9,1),m=p(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},S=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},v=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},C=(e,t,c)=>{(null==t||t<0)&&(t=0),(null==c||c>e.length)&&(c=e.length);const l=new(2==e.BYTES_PER_ELEMENT?o:4==e.BYTES_PER_ELEMENT?r:n)(c-t)
5
+ ;return l.set(e.subarray(t,c)),l},k=["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||k[e]);if(o.code=e,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,y=o.b||0,k=o.l,x=o.d,T=o.m,$=o.n;const j=8*r;do{if(!k){g=S(e,h,1);const c=S(e,h+1,3);if(h+=3,!c){
6
+ const n=4+((h+7)/8|0),c=e[n-4]|e[n-3]<<8,l=n+c;if(l>r){f&&E(0);break}a&&u(y+c),t.set(e.subarray(n,l),y),o.b=y+=c,o.p=h=8*l,o.f=g;continue}if(1==c)k=b,x=m,T=9,$=5;else if(2==c){const t=S(e,h,31)+257,o=S(e,h+10,15)+4,r=t+S(e,h+5,31)+1;h+=14;const c=new n(r),l=new n(19);for(let t=0;t<o;++t)l[s[t]]=S(e,h+3*t,7);h+=3*o;const a=w(l),i=(1<<a)-1,f=p(l,a,1);for(let t=0;t<r;){const n=f[S(e,h,i)];h+=15&n;const o=n>>>4;if(o<16)c[t++]=o;else{let n=0,r=0;for(16==o?(r=3+S(e,h,3),h+=2,n=c[t-1]):17==o?(r=3+S(e,h,7),h+=3):18==o&&(r=11+S(e,h,127),h+=7);r--;)c[t++]=n}}const d=c.subarray(0,t),u=c.subarray(t);T=w(d),$=w(u),k=p(d,T,1),x=p(u,$,1)}else E(1);if(h>j){f&&E(0);break}}a&&u(y+131072);const C=(1<<T)-1,z=(1<<$)-1;let O=h;for(;;O=h){const n=k[v(e,h)&C],o=n>>>4;if(h+=15&n,h>j){f&&E(0);break}if(n||E(2),
7
+ o<256)t[y++]=o;else{if(256==o){O=h,k=void 0;break}{let n=o-254;if(o>264){const t=o-257,r=c[t];n=S(e,h,(1<<r)-1)+i[t],h+=r}const r=x[v(e,h)&z],s=r>>>4;r||E(3),h+=15&r;let g=d[s];if(s>3){const t=l[s];g+=v(e,h)&(1<<t)-1,h+=t}if(h>j){f&&E(0);break}a&&u(y+131072);const p=y+n;for(;y<p;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=p}}}o.l=k,o.p=O,o.b=y,o.f=g,k&&(g=1,o.m=T,o.d=x,o.n=$)}while(!g);return y==t.length?t:C(t,0,y)},T=(e,t)=>e[t]|e[t+1]<<8,$=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,j=(e,t)=>$(e,t)+4294967296*$(e,t+4),z=(e,t)=>t+30+T(e,t+26)+T(e,t+28),O=(e,t,n)=>{const o=!(2048&T(e,t+8)),r=T(e,t+28),c=M(e.subarray(t+46,t+46+r),o),l=t+46+r,s=$(e,t+20),[a,i,f]=n&&4294967295==s?P(e,l):[s,$(e,t+24),$(e,t+42)],d=l+T(e,t+30)
8
+ ;return[T(e,t+10),a,i,c,l+T(e,t+30)+T(e,t+32),f,M(e.subarray(d,d+T(e,t+32)),o)]},P=(e,t)=>{for(;1!=T(e,t);t+=4+T(e,t+2));return[j(e,t+12),j(e,t+4),j(e,t+20)]};let U;const L=new n(0);try{const e=new TextDecoder;e.decode(L,{stream:!0}),U=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(U)return U.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,C(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)
9
+ ;return n.length&&E(8),t}}let _,N,R=new TextDecoder,A=function(e,t){const o={};let r=e.length-22;for(;101010256!=$(e,r);--r)(!r||e.length-r>65558)&&E(13);let c=T(e,r+8);if(!c)return{};let l=$(e,r+16);const s=4294967295==l;s&&(r=$(e,r-12),101075792!=$(e,r)&&E(13),c=$(e,r+32),l=$(e,r+48));const a=t&&t.filter;for(let t=0;t<c;++t){const[t,r,c,i,f,d,u]=O(e,l,s),g=z(e,d);if(l=f,!a||a({name:i,size:r,originalSize:c,compression:t})){let l;t?8===t?l=x(e.subarray(g,g+r),new n(c)):E(14,"unknown compression type "+t):l=C(e,g,g+r),l&&(o[i]={data:l,comment:u})}}return o},B=()=>{R=void 0,F=D=Y=B=void 0,_=N=void 0,q=A=void 0},q=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}`}},D=(e,t)=>{_=e,
10
+ N=t||""},F=(e,t,n,o)=>{const r=()=>{n(),console.log(`script ${t} is ready`)};let c=N?document.querySelector(N).nextSibling:void 0;const l=document.head[c?"insertBefore":"appendChild"](document.createElement("script"),c);if(l.id=t,o){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));l.integrity=o,l.onload=r,l.src=t}else l.text=e,r()},Y=async(e,t=console.log)=>{const n=e+".zip",o=await fetch(`${_}/${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 l=new Uint8Array(r);let s=0;for(;;){const e=await o.read();if(e.done)break;l.set(e.value,s),s+=e.value.length,t(`loading zip: ${s.toLocaleString()} bytes(${Math.round(s/r*100)}%)`)}return n?l.slice(0,s):l
11
+ })).catch((e=>(console.error(e),null)));if(o&&o.length){t(`loaded ${n}, decompressing binary...`),console.time(`unzip: ${n}`);const e=A(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];F(R.decode(c.data,{stream:!1}),o,r,q(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);D(e.base,e.selector);try{const t=[];for(const n of e.load)t.push(Y(n));Promise.all(t).then((()=>{let t;t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"],"function"==typeof t&&t(),B()}))}catch(e){console.error(e)}}}};return setTimeout(J,250),t})()));
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "./index.js",
3
+ "types": "../index.d.ts"
4
+ }
package/unzip-sync.d.ts CHANGED
@@ -1,8 +1,8 @@
1
+ export declare function strFromU8(dat: Uint8Array, latin1?: boolean): string;
2
+ export declare function inflateSync(data: Uint8Array, out?: Uint8Array): Uint8Array;
1
3
  export interface FlateError extends Error {
2
4
  code: number;
3
5
  }
4
- export declare function strFromU8(dat: Uint8Array, latin1?: boolean): string;
5
- export declare function inflateSync(data: Uint8Array, out?: Uint8Array): Uint8Array;
6
6
  export interface UnzipFileInfo {
7
7
  name: string;
8
8
  size: number;
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:()=>N,loadCompressedScript:()=>F,setConfig:()=>q,unzipSync:()=>B});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]),l=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]),s=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(l,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 l=new o(t);for(;c<r;++c)e[c]&&++l[e[c]-1];const s=new o(t);for(c=0;c<t;++c)s[c]=s[c-1]+l[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 l=s[e[c]-1]++<<r;for(const e=l|(1<<r)-1;l<=e;++l)a[g[l]>>>n]=o}}else for(a=new o(r),c=0;c<r;++c)e[c]&&(a[c]=g[s[e[c]-1]++]>>>15-e[c]);return a},m=new n(288);for(let e=0;e<144;++e)m[e]=8;for(let e=144;e<256;++e)m[e]=9;for(let e=256;e<280;++e)m[e]=7
4
- ;for(let e=280;e<288;++e)m[e]=8;const p=new n(32);for(let e=0;e<32;++e)p[e]=5;const y=h(m,9,1),b=h(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},S=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},v=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},C=(e,t,c)=>{(null==t||t<0)&&(t=0),(null==c||c>e.length)&&(c=e.length);const l=new(2==e.BYTES_PER_ELEMENT?o:4==e.BYTES_PER_ELEMENT?r:n)(c-t);return l.set(e.subarray(t,c)),l},E=['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'],k=(e,t,n)=>{const o=new Error(t||E[e]);if(o.code=e,
5
- Error.captureStackTrace&&Error.captureStackTrace(o,k),!n)throw o;return o},T=(e,t)=>e[t]|e[t+1]<<8,x=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,O=(e,t)=>x(e,t)+4294967296*x(e,t+4),$=(e,t)=>t+30+T(e,t+26)+T(e,t+28),j=(e,t,n)=>{const o=!(2048&T(e,t+8)),r=T(e,t+28),c=M(e.subarray(t+46,t+46+r),o),l=t+46+r,s=x(e,t+20),[a,i,f]=n&&4294967295==s?P(e,l):[s,x(e,t+24),x(e,t+42)],d=l+T(e,t+30);return[T(e,t+10),a,i,c,l+T(e,t+30)+T(e,t+32),f,M(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 U;const z=new n(0);try{const e=new TextDecoder;e.decode(z,{stream:!0}),U=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(U)return U.decode(e);{
6
- 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,C(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&&k(8),t}}function _(e,t){return((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,m=o.p||0,p=o.b||0,E=o.l,T=o.d,x=o.m,O=o.n;const $=8*r;do{if(!E){g=S(e,m,1);const c=S(e,m+1,3);if(m+=3,!c){const n=4+((m+7)/8|0),c=e[n-4]|e[n-3]<<8,l=n+c;if(l>r){
7
- f&&k(0);break}a&&u(p+c),t.set(e.subarray(n,l),p),o.b=p+=c,o.p=m=8*l,o.f=g;continue}if(1==c)E=y,T=b,x=9,O=5;else if(2==c){const t=S(e,m,31)+257,o=S(e,m+10,15)+4,r=t+S(e,m+5,31)+1;m+=14;const c=new n(r),l=new n(19);for(let t=0;t<o;++t)l[s[t]]=S(e,m+3*t,7);m+=3*o;const a=w(l),i=(1<<a)-1,f=h(l,a,1);for(let t=0;t<r;){const n=f[S(e,m,i)];m+=15&n;const o=n>>>4;if(o<16)c[t++]=o;else{let n=0,r=0;for(16==o?(r=3+S(e,m,3),m+=2,n=c[t-1]):17==o?(r=3+S(e,m,7),m+=3):18==o&&(r=11+S(e,m,127),m+=7);r--;)c[t++]=n}}const d=c.subarray(0,t),u=c.subarray(t);x=w(d),O=w(u),E=h(d,x,1),T=h(u,O,1)}else k(1);if(m>$){f&&k(0);break}}a&&u(p+131072);const C=(1<<x)-1,j=(1<<O)-1;let P=m;for(;;P=m){const n=E[v(e,m)&C],o=n>>>4;if(m+=15&n,m>$){f&&k(0);break}if(n||k(2),o<256)t[p++]=o;else{if(256==o){P=m,E=void 0;break}{
8
- let n=o-254;if(o>264){const t=o-257,r=c[t];n=S(e,m,(1<<r)-1)+i[t],m+=r}const r=T[v(e,m)&j],s=r>>>4;r||k(3),m+=15&r;let g=d[s];if(s>3){const t=l[s];g+=v(e,m)&(1<<t)-1,m+=t}if(m>$){f&&k(0);break}a&&u(p+131072);const h=p+n;for(;p<h;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=h}}}o.l=E,o.p=P,o.b=p,o.f=g,E&&(g=1,o.m=x,o.d=T,o.n=O)}while(!g);return p==t.length?t:C(t,0,p)})(e,t)}let L,R,A=new TextDecoder,B=function(e,t){const o={};let r=e.length-22;for(;101010256!=x(e,r);--r)(!r||e.length-r>65558)&&k(13);let c=T(e,r+8);if(!c)return{};let l=x(e,r+16);const s=4294967295==l;s&&(r=x(e,r-12),101075792!=x(e,r)&&k(13),c=x(e,r+32),l=x(e,r+48));const a=t&&t.filter;for(let t=0;t<c;++t){const[t,r,c,i,f,d,u]=j(e,l,s),g=$(e,d);if(l=f,!a||a({name:i,size:r,originalSize:c,compression:t})){
9
- let l;t?8===t?l=_(e.subarray(g,g+r),new n(c)):k(14,'unknown compression type '+t):l=C(e,g,g+r),l&&(o[i]={data:l,comment:u})}}return o},N=()=>{A=void 0,D=q=F=N=void 0,L=R=void 0,B=void 0},q=(e,t)=>{L=e,R=t||""},D=(e,t,n,o)=>{const r=document.createElement("script"),c=R?document.querySelector(R).nextSibling:document.head.lastElementChild;document.head.insertBefore(r,c),r.id=t;const l=()=>{n(),console.log(`script ${t} is ready`)};if(o){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));r.integrity=o,r.src=t,r.onload=l}else r.text=e,l()},F=async(e,t=console.log)=>{const n=e+".js",o=await fetch(`${L}/${e}.zip`).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 l=new Uint8Array(r)
10
- ;let s=0;for(;;){const e=await o.read();if(e.done)break;l.set(e.value,s),s+=e.value.length,t(`loading script: ${s.toLocaleString()} bytes(${Math.round(s/r*100)}%)`)}return n?l.slice(0,s):l})).catch((e=>(console.error(e),null)));if(o&&o.length){t(`loaded script ${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)[0],o=e[n];D(A.decode(o.data,{stream:!1}),n,t,o.comment)}))}},Y=()=>{Y=void 0;const e=document.querySelector("script[data-csl-config]");if(e){const t=e.dataset.cslConfig;if(t){const e=JSON.parse(t);q(e.base,e.selector);const n=[];for(const t of e.load)n.push(F(t));try{Promise.all(n).then((()=>{let t
11
- ;t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"],"function"==typeof t&&t(),N()}))}catch(e){console.error(e)}}}};setTimeout(Y,250),module.exports=t})();
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:()=>N,loadCompressedScript:()=>Y,setConfig:()=>D,unzipSync:()=>B});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]),l=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]),s=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(l,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 l=new o(t);for(;c<r;++c)e[c]&&++l[e[c]-1];const s=new o(t);for(c=0;c<t;++c)s[c]=s[c-1]+l[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 l=s[e[c]-1]++<<r;for(const e=l|(1<<r)-1;l<=e;++l)a[g[l]>>>n]=o}}else for(a=new o(r),c=0;c<r;++c)e[c]&&(a[c]=g[s[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},S=(e,t,n)=>{const o=t/8|0;return(e[o]|e[o+1]<<8)>>(7&t)&n},v=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},C=(e,t,c)=>{(null==t||t<0)&&(t=0),(null==c||c>e.length)&&(c=e.length);const l=new(2==e.BYTES_PER_ELEMENT?o:4==e.BYTES_PER_ELEMENT?r:n)(c-t);return l.set(e.subarray(t,c)),l},k=["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||k[e]);if(o.code=e,
5
+ Error.captureStackTrace&&Error.captureStackTrace(o,E),!n)throw o;return o},T=(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,k=o.l,T=o.d,$=o.m,x=o.n;const z=8*r;do{if(!k){g=S(e,p,1);const c=S(e,p+1,3);if(p+=3,!c){const n=4+((p+7)/8|0),c=e[n-4]|e[n-3]<<8,l=n+c;if(l>r){f&&E(0);break}a&&u(y+c),t.set(e.subarray(n,l),y),o.b=y+=c,o.p=p=8*l,o.f=g;continue}if(1==c)k=b,T=m,$=9,x=5;else if(2==c){const t=S(e,p,31)+257,o=S(e,p+10,15)+4,r=t+S(e,p+5,31)+1;p+=14;const c=new n(r),l=new n(19);for(let t=0;t<o;++t)l[s[t]]=S(e,p+3*t,7);p+=3*o;const a=w(l),i=(1<<a)-1,f=h(l,a,1);for(let t=0;t<r;){const n=f[S(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+S(e,p,3),p+=2,n=c[t-1]):17==o?(r=3+S(e,p,7),p+=3):18==o&&(r=11+S(e,p,127),p+=7);r--;)c[t++]=n}}const d=c.subarray(0,t),u=c.subarray(t);$=w(d),x=w(u),k=h(d,$,1),T=h(u,x,1)}else E(1);if(p>z){f&&E(0);break}}a&&u(y+131072);const C=(1<<$)-1,O=(1<<x)-1;let P=p;for(;;P=p){const n=k[v(e,p)&C],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){P=p,k=void 0;break}{let n=o-254;if(o>264){const t=o-257,r=c[t];n=S(e,p,(1<<r)-1)+i[t],p+=r}const r=T[v(e,p)&O],s=r>>>4;r||E(3),p+=15&r;let g=d[s];if(s>3){const t=l[s];g+=v(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=k,o.p=P,o.b=y,o.f=g,k&&(g=1,o.m=$,o.d=T,o.n=x)
7
+ }while(!g);return y==t.length?t:C(t,0,y)},$=(e,t)=>e[t]|e[t+1]<<8,x=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,z=(e,t)=>x(e,t)+4294967296*x(e,t+4),O=(e,t)=>t+30+$(e,t+26)+$(e,t+28),P=(e,t,n)=>{const o=!(2048&$(e,t+8)),r=$(e,t+28),c=_(e.subarray(t+46,t+46+r),o),l=t+46+r,s=x(e,t+20),[a,i,f]=n&&4294967295==s?U(e,l):[s,x(e,t+24),x(e,t+42)],d=l+$(e,t+30);return[$(e,t+10),a,i,c,l+$(e,t+30)+$(e,t+32),f,_(e.subarray(d,d+$(e,t+32)),o)]},U=(e,t)=>{for(;1!=$(e,t);t+=4+$(e,t+2));return[z(e,t+12),z(e,t+4),z(e,t+20)]};let j;const M=new n(0);try{const e=new TextDecoder;e.decode(M,{stream:!0}),j=e}catch(e){}function _(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(j)return j.decode(e);{const[t,n]=(e=>{for(let t="",n=0;;){
8
+ let o=e[n++];const r=+(o>127)+ +(o>223)+ +(o>239);if(n+r>e.length)return[t,C(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 L,R,A=new TextDecoder,B=function(e,t){const o={};let r=e.length-22;for(;101010256!=x(e,r);--r)(!r||e.length-r>65558)&&E(13);let c=$(e,r+8);if(!c)return{};let l=x(e,r+16);const s=4294967295==l;s&&(r=x(e,r-12),101075792!=x(e,r)&&E(13),c=x(e,r+32),l=x(e,r+48));const a=t&&t.filter;for(let t=0;t<c;++t){const[t,r,c,i,f,d,u]=P(e,l,s),g=O(e,d);if(l=f,!a||a({name:i,size:r,originalSize:c,compression:t})){let l
9
+ ;t?8===t?l=T(e.subarray(g,g+r),new n(c)):E(14,"unknown compression type "+t):l=C(e,g,g+r),l&&(o[i]={data:l,comment:u})}}return o},N=()=>{A=void 0,F=D=Y=N=void 0,L=R=void 0,q=B=void 0},q=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}`}},D=(e,t)=>{L=e,R=t||""},F=(e,t,n,o)=>{const r=()=>{n(),console.log(`script ${t} is ready`)};let c=R?document.querySelector(R).nextSibling:void 0;const l=document.head[c?"insertBefore":"appendChild"](document.createElement("script"),c);if(l.id=t,o){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));l.integrity=o,l.onload=r,l.src=t}else l.text=e,r()},Y=async(e,t=console.log)=>{
10
+ const n=e+".zip",o=await fetch(`${L}/${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 l=new Uint8Array(r);let s=0;for(;;){const e=await o.read();if(e.done)break;l.set(e.value,s),s+=e.value.length,t(`loading zip: ${s.toLocaleString()} bytes(${Math.round(s/r*100)}%)`)}return n?l.slice(0,s):l})).catch((e=>(console.error(e),null)));if(o&&o.length){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=0;t<n.length;){const o=n[t++],c=e[o];F(A.decode(c.data,{stream:!1}),o,r,q(c.comment))}}))}},J=()=>{J=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);D(e.base,e.selector);try{const t=[];for(const n of e.load)t.push(Y(n));Promise.all(t).then((()=>{let t;t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"],"function"==typeof t&&t(),N()}))}catch(e){console.error(e)}}}};setTimeout(J,250),module.exports=t})();
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "./index.js",
3
+ "types": "../index.d.ts"
4
+ }
@@ -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:()=>_,aN:()=>F,v6:()=>q,GZ:()=>M});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),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 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;for(let e=280;e<288;++e)p[e]=8;const m=new n(32);for(let e=0;e<32;++e)m[e]=5;const b=h(p,9,1),w=h(m,5,1),y=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)},E=(e,t,c)=>{(null==t||t<0)&&(t=0),(null==c||c>e.length)&&(c=e.length);const s=new(2==e.BYTES_PER_ELEMENT?o:4==e.BYTES_PER_ELEMENT?r:n)(c-t);return s.set(e.subarray(t,c)),s},S=['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'],k=(e,t,n)=>{const o=new Error(t||S[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,k),!n)throw o;return o},x=(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,$=(e,t)=>T(e,t)+4294967296*T(e,t+4),U=(e,t)=>t+30+x(e,t+26)+x(e,t+28),z=(e,t,n)=>{
5
- const o=!(2048&x(e,t+8)),r=x(e,t+28),c=P(e.subarray(t+46,t+46+r),o),s=t+46+r,l=T(e,t+20),[a,i,f]=n&&4294967295==l?L(e,s):[l,T(e,t+24),T(e,t+42)],d=s+x(e,t+30);return[x(e,t+10),a,i,c,s+x(e,t+30)+x(e,t+32),f,P(e.subarray(d,d+x(e,t+32)),o)]},L=(e,t)=>{for(;1!=x(e,t);t+=4+x(e,t+2));return[$(e,t+12),$(e,t+4),$(e,t+20)]};let O;const j=new n(0);try{const e=new TextDecoder;e.decode(j,{stream:!0}),O=e}catch(e){}function P(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(O)return O.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,E(e,n-1)];r?3==r?(o=((15&o)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,
6
- 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&&k(8),t}}function N(e,t){return((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,m=o.b||0,S=o.l,x=o.d,T=o.m,$=o.n;const U=8*r;do{if(!S){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&&k(0);break}a&&u(m+c),t.set(e.subarray(n,s),m),o.b=m+=c,o.p=p=8*s,o.f=g;continue}if(1==c)S=b,x=w,T=9,$=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
7
- ;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=y(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;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);T=y(d),$=y(u),S=h(d,T,1),x=h(u,$,1)}else k(1);if(p>U){f&&k(0);break}}a&&u(m+131072);const E=(1<<T)-1,z=(1<<$)-1;let L=p;for(;;L=p){const n=S[C(e,p)&E],o=n>>>4;if(p+=15&n,p>U){f&&k(0);break}if(n||k(2),o<256)t[m++]=o;else{if(256==o){L=p,S=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)&z],l=r>>>4;r||k(3),p+=15&r;let g=d[l];if(l>3){const t=s[l];g+=C(e,p)&(1<<t)-1,p+=t}if(p>U){f&&k(0);break
8
- }a&&u(m+131072);const h=m+n;for(;m<h;m+=4)t[m]=t[m-g],t[m+1]=t[m+1-g],t[m+2]=t[m+2-g],t[m+3]=t[m+3-g];m=h}}}o.l=S,o.p=L,o.b=m,o.f=g,S&&(g=1,o.m=T,o.d=x,o.n=$)}while(!g);return m==t.length?t:E(t,0,m)})(e,t)}let R,A,B=new TextDecoder,M=function(e,t){const o={};let r=e.length-22;for(;101010256!=T(e,r);--r)(!r||e.length-r>65558)&&k(13);let c=x(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)&&k(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]=z(e,s,l),g=U(e,d);if(s=f,!a||a({name:i,size:r,originalSize:c,compression:t})){let s;t?8===t?s=N(e.subarray(g,g+r),new n(c)):k(14,'unknown compression type '+t):s=E(e,g,g+r),s&&(o[i]={data:s,comment:u})}}return o},_=()=>{B=void 0,D=q=F=_=void 0,R=A=void 0,M=void 0
9
- },q=(e,t)=>{R=e,A=t||""},D=(e,t,n,o)=>{const r=document.createElement("script"),c=A?document.querySelector(A).nextSibling:document.head.lastElementChild;document.head.insertBefore(r,c),r.id=t;const s=()=>{n(),console.log(`script ${t} is ready`)};if(o){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));r.integrity=o,r.src=t,r.onload=s}else r.text=e,s()},F=async(e,t=console.log)=>{const n=e+".js",o=await fetch(`${R}/${e}.zip`).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 script: ${l.toLocaleString()} bytes(${Math.round(l/r*100)}%)`)}return n?s.slice(0,l):s
10
- })).catch((e=>(console.error(e),null)));if(o&&o.length){t(`loaded script ${n}, decompressing binary...`),console.time(`unzip: ${n}`);const e=M(o);return console.timeEnd(`unzip: ${n}`),t(`${n} decompressed 😃`),new Promise((t=>{const n=Object.keys(e)[0],o=e[n];D(B.decode(o.data,{stream:!1}),n,t,o.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);q(e.base,e.selector);const n=[];for(const t of e.load)n.push(F(t));try{Promise.all(n).then((()=>{let t;t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"],"function"==typeof t&&t(),_()}))}catch(e){console.error(e)}}}};setTimeout(G,250);var Y=t.Lx,Z=t.aN,J=t.v6,H=t.GZ
11
- ;export{Y as cleanUp,Z as loadCompressedScript,J as setConfig,H as unzipSync};
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:()=>_,aN:()=>G,v6:()=>D,GZ:()=>M});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),h=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,h[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;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[h[s]>>>n]=o}}else for(a=new o(r),c=0;c<r;++c)e[c]&&(a[c]=h[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;for(let e=280;e<288;++e)p[e]=8;const m=new n(32);for(let e=0;e<32;++e)m[e]=5;const b=g(p,9,1),w=g(m,5,1),y=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)},S=(e,t,c)=>{(null==t||t<0)&&(t=0),(null==c||c>e.length)&&(c=e.length);const s=new(2==e.BYTES_PER_ELEMENT?o:4==e.BYTES_PER_ELEMENT?r:n)(c-t);return s.set(e.subarray(t,c)),s},k=["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||k[e]);if(o.code=e,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){
5
+ const r=new n(Math.max(2*o,e));r.set(t),t=r}};let h=o.f||0,p=o.p||0,m=o.b||0,k=o.l,x=o.d,$=o.m,T=o.n;const z=8*r;do{if(!k){h=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(m+c),t.set(e.subarray(n,s),m),o.b=m+=c,o.p=p=8*s,o.f=h;continue}if(1==c)k=b,x=w,$=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=y(s),i=(1<<a)-1,f=g(s,a,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);$=y(d),T=y(u),k=g(d,$,1),x=g(u,T,1)
6
+ }else E(1);if(p>z){f&&E(0);break}}a&&u(m+131072);const S=(1<<$)-1,U=(1<<T)-1;let L=p;for(;;L=p){const n=k[C(e,p)&S],o=n>>>4;if(p+=15&n,p>z){f&&E(0);break}if(n||E(2),o<256)t[m++]=o;else{if(256==o){L=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],l=r>>>4;r||E(3),p+=15&r;let h=d[l];if(l>3){const t=s[l];h+=C(e,p)&(1<<t)-1,p+=t}if(p>z){f&&E(0);break}a&&u(m+131072);const g=m+n;for(;m<g;m+=4)t[m]=t[m-h],t[m+1]=t[m+1-h],t[m+2]=t[m+2-h],t[m+3]=t[m+3-h];m=g}}}o.l=k,o.p=L,o.b=m,o.f=h,k&&(h=1,o.m=$,o.d=x,o.n=T)}while(!h);return m==t.length?t:S(t,0,m)},$=(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),U=(e,t)=>t+30+$(e,t+26)+$(e,t+28),L=(e,t,n)=>{
7
+ const o=!(2048&$(e,t+8)),r=$(e,t+28),c=N(e.subarray(t+46,t+46+r),o),s=t+46+r,l=T(e,t+20),[a,i,f]=n&&4294967295==l?O(e,s):[l,T(e,t+24),T(e,t+42)],d=s+$(e,t+30);return[$(e,t+10),a,i,c,s+$(e,t+30)+$(e,t+32),f,N(e.subarray(d,d+$(e,t+32)),o)]},O=(e,t)=>{for(;1!=$(e,t);t+=4+$(e,t+2));return[z(e,t+12),z(e,t+4),z(e,t+20)]};let P;const j=new n(0);try{const e=new TextDecoder;e.decode(j,{stream:!0}),P=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(P)return P.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&&E(8),t}}let R,A,B=new TextDecoder,M=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=$(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]=L(e,s,l),h=U(e,d);if(s=f,!a||a({name:i,size:r,originalSize:c,compression:t})){let s;t?8===t?s=x(e.subarray(h,h+r),new n(c)):E(14,"unknown compression type "+t):s=S(e,h,h+r),s&&(o[i]={data:s,comment:u})}}return o},_=()=>{B=void 0,F=D=G=_=void 0,R=A=void 0,
9
+ q=M=void 0},q=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}`}},D=(e,t)=>{R=e,A=t||""},F=(e,t,n,o)=>{const r=()=>{n(),console.log(`script ${t} is ready`)};let c=A?document.querySelector(A).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()},G=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 l=0;for(;;){
10
+ 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=M(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];F(B.decode(c.data,{stream:!1}),o,r,q(c.comment))}}))}},Y=()=>{Y=void 0;const e=document.querySelector("script[data-csl-config]");if(e){const t=e.dataset.cslConfig;if(t){const e=JSON.parse(t);D(e.base,e.selector);try{const t=[];for(const n of e.load)t.push(G(n));Promise.all(t).then((()=>{let t
11
+ ;t="function"==typeof cslCallback?cslCallback:window[e.callback||"cslCallback"],"function"==typeof t&&t(),_()}))}catch(e){console.error(e)}}}};setTimeout(Y,250);var Z=t.Lx,J=t.aN,H=t.v6,I=t.GZ;export{Z as cleanUp,J as loadCompressedScript,H as setConfig,I as unzipSync};
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "./index.mjs",
3
+ "types": "../index.d.ts"
4
+ }