single-file-core 1.6.40 → 1.7.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/filename.js +11 -2
- package/core/helper.js +16 -3
- package/core/index.js +13 -2
- package/core/lib/processor-helper-common.js +38 -0
- package/core/lib/processor-helper-inline.js +25 -0
- package/core/lib/processor-helper.js +25 -0
- package/core/util.js +1 -0
- package/modules/css-fonts-minifier.js +4 -1
- package/modules/font-glyphs-minifier.js +1570 -0
- package/modules/template-formatter.js +2 -0
- package/package.json +1 -1
- package/processors/compression/compression-packager.js +2 -8
- package/processors/compression/compression.js +16 -7
- package/processors/frame-tree/content/content-frame-tree.js +20 -8
|
@@ -16877,6 +16877,7 @@ async function formatFilename(content, doc, options) {
|
|
|
16877
16877
|
}
|
|
16878
16878
|
const { filenameReplacementCharacter, filenameReplacedCharacters, filenameReplacementCharacters } = options;
|
|
16879
16879
|
filename = getValidFilename(filename, filenameReplacedCharacters, filenameReplacementCharacter, filenameReplacementCharacters);
|
|
16880
|
+
filename = filename.replace(/\s+/g, " ");
|
|
16880
16881
|
if (!options.backgroundSave) {
|
|
16881
16882
|
filename = filename.replace(/\//g, filenameReplacementCharacter);
|
|
16882
16883
|
}
|
|
@@ -17009,6 +17010,7 @@ async function evalTemplate(template = "", options, content, doc, context = {})
|
|
|
17009
17010
|
"lowercase": value => value.toLowerCase(),
|
|
17010
17011
|
"uppercase": value => value.toUpperCase(),
|
|
17011
17012
|
"capitalize": value => value.charAt(0).toUpperCase() + value.slice(1),
|
|
17013
|
+
"titlecase": value => value.replace(/(^|[^\p{L}\p{N}'’])(\p{L})/gu, (match, separator, letter) => separator + letter.toUpperCase()),
|
|
17012
17014
|
"replace": (value, searchValue, replaceValue) => searchValue && replaceValue ? replaceAll(value, searchValue, replaceValue) : value,
|
|
17013
17015
|
"trim": value => value.trim(),
|
|
17014
17016
|
"trim-left": value => value.trimLeft(),
|
package/package.json
CHANGED
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
/* global URL */
|
|
25
25
|
|
|
26
26
|
import {
|
|
27
|
-
configure,
|
|
28
27
|
TextReader,
|
|
29
28
|
TextWriter,
|
|
30
29
|
Uint8ArrayReader,
|
|
@@ -33,12 +32,11 @@ import {
|
|
|
33
32
|
} from "./../../vendor/zip/zip.js";
|
|
34
33
|
import {
|
|
35
34
|
createArchive,
|
|
35
|
+
configureZipWorker,
|
|
36
36
|
escapeHTML,
|
|
37
37
|
PROCESS_OPTION_NAMES
|
|
38
38
|
} from "./compression.js";
|
|
39
39
|
|
|
40
|
-
const browser = globalThis.browser;
|
|
41
|
-
|
|
42
40
|
const PAGES_PREFIX = "pages/";
|
|
43
41
|
const PAGES_FILENAME = "sfz-pages.json";
|
|
44
42
|
const MANIFEST_FILENAME = "manifest.json";
|
|
@@ -62,11 +60,7 @@ const SYMLINK_UNIX_MODE = 0o120777;
|
|
|
62
60
|
export { createPagesArchive };
|
|
63
61
|
|
|
64
62
|
async function createPagesArchive(pages, options) {
|
|
65
|
-
|
|
66
|
-
configure({ workerURI: "/lib/single-file-z-worker.js", workerStartupTimeout: 2000 });
|
|
67
|
-
} else {
|
|
68
|
-
configure({ useWebWorkers: false });
|
|
69
|
-
}
|
|
63
|
+
configureZipWorker(options);
|
|
70
64
|
const manifest = {
|
|
71
65
|
pages: pages.map((page, pageIndex) => ({
|
|
72
66
|
path: getPagePath(pageIndex, options.createRootDirectory),
|
|
@@ -49,6 +49,8 @@ const COMPRESSIBLE_CONTENT_TYPES = ["application/javascript", "application/x-jav
|
|
|
49
49
|
const TEXT_CONTENT_TYPE_PREFIX = "text/";
|
|
50
50
|
const NO_COMPRESSION_EXTENSIONS = [".jpg", ".jpeg", ".png", ".apng", ".gif", ".webp", ".avif", ".heif", ".heic", ".jxl", ".pdf", ".woff", ".woff2", ".mp4", ".webm", ".avi", ".mpeg", ".mov", ".ts", ".ogv", ".mp3", ".ogg", ".oga", ".weba", ".m4a", ".aac", ".opus", ".flac"];
|
|
51
51
|
const SCRIPT_PATH = "/lib/single-file-zip.min.js";
|
|
52
|
+
const DEFAULT_ZIP_WORKER_URI = "/lib/single-file-z-worker.js";
|
|
53
|
+
const ZIP_WORKER_STARTUP_TIMEOUT = 2000;
|
|
52
54
|
const EXTRA_DATA_TAGS = [
|
|
53
55
|
["<script type=sfz-data>", "</script>"],
|
|
54
56
|
["<style type=sfz-data>", "</style>"],
|
|
@@ -128,25 +130,32 @@ const PROCESS_OPTION_NAMES = [
|
|
|
128
130
|
"preventAppendedData",
|
|
129
131
|
"selfExtractingArchive",
|
|
130
132
|
"url",
|
|
131
|
-
"zipScript"
|
|
133
|
+
"zipScript",
|
|
134
|
+
"zipWorkerURI"
|
|
132
135
|
];
|
|
133
136
|
|
|
134
137
|
export {
|
|
135
138
|
process,
|
|
136
139
|
createArchive,
|
|
140
|
+
configureZipWorker,
|
|
137
141
|
escapeHTML,
|
|
138
142
|
PROCESS_OPTION_NAMES,
|
|
139
|
-
DEFAULT_MAX_APPENDED_DATA_LENGTH
|
|
143
|
+
DEFAULT_MAX_APPENDED_DATA_LENGTH,
|
|
144
|
+
DEFAULT_ZIP_WORKER_URI
|
|
140
145
|
};
|
|
141
146
|
|
|
147
|
+
function configureZipWorker(options) {
|
|
148
|
+
const configuration = browser && browser.runtime && browser.runtime.getURL
|
|
149
|
+
? { workerURI: options.zipWorkerURI || DEFAULT_ZIP_WORKER_URI, workerStartupTimeout: ZIP_WORKER_STARTUP_TIMEOUT }
|
|
150
|
+
: { useWebWorkers: false };
|
|
151
|
+
configure(configuration);
|
|
152
|
+
return configuration;
|
|
153
|
+
}
|
|
154
|
+
|
|
142
155
|
async function process(pageData, options, lastModDate = new Date()) {
|
|
143
156
|
let script;
|
|
144
157
|
const extensionContext = Boolean(browser && browser.runtime && browser.runtime.getURL);
|
|
145
|
-
|
|
146
|
-
configure({ workerURI: "/lib/single-file-z-worker.js" });
|
|
147
|
-
} else {
|
|
148
|
-
configure({ useWebWorkers: false });
|
|
149
|
-
}
|
|
158
|
+
configureZipWorker(options);
|
|
150
159
|
if (options.zipScript) {
|
|
151
160
|
script = options.zipScript;
|
|
152
161
|
} else if (extensionContext) {
|
|
@@ -226,8 +226,8 @@ function initRequestSync(message) {
|
|
|
226
226
|
}
|
|
227
227
|
processFrames(document, message.options, windowId, sessionId, false);
|
|
228
228
|
if (!TOP_WINDOW) {
|
|
229
|
-
sendInitResponse({ frames: [getFrameData(document, globalThis, windowId, message.options, message.scrolling)], sessionId, requestedFrameId: document
|
|
230
|
-
|
|
229
|
+
sendInitResponse({ frames: [getFrameData(document, globalThis, windowId, message.options, message.scrolling)], sessionId, requestedFrameId: getRequestedFrameId(document) && windowId });
|
|
230
|
+
clearRequestedFrameId(document);
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
@@ -239,8 +239,8 @@ async function initRequestAsync(message) {
|
|
|
239
239
|
}
|
|
240
240
|
processFrames(document, message.options, windowId, sessionId, message.waitForFrames !== false);
|
|
241
241
|
if (!TOP_WINDOW) {
|
|
242
|
-
sendInitResponse({ frames: [getFrameData(document, globalThis, windowId, message.options, message.scrolling)], sessionId, requestedFrameId: document
|
|
243
|
-
|
|
242
|
+
sendInitResponse({ frames: [getFrameData(document, globalThis, windowId, message.options, message.scrolling)], sessionId, requestedFrameId: getRequestedFrameId(document) && windowId });
|
|
243
|
+
clearRequestedFrameId(document);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
@@ -329,7 +329,7 @@ function processFramesAsync(doc, frameElements, options, parentWindowId, session
|
|
|
329
329
|
frameElement.setAttribute(helper.WIN_ID_ATTRIBUTE_NAME, windowId);
|
|
330
330
|
frames.push({ windowId });
|
|
331
331
|
});
|
|
332
|
-
sendInitResponse({ frames, sessionId, requestedFrameId: doc
|
|
332
|
+
sendInitResponse({ frames, sessionId, requestedFrameId: getRequestedFrameId(doc) && parentWindowId });
|
|
333
333
|
frameElements.forEach((frameElement, frameIndex) => {
|
|
334
334
|
if (isHiddenFrame(frameElement)) {
|
|
335
335
|
return;
|
|
@@ -344,7 +344,7 @@ function processFramesAsync(doc, frameElements, options, parentWindowId, session
|
|
|
344
344
|
setFrameFallback(sessionId, windowId, () => getSrcdocFrameData(frameElement, windowId, options, sessionId));
|
|
345
345
|
requestTimeouts[windowId] = globalThis.setTimeout(() => sendInitResponse({ frames: [getFrameFallback(sessionId, windowId) || { windowId, processed: true }], sessionId }), TIMEOUT_INIT_REQUEST_MESSAGE);
|
|
346
346
|
});
|
|
347
|
-
|
|
347
|
+
clearRequestedFrameId(doc);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
function processFramesSync(doc, frameElements, options, parentWindowId, sessionId, waitForFrames) {
|
|
@@ -384,8 +384,20 @@ function processFramesSync(doc, frameElements, options, parentWindowId, sessionI
|
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
|
-
sendInitResponse({ frames, sessionId, requestedFrameId: doc
|
|
388
|
-
|
|
387
|
+
sendInitResponse({ frames, sessionId, requestedFrameId: getRequestedFrameId(doc) && parentWindowId });
|
|
388
|
+
clearRequestedFrameId(doc);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function getRequestedFrameId(doc) {
|
|
392
|
+
const dataset = doc.documentElement.dataset;
|
|
393
|
+
return dataset && dataset.requestedFrameId;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function clearRequestedFrameId(doc) {
|
|
397
|
+
const dataset = doc.documentElement.dataset;
|
|
398
|
+
if (dataset) {
|
|
399
|
+
delete dataset.requestedFrameId;
|
|
400
|
+
}
|
|
389
401
|
}
|
|
390
402
|
|
|
391
403
|
function clearFrameTimeout(type, sessionId, windowId) {
|