@ox-content/vite-plugin 3.0.0-alpha.16 → 3.0.0-alpha.18
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/dist/index.cjs +99 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -39
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +23 -39
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +38 -18
- package/dist/index.mjs.map +1 -1
- package/dist/markdown-tables.d.cts +13 -16
- package/dist/markdown-tables.d.cts.map +1 -1
- package/dist/markdown-tables.d.mts +13 -16
- package/dist/markdown-tables.d.mts.map +1 -1
- package/dist/napi.cjs +44 -0
- package/dist/napi.cjs.map +1 -0
- package/dist/napi.mjs +34 -0
- package/dist/napi.mjs.map +1 -0
- package/dist/reader-chrome-client.cjs +103 -0
- package/dist/reader-chrome-client.d.cts +2 -0
- package/dist/reader-chrome-client.d.mts +2 -0
- package/dist/reader-chrome-client.mjs +102 -0
- package/dist/reader-chrome.cjs +109 -0
- package/dist/reader-chrome.cjs.map +1 -0
- package/dist/reader-chrome.d.cts +103 -0
- package/dist/reader-chrome.d.mts +103 -0
- package/dist/reader-chrome.mjs +98 -0
- package/dist/reader-chrome.mjs.map +1 -0
- package/dist/styles/all.css +2 -0
- package/dist/styles/core.css +53 -1
- package/dist/styles/reader-chrome.css +163 -0
- package/dist/styles/theme-transition.css +37 -0
- package/dist/styles/twitter-full.css +87 -13
- package/dist/theme-tokens.d.cts +18 -21
- package/dist/theme-tokens.d.cts.map +1 -1
- package/dist/theme-tokens.d.mts +18 -21
- package/dist/theme-tokens.d.mts.map +1 -1
- package/dist/theme-transition-client.cjs +161 -0
- package/dist/theme-transition-client.d.cts +21 -0
- package/dist/theme-transition-client.d.mts +21 -0
- package/dist/theme-transition-client.mjs +160 -0
- package/dist/twitter-client.cjs +84 -0
- package/dist/twitter-client.d.cts +11 -0
- package/dist/twitter-client.d.mts +11 -0
- package/dist/twitter-client.mjs +83 -0
- package/dist/vitepress.cjs +5 -43
- package/dist/vitepress.cjs.map +1 -1
- package/dist/vitepress.mjs +5 -31
- package/dist/vitepress.mjs.map +1 -1
- package/package.json +46 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Generated from crates/ox_content_ssg/src/html/plugins/twitter.js.
|
|
2
|
+
// Run npm/vite-plugin-ox-content/scripts/build-twitter-client.mjs.
|
|
3
|
+
|
|
4
|
+
const TWEET_COPY_RESET_MS = 6000;
|
|
5
|
+
const oxTweetInitializedRoots = new WeakSet();
|
|
6
|
+
const oxTweetCopyResetTimers = new WeakMap();
|
|
7
|
+
const oxTweetHandledEvents = new WeakSet();
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line no-unused-vars
|
|
10
|
+
function initTweetCards(rootInput, options) {
|
|
11
|
+
const fallbackDocument = typeof document === "undefined" ? undefined : document;
|
|
12
|
+
const root = rootInput ?? fallbackDocument;
|
|
13
|
+
if (!root || oxTweetInitializedRoots.has(root) || typeof root.addEventListener !== "function") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
oxTweetInitializedRoots.add(root);
|
|
18
|
+
const copiedMs =
|
|
19
|
+
options && Number.isFinite(options.copiedMs)
|
|
20
|
+
? Math.max(0, options.copiedMs)
|
|
21
|
+
: TWEET_COPY_RESET_MS;
|
|
22
|
+
const getClipboard = () =>
|
|
23
|
+
options && options.clipboard
|
|
24
|
+
? options.clipboard
|
|
25
|
+
: typeof navigator === "undefined"
|
|
26
|
+
? undefined
|
|
27
|
+
: navigator.clipboard;
|
|
28
|
+
|
|
29
|
+
root.addEventListener("click", (event) => {
|
|
30
|
+
if (oxTweetHandledEvents.has(event) || event.defaultPrevented) return;
|
|
31
|
+
const action = closestTweetCopyAction(event.target);
|
|
32
|
+
if (!action) return;
|
|
33
|
+
|
|
34
|
+
const url = action.getAttribute("data-ox-tweet-copy-url") || action.getAttribute("href");
|
|
35
|
+
const clipboard = getClipboard();
|
|
36
|
+
if (!url || !clipboard || typeof clipboard.writeText !== "function") return;
|
|
37
|
+
|
|
38
|
+
oxTweetHandledEvents.add(event);
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
clipboard
|
|
41
|
+
.writeText(url)
|
|
42
|
+
.then(() => setTweetCopyState(action, "copied", copiedMs))
|
|
43
|
+
.catch(() => setTweetCopyState(action, "failed", copiedMs));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line no-unused-vars
|
|
48
|
+
const initTwitterCards = initTweetCards;
|
|
49
|
+
|
|
50
|
+
function closestTweetCopyAction(target) {
|
|
51
|
+
if (!target || typeof target.closest !== "function") return undefined;
|
|
52
|
+
const action = target.closest("[data-ox-tweet-copy]");
|
|
53
|
+
if (!action || typeof action.getAttribute !== "function") return undefined;
|
|
54
|
+
return action;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function setTweetCopyState(action, state, copiedMs) {
|
|
58
|
+
const previousTimer = oxTweetCopyResetTimers.get(action);
|
|
59
|
+
if (previousTimer) clearTimeout(previousTimer);
|
|
60
|
+
|
|
61
|
+
const label = state === "copied" ? "Copied!" : state === "failed" ? "Copy failed" : "Copy link";
|
|
62
|
+
const status =
|
|
63
|
+
typeof action.querySelector === "function"
|
|
64
|
+
? action.querySelector("[data-ox-tweet-copy-status]")
|
|
65
|
+
: undefined;
|
|
66
|
+
|
|
67
|
+
if (state === "copied") action.setAttribute("data-ox-tweet-copied", "");
|
|
68
|
+
else action.removeAttribute("data-ox-tweet-copied");
|
|
69
|
+
action.setAttribute("aria-label", label);
|
|
70
|
+
action.setAttribute("title", label);
|
|
71
|
+
if (status) status.textContent = state ? label : "";
|
|
72
|
+
|
|
73
|
+
if (state) {
|
|
74
|
+
oxTweetCopyResetTimers.set(
|
|
75
|
+
action,
|
|
76
|
+
setTimeout(() => setTweetCopyState(action, undefined, copiedMs), copiedMs),
|
|
77
|
+
);
|
|
78
|
+
} else {
|
|
79
|
+
oxTweetCopyResetTimers.delete(action);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { TWEET_COPY_RESET_MS, initTweetCards, initTwitterCards };
|
package/dist/vitepress.cjs
CHANGED
|
@@ -38,6 +38,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
}) : target, mod));
|
|
39
39
|
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
40
|
//#endregion
|
|
41
|
+
const require_napi = require("./napi.cjs");
|
|
41
42
|
const require_theme_tokens = require("./theme-tokens.cjs");
|
|
42
43
|
let node_module = require("node:module");
|
|
43
44
|
let node_fs = require("node:fs");
|
|
@@ -45,36 +46,6 @@ let node_path = require("node:path");
|
|
|
45
46
|
let node_crypto = require("node:crypto");
|
|
46
47
|
let node_fs_promises = require("node:fs/promises");
|
|
47
48
|
let glob = require("glob");
|
|
48
|
-
//#region src/napi.ts
|
|
49
|
-
const requireNapi = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
50
|
-
function getDefaultExport(value) {
|
|
51
|
-
if (!value || typeof value !== "object" || !("default" in value)) return;
|
|
52
|
-
const defaultExport = value.default;
|
|
53
|
-
return defaultExport && typeof defaultExport === "object" ? defaultExport : void 0;
|
|
54
|
-
}
|
|
55
|
-
function normalizeNapiModule(mod) {
|
|
56
|
-
const defaultExport = getDefaultExport(mod);
|
|
57
|
-
return defaultExport ? {
|
|
58
|
-
...defaultExport,
|
|
59
|
-
...mod
|
|
60
|
-
} : mod;
|
|
61
|
-
}
|
|
62
|
-
async function importNapiModule() {
|
|
63
|
-
return normalizeNapiModule(await import("@ox-content/napi"));
|
|
64
|
-
}
|
|
65
|
-
let syncNapiModule;
|
|
66
|
-
function importNapiModuleSync() {
|
|
67
|
-
if (syncNapiModule) return syncNapiModule;
|
|
68
|
-
if (syncNapiModule === null) throw new Error("[ox-content] @ox-content/napi is required. Please ensure the NAPI module is built.");
|
|
69
|
-
try {
|
|
70
|
-
syncNapiModule = normalizeNapiModule(requireNapi("@ox-content/napi"));
|
|
71
|
-
return syncNapiModule;
|
|
72
|
-
} catch {
|
|
73
|
-
syncNapiModule = null;
|
|
74
|
-
throw new Error("[ox-content] @ox-content/napi is required. Please ensure the NAPI module is built.");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
//#endregion
|
|
78
49
|
//#region src/theme-fonts-acquire.ts
|
|
79
50
|
/**
|
|
80
51
|
* Resolve self-hosted faces from a local file / `@fontsource` directory or
|
|
@@ -709,6 +680,7 @@ function resolveHeaderNavItems(items, locale, defaultLocale) {
|
|
|
709
680
|
const defaultTheme = {
|
|
710
681
|
name: "default",
|
|
711
682
|
viewTransitions: true,
|
|
683
|
+
toggleTransition: false,
|
|
712
684
|
aside: false,
|
|
713
685
|
breadcrumbs: false,
|
|
714
686
|
headingPermalink: "hover",
|
|
@@ -850,6 +822,7 @@ function resolveTheme(config) {
|
|
|
850
822
|
return {
|
|
851
823
|
name: merged.name ?? "custom",
|
|
852
824
|
viewTransitions: merged.viewTransitions ?? defaultTheme.viewTransitions ?? true,
|
|
825
|
+
toggleTransition: merged.toggleTransition === "circle" ? "circle" : false,
|
|
853
826
|
aside: merged.aside ?? defaultTheme.aside ?? false,
|
|
854
827
|
breadcrumbs: resolveThemeFlag(merged.breadcrumbs),
|
|
855
828
|
headingPermalink: merged.headingPermalink === "always" ? "always" : "hover",
|
|
@@ -909,6 +882,7 @@ function themeToNapi(theme, locale, base, iconsEnabled = false) {
|
|
|
909
882
|
const socialLinks = socialLinksToNapi(theme.socialLinks);
|
|
910
883
|
return {
|
|
911
884
|
viewTransitions: theme.viewTransitions,
|
|
885
|
+
toggleTransition: theme.toggleTransition === "circle" ? "circle" : void 0,
|
|
912
886
|
aside: theme.aside,
|
|
913
887
|
breadcrumbs: theme.breadcrumbs,
|
|
914
888
|
headingPermalink: theme.headingPermalink,
|
|
@@ -1245,7 +1219,7 @@ function formatObjectKey(key) {
|
|
|
1245
1219
|
* Normalizes VitePress-specific frontmatter into ox-content's entry-page shape.
|
|
1246
1220
|
*/
|
|
1247
1221
|
function normalizeVitePressFrontmatter(frontmatter) {
|
|
1248
|
-
return importNapiModuleSync().normalizeVitePressFrontmatter(frontmatter);
|
|
1222
|
+
return require_napi.importNapiModuleSync().normalizeVitePressFrontmatter(frontmatter);
|
|
1249
1223
|
}
|
|
1250
1224
|
//#endregion
|
|
1251
1225
|
Object.defineProperty(exports, "__esmMin", {
|
|
@@ -1308,18 +1282,6 @@ Object.defineProperty(exports, "generateVitePressMigrationConfig", {
|
|
|
1308
1282
|
return generateVitePressMigrationConfig;
|
|
1309
1283
|
}
|
|
1310
1284
|
});
|
|
1311
|
-
Object.defineProperty(exports, "importNapiModule", {
|
|
1312
|
-
enumerable: true,
|
|
1313
|
-
get: function() {
|
|
1314
|
-
return importNapiModule;
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1317
|
-
Object.defineProperty(exports, "importNapiModuleSync", {
|
|
1318
|
-
enumerable: true,
|
|
1319
|
-
get: function() {
|
|
1320
|
-
return importNapiModuleSync;
|
|
1321
|
-
}
|
|
1322
|
-
});
|
|
1323
1285
|
Object.defineProperty(exports, "mergeThemes", {
|
|
1324
1286
|
enumerable: true,
|
|
1325
1287
|
get: function() {
|