single-file-core 1.5.45 → 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 +10 -2
- package/core/infobar.js +1 -1
- package/core/lib/processor-helper-common.js +6 -2
- package/core/lib/processor-helper-inline.js +9 -6
- package/core/lib/processor-helper.js +9 -6
- 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/template-formatter.js +10 -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 +2 -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
package/core/helper.js
CHANGED
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import * as cssUnescape from "./../vendor/css-unescape.js";
|
|
27
25
|
import * as hooksFrames from "./../processors/hooks/content/content-hooks-frames.js";
|
|
28
26
|
import * as infobar from "./infobar.js";
|
|
@@ -80,6 +78,7 @@ const DEFAULT_REPLACED_CHARACTERS = ["~", "+", "?", "%", "*", ":", "|", "\"", "<
|
|
|
80
78
|
const DEFAULT_REPLACEMENT_CHARACTER = "_";
|
|
81
79
|
const DEFAULT_REPLACEMENT_CHARACTERS = ["~", "+", "?", "%", "*", ":", "|", """, "<", ">", "\"];
|
|
82
80
|
const addEventListener = (type, listener, options) => globalThis.addEventListener(type, listener, options);
|
|
81
|
+
// eslint-disable-next-line no-unused-vars
|
|
83
82
|
const dispatchEvent = event => { try { globalThis.dispatchEvent(event); } catch (error) { /* ignored */ } };
|
|
84
83
|
const JSON = globalThis.JSON;
|
|
85
84
|
const crypto = globalThis.crypto;
|
|
@@ -147,6 +146,7 @@ function initUserScriptHandler() {
|
|
|
147
146
|
let detailUserScript;
|
|
148
147
|
try {
|
|
149
148
|
detailUserScript = detail == "jsonDetail" ? JSON.stringify({ options: userScriptOptions }) : { options: userScriptOptions };
|
|
149
|
+
// eslint-disable-next-line no-unused-vars
|
|
150
150
|
} catch (error) {
|
|
151
151
|
// ignored
|
|
152
152
|
}
|
|
@@ -161,6 +161,7 @@ function initUserScriptHandler() {
|
|
|
161
161
|
if (detail.options) {
|
|
162
162
|
Object.assign(options, detail.options);
|
|
163
163
|
}
|
|
164
|
+
// eslint-disable-next-line no-unused-vars
|
|
164
165
|
} catch (error) {
|
|
165
166
|
// ignored
|
|
166
167
|
}
|
|
@@ -236,6 +237,7 @@ function preProcessDoc(doc, win, options) {
|
|
|
236
237
|
if (doc.referrer) {
|
|
237
238
|
try {
|
|
238
239
|
referrer = new URL("/", new URL(doc.referrer).origin).href;
|
|
240
|
+
// eslint-disable-next-line no-unused-vars
|
|
239
241
|
} catch (error) {
|
|
240
242
|
// ignored
|
|
241
243
|
}
|
|
@@ -314,6 +316,7 @@ function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map
|
|
|
314
316
|
shadowRoot.removeEventListener(GET_ADOPTED_STYLESHEETS_RESPONSE_EVENT, listener);
|
|
315
317
|
}
|
|
316
318
|
}
|
|
319
|
+
// eslint-disable-next-line no-unused-vars
|
|
317
320
|
} catch (error) {
|
|
318
321
|
// ignored
|
|
319
322
|
}
|
|
@@ -327,6 +330,7 @@ function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map
|
|
|
327
330
|
if (shadowRoot.adoptedStyleSheets && shadowRoot.adoptedStyleSheets.length === undefined) {
|
|
328
331
|
shadowRoot.dispatchEvent(new CustomEvent(UNREGISTER_GET_ADOPTED_STYLESHEETS_REQUEST_EVENT, { bubbles: true }));
|
|
329
332
|
}
|
|
333
|
+
// eslint-disable-next-line no-unused-vars
|
|
330
334
|
} catch (error) {
|
|
331
335
|
// ignored
|
|
332
336
|
}
|
|
@@ -381,6 +385,7 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
|
|
|
381
385
|
});
|
|
382
386
|
element.setAttribute(CANVAS_ATTRIBUTE_NAME, data.canvases.length - 1);
|
|
383
387
|
data.markedElements.push(element);
|
|
388
|
+
// eslint-disable-next-line no-unused-vars
|
|
384
389
|
} catch (error) {
|
|
385
390
|
// ignored
|
|
386
391
|
}
|
|
@@ -436,6 +441,7 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
|
|
|
436
441
|
data.posters.push(canvasElement.toDataURL("image/png", ""));
|
|
437
442
|
element.setAttribute(POSTER_ATTRIBUTE_NAME, data.posters.length - 1);
|
|
438
443
|
data.markedElements.push(element);
|
|
444
|
+
// eslint-disable-next-line no-unused-vars
|
|
439
445
|
} catch (error) {
|
|
440
446
|
// ignored
|
|
441
447
|
}
|
|
@@ -500,6 +506,7 @@ function getShadowRoot(element) {
|
|
|
500
506
|
} else if (chrome && chrome.dom && chrome.dom.openOrClosedShadowRoot) {
|
|
501
507
|
try {
|
|
502
508
|
return chrome.dom.openOrClosedShadowRoot(element);
|
|
509
|
+
// eslint-disable-next-line no-unused-vars
|
|
503
510
|
} catch (error) {
|
|
504
511
|
return element.shadowRoot;
|
|
505
512
|
}
|
|
@@ -587,6 +594,7 @@ function getStylesheetsData(doc) {
|
|
|
587
594
|
contents[styleIndex] = Array.from(styleElement.sheet.cssRules).map(cssRule => cssRule.cssText).join("\n");
|
|
588
595
|
}
|
|
589
596
|
}
|
|
597
|
+
// eslint-disable-next-line no-unused-vars
|
|
590
598
|
} catch (error) {
|
|
591
599
|
// ignored
|
|
592
600
|
}
|
|
@@ -693,6 +701,7 @@ async function digest(algo, text) {
|
|
|
693
701
|
try {
|
|
694
702
|
const hash = await crypto.subtle.digest(algo, new TextEncoder("utf-8").encode(text));
|
|
695
703
|
return hex(hash);
|
|
704
|
+
// eslint-disable-next-line no-unused-vars
|
|
696
705
|
} catch (error) {
|
|
697
706
|
return "";
|
|
698
707
|
}
|
|
@@ -719,6 +728,7 @@ function flatten(array) {
|
|
|
719
728
|
function getComputedStyle(win, element, pseudoElement) {
|
|
720
729
|
try {
|
|
721
730
|
return win.getComputedStyle(element, pseudoElement);
|
|
731
|
+
// eslint-disable-next-line no-unused-vars
|
|
722
732
|
} catch (error) {
|
|
723
733
|
// ignored
|
|
724
734
|
}
|
package/core/index.js
CHANGED
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import {
|
|
27
25
|
getProcessorHelperClass,
|
|
28
26
|
cssTree
|
|
@@ -516,6 +514,7 @@ class Processor {
|
|
|
516
514
|
infobarURL = url.split("url: ")[1].trim();
|
|
517
515
|
infobarSaveDate = saveDate.split("saved date: ")[1];
|
|
518
516
|
firstComment.remove();
|
|
517
|
+
// eslint-disable-next-line no-unused-vars
|
|
519
518
|
} catch (error) {
|
|
520
519
|
// ignored
|
|
521
520
|
}
|
|
@@ -905,6 +904,7 @@ class Processor {
|
|
|
905
904
|
Array.from(originalElement.attributes).forEach(attribute => {
|
|
906
905
|
try {
|
|
907
906
|
placeHolderElement.setAttribute(attribute.name, attribute.value);
|
|
907
|
+
// eslint-disable-next-line no-unused-vars
|
|
908
908
|
} catch (error) {
|
|
909
909
|
// ignored
|
|
910
910
|
}
|
|
@@ -914,6 +914,7 @@ class Processor {
|
|
|
914
914
|
}
|
|
915
915
|
try {
|
|
916
916
|
templateElement.replaceWith(placeHolderElement);
|
|
917
|
+
// eslint-disable-next-line no-unused-vars
|
|
917
918
|
} catch (error) {
|
|
918
919
|
if (originalElement) {
|
|
919
920
|
templateElement.replaceWith(originalElement);
|
|
@@ -1107,6 +1108,7 @@ class Processor {
|
|
|
1107
1108
|
let resolvedURL;
|
|
1108
1109
|
try {
|
|
1109
1110
|
resolvedURL = util.resolveURL(href, this.options.baseURI || this.options.url);
|
|
1111
|
+
// eslint-disable-next-line no-unused-vars
|
|
1110
1112
|
} catch (error) {
|
|
1111
1113
|
// ignored
|
|
1112
1114
|
}
|
|
@@ -1117,6 +1119,7 @@ class Processor {
|
|
|
1117
1119
|
}
|
|
1118
1120
|
try {
|
|
1119
1121
|
element.setAttribute("href", resolvedURL);
|
|
1122
|
+
// eslint-disable-next-line no-unused-vars
|
|
1120
1123
|
} catch (error) {
|
|
1121
1124
|
// ignored
|
|
1122
1125
|
}
|
|
@@ -1133,12 +1136,14 @@ class Processor {
|
|
|
1133
1136
|
let resolvedURL;
|
|
1134
1137
|
try {
|
|
1135
1138
|
resolvedURL = util.resolveURL(href, this.options.baseURI || this.options.url);
|
|
1139
|
+
// eslint-disable-next-line no-unused-vars
|
|
1136
1140
|
} catch (error) {
|
|
1137
1141
|
// ignored
|
|
1138
1142
|
}
|
|
1139
1143
|
if (resolvedURL) {
|
|
1140
1144
|
try {
|
|
1141
1145
|
element.setAttribute("href", resolvedURL);
|
|
1146
|
+
// eslint-disable-next-line no-unused-vars
|
|
1142
1147
|
} catch (error) {
|
|
1143
1148
|
// ignored
|
|
1144
1149
|
}
|
|
@@ -1178,6 +1183,7 @@ class Processor {
|
|
|
1178
1183
|
context.drawImage(temporaryVideoElement, 0, 0, canvasElement.width, canvasElement.height);
|
|
1179
1184
|
try {
|
|
1180
1185
|
videoElement.poster = canvasElement.toDataURL("image/png", "");
|
|
1186
|
+
// eslint-disable-next-line no-unused-vars
|
|
1181
1187
|
} catch (error) {
|
|
1182
1188
|
// ignored
|
|
1183
1189
|
}
|
|
@@ -1269,6 +1275,7 @@ class Processor {
|
|
|
1269
1275
|
if (src && !testIgnoredPath(src)) {
|
|
1270
1276
|
try {
|
|
1271
1277
|
url = util.resolveURL(src, this.baseURI);
|
|
1278
|
+
// eslint-disable-next-line no-unused-vars
|
|
1272
1279
|
} catch (error) {
|
|
1273
1280
|
// ignored
|
|
1274
1281
|
}
|
|
@@ -1446,6 +1453,7 @@ class Processor {
|
|
|
1446
1453
|
element.textContent = "";
|
|
1447
1454
|
try {
|
|
1448
1455
|
resourceURL = util.resolveURL(scriptSrc, this.baseURI);
|
|
1456
|
+
// eslint-disable-next-line no-unused-vars
|
|
1449
1457
|
} catch (error) {
|
|
1450
1458
|
// ignored
|
|
1451
1459
|
}
|
package/core/infobar.js
CHANGED
|
@@ -189,7 +189,7 @@ function appendInfobar(doc, options, useShadowRoot) {
|
|
|
189
189
|
const styleElement = doc.createElement("style");
|
|
190
190
|
styleElement.textContent = INFOBAR_STYLES;
|
|
191
191
|
if (options.infobarPositionAbsolute) {
|
|
192
|
-
styleElement.textContent +=
|
|
192
|
+
styleElement.textContent += ".infobar { position: absolute; }";
|
|
193
193
|
const parentElementStyle = getComputedStyle(parentElement);
|
|
194
194
|
if (parentElementStyle.position == "static") {
|
|
195
195
|
parentElement.style.setProperty("position", "relative", "important");
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import {
|
|
27
25
|
normalizeFontFamily,
|
|
28
26
|
getFontWeight
|
|
@@ -139,6 +137,7 @@ class ProcessorHelperCommon {
|
|
|
139
137
|
resourceElement.setAttribute(attributeName, util.EMPTY_RESOURCE);
|
|
140
138
|
try {
|
|
141
139
|
resourceURL = util.resolveURL(resourceURL, baseURI);
|
|
140
|
+
// eslint-disable-next-line no-unused-vars
|
|
142
141
|
} catch (error) {
|
|
143
142
|
// ignored
|
|
144
143
|
}
|
|
@@ -153,6 +152,7 @@ class ProcessorHelperCommon {
|
|
|
153
152
|
let symbolElement;
|
|
154
153
|
try {
|
|
155
154
|
symbolElement = svgDoc.querySelector(hashMatch[0]);
|
|
155
|
+
// eslint-disable-next-line no-unused-vars
|
|
156
156
|
} catch (error) {
|
|
157
157
|
// ignored
|
|
158
158
|
}
|
|
@@ -225,6 +225,7 @@ class ProcessorHelperCommon {
|
|
|
225
225
|
if (testValidPath(resourceURL)) {
|
|
226
226
|
try {
|
|
227
227
|
resourceURL = util.resolveURL(resourceURL, baseURI);
|
|
228
|
+
// eslint-disable-next-line no-unused-vars
|
|
228
229
|
} catch (error) {
|
|
229
230
|
// ignored
|
|
230
231
|
}
|
|
@@ -377,6 +378,7 @@ class ProcessorHelperCommon {
|
|
|
377
378
|
if (!originalResourceURL.startsWith("#")) {
|
|
378
379
|
try {
|
|
379
380
|
resolvedURL = util.resolveURL(resourceURL, baseURI);
|
|
381
|
+
// eslint-disable-next-line no-unused-vars
|
|
380
382
|
} catch (error) {
|
|
381
383
|
// ignored
|
|
382
384
|
}
|
|
@@ -538,6 +540,7 @@ class ProcessorHelperCommon {
|
|
|
538
540
|
property = ruleData.block.children.filter(node => {
|
|
539
541
|
try {
|
|
540
542
|
return node.property == propertyName && !cssTree.generate(node.value).match(/\\9$/);
|
|
543
|
+
// eslint-disable-next-line no-unused-vars
|
|
541
544
|
} catch (error) {
|
|
542
545
|
return node.property == propertyName;
|
|
543
546
|
}
|
|
@@ -546,6 +549,7 @@ class ProcessorHelperCommon {
|
|
|
546
549
|
if (property) {
|
|
547
550
|
try {
|
|
548
551
|
return cssTree.generate(property.data.value);
|
|
552
|
+
// eslint-disable-next-line no-unused-vars
|
|
549
553
|
} catch (error) {
|
|
550
554
|
// ignored
|
|
551
555
|
}
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import * as cssTree from "./../../vendor/css-tree.js";
|
|
27
25
|
|
|
28
26
|
const JSON = globalThis.JSON;
|
|
@@ -169,6 +167,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
169
167
|
urlNode.value = util.EMPTY_RESOURCE;
|
|
170
168
|
try {
|
|
171
169
|
resourceURL = util.resolveURL(resourceURL, baseURI);
|
|
170
|
+
// eslint-disable-next-line no-unused-vars
|
|
172
171
|
} catch (error) {
|
|
173
172
|
// ignored
|
|
174
173
|
}
|
|
@@ -319,6 +318,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
319
318
|
if (testValidPath(resourceURL)) {
|
|
320
319
|
try {
|
|
321
320
|
resourceURL = util.resolveURL(resourceURL, baseURI);
|
|
321
|
+
// eslint-disable-next-line no-unused-vars
|
|
322
322
|
} catch (error) {
|
|
323
323
|
// ignored
|
|
324
324
|
}
|
|
@@ -332,6 +332,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
332
332
|
if (this.testEmptyResource(content)) {
|
|
333
333
|
try {
|
|
334
334
|
originURL = util.resolveURL(originURL, baseURI);
|
|
335
|
+
// eslint-disable-next-line no-unused-vars
|
|
335
336
|
} catch (error) {
|
|
336
337
|
// ignored
|
|
337
338
|
}
|
|
@@ -349,6 +350,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
349
350
|
acceptHeaders: options.acceptHeaders,
|
|
350
351
|
networkTimeout: options.networkTimeout
|
|
351
352
|
})).data;
|
|
353
|
+
// eslint-disable-next-line no-unused-vars
|
|
352
354
|
} catch (error) {
|
|
353
355
|
// ignored
|
|
354
356
|
}
|
|
@@ -416,9 +418,9 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
416
418
|
if (forbiddenPrefixFound) {
|
|
417
419
|
return "";
|
|
418
420
|
}
|
|
419
|
-
return content + (srcsetValue.w ? " " + srcsetValue.w + "w" :
|
|
421
|
+
return content + (srcsetValue.w ? " " + srcsetValue.w + "w" :
|
|
420
422
|
srcsetValue.h ? " " + srcsetValue.h + "h" :
|
|
421
|
-
|
|
423
|
+
srcsetValue.d ? " " + srcsetValue.d + "x" : "");
|
|
422
424
|
}
|
|
423
425
|
|
|
424
426
|
testEmptyResource(resource) {
|
|
@@ -564,6 +566,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
564
566
|
fontFace.load().then(() => fontFace.loaded).then(() => { source.valid = true; globalThis.clearTimeout(timeout); }),
|
|
565
567
|
new Promise(resolve => timeout = globalThis.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
|
|
566
568
|
]);
|
|
569
|
+
// eslint-disable-next-line no-unused-vars
|
|
567
570
|
} catch (error) {
|
|
568
571
|
// ignored
|
|
569
572
|
}
|
|
@@ -606,8 +609,8 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
606
609
|
fontInfo.reverse();
|
|
607
610
|
try {
|
|
608
611
|
srcDeclaration.data.value = cssTree.parse(fontInfo.map(fontSource => fontSource.src).join(","), { context: "value", parseCustomProperty: true });
|
|
609
|
-
|
|
610
|
-
catch (error) {
|
|
612
|
+
// eslint-disable-next-line no-unused-vars
|
|
613
|
+
} catch (error) {
|
|
611
614
|
// ignored
|
|
612
615
|
}
|
|
613
616
|
}
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import * as cssTree from "./../../vendor/css-tree.js";
|
|
27
25
|
|
|
28
26
|
const JSON = globalThis.JSON;
|
|
@@ -158,6 +156,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
158
156
|
urlNode.value = util.EMPTY_RESOURCE;
|
|
159
157
|
try {
|
|
160
158
|
resourceURL = util.resolveURL(resourceURL, baseURI);
|
|
159
|
+
// eslint-disable-next-line no-unused-vars
|
|
161
160
|
} catch (error) {
|
|
162
161
|
// ignored
|
|
163
162
|
}
|
|
@@ -303,6 +302,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
303
302
|
if (testValidPath(resourceURL)) {
|
|
304
303
|
try {
|
|
305
304
|
resourceURL = util.resolveURL(resourceURL, baseURI);
|
|
305
|
+
// eslint-disable-next-line no-unused-vars
|
|
306
306
|
} catch (error) {
|
|
307
307
|
// ignored
|
|
308
308
|
}
|
|
@@ -314,6 +314,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
314
314
|
if (this.testEmptyResource(content)) {
|
|
315
315
|
try {
|
|
316
316
|
originURL = util.resolveURL(originURL, baseURI);
|
|
317
|
+
// eslint-disable-next-line no-unused-vars
|
|
317
318
|
} catch (error) {
|
|
318
319
|
// ignored
|
|
319
320
|
}
|
|
@@ -330,6 +331,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
330
331
|
acceptHeaders: options.acceptHeaders,
|
|
331
332
|
networkTimeout: options.networkTimeout
|
|
332
333
|
})).data;
|
|
334
|
+
// eslint-disable-next-line no-unused-vars
|
|
333
335
|
} catch (error) {
|
|
334
336
|
// ignored
|
|
335
337
|
}
|
|
@@ -364,9 +366,9 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
364
366
|
const { content, indexResource, extension, contentType } = await batchRequest.addURL(resourceURL, { asBinary: true, expectedType: "image" });
|
|
365
367
|
const name = "images/" + indexResource + extension;
|
|
366
368
|
resources.images.set(indexResource, { name, content, extension, contentType, url: resourceURL });
|
|
367
|
-
return name + (srcsetValue.w ? " " + srcsetValue.w + "w" :
|
|
369
|
+
return name + (srcsetValue.w ? " " + srcsetValue.w + "w" :
|
|
368
370
|
srcsetValue.h ? " " + srcsetValue.h + "h" :
|
|
369
|
-
|
|
371
|
+
srcsetValue.d ? " " + srcsetValue.d + "x" : "");
|
|
370
372
|
}
|
|
371
373
|
|
|
372
374
|
testEmptyResource(resource) {
|
|
@@ -484,6 +486,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
484
486
|
fontFace.load().then(() => fontFace.loaded).then(() => { source.valid = true; globalThis.clearTimeout(timeout); }),
|
|
485
487
|
new Promise(resolve => timeout = globalThis.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
|
|
486
488
|
]);
|
|
489
|
+
// eslint-disable-next-line no-unused-vars
|
|
487
490
|
} catch (error) {
|
|
488
491
|
// ignored
|
|
489
492
|
}
|
|
@@ -539,8 +542,8 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
539
542
|
fontInfo.reverse();
|
|
540
543
|
try {
|
|
541
544
|
srcDeclaration.data.value = cssTree.parse(fontInfo.map(fontSource => fontSource.src).join(","), { context: "value", parseCustomProperty: true });
|
|
542
|
-
|
|
543
|
-
catch (error) {
|
|
545
|
+
// eslint-disable-next-line no-unused-vars
|
|
546
|
+
} catch (error) {
|
|
544
547
|
// ignored
|
|
545
548
|
}
|
|
546
549
|
}
|
package/core/util.js
CHANGED
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import * as vendor from "./../vendor/index.js";
|
|
27
25
|
import * as modules from "./../modules/index.js";
|
|
28
26
|
import * as helper from "./helper.js";
|
|
@@ -91,6 +89,7 @@ function getInstance(utilOptions) {
|
|
|
91
89
|
let matchExtension;
|
|
92
90
|
try {
|
|
93
91
|
matchExtension = new URL(resourceURL).pathname.match(/(\.[^\\/.]*)$/);
|
|
92
|
+
// eslint-disable-next-line no-unused-vars
|
|
94
93
|
} catch (error) {
|
|
95
94
|
// ignored
|
|
96
95
|
}
|
|
@@ -265,6 +264,7 @@ function getInstance(utilOptions) {
|
|
|
265
264
|
fetchFrameResource(resourceURL, { frameId: options.frameId, referrer: options.resourceReferrer, headers: { accept } }),
|
|
266
265
|
networkTimeoutPromise
|
|
267
266
|
]);
|
|
267
|
+
// eslint-disable-next-line no-unused-vars
|
|
268
268
|
} catch (error) {
|
|
269
269
|
response = await Promise.race([
|
|
270
270
|
fetchResource(resourceURL, { headers: { accept } }),
|
|
@@ -277,6 +277,7 @@ function getInstance(utilOptions) {
|
|
|
277
277
|
networkTimeoutPromise
|
|
278
278
|
]);
|
|
279
279
|
}
|
|
280
|
+
// eslint-disable-next-line no-unused-vars
|
|
280
281
|
} catch (error) {
|
|
281
282
|
return getFetchResponse(resourceURL, options);
|
|
282
283
|
} finally {
|
|
@@ -288,6 +289,7 @@ function getInstance(utilOptions) {
|
|
|
288
289
|
let buffer;
|
|
289
290
|
try {
|
|
290
291
|
buffer = await response.arrayBuffer();
|
|
292
|
+
// eslint-disable-next-line no-unused-vars
|
|
291
293
|
} catch (error) {
|
|
292
294
|
return options.inline ? { data: options.asBinary ? helper.EMPTY_RESOURCE : "", resourceURL } : { resourceURL };
|
|
293
295
|
}
|
|
@@ -297,6 +299,7 @@ function getInstance(utilOptions) {
|
|
|
297
299
|
const mimeType = new vendor.MIMEType(response.headers.get("content-type"));
|
|
298
300
|
contentType = mimeType.type + "/" + mimeType.subtype;
|
|
299
301
|
charset = mimeType.parameters.get("charset");
|
|
302
|
+
// eslint-disable-next-line no-unused-vars
|
|
300
303
|
} catch (error) {
|
|
301
304
|
// ignored
|
|
302
305
|
}
|
|
@@ -322,6 +325,7 @@ function getInstance(utilOptions) {
|
|
|
322
325
|
} else {
|
|
323
326
|
return getFetchResponse(resourceURL, options, buffer, null, contentType);
|
|
324
327
|
}
|
|
328
|
+
// eslint-disable-next-line no-unused-vars
|
|
325
329
|
} catch (error) {
|
|
326
330
|
return getFetchResponse(resourceURL, options);
|
|
327
331
|
}
|
|
@@ -340,6 +344,7 @@ function getInstance(utilOptions) {
|
|
|
340
344
|
} else {
|
|
341
345
|
try {
|
|
342
346
|
return getFetchResponse(resourceURL, options, buffer, charset, contentType);
|
|
347
|
+
// eslint-disable-next-line no-unused-vars
|
|
343
348
|
} catch (error) {
|
|
344
349
|
return getFetchResponse(resourceURL, options, null, charset);
|
|
345
350
|
}
|
|
@@ -372,6 +377,7 @@ async function getFetchResponse(resourceURL, options, data, charset, contentType
|
|
|
372
377
|
}
|
|
373
378
|
try {
|
|
374
379
|
data = new TextDecoder(charset).decode(data);
|
|
380
|
+
// eslint-disable-next-line no-unused-vars
|
|
375
381
|
} catch (error) {
|
|
376
382
|
charset = "utf-8";
|
|
377
383
|
data = new TextDecoder(charset).decode(data);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
js.configs.recommended,
|
|
5
|
+
{
|
|
6
|
+
languageOptions: {
|
|
7
|
+
ecmaVersion: 2025,
|
|
8
|
+
sourceType: "module",
|
|
9
|
+
globals: {
|
|
10
|
+
console: "readonly",
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
"linebreak-style": [
|
|
15
|
+
"error",
|
|
16
|
+
"unix"
|
|
17
|
+
],
|
|
18
|
+
"quotes": [
|
|
19
|
+
"error",
|
|
20
|
+
"double"
|
|
21
|
+
],
|
|
22
|
+
"semi": [
|
|
23
|
+
"error",
|
|
24
|
+
"always"
|
|
25
|
+
],
|
|
26
|
+
"no-console": [
|
|
27
|
+
"warn"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
];
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
/* global globalThis */
|
|
25
|
-
|
|
26
24
|
import * as cssTree from "./../vendor/css-tree.js";
|
|
27
25
|
import * as fontPropertyParser from "./../vendor/css-font-property-parser.js";
|
|
28
26
|
import {
|
|
@@ -248,6 +246,7 @@ function getDeclarationValue(declarations, propertyName) {
|
|
|
248
246
|
if (property) {
|
|
249
247
|
try {
|
|
250
248
|
return helper.removeQuotes(cssTree.generate(property.data.value)).toLowerCase();
|
|
249
|
+
// eslint-disable-next-line no-unused-vars
|
|
251
250
|
} catch (error) {
|
|
252
251
|
// ignored
|
|
253
252
|
}
|
|
@@ -278,6 +277,7 @@ function getFontFamilyNames(declarations, options) {
|
|
|
278
277
|
}
|
|
279
278
|
const parsedFont = fontPropertyParser.parse(value);
|
|
280
279
|
parsedFont.family.forEach(familyName => fontFamilyNames.push(helper.normalizeFontFamily(familyName)));
|
|
280
|
+
// eslint-disable-next-line no-unused-vars
|
|
281
281
|
} catch (error) {
|
|
282
282
|
// ignored
|
|
283
283
|
}
|
|
@@ -158,6 +158,7 @@ function getMatchedElementsSelector(doc, selectorInfo, styles, matchedElementsCa
|
|
|
158
158
|
(matchedElement.style.getPropertyValue(DISPLAY_STYLE) != "none" || matchedElement.style.getPropertyPriority("display") != "important")
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
|
+
// eslint-disable-next-line no-unused-vars
|
|
161
162
|
} catch (error) {
|
|
162
163
|
// ignored
|
|
163
164
|
}
|
package/modules/html-minifier.js
CHANGED
|
@@ -230,6 +230,7 @@ function compressJSONLD(node) {
|
|
|
230
230
|
if (node.nodeType == Node_ELEMENT_NODE && getTagName(node) == "SCRIPT" && node.type == "application/ld+json" && node.textContent.trim()) {
|
|
231
231
|
try {
|
|
232
232
|
node.textContent = JSON.stringify(JSON.parse(node.textContent));
|
|
233
|
+
// eslint-disable-next-line no-unused-vars
|
|
233
234
|
} catch (error) {
|
|
234
235
|
// ignored
|
|
235
236
|
}
|
|
@@ -245,5 +246,5 @@ function removeEmptyInlineElements(doc) {
|
|
|
245
246
|
}
|
|
246
247
|
|
|
247
248
|
function getTagName(element) {
|
|
248
|
-
return
|
|
249
|
+
return element.tagName && element.tagName.toUpperCase();
|
|
249
250
|
}
|
|
@@ -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,12 +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
|
|
17020
17021
|
"encode-base64": value => { try { return btoa(value); } catch (error) { return value; } },
|
|
17022
|
+
// eslint-disable-next-line no-unused-vars
|
|
17021
17023
|
"decode-base64": value => { try { return atob(value); } catch (error) { return value; } },
|
|
17024
|
+
// eslint-disable-next-line no-unused-vars
|
|
17022
17025
|
"encode-uri": value => { try { return encodeURI(value); } catch (error) { return value; } },
|
|
17026
|
+
// eslint-disable-next-line no-unused-vars
|
|
17023
17027
|
"decode-uri": value => { try { return decodeURI(value); } catch (error) { return value; } },
|
|
17028
|
+
// eslint-disable-next-line no-unused-vars
|
|
17024
17029
|
"encode-uri-component": value => { try { return encodeURIComponent(value); } catch (error) { return value; } },
|
|
17030
|
+
// eslint-disable-next-line no-unused-vars
|
|
17025
17031
|
"decode-uri-component": value => { try { return decodeURIComponent(value); } catch (error) { return value; } },
|
|
17026
17032
|
"date-locale": locales => context.currentDate.toLocaleDateString(locales),
|
|
17027
17033
|
"time-locale": locales => context.currentDate.toLocaleTimeString(locales),
|
|
@@ -17096,6 +17102,7 @@ async function evalTemplate(template = "", options, content, doc, context = {})
|
|
|
17096
17102
|
try {
|
|
17097
17103
|
const dontReplaceSlash = fn.dontReplaceSlash === undefined ? true : fn.dontReplaceSlash;
|
|
17098
17104
|
return await getValue(() => fn(argument, ...optionalArguments), dontReplaceSlash, options.filenameReplacementCharacter, lengthData);
|
|
17105
|
+
// eslint-disable-next-line no-unused-vars
|
|
17099
17106
|
} catch (error) {
|
|
17100
17107
|
return "";
|
|
17101
17108
|
}
|
|
@@ -17186,6 +17193,7 @@ function extractMaxLength(lengthData) {
|
|
|
17186
17193
|
function decode(value) {
|
|
17187
17194
|
try {
|
|
17188
17195
|
return decodeURI(value);
|
|
17196
|
+
// eslint-disable-next-line no-unused-vars
|
|
17189
17197
|
} catch (error) {
|
|
17190
17198
|
return value;
|
|
17191
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
|
+
}
|