single-file-core 1.5.94 → 1.5.95
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.
|
@@ -17187,6 +17187,10 @@ async function evalTemplate(template = "", options, content, doc, context = {})
|
|
|
17187
17187
|
variables[prefix + "minutes-utc"] = { getter: () => String(date.getUTCMinutes()).padStart(2, "0") };
|
|
17188
17188
|
variables[prefix + "seconds-utc"] = { getter: () => String(date.getUTCSeconds()).padStart(2, "0") };
|
|
17189
17189
|
variables[prefix + "time-ms"] = { getter: () => String(date.getTime()) };
|
|
17190
|
+
variables[prefix + "weekday-locale"] = { getter: () => date.toLocaleDateString(undefined, { weekday: "long" }) };
|
|
17191
|
+
variables[prefix + "weekday-short-locale"] = { getter: () => date.toLocaleDateString(undefined, { weekday: "short" }) };
|
|
17192
|
+
variables[prefix + "weekday-utc"] = { getter: () => date.toLocaleDateString(undefined, { weekday: "long", timeZone: "UTC" }) };
|
|
17193
|
+
variables[prefix + "weekday-short-utc"] = { getter: () => date.toLocaleDateString(undefined, { weekday: "short", timeZone: "UTC" }) };
|
|
17190
17194
|
}
|
|
17191
17195
|
}
|
|
17192
17196
|
|
package/package.json
CHANGED
|
@@ -69,6 +69,7 @@ async function router(content, { extract, display }) {
|
|
|
69
69
|
const manifest = JSON.parse(await pagesEntry.getData(new zip.TextWriter()));
|
|
70
70
|
const tocEntry = entries.find(entry => entry.filename == TOC_FILENAME);
|
|
71
71
|
const { pages } = manifest;
|
|
72
|
+
const pageTransitions = manifest.pageTransitions || "auto";
|
|
72
73
|
const aliases = new Map(Object.entries(manifest.aliases || {}));
|
|
73
74
|
pages.forEach(page => {
|
|
74
75
|
urlToPath.set(stripFragment(page.url), page.path);
|
|
@@ -141,7 +142,7 @@ async function router(content, { extract, display }) {
|
|
|
141
142
|
const willRender = routed && path != currentPath && isRenderablePath(path);
|
|
142
143
|
// the whole render and scroll sequence runs inside the view transition
|
|
143
144
|
// so that the crossfade ends on the final scroll position
|
|
144
|
-
if (willRender && document.startViewTransition && !prefersReducedMotion()) {
|
|
145
|
+
if (willRender && document.startViewTransition && pageTransitionEnabled() && !prefersReducedMotion()) {
|
|
145
146
|
await document.startViewTransition(update).updateCallbackDone;
|
|
146
147
|
} else {
|
|
147
148
|
await update();
|
|
@@ -324,6 +325,30 @@ async function router(content, { extract, display }) {
|
|
|
324
325
|
return node;
|
|
325
326
|
}
|
|
326
327
|
|
|
328
|
+
// "auto" approximates the cross-document opt-in of live sites: the transition
|
|
329
|
+
// runs when the displayed page itself contains an @view-transition rule set
|
|
330
|
+
// to navigation: auto, so pages without transitions stay instant
|
|
331
|
+
function pageTransitionEnabled() {
|
|
332
|
+
if (pageTransitions == "fade") {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
if (pageTransitions == "none") {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
return Array.from(document.styleSheets).some(styleSheet => {
|
|
339
|
+
try {
|
|
340
|
+
return containsViewTransitionRule(styleSheet.cssRules);
|
|
341
|
+
} catch {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function containsViewTransitionRule(cssRules) {
|
|
348
|
+
return Array.from(cssRules).some(cssRule => cssRule.navigation == "auto" ||
|
|
349
|
+
(cssRule.cssRules && cssRule.cssRules.length && containsViewTransitionRule(cssRule.cssRules)));
|
|
350
|
+
}
|
|
351
|
+
|
|
327
352
|
function prefersReducedMotion() {
|
|
328
353
|
return Boolean(globalThis.matchMedia && globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
|
329
354
|
}
|