compressed-script-loader 1.4.15 → 1.4.19
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 +26 -1
- package/bin/cslpack.js +2 -2
- package/import-map.d.ts +4 -0
- package/index.d.ts +1 -1
- package/package.json +3 -2
- package/umd/index.js +1 -1
- package/unzip-sync.d.ts +21 -1
- package/webpack/index.js +1 -1
- package/webpack-esm/index.mjs +1 -1
package/README.md
CHANGED
|
@@ -45,7 +45,32 @@ You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the pref
|
|
|
45
45
|
|
|
46
46
|
## 🖌️ TODO
|
|
47
47
|
|
|
48
|
-
+ `type="module"`
|
|
48
|
+
+ `type="module"`
|
|
49
|
+
- stage 1 (v1.3.4, unstable)
|
|
50
|
+
- stage 2 (v1.4.8, unstable)
|
|
51
|
+
* Module id mapped by "baseUrl" and "paths" in tsconfig.json can now be resolved.
|
|
52
|
+
```jsonc
|
|
53
|
+
//
|
|
54
|
+
{
|
|
55
|
+
"compilerOptions": {
|
|
56
|
+
//
|
|
57
|
+
"baseUrl": ".",
|
|
58
|
+
"paths": {
|
|
59
|
+
"eveworld/*": [
|
|
60
|
+
"./*"
|
|
61
|
+
],
|
|
62
|
+
"web/*": [
|
|
63
|
+
"./web/*"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
note:
|
|
71
|
+
1. Filename only recognizes "tsconfig.json".
|
|
72
|
+
2. At a minimum, `compilerOptions.baseUrl` and `compilerOptions.paths` are required.
|
|
73
|
+
3. No matter where "tsconfig.json" is located, if `compilerOptions.baseUrl` is set correctly, there will be no error! (Probably...)
|
|
49
74
|
|
|
50
75
|
## 🦯 Use for SPA
|
|
51
76
|
|
package/bin/cslpack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*! For license information please see cslpack.js.LICENSE.txt */
|
|
3
|
-
(()=>{var _wm_={274:module=>{const 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)||/^(?:re)?\/[^/]+\/[gimuys]{0,6}$/.test(v)?(/^re\//.test(v)&&(v=v.substring(2)),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 t=_wmc_[e];if(void 0!==t)return t.exports;var s=_wmc_[e]={exports:{}};return _wm_[e](s,s.exports,_wr_),s.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_);
|
|
4
|
-
t[i.homogenized]=[a.encode(
|
|
3
|
+
(()=>{var _wm_={274:module=>{const 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)||/^(?:re)?\/[^/]+\/[gimuys]{0,6}$/.test(v)?(/^re\//.test(v)&&(v=v.substring(2)),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},48:e=>{"use strict";e.exports=require("fs")},315:e=>{"use strict";e.exports=require("path")},760:(__unused_webpack___webpack_module__,_we_,_wr_)=>{"use strict";_wr_.d(_we_,{U:()=>ModuleCouldNotResovleError,c:()=>ModuleResolver});var fs__WEBPACK_IMPORTED_MODULE_0__=_wr_(48),path__WEBPACK_IMPORTED_MODULE_1__=_wr_(315);class ModuleCouldNotResovleError extends Error{}function caseTsConfig(startDir,map){let tsconfig,prevDir,found=!1;do{if(tsconfig=path__WEBPACK_IMPORTED_MODULE_1__.resolve(startDir,"tsconfig.json"),fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(tsconfig)){console.log("okay, tsconfig.json found!"),found=!0;break}prevDir=startDir,startDir=path__WEBPACK_IMPORTED_MODULE_1__.parse(startDir).dir}while(startDir!==prevDir);if(!found)return void console.log("huh, tsconfig.json not found!");const src=fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(tsconfig,"utf8"),cfg=eval("("+src+")"),co=cfg.compilerOptions;let pathskeys;return co.paths&&(pathskeys=Object.keys(co.paths)).length?(pathskeys.forEach((e=>{const t=[];map[e]=t;const s=co.paths[e];for(let e=0;e<s.length;){const o=path__WEBPACK_IMPORTED_MODULE_1__.resolve(startDir,co.baseUrl,s[e++]).toUnixPath();t.push(o)}})),console.log(map),!0):void 0}function resolveFromTsConfigPaths(e,t){const s=e=>{const t=e.length-1;return"*"===e[t]&&(e=e.substring(0,t)),e};for(let[o,r]of Object.entries(t))if(o=s(o),e.startsWith(o))for(let t of r){t=s(t);const r=e.replace(o,t);if(fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(r))return r.toUnixPath()}return""}const ModuleResolver={foundConfig:!1,virtualPaths:{},resolve(e,t,s){const o=path__WEBPACK_IMPORTED_MODULE_1__.parse(e),r=path__WEBPACK_IMPORTED_MODULE_1__.resolve(o.dir,t).toUnixPath();if(fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(r))return r;if(!this.foundConfig){if(!caseTsConfig(o.dir,this.virtualPaths))throw new ModuleCouldNotResovleError("Sorry, this situation currently not supported.");this.foundConfig=!0}const n=resolveFromTsConfigPaths(t,this.virtualPaths);return s(`ModuleResolver::resolve->resolveFromTsConfigPaths: [${n}]`,"lightwarn"),n}}}},_wmc_={};function _wr_(e){var t=_wmc_[e];if(void 0!==t)return t.exports;var s=_wmc_[e]={exports:{}};return _wm_[e](s,s.exports,_wr_),s.exports}_wr_.d=(e,t)=>{for(var s in t)_wr_.o(t,s)&&!_wr_.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},_wr_.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_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_);var e=_wr_(48),t=_wr_(274),s=_wr_(315);const o=require("fflate"),r=require("util"),n=require("crypto");require("colors");var i=_wr_(760);function a(){return new RegExp("\n (?<!\\/\\/\\s*)(?:import|export)\n \\s*\n (?:\n (?:\n [\\w_]+\\s+| # default import, e.g - import fs from \"./file\";\n (?:[\\w_]+\\s*,\\s*|\\stype\\s*)?\\{[^}]+\\}\\s*| # e.g - import View, { TitiledSphereMesh } from \"./view\";\n \\*\\s*as\\s+[\\w_]+\\s+| # e.g - export * as OO from \"./rateLimiter\";\n \\*\\s* # e.g - export * from \"./rateLimiter\";\n )from\n )?\n \\s*\n [\"'](?!https?:)((?:[.\\/]+)?[^\"']+(?:\\.(?:c|m)?js)?)[\"'] # (./|../|../../) ...\n \\s*;?\n ".replace(/\s*\(\?\#.*\)\s*$|(?<!\\)\#\s*.*$|\s+/gm,""),"g")}String.prototype.toUnixPath="\\"===s.sep?function(){return this.replace(/\\/g,"/")}:function(){return this};const c=new TextEncoder,_=process.env.CI?()=>{}:console.log.bind(console,"[cslpack]:".blue),l=(e,t)=>{e="info"===t?e.gray:"warn"===t?e.cyan:"lightwarn"===t?e.green:e,_(e)},p=new Map,u=e=>{e&&_(p),p.clear()},d=t=>(_(`createCSLPackEntry actualPath:[${t}]`),{canonicalPath:t,homogenized:"",code:e.readFileSync(t,"utf8"),
|
|
4
|
+
modIdDetails:[]}),h=(e,t)=>{const s=a(),o=e.code;let r;for(;r=s.exec(o);){const s=r[1],o=r[0];if(e.modIdDetails.push({moduleId:s,statement:o,referrer:e.canonicalPath}),!p.has(s)){const o=i.c.resolve(e.canonicalPath,s,l);if(!o)throw new i.U(`moduleId: "${s}" cannot be resolved, stop processing`);p.set(s,o),t[o]?l(`source: "${o}" is already scanned`,"info"):h(t[o]=d(o),t)}}};const f=()=>{if(i.c.foundConfig)return{extras:{comment:"module resolve from tsconfig.json",config:i.c.virtualPaths}}},g=new r.TextEncoder;let m="./dist/bundle.zip",v=t();console.log(v);let b=v.args;b||(console.log(`\n> ERROR: the file to pack is required\n\n$ cslpack [-(d|dest) <output zip path>] [-sha <256|384|512>] [-m <main jsname>] <jspath> <jspath>...\n\n -(d|dest): zip output path. when omited will be output to ${m}\n -sha : [256|384|512] when omited use 384 "sha384"\n -m : When packing the esm module, specify the script name that will be the entry point.\n The "importmap" is automatically generated and packed together.\n\n NOTE: \`cslpack\` doesn't keep directory path\n`),process.exit(1));const w=new class{prefetchSources={};list={};cslImportMap;constructor(e){this.setModuleMain(e)}setModuleMain(e){"string"==typeof e&&e.length?this.cslImportMap={main:e,map:{imports:{}},version:1}:this.cslImportMap=void 0,u()}add(e){const t=((e,t)=>{const o=s.resolve(e).toUnixPath();if(!t[o])return t[o]=d(o);l(`source: "${o}" is already scanned`,"info")})(e,this.prefetchSources);t&&this.cslImportMap&&h(t,this.prefetchSources)}async emit(t,r){const i=this.prefetchSources;(e=>{const t=function(e){if(0===e.length)return"";e.sort();let t=e[0],s=e[e.length-1],o=0;for(;o<t.length&&t[o]===s[o];)o++;return t.substring(0,o-1)}(Object.values(e).map((e=>e.canonicalPath)));if(!t)throw new ReferenceError("No common parts detected among the paths.");const s=/\\|\//.exec(t)||["/"],o=t.lastIndexOf(s[0])+1;0!==o&&Object.values(e).forEach((e=>{e.homogenized=e.canonicalPath.substring(o)}))})(i),(t=>{const s=f(),o=JSON.stringify({...t,...s},((e,t)=>"code"===e?"...":t),2);e.writeFile("./cslpack-info.json",o,"binary",(()=>{console.log()}))})(i);let l=this.list,u=this.cslImportMap;await((e,t,o,r)=>{const i=a(),_=o?.map.imports,l=[];return/256|384|512/.test(r)||(r="384"),Object.values(e).forEach((a=>{let u=a.code;_&&(i.lastIndex=0,u=u.replace(i,((t,s)=>{const o=p.get(s);if(!o)throw new Error("process homogenizeModuleIds failed!");const r=e[o].homogenized;return _[r]="",t.replace(s,r)}))),s.parse(a.canonicalPath).base===o?.main&&(o.main=a.homogenized);const d=`[hash(sha${r})::${a.homogenized}]`;console.time(d),l.push(new Promise((e=>{t[a.homogenized]=[c.encode(u),{level:7,comment:n.createHash(`sha${r}`).update(u).digest("base64")}],console.timeEnd(d),e()})))})),Promise.all(l)})(i,l,u,r),u&&(l["$importmap.dat"]=[g.encode(JSON.stringify(u,null,2)),{level:7}]);const d=`[fflate.zip:${t}]`;console.time(d),o.zip(l,((o,r)=>{if(console.timeEnd(d),o)throw o;(t=>{const o=s.dirname(t);e.existsSync(o)||e.mkdirSync(o,{recursive:!0})})(t),e.writeFile(t,r,"binary",(()=>{_(u),this.reset()}))}))}reset(){this.list={},this.prefetchSources={},this.cslImportMap=void 0,u(!0)}}(v.m);let x=v.sha;/256|384|512/.test(x)||(x="384");for(const t of b){e.statSync(t).isFile()&&w.add(t)}w.emit(v.d||v.dest||m,x).then((()=>{console.log("cslpack done!")}))})(),module.exports=_we_})();
|
package/import-map.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ declare let setConfig: (base: string, insertionSelector?: string) => void;
|
|
|
34
34
|
* @param {(msg: string) => void} [log] default: `console.log`
|
|
35
35
|
*/
|
|
36
36
|
declare let loadCompressedScript: (baseName: string, log?: (msg: string) => void) => Promise<void>;
|
|
37
|
-
declare const version = "v1.4.
|
|
37
|
+
declare const version = "v1.4.19";
|
|
38
38
|
/**
|
|
39
39
|
* `importmap` zip entry name
|
|
40
40
|
*/
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compressed-script-loader",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"description": "Reduces network traffic for huge source files built by webpack etc.",
|
|
5
5
|
"private": false,
|
|
6
|
+
"browser": "./umd/index.js",
|
|
6
7
|
"main": "./webpack/index.js",
|
|
7
8
|
"module": "./webpack-esm/index.mjs",
|
|
8
9
|
"unpkg": "./umd/index.js",
|
|
9
10
|
"bin": {
|
|
10
|
-
"cslpack": "
|
|
11
|
+
"cslpack": "bin/cslpack.js"
|
|
11
12
|
},
|
|
12
13
|
"sideEffects": false,
|
|
13
14
|
"types": "./index.d.ts",
|
package/umd/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
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,{IM_MAP_ID:()=>te,cleanUp:()=>G,loadCompressedScript:()=>X,setConfig:()=>Q,unzipSync:()=>Y,version:()=>ee});const n=String.fromCharCode,o=Uint8Array,r=Uint16Array,l=Uint32Array,i=new o([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]),a=new o([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 o([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),c=(e,t)=>{const n=new r(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];const o=new l(n[30]);for(let e=1;e<30;++e)for(let t=n[e];t<n[e+1];++t)o[t]=t-n[e]<<5|e;return[n,o]},[d,f]=c(i,2);d[28]=258,f[258]=28;const[u,p]=c(a,0),y=new r(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,y[e]=((65280&t)>>>8|(255&t)<<8)>>>1}const g=(e,t,n)=>{const o=e.length;let l=0;const i=new r(t);for(;l<o;++l)e[l]&&++i[e[l]-1];const a=new r(t);for(l=0;l<t;++l)a[l]=a[l-1]+i[l-1]<<1;let s;if(n){s=new r(1<<t);const n=15-t;for(l=0;l<o;++l)if(e[l]){const o=l<<4|e[l],r=t-e[l];let i=a[e[l]-1]++<<r;for(const e=i|(1<<r)-1;i<=e;++i)s[y[i]>>>n]=o}}else for(s=new r(o),l=0;l<o;++l)e[l]&&(s[l]=y[a[e[l]-1]++]>>>15-e[l]);return s},m=new o(288),b=new o(32);{let e=0;for(;e<144;)m[e++]=8;for(;e<256;)m[e++]=9;for(;e<280;)m[e++]=7;for(;e<288;)m[e++]=8;for(e=0;e<32;)b[e++]=5}const h=g(m,9,1),w=g(b,5,1),v=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},k=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},x=[,o,r,,l],$=(e,t,n)=>{(!t||t<0)&&(t=0),(!n||n>e.length)&&(n=e.length);const o=new x[e.BYTES_PER_ELEMENT](n-t);return o.set(e.subarray(t,n)),o},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"];let O=Error.captureStackTrace;const T=(e,t,n)=>{const o=new Error(t||E[e]);if(o.code=e,O&&O(o,T),!n)throw o;return o},j=(e,t,n)=>{const r=e.length;if(!r||n&&n.f&&!n.l)return t||new o(0);const l=!t||!!n,c=!n||n.i;!n&&(n={}),!t&&(t=new o(3*r));const f=e=>{let n=t.length;if(e>n){const r=new o(Math.max(2*n,e));r.set(t),t=r}};let p=n.f||0,y=n.p||0,m=n.b||0,b=n.l,x=n.d,E=n.m,O=n.n;const j=8*r;do{if(!b){p=S(e,y,1);const i=S(e,y+1,3);if(y+=3,!i){const o=4+((y+7)/8|0),i=e[o-4]|e[o-3]<<8,a=o+i;if(a>r){c&&T(0);break}l&&f(m+i),t.set(e.subarray(o,a),m),n.b=m+=i,n.p=y=8*a,n.f=p;continue}if(1===i)b=h,x=w,E=9,O=5;else if(2===i){const t=S(e,y,31)+257,n=S(e,y+10,15)+4,r=t+S(e,y+5,31)+1;y+=14;const l=new o(r),i=new o(19);for(let t=0;t<n;++t)i[s[t]]=S(e,y+3*t,7);y+=3*n;const a=v(i),c=(1<<a)-1,d=g(i,a,1);for(let t=0;t<r;){const n=d[S(e,y,c)];y+=15&n;const o=n>>>4;if(o<16)l[t++]=o;else{let n=0,r=0;for(16===o?(r=3+S(e,y,3),y+=2,n=l[t-1]):17===o?(r=3+S(e,y,7),y+=3):18===o&&(r=11+S(e,y,127),y+=7);r--;)l[t++]=n}}const f=l.subarray(0,t),u=l.subarray(t);E=v(f),O=v(u),b=g(f,E,1),x=g(u,O,1)}else T(1);if(y>j){c&&T(0);break}}l&&f(m+131072);const $=(1<<E)-1,C=(1<<O)-1;let A=y;for(;;A=y){const n=b[k(e,y)&$],o=n>>>4;if(y+=15&n,y>j){c&&T(0);break}if(n||T(2),o<256)t[m++]=o;else{if(256===o){A=y,b=void 0;break}{let n=o-254;if(o>264){const t=o-257,r=i[t];n=S(e,y,(1<<r)-1)+d[t],y+=r}const r=x[k(e,y)&C],s=r>>>4;r||T(3),y+=15&r;let p=u[s];if(s>3){const t=a[s];p+=k(e,y)&(1<<t)-1,y+=t}if(y>j){c&&T(0);break}l&&f(m+131072);const g=m+n;for(;m<g;m+=4)t[m]=t[m-p],t[m+1]=t[m+1-p],t[m+2]=t[m+2-p],t[m+3]=t[m+3-p];m=g}}}n.l=b,n.p=A,n.b=m,n.f=p,b&&(p=1,n.m=E,n.d=x,n.n=O)}while(!p);return m===t.length?t:$(t,0,m)},C=(e,t)=>e[t]|e[t+1]<<8,A=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,M=(e,t)=>A(e,t)+4294967296*A(e,t+4),z=(e,t)=>t+30+C(e,t+26)+C(e,t+28),P=(e,t,n)=>{const o=!(2048&C(e,t+8)),r=C(e,t+28),l=R(e.subarray(t+46,t+46+r),o),i=t+46+r,a=A(e,t+20),[s,c,d]=n&&4294967295===a?U(e,i):[a,A(e,t+24),A(e,t+42)],f=i+C(e,t+30);return[C(e,t+10),s,c,l,i+C(e,t+30)+C(e,t+32),d,R(e.subarray(f,f+C(e,t+32)),o)]},U=(e,t)=>{for(;1!=C(e,t);t+=4+C(e,t+2));return[M(e,t+12),M(e,t+4),M(e,t+20)]};let L;const N=new o(0);try{const e=new TextDecoder;e.decode(N,{stream:!0}),L=e}catch{}const _=e=>{for(let t="",o=0;;){let r=e[o++];const l=+(r>127)+ +(r>223)+ +(r>239);if(o+l>e.length)return[t,$(e,o-1)];l?3===l?(r=((15&r)<<18|(63&e[o++])<<12|(63&e[o++])<<6|63&e[o++])-65536,
|
|
3
|
-
t+=n(55296|r>>10,56320|1023&r)):t+=n(1&l?(31&r)<<6|63&e[o++]:(15&r)<<12|(63&e[o++])<<6|63&e[o++]):t+=n(r)}};function R(e,t){if(t){let t="";for(let o=0;o<e.length;o+=16384)t+=n.apply(null,e.subarray(o,o+16384));return t}if(L)return L.decode(e);{const[t,n]=_(e);return n.length&&T(8),t}}let B,D,J=console.log,q=document,F=Object.keys,I=new TextDecoder,Y=function(e,t){const n={};let r=e.length-22;for(;101010256!=A(e,r);--r)(!r||e.length-r>65558)&&T(13);let l=C(e,r+8);if(!l)return{};let i=A(e,r+16);const a=4294967295===i;a&&(r=A(e,r-12),101075792!=A(e,r)&&T(13),l=A(e,r+32),i=A(e,r+48));const s=t&&t.filter;for(let t=0;t<l;++t){const[t,r,l,c,d,f,u]=P(e,i,a),p=z(e,f);if(i=d,!s||s({name:c,size:r,originalSize:l,compression:t,comment:u})){let i;t?8===t?i=j(e.subarray(p,p+r),new o(l)):T(14,"unknown compression type "+t):i=$(e,p,p+r),i&&(n[c]={data:i,comment:u})}}return n},G=()=>{I=void 0,V=Q=X=G=void 0,B=D=void 0,W=K=H=Y=void 0},H=e=>{let t=/^(?:sha\d{3}-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){let n=(e=t[1]).length;if(!(88^n&&64^n&&44^n))return`sha${64==n?384:88==n?512:256}-${e}`}},K=(e,t="text/javascript")=>URL.createObjectURL(new Blob([e],{type:t})),Q=(e,t)=>{B=e,D=t||""},V=(e,t,n=(()=>{}),o={})=>{let r=()=>{n(),J(`script ${t} is ready`)},l=D?q.querySelector(D).nextElementSibling:void 0,i=q.head[l?"insertBefore":"appendChild"](q.createElement("script"),l);i.id=t,o.type&&(i.type=o.type);let a=o.integrity;a?(i.integrity=a,i.crossOrigin="",i.onload=r,i.src=o.url||K(e)):(i.text=e,r())},W=e=>{let t,n=F(e);if(n.includes(te)){n=n.filter((e=>e!==te));let o,r=I.decode(e[te].data),l=JSON.parse(r),i=l.map.imports,a=[],s=new Map;const c=F(i);for(let t=0;t<c.length;){const n=c[t++];let r=s.get(n);r||s.set(n,r=K(I.decode(e[n].data))),i[n]=r,n!==l.main||o||(o=r),!a.includes(n)&&a.push(n)}V(JSON.stringify(l.map,null,2),te,void 0,{type:"importmap"}),n=n.filter((e=>!a.includes(e))),t={entryMain:o,imdata:l}}return[n,t]},X=async(e,t=J)=>{let n=e+".zip",o=await fetch(`${B||"."}/${n}`).then((async e=>{let n=!!e.headers.get("content-encoding"),o=e.body.getReader(),r=(l=+e.headers.get("content-length"),n?l<<1|0:l);var l;let i=new Uint8Array(r),a=0;for(;;){let{done:e,value:n}=await o.read();if(e)break;i.set(n,a),a+=n.length,t(`loading zip: ${a.toLocaleString()} bytes(${a/r*100|0}%)`)}return n?i.slice(0,a):i})).catch((e=>{console.error(e)}));if(o&&o.length){t(`loaded ${n}, decompressing binary...`);let e=`unzip: ${n}`;console.time(e);let r=Y(o);return console.timeEnd(e),t(`${n} decompressed 😃`),new Promise((e=>{let[t,{entryMain:n,imdata:o}={}]=W(r),l=t.length,i=o?.main,a=()=>{! --l&&e()};for(let e,o=0;e=t[o++];){let t=r[e],o=e===i;V(I.decode(t.data),e,a,{integrity:H(t.comment),url:o?n:void 0,type:o?"module":void 0})}}))}throw new Error(`Could not load "${n}"`)},Z=async()=>{Z=void 0;let e=q.querySelector("script[data-csl-config]");if(e){let t=e.dataset.cslConfig;if(t){t=JSON.parse(t);let e=t.load?(Q(t.base,t.selector),Array.isArray(t.load)?t.load:[t.load]):Array.isArray(t)?t:"string"==typeof t?[t]:[],n=[];for(let t of e)n.push(X(t).catch((e=>e)));let o=(await Promise.all(n)).filter((e=>e&&e.name));setTimeout((()=>{let e="function"==typeof cslCallback?cslCallback:window[t.callback||"cslCallback"];"function"==typeof e&&e(o.length?o:void 0)}),60),t.cleanup&&G()}}};setTimeout(Z,99);const ee="v1.4.
|
|
3
|
+
t+=n(55296|r>>10,56320|1023&r)):t+=n(1&l?(31&r)<<6|63&e[o++]:(15&r)<<12|(63&e[o++])<<6|63&e[o++]):t+=n(r)}};function R(e,t){if(t){let t="";for(let o=0;o<e.length;o+=16384)t+=n.apply(null,e.subarray(o,o+16384));return t}if(L)return L.decode(e);{const[t,n]=_(e);return n.length&&T(8),t}}let B,D,J=console.log,q=document,F=Object.keys,I=new TextDecoder,Y=function(e,t){const n={};let r=e.length-22;for(;101010256!=A(e,r);--r)(!r||e.length-r>65558)&&T(13);let l=C(e,r+8);if(!l)return{};let i=A(e,r+16);const a=4294967295===i;a&&(r=A(e,r-12),101075792!=A(e,r)&&T(13),l=A(e,r+32),i=A(e,r+48));const s=t&&t.filter;for(let t=0;t<l;++t){const[t,r,l,c,d,f,u]=P(e,i,a),p=z(e,f);if(i=d,!s||s({name:c,size:r,originalSize:l,compression:t,comment:u})){let i;t?8===t?i=j(e.subarray(p,p+r),new o(l)):T(14,"unknown compression type "+t):i=$(e,p,p+r),i&&(n[c]={data:i,comment:u})}}return n},G=()=>{I=void 0,V=Q=X=G=void 0,B=D=void 0,W=K=H=Y=void 0},H=e=>{let t=/^(?:sha\d{3}-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){let n=(e=t[1]).length;if(!(88^n&&64^n&&44^n))return`sha${64==n?384:88==n?512:256}-${e}`}},K=(e,t="text/javascript")=>URL.createObjectURL(new Blob([e],{type:t})),Q=(e,t)=>{B=e,D=t||""},V=(e,t,n=(()=>{}),o={})=>{let r=()=>{n(),J(`script ${t} is ready`)},l=D?q.querySelector(D).nextElementSibling:void 0,i=q.head[l?"insertBefore":"appendChild"](q.createElement("script"),l);i.id=t,o.type&&(i.type=o.type);let a=o.integrity;a?(i.integrity=a,i.crossOrigin="",i.onload=r,i.src=o.url||K(e)):(i.text=e,r())},W=e=>{let t,n=F(e);if(n.includes(te)){n=n.filter((e=>e!==te));let o,r=I.decode(e[te].data),l=JSON.parse(r),i=l.map.imports,a=[],s=new Map;const c=F(i);for(let t=0;t<c.length;){const n=c[t++];let r=s.get(n);r||s.set(n,r=K(I.decode(e[n].data))),i[n]=r,n!==l.main||o||(o=r),!a.includes(n)&&a.push(n)}V(JSON.stringify(l.map,null,2),te,void 0,{type:"importmap"}),n=n.filter((e=>!a.includes(e))),t={entryMain:o,imdata:l}}return[n,t]},X=async(e,t=J)=>{let n=e+".zip",o=await fetch(`${B||"."}/${n}`).then((async e=>{let n=!!e.headers.get("content-encoding"),o=e.body.getReader(),r=(l=+e.headers.get("content-length"),n?l<<1|0:l);var l;let i=new Uint8Array(r),a=0;for(;;){let{done:e,value:n}=await o.read();if(e)break;i.set(n,a),a+=n.length,t(`loading zip: ${a.toLocaleString()} bytes(${a/r*100|0}%)`)}return n?i.slice(0,a):i})).catch((e=>{console.error(e)}));if(o&&o.length){t(`loaded ${n}, decompressing binary...`);let e=`unzip: ${n}`;console.time(e);let r=Y(o);return console.timeEnd(e),t(`${n} decompressed 😃`),new Promise((e=>{let[t,{entryMain:n,imdata:o}={}]=W(r),l=t.length,i=o?.main,a=()=>{! --l&&e()};for(let e,o=0;e=t[o++];){let t=r[e],o=e===i;V(I.decode(t.data),e,a,{integrity:H(t.comment),url:o?n:void 0,type:o?"module":void 0})}}))}throw new Error(`Could not load "${n}"`)},Z=async()=>{Z=void 0;let e=q.querySelector("script[data-csl-config]");if(e){let t=e.dataset.cslConfig;if(t){t=JSON.parse(t);let e=t.load?(Q(t.base,t.selector),Array.isArray(t.load)?t.load:[t.load]):Array.isArray(t)?t:"string"==typeof t?[t]:[],n=[];for(let t of e)n.push(X(t).catch((e=>e)));let o=(await Promise.all(n)).filter((e=>e&&e.name));setTimeout((()=>{let e="function"==typeof cslCallback?cslCallback:window[t.callback||"cslCallback"];"function"==typeof e&&e(o.length?o:void 0)}),60),t.cleanup&&G()}}};setTimeout(Z,99);const ee="v1.4.19",te="$importmap.dat";return t})()));
|
package/unzip-sync.d.ts
CHANGED
|
@@ -71,4 +71,24 @@ export interface Unzipped {
|
|
|
71
71
|
* @param {UnzipOptions} [opts] The ZIP extraction options
|
|
72
72
|
* @returns {Unzipped} The decompressed files
|
|
73
73
|
*/
|
|
74
|
-
export declare function unzipSync(data: Uint8Array, opts?: UnzipOptions): Unzipped;
|
|
74
|
+
export declare function unzipSync(data: Uint8Array, opts?: UnzipOptions): Unzipped;
|
|
75
|
+
{number} originalSize The original size of the file
|
|
76
|
+
* @prop {number} compression The compression format for the data stream.
|
|
77
|
+
* @prop {string} [comment]
|
|
78
|
+
*
|
|
79
|
+
* This number is determined bythe spec in PKZIP's APPNOTE.txt, section 4.4.5. For example,
|
|
80
|
+
* 0 = nocompression, 8 = deflate, 14 = LZMA.
|
|
81
|
+
*
|
|
82
|
+
* If the filter function returns truebut this value is not 8, the unzip function will throw.
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
|
|
86
|
+
* performance with more than one file.
|
|
87
|
+
*
|
|
88
|
+
* NOTE: Added comment extraction feature (by jeffy-g
|
|
89
|
+
*
|
|
90
|
+
* @param {Uint8Array} data The raw compressed ZIP file
|
|
91
|
+
* @param {UnzipOptions} [opts] The ZIP extraction options
|
|
92
|
+
* @returns {Unzipped} The decompressed files
|
|
93
|
+
*/
|
|
94
|
+
export declare function unzipSync(data: Uint8Array, opts?: UnzipOptions): Unzipped;
|
package/webpack/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
2
|
(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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,{IM_MAP_ID:()=>te,cleanUp:()=>G,loadCompressedScript:()=>X,setConfig:()=>Q,unzipSync:()=>Y,version:()=>ee});const n=String.fromCharCode,r=Uint8Array,o=Uint16Array,l=Uint32Array,i=new r([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]),a=new r([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 r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),c=(e,t)=>{const n=new o(31);for(let r=0;r<31;++r)n[r]=t+=1<<e[r-1];const r=new l(n[30]);for(let e=1;e<30;++e)for(let t=n[e];t<n[e+1];++t)r[t]=t-n[e]<<5|e;return[n,r]},[d,f]=c(i,2);d[28]=258,f[258]=28;const[u,p]=c(a,0),y=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,y[e]=((65280&t)>>>8|(255&t)<<8)>>>1}const g=(e,t,n)=>{const r=e.length;let l=0;const i=new o(t);for(;l<r;++l)e[l]&&++i[e[l]-1];const a=new o(t);for(l=0;l<t;++l)a[l]=a[l-1]+i[l-1]<<1;let s;if(n){s=new o(1<<t);const n=15-t;for(l=0;l<r;++l)if(e[l]){const r=l<<4|e[l],o=t-e[l];let i=a[e[l]-1]++<<o;for(const e=i|(1<<o)-1;i<=e;++i)s[y[i]>>>n]=r}}else for(s=new o(r),l=0;l<r;++l)e[l]&&(s[l]=y[a[e[l]-1]++]>>>15-e[l]);return s},m=new r(288),h=new r(32);{let e=0;for(;e<144;)m[e++]=8;for(;e<256;)m[e++]=9;for(;e<280;)m[e++]=7;for(;e<288;)m[e++]=8;for(e=0;e<32;)h[e++]=5}const b=g(m,9,1),w=g(h,5,1),v=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 r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},k=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},$=[,r,o,,l],E=(e,t,n)=>{(!t||t<0)&&(t=0),(!n||n>e.length)&&(n=e.length);const r=new $[e.BYTES_PER_ELEMENT](n-t);return r.set(e.subarray(t,n)),r},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"];let x=Error.captureStackTrace;const C=(e,t,n)=>{const r=new Error(t||O[e]);if(r.code=e,x&&x(r,C),!n)throw r;return r},T=(e,t,n)=>{const o=e.length;if(!o||n&&n.f&&!n.l)return t||new r(0);const l=!t||!!n,c=!n||n.i;!n&&(n={}),!t&&(t=new r(3*o));const f=e=>{let n=t.length;if(e>n){const o=new r(Math.max(2*n,e));o.set(t),t=o}};let p=n.f||0,y=n.p||0,m=n.b||0,h=n.l,$=n.d,O=n.m,x=n.n;const T=8*o;do{if(!h){p=S(e,y,1);const i=S(e,y+1,3);if(y+=3,!i){const r=4+((y+7)/8|0),i=e[r-4]|e[r-3]<<8,a=r+i;if(a>o){c&&C(0);break}l&&f(m+i),t.set(e.subarray(r,a),m),n.b=m+=i,n.p=y=8*a,n.f=p;continue}if(1===i)h=b,$=w,O=9,x=5;else if(2===i){const t=S(e,y,31)+257,n=S(e,y+10,15)+4,o=t+S(e,y+5,31)+1;y+=14;const l=new r(o),i=new r(19);for(let t=0;t<n;++t)i[s[t]]=S(e,y+3*t,7);y+=3*n;const a=v(i),c=(1<<a)-1,d=g(i,a,1);for(let t=0;t<o;){const n=d[S(e,y,c)];y+=15&n;const r=n>>>4;if(r<16)l[t++]=r;else{let n=0,o=0;for(16===r?(o=3+S(e,y,3),y+=2,n=l[t-1]):17===r?(o=3+S(e,y,7),y+=3):18===r&&(o=11+S(e,y,127),y+=7);o--;)l[t++]=n}}const f=l.subarray(0,t),u=l.subarray(t);O=v(f),x=v(u),h=g(f,O,1),$=g(u,x,1)}else C(1);if(y>T){c&&C(0);break}}l&&f(m+131072);const E=(1<<O)-1,A=(1<<x)-1;let M=y;for(;;M=y){const n=h[k(e,y)&E],r=n>>>4;if(y+=15&n,y>T){c&&C(0);break}if(n||C(2),r<256)t[m++]=r;else{if(256===r){M=y,h=void 0;break}{let n=r-254;if(r>264){const t=r-257,o=i[t];n=S(e,y,(1<<o)-1)+d[t],y+=o}const o=$[k(e,y)&A],s=o>>>4;o||C(3),y+=15&o;let p=u[s];if(s>3){const t=a[s];p+=k(e,y)&(1<<t)-1,y+=t}if(y>T){c&&C(0);break}l&&f(m+131072);const g=m+n;for(;m<g;m+=4)t[m]=t[m-p],t[m+1]=t[m+1-p],t[m+2]=t[m+2-p],t[m+3]=t[m+3-p];m=g}}}n.l=h,n.p=M,n.b=m,n.f=p,h&&(p=1,n.m=O,n.d=$,n.n=x)}while(!p);return m===t.length?t:E(t,0,m)},A=(e,t)=>e[t]|e[t+1]<<8,M=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,z=(e,t)=>M(e,t)+4294967296*M(e,t+4),P=(e,t)=>t+30+A(e,t+26)+A(e,t+28),U=(e,t,n)=>{const r=!(2048&A(e,t+8)),o=A(e,t+28),l=R(e.subarray(t+46,t+46+o),r),i=t+46+o,a=M(e,t+20),[s,c,d]=n&&4294967295===a?j(e,i):[a,M(e,t+24),M(e,t+42)],f=i+A(e,t+30);return[A(e,t+10),s,c,l,i+A(e,t+30)+A(e,t+32),d,R(e.subarray(f,f+A(e,t+32)),r)]},j=(e,t)=>{for(;1!=A(e,t);t+=4+A(e,t+2));return[z(e,t+12),z(e,t+4),z(e,t+20)]};let _;const L=new r(0);try{const e=new TextDecoder;e.decode(L,{stream:!0}),_=e}catch{}const N=e=>{for(let t="",r=0;;){let o=e[r++];const l=+(o>127)+ +(o>223)+ +(o>239);if(r+l>e.length)return[t,E(e,r-1)];l?3===l?(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t+=n(55296|o>>10,56320|1023&o)):t+=n(1&l?(31&o)<<6|63&e[r++]:(15&o)<<12|(63&e[r++])<<6|63&e[r++]):t+=n(o)}};function R(e,t){if(t){let t="";for(let r=0;r<e.length;r+=16384)t+=n.apply(null,e.subarray(r,r+16384));return t}if(_)return _.decode(e);{const[t,n]=N(e)
|
|
3
|
-
;return n.length&&C(8),t}}let B,D,J=console.log,q=document,F=Object.keys,I=new TextDecoder,Y=function(e,t){const n={};let o=e.length-22;for(;101010256!=M(e,o);--o)(!o||e.length-o>65558)&&C(13);let l=A(e,o+8);if(!l)return{};let i=M(e,o+16);const a=4294967295===i;a&&(o=M(e,o-12),101075792!=M(e,o)&&C(13),l=M(e,o+32),i=M(e,o+48));const s=t&&t.filter;for(let t=0;t<l;++t){const[t,o,l,c,d,f,u]=U(e,i,a),p=P(e,f);if(i=d,!s||s({name:c,size:o,originalSize:l,compression:t,comment:u})){let i;t?8===t?i=T(e.subarray(p,p+o),new r(l)):C(14,"unknown compression type "+t):i=E(e,p,p+o),i&&(n[c]={data:i,comment:u})}}return n},G=()=>{I=void 0,V=Q=X=G=void 0,B=D=void 0,W=K=H=Y=void 0},H=e=>{let t=/^(?:sha\d{3}-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){let n=(e=t[1]).length;if(!(88^n&&64^n&&44^n))return`sha${64==n?384:88==n?512:256}-${e}`}},K=(e,t="text/javascript")=>URL.createObjectURL(new Blob([e],{type:t})),Q=(e,t)=>{B=e,D=t||""},V=(e,t,n=(()=>{}),r={})=>{let o=()=>{n(),J(`script ${t} is ready`)},l=D?q.querySelector(D).nextElementSibling:void 0,i=q.head[l?"insertBefore":"appendChild"](q.createElement("script"),l);i.id=t,r.type&&(i.type=r.type);let a=r.integrity;a?(i.integrity=a,i.crossOrigin="",i.onload=o,i.src=r.url||K(e)):(i.text=e,o())},W=e=>{let t,n=F(e);if(n.includes(te)){n=n.filter((e=>e!==te));let r,o=I.decode(e[te].data),l=JSON.parse(o),i=l.map.imports,a=[],s=new Map;const c=F(i);for(let t=0;t<c.length;){const n=c[t++];let o=s.get(n);o||s.set(n,o=K(I.decode(e[n].data))),i[n]=o,n!==l.main||r||(r=o),!a.includes(n)&&a.push(n)}V(JSON.stringify(l.map,null,2),te,void 0,{type:"importmap"}),n=n.filter((e=>!a.includes(e))),t={entryMain:r,imdata:l}}return[n,t]},X=async(e,t=J)=>{let n=e+".zip",r=await fetch(`${B||"."}/${n}`).then((async e=>{let n=!!e.headers.get("content-encoding"),r=e.body.getReader(),o=(l=+e.headers.get("content-length"),n?l<<1|0:l);var l;let i=new Uint8Array(o),a=0;for(;;){let{done:e,value:n}=await r.read();if(e)break;i.set(n,a),a+=n.length,t(`loading zip: ${a.toLocaleString()} bytes(${a/o*100|0}%)`)}return n?i.slice(0,a):i})).catch((e=>{console.error(e)}));if(r&&r.length){t(`loaded ${n}, decompressing binary...`);let e=`unzip: ${n}`;console.time(e);let o=Y(r);return console.timeEnd(e),t(`${n} decompressed 😃`),new Promise((e=>{let[t,{entryMain:n,imdata:r}={}]=W(o),l=t.length,i=r?.main,a=()=>{! --l&&e()};for(let e,r=0;e=t[r++];){let t=o[e],r=e===i;V(I.decode(t.data),e,a,{integrity:H(t.comment),url:r?n:void 0,type:r?"module":void 0})}}))}throw new Error(`Could not load "${n}"`)},Z=async()=>{Z=void 0;let e=q.querySelector("script[data-csl-config]");if(e){let t=e.dataset.cslConfig;if(t){t=JSON.parse(t);let e=t.load?(Q(t.base,t.selector),Array.isArray(t.load)?t.load:[t.load]):Array.isArray(t)?t:"string"==typeof t?[t]:[],n=[];for(let t of e)n.push(X(t).catch((e=>e)));let r=(await Promise.all(n)).filter((e=>e&&e.name));setTimeout((()=>{let e="function"==typeof cslCallback?cslCallback:window[t.callback||"cslCallback"];"function"==typeof e&&e(r.length?r:void 0)}),60),t.cleanup&&G()}}};setTimeout(Z,99);const ee="v1.4.
|
|
3
|
+
;return n.length&&C(8),t}}let B,D,J=console.log,q=document,F=Object.keys,I=new TextDecoder,Y=function(e,t){const n={};let o=e.length-22;for(;101010256!=M(e,o);--o)(!o||e.length-o>65558)&&C(13);let l=A(e,o+8);if(!l)return{};let i=M(e,o+16);const a=4294967295===i;a&&(o=M(e,o-12),101075792!=M(e,o)&&C(13),l=M(e,o+32),i=M(e,o+48));const s=t&&t.filter;for(let t=0;t<l;++t){const[t,o,l,c,d,f,u]=U(e,i,a),p=P(e,f);if(i=d,!s||s({name:c,size:o,originalSize:l,compression:t,comment:u})){let i;t?8===t?i=T(e.subarray(p,p+o),new r(l)):C(14,"unknown compression type "+t):i=E(e,p,p+o),i&&(n[c]={data:i,comment:u})}}return n},G=()=>{I=void 0,V=Q=X=G=void 0,B=D=void 0,W=K=H=Y=void 0},H=e=>{let t=/^(?:sha\d{3}-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){let n=(e=t[1]).length;if(!(88^n&&64^n&&44^n))return`sha${64==n?384:88==n?512:256}-${e}`}},K=(e,t="text/javascript")=>URL.createObjectURL(new Blob([e],{type:t})),Q=(e,t)=>{B=e,D=t||""},V=(e,t,n=(()=>{}),r={})=>{let o=()=>{n(),J(`script ${t} is ready`)},l=D?q.querySelector(D).nextElementSibling:void 0,i=q.head[l?"insertBefore":"appendChild"](q.createElement("script"),l);i.id=t,r.type&&(i.type=r.type);let a=r.integrity;a?(i.integrity=a,i.crossOrigin="",i.onload=o,i.src=r.url||K(e)):(i.text=e,o())},W=e=>{let t,n=F(e);if(n.includes(te)){n=n.filter((e=>e!==te));let r,o=I.decode(e[te].data),l=JSON.parse(o),i=l.map.imports,a=[],s=new Map;const c=F(i);for(let t=0;t<c.length;){const n=c[t++];let o=s.get(n);o||s.set(n,o=K(I.decode(e[n].data))),i[n]=o,n!==l.main||r||(r=o),!a.includes(n)&&a.push(n)}V(JSON.stringify(l.map,null,2),te,void 0,{type:"importmap"}),n=n.filter((e=>!a.includes(e))),t={entryMain:r,imdata:l}}return[n,t]},X=async(e,t=J)=>{let n=e+".zip",r=await fetch(`${B||"."}/${n}`).then((async e=>{let n=!!e.headers.get("content-encoding"),r=e.body.getReader(),o=(l=+e.headers.get("content-length"),n?l<<1|0:l);var l;let i=new Uint8Array(o),a=0;for(;;){let{done:e,value:n}=await r.read();if(e)break;i.set(n,a),a+=n.length,t(`loading zip: ${a.toLocaleString()} bytes(${a/o*100|0}%)`)}return n?i.slice(0,a):i})).catch((e=>{console.error(e)}));if(r&&r.length){t(`loaded ${n}, decompressing binary...`);let e=`unzip: ${n}`;console.time(e);let o=Y(r);return console.timeEnd(e),t(`${n} decompressed 😃`),new Promise((e=>{let[t,{entryMain:n,imdata:r}={}]=W(o),l=t.length,i=r?.main,a=()=>{! --l&&e()};for(let e,r=0;e=t[r++];){let t=o[e],r=e===i;V(I.decode(t.data),e,a,{integrity:H(t.comment),url:r?n:void 0,type:r?"module":void 0})}}))}throw new Error(`Could not load "${n}"`)},Z=async()=>{Z=void 0;let e=q.querySelector("script[data-csl-config]");if(e){let t=e.dataset.cslConfig;if(t){t=JSON.parse(t);let e=t.load?(Q(t.base,t.selector),Array.isArray(t.load)?t.load:[t.load]):Array.isArray(t)?t:"string"==typeof t?[t]:[],n=[];for(let t of e)n.push(X(t).catch((e=>e)));let r=(await Promise.all(n)).filter((e=>e&&e.name));setTimeout((()=>{let e="function"==typeof cslCallback?cslCallback:window[t.callback||"cslCallback"];"function"==typeof e&&e(r.length?r:void 0)}),60),t.cleanup&&G()}}};setTimeout(Z,99);const ee="v1.4.19",te="$importmap.dat";module.exports=t})();
|
package/webpack-esm/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.mjs.LICENSE.txt */
|
|
2
2
|
var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{Hx:()=>te,Lx:()=>I,aN:()=>W,v6:()=>K,GZ:()=>H,i8:()=>ee});const n=String.fromCharCode,r=Uint8Array,o=Uint16Array,l=Uint32Array,a=new r([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]),i=new r([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 r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),c=(e,t)=>{const n=new o(31);for(let r=0;r<31;++r)n[r]=t+=1<<e[r-1];const r=new l(n[30]);for(let e=1;e<30;++e)for(let t=n[e];t<n[e+1];++t)r[t]=t-n[e]<<5|e;return[n,r]},[d,f]=c(a,2);d[28]=258,f[258]=28;const[u,p]=c(i,0),y=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,y[e]=((65280&t)>>>8|(255&t)<<8)>>>1}const g=(e,t,n)=>{const r=e.length;let l=0;const a=new o(t);for(;l<r;++l)e[l]&&++a[e[l]-1];const i=new o(t);for(l=0;l<t;++l)i[l]=i[l-1]+a[l-1]<<1;let s;if(n){s=new o(1<<t);const n=15-t;for(l=0;l<r;++l)if(e[l]){const r=l<<4|e[l],o=t-e[l];let a=i[e[l]-1]++<<o;for(const e=a|(1<<o)-1;a<=e;++a)s[y[a]>>>n]=r}}else for(s=new o(r),l=0;l<r;++l)e[l]&&(s[l]=y[i[e[l]-1]++]>>>15-e[l]);return s},m=new r(288),h=new r(32);{let e=0;for(;e<144;)m[e++]=8;for(;e<256;)m[e++]=9;for(;e<280;)m[e++]=7;for(;e<288;)m[e++]=8;for(e=0;e<32;)h[e++]=5}const w=g(m,9,1),b=g(h,5,1),v=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},k=(e,t,n)=>{const r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},x=(e,t)=>{const n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},S=[,r,o,,l],$=(e,t,n)=>{(!t||t<0)&&(t=0),(!n||n>e.length)&&(n=e.length);const r=new S[e.BYTES_PER_ELEMENT](n-t);return r.set(e.subarray(t,n)),r},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"];let C=Error.captureStackTrace;const O=(e,t,n)=>{const r=new Error(t||E[e]);if(r.code=e,C&&C(r,O),!n)throw r;return r},A=(e,t,n)=>{const o=e.length;if(!o||n&&n.f&&!n.l)return t||new r(0);const l=!t||!!n,c=!n||n.i;!n&&(n={}),!t&&(t=new r(3*o));const f=e=>{let n=t.length;if(e>n){const o=new r(Math.max(2*n,e));o.set(t),t=o}};let p=n.f||0,y=n.p||0,m=n.b||0,h=n.l,S=n.d,E=n.m,C=n.n;const A=8*o;do{if(!h){p=k(e,y,1);const a=k(e,y+1,3);if(y+=3,!a){const r=4+((y+7)/8|0),a=e[r-4]|e[r-3]<<8,i=r+a;if(i>o){c&&O(0);break}l&&f(m+a),t.set(e.subarray(r,i),m),n.b=m+=a,n.p=y=8*i,n.f=p;continue}if(1===a)h=w,S=b,E=9,C=5;else if(2===a){const t=k(e,y,31)+257,n=k(e,y+10,15)+4,o=t+k(e,y+5,31)+1;y+=14;const l=new r(o),a=new r(19);for(let t=0;t<n;++t)a[s[t]]=k(e,y+3*t,7);y+=3*n;const i=v(a),c=(1<<i)-1,d=g(a,i,1);for(let t=0;t<o;){const n=d[k(e,y,c)];y+=15&n;const r=n>>>4;if(r<16)l[t++]=r;else{let n=0,o=0;for(16===r?(o=3+k(e,y,3),y+=2,n=l[t-1]):17===r?(o=3+k(e,y,7),y+=3):18===r&&(o=11+k(e,y,127),y+=7);o--;)l[t++]=n}}const f=l.subarray(0,t),u=l.subarray(t);E=v(f),C=v(u),h=g(f,E,1),S=g(u,C,1)}else O(1);if(y>A){c&&O(0);break}}l&&f(m+131072);const $=(1<<E)-1,z=(1<<C)-1;let T=y;for(;;T=y){const n=h[x(e,y)&$],r=n>>>4;if(y+=15&n,y>A){c&&O(0);break}if(n||O(2),r<256)t[m++]=r;else{if(256===r){T=y,h=void 0;break}{let n=r-254;if(r>264){const t=r-257,o=a[t];n=k(e,y,(1<<o)-1)+d[t],y+=o}const o=S[x(e,y)&z],s=o>>>4;o||O(3),y+=15&o;let p=u[s];if(s>3){const t=i[s];p+=x(e,y)&(1<<t)-1,y+=t}if(y>A){c&&O(0);break}l&&f(m+131072);const g=m+n;for(;m<g;m+=4)t[m]=t[m-p],t[m+1]=t[m+1-p],t[m+2]=t[m+2-p],t[m+3]=t[m+3-p];m=g}}}n.l=h,n.p=T,n.b=m,n.f=p,h&&(p=1,n.m=E,n.d=S,n.n=C)}while(!p);return m===t.length?t:$(t,0,m)},z=(e,t)=>e[t]|e[t+1]<<8,T=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,U=(e,t)=>T(e,t)+4294967296*T(e,t+4),M=(e,t)=>t+30+z(e,t+26)+z(e,t+28),L=(e,t,n)=>{const r=!(2048&z(e,t+8)),o=z(e,t+28),l=_(e.subarray(t+46,t+46+o),r),a=t+46+o,i=T(e,t+20),[s,c,d]=n&&4294967295===i?N(e,a):[i,T(e,t+24),T(e,t+42)],f=a+z(e,t+30);return[z(e,t+10),s,c,l,a+z(e,t+30)+z(e,t+32),d,_(e.subarray(f,f+z(e,t+32)),r)]},N=(e,t)=>{for(;1!=z(e,t);t+=4+z(e,t+2));return[U(e,t+12),U(e,t+4),U(e,t+20)]};let P;const j=new r(0);try{const e=new TextDecoder;e.decode(j,{stream:!0}),P=e}catch{}const R=e=>{for(let t="",r=0;;){let o=e[r++];const l=+(o>127)+ +(o>223)+ +(o>239);if(r+l>e.length)return[t,$(e,r-1)];l?3===l?(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t+=n(55296|o>>10,56320|1023&o)):t+=n(1&l?(31&o)<<6|63&e[r++]:(15&o)<<12|(63&e[r++])<<6|63&e[r++]):t+=n(o)}};function _(e,t){if(t){let t="";for(let r=0;r<e.length;r+=16384)t+=n.apply(null,e.subarray(r,r+16384));return t}if(P)return P.decode(e);{const[t,n]=R(e);return n.length&&O(8),t}}let B,D,J=console.log,q=document,F=Object.keys,G=new TextDecoder,H=function(e,t){const n={};let o=e.length-22;for(;101010256!=T(e,o);--o)(!o||e.length-o>65558)&&O(13);let l=z(e,o+8);if(!l)return{};let a=T(e,o+16)
|
|
3
|
-
;const i=4294967295===a;i&&(o=T(e,o-12),101075792!=T(e,o)&&O(13),l=T(e,o+32),a=T(e,o+48));const s=t&&t.filter;for(let t=0;t<l;++t){const[t,o,l,c,d,f,u]=L(e,a,i),p=M(e,f);if(a=d,!s||s({name:c,size:o,originalSize:l,compression:t,comment:u})){let a;t?8===t?a=A(e.subarray(p,p+o),new r(l)):O(14,"unknown compression type "+t):a=$(e,p,p+o),a&&(n[c]={data:a,comment:u})}}return n},I=()=>{G=void 0,Q=K=W=I=void 0,B=D=void 0,V=Y=Z=H=void 0},Z=e=>{let t=/^(?:sha\d{3}-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){let n=(e=t[1]).length;if(!(88^n&&64^n&&44^n))return`sha${64==n?384:88==n?512:256}-${e}`}},Y=(e,t="text/javascript")=>URL.createObjectURL(new Blob([e],{type:t})),K=(e,t)=>{B=e,D=t||""},Q=(e,t,n=(()=>{}),r={})=>{let o=()=>{n(),J(`script ${t} is ready`)},l=D?q.querySelector(D).nextElementSibling:void 0,a=q.head[l?"insertBefore":"appendChild"](q.createElement("script"),l);a.id=t,r.type&&(a.type=r.type);let i=r.integrity;i?(a.integrity=i,a.crossOrigin="",a.onload=o,a.src=r.url||Y(e)):(a.text=e,o())},V=e=>{let t,n=F(e);if(n.includes(te)){n=n.filter((e=>e!==te));let r,o=G.decode(e[te].data),l=JSON.parse(o),a=l.map.imports,i=[],s=new Map;const c=F(a);for(let t=0;t<c.length;){const n=c[t++];let o=s.get(n);o||s.set(n,o=Y(G.decode(e[n].data))),a[n]=o,n!==l.main||r||(r=o),!i.includes(n)&&i.push(n)}Q(JSON.stringify(l.map,null,2),te,void 0,{type:"importmap"}),n=n.filter((e=>!i.includes(e))),t={entryMain:r,imdata:l}}return[n,t]},W=async(e,t=J)=>{let n=e+".zip",r=await fetch(`${B||"."}/${n}`).then((async e=>{let n=!!e.headers.get("content-encoding"),r=e.body.getReader(),o=(l=+e.headers.get("content-length"),n?l<<1|0:l);var l;let a=new Uint8Array(o),i=0;for(;;){let{done:e,value:n}=await r.read();if(e)break;a.set(n,i),i+=n.length,t(`loading zip: ${i.toLocaleString()} bytes(${i/o*100|0}%)`)}return n?a.slice(0,i):a})).catch((e=>{console.error(e)}));if(r&&r.length){t(`loaded ${n}, decompressing binary...`);let e=`unzip: ${n}`;console.time(e);let o=H(r);return console.timeEnd(e),t(`${n} decompressed 😃`),new Promise((e=>{let[t,{entryMain:n,imdata:r}={}]=V(o),l=t.length,a=r?.main,i=()=>{! --l&&e()};for(let e,r=0;e=t[r++];){let t=o[e],r=e===a;Q(G.decode(t.data),e,i,{integrity:Z(t.comment),url:r?n:void 0,type:r?"module":void 0})}}))}throw new Error(`Could not load "${n}"`)},X=async()=>{X=void 0;let e=q.querySelector("script[data-csl-config]");if(e){let t=e.dataset.cslConfig;if(t){t=JSON.parse(t);let e=t.load?(K(t.base,t.selector),Array.isArray(t.load)?t.load:[t.load]):Array.isArray(t)?t:"string"==typeof t?[t]:[],n=[];for(let t of e)n.push(W(t).catch((e=>e)));let r=(await Promise.all(n)).filter((e=>e&&e.name));setTimeout((()=>{let e="function"==typeof cslCallback?cslCallback:window[t.callback||"cslCallback"];"function"==typeof e&&e(r.length?r:void 0)}),60),t.cleanup&&I()}}};setTimeout(X,99);const ee="v1.4.
|
|
3
|
+
;const i=4294967295===a;i&&(o=T(e,o-12),101075792!=T(e,o)&&O(13),l=T(e,o+32),a=T(e,o+48));const s=t&&t.filter;for(let t=0;t<l;++t){const[t,o,l,c,d,f,u]=L(e,a,i),p=M(e,f);if(a=d,!s||s({name:c,size:o,originalSize:l,compression:t,comment:u})){let a;t?8===t?a=A(e.subarray(p,p+o),new r(l)):O(14,"unknown compression type "+t):a=$(e,p,p+o),a&&(n[c]={data:a,comment:u})}}return n},I=()=>{G=void 0,Q=K=W=I=void 0,B=D=void 0,V=Y=Z=H=void 0},Z=e=>{let t=/^(?:sha\d{3}-)?([a-z0-9+/=]{44,88})$/i.exec(e);if(t){let n=(e=t[1]).length;if(!(88^n&&64^n&&44^n))return`sha${64==n?384:88==n?512:256}-${e}`}},Y=(e,t="text/javascript")=>URL.createObjectURL(new Blob([e],{type:t})),K=(e,t)=>{B=e,D=t||""},Q=(e,t,n=(()=>{}),r={})=>{let o=()=>{n(),J(`script ${t} is ready`)},l=D?q.querySelector(D).nextElementSibling:void 0,a=q.head[l?"insertBefore":"appendChild"](q.createElement("script"),l);a.id=t,r.type&&(a.type=r.type);let i=r.integrity;i?(a.integrity=i,a.crossOrigin="",a.onload=o,a.src=r.url||Y(e)):(a.text=e,o())},V=e=>{let t,n=F(e);if(n.includes(te)){n=n.filter((e=>e!==te));let r,o=G.decode(e[te].data),l=JSON.parse(o),a=l.map.imports,i=[],s=new Map;const c=F(a);for(let t=0;t<c.length;){const n=c[t++];let o=s.get(n);o||s.set(n,o=Y(G.decode(e[n].data))),a[n]=o,n!==l.main||r||(r=o),!i.includes(n)&&i.push(n)}Q(JSON.stringify(l.map,null,2),te,void 0,{type:"importmap"}),n=n.filter((e=>!i.includes(e))),t={entryMain:r,imdata:l}}return[n,t]},W=async(e,t=J)=>{let n=e+".zip",r=await fetch(`${B||"."}/${n}`).then((async e=>{let n=!!e.headers.get("content-encoding"),r=e.body.getReader(),o=(l=+e.headers.get("content-length"),n?l<<1|0:l);var l;let a=new Uint8Array(o),i=0;for(;;){let{done:e,value:n}=await r.read();if(e)break;a.set(n,i),i+=n.length,t(`loading zip: ${i.toLocaleString()} bytes(${i/o*100|0}%)`)}return n?a.slice(0,i):a})).catch((e=>{console.error(e)}));if(r&&r.length){t(`loaded ${n}, decompressing binary...`);let e=`unzip: ${n}`;console.time(e);let o=H(r);return console.timeEnd(e),t(`${n} decompressed 😃`),new Promise((e=>{let[t,{entryMain:n,imdata:r}={}]=V(o),l=t.length,a=r?.main,i=()=>{! --l&&e()};for(let e,r=0;e=t[r++];){let t=o[e],r=e===a;Q(G.decode(t.data),e,i,{integrity:Z(t.comment),url:r?n:void 0,type:r?"module":void 0})}}))}throw new Error(`Could not load "${n}"`)},X=async()=>{X=void 0;let e=q.querySelector("script[data-csl-config]");if(e){let t=e.dataset.cslConfig;if(t){t=JSON.parse(t);let e=t.load?(K(t.base,t.selector),Array.isArray(t.load)?t.load:[t.load]):Array.isArray(t)?t:"string"==typeof t?[t]:[],n=[];for(let t of e)n.push(W(t).catch((e=>e)));let r=(await Promise.all(n)).filter((e=>e&&e.name));setTimeout((()=>{let e="function"==typeof cslCallback?cslCallback:window[t.callback||"cslCallback"];"function"==typeof e&&e(r.length?r:void 0)}),60),t.cleanup&&I()}}};setTimeout(X,99);const ee="v1.4.19",te="$importmap.dat";var ne=t.Hx,re=t.Lx,oe=t.aN,le=t.v6,ae=t.GZ,ie=t.i8;export{ne as IM_MAP_ID,re as cleanUp,oe as loadCompressedScript,le as setConfig,ae as unzipSync,ie as version};
|