@ox-content/vite-plugin 3.0.0-alpha.17 → 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 +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5677 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5677 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/reader-chrome.cjs.map +1 -1
- package/dist/reader-chrome.d.cts +58 -5703
- package/dist/reader-chrome.d.mts +58 -5703
- package/dist/reader-chrome.mjs.map +1 -1
- package/dist/styles/all.css +1 -0
- package/dist/styles/core.css +53 -1
- package/dist/styles/reader-chrome.css +12 -9
- package/dist/styles/theme-transition.css +37 -0
- package/dist/styles/twitter-full.css +22 -4
- 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 +3 -0
- package/dist/vitepress.cjs.map +1 -1
- package/dist/vitepress.mjs +3 -0
- package/dist/vitepress.mjs.map +1 -1
- package/package.json +25 -4
- package/dist/reader-chrome.d.cts.map +0 -1
- package/dist/reader-chrome.d.mts.map +0 -1
- package/dist/reader-chrome2.d.cts +0 -2
- package/dist/reader-chrome2.d.mts +0 -2
- package/dist/theme-tokens2.d.cts +0 -75
- package/dist/theme-tokens2.d.cts.map +0 -1
- package/dist/theme-tokens2.d.mts +0 -75
- package/dist/theme-tokens2.d.mts.map +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
"use strict";
|
|
5
|
+
const TWEET_COPY_RESET_MS = 6000;
|
|
6
|
+
const oxTweetInitializedRoots = new WeakSet();
|
|
7
|
+
const oxTweetCopyResetTimers = new WeakMap();
|
|
8
|
+
const oxTweetHandledEvents = new WeakSet();
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line no-unused-vars
|
|
11
|
+
function initTweetCards(rootInput, options) {
|
|
12
|
+
const fallbackDocument = typeof document === "undefined" ? undefined : document;
|
|
13
|
+
const root = rootInput ?? fallbackDocument;
|
|
14
|
+
if (!root || oxTweetInitializedRoots.has(root) || typeof root.addEventListener !== "function") {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
oxTweetInitializedRoots.add(root);
|
|
19
|
+
const copiedMs =
|
|
20
|
+
options && Number.isFinite(options.copiedMs)
|
|
21
|
+
? Math.max(0, options.copiedMs)
|
|
22
|
+
: TWEET_COPY_RESET_MS;
|
|
23
|
+
const getClipboard = () =>
|
|
24
|
+
options && options.clipboard
|
|
25
|
+
? options.clipboard
|
|
26
|
+
: typeof navigator === "undefined"
|
|
27
|
+
? undefined
|
|
28
|
+
: navigator.clipboard;
|
|
29
|
+
|
|
30
|
+
root.addEventListener("click", (event) => {
|
|
31
|
+
if (oxTweetHandledEvents.has(event) || event.defaultPrevented) return;
|
|
32
|
+
const action = closestTweetCopyAction(event.target);
|
|
33
|
+
if (!action) return;
|
|
34
|
+
|
|
35
|
+
const url = action.getAttribute("data-ox-tweet-copy-url") || action.getAttribute("href");
|
|
36
|
+
const clipboard = getClipboard();
|
|
37
|
+
if (!url || !clipboard || typeof clipboard.writeText !== "function") return;
|
|
38
|
+
|
|
39
|
+
oxTweetHandledEvents.add(event);
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
clipboard
|
|
42
|
+
.writeText(url)
|
|
43
|
+
.then(() => setTweetCopyState(action, "copied", copiedMs))
|
|
44
|
+
.catch(() => setTweetCopyState(action, "failed", copiedMs));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line no-unused-vars
|
|
49
|
+
const initTwitterCards = initTweetCards;
|
|
50
|
+
|
|
51
|
+
function closestTweetCopyAction(target) {
|
|
52
|
+
if (!target || typeof target.closest !== "function") return undefined;
|
|
53
|
+
const action = target.closest("[data-ox-tweet-copy]");
|
|
54
|
+
if (!action || typeof action.getAttribute !== "function") return undefined;
|
|
55
|
+
return action;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function setTweetCopyState(action, state, copiedMs) {
|
|
59
|
+
const previousTimer = oxTweetCopyResetTimers.get(action);
|
|
60
|
+
if (previousTimer) clearTimeout(previousTimer);
|
|
61
|
+
|
|
62
|
+
const label = state === "copied" ? "Copied!" : state === "failed" ? "Copy failed" : "Copy link";
|
|
63
|
+
const status =
|
|
64
|
+
typeof action.querySelector === "function"
|
|
65
|
+
? action.querySelector("[data-ox-tweet-copy-status]")
|
|
66
|
+
: undefined;
|
|
67
|
+
|
|
68
|
+
if (state === "copied") action.setAttribute("data-ox-tweet-copied", "");
|
|
69
|
+
else action.removeAttribute("data-ox-tweet-copied");
|
|
70
|
+
action.setAttribute("aria-label", label);
|
|
71
|
+
action.setAttribute("title", label);
|
|
72
|
+
if (status) status.textContent = state ? label : "";
|
|
73
|
+
|
|
74
|
+
if (state) {
|
|
75
|
+
oxTweetCopyResetTimers.set(
|
|
76
|
+
action,
|
|
77
|
+
setTimeout(() => setTweetCopyState(action, undefined, copiedMs), copiedMs),
|
|
78
|
+
);
|
|
79
|
+
} else {
|
|
80
|
+
oxTweetCopyResetTimers.delete(action);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = { TWEET_COPY_RESET_MS, initTweetCards, initTwitterCards };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type TweetCardsRoot = Document | Element;
|
|
2
|
+
export interface InitTweetCardsOptions {
|
|
3
|
+
clipboard?: Pick<Clipboard, "writeText">;
|
|
4
|
+
copiedMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const TWEET_COPY_RESET_MS = 6000;
|
|
7
|
+
export declare function initTweetCards(
|
|
8
|
+
root?: TweetCardsRoot,
|
|
9
|
+
options?: InitTweetCardsOptions,
|
|
10
|
+
): void;
|
|
11
|
+
export declare const initTwitterCards: typeof initTweetCards;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type TweetCardsRoot = Document | Element;
|
|
2
|
+
export interface InitTweetCardsOptions {
|
|
3
|
+
clipboard?: Pick<Clipboard, "writeText">;
|
|
4
|
+
copiedMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const TWEET_COPY_RESET_MS = 6000;
|
|
7
|
+
export declare function initTweetCards(
|
|
8
|
+
root?: TweetCardsRoot,
|
|
9
|
+
options?: InitTweetCardsOptions,
|
|
10
|
+
): void;
|
|
11
|
+
export declare const initTwitterCards: typeof initTweetCards;
|
|
@@ -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
|
@@ -680,6 +680,7 @@ function resolveHeaderNavItems(items, locale, defaultLocale) {
|
|
|
680
680
|
const defaultTheme = {
|
|
681
681
|
name: "default",
|
|
682
682
|
viewTransitions: true,
|
|
683
|
+
toggleTransition: false,
|
|
683
684
|
aside: false,
|
|
684
685
|
breadcrumbs: false,
|
|
685
686
|
headingPermalink: "hover",
|
|
@@ -821,6 +822,7 @@ function resolveTheme(config) {
|
|
|
821
822
|
return {
|
|
822
823
|
name: merged.name ?? "custom",
|
|
823
824
|
viewTransitions: merged.viewTransitions ?? defaultTheme.viewTransitions ?? true,
|
|
825
|
+
toggleTransition: merged.toggleTransition === "circle" ? "circle" : false,
|
|
824
826
|
aside: merged.aside ?? defaultTheme.aside ?? false,
|
|
825
827
|
breadcrumbs: resolveThemeFlag(merged.breadcrumbs),
|
|
826
828
|
headingPermalink: merged.headingPermalink === "always" ? "always" : "hover",
|
|
@@ -880,6 +882,7 @@ function themeToNapi(theme, locale, base, iconsEnabled = false) {
|
|
|
880
882
|
const socialLinks = socialLinksToNapi(theme.socialLinks);
|
|
881
883
|
return {
|
|
882
884
|
viewTransitions: theme.viewTransitions,
|
|
885
|
+
toggleTransition: theme.toggleTransition === "circle" ? "circle" : void 0,
|
|
883
886
|
aside: theme.aside,
|
|
884
887
|
breadcrumbs: theme.breadcrumbs,
|
|
885
888
|
headingPermalink: theme.headingPermalink,
|