single-file-core 1.5.44 → 1.5.46
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 +12 -2
- package/core/index.js +11 -4
- package/core/infobar.js +25 -4
- package/core/lib/processor-helper-common.js +6 -2
- package/core/lib/processor-helper-inline.js +10 -5
- package/core/lib/processor-helper.js +10 -5
- package/core/util.js +8 -2
- package/eslint.config.mjs +31 -0
- package/modules/css-fonts-minifier.js +2 -2
- package/modules/css-matched-rules.js +1 -0
- package/modules/html-images-alt-minifier.js +1 -0
- package/modules/html-minifier.js +2 -1
- package/modules/html-serializer.js +2 -2
- package/modules/template-formatter.js +12 -2
- package/package.json +6 -3
- package/processors/compression/compression.js +1 -1
- package/processors/frame-tree/content/content-frame-tree.js +7 -2
- package/processors/hooks/content/content-hooks-frames-web.js +4 -1
- package/processors/hooks/content/content-hooks-frames.js +1 -1
- package/processors/lazy/content/content-lazy-loader.js +3 -2
- package/single-file-infobar.js +7 -1
- package/single-file.js +0 -2
- package/vendor/css-media-query-parser.js +1 -1
- package/vendor/css-minifier.js +4 -3
- package/vendor/css-tree.js +10 -10
- package/vendor/css-unescape.js +0 -1
- package/vendor/html-srcset-parser.js +2 -2
- package/vendor/mime-type-parser.js +2 -2
- package/.eslintrc.js +0 -40
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global
|
|
24
|
+
/* global btoa, atob */
|
|
25
25
|
|
|
26
26
|
import { parse } from "./template-parser.js";
|
|
27
27
|
import { getContentSize, digest, getValidFilename } from "./../core/helper.js";
|
|
@@ -33,7 +33,6 @@ const Intl = globalThis.Intl;
|
|
|
33
33
|
const URLSearchParams = globalThis.URLSearchParams;
|
|
34
34
|
const navigator = globalThis.navigator;
|
|
35
35
|
|
|
36
|
-
// eslint-disable-next-line quotes
|
|
37
36
|
const REGEXP_ESCAPE = /([{}()^$&.*?/+|[\\\\]|\]|-)/g;
|
|
38
37
|
|
|
39
38
|
const EMOJI_NAMES = {
|
|
@@ -17016,10 +17015,19 @@ async function evalTemplate(template = "", options, content, doc, context = {})
|
|
|
17016
17015
|
const subdomains = urlSubDomains.split(".");
|
|
17017
17016
|
return subdomains[subdomains.length - index - 1];
|
|
17018
17017
|
},
|
|
17018
|
+
// eslint-disable-next-line no-unused-vars
|
|
17019
17019
|
"stringify": value => { try { return JSON.stringify(value); } catch (error) { return value; } },
|
|
17020
|
+
// eslint-disable-next-line no-unused-vars
|
|
17021
|
+
"encode-base64": value => { try { return btoa(value); } catch (error) { return value; } },
|
|
17022
|
+
// eslint-disable-next-line no-unused-vars
|
|
17023
|
+
"decode-base64": value => { try { return atob(value); } catch (error) { return value; } },
|
|
17024
|
+
// eslint-disable-next-line no-unused-vars
|
|
17020
17025
|
"encode-uri": value => { try { return encodeURI(value); } catch (error) { return value; } },
|
|
17026
|
+
// eslint-disable-next-line no-unused-vars
|
|
17021
17027
|
"decode-uri": value => { try { return decodeURI(value); } catch (error) { return value; } },
|
|
17028
|
+
// eslint-disable-next-line no-unused-vars
|
|
17022
17029
|
"encode-uri-component": value => { try { return encodeURIComponent(value); } catch (error) { return value; } },
|
|
17030
|
+
// eslint-disable-next-line no-unused-vars
|
|
17023
17031
|
"decode-uri-component": value => { try { return decodeURIComponent(value); } catch (error) { return value; } },
|
|
17024
17032
|
"date-locale": locales => context.currentDate.toLocaleDateString(locales),
|
|
17025
17033
|
"time-locale": locales => context.currentDate.toLocaleTimeString(locales),
|
|
@@ -17094,6 +17102,7 @@ async function evalTemplate(template = "", options, content, doc, context = {})
|
|
|
17094
17102
|
try {
|
|
17095
17103
|
const dontReplaceSlash = fn.dontReplaceSlash === undefined ? true : fn.dontReplaceSlash;
|
|
17096
17104
|
return await getValue(() => fn(argument, ...optionalArguments), dontReplaceSlash, options.filenameReplacementCharacter, lengthData);
|
|
17105
|
+
// eslint-disable-next-line no-unused-vars
|
|
17097
17106
|
} catch (error) {
|
|
17098
17107
|
return "";
|
|
17099
17108
|
}
|
|
@@ -17184,6 +17193,7 @@ function extractMaxLength(lengthData) {
|
|
|
17184
17193
|
function decode(value) {
|
|
17185
17194
|
try {
|
|
17186
17195
|
return decodeURI(value);
|
|
17196
|
+
// eslint-disable-next-line no-unused-vars
|
|
17187
17197
|
} catch (error) {
|
|
17188
17198
|
return value;
|
|
17189
17199
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "single-file-core",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.46",
|
|
4
4
|
"description": "SingleFile Core",
|
|
5
5
|
"author": "Gildas Lormeau",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
@@ -14,5 +14,8 @@
|
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/gildas-lormeau/single-file-core/issues"
|
|
16
16
|
},
|
|
17
|
-
"homepage": "https://github.com/gildas-lormeau/single-file-core#readme"
|
|
18
|
-
|
|
17
|
+
"homepage": "https://github.com/gildas-lormeau/single-file-core#readme",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"eslint": "^9.20.1"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import * as lazy from "./../../lazy/content/content-lazy-loader.js";
|
|
27
25
|
import {
|
|
28
26
|
ON_BEFORE_CAPTURE_EVENT_NAME,
|
|
@@ -293,6 +291,7 @@ function processFramesAsync(doc, frameElements, options, parentWindowId, session
|
|
|
293
291
|
const windowId = parentWindowId + WINDOW_ID_SEPARATOR + frameIndex;
|
|
294
292
|
try {
|
|
295
293
|
sendMessage(frameElement.contentWindow, { method: INIT_REQUEST_MESSAGE, windowId, sessionId, options, scrolling: frameElement.scrolling });
|
|
294
|
+
// eslint-disable-next-line no-unused-vars
|
|
296
295
|
} catch (error) {
|
|
297
296
|
// ignored
|
|
298
297
|
}
|
|
@@ -310,6 +309,7 @@ function processFramesSync(doc, frameElements, options, parentWindowId, sessionI
|
|
|
310
309
|
frameDoc = frameElement.contentDocument;
|
|
311
310
|
frameWindow = frameElement.contentWindow;
|
|
312
311
|
frameWindow.stop();
|
|
312
|
+
// eslint-disable-next-line no-unused-vars
|
|
313
313
|
} catch (error) {
|
|
314
314
|
// ignored
|
|
315
315
|
}
|
|
@@ -324,6 +324,7 @@ function processFramesSync(doc, frameElements, options, parentWindowId, sessionI
|
|
|
324
324
|
clearFrameTimeout("requestTimeouts", sessionId, windowId);
|
|
325
325
|
processFrames(frameDoc, options, windowId, sessionId);
|
|
326
326
|
frames.push(getFrameData(frameDoc, frameWindow, windowId, options, frameElement.scrolling));
|
|
327
|
+
// eslint-disable-next-line no-unused-vars
|
|
327
328
|
} catch (error) {
|
|
328
329
|
frames.push({ windowId, processed: true });
|
|
329
330
|
}
|
|
@@ -357,6 +358,7 @@ function cleanupFrames(frameElements, parentWindowId, sessionId) {
|
|
|
357
358
|
frameElement.removeAttribute(helper.WIN_ID_ATTRIBUTE_NAME);
|
|
358
359
|
try {
|
|
359
360
|
sendMessage(frameElement.contentWindow, { method: CLEANUP_REQUEST_MESSAGE, windowId, sessionId });
|
|
361
|
+
// eslint-disable-next-line no-unused-vars
|
|
360
362
|
} catch (error) {
|
|
361
363
|
// ignored
|
|
362
364
|
}
|
|
@@ -366,12 +368,14 @@ function cleanupFrames(frameElements, parentWindowId, sessionId) {
|
|
|
366
368
|
let frameDoc;
|
|
367
369
|
try {
|
|
368
370
|
frameDoc = frameElement.contentDocument;
|
|
371
|
+
// eslint-disable-next-line no-unused-vars
|
|
369
372
|
} catch (error) {
|
|
370
373
|
// ignored
|
|
371
374
|
}
|
|
372
375
|
if (frameDoc) {
|
|
373
376
|
try {
|
|
374
377
|
cleanupFrames(getFrames(frameDoc), windowId, sessionId);
|
|
378
|
+
// eslint-disable-next-line no-unused-vars
|
|
375
379
|
} catch (error) {
|
|
376
380
|
// ignored
|
|
377
381
|
}
|
|
@@ -383,6 +387,7 @@ function sendInitResponse(message) {
|
|
|
383
387
|
message.method = INIT_RESPONSE_MESSAGE;
|
|
384
388
|
try {
|
|
385
389
|
top.singlefile.processors.frameTree.initResponse(message);
|
|
390
|
+
// eslint-disable-next-line no-unused-vars
|
|
386
391
|
} catch (error) {
|
|
387
392
|
sendMessage(top, message, true);
|
|
388
393
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global
|
|
24
|
+
/* global window */
|
|
25
25
|
|
|
26
26
|
(globalThis => {
|
|
27
27
|
|
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
document.addEventListener(BLOCK_COOKIES_START_EVENT, () => {
|
|
110
110
|
try {
|
|
111
111
|
document.__defineGetter__("cookie", () => { throw new Error("document.cookie temporary blocked by SingleFile"); });
|
|
112
|
+
// eslint-disable-next-line no-unused-vars
|
|
112
113
|
} catch (error) {
|
|
113
114
|
// ignored
|
|
114
115
|
}
|
|
@@ -155,6 +156,7 @@
|
|
|
155
156
|
if (globalThis.bootstrap && event.detail.data) {
|
|
156
157
|
globalThis.bootstrap(event.detail.data);
|
|
157
158
|
}
|
|
159
|
+
// eslint-disable-next-line no-unused-vars
|
|
158
160
|
} catch (error) {
|
|
159
161
|
// ignored
|
|
160
162
|
}
|
|
@@ -438,6 +440,7 @@
|
|
|
438
440
|
if (dispatchScrollEvent) {
|
|
439
441
|
globalThis.dispatchEvent(new UIEvent("scroll"));
|
|
440
442
|
}
|
|
443
|
+
// eslint-disable-next-line no-unused-vars
|
|
441
444
|
} catch (error) {
|
|
442
445
|
// ignored
|
|
443
446
|
}
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import * as hooksFrames from "./../../hooks/content/content-hooks-frames.js";
|
|
27
25
|
import {
|
|
28
26
|
LAZY_SRC_ATTRIBUTE_NAME,
|
|
@@ -51,6 +49,7 @@ if (browser && browser.runtime && browser.runtime.onMessage && browser.runtime.o
|
|
|
51
49
|
timeouts.delete(message.type);
|
|
52
50
|
try {
|
|
53
51
|
timeoutData.callback();
|
|
52
|
+
// eslint-disable-next-line no-unused-vars
|
|
54
53
|
} catch (error) {
|
|
55
54
|
clearRegularTimeout(message.type);
|
|
56
55
|
}
|
|
@@ -192,6 +191,7 @@ async function setAsyncTimeout(type, callback, delay, forceNativeTimeout) {
|
|
|
192
191
|
timeouts.set(type, timeoutData);
|
|
193
192
|
try {
|
|
194
193
|
await browser.runtime.sendMessage({ method: "singlefile.lazyTimeout.setTimeout", type, delay });
|
|
194
|
+
// eslint-disable-next-line no-unused-vars
|
|
195
195
|
} catch (error) {
|
|
196
196
|
setRegularTimeout(type, callback, delay);
|
|
197
197
|
}
|
|
@@ -215,6 +215,7 @@ async function clearAsyncTimeout(type) {
|
|
|
215
215
|
if (browser && browser.runtime && browser.runtime.sendMessage) {
|
|
216
216
|
try {
|
|
217
217
|
await browser.runtime.sendMessage({ method: "singlefile.lazyTimeout.clearTimeout", type });
|
|
218
|
+
// eslint-disable-next-line no-unused-vars
|
|
218
219
|
} catch (error) {
|
|
219
220
|
clearRegularTimeout(type);
|
|
220
221
|
}
|
package/single-file-infobar.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global
|
|
24
|
+
/* global window, document */
|
|
25
25
|
|
|
26
26
|
import { appendInfobar, refreshInfobarInfo, extractInfobarData } from "./core/infobar.js";
|
|
27
27
|
|
|
@@ -55,12 +55,18 @@ import { appendInfobar, refreshInfobarInfo, extractInfobarData } from "./core/in
|
|
|
55
55
|
if (browser && browser.runtime && browser.runtime.sendMessage) {
|
|
56
56
|
try {
|
|
57
57
|
options = await browser.runtime.sendMessage({ method: "tabs.getOptions", url: infoData.saveUrl });
|
|
58
|
+
// eslint-disable-next-line no-unused-vars
|
|
58
59
|
} catch (error) {
|
|
59
60
|
// ignored
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
if (options.displayInfobar) {
|
|
63
64
|
infoData.openInfobar = options.openInfobar;
|
|
65
|
+
infoData.infobarPositionAbsolute = options.infobarPositionAbsolute;
|
|
66
|
+
infoData.infobarPositionTop = options.infobarPositionTop;
|
|
67
|
+
infoData.infobarPositionRight = options.infobarPositionRight;
|
|
68
|
+
infoData.infobarPositionBottom = options.infobarPositionBottom;
|
|
69
|
+
infoData.infobarPositionLeft = options.infobarPositionLeft;
|
|
64
70
|
appendInfobar(document, infoData, true);
|
|
65
71
|
refreshInfobarInfo(document, infoData);
|
|
66
72
|
}
|
package/single-file.js
CHANGED
package/vendor/css-minifier.js
CHANGED
|
@@ -246,7 +246,7 @@ function keyframes(content, preservedTokens) {
|
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
248
|
|
|
249
|
-
while (true) {
|
|
249
|
+
while (true) {
|
|
250
250
|
|
|
251
251
|
let level = 0;
|
|
252
252
|
buffer = "";
|
|
@@ -327,7 +327,7 @@ function collectComments(content, comments) {
|
|
|
327
327
|
|
|
328
328
|
let from = 0, end;
|
|
329
329
|
|
|
330
|
-
while (true) {
|
|
330
|
+
while (true) {
|
|
331
331
|
|
|
332
332
|
const start = content.indexOf("/*", from);
|
|
333
333
|
|
|
@@ -572,7 +572,8 @@ function processString(content = "", options = defaultOptions) {
|
|
|
572
572
|
try {
|
|
573
573
|
pattern = REGEXP_REMOVE_SPACES;
|
|
574
574
|
content = content.replace(pattern, token => token.replace(REGEXP_COLUMN, "___PSEUDOCLASSCOLON___"));
|
|
575
|
-
|
|
575
|
+
// eslint-disable-next-line no-unused-vars
|
|
576
|
+
} catch (error) {
|
|
576
577
|
// ignored
|
|
577
578
|
}
|
|
578
579
|
|