single-file-core 1.5.129 → 1.6.0
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/core/helper.js +27 -1
- package/core/index.js +34 -21
- package/core/infobar.js +7 -7
- package/core/lib/processor-helper-inline.js +1 -1
- package/core/lib/processor-helper.js +1 -1
- package/package.json +1 -1
- package/processors/compression/compression.js +2 -1
- package/processors/frame-tree/content/content-frame-tree.js +1 -1
- package/processors/hooks/content/content-hooks-frames-web.js +48 -38
- package/processors/hooks/content/content-hooks-frames.js +28 -27
- package/processors/lazy/content/content-lazy-loader.js +10 -10
- package/single-file.js +10 -9
- package/test/capture/canonical-link.js +50 -0
- package/test/capture/common.js +1 -0
- package/test/capture/deferred-content-options.js +71 -0
- package/test/capture/dom.js +13 -1
- package/test/capture/maff-metadata.js +205 -0
- package/test/capture/script-uri-sanitization.js +82 -0
- package/test/sfz-harness/pages-archive.js +5 -2
- package/vendor/zip/z-worker.js +1 -1
- package/vendor/zip/zip.js +707 -951
- package/vendor/zip/zip.min.js +1 -1
- package/zip-build/package-lock.json +4 -4
- package/zip-build/package.json +1 -1
- package/zip-build/reserved-property-names.json +4 -0
- package/zip-build/rollup.config.js +1 -1
package/single-file.js
CHANGED
|
@@ -47,6 +47,7 @@ function init(initOptions) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async function getPageData(options = {}, initOptions, doc, win) {
|
|
50
|
+
options = helper.normalizeOptions(options);
|
|
50
51
|
if (doc === undefined) {
|
|
51
52
|
doc = globalThis.document;
|
|
52
53
|
}
|
|
@@ -61,41 +62,41 @@ async function getPageData(options = {}, initOptions, doc, win) {
|
|
|
61
62
|
const preInitializationPromises = [];
|
|
62
63
|
if (!options.saveRawPage) {
|
|
63
64
|
let lazyLoadPromise;
|
|
64
|
-
if (options.
|
|
65
|
+
if (options.loadDeferredContent) {
|
|
65
66
|
lazyLoadPromise = processors.lazy.process(options);
|
|
66
|
-
if (options.
|
|
67
|
+
if (options.loadDeferredContentBeforeFrames) {
|
|
67
68
|
await lazyLoadPromise;
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
if (!options.removeFrames && frames && globalThis.frames) {
|
|
71
72
|
let frameTreePromise;
|
|
72
|
-
if (options.
|
|
73
|
-
frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.
|
|
73
|
+
if (options.loadDeferredContent) {
|
|
74
|
+
frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredContentBeforeFrames || !options.loadDeferredContent ? 0 : options.loadDeferredContentMaxIdleTime));
|
|
74
75
|
} else {
|
|
75
76
|
frameTreePromise = frames.getAsync(options);
|
|
76
77
|
}
|
|
77
|
-
if (options.
|
|
78
|
+
if (options.loadDeferredContentBeforeFrames) {
|
|
78
79
|
options.frames = await frameTreePromise;
|
|
79
80
|
} else {
|
|
80
81
|
preInitializationPromises.push(frameTreePromise);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
if (options.
|
|
84
|
+
if (options.loadDeferredContent && !options.loadDeferredContentBeforeFrames) {
|
|
84
85
|
preInitializationPromises.push(lazyLoadPromise);
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
if (!options.
|
|
88
|
+
if (!options.loadDeferredContentBeforeFrames) {
|
|
88
89
|
[options.frames] = await Promise.all(preInitializationPromises);
|
|
89
90
|
}
|
|
90
91
|
framesSessionId = options.frames && options.frames.sessionId;
|
|
91
92
|
}
|
|
92
93
|
options.doc = doc;
|
|
93
94
|
options.win = win;
|
|
94
|
-
options.insertCanonicalLink = true;
|
|
95
|
+
options.insertCanonicalLink = options.insertCanonicalLink === undefined ? true : options.insertCanonicalLink;
|
|
95
96
|
|
|
96
97
|
const externalOnProgress = options.onprogress;
|
|
97
98
|
options.onprogress = async event => {
|
|
98
|
-
if (event.type === event.RESOURCES_INITIALIZED && doc && win && options.
|
|
99
|
+
if (event.type === event.RESOURCES_INITIALIZED && doc && win && options.loadDeferredContent) {
|
|
99
100
|
processors.lazy.resetZoomLevel(options);
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { capture, html } from "./common.js";
|
|
2
|
+
|
|
3
|
+
const PAGE_URL = "https://example.com/page.html";
|
|
4
|
+
const FILE_URL = "file:///tmp/page.html";
|
|
5
|
+
const PAGE = html("<h1>page</h1>");
|
|
6
|
+
|
|
7
|
+
const resources = {
|
|
8
|
+
[PAGE_URL]: { body: PAGE },
|
|
9
|
+
[FILE_URL]: { body: PAGE }
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
let failed = false;
|
|
13
|
+
|
|
14
|
+
// insertCanonicalLink was forced to true in single-file.js after the options were merged, so it read
|
|
15
|
+
// as an option in three places and could be set from none: the CLI flag was written, measured doing
|
|
16
|
+
// nothing, and removed again rather than shipped. It now defaults to true instead of being forced,
|
|
17
|
+
// which is what makes the flag and the extension config key mean anything.
|
|
18
|
+
{
|
|
19
|
+
const content = await capture(resources, { url: PAGE_URL, content: PAGE });
|
|
20
|
+
check("a canonical link is inserted by default", content.includes("rel=\"canonical\""), true);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
{
|
|
24
|
+
const content = await capture(resources, { url: PAGE_URL, content: PAGE, insertCanonicalLink: false });
|
|
25
|
+
check("insertCanonicalLink false suppresses it", content.includes("rel=\"canonical\""), false);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
const content = await capture(resources, { url: PAGE_URL, content: PAGE, insertCanonicalLink: true });
|
|
30
|
+
check("insertCanonicalLink true keeps it", content.includes("rel=\"canonical\""), true);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// The href guard is the reason the option is safe to default on: a page saved from disk has no
|
|
34
|
+
// canonical URL to point at, and the element is skipped rather than written with a file: href.
|
|
35
|
+
{
|
|
36
|
+
const content = await capture(resources, { url: FILE_URL, content: PAGE });
|
|
37
|
+
check("a page saved from file: gets no canonical link", content.includes("rel=\"canonical\""), false);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (failed) {
|
|
41
|
+
console.log("FAILED");
|
|
42
|
+
Deno.exit(1);
|
|
43
|
+
}
|
|
44
|
+
console.log("OK");
|
|
45
|
+
|
|
46
|
+
function check(label, actual, expected) {
|
|
47
|
+
const ok = actual === expected;
|
|
48
|
+
console.log(`${ok ? "PASS" : "FAIL"} ${label}: ${actual}${ok ? "" : " (expected " + expected + ")"}`);
|
|
49
|
+
failed ||= !ok;
|
|
50
|
+
}
|
package/test/capture/common.js
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { helper } from "./common.js";
|
|
2
|
+
|
|
3
|
+
// The loadDeferredImages* options were renamed to loadDeferredContent* because they never applied to
|
|
4
|
+
// images only: they govern every kind of deferred content, including frames and whole virtualized
|
|
5
|
+
// message lists. The old names stay accepted because they are public API in two ways core cannot
|
|
6
|
+
// see - a library caller passing them to getPageData, and another extension passing them through the
|
|
7
|
+
// external capture API - so this suite pins the compatibility shim rather than the rename.
|
|
8
|
+
|
|
9
|
+
const DEPRECATED_NAMES = {
|
|
10
|
+
loadDeferredImages: "loadDeferredContent",
|
|
11
|
+
loadDeferredImagesMaxIdleTime: "loadDeferredContentMaxIdleTime",
|
|
12
|
+
loadDeferredImagesBlockCookies: "loadDeferredContentBlockCookies",
|
|
13
|
+
loadDeferredImagesBlockStorage: "loadDeferredContentBlockStorage",
|
|
14
|
+
loadDeferredImagesKeepZoomLevel: "loadDeferredContentKeepZoomLevel",
|
|
15
|
+
loadDeferredImagesDispatchScrollEvent: "loadDeferredContentDispatchScrollEvent",
|
|
16
|
+
loadDeferredImagesBeforeFrames: "loadDeferredContentBeforeFrames"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
let failed = false;
|
|
20
|
+
|
|
21
|
+
{
|
|
22
|
+
for (const deprecatedName of Object.keys(DEPRECATED_NAMES)) {
|
|
23
|
+
const optionName = DEPRECATED_NAMES[deprecatedName];
|
|
24
|
+
const value = deprecatedName.endsWith("MaxIdleTime") ? 3000 : true;
|
|
25
|
+
const normalized = helper.normalizeOptions({ [deprecatedName]: value });
|
|
26
|
+
check(`${deprecatedName} fills ${optionName}`, normalized[optionName], value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// A false or 0 must survive: testing the deprecated value for truthiness instead of for undefined
|
|
31
|
+
// would silently drop every option a user turned off, which is the half that matters most here.
|
|
32
|
+
{
|
|
33
|
+
const normalized = helper.normalizeOptions({ loadDeferredImages: false, loadDeferredImagesMaxIdleTime: 0 });
|
|
34
|
+
check("a deprecated false is carried over", normalized.loadDeferredContent, false);
|
|
35
|
+
check("a deprecated 0 is carried over", normalized.loadDeferredContentMaxIdleTime, 0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
{
|
|
39
|
+
const normalized = helper.normalizeOptions({ loadDeferredImages: false, loadDeferredContent: true });
|
|
40
|
+
check("the new name wins when both are set", normalized.loadDeferredContent, true);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// getPageData is handed the caller's own object, so filling the new names in place would edit an
|
|
44
|
+
// object the caller still holds and may reuse for a second capture.
|
|
45
|
+
{
|
|
46
|
+
const options = { loadDeferredImages: true };
|
|
47
|
+
const normalized = helper.normalizeOptions(options);
|
|
48
|
+
check("the caller's object is not mutated", options.loadDeferredContent, undefined);
|
|
49
|
+
check("a copy is returned instead", normalized.loadDeferredContent, true);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
const options = { removeFrames: true };
|
|
54
|
+
check("an options object without deprecated names is returned as is", helper.normalizeOptions(options), options);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
check("a missing options object is tolerated", helper.normalizeOptions(undefined), undefined);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (failed) {
|
|
62
|
+
console.log("FAILED");
|
|
63
|
+
Deno.exit(1);
|
|
64
|
+
}
|
|
65
|
+
console.log("OK");
|
|
66
|
+
|
|
67
|
+
function check(label, actual, expected) {
|
|
68
|
+
const ok = actual === expected;
|
|
69
|
+
console.log(`${ok ? "PASS" : "FAIL"} ${label}: ${actual}${ok ? "" : " (expected " + expected + ")"}`);
|
|
70
|
+
failed ||= !ok;
|
|
71
|
+
}
|
package/test/capture/dom.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// reads globalThis.window, then calls init() and new MutationObserver(init) at module scope. That
|
|
4
4
|
// hook belongs to the page world and does nothing useful here; it only has to load without throwing.
|
|
5
5
|
// Import this module first and import single-file.js dynamically, the way common.js does.
|
|
6
|
-
import { DOMParser, Document } from "jsr:@b-fuze/deno-dom@0.1.56";
|
|
6
|
+
import { DOMParser, Document, Element } from "jsr:@b-fuze/deno-dom@0.1.56";
|
|
7
7
|
|
|
8
8
|
globalThis.DOMParser = DOMParser;
|
|
9
9
|
globalThis.Document = Document;
|
|
@@ -12,3 +12,15 @@ globalThis.MutationObserver = class {
|
|
|
12
12
|
observe() { }
|
|
13
13
|
disconnect() { }
|
|
14
14
|
};
|
|
15
|
+
|
|
16
|
+
// deno-dom implements neither of these, so removeEmbedScripts throws here and nowhere else. Mapping
|
|
17
|
+
// them onto the qualified-name methods is faithful for what deno-dom can represent, which is only
|
|
18
|
+
// null-namespace attributes: it drops the prefix of xlink:href and lowercases nothing, so the
|
|
19
|
+
// namespaced and mixed-case cases cannot be written as a fixture at all. Those are covered by the
|
|
20
|
+
// browser suite in single-file-cli, which drives a real DOM.
|
|
21
|
+
Element.prototype.setAttributeNS = function (namespaceURI, qualifiedName, value) {
|
|
22
|
+
this.setAttribute(qualifiedName, value);
|
|
23
|
+
};
|
|
24
|
+
Element.prototype.removeAttributeNS = function (namespaceURI, localName) {
|
|
25
|
+
this.removeAttribute(localName);
|
|
26
|
+
};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import "./dom.js";
|
|
2
|
+
|
|
3
|
+
// core/util.js captures globalThis.DOMParser when it loads, and deno-dom throws on "text/xml", so
|
|
4
|
+
// the MAFF metadata could not be parsed here at all. This substitutes a stub for that one mime type,
|
|
5
|
+
// installed before common.js imports core, the same ordering constraint dom.js itself documents.
|
|
6
|
+
//
|
|
7
|
+
// What the stub stands for and what it does not. The two defects fixed alongside this suite are both
|
|
8
|
+
// about what core does with what the parser HANDS BACK — an attribute that came back null, and which
|
|
9
|
+
// of two almost-identical option fields gets written out — so a stub returning null or a string
|
|
10
|
+
// covers them faithfully. It does NOT cover the parse: that `RDF > Description > originalurl` matches
|
|
11
|
+
// `<RDF:RDF><RDF:Description><MAF:originalurl>` by local name, and that getAttributeNS resolves the
|
|
12
|
+
// RDF prefix, are properties of a real XML DOM that only a browser suite can confirm.
|
|
13
|
+
const XML_DOCUMENTS = new Map();
|
|
14
|
+
const NativeDOMParser = globalThis.DOMParser;
|
|
15
|
+
|
|
16
|
+
class StubXMLDocument {
|
|
17
|
+
constructor(values) {
|
|
18
|
+
this.values = values;
|
|
19
|
+
}
|
|
20
|
+
// undefined means the element is absent, null means it is present with no RDF:resource attribute
|
|
21
|
+
querySelector(selector) {
|
|
22
|
+
const localName = selector.split(">").pop().trim();
|
|
23
|
+
const value = this.values[localName];
|
|
24
|
+
return value === undefined ? null : { getAttributeNS: () => value };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
globalThis.DOMParser = class {
|
|
29
|
+
parseFromString(content, mimeType) {
|
|
30
|
+
if (mimeType == "text/xml") {
|
|
31
|
+
return new StubXMLDocument(XML_DOCUMENTS.get(content) || {});
|
|
32
|
+
}
|
|
33
|
+
return new NativeDOMParser().parseFromString(content, mimeType);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const { capture, frameData, html, WIN_ID_ATTRIBUTE_NAME } = await import("./common.js");
|
|
38
|
+
|
|
39
|
+
const PAGE_URL = "https://example.com/page.html";
|
|
40
|
+
const RDF_URL = "https://example.com/index.rdf";
|
|
41
|
+
const FRAME_URL = "https://example.com/frame-dir/frame.html";
|
|
42
|
+
const FRAME_RDF_URL = "https://example.com/frame-dir/index.rdf";
|
|
43
|
+
const ORIGINAL_URL = "https://original.example/real.html";
|
|
44
|
+
const ARCHIVE_TIME = "Mon, 01 Jan 2024 10:20:30 GMT";
|
|
45
|
+
const ARCHIVE_TIME_MS = new Date(ARCHIVE_TIME).getTime();
|
|
46
|
+
const COMPLETE = { originalurl: ORIGINAL_URL, archivetime: ARCHIVE_TIME };
|
|
47
|
+
const PAGE = html("<h1>page</h1>");
|
|
48
|
+
const FRAME_PAGE = html("<h1>frame</h1>");
|
|
49
|
+
const HOST_PAGE = html("<h1>host</h1><iframe src=\"" + FRAME_URL + "\" " + WIN_ID_ATTRIBUTE_NAME + "=\"0.1\"></iframe>");
|
|
50
|
+
|
|
51
|
+
// The canonical link would be the obvious place to read the recovered url, but deno-dom reflects
|
|
52
|
+
// neither the href nor the type property, so core's `element.href = ...` leaves no attribute behind.
|
|
53
|
+
// Two observables survive that: the SingleFile comment, which core builds from options.saveUrl, and
|
|
54
|
+
// the embedded options block, which is where the second defect lives.
|
|
55
|
+
const OPTIONS_BLOCK = /<script data-single-file-options[^>]*>([^<]*)<\/script>/;
|
|
56
|
+
|
|
57
|
+
let fixtureIndex = 0;
|
|
58
|
+
|
|
59
|
+
function rdf(values) {
|
|
60
|
+
const content = "<?xml version=\"1.0\"?><!-- fixture " + (fixtureIndex++) + " -->";
|
|
61
|
+
XML_DOCUMENTS.set(content, values);
|
|
62
|
+
return content;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class CountingResources extends Map {
|
|
66
|
+
constructor(entries) {
|
|
67
|
+
super(entries);
|
|
68
|
+
this.counts = new Map();
|
|
69
|
+
}
|
|
70
|
+
get(key) {
|
|
71
|
+
this.counts.set(key, (this.counts.get(key) || 0) + 1);
|
|
72
|
+
return super.get(key);
|
|
73
|
+
}
|
|
74
|
+
countOf(key) {
|
|
75
|
+
return this.counts.get(key) || 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function resources(rdfContent) {
|
|
80
|
+
const entries = [
|
|
81
|
+
[PAGE_URL, { body: PAGE }],
|
|
82
|
+
[FRAME_URL, { body: FRAME_PAGE }]
|
|
83
|
+
];
|
|
84
|
+
if (rdfContent !== undefined) {
|
|
85
|
+
entries.push([RDF_URL, { body: rdfContent, contentType: "text/xml" }]);
|
|
86
|
+
}
|
|
87
|
+
return new CountingResources(entries);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function commentURL(content) {
|
|
91
|
+
const match = content.match(/ url: ([^\n]*)/);
|
|
92
|
+
return match && match[1].trim();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function embeddedOptions(content) {
|
|
96
|
+
const match = content.match(OPTIONS_BLOCK);
|
|
97
|
+
return match && JSON.parse(match[1]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let failed = false;
|
|
101
|
+
|
|
102
|
+
// readMaffMetadata is the new name of enableMaff, which was implemented in core and set by nothing:
|
|
103
|
+
// no CLI flag, no config key, no UI anywhere. That is what made renaming it free, and exposing it is
|
|
104
|
+
// what made the two defects below reachable by a user.
|
|
105
|
+
{
|
|
106
|
+
const map = resources(rdf(COMPLETE));
|
|
107
|
+
const content = await capture(map, { url: PAGE_URL, content: PAGE, insertSingleFileComment: true });
|
|
108
|
+
check("index.rdf is not requested when the option is off", map.countOf(RDF_URL), 0);
|
|
109
|
+
check("the page url is saved when the option is off", commentURL(content), PAGE_URL);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
{
|
|
113
|
+
const map = resources(rdf(COMPLETE));
|
|
114
|
+
const content = await capture(map, { url: PAGE_URL, content: PAGE, readMaffMetadata: true, insertSingleFileComment: true });
|
|
115
|
+
check("index.rdf is requested when the option is on", map.countOf(RDF_URL), 1);
|
|
116
|
+
check("the original url is recovered", commentURL(content), ORIGINAL_URL);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// THE CRASH. An originalurl with no RDF:resource made getAttributeNS return null, saveUrl became
|
|
120
|
+
// null, and the canonical link then called .match() on it and failed the whole capture with a
|
|
121
|
+
// TypeError. The archivetime branch beside it had always guarded its own value, so the two halves of
|
|
122
|
+
// one method disagreed with each other.
|
|
123
|
+
{
|
|
124
|
+
let threw = false;
|
|
125
|
+
let content = "";
|
|
126
|
+
try {
|
|
127
|
+
content = await capture(resources(rdf({ originalurl: null, archivetime: ARCHIVE_TIME })), {
|
|
128
|
+
url: PAGE_URL,
|
|
129
|
+
content: PAGE,
|
|
130
|
+
readMaffMetadata: true,
|
|
131
|
+
insertSingleFileComment: true
|
|
132
|
+
});
|
|
133
|
+
} catch {
|
|
134
|
+
threw = true;
|
|
135
|
+
}
|
|
136
|
+
check("an originalurl with no resource attribute does not fail the capture", threw, false);
|
|
137
|
+
check("and the page url is kept", commentURL(content), PAGE_URL);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
{
|
|
141
|
+
const content = await capture(resources(rdf({ originalurl: ORIGINAL_URL, archivetime: null })), {
|
|
142
|
+
url: PAGE_URL,
|
|
143
|
+
content: PAGE,
|
|
144
|
+
readMaffMetadata: true,
|
|
145
|
+
insertSingleFileComment: true
|
|
146
|
+
});
|
|
147
|
+
check("an archivetime with no resource attribute is tolerated", commentURL(content), ORIGINAL_URL);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
{
|
|
151
|
+
const content = await capture(resources(), { url: PAGE_URL, content: PAGE, readMaffMetadata: true, insertSingleFileComment: true });
|
|
152
|
+
check("a missing index.rdf leaves the page url in place", commentURL(content), PAGE_URL);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// THE INCONSISTENCY. saveFilenameTemplateData wrote saveUrl from options.url, one line above writing
|
|
156
|
+
// saveDate from the value MAFF had just recovered, so the embedded block paired the archive's date
|
|
157
|
+
// with the extracted copy's path, and a recompute in the editor resolved {url-*} against the wrong
|
|
158
|
+
// one. options.saveUrl and options.url are identical on every other code path, which is what let it
|
|
159
|
+
// sit unnoticed.
|
|
160
|
+
{
|
|
161
|
+
const content = await capture(resources(rdf(COMPLETE)), {
|
|
162
|
+
url: PAGE_URL,
|
|
163
|
+
content: PAGE,
|
|
164
|
+
readMaffMetadata: true,
|
|
165
|
+
saveFilenameTemplateData: true
|
|
166
|
+
});
|
|
167
|
+
const embedded = embeddedOptions(content);
|
|
168
|
+
check("the embedded options block exists", Boolean(embedded), true);
|
|
169
|
+
if (embedded) {
|
|
170
|
+
check("the embedded saveUrl is the recovered one", embedded.saveUrl, ORIGINAL_URL);
|
|
171
|
+
check("the embedded saveDate is the recovered one", embedded.saveDate, ARCHIVE_TIME_MS);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
{
|
|
176
|
+
const content = await capture(resources(rdf(COMPLETE)), { url: PAGE_URL, content: PAGE, saveFilenameTemplateData: true });
|
|
177
|
+
const embedded = embeddedOptions(content);
|
|
178
|
+
check("the embedded saveUrl is the page url when the option is off", embedded && embedded.saveUrl, PAGE_URL);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Only the root document reaches Processor.initialize, because Runner.run guards that call with
|
|
182
|
+
// `if (this.root)`. That guard is the whole reason a page with twenty frames does not make twenty
|
|
183
|
+
// pointless index.rdf requests, and nothing else pins it. Note initializeProcessor resets a list of
|
|
184
|
+
// root-only options for frames and readMaffMetadata is deliberately NOT in it: next to this guard
|
|
185
|
+
// such a reset is dead code, which is exactly what adding one and watching nothing change proved.
|
|
186
|
+
{
|
|
187
|
+
const map = resources(rdf(COMPLETE));
|
|
188
|
+
const frames = [frameData("0.1", FRAME_URL, FRAME_PAGE)];
|
|
189
|
+
const content = await capture(map, { url: PAGE_URL, content: HOST_PAGE, frames, readMaffMetadata: true });
|
|
190
|
+
check("the root asks for its index.rdf", map.countOf(RDF_URL), 1);
|
|
191
|
+
check("a frame does not ask for one of its own", map.countOf(FRAME_RDF_URL), 0);
|
|
192
|
+
check("the frame is still captured", content.includes("frame"), true);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (failed) {
|
|
196
|
+
console.log("FAILED");
|
|
197
|
+
Deno.exit(1);
|
|
198
|
+
}
|
|
199
|
+
console.log("OK");
|
|
200
|
+
|
|
201
|
+
function check(label, actual, expected) {
|
|
202
|
+
const ok = actual === expected;
|
|
203
|
+
console.log(`${ok ? "PASS" : "FAIL"} ${label}: ${actual}${ok ? "" : " (expected " + expected + ")"}`);
|
|
204
|
+
failed ||= !ok;
|
|
205
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { capture, html } from "./common.js";
|
|
2
|
+
|
|
3
|
+
const PAGE_URL = "https://example.com/page.html";
|
|
4
|
+
|
|
5
|
+
// blockScripts is what removeEmbedScripts is wired to, and it is the option every save turns on to
|
|
6
|
+
// promise that the saved page holds no script. These fixtures are the ways a javascript: URL used to
|
|
7
|
+
// survive that promise.
|
|
8
|
+
const BLOCK = { blockScripts: true };
|
|
9
|
+
|
|
10
|
+
// The sanitizer used to read the resolved IDL property, element.href and element.src, and rewrite the
|
|
11
|
+
// attribute only when the property was a string starting with "javascript:". That missed every SVG
|
|
12
|
+
// link, because SVGAElement.href is an SVGAnimatedString and the guard skipped it, and it never
|
|
13
|
+
// looked at form submission targets at all. Each of these executed on one click in a saved page.
|
|
14
|
+
const VECTORS = [
|
|
15
|
+
["svg link", "<svg xmlns=\"http://www.w3.org/2000/svg\"><a id=\"target\" href=\"javascript:alert(1)\"><rect/></a></svg>"],
|
|
16
|
+
["form action", "<form action=\"javascript:alert(1)\"><input type=\"submit\"></form>"],
|
|
17
|
+
["button formaction", "<form><button formaction=\"javascript:alert(1)\">go</button></form>"],
|
|
18
|
+
["image input formaction", "<form><input type=\"image\" formaction=\"javascript:alert(1)\"></form>"],
|
|
19
|
+
["object data", "<object data=\"javascript:alert(1)\"></object>"],
|
|
20
|
+
["anchor href", "<a href=\"javascript:alert(1)\">go</a>"],
|
|
21
|
+
["iframe src", "<iframe src=\"javascript:alert(1)\"></iframe>"]
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
let failed = false;
|
|
25
|
+
|
|
26
|
+
for (const [label, body] of VECTORS) {
|
|
27
|
+
const content = await capture({}, { url: PAGE_URL, content: html(body), ...BLOCK });
|
|
28
|
+
check(`${label} is neutralized`, content.includes("javascript:alert"), false);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// The URL parser decides what a javascript: URL is, so the obfuscations it folds away have to be
|
|
32
|
+
// folded away here too: leading whitespace is stripped, a tab inside the scheme is removed, and the
|
|
33
|
+
// scheme is compared case-insensitively.
|
|
34
|
+
const OBFUSCATIONS = [
|
|
35
|
+
["leading whitespace and mixed case", " \tJaVaScRiPt:alert(1)"],
|
|
36
|
+
["tab inside the scheme", "ja	vascript:alert(1)"],
|
|
37
|
+
["newline before the scheme", " javascript:alert(1)"],
|
|
38
|
+
["uppercase scheme", "JAVASCRIPT:alert(1)"]
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
for (const [label, value] of OBFUSCATIONS) {
|
|
42
|
+
const content = await capture({}, { url: PAGE_URL, content: html(`<a href="${value}">go</a>`), ...BLOCK });
|
|
43
|
+
check(`${label} is neutralized`, content.includes("alert(1)"), false);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The control. A space inside the scheme is not a javascript: URL, and neither is a relative path, so
|
|
47
|
+
// a sanitizer that rewrote either would be matching on text rather than on what the URL parser says.
|
|
48
|
+
// Neither href survives as written, because resolveHrefs makes both absolute afterwards; what the
|
|
49
|
+
// control asserts is that the sanitizer did not claim them.
|
|
50
|
+
{
|
|
51
|
+
const content = await capture({}, { url: PAGE_URL, content: html("<a href=\"java script:alert(1)\">go</a><a href=\"page.html\">go</a>"), ...BLOCK });
|
|
52
|
+
check("a space inside the scheme is not treated as a script URI", content.includes("javascript:void(0)"), false);
|
|
53
|
+
check("a relative href is not treated as a script URI", content.includes("page.html"), true);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// The other half of removeEmbedScripts, kept here so that a rewrite of the attribute walk cannot drop
|
|
57
|
+
// it silently. Only the script elements can be checked from here: the event handler attribute names
|
|
58
|
+
// come from enumerating the on* IDL properties of an element, and deno-dom implements none of them,
|
|
59
|
+
// so the set is empty in this harness and a handler fixture would pass whatever the code did. The
|
|
60
|
+
// browser suite in single-file-cli covers the handlers.
|
|
61
|
+
{
|
|
62
|
+
const scripts = await capture({}, { url: PAGE_URL, content: html("<script>alert(1)</script><svg xmlns=\"http://www.w3.org/2000/svg\"><script>alert(2)</script></svg>"), ...BLOCK });
|
|
63
|
+
check("html and svg script elements are removed", scripts.includes("alert("), false);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The option still has to be an option: with blockScripts off none of this is rewritten.
|
|
67
|
+
{
|
|
68
|
+
const content = await capture({}, { url: PAGE_URL, content: html("<a href=\"javascript:alert(1)\">go</a>") });
|
|
69
|
+
check("nothing is rewritten with blockScripts off", content.includes("javascript:alert(1)"), true);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (failed) {
|
|
73
|
+
console.log("FAILED");
|
|
74
|
+
Deno.exit(1);
|
|
75
|
+
}
|
|
76
|
+
console.log("OK");
|
|
77
|
+
|
|
78
|
+
function check(label, actual, expected) {
|
|
79
|
+
const ok = actual === expected;
|
|
80
|
+
console.log(`${ok ? "PASS" : "FAIL"} ${label}: ${actual}${ok ? "" : " (expected " + expected + ")"}`);
|
|
81
|
+
failed ||= !ok;
|
|
82
|
+
}
|
|
@@ -249,8 +249,8 @@ async function makePage(seed, { url, title, originalUrls }) {
|
|
|
249
249
|
|
|
250
250
|
// a page archive holding, on purpose, nothing the packager's own writer would produce by default:
|
|
251
251
|
// a directory record, a name that needs the language encoding flag, a stored entry beside one
|
|
252
|
-
// deflated at the highest level, unix ownership,
|
|
253
|
-
// dates outside the one the packager pins on its writer
|
|
252
|
+
// deflated at the highest level, unix ownership, a non-default version-made-by spec byte, an
|
|
253
|
+
// extra field zip.js does not interpret, and dates outside the one the packager pins on its writer
|
|
254
254
|
async function makeMetadataPage() {
|
|
255
255
|
const zipWriter = new ZipWriter(new Uint8ArrayWriter(), { lastModDate: SOURCE_DATE });
|
|
256
256
|
await zipWriter.add("folder/", null, { directory: true, comment: "a folder" });
|
|
@@ -261,6 +261,9 @@ async function makeMetadataPage() {
|
|
|
261
261
|
lastAccessDate: SOURCE_DATE,
|
|
262
262
|
internalFileAttributes: 1,
|
|
263
263
|
msDosCompatible: false,
|
|
264
|
+
// only the high byte is rewritten to host Unix, so the 0x32 spec byte survives and the
|
|
265
|
+
// copied value differs from the 0x0300 both writers land on by default
|
|
266
|
+
versionMadeBy: 0x0332,
|
|
264
267
|
unixMode: 0o100755,
|
|
265
268
|
uid: 501,
|
|
266
269
|
gid: 20,
|
package/vendor/zip/z-worker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";const{Array:t,Object:e,Number:n,Math:r,Error:s,Uint8Array:o,Uint16Array:c,Uint32Array:a,Int32Array:i,Map:u,DataView:f,Promise:l,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,k="undefined",z="function",C=new o,b=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;b[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=b[e-1][t];b[e][t]=n>>>8^b[0][255&n]}const[I,A,x,P,M,B,D,F]=b;class R{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let r=0;if(n>=8&&t.buffer){const s=new f(t.buffer,t.byteOffset,n),o=n-8;for(;o>=r;r+=8){const t=e^s.getInt32(r,!0),n=s.getInt32(r+4,!0);e=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^M[t>>>24&255]^P[255&n]^x[n>>>8&255]^A[n>>>16&255]^I[n>>>24&255]}}for(;n>r;r++)e=e>>>8^I[255&(e^t[r])];this.o=e}get(){return~this.o}}class V extends d{constructor(){let t;const e=new R;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new f(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function _(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function T(t){return new f(t.buffer,t.byteOffset,t.byteLength)}const U={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],r=U.l(n);return 32===r?t.concat(e):U.h(e,r,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+U.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,r.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=U.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>r.round(t/1099511627776)||32,h(t,e,n,r){for(void 0===r&&(r=[]);e>=32;e-=32)r.push(n),n=0;if(0===e)return r.concat(t);for(let s=0;s<t.length;s++)r.push(n|t[s]>>>e),n=t[s]<<32-e;const s=t.length?t[t.length-1]:0,o=U.l(s);return r.push(U.S(e+o&31,e+o>32?n:r.pop(),1)),r}},K={bytes:{v(t){const e=U.bitLength(t)/8,n=new o(e);let r;for(let s=0;e>s;s++)3&s||(r=t[s/4]),n[s]=r>>>24,r<<=8;return n},C(t){const e=[];let n,r=0;for(n=0;n<t.length;n++)r=r<<8|t[n],3&~n||(e.push(r),r=0);return 3&n&&e.push(U.S(8*(3&n),r)),e}}},j=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.A=[1518500249,1859775393,2400959708,3395469782],t?(e.P=t.P.slice(0),e.M=t.M.slice(0),e.B=t.B):e.reset()}reset(){const t=this;return t.P=t.I.slice(0),t.M=[],t.B=0,t}update(t){const e=this;"string"==typeof t&&(t=K.D.C(t));const n=e.M=U.concat(e.M,t),r=e.B,o=e.B=r+U.bitLength(t);if(o>9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const c=new a(n);let i=0;for(let t=e.blockSize+r-(e.blockSize+r&e.blockSize-1);o>=t;t+=e.blockSize)e.F(c.subarray(16*i,16*(i+1))),i+=1;return n.splice(0,16*i),e}R(){const t=this;let e=t.M;const n=t.P;e=U.concat(e,[U.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(r.floor(t.B/4294967296)),e.push(0|t.B);e.length;)t.F(e.splice(0,16));return t.reset(),n}V(t,e,n,r){return t>19?t>39?t>59?t>79?void 0:e^n^r:e&n|e&r|n&r:e^n^r:e&n|~e&r}_(t,e){return e<<t|e>>>32-t}F(e){const n=this,s=n.P,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=s[0],a=s[1],i=s[2],u=s[3],f=s[4];for(let t=0;79>=t;t++){16>t||(o[t]=n._(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n._(5,c)+n.V(t,a,i,u)+f+o[t]+n.A[r.floor(t/20)]|0;f=u,u=i,i=n._(30,a),a=c,c=e}s[0]=s[0]+c|0,s[1]=s[1]+a|0,s[2]=s[2]+i|0,s[3]=s[3]+u|0,s[4]=s[4]+f|0}},E={importKey:t=>new E.T(K.bytes.C(t)),U(t,e,n,r){if(n=n||1e4,0>r||0>n)throw new s("invalid params to pbkdf2");const o=1+(r>>5)<<2;let c,a,i,u,l;const w=new ArrayBuffer(o),h=new f(w);let p=0;const d=U;for(e=K.bytes.C(e),l=1;(o||1)>p;l++){for(c=a=t.encrypt(d.concat(e,[l])),i=1;n>i;i++)for(a=t.encrypt(a),u=0;u<a.length;u++)c[u]^=a[u];for(i=0;(o||1)>p&&i<c.length;i++)h.setInt32(p,c[i]),p+=4}return w.slice(0,r/8)},T:class{constructor(t){const e=this,n=e.K=j,r=[[],[]];e.j=[new n,new n];const s=e.j[0].blockSize/32;t.length>s&&(t=(new n).update(t).R());for(let e=0;s>e;e++)r[0][e]=909522486^t[e],r[1][e]=1549556828^t[e];e.j[0].update(r[0]),e.j[1].update(r[1]),e.O=new n(e.j[0])}reset(){const t=this;t.O=new t.K(t.j[0]),t.W=!1}update(t){this.W=!0,this.O.update(t)}digest(){const t=this,e=t.O.R(),n=new t.K(t.j[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.W)throw new s("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},O=typeof h!=k&&typeof h.getRandomValues==z,W="Invalid password",H="zipjs-abort-check-password";function L(t){if(O)return h.getRandomValues(t);throw new s("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=e.assign({hash:{name:"HMAC"}},q),J=e.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],Z=10,$=[0,0,0,0],tt=typeof h!=k,et=tt&&h.subtle,nt=tt&&typeof et!=k,rt=K.bytes,st=class{constructor(t){const e=this;e.H=[[[],[],[],[],[]],[[],[],[],[],[]]],e.H[0][0][0]||e.L();const n=e.H[0][4],r=e.H[1],o=t.length;let c,a,i,u=1;if(4!==o&&6!==o&&8!==o)throw new s("invalid aes key size");for(e.A=[a=t.slice(0),i=[]],c=o;4*o+28>c;c++){let t=a[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^u<<24,u=u<<1^283*(u>>7))),a[c]=a[c-o]^t}for(let t=0;c;t++,c--){const e=a[3&t?c:c-4];i[t]=4>=c||4>t?e:r[0][n[e>>>24]]^r[1][n[e>>16&255]]^r[2][n[e>>8&255]]^r[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}L(){const t=this.H[0],e=this.H[1],n=t[4],r=e[4],s=[],o=[];let c,a,i,u;for(let t=0;256>t;t++)o[(s[t]=t<<1^283*(t>>7))^t]=t;for(let f=c=0;!n[f];f^=a||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[f]=o,r[o]=f,u=s[i=s[a=s[f]]];let l=16843009*u^65537*i^257*a^16843008*f,w=257*s[o]^16843008*o;for(let n=0;4>n;n++)t[n][f]=w=w<<24^w>>>8,e[n][o]=l=l<<24^l>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new s("invalid aes block size");const n=this.A[e],r=n.length/4-2,o=[0,0,0,0],c=this.H[e],a=c[0],i=c[1],u=c[2],f=c[3],l=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;r>t;t++)w=a[d>>>24]^i[y>>16&255]^u[m>>8&255]^f[255&S]^n[g],h=a[y>>>24]^i[m>>16&255]^u[S>>8&255]^f[255&d]^n[g+1],p=a[m>>>24]^i[S>>16&255]^u[d>>8&255]^f[255&y]^n[g+2],S=a[S>>>24]^i[d>>16&255]^u[y>>8&255]^f[255&m]^n[g+3],g+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&S]^n[g++],w=d,d=y,y=m,m=S,S=w;return o}},ot=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let r;if(!(r=e.length))return[];const s=U.bitLength(e);for(let s=0;r>s;s+=4){this.$(n);const r=t.encrypt(n);e[s]^=r[0],e[s+1]^=r[1],e[s+2]^=r[2],e[s+3]^=r[3]}return U.m(e,s)}},ct=E.T;let at=tt&&nt&&typeof et.importKey==z,it=tt&&nt&&typeof et.deriveBits==z;class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:r,checkAuthenticationCode:c=!0}){super({start(){lt(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:a,et:i,ready:u}=n;c?(await(async(t,e,n,r)=>{const o=await ht(t,e,n,dt(r,0,X[e])),c=dt(r,X[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new s(W)})(n,a,c,dt(t,0,X[a]+2)),t=dt(t,X[a]+2),r?e.error(new s(H)):i()):await u;const f=new o(t.length-Z-(t.length-Z)%N);e.enqueue(wt(n,t,f,0,Z,!0))},async flush(t){const{nt:e,st:n,ot:r,ready:o}=this;if(n&&e){await o;const a=dt(r,0,r.length-Z),i=dt(r,r.length-Z);let u=C;if(a.length){const t=mt(rt,a);n.update(t);const r=e.update(t);u=yt(rt,r)}const f=dt(yt(rt,n.digest()),0,Z);let l=r.length<Z?1:0;for(let t=0;Z>t;t++)l|=f[t]^i[t];if(l&&c)throw new s("Invalid authentication code");t.enqueue(u)}}})}}class ft extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){lt(this,t,e,n)},async transform(t,e){const n=this,{password:r,strength:s,et:c,ready:a}=n;let i=C;r?(i=await(async(t,e,n)=>{const r=L(new o(X[e]));return _(r,await ht(t,e,n,r))})(n,s,r),c()):await a;const u=new o(i.length+t.length-t.length%N);u.set(i,0),e.enqueue(wt(n,t,u,i.length,0))},async flush(t){const{nt:e,st:n,ot:r,ready:s}=this;if(n&&e){await s;let o=C;if(r.length){const t=e.update(mt(rt,r));n.update(t),o=yt(rt,t)}const c=yt(rt,n.digest()).slice(0,Z);t.enqueue(_(o,c))}}})}}function lt(t,n,r,s){e.assign(t,{ready:new l(e=>t.et=e),password:pt(n,r),strength:s-1,ot:C})}function wt(t,e,n,r,s,c){const{nt:a,st:i,ot:u}=t;u.length&&(e=_(u,e));const f=e.length-s;let l;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,r+(f-f%N)),l=0;f-N>=l;l+=N){const t=mt(rt,dt(e,l,l+N));c&&i.update(t);const s=a.update(t);c||i.update(s),n.set(yt(rt,s),l+r)}return t.ot=dt(e,l),n}async function ht(n,r,s,c){n.password=null;const a=await(async(t,e,n,r,s)=>{if(!at)return E.importKey(e);try{return await et.importKey("raw",e,n,!1,s)}catch{return at=!1,E.importKey(e)}})(0,s,G,0,Q),i=await(async(t,e,n)=>{if(!it)return E.U(e,t.salt,J.iterations,n);try{return await et.deriveBits(t,e,n)}catch{return it=!1,E.U(e,t.salt,J.iterations,n)}})(e.assign({salt:c},J),a,8*(2*Y[r]+2)),u=new o(i),f=mt(rt,dt(u,0,Y[r])),l=mt(rt,dt(u,Y[r],2*Y[r])),w=dt(u,2*Y[r]);return e.assign(n,{keys:{key:f,ct:l,passwordVerification:w},nt:new ot(new st(f),t.from($)),st:new ct(l)}),w}function pt(t,e){return e===v?(t=>{if(typeof w==k){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function dt(t,e,n){return t.subarray(e,n)}function yt(t,e){return t.v(e)}function mt(t,e){return t.C(e)}class St extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:r}){super({start(){vt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=kt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new s(W);t=t.subarray(12)}r?e.error(new s(H)):e.enqueue(kt(n,t))}})}}class gt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){vt(this,t,e,n)},transform(t,e){const n=this;let r,s;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=L(new o(12));e[11]=n.passwordVerification,r=new o(t.length+e.length),r.set(zt(n,e),0),s=12}else r=new o(t.length),s=0;r.set(zt(n,t),s),e.enqueue(r)}})}}function vt(t,n,r,s){e.assign(t,{password:n,rawPassword:r,passwordVerification:s}),((t,n,r)=>{const s=[305419896,591751049,878082192];if(e.assign(t,{keys:s,it:new R(s[0]),ut:new R(s[2])}),r)for(let e=0;e<r.length;e++)Ct(t,r[e]);else for(let e=0;e<n.length;e++)Ct(t,n.charCodeAt(e))})(t,n,r)}function kt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=bt(t)^e[r],Ct(t,n[r]);return n}function zt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=bt(t)^e[r],Ct(t,e[r]);return n}function Ct(t,e){let[,n]=t.keys;t.it.append([e]);const s=~t.it.get();n=At(r.imul(At(n+It(s)),134775813)+1),t.ut.append([n>>>24]);const o=~t.ut.get();t.keys=[s,n,o]}function bt(t){const e=2|t.keys[2];return It(r.imul(e,1^e)>>>8)}function It(t){return 255&t}function At(t){return 4294967295&t}function xt(t){if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:r}=await e.read();r?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})}const Pt=new u;function Mt(t){return Pt.get(t)}const Bt="Invalid uncompressed size",Dt="deflate-raw",Ft="gzip",Rt=[31,139,8];class Vt extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:r}){super({});const{compressed:s,encrypted:o,useCompressionStream:c,zipCrypto:a,computeCrc32:i,level:u,deflate64:l,format:w,compressionMethod:h,inputSize:p}=t,d=this;let y,m,S,g=super.readable;const v=w&&Mt(w),k=i&&s&&!l&&!v&&(!o||a)&&!(!c||!r);if(o&&!a||!i||k||(y=new V,g=Ot(g,y)),s)if(v)g=Wt(g,jt(v.CompressionStream,w,{level:u,chunkSize:e,compressionMethod:h,uncompressedSize:p}));else if(k)S=new _t,g=Wt(g,new r(Ft)),g=Ot(g,S);else try{g=Et(g,c,{level:u,chunkSize:e},r,n)}catch(t){let e;try{e=new r(Ft)}catch{throw t}g=Wt(g,e),g=Ot(g,new _t)}o&&(a?g=Ot(g,new gt(t)):(m=new ft(t),g=Ot(g,m))),Kt(d,g,()=>{o&&!a||!i||(d.crc32=k?S.crc32:new f(y.value.buffer).getUint32(0))})}}class _t extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,s){if(e){const n=r.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=_(n,t));const c=o-8,a=r.min(c,n.length);s.enqueue(_(n.subarray(0,a),t.subarray(0,c-a))),n=_(n.subarray(a),t.subarray(c-a))},flush(){const e=T(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Tt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:r}){super({});const{zipCrypto:c,encrypted:a,checkCrc32:i,crc32:u,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:k}=t;let z,C,b=super.readable;if(a&&(c?b=Ot(b,new St(t)):(C=new ut(t),b=Ot(b,C))),w){const t=m&&Mt(m);if(t)b=Wt(b,jt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:k}));else try{b=Et(b,h,{chunkSize:e,deflate64:p},r,n)}catch(t){if(p||k===v)throw t;let e;try{e=new r(Ft)}catch{throw t}b=((t,e,n)=>{const r=new R;let c,a,i,u=0,f=!1;const w=new l((t,e)=>{a=t,i=e});w.catch(()=>{}),n||a();const h=new d({start(t){const e=new o(10);e.set(Rt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){f=!0,y();try{await w}finally{m()}const e=new o(8),s=T(e);s.setUint32(0,r.get(),!0),s.setUint32(4,n,!0),t.enqueue(e)},cancel(t){i(t)}}),p=new d({transform(t,e){r.append(t),u+=t.length,n>u?f&&y():a(),e.enqueue(t)},cancel(t){i(t)}});return t=Ot(t,h),Ot(t=Wt(t,e),p);function y(){m(),c=setTimeout(()=>i(new s(Bt)),5e3)}function m(){clearTimeout(c)}})(b,e,k)}b=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new s("Invalid compressed data");throw e.cause=t,e}const{value:r,done:o}=n;o?t.close():t.enqueue(r)},cancel:t=>e.cancel(t)})})(b)}i&&(z=new V,b=Ot(b,z)),Kt(this,b,()=>{if(i){const t=new f(z.value.buffer);if(u!=t.getUint32(0,!1))throw new s("Invalid CRC32")}})}}const Ut=new u;function Kt(t,n,r){n=Ot(n,new d({flush:r})),e.defineProperty(t,"readable",{get:()=>n})}function jt(t,e,n){if(!t)throw new s("Compression method not supported");return new t(e,n)}function Et(t,e,n,r,s){const o=e&&r?r:s||r,c=n.deflate64?"deflate64-raw":Dt;let a;try{a=new o(c,n)}catch(t){if(!e||!s||o==s)throw t;a=new s(c,n)}return Wt(t,a)}function Ot(t,e){return xt(t).pipeThrough(e)}function Wt(t,e){const n=e.writable.getWriter(),r=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await r.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(r,t)}})(),e.readable}const Ht="data",Lt="close",Nt="deflate";class qt extends d{constructor(t,n){super({});const r=this,{codecType:o}=t;let c;o.startsWith(Nt)?c=Vt:o.startsWith("inflate")&&(c=Tt),r.outputSize=0;let a=0;const i=new c(t,n),u=super.readable,f=new d({transform(t,e){t&&t.length&&(a+=t.length,e.enqueue(t))},flush(){e.assign(r,{inputSize:a})}}),l=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),r.outputSize+=e.length,t.outputSize!==v&&r.outputSize>t.outputSize))throw new s(Bt)},flush(){const{crc32:t}=i;e.assign(r,{crc32:t,inputSize:a})}});e.defineProperty(r,"readable",{get:()=>u.pipeThrough(f).pipeThrough(i).pipeThrough(l)})}}class Gt extends d{constructor(t){const r=[];let s=0,c=0;function a(){const e=new o(t);let n=0;for(;t>n;){const s=r[0],o=t-n;s.length>o?(e.set(s.subarray(0,o),n),r[0]=s.subarray(o),n+=o):(e.set(s,n),n+=s.length,r.shift())}return s-=t,e}n.isFinite(t)&&t>=1||(t=65536),super({transform(e,n){for(r.push(e),s+=e.length;s>t;)c+=t,n.enqueue(a())},flush(t){s&&(c+=s,t.enqueue(((t,e)=>{const n=new o(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n})(r,s)))}}),e.defineProperty(this,"outputSize",{get:()=>c})}}let Jt=2;try{typeof navigator!=k&&navigator.hardwareConcurrency&&(Jt=navigator.hardwareConcurrency)}catch{}function Qt(t){return!!t&&"object"==typeof t}const Xt=new u,Yt=new u,Zt=(()=>{try{return structuredClone(new s)instanceof s}catch{return!1}})();let $t,te=0;async function ee(t){let e,o,c;try{const{options:a,config:i}=t;if(a.format)try{await(async(t,e)=>{!Pt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:r}=e;if(typeof n!=z&&typeof r!=z)throw new s("Invalid codec module");Pt.set(t,{CompressionStream:n,DecompressionStream:r})})(t,await(import(e)))})(a.format,a.codecURI)}catch(t){if(Qt(t))try{t.codecImportFailed=!0}catch{}throw t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,a.compressed&&!a.format)if(a.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Ut.get(t);n||(n=new u,Ut.set(t,n));let r=n.get(e);if(r===v){try{new t(e),r=!0}catch{r=!1}n.set(e,r)}return r})(a.codecType.startsWith(Nt)?i.CompressionStream:i.DecompressionStream,Dt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{a.useCompressionStream=!0}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const f={highWaterMark:1},w=t.readable?xt(t.readable):new y({async pull(t){const e=new l(t=>Xt.set(te,t));ne({type:"pull",messageId:te}),te=(te+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await e;t.enqueue(r),s&&t.close()}},f);c=t.writable?(t=>{if(t instanceof m)return t;const e=t.getWriter();return new m({write:t=>e.write(t),close:()=>e.close(),abort:t=>e.abort(t)})})(t.writable):new m({async write(t){let e;const r=new l(t=>e=t);Yt.set(te,e),ne({type:Ht,value:t,messageId:te}),te=(te+1)%n.MAX_SAFE_INTEGER,await r}},f),e=new qt(a,i),o=new Gt((t=>{return s="string"==typeof(e=s=t.chunkSize)&&e.trim()?n(e):e,n.isInteger(s)&&s>=1?r.max(s,64):65536;var e,s})(i)),$t=new AbortController;const{signal:h}=$t;await w.pipeThrough(e).pipeThrough(o).pipeTo(c,{signal:h,preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{crc32:p,inputSize:d,outputSize:S}=e;ne({type:Lt,result:{crc32:p,inputSize:d,outputSize:S}})}catch(t){const e=o?o.outputSize:0;if(Qt(t))try{t.outputSize=e}catch{}if(c&&!c.locked)try{await c.getWriter().close()}catch{}re(t,e)}}function ne(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function re(t,e){const{message:n,stack:r,code:o,name:c,outputSize:a,cause:i,codecImportFailed:u}=((t=new s("Unknown error"))=>Qt(t)?t:new s(t+""))(t),f={message:n,stack:r,code:o,name:c,outputSize:a===v?e:a};if(i&&(f.cause={name:i.name,message:i.message}),u&&(f.codecImportFailed=!0),Zt)try{return void p({error:f,errorValue:{value:t}})}catch{}p({error:f})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:r,done:s}=t;try{if("start"==e&&ee(t),e==Ht){const t=Xt.get(n);Xt.delete(n),t({value:r||new o,done:s})}if("ack"==e){const t=Yt.get(n);Yt.delete(n),t()}e==Lt&&$t.abort()}catch(t){re(t)}}),p({type:"ready"}),((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),r&&(t.DecompressionStreamFallback=r)}})()}();
|
|
1
|
+
!function(){"use strict";const{Array:t,Object:e,Number:n,Math:r,Error:s,Uint8Array:o,Uint16Array:c,Uint32Array:a,Int32Array:i,Map:w,DataView:u,Promise:f,TextEncoder:l,crypto:p,postMessage:d,TransformStream:h,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,z="undefined",k="function",C=new o,I=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;I[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=I[e-1][t];I[e][t]=n>>>8^I[0][255&n]}const[b,x,A,P,M,D,F,E]=I;class R{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let r=0;if(n>=8&&t.buffer){const s=new u(t.buffer,t.byteOffset,n),o=n-8;for(;o>=r;r+=8){const t=e^s.getInt32(r,!0),n=s.getInt32(r+4,!0);e=E[255&t]^F[t>>>8&255]^D[t>>>16&255]^M[t>>>24&255]^P[255&n]^A[n>>>8&255]^x[n>>>16&255]^b[n>>>24&255]}}for(;n>r;r++)e=e>>>8^b[255&(e^t[r])];this.o=e}get(){return~this.o}}class T extends h{constructor(){let t;const e=new R;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new u(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function U(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function V(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const B=64,j=20,K=new o([128]),O=new o(1),H=new i([1732584193,4023233417,2562383102,271733878,3285377520]),W=new o(256),L=new i(256),N=new i(256),q=new i(256),G=new i(256);let J=!1;function Q(t,e){(()=>{if(!J){let t=1,e=1;do{t=255&(t^t<<1^(128&t?27:0)),e=255&(e^e<<1),e=255&(e^e<<2),e=255&(e^e<<4),128&e&&(e^=9),W[t]=255&(e^(e<<1|e>>7)^(e<<2|e>>6)^(e<<3|e>>5)^(e<<4|e>>4)^99)}while(1!=t);W[0]=99;for(let t=0;256>t;t++){const e=W[t],n=$(e),r=n<<24|e<<16|e<<8|n^e;L[t]=r,N[t]=r>>>8|r<<24,q[t]=r>>>16|r<<16,G[t]=r>>>24|r<<8}J=!0}})();const n=new i(60),r=((t,e)=>{const n=t.length>>2,r=n+6,s=4*(r+1);let o=1;for(let r=0;n>r;r++)e[r]=t[4*r]<<24|t[4*r+1]<<16|t[4*r+2]<<8|t[4*r+3];for(let t=n;s>t;t++){let r=e[t-1];t%n==0?(r=Y(r<<8|r>>>24)^o<<24,o=$(o)):n>6&&t%n==4&&(r=Y(r)),e[t]=e[t-n]^r}return r})(t,n),s=new i(4),o=X(e);let c=0,a=0,w=0,f=0;return{process(t,e){e&&o.update(t,0,t.length),(t=>{const e=new u(t.buffer,t.byteOffset,t.byteLength),n=t.length;let r=0;for(;n>=r+16;r+=16)l(),e.setInt32(r,e.getInt32(r)^s[0]),e.setInt32(r+4,e.getInt32(r+4)^s[1]),e.setInt32(r+8,e.getInt32(r+8)^s[2]),e.setInt32(r+12,e.getInt32(r+12)^s[3]);if(n>r){l();for(let e=0;n>r;r++,e++)t[r]^=s[e>>2]>>>24-8*(3&e)}})(t),e||o.update(t,0,t.length)},digest:()=>o.digest()};function l(){c=c+1|0,c||(a=a+1|0,a||(w=w+1|0,w||(f=f+1|0)));let t=Z(c)^n[0],e=Z(a)^n[1],o=Z(w)^n[2],i=Z(f)^n[3],u=L[t>>>24]^N[e>>>16&255]^q[o>>>8&255]^G[255&i]^n[4],l=L[e>>>24]^N[o>>>16&255]^q[i>>>8&255]^G[255&t]^n[5],p=L[o>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&e]^n[6],d=L[i>>>24]^N[t>>>16&255]^q[e>>>8&255]^G[255&o]^n[7];t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^n[8],e=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^n[9],o=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^n[10],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^n[11],u=L[t>>>24]^N[e>>>16&255]^q[o>>>8&255]^G[255&i]^n[12],l=L[e>>>24]^N[o>>>16&255]^q[i>>>8&255]^G[255&t]^n[13],p=L[o>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&e]^n[14],d=L[i>>>24]^N[t>>>16&255]^q[e>>>8&255]^G[255&o]^n[15],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^n[16],e=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^n[17],o=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^n[18],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^n[19],u=L[t>>>24]^N[e>>>16&255]^q[o>>>8&255]^G[255&i]^n[20],l=L[e>>>24]^N[o>>>16&255]^q[i>>>8&255]^G[255&t]^n[21],p=L[o>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&e]^n[22],d=L[i>>>24]^N[t>>>16&255]^q[e>>>8&255]^G[255&o]^n[23],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^n[24],e=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^n[25],o=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^n[26],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^n[27],u=L[t>>>24]^N[e>>>16&255]^q[o>>>8&255]^G[255&i]^n[28],l=L[e>>>24]^N[o>>>16&255]^q[i>>>8&255]^G[255&t]^n[29],p=L[o>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&e]^n[30],d=L[i>>>24]^N[t>>>16&255]^q[e>>>8&255]^G[255&o]^n[31],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^n[32],e=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^n[33],o=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^n[34],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^n[35],u=L[t>>>24]^N[e>>>16&255]^q[o>>>8&255]^G[255&i]^n[36],l=L[e>>>24]^N[o>>>16&255]^q[i>>>8&255]^G[255&t]^n[37],p=L[o>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&e]^n[38],d=L[i>>>24]^N[t>>>16&255]^q[e>>>8&255]^G[255&o]^n[39];let h=40;r>10&&(t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^n[40],e=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^n[41],o=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^n[42],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^n[43],u=L[t>>>24]^N[e>>>16&255]^q[o>>>8&255]^G[255&i]^n[44],l=L[e>>>24]^N[o>>>16&255]^q[i>>>8&255]^G[255&t]^n[45],p=L[o>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&e]^n[46],d=L[i>>>24]^N[t>>>16&255]^q[e>>>8&255]^G[255&o]^n[47],h=48),r>12&&(t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^n[48],e=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^n[49],o=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^n[50],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^n[51],u=L[t>>>24]^N[e>>>16&255]^q[o>>>8&255]^G[255&i]^n[52],l=L[e>>>24]^N[o>>>16&255]^q[i>>>8&255]^G[255&t]^n[53],p=L[o>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&e]^n[54],d=L[i>>>24]^N[t>>>16&255]^q[e>>>8&255]^G[255&o]^n[55],h=56),s[0]=(W[u>>>24]<<24|W[l>>>16&255]<<16|W[p>>>8&255]<<8|W[255&d])^n[h],s[1]=(W[l>>>24]<<24|W[p>>>16&255]<<16|W[d>>>8&255]<<8|W[255&u])^n[h+1],s[2]=(W[p>>>24]<<24|W[d>>>16&255]<<16|W[u>>>8&255]<<8|W[255&l])^n[h+2],s[3]=(W[d>>>24]<<24|W[u>>>16&255]<<16|W[l>>>8&255]<<8|W[255&p])^n[h+3]}}function X(t){const e=(()=>{const t=new i(H),e=new i(16),n=new o(B),s=new u(n.buffer),c=new o(8);let a=0,w=0;return{update:f,digest:()=>{const e=8*w,n=r.floor(e/4294967296),s=e>>>0;for(f(K,0,1);56!=a;)f(O,0,1);c[0]=n>>>24,c[1]=n>>>16,c[2]=n>>>8,c[3]=n,c[4]=s>>>24,c[5]=s>>>16,c[6]=s>>>8,c[7]=s,f(c,0,8);const i=new o(j),l=new u(i.buffer);for(let e=0;e<t.length;e++)l.setInt32(4*e,t[e]);return t.set(H),a=0,w=0,i}};function f(t,e,r){const o=e+r;if(w+=r,a){for(;o>e&&B>a;)n[a++]=t[e++];a==B&&(l(s,0),a=0)}if(o>=e+B){const n=new u(t.buffer,t.byteOffset,t.byteLength);for(;o>=e+B;e+=B)l(n,e)}for(;o>e;)n[a++]=t[e++]}function l(n,r){for(let t=0;16>t;t++)e[t]=n.getInt32(r+4*t);let s,o=t[0],c=t[1],a=t[2],i=t[3],w=t[4];for(let t=0;15>t;t+=5)w=(o<<5|o>>>27)+((a^i)&c^i)+w+1518500249+e[t]|0,c=c<<30|c>>>2,i=(w<<5|w>>>27)+((c^a)&o^a)+i+1518500249+e[t+1]|0,o=o<<30|o>>>2,a=(i<<5|i>>>27)+((o^c)&w^c)+a+1518500249+e[t+2]|0,w=w<<30|w>>>2,c=(a<<5|a>>>27)+((w^o)&i^o)+c+1518500249+e[t+3]|0,i=i<<30|i>>>2,o=(c<<5|c>>>27)+((i^w)&a^w)+o+1518500249+e[t+4]|0,a=a<<30|a>>>2;w=(o<<5|o>>>27)+((a^i)&c^i)+w+1518500249+e[15]|0,c=c<<30|c>>>2,s=e[13]^e[8]^e[2]^e[0],s=s<<1|s>>>31,e[0]=s,i=(w<<5|w>>>27)+((c^a)&o^a)+i+1518500249+s|0,o=o<<30|o>>>2,s=e[14]^e[9]^e[3]^e[1],s=s<<1|s>>>31,e[1]=s,a=(i<<5|i>>>27)+((o^c)&w^c)+a+1518500249+s|0,w=w<<30|w>>>2,s=e[15]^e[10]^e[4]^e[2],s=s<<1|s>>>31,e[2]=s,c=(a<<5|a>>>27)+((w^o)&i^o)+c+1518500249+s|0,i=i<<30|i>>>2,s=e[0]^e[11]^e[5]^e[3],s=s<<1|s>>>31,e[3]=s,o=(c<<5|c>>>27)+((i^w)&a^w)+o+1518500249+s|0,a=a<<30|a>>>2;for(let t=20;40>t;t+=5)s=e[t-3&15]^e[t-8&15]^e[t-14&15]^e[15&t],s=s<<1|s>>>31,e[15&t]=s,w=(o<<5|o>>>27)+(c^a^i)+w+1859775393+s|0,c=c<<30|c>>>2,s=e[t-2&15]^e[t-7&15]^e[t-13&15]^e[t+1&15],s=s<<1|s>>>31,e[t+1&15]=s,i=(w<<5|w>>>27)+(o^c^a)+i+1859775393+s|0,o=o<<30|o>>>2,s=e[t-1&15]^e[t-6&15]^e[t-12&15]^e[t+2&15],s=s<<1|s>>>31,e[t+2&15]=s,a=(i<<5|i>>>27)+(w^o^c)+a+1859775393+s|0,w=w<<30|w>>>2,s=e[15&t]^e[t-5&15]^e[t-11&15]^e[t+3&15],s=s<<1|s>>>31,e[t+3&15]=s,c=(a<<5|a>>>27)+(i^w^o)+c+1859775393+s|0,i=i<<30|i>>>2,s=e[t+1&15]^e[t-4&15]^e[t-10&15]^e[t+4&15],s=s<<1|s>>>31,e[t+4&15]=s,o=(c<<5|c>>>27)+(a^i^w)+o+1859775393+s|0,a=a<<30|a>>>2;for(let t=40;60>t;t+=5)s=e[t-3&15]^e[t-8&15]^e[t-14&15]^e[15&t],s=s<<1|s>>>31,e[15&t]=s,w=(o<<5|o>>>27)+(c&a|(c|a)&i)+w+2400959708+s|0,c=c<<30|c>>>2,s=e[t-2&15]^e[t-7&15]^e[t-13&15]^e[t+1&15],s=s<<1|s>>>31,e[t+1&15]=s,i=(w<<5|w>>>27)+(o&c|(o|c)&a)+i+2400959708+s|0,o=o<<30|o>>>2,s=e[t-1&15]^e[t-6&15]^e[t-12&15]^e[t+2&15],s=s<<1|s>>>31,e[t+2&15]=s,a=(i<<5|i>>>27)+(w&o|(w|o)&c)+a+2400959708+s|0,w=w<<30|w>>>2,s=e[15&t]^e[t-5&15]^e[t-11&15]^e[t+3&15],s=s<<1|s>>>31,e[t+3&15]=s,c=(a<<5|a>>>27)+(i&w|(i|w)&o)+c+2400959708+s|0,i=i<<30|i>>>2,s=e[t+1&15]^e[t-4&15]^e[t-10&15]^e[t+4&15],s=s<<1|s>>>31,e[t+4&15]=s,o=(c<<5|c>>>27)+(a&i|(a|i)&w)+o+2400959708+s|0,a=a<<30|a>>>2;for(let t=60;80>t;t+=5)s=e[t-3&15]^e[t-8&15]^e[t-14&15]^e[15&t],s=s<<1|s>>>31,e[15&t]=s,w=(o<<5|o>>>27)+(c^a^i)+w+3395469782+s|0,c=c<<30|c>>>2,s=e[t-2&15]^e[t-7&15]^e[t-13&15]^e[t+1&15],s=s<<1|s>>>31,e[t+1&15]=s,i=(w<<5|w>>>27)+(o^c^a)+i+3395469782+s|0,o=o<<30|o>>>2,s=e[t-1&15]^e[t-6&15]^e[t-12&15]^e[t+2&15],s=s<<1|s>>>31,e[t+2&15]=s,a=(i<<5|i>>>27)+(w^o^c)+a+3395469782+s|0,w=w<<30|w>>>2,s=e[15&t]^e[t-5&15]^e[t-11&15]^e[t+3&15],s=s<<1|s>>>31,e[t+3&15]=s,c=(a<<5|a>>>27)+(i^w^o)+c+3395469782+s|0,i=i<<30|i>>>2,s=e[t+1&15]^e[t-4&15]^e[t-10&15]^e[t+4&15],s=s<<1|s>>>31,e[t+4&15]=s,o=(c<<5|c>>>27)+(a^i^w)+o+3395469782+s|0,a=a<<30|a>>>2;t[0]=t[0]+o|0,t[1]=t[1]+c|0,t[2]=t[2]+a|0,t[3]=t[3]+i|0,t[4]=t[4]+w|0}})(),n=new o(B),s=new o(B);t.length>B&&(e.update(t,0,t.length),t=e.digest());for(let e=0;B>e;e++){const r=e<t.length?t[e]:0;n[e]=54^r,s[e]=92^r}return e.update(n,0,B),{update(t,n,r){e.update(t,n,r)},digest(){const t=e.digest();e.update(s,0,B),e.update(t,0,j);const r=e.digest();return e.update(n,0,B),r}}}function Y(t){return W[t>>>24]<<24|W[t>>>16&255]<<16|W[t>>>8&255]<<8|W[255&t]}function Z(t){return t<<24|(65280&t)<<8|t>>>8&65280|t>>>24}function $(t){return 255&(t<<1^27*(t>>7))}const _=typeof p!=z&&typeof p.getRandomValues==k,tt="Invalid password",et="zipjs-abort-check-password";function nt(t){if(_)return p.getRandomValues(t);throw new s("Crypto API not supported")}const rt={name:"PBKDF2"},st=e.assign({hash:{name:"HMAC"}},rt),ot=e.assign({iterations:1e3,hash:{name:"SHA-1"}},rt),ct=["deriveBits"],at=[8,12,16],it=[16,24,32],wt=10,ut=typeof p!=z,ft=ut&&p.subtle;let lt=ut&&typeof ft!=z&&typeof ft.importKey==k&&typeof ft.deriveBits==k,pt=Q;class dt extends h{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:r,checkAuthenticationCode:c=!0}){super({start(){yt(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:a,l:i,ready:w}=n;c?(await(async(t,e,n,r)=>{const o=await gt(t,e,n,zt(r,0,at[e])),c=zt(r,at[e]);if(o[0]!=c[0]||o[1]!=c[1])throw St(t),new s(tt)})(n,a,c,zt(t,0,at[a]+2)),t=zt(t,at[a]+2),r?(St(n),e.error(new s(et))):i()):await w;const u=new o(t.length-wt-(t.length-wt)%16);e.enqueue(mt(n,t,u,0,wt,!0))},async flush(t){const{h:e,m:n,ready:r}=this;if(e){await r;const a=zt(n,n.length-wt),i=new o(zt(n,0,n.length-wt));e.process(i,!0);const w=e.digest();let u=n.length<wt?1:0;for(let t=0;wt>t;t++)u|=w[t]^a[t];if(u&&c)throw new s("Invalid authentication code");t.enqueue(i)}},cancel(){St(this)}})}}class ht extends h{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){yt(this,t,e,n)},async transform(t,e){const n=this,{password:r,strength:s,l:c,ready:a}=n;let i=C;r?(i=await(async(t,e,n)=>{const r=nt(new o(at[e]));return U(r,await gt(t,e,n,r))})(n,s,r),c()):await a;const w=new o(i.length+t.length-t.length%16);w.set(i,0),e.enqueue(mt(n,t,w,i.length,0,!1))},async flush(t){const{h:e,m:n,ready:r}=this;if(e){await r;const s=new o(n);e.process(s,!1);const c=zt(e.digest(),0,wt);t.enqueue(U(s,c))}},cancel(){St(this)}})}}function yt(t,n,r,s){e.assign(t,{ready:new f(e=>t.l=e),password:vt(n,r),strength:s-1,m:C})}function mt(t,e,n,r,s,c){const{h:a,m:i}=t;i.length&&(e=U(i,e));const w=e.length-s,u=w-w%16;if(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,r+u),u){const t=zt(n,r,r+u);t.set(zt(e,0,u)),a.process(t,c)}return t.m=zt(e,u),n}function St({h:t}){t&&t.dispose&&t.dispose()}async function gt(t,n,s,c){t.password=null;const a=it[n],i=await(async(t,n,s)=>{if(lt)try{const r=await ft.importKey("raw",t,st,!1,ct);return new o(await ft.deriveBits(e.assign({salt:n},ot),r,8*s))}catch{lt=!1}return((t,e,n,s)=>{const c=X(t),a=new o(s),i=new o(e.length+4),w=new u(i.buffer);i.set(e);for(let t=1,n=0;s>n;t++,n+=j){w.setUint32(e.length,t),c.update(i,0,i.length);let o=c.digest();const u=o.slice();for(let t=1;1e3>t;t++){c.update(o,0,j),o=c.digest();for(let t=0;j>t;t++)u[t]^=o[t]}a.set(u.subarray(0,r.min(j,s-n)),n)}return a})(t,n,0,s)})(s,c,2*a+2);return t.h=pt(zt(i,0,a),zt(i,a,2*a)),zt(i,2*a)}function vt(t,e){return e===v?(t=>{if(typeof l==z){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new l).encode(t)})(t):e}function zt(t,e,n){return t.subarray(e,n)}class kt extends h{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:r}){super({start(){It(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=bt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new s(tt);t=t.subarray(12)}r?e.error(new s(et)):e.enqueue(bt(n,t))}})}}class Ct extends h{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){It(this,t,e,n)},transform(t,e){const n=this;let r,s;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=nt(new o(12));e[11]=n.passwordVerification,r=new o(t.length+e.length),r.set(xt(n,e),0),s=12}else r=new o(t.length),s=0;r.set(xt(n,t),s),e.enqueue(r)}})}}function It(t,n,r,s){e.assign(t,{password:n,rawPassword:r,passwordVerification:s}),((t,n,r)=>{const s=[305419896,591751049,878082192];if(e.assign(t,{keys:s,S:new R(s[0]),v:new R(s[2])}),r)for(let e=0;e<r.length;e++)At(t,r[e]);else for(let e=0;e<n.length;e++)At(t,n.charCodeAt(e))})(t,n,r)}function bt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=Pt(t)^e[r],At(t,n[r]);return n}function xt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=Pt(t)^e[r],At(t,e[r]);return n}function At(t,e){let[,n]=t.keys;t.S.append([e]);const s=~t.S.get();n=Dt(r.imul(Dt(n+Mt(s)),134775813)+1),t.v.append([n>>>24]);const o=~t.v.get();t.keys=[s,n,o]}function Pt(t){const e=2|t.keys[2];return Mt(r.imul(e,1^e)>>>8)}function Mt(t){return 255&t}function Dt(t){return 4294967295&t}function Ft(t){if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:r}=await e.read();r?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})}const Et=new w;function Rt(t){return Et.get(t)}const Tt="Invalid uncompressed size",Ut="deflate-raw",Vt="gzip",Bt=[31,139,8];class jt extends h{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:r}){super({});const{compressed:s,encrypted:o,useCompressionStream:c,zipCrypto:a,computeCrc32:i,level:w,deflate64:f,format:l,compressionMethod:p,inputSize:d}=t,h=this;let y,m,S,g=super.readable;const v=l&&Rt(l),z=((t,e,n)=>t&&e?e:n&&n.C?n:void 0)(c,r,n),k=i&&s&&!f&&!v&&(!o||a)&&!!z;if(o&&!a||!i||k||(y=new T,g=qt(g,y)),s)if(v)g=Gt(g,Lt(v.CompressionStream,l,{level:w,chunkSize:e,compressionMethod:p,uncompressedSize:d}));else if(k)S=new Kt,g=Gt(g,new z(Vt,{level:w,chunkSize:e})),g=qt(g,S);else try{g=Nt(g,c,{level:w,chunkSize:e},r,n)}catch(t){let e;try{e=new r(Vt)}catch{throw t}g=Gt(g,e),g=qt(g,new Kt)}o&&(a?g=qt(g,new Ct(t)):(m=new ht(t),g=qt(g,m))),Wt(h,g,()=>{o&&!a||!i||(h.crc32=k?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Kt extends h{constructor(){let t,e=10,n=new o(0);super({transform(t,s){if(e){const n=r.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=U(n,t));const c=o-8,a=r.min(c,n.length);s.enqueue(U(n.subarray(0,a),t.subarray(0,c-a))),n=U(n.subarray(a),t.subarray(c-a))},flush(){const e=V(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Ot extends h{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:r}){super({});const{zipCrypto:c,encrypted:a,checkCrc32:i,crc32:w,compressed:l,useCompressionStream:p,deflate64:d,format:m,compressionMethod:S,rawBitFlag:g,outputSize:z}=t;let k,C,I,b=super.readable;if(a&&(c?b=qt(b,new kt(t)):(C=new dt(t),b=qt(b,C))),l){const t=m&&Rt(m);if(t)b=Gt(b,Lt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:z}));else try{b=Nt(b,p,{chunkSize:e,deflate64:d},r,n)}catch(t){if(d||z===v)throw t;let e;try{e=new r(Vt)}catch{throw t}I=new R,b=((t,e,n,r)=>{let c,a,i,w=0,u=!1;const l=new f((t,e)=>{a=t,i=e});l.catch(()=>{}),n||a();const p=new h({start(t){const e=new o(10);e.set(Bt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){u=!0,y();try{await l}finally{m()}const e=new o(8),s=V(e);s.setUint32(0,r.get(),!0),s.setUint32(4,n,!0),t.enqueue(e)},cancel(t){i(t)}}),d=new h({transform(t,e){r.append(t),w+=t.length,n>w?u&&y():a(),e.enqueue(t)},cancel(t){i(t)}});return t=qt(t,p),qt(t=Gt(t,e),d);function y(){m(),c=setTimeout(()=>i(new s(Tt)),5e3)}function m(){clearTimeout(c)}})(b,e,z,I)}b=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new s("Invalid compressed data");throw e.cause=t,e}const{value:r,done:o}=n;o?t.close():t.enqueue(r)},cancel:t=>e.cancel(t)})})(b)}i&&!I&&(k=new T,b=qt(b,k)),Wt(this,b,()=>{if(i){const t=I?I.get()>>>0:new u(k.value.buffer).getUint32(0,!1);if(w!=t)throw new s("Invalid CRC32")}})}}const Ht=new w;function Wt(t,n,r){n=qt(n,new h({flush:r})),e.defineProperty(t,"readable",{get:()=>n})}function Lt(t,e,n){if(!t)throw new s("Compression method not supported");return new t(e,n)}function Nt(t,e,n,r,s){const o=e&&r?r:s||r,c=n.deflate64?"deflate64-raw":Ut;let a;try{a=new o(c,n)}catch(t){if(!e||!s||o==s)throw t;a=new s(c,n)}return Gt(t,a)}function qt(t,e){return Ft(t).pipeThrough(e)}function Gt(t,e){const n=e.writable.getWriter(),r=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await r.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(r,t)}})(),e.readable}const Jt="data",Qt="deflate";class Xt extends h{constructor(t,n){super({});const r=this,{codecType:o}=t;let c;o.startsWith(Qt)?c=jt:o.startsWith("inflate")&&(c=Ot),r.outputSize=0;let a=0;const i=new c(t,n),w=super.readable,u=new h({transform(t,e){t&&t.length&&(a+=t.length,e.enqueue(t))},flush(){e.assign(r,{inputSize:a})}}),f=new h({transform(e,n){if(e&&e.length&&(n.enqueue(e),r.outputSize+=e.length,t.outputSize!==v&&r.outputSize>t.outputSize))throw new s(Tt)},flush(){const{crc32:t}=i;e.assign(r,{crc32:t,inputSize:a})}});e.defineProperty(r,"readable",{get:()=>w.pipeThrough(u).pipeThrough(i).pipeThrough(f)})}}class Yt extends h{constructor(t){const r=[];let s=0,c=0;function a(){const e=new o(t);let n=0;for(;t>n;){const s=r[0],o=t-n;s.length>o?(e.set(s.subarray(0,o),n),r[0]=s.subarray(o),n+=o):(e.set(s,n),n+=s.length,r.shift())}return s-=t,e}n.isFinite(t)&&t>=1||(t=65536),super({transform(e,n){for(r.push(e),s+=e.length;s>t;)c+=t,n.enqueue(a())},flush(t){s&&(c+=s,t.enqueue(((t,e)=>{const n=new o(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n})(r,s)))}}),e.defineProperty(this,"outputSize",{get:()=>c})}}let Zt=2;try{typeof navigator!=z&&navigator.hardwareConcurrency&&(Zt=navigator.hardwareConcurrency)}catch{}function $t(t){return!!t&&"object"==typeof t}const _t=new w,te=new w,ee=(()=>{try{return structuredClone(new s)instanceof s}catch{return!1}})();let ne=0;async function re(t){let e,o,c;try{const{options:a,config:i}=t;if(a.format)try{await(async(t,e)=>{!Et.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:r}=e;if(typeof n!=k&&typeof r!=k)throw new s("Invalid codec module");Et.set(t,{CompressionStream:n,DecompressionStream:r})})(t,await(import(e)))})(a.format,a.codecURI)}catch(t){if($t(t))try{t.codecImportFailed=!0}catch{}throw t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,a.compressed&&!a.format)if(a.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Ht.get(t);n||(n=new w,Ht.set(t,n));let r=n.get(e);if(r===v){try{new t(e),r=!0}catch{r=!1}n.set(e,r)}return r})(a.codecType.startsWith(Qt)?i.CompressionStream:i.DecompressionStream,Ut))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{a.useCompressionStream=!0}if(a.encrypted&&!a.zipCrypto)try{await self.initModule(t.config)}catch{}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const u={highWaterMark:1},l=t.readable?Ft(t.readable):new y({async pull(t){const e=new f(t=>_t.set(ne,t));se({type:"pull",messageId:ne}),ne=(ne+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await e;t.enqueue(r),s&&t.close()}},u);c=t.writable?(t=>{if(t instanceof m)return t;const e=t.getWriter();return new m({write:t=>e.write(t),close:()=>e.close(),abort:t=>e.abort(t)})})(t.writable):new m({async write(t){let e;const r=new f(t=>e=t);te.set(ne,e),se({type:Jt,value:t,messageId:ne}),ne=(ne+1)%n.MAX_SAFE_INTEGER,await r}},u),e=new Xt(a,i),o=new Yt((t=>{return s="string"==typeof(e=s=t.chunkSize)&&e.trim()?n(e):e,n.isInteger(s)&&s>=1?r.max(s,64):65536;var e,s})(i)),await l.pipeThrough(e).pipeThrough(o).pipeTo(c,{preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{crc32:p,inputSize:d,outputSize:h}=e;se({type:"close",result:{crc32:p,inputSize:d,outputSize:h}})}catch(t){const e=o?o.outputSize:0;if($t(t))try{t.outputSize=e}catch{}if(c&&!c.locked)try{await c.getWriter().close()}catch{}oe(t,e)}}function se(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,d(t,[t.value])}catch{d(t)}else d(t);else d(t);var n}function oe(t,e){const{message:n,stack:r,code:o,name:c,outputSize:a,cause:i,codecImportFailed:w}=((t=new s("Unknown error"))=>$t(t)?t:new s(t+""))(t),u={message:n,stack:r,code:o,name:c,outputSize:a===v?e:a};if(i&&(u.cause={name:i.name,message:i.message}),w&&(u.codecImportFailed=!0),ee)try{return void d({error:u,errorValue:{value:t}})}catch{}d({error:u})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:r,done:s}=t;try{if("start"==e&&re(t),e==Jt){const t=_t.get(n);_t.delete(n),t({value:r||new o,done:s})}if("ack"==e){const t=te.get(n);te.delete(n),t()}}catch(t){oe(t)}}),d({type:"ready"}),((t={})=>{const{init:e,I:n}=t,r=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;n&&(pt=n||Q),self.initModule=async t=>{e&&await e(t),r&&(t.CompressionStreamFallback=r),s&&(t.DecompressionStreamFallback=s)}})()}();
|