@ox-content/vite-plugin 2.26.0 → 2.28.0

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/pm.cjs ADDED
@@ -0,0 +1,45 @@
1
+ const require_chunk = require("./chunk.cjs");
2
+ const require_napi = require("./napi.cjs");
3
+ const require_tabs = require("./tabs.cjs");
4
+ //#region src/plugins/pm.ts
5
+ /**
6
+ * Package Manager Tabs Plugin
7
+ *
8
+ * Transforms <pm>npm install …</pm> blocks into a tab group with one tab per
9
+ * package manager (npm/pnpm/yarn/bun). The single npm-style command is converted
10
+ * to each package manager's equivalent natively in Rust (`transformPmEmbeds` in
11
+ * @ox-content/napi), and the result reuses the same `ox-tabs` widget markup as
12
+ * the generic `<tabs>` plugin so styling and keyboard navigation are consistent.
13
+ *
14
+ * Syncing is opt-in (off by default): when enabled, the rendered group carries a
15
+ * `data-ox-tab-group="pkg-manager"` attribute so the client runtime can keep
16
+ * every package-manager group on the page in sync via localStorage.
17
+ *
18
+ * Package-manager groups share the tab-group counter with the `<tabs>` plugin so
19
+ * `data-group` ids (and the CSS produced by `generateTabsCSS`) stay unique.
20
+ */
21
+ var pm_exports = /* @__PURE__ */ require_chunk.__exportAll({ transformPm: () => transformPm });
22
+ /**
23
+ * Transform `<pm>` package-manager blocks in HTML into install tabs.
24
+ *
25
+ * @param html - Rendered HTML potentially containing `<pm>` blocks.
26
+ * @param options - Package-manager tab options (syncing is opt-in).
27
+ * @returns The rewritten HTML.
28
+ */
29
+ async function transformPm(html, options) {
30
+ if (!/<pm[\s/>]/i.test(html)) return html;
31
+ const mod = await require_napi.importNapiModule();
32
+ const startGroup = require_tabs.getTabGroupCounter();
33
+ const result = mod.transformPmEmbeds(html, startGroup, { sync: options?.sync ?? false });
34
+ require_tabs.setTabGroupCounter(startGroup + result.groupCount);
35
+ return result.html;
36
+ }
37
+ //#endregion
38
+ Object.defineProperty(exports, "pm_exports", {
39
+ enumerable: true,
40
+ get: function() {
41
+ return pm_exports;
42
+ }
43
+ });
44
+
45
+ //# sourceMappingURL=pm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pm.cjs","names":["importNapiModule","getTabGroupCounter"],"sources":["../src/plugins/pm.ts"],"sourcesContent":["/**\n * Package Manager Tabs Plugin\n *\n * Transforms <pm>npm install …</pm> blocks into a tab group with one tab per\n * package manager (npm/pnpm/yarn/bun). The single npm-style command is converted\n * to each package manager's equivalent natively in Rust (`transformPmEmbeds` in\n * @ox-content/napi), and the result reuses the same `ox-tabs` widget markup as\n * the generic `<tabs>` plugin so styling and keyboard navigation are consistent.\n *\n * Syncing is opt-in (off by default): when enabled, the rendered group carries a\n * `data-ox-tab-group=\"pkg-manager\"` attribute so the client runtime can keep\n * every package-manager group on the page in sync via localStorage.\n *\n * Package-manager groups share the tab-group counter with the `<tabs>` plugin so\n * `data-group` ids (and the CSS produced by `generateTabsCSS`) stay unique.\n */\n\nimport { importNapiModule } from \"../napi\";\nimport { getTabGroupCounter, setTabGroupCounter } from \"./tabs\";\n\n/** Options for {@link transformPm}. */\nexport interface PmOptions {\n /**\n * Enable opt-in synced package-manager tab groups. When `true`, a\n * `data-ox-tab-group=\"pkg-manager\"` attribute is emitted so the client runtime\n * syncs the active package manager across every pm group on the page and\n * persists the choice in localStorage. Default: false.\n */\n sync?: boolean;\n}\n\n/**\n * Transform `<pm>` package-manager blocks in HTML into install tabs.\n *\n * @param html - Rendered HTML potentially containing `<pm>` blocks.\n * @param options - Package-manager tab options (syncing is opt-in).\n * @returns The rewritten HTML.\n */\nexport async function transformPm(html: string, options?: PmOptions): Promise<string> {\n // Cheap marker check: skip the NAPI call entirely when there's no `<pm>`\n // element. The Rust side guards the same way, but short-circuiting here avoids\n // marshalling the whole document across the boundary.\n if (!/<pm[\\s/>]/i.test(html)) {\n return html;\n }\n\n const mod = await importNapiModule();\n const startGroup = getTabGroupCounter();\n const result = mod.transformPmEmbeds(html, startGroup, {\n sync: options?.sync ?? false,\n });\n setTabGroupCounter(startGroup + result.groupCount);\n return result.html;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,eAAsB,YAAY,MAAc,SAAsC;CAIpF,IAAI,CAAC,aAAa,KAAK,KAAK,EAC1B,OAAO;CAGT,MAAM,MAAM,MAAMA,aAAAA,kBAAkB;CACpC,MAAM,aAAaC,aAAAA,oBAAoB;CACvC,MAAM,SAAS,IAAI,kBAAkB,MAAM,YAAY,EACrD,MAAM,SAAS,QAAQ,OACxB,CAAC;CACF,aAAA,mBAAmB,aAAa,OAAO,WAAW;CAClD,OAAO,OAAO"}
package/dist/pm.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { t as transformPm } from "./pm2.mjs";
2
+ export { transformPm };
package/dist/pm2.mjs ADDED
@@ -0,0 +1,38 @@
1
+ import { t as importNapiModule } from "./napi.mjs";
2
+ import { i as setTabGroupCounter, n as getTabGroupCounter } from "./tabs2.mjs";
3
+ //#region src/plugins/pm.ts
4
+ /**
5
+ * Package Manager Tabs Plugin
6
+ *
7
+ * Transforms <pm>npm install …</pm> blocks into a tab group with one tab per
8
+ * package manager (npm/pnpm/yarn/bun). The single npm-style command is converted
9
+ * to each package manager's equivalent natively in Rust (`transformPmEmbeds` in
10
+ * @ox-content/napi), and the result reuses the same `ox-tabs` widget markup as
11
+ * the generic `<tabs>` plugin so styling and keyboard navigation are consistent.
12
+ *
13
+ * Syncing is opt-in (off by default): when enabled, the rendered group carries a
14
+ * `data-ox-tab-group="pkg-manager"` attribute so the client runtime can keep
15
+ * every package-manager group on the page in sync via localStorage.
16
+ *
17
+ * Package-manager groups share the tab-group counter with the `<tabs>` plugin so
18
+ * `data-group` ids (and the CSS produced by `generateTabsCSS`) stay unique.
19
+ */
20
+ /**
21
+ * Transform `<pm>` package-manager blocks in HTML into install tabs.
22
+ *
23
+ * @param html - Rendered HTML potentially containing `<pm>` blocks.
24
+ * @param options - Package-manager tab options (syncing is opt-in).
25
+ * @returns The rewritten HTML.
26
+ */
27
+ async function transformPm(html, options) {
28
+ if (!/<pm[\s/>]/i.test(html)) return html;
29
+ const mod = await importNapiModule();
30
+ const startGroup = getTabGroupCounter();
31
+ const result = mod.transformPmEmbeds(html, startGroup, { sync: options?.sync ?? false });
32
+ setTabGroupCounter(startGroup + result.groupCount);
33
+ return result.html;
34
+ }
35
+ //#endregion
36
+ export { transformPm as t };
37
+
38
+ //# sourceMappingURL=pm2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pm2.mjs","names":[],"sources":["../src/plugins/pm.ts"],"sourcesContent":["/**\n * Package Manager Tabs Plugin\n *\n * Transforms <pm>npm install …</pm> blocks into a tab group with one tab per\n * package manager (npm/pnpm/yarn/bun). The single npm-style command is converted\n * to each package manager's equivalent natively in Rust (`transformPmEmbeds` in\n * @ox-content/napi), and the result reuses the same `ox-tabs` widget markup as\n * the generic `<tabs>` plugin so styling and keyboard navigation are consistent.\n *\n * Syncing is opt-in (off by default): when enabled, the rendered group carries a\n * `data-ox-tab-group=\"pkg-manager\"` attribute so the client runtime can keep\n * every package-manager group on the page in sync via localStorage.\n *\n * Package-manager groups share the tab-group counter with the `<tabs>` plugin so\n * `data-group` ids (and the CSS produced by `generateTabsCSS`) stay unique.\n */\n\nimport { importNapiModule } from \"../napi\";\nimport { getTabGroupCounter, setTabGroupCounter } from \"./tabs\";\n\n/** Options for {@link transformPm}. */\nexport interface PmOptions {\n /**\n * Enable opt-in synced package-manager tab groups. When `true`, a\n * `data-ox-tab-group=\"pkg-manager\"` attribute is emitted so the client runtime\n * syncs the active package manager across every pm group on the page and\n * persists the choice in localStorage. Default: false.\n */\n sync?: boolean;\n}\n\n/**\n * Transform `<pm>` package-manager blocks in HTML into install tabs.\n *\n * @param html - Rendered HTML potentially containing `<pm>` blocks.\n * @param options - Package-manager tab options (syncing is opt-in).\n * @returns The rewritten HTML.\n */\nexport async function transformPm(html: string, options?: PmOptions): Promise<string> {\n // Cheap marker check: skip the NAPI call entirely when there's no `<pm>`\n // element. The Rust side guards the same way, but short-circuiting here avoids\n // marshalling the whole document across the boundary.\n if (!/<pm[\\s/>]/i.test(html)) {\n return html;\n }\n\n const mod = await importNapiModule();\n const startGroup = getTabGroupCounter();\n const result = mod.transformPmEmbeds(html, startGroup, {\n sync: options?.sync ?? false,\n });\n setTabGroupCounter(startGroup + result.groupCount);\n return result.html;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,eAAsB,YAAY,MAAc,SAAsC;CAIpF,IAAI,CAAC,aAAa,KAAK,KAAK,EAC1B,OAAO;CAGT,MAAM,MAAM,MAAM,kBAAkB;CACpC,MAAM,aAAa,oBAAoB;CACvC,MAAM,SAAS,IAAI,kBAAkB,MAAM,YAAY,EACrD,MAAM,SAAS,QAAQ,OACxB,CAAC;CACF,mBAAmB,aAAa,OAAO,WAAW;CAClD,OAAO,OAAO"}
package/dist/tabs.cjs CHANGED
@@ -15,7 +15,9 @@ const require_napi = require("./napi.cjs");
15
15
  */
16
16
  var tabs_exports = /* @__PURE__ */ require_chunk.__exportAll({
17
17
  generateTabsCSS: () => generateTabsCSS,
18
+ getTabGroupCounter: () => getTabGroupCounter,
18
19
  resetTabGroupCounter: () => resetTabGroupCounter,
20
+ setTabGroupCounter: () => setTabGroupCounter,
19
21
  transformTabs: () => transformTabs
20
22
  });
21
23
  let tabGroupCounter = 0;
@@ -26,6 +28,18 @@ function resetTabGroupCounter() {
26
28
  tabGroupCounter = 0;
27
29
  }
28
30
  /**
31
+ * Read the shared tab group counter. Other tab-like transforms (such as the
32
+ * package-manager tabs) share this counter so `data-group` ids and the CSS
33
+ * generated by {@link generateTabsCSS} stay unique across a page.
34
+ */
35
+ function getTabGroupCounter() {
36
+ return tabGroupCounter;
37
+ }
38
+ /** Set the shared tab group counter (advanced by other tab-like transforms). */
39
+ function setTabGroupCounter(value) {
40
+ tabGroupCounter = value;
41
+ }
42
+ /**
29
43
  * Transform Tabs components in HTML.
30
44
  */
31
45
  async function transformTabs(html) {
@@ -51,12 +65,24 @@ Object.defineProperty(exports, "generateTabsCSS", {
51
65
  return generateTabsCSS;
52
66
  }
53
67
  });
68
+ Object.defineProperty(exports, "getTabGroupCounter", {
69
+ enumerable: true,
70
+ get: function() {
71
+ return getTabGroupCounter;
72
+ }
73
+ });
54
74
  Object.defineProperty(exports, "resetTabGroupCounter", {
55
75
  enumerable: true,
56
76
  get: function() {
57
77
  return resetTabGroupCounter;
58
78
  }
59
79
  });
80
+ Object.defineProperty(exports, "setTabGroupCounter", {
81
+ enumerable: true,
82
+ get: function() {
83
+ return setTabGroupCounter;
84
+ }
85
+ });
60
86
  Object.defineProperty(exports, "tabs_exports", {
61
87
  enumerable: true,
62
88
  get: function() {
package/dist/tabs.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.cjs","names":["importNapiModule"],"sources":["../src/plugins/tabs.ts"],"sourcesContent":["/**\n * Tabs Plugin - Pure CSS implementation\n *\n * Transforms <Tabs>/<Tab> components into accessible HTML with CSS :has()\n * based tab switching (no JavaScript required).\n *\n * The HTML rewrite is performed in Rust (`transformTabsEmbeds` in\n * @ox-content/napi), replacing the previous rehype parse/stringify round-trip.\n * The per-build group counter (consumed by `generateTabsCSS`) stays here and is\n * advanced by the number of groups the Rust transform reports, so CSS\n * generation still covers exactly the groups that were emitted.\n */\n\nimport { importNapiModule } from \"../napi\";\n\nlet tabGroupCounter = 0;\n\n/**\n * Reset tab group counter (for testing and per dev-server request).\n */\nexport function resetTabGroupCounter(): void {\n tabGroupCounter = 0;\n}\n\n/**\n * Transform Tabs components in HTML.\n */\nexport async function transformTabs(html: string): Promise<string> {\n // Cheap marker check: skip the NAPI call entirely when there's no `<tabs>`\n // element. The Rust side guards the same way, but short-circuiting here\n // avoids marshalling the whole document across the boundary.\n if (!/<tabs/i.test(html)) {\n return html;\n }\n\n const mod = await importNapiModule();\n const result = mod.transformTabsEmbeds(html, tabGroupCounter);\n tabGroupCounter += result.groupCount;\n return result.html;\n}\n\n/**\n * Generate dynamic CSS for :has() based tab switching.\n * This is needed because :has() selectors need unique IDs.\n */\nexport function generateTabsCSS(groupCount: number): string {\n if (groupCount === 0) return \"\";\n\n let css = \"/* Dynamic Tabs CSS */\\n\";\n\n for (let g = 0; g < groupCount; g++) {\n for (let t = 0; t < 8; t++) {\n css += `.ox-tabs[data-group=\"${g}\"]:has(#ox-tab-${g}-${t}:checked) .ox-tab-panel[data-tab=\"${t}\"] { display: block; }\\n`;\n }\n }\n\n return css;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA,IAAI,kBAAkB;;;;AAKtB,SAAgB,uBAA6B;CAC3C,kBAAkB;;;;;AAMpB,eAAsB,cAAc,MAA+B;CAIjE,IAAI,CAAC,SAAS,KAAK,KAAK,EACtB,OAAO;CAIT,MAAM,UAAS,MADGA,aAAAA,kBAAkB,EACjB,oBAAoB,MAAM,gBAAgB;CAC7D,mBAAmB,OAAO;CAC1B,OAAO,OAAO;;;;;;AAOhB,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,eAAe,GAAG,OAAO;CAE7B,IAAI,MAAM;CAEV,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACrB,OAAO,wBAAwB,EAAE,iBAAiB,EAAE,GAAG,EAAE,oCAAoC,EAAE;CAInG,OAAO"}
1
+ {"version":3,"file":"tabs.cjs","names":["importNapiModule"],"sources":["../src/plugins/tabs.ts"],"sourcesContent":["/**\n * Tabs Plugin - Pure CSS implementation\n *\n * Transforms <Tabs>/<Tab> components into accessible HTML with CSS :has()\n * based tab switching (no JavaScript required).\n *\n * The HTML rewrite is performed in Rust (`transformTabsEmbeds` in\n * @ox-content/napi), replacing the previous rehype parse/stringify round-trip.\n * The per-build group counter (consumed by `generateTabsCSS`) stays here and is\n * advanced by the number of groups the Rust transform reports, so CSS\n * generation still covers exactly the groups that were emitted.\n */\n\nimport { importNapiModule } from \"../napi\";\n\nlet tabGroupCounter = 0;\n\n/**\n * Reset tab group counter (for testing and per dev-server request).\n */\nexport function resetTabGroupCounter(): void {\n tabGroupCounter = 0;\n}\n\n/**\n * Read the shared tab group counter. Other tab-like transforms (such as the\n * package-manager tabs) share this counter so `data-group` ids and the CSS\n * generated by {@link generateTabsCSS} stay unique across a page.\n */\nexport function getTabGroupCounter(): number {\n return tabGroupCounter;\n}\n\n/** Set the shared tab group counter (advanced by other tab-like transforms). */\nexport function setTabGroupCounter(value: number): void {\n tabGroupCounter = value;\n}\n\n/**\n * Transform Tabs components in HTML.\n */\nexport async function transformTabs(html: string): Promise<string> {\n // Cheap marker check: skip the NAPI call entirely when there's no `<tabs>`\n // element. The Rust side guards the same way, but short-circuiting here\n // avoids marshalling the whole document across the boundary.\n if (!/<tabs/i.test(html)) {\n return html;\n }\n\n const mod = await importNapiModule();\n const result = mod.transformTabsEmbeds(html, tabGroupCounter);\n tabGroupCounter += result.groupCount;\n return result.html;\n}\n\n/**\n * Generate dynamic CSS for :has() based tab switching.\n * This is needed because :has() selectors need unique IDs.\n */\nexport function generateTabsCSS(groupCount: number): string {\n if (groupCount === 0) return \"\";\n\n let css = \"/* Dynamic Tabs CSS */\\n\";\n\n for (let g = 0; g < groupCount; g++) {\n for (let t = 0; t < 8; t++) {\n css += `.ox-tabs[data-group=\"${g}\"]:has(#ox-tab-${g}-${t}:checked) .ox-tab-panel[data-tab=\"${t}\"] { display: block; }\\n`;\n }\n }\n\n return css;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA,IAAI,kBAAkB;;;;AAKtB,SAAgB,uBAA6B;CAC3C,kBAAkB;;;;;;;AAQpB,SAAgB,qBAA6B;CAC3C,OAAO;;;AAIT,SAAgB,mBAAmB,OAAqB;CACtD,kBAAkB;;;;;AAMpB,eAAsB,cAAc,MAA+B;CAIjE,IAAI,CAAC,SAAS,KAAK,KAAK,EACtB,OAAO;CAIT,MAAM,UAAS,MADGA,aAAAA,kBAAkB,EACjB,oBAAoB,MAAM,gBAAgB;CAC7D,mBAAmB,OAAO;CAC1B,OAAO,OAAO;;;;;;AAOhB,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,eAAe,GAAG,OAAO;CAE7B,IAAI,MAAM;CAEV,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACrB,OAAO,wBAAwB,EAAE,iBAAiB,EAAE,GAAG,EAAE,oCAAoC,EAAE;CAInG,OAAO"}
package/dist/tabs.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { r as transformTabs } from "./tabs2.mjs";
1
+ import { a as transformTabs } from "./tabs2.mjs";
2
2
  export { transformTabs };
package/dist/tabs2.mjs CHANGED
@@ -20,6 +20,18 @@ function resetTabGroupCounter() {
20
20
  tabGroupCounter = 0;
21
21
  }
22
22
  /**
23
+ * Read the shared tab group counter. Other tab-like transforms (such as the
24
+ * package-manager tabs) share this counter so `data-group` ids and the CSS
25
+ * generated by {@link generateTabsCSS} stay unique across a page.
26
+ */
27
+ function getTabGroupCounter() {
28
+ return tabGroupCounter;
29
+ }
30
+ /** Set the shared tab group counter (advanced by other tab-like transforms). */
31
+ function setTabGroupCounter(value) {
32
+ tabGroupCounter = value;
33
+ }
34
+ /**
23
35
  * Transform Tabs components in HTML.
24
36
  */
25
37
  async function transformTabs(html) {
@@ -39,6 +51,6 @@ function generateTabsCSS(groupCount) {
39
51
  return css;
40
52
  }
41
53
  //#endregion
42
- export { resetTabGroupCounter as n, transformTabs as r, generateTabsCSS as t };
54
+ export { transformTabs as a, setTabGroupCounter as i, getTabGroupCounter as n, resetTabGroupCounter as r, generateTabsCSS as t };
43
55
 
44
56
  //# sourceMappingURL=tabs2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tabs2.mjs","names":[],"sources":["../src/plugins/tabs.ts"],"sourcesContent":["/**\n * Tabs Plugin - Pure CSS implementation\n *\n * Transforms <Tabs>/<Tab> components into accessible HTML with CSS :has()\n * based tab switching (no JavaScript required).\n *\n * The HTML rewrite is performed in Rust (`transformTabsEmbeds` in\n * @ox-content/napi), replacing the previous rehype parse/stringify round-trip.\n * The per-build group counter (consumed by `generateTabsCSS`) stays here and is\n * advanced by the number of groups the Rust transform reports, so CSS\n * generation still covers exactly the groups that were emitted.\n */\n\nimport { importNapiModule } from \"../napi\";\n\nlet tabGroupCounter = 0;\n\n/**\n * Reset tab group counter (for testing and per dev-server request).\n */\nexport function resetTabGroupCounter(): void {\n tabGroupCounter = 0;\n}\n\n/**\n * Transform Tabs components in HTML.\n */\nexport async function transformTabs(html: string): Promise<string> {\n // Cheap marker check: skip the NAPI call entirely when there's no `<tabs>`\n // element. The Rust side guards the same way, but short-circuiting here\n // avoids marshalling the whole document across the boundary.\n if (!/<tabs/i.test(html)) {\n return html;\n }\n\n const mod = await importNapiModule();\n const result = mod.transformTabsEmbeds(html, tabGroupCounter);\n tabGroupCounter += result.groupCount;\n return result.html;\n}\n\n/**\n * Generate dynamic CSS for :has() based tab switching.\n * This is needed because :has() selectors need unique IDs.\n */\nexport function generateTabsCSS(groupCount: number): string {\n if (groupCount === 0) return \"\";\n\n let css = \"/* Dynamic Tabs CSS */\\n\";\n\n for (let g = 0; g < groupCount; g++) {\n for (let t = 0; t < 8; t++) {\n css += `.ox-tabs[data-group=\"${g}\"]:has(#ox-tab-${g}-${t}:checked) .ox-tab-panel[data-tab=\"${t}\"] { display: block; }\\n`;\n }\n }\n\n return css;\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,IAAI,kBAAkB;;;;AAKtB,SAAgB,uBAA6B;CAC3C,kBAAkB;;;;;AAMpB,eAAsB,cAAc,MAA+B;CAIjE,IAAI,CAAC,SAAS,KAAK,KAAK,EACtB,OAAO;CAIT,MAAM,UAAS,MADG,kBAAkB,EACjB,oBAAoB,MAAM,gBAAgB;CAC7D,mBAAmB,OAAO;CAC1B,OAAO,OAAO;;;;;;AAOhB,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,eAAe,GAAG,OAAO;CAE7B,IAAI,MAAM;CAEV,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACrB,OAAO,wBAAwB,EAAE,iBAAiB,EAAE,GAAG,EAAE,oCAAoC,EAAE;CAInG,OAAO"}
1
+ {"version":3,"file":"tabs2.mjs","names":[],"sources":["../src/plugins/tabs.ts"],"sourcesContent":["/**\n * Tabs Plugin - Pure CSS implementation\n *\n * Transforms <Tabs>/<Tab> components into accessible HTML with CSS :has()\n * based tab switching (no JavaScript required).\n *\n * The HTML rewrite is performed in Rust (`transformTabsEmbeds` in\n * @ox-content/napi), replacing the previous rehype parse/stringify round-trip.\n * The per-build group counter (consumed by `generateTabsCSS`) stays here and is\n * advanced by the number of groups the Rust transform reports, so CSS\n * generation still covers exactly the groups that were emitted.\n */\n\nimport { importNapiModule } from \"../napi\";\n\nlet tabGroupCounter = 0;\n\n/**\n * Reset tab group counter (for testing and per dev-server request).\n */\nexport function resetTabGroupCounter(): void {\n tabGroupCounter = 0;\n}\n\n/**\n * Read the shared tab group counter. Other tab-like transforms (such as the\n * package-manager tabs) share this counter so `data-group` ids and the CSS\n * generated by {@link generateTabsCSS} stay unique across a page.\n */\nexport function getTabGroupCounter(): number {\n return tabGroupCounter;\n}\n\n/** Set the shared tab group counter (advanced by other tab-like transforms). */\nexport function setTabGroupCounter(value: number): void {\n tabGroupCounter = value;\n}\n\n/**\n * Transform Tabs components in HTML.\n */\nexport async function transformTabs(html: string): Promise<string> {\n // Cheap marker check: skip the NAPI call entirely when there's no `<tabs>`\n // element. The Rust side guards the same way, but short-circuiting here\n // avoids marshalling the whole document across the boundary.\n if (!/<tabs/i.test(html)) {\n return html;\n }\n\n const mod = await importNapiModule();\n const result = mod.transformTabsEmbeds(html, tabGroupCounter);\n tabGroupCounter += result.groupCount;\n return result.html;\n}\n\n/**\n * Generate dynamic CSS for :has() based tab switching.\n * This is needed because :has() selectors need unique IDs.\n */\nexport function generateTabsCSS(groupCount: number): string {\n if (groupCount === 0) return \"\";\n\n let css = \"/* Dynamic Tabs CSS */\\n\";\n\n for (let g = 0; g < groupCount; g++) {\n for (let t = 0; t < 8; t++) {\n css += `.ox-tabs[data-group=\"${g}\"]:has(#ox-tab-${g}-${t}:checked) .ox-tab-panel[data-tab=\"${t}\"] { display: block; }\\n`;\n }\n }\n\n return css;\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,IAAI,kBAAkB;;;;AAKtB,SAAgB,uBAA6B;CAC3C,kBAAkB;;;;;;;AAQpB,SAAgB,qBAA6B;CAC3C,OAAO;;;AAIT,SAAgB,mBAAmB,OAAqB;CACtD,kBAAkB;;;;;AAMpB,eAAsB,cAAc,MAA+B;CAIjE,IAAI,CAAC,SAAS,KAAK,KAAK,EACtB,OAAO;CAIT,MAAM,UAAS,MADG,kBAAkB,EACjB,oBAAoB,MAAM,gBAAgB;CAC7D,mBAAmB,OAAO;CAC1B,OAAO,OAAO;;;;;;AAOhB,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,eAAe,GAAG,OAAO;CAE7B,IAAI,MAAM;CAEV,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACrB,OAAO,wBAAwB,EAAE,iBAAiB,EAAE,GAAG,EAAE,oCAAoC,EAAE;CAInG,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/vite-plugin",
3
- "version": "2.26.0",
3
+ "version": "2.28.0",
4
4
  "description": "Vite plugin for Ox Content - High-performance Markdown processing with Environment API",
5
5
  "keywords": [
6
6
  "environment-api",
@@ -58,7 +58,7 @@
58
58
  "shiki": "^4.0.2",
59
59
  "typescript": "^6.0.3",
60
60
  "unified": "^11.0.5",
61
- "@ox-content/napi": "2.26.0"
61
+ "@ox-content/napi": "2.28.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@playwright/test": "^1.60.0",