@ox-content/vite-plugin 3.0.0-alpha.16 → 3.0.0-alpha.17

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.
Files changed (46) hide show
  1. package/dist/index.cjs +98 -69
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +3 -5693
  4. package/dist/index.d.cts.map +1 -1
  5. package/dist/index.d.mts +3 -5693
  6. package/dist/index.d.mts.map +1 -1
  7. package/dist/index.mjs +37 -18
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/markdown-tables.d.cts +13 -16
  10. package/dist/markdown-tables.d.cts.map +1 -1
  11. package/dist/markdown-tables.d.mts +13 -16
  12. package/dist/markdown-tables.d.mts.map +1 -1
  13. package/dist/napi.cjs +44 -0
  14. package/dist/napi.cjs.map +1 -0
  15. package/dist/napi.mjs +34 -0
  16. package/dist/napi.mjs.map +1 -0
  17. package/dist/reader-chrome-client.cjs +103 -0
  18. package/dist/reader-chrome-client.d.cts +2 -0
  19. package/dist/reader-chrome-client.d.mts +2 -0
  20. package/dist/reader-chrome-client.mjs +102 -0
  21. package/dist/reader-chrome.cjs +109 -0
  22. package/dist/reader-chrome.cjs.map +1 -0
  23. package/dist/reader-chrome.d.cts +5748 -0
  24. package/dist/reader-chrome.d.cts.map +1 -0
  25. package/dist/reader-chrome.d.mts +5748 -0
  26. package/dist/reader-chrome.d.mts.map +1 -0
  27. package/dist/reader-chrome.mjs +98 -0
  28. package/dist/reader-chrome.mjs.map +1 -0
  29. package/dist/reader-chrome2.d.cts +2 -0
  30. package/dist/reader-chrome2.d.mts +2 -0
  31. package/dist/styles/all.css +1 -0
  32. package/dist/styles/reader-chrome.css +160 -0
  33. package/dist/styles/twitter-full.css +65 -9
  34. package/dist/theme-tokens.d.cts +18 -21
  35. package/dist/theme-tokens.d.cts.map +1 -1
  36. package/dist/theme-tokens.d.mts +18 -21
  37. package/dist/theme-tokens.d.mts.map +1 -1
  38. package/dist/theme-tokens2.d.cts +75 -0
  39. package/dist/theme-tokens2.d.cts.map +1 -0
  40. package/dist/theme-tokens2.d.mts +75 -0
  41. package/dist/theme-tokens2.d.mts.map +1 -0
  42. package/dist/vitepress.cjs +2 -43
  43. package/dist/vitepress.cjs.map +1 -1
  44. package/dist/vitepress.mjs +2 -31
  45. package/dist/vitepress.mjs.map +1 -1
  46. package/package.json +25 -4
@@ -0,0 +1,75 @@
1
+ //#region src/theme-tokens.d.ts
2
+ /**
3
+ * Free-form `--octc-*` custom properties for themes that need more than the
4
+ * typed `colors` / `fonts` / `layout` fields.
5
+ *
6
+ * Keys are written **without** the `--octc-` prefix, so `"surface-glass"`
7
+ * becomes `--octc-surface-glass`. This is the seam that keeps the two theme
8
+ * axes independent: a color package can restyle code-block line markers, brand
9
+ * accents, and surface textures purely through tokens, while a skin package
10
+ * lays out geometry against those same tokens without knowing any color.
11
+ */
12
+ type ThemeTokens = Record<string, string>;
13
+ /**
14
+ * The token-bearing shape of a theme.
15
+ *
16
+ * Declared structurally instead of importing `ThemeConfig` so this module keeps
17
+ * an empty import graph: `@ox-content/vite-plugin/theme-tokens` has to be
18
+ * loadable by a bare (`ssg.bare: true`) or custom host that never pulls in the
19
+ * Vite plugin, the SSG, the native binding, or a filesystem API. Every
20
+ * `ThemeConfig` — including the published `@ox-content/theme-color-*` and
21
+ * `@ox-content/theme-*` packages — satisfies it.
22
+ */
23
+ interface ThemeTokenSource {
24
+ tokens?: ThemeTokens;
25
+ darkTokens?: ThemeTokens;
26
+ extends?: ThemeTokenSource;
27
+ }
28
+ /**
29
+ * Options for {@link renderThemeTokenCss}.
30
+ */
31
+ interface RenderThemeTokenCssOptions {
32
+ /**
33
+ * Keeps only the tokens whose name passes the predicate. Names arrive without
34
+ * the `--octc-` prefix, so `(name) => name.startsWith("syntax-")` reuses a
35
+ * color scheme's highlighter palette without adopting its page colors,
36
+ * typography, or layout policy.
37
+ *
38
+ * Filtering runs per layer, before merging, so a token a later layer would
39
+ * have overridden is dropped along with the override.
40
+ */
41
+ include?: (name: string) => boolean;
42
+ }
43
+ /**
44
+ * Renders a theme's `--octc-*` tokens as a standalone stylesheet.
45
+ *
46
+ * The built-in SSG emits these declarations itself, but `ssg.bare: true` and
47
+ * custom hosts render their own document — this is how they get the same
48
+ * tokens. The built-in highlighter emits `var(--octc-syntax-*)` references, so
49
+ * a bare host that wants only the highlighter palette can ask for it:
50
+ *
51
+ * ```ts
52
+ * import { renderThemeTokenCss } from "@ox-content/vite-plugin/theme-tokens";
53
+ * import { kanagawa } from "@ox-content/theme-color-kanagawa";
54
+ *
55
+ * const css = renderThemeTokenCss(kanagawa, {
56
+ * include: (name) => name.startsWith("syntax-"),
57
+ * });
58
+ * ```
59
+ *
60
+ * Layers compose left to right and each layer's `extends` chain is flattened
61
+ * base-first, matching how `resolveTheme()` stacks a skin and a color scheme.
62
+ */
63
+ declare function renderThemeTokenCss(theme: ThemeTokenSource | ThemeTokenSource[], options?: RenderThemeTokenCssOptions): string;
64
+ /**
65
+ * Renders light and dark token records as the three selectors the SSG runtime
66
+ * switches between: an explicit `[data-theme="dark"]` opt-in, the OS
67
+ * `prefers-color-scheme` fallback, and the `:root` base.
68
+ *
69
+ * Emitted after the typed color variables and before the theme's own `css`, so
70
+ * a token can override a typed color and raw `css` can override a token.
71
+ */
72
+ declare function tokensToCss(light: ThemeTokens, dark: ThemeTokens): string;
73
+ //#endregion
74
+ export { tokensToCss as a, renderThemeTokenCss as i, ThemeTokenSource as n, ThemeTokens as r, RenderThemeTokenCssOptions as t };
75
+ //# sourceMappingURL=theme-tokens2.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-tokens2.d.cts","names":[],"sources":["../src/theme-tokens.ts"],"mappings":";;;;;;;;;;;KAUY,cAAc;;;;;;;;;;;UAeT;EACf,SAAS;EACT,aAAa;EACb,UAAU;;;;;UAMK;;;;;;;;;;EAUf,WAAW;;;;;;;;;;;;;;;;;;;;;;iBAuBG,oBACd,OAAO,mBAAmB,oBAC1B,UAAS;;;;;;;;;iBAiBK,YAAY,OAAO,aAAa,MAAM"}
@@ -0,0 +1,75 @@
1
+ //#region src/theme-tokens.d.ts
2
+ /**
3
+ * Free-form `--octc-*` custom properties for themes that need more than the
4
+ * typed `colors` / `fonts` / `layout` fields.
5
+ *
6
+ * Keys are written **without** the `--octc-` prefix, so `"surface-glass"`
7
+ * becomes `--octc-surface-glass`. This is the seam that keeps the two theme
8
+ * axes independent: a color package can restyle code-block line markers, brand
9
+ * accents, and surface textures purely through tokens, while a skin package
10
+ * lays out geometry against those same tokens without knowing any color.
11
+ */
12
+ type ThemeTokens = Record<string, string>;
13
+ /**
14
+ * The token-bearing shape of a theme.
15
+ *
16
+ * Declared structurally instead of importing `ThemeConfig` so this module keeps
17
+ * an empty import graph: `@ox-content/vite-plugin/theme-tokens` has to be
18
+ * loadable by a bare (`ssg.bare: true`) or custom host that never pulls in the
19
+ * Vite plugin, the SSG, the native binding, or a filesystem API. Every
20
+ * `ThemeConfig` — including the published `@ox-content/theme-color-*` and
21
+ * `@ox-content/theme-*` packages — satisfies it.
22
+ */
23
+ interface ThemeTokenSource {
24
+ tokens?: ThemeTokens;
25
+ darkTokens?: ThemeTokens;
26
+ extends?: ThemeTokenSource;
27
+ }
28
+ /**
29
+ * Options for {@link renderThemeTokenCss}.
30
+ */
31
+ interface RenderThemeTokenCssOptions {
32
+ /**
33
+ * Keeps only the tokens whose name passes the predicate. Names arrive without
34
+ * the `--octc-` prefix, so `(name) => name.startsWith("syntax-")` reuses a
35
+ * color scheme's highlighter palette without adopting its page colors,
36
+ * typography, or layout policy.
37
+ *
38
+ * Filtering runs per layer, before merging, so a token a later layer would
39
+ * have overridden is dropped along with the override.
40
+ */
41
+ include?: (name: string) => boolean;
42
+ }
43
+ /**
44
+ * Renders a theme's `--octc-*` tokens as a standalone stylesheet.
45
+ *
46
+ * The built-in SSG emits these declarations itself, but `ssg.bare: true` and
47
+ * custom hosts render their own document — this is how they get the same
48
+ * tokens. The built-in highlighter emits `var(--octc-syntax-*)` references, so
49
+ * a bare host that wants only the highlighter palette can ask for it:
50
+ *
51
+ * ```ts
52
+ * import { renderThemeTokenCss } from "@ox-content/vite-plugin/theme-tokens";
53
+ * import { kanagawa } from "@ox-content/theme-color-kanagawa";
54
+ *
55
+ * const css = renderThemeTokenCss(kanagawa, {
56
+ * include: (name) => name.startsWith("syntax-"),
57
+ * });
58
+ * ```
59
+ *
60
+ * Layers compose left to right and each layer's `extends` chain is flattened
61
+ * base-first, matching how `resolveTheme()` stacks a skin and a color scheme.
62
+ */
63
+ declare function renderThemeTokenCss(theme: ThemeTokenSource | ThemeTokenSource[], options?: RenderThemeTokenCssOptions): string;
64
+ /**
65
+ * Renders light and dark token records as the three selectors the SSG runtime
66
+ * switches between: an explicit `[data-theme="dark"]` opt-in, the OS
67
+ * `prefers-color-scheme` fallback, and the `:root` base.
68
+ *
69
+ * Emitted after the typed color variables and before the theme's own `css`, so
70
+ * a token can override a typed color and raw `css` can override a token.
71
+ */
72
+ declare function tokensToCss(light: ThemeTokens, dark: ThemeTokens): string;
73
+ //#endregion
74
+ export { tokensToCss as a, renderThemeTokenCss as i, ThemeTokenSource as n, ThemeTokens as r, RenderThemeTokenCssOptions as t };
75
+ //# sourceMappingURL=theme-tokens2.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-tokens2.d.mts","names":[],"sources":["../src/theme-tokens.ts"],"mappings":";;;;;;;;;;;KAUY,cAAc;;;;;;;;;;;UAeT;EACf,SAAS;EACT,aAAa;EACb,UAAU;;;;;UAMK;;;;;;;;;;EAUf,WAAW;;;;;;;;;;;;;;;;;;;;;;iBAuBG,oBACd,OAAO,mBAAmB,oBAC1B,UAAS;;;;;;;;;iBAiBK,YAAY,OAAO,aAAa,MAAM"}
@@ -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
@@ -1245,7 +1216,7 @@ function formatObjectKey(key) {
1245
1216
  * Normalizes VitePress-specific frontmatter into ox-content's entry-page shape.
1246
1217
  */
1247
1218
  function normalizeVitePressFrontmatter(frontmatter) {
1248
- return importNapiModuleSync().normalizeVitePressFrontmatter(frontmatter);
1219
+ return require_napi.importNapiModuleSync().normalizeVitePressFrontmatter(frontmatter);
1249
1220
  }
1250
1221
  //#endregion
1251
1222
  Object.defineProperty(exports, "__esmMin", {
@@ -1308,18 +1279,6 @@ Object.defineProperty(exports, "generateVitePressMigrationConfig", {
1308
1279
  return generateVitePressMigrationConfig;
1309
1280
  }
1310
1281
  });
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
1282
  Object.defineProperty(exports, "mergeThemes", {
1324
1283
  enumerable: true,
1325
1284
  get: function() {