single-file-core 1.5.12 → 1.5.14
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/index.js
CHANGED
|
@@ -1535,7 +1535,7 @@ class Processor {
|
|
|
1535
1535
|
publisher: publisherElement && publisherElement.content ? publisherElement.content.trim() : "",
|
|
1536
1536
|
heading: headingElement && headingElement.textContent ? headingElement.textContent.trim() : ""
|
|
1537
1537
|
};
|
|
1538
|
-
this.options.infobarContent = await util.evalTemplate(this.options.infobarTemplate, this.options, null, this.doc, true);
|
|
1538
|
+
this.options.infobarContent = await util.evalTemplate(this.options.infobarTemplate, this.options, null, this.doc, { dontReplaceSlash: true });
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
1541
|
|
package/core/infobar.js
CHANGED
|
@@ -75,11 +75,11 @@ const INFOBAR_STYLES = `
|
|
|
75
75
|
animation-iteration-count: 2;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
.infobar:valid, .infobar:not(:focus-within) .infobar-content {
|
|
78
|
+
.infobar:valid, .infobar:not(:focus-within):not(.infobar-focus) .infobar-content {
|
|
79
79
|
display: none;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
.infobar:focus-within {
|
|
82
|
+
.infobar:focus-within, .infobar.infobar-focus {
|
|
83
83
|
background-color: #f9f9f9;
|
|
84
84
|
border-color: #878787;
|
|
85
85
|
border-radius: 8px;
|
|
@@ -135,9 +135,10 @@ const INFOBAR_STYLES = `
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
.infobar:focus-within .infobar-icon {
|
|
138
|
+
.infobar:focus-within .infobar-icon, .infobar.infobar-focus .infobar-icon {
|
|
139
139
|
z-index: -1;
|
|
140
140
|
background-image: none;
|
|
141
|
+
margin: 4px;
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
.infobar .infobar-close-icon {
|
|
@@ -196,6 +197,9 @@ function appendInfobar(doc, options, useShadowRoot) {
|
|
|
196
197
|
shadowRootContent.appendChild(styleElement);
|
|
197
198
|
const infobarContent = doc.createElement("form");
|
|
198
199
|
infobarContent.classList.add("infobar");
|
|
200
|
+
if (options.openInfobar) {
|
|
201
|
+
infobarContent.classList.add("infobar-focus");
|
|
202
|
+
}
|
|
199
203
|
shadowRootContent.appendChild(infobarContent);
|
|
200
204
|
const iconElement = doc.createElement("span");
|
|
201
205
|
iconElement.tabIndex = -1;
|
|
@@ -276,9 +280,10 @@ function refreshInfobarInfo(doc, { saveUrl, infobarContent, saveDate }) {
|
|
|
276
280
|
}
|
|
277
281
|
}
|
|
278
282
|
|
|
279
|
-
function displayIcon(doc, useShadowRoot) {
|
|
283
|
+
function displayIcon(doc, useShadowRoot, options = {}) {
|
|
280
284
|
const infoData = extractInfobarData(doc);
|
|
281
285
|
if (infoData.saveUrl) {
|
|
286
|
+
infoData.openInfobar = options.openInfobar;
|
|
282
287
|
appendInfobar(doc, infoData, useShadowRoot);
|
|
283
288
|
refreshInfobarInfo(doc, infoData);
|
|
284
289
|
}
|
package/core/util.js
CHANGED
|
@@ -166,8 +166,8 @@ function getInstance(utilOptions) {
|
|
|
166
166
|
getMimeType(options) {
|
|
167
167
|
return !options.compressContent || options.selfExtractingArchive ? "text/html" : "application/zip";
|
|
168
168
|
},
|
|
169
|
-
async evalTemplate(template, options, content, doc,
|
|
170
|
-
return modules.templateFormatter.evalTemplate(template, options, content, doc,
|
|
169
|
+
async evalTemplate(template, options, content, doc, context) {
|
|
170
|
+
return modules.templateFormatter.evalTemplate(template, options, content, doc, context);
|
|
171
171
|
},
|
|
172
172
|
minifyHTML(doc, options) {
|
|
173
173
|
return modules.htmlMinifier.process(doc, options);
|
|
@@ -72,7 +72,7 @@ function matchesMediaType(mediaText) {
|
|
|
72
72
|
const foundMediaTypes = helper.flatten(mediaQueryParser.parseMediaList(mediaText).map(node => getMediaTypes(node)));
|
|
73
73
|
return foundMediaTypes.find(mediaTypeInfo =>
|
|
74
74
|
(!mediaTypeInfo.not && (mediaTypeInfo.value == MEDIA_SCREEN || mediaTypeInfo.value == MEDIA_ALL)) ||
|
|
75
|
-
(mediaTypeInfo.not && (mediaTypeInfo.value != MEDIA_SCREEN
|
|
75
|
+
(mediaTypeInfo.not && (mediaTypeInfo.value != MEDIA_SCREEN)));
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
function getMediaTypes(parentNode, mediaTypes = []) {
|
|
@@ -16899,7 +16899,9 @@ async function formatFilename(content, doc, options) {
|
|
|
16899
16899
|
return filename.trim();
|
|
16900
16900
|
}
|
|
16901
16901
|
|
|
16902
|
-
async function evalTemplate(template = "", options, content, doc,
|
|
16902
|
+
async function evalTemplate(template = "", options, content, doc, context = {}) {
|
|
16903
|
+
const { dontReplaceSlash } = context;
|
|
16904
|
+
context.currentDate = new Date();
|
|
16903
16905
|
const url = new URL(options.saveUrl);
|
|
16904
16906
|
const urlHref = decode(url.href);
|
|
16905
16907
|
const params = Array.from(new URLSearchParams(url.search));
|
|
@@ -17018,11 +17020,11 @@ async function evalTemplate(template = "", options, content, doc, dontReplaceSla
|
|
|
17018
17020
|
"decode-uri": value => { try { return decodeURI(value); } catch (error) { return value; } },
|
|
17019
17021
|
"encode-uri-component": value => { try { return encodeURIComponent(value); } catch (error) { return value; } },
|
|
17020
17022
|
"decode-uri-component": value => { try { return decodeURIComponent(value); } catch (error) { return value; } },
|
|
17021
|
-
"date-locale": locales =>
|
|
17022
|
-
"time-locale": locales =>
|
|
17023
|
-
"datetime-locale": locales =>
|
|
17023
|
+
"date-locale": locales => context.currentDate.toLocaleDateString(locales),
|
|
17024
|
+
"time-locale": locales => context.currentDate.toLocaleTimeString(locales),
|
|
17025
|
+
"datetime-locale": locales => context.currentDate.toLocaleString(locales),
|
|
17024
17026
|
"datetime-custom": (locale, year, month, day, weekday, hour, minute, second, hour12, timeZone, fractionalSecondDigits, timeZoneName, dayPeriod, era, localeMatcher) => {
|
|
17025
|
-
const date =
|
|
17027
|
+
const date = context.currentDate;
|
|
17026
17028
|
const options = {};
|
|
17027
17029
|
setOption(options, "year", year);
|
|
17028
17030
|
setOption(options, "month", month);
|
package/package.json
CHANGED
|
@@ -43,8 +43,8 @@ const helper = {
|
|
|
43
43
|
extractInfobarData(doc) {
|
|
44
44
|
return infobar.extractInfobarData(doc);
|
|
45
45
|
},
|
|
46
|
-
displayIcon(doc, useShadowRoot) {
|
|
47
|
-
return infobar.displayIcon(doc, useShadowRoot);
|
|
46
|
+
displayIcon(doc, useShadowRoot, options = {}) {
|
|
47
|
+
return infobar.displayIcon(doc, useShadowRoot, options);
|
|
48
48
|
},
|
|
49
49
|
zip,
|
|
50
50
|
extract,
|
package/single-file-infobar.js
CHANGED
|
@@ -60,6 +60,7 @@ import { appendInfobar, refreshInfobarInfo, extractInfobarData } from "./core/in
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
if (options.displayInfobar) {
|
|
63
|
+
infoData.openInfobar = options.openInfobar;
|
|
63
64
|
appendInfobar(document, infoData, true);
|
|
64
65
|
refreshInfobarInfo(document, infoData);
|
|
65
66
|
}
|