compressed-script-loader 1.3.9 → 1.4.15
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 +12 -12
- package/bin/cslpack.js +2 -3
- package/bin/cslpack.js.LICENSE.txt +8 -0
- package/csl-types.d.ts +1 -1
- package/index.d.ts +3 -3
- package/package.json +6 -2
- package/umd/index.js +2 -2
- package/unzip-sync.d.ts +0 -19
- package/webpack/index.js +2 -2
- package/webpack-esm/index.mjs +2 -2
package/README.md
CHANGED
|
@@ -83,18 +83,18 @@ You can use `sha256`, `sha384`, and `sha512` in `script.integrity`, and the pref
|
|
|
83
83
|
+ vscode snippet
|
|
84
84
|
|
|
85
85
|
```json
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
"compressed script loader snippet": {
|
|
87
|
+
"prefix": "csl-script-tag",
|
|
88
|
+
"scope": "markdown,html,json,jsonc,snippets",
|
|
89
|
+
"description": "Insert compressed script loader script tag.",
|
|
90
|
+
"body": [
|
|
91
|
+
"<script data-csl-config='{",
|
|
92
|
+
" \"base\": \"${1:./lib}\",",
|
|
93
|
+
" \"load\": ${2|\"bundle\",[\"bundle\"]|},",
|
|
94
|
+
" ${3|\"callback\": \"cslCallback\",\"callback\": \"cslCallback\",\n\"cleanup\": true|}",
|
|
95
|
+
"}' src=\"https://cdn.jsdelivr.net/npm/compressed-script-loader/umd/index.js\" defer></script>"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
|
package/bin/cslpack.js
CHANGED
|
@@ -1,5 +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
|
|
4
|
-
|
|
5
|
-
;re||(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 ${Z}\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 te=new class{list={};map;constructor(e){this.setModuleMain(e)}setModuleMain(e){"string"==typeof e&&e.length?this.map={main:e,map:{imports:{}}}:this.map=void 0}add(r,t){let a=n.parse(r),o=`${a.dir}/${a.base}`,i=e.readFileSync(o,"utf8");if(i){let e=this.map;e&&((e,r,t)=>{const n=/(?<!\/\/\s*)(?:import|export)\s*(?:|[\w_]+\s+from|(?:[\w_]+\s*,\s*)?\{[^}]+\}\s*from|\*\s*as\s+[\w_]+\s+from|\*\s*from)?\s*"(([.\/]+)?[^"]+(?:\.(?:c|m)?js)?)"\s*;?/gm;let a,o=r.imports;for(;a=n.exec(e);)t&&!a[2]||(o[a[1]]="")})(i,e.map),this.list[a.base]=[X.encode(i),{level:7,comment:t}]}}emit(r){let t=this.list,o=this.map;o&&(t["$importmap.dat"]=[X.encode(JSON.stringify(o,null,2)),{level:7}]);let i=`[fflate.zip:${r}]`;console.time(i);let s=function(e,r){r||(r={});var t={},n=[];Y(e,'',t,r);var o=0,i=0;for(var s in t){var f=t[s],l=f[0],c=f[1],u=0==c.level?0:8,v=(M=K(s)).length,h=c.comment,p=h&&K(h),d=p&&p.length,g=L(c.extra);v>65535&&T(11);var m=u?J(l,c):l,_=m.length,w=W();w.p(l),n.push(P(c,{size:l.length,crc:w.d(),c:m,f:M,m:p,u:v!=s.length||p&&h.length!=d,o,compression:u})),o+=30+v+g+_,i+=76+2*(v+g)+(d||0)+_}for(var b=new a(i+22),x=o,y=i-o,k=0;k<n.length;++k){var M=n[k];Q(b,M.o,M,M.f,M.u,M.c.length);var A=30+M.f.length+L(M.extra);b.set(M.c,M.o+A),Q(b,o,M,M.f,M.u,M.c.length,M.o,M.m),o+=16+A+(M.m?M.m.length:0)}return V(b,o,n.length,y,x),b}(t,{});(r=>{const t=n.dirname(r);e.existsSync(t)||e.mkdirSync(t,{recursive:!0})})(r),e.writeFile(r,s,"binary",(()=>{console.timeEnd(i),console.log(o),this.reset()}))}reset(){this.list={},this.map=void 0}}(ee.m);let ne=ee.sha;/256|384|512/.test(ne)||(ne="384");for(const t of re){if(e.statSync(t).isFile()){const e=r.execSync(`bash -c "echo -n $(openssl dgst -sha${ne} -binary ${t} | openssl base64 -A)"`,{encoding:"utf8"});te.add(t,e)}}te.emit(ee.d||ee.dest||Z)})(),module.exports=_we_})();
|
|
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_);const e=require("fs");var t=_wr_(274);const s=require("path"),o=require("fflate"),r=require("util"),n=require("crypto");require("colors");function i(){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=function(){return this.replace(/\\/g,"/")};const a=new TextEncoder,c=process.env.CI?()=>{}:console.log.bind(console,"[cslpack]:".blue),p=(e,t)=>{e="info"===t?e.gray:"warn"===t?e.cyan:"lightwarn"===t?e.green:e,c(e)},l=new Map,d=e=>{e&&c(l),l.clear()},h=t=>(c(`createCSLPackEntry actualPath:[${t}]`),{canonicalPath:t,homogenized:"",code:e.readFileSync(t,"utf8"),modIdDetails:[]}),m=(e,t)=>{const o=i(),r=e.code;let n;for(;n=o.exec(r);){const o=n[1],r=n[0];if(e.modIdDetails.push({moduleId:o,statement:r,referrer:e.canonicalPath}),!l.has(o)){const r=s.parse(e.canonicalPath),n=s.resolve(r.dir,o).toUnixPath();l.set(o,n),t[n]?p(`source: "${n}" is already scanned`,"info"):m(t[n]=h(n),t)}}};const u=new r.TextEncoder;let _="./dist/bundle.zip",g=t();console.log(g);let f=g.args;f||(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 ${_}\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 v=new class{prefetchSources={};list={};cslImportMap;constructor(e){this.setModuleMain(e)}setModuleMain(e){"string"==typeof e&&e.length?this.cslImportMap={main:e,map:{imports:{}}}:this.cslImportMap=void 0,d()}add(e){const t=((e,t)=>{const o=s.resolve(e).toUnixPath();if(!t[o])return t[o]=h(o);p(`source: "${o}" is already scanned`,"info")})(e,this.prefetchSources);t&&this.cslImportMap&&m(t,this.prefetchSources)}async emit(t,r){/256|384|512/.test(r)||(r="384");const p=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)}))})(p);const d=JSON.stringify(p,((e,t)=>"code"===e?"...":t),2);e.writeFile("./cslpack-info.json",d,"binary",(()=>{console.log()}));let h=this.list,m=this.cslImportMap;await((e,t,o,r)=>{const c=i(),p=o?.map.imports,d=[];return Object.values(e).forEach((i=>{const h=i.code;let m;p&&(c.lastIndex=0,m=h.replace(c,((t,s)=>{const o=l.get(s);if(!o)throw new Error("process homogenizeModuleIds failed!");const r=e[o].homogenized;return p[r]="",t.replace(s,r)}))),s.parse(i.canonicalPath).base===o?.main&&(o.main=i.homogenized);const u=`[openssl dgst:${i.homogenized}]`;console.time(u),d.push(new Promise((e=>{
|
|
4
|
+
t[i.homogenized]=[a.encode(m||h),{level:7,comment:n.createHash(`sha${r}`).update(m||h).digest('base64')}],console.timeEnd(u),e()})))})),Promise.all(d)})(p,h,m,r),m&&(h["$importmap.dat"]=[u.encode(JSON.stringify(m,null,2)),{level:7}]);const _=`[fflate.zip:${t}]`;console.time(_),o.zip(h,((o,r)=>{if(console.timeEnd(_),o)throw o;(t=>{const o=s.dirname(t);e.existsSync(o)||e.mkdirSync(o,{recursive:!0})})(t),e.writeFile(t,r,"binary",(()=>{c(m),this.reset()}))}))}reset(){this.list={},this.prefetchSources={},this.cslImportMap=void 0,d(!0)}}(g.m);let x=g.sha;/256|384|512/.test(x)||(x="384");for(const t of f){e.statSync(t).isFile()&&v.add(t)}v.emit(g.d||g.dest||_,x).then((()=>{console.log("cslpack done!")}))})(),module.exports=_we_})();
|
|
@@ -5,3 +5,11 @@
|
|
|
5
5
|
https://opensource.org/licenses/mit-license.php
|
|
6
6
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
7
|
*/
|
|
8
|
+
|
|
9
|
+
/*!
|
|
10
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
11
|
+
Copyright (C) 2023 jeffy-g <hirotom1107@gmail.com>
|
|
12
|
+
Released under the MIT license
|
|
13
|
+
https://opensource.org/licenses/mit-license.php
|
|
14
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
15
|
+
*/
|
package/csl-types.d.ts
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* </script>
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
declare var NsLoader: typeof import("./index
|
|
40
|
+
declare var NsLoader: typeof import("./index");
|
|
41
41
|
/**
|
|
42
42
|
* `cslCallback` is the callback function name called by default to notify the zip file load completion
|
|
43
43
|
* when `data-csl-config` is embedded in the script element.
|
package/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
https://opensource.org/licenses/mit-license.php
|
|
6
6
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
7
|
*/
|
|
8
|
-
/// <reference
|
|
9
|
-
/// <reference
|
|
8
|
+
/// <reference path="./csl-types.d.ts" />
|
|
9
|
+
/// <reference path="./import-map.d.ts" />
|
|
10
10
|
/**
|
|
11
11
|
* @file Load zipped javascript source to page by fetch API
|
|
12
12
|
* @author jeffy-g <hirotom1107@gmail.com>
|
|
@@ -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.
|
|
37
|
+
declare const version = "v1.4.15";
|
|
38
38
|
/**
|
|
39
39
|
* `importmap` zip entry name
|
|
40
40
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compressed-script-loader",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.15",
|
|
4
4
|
"description": "Reduces network traffic for huge source files built by webpack etc.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./webpack/index.js",
|
|
@@ -43,5 +43,9 @@
|
|
|
43
43
|
"SPA",
|
|
44
44
|
"html",
|
|
45
45
|
"dhtml"
|
|
46
|
-
]
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"fflate": "^0.8.1",
|
|
49
|
+
"colors": "^1.4.0"
|
|
50
|
+
}
|
|
47
51
|
}
|
package/umd/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
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]},[f
|
|
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,f,
|
|
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.15",te="$importmap.dat";return t})()));
|
package/unzip-sync.d.ts
CHANGED
|
@@ -61,25 +61,6 @@ export interface Unzipped {
|
|
|
61
61
|
comment?: string;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {Error & { code: number }} FlateError An error generated within this library
|
|
66
|
-
* @typedef {(file: UnzipFileInfo) => boolean} UnzipFileFilter
|
|
67
|
-
* @typedef {{ filter?: UnzipFileFilter }} UnzipOptions
|
|
68
|
-
* @typedef {Record<string, { data: Uint8Array; comment?: string; }>} Unzipped
|
|
69
|
-
*/
|
|
70
|
-
/**
|
|
71
|
-
* @typedef UnzipFileInfo
|
|
72
|
-
* @prop {string} name The name of the file
|
|
73
|
-
* @prop {number} size The compressed size of the file
|
|
74
|
-
* @prop {number} originalSize The original size of the file
|
|
75
|
-
* @prop {number} compression The compression format for the data stream.
|
|
76
|
-
* @prop {string} [comment]
|
|
77
|
-
*
|
|
78
|
-
* This number is determined bythe spec in PKZIP's APPNOTE.txt, section 4.4.5. For example,
|
|
79
|
-
* 0 = nocompression, 8 = deflate, 14 = LZMA.
|
|
80
|
-
*
|
|
81
|
-
* If the filter function returns truebut this value is not 8, the unzip function will throw.
|
|
82
|
-
*/
|
|
83
64
|
/**
|
|
84
65
|
* Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
|
|
85
66
|
* performance with more than one file.
|
package/webpack/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
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}
|
|
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;F(i)
|
|
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.15",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
|
-
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]},[f
|
|
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,f,
|
|
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.15",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};
|