@takazudo/zudo-doc 0.1.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.
Files changed (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/dist/body-foot-util/body-foot-util-area.d.ts +55 -0
  4. package/dist/body-foot-util/body-foot-util-area.js +71 -0
  5. package/dist/body-foot-util/edit-link.d.ts +45 -0
  6. package/dist/body-foot-util/edit-link.js +42 -0
  7. package/dist/body-foot-util/index.d.ts +3 -0
  8. package/dist/body-foot-util/index.js +11 -0
  9. package/dist/breadcrumb/breadcrumb.d.ts +57 -0
  10. package/dist/breadcrumb/breadcrumb.js +113 -0
  11. package/dist/breadcrumb/find-path.d.ts +16 -0
  12. package/dist/breadcrumb/find-path.js +13 -0
  13. package/dist/breadcrumb/index.d.ts +4 -0
  14. package/dist/breadcrumb/index.js +7 -0
  15. package/dist/breadcrumb/types.d.ts +32 -0
  16. package/dist/breadcrumb/types.js +0 -0
  17. package/dist/code-syntax/code-block-enhancer-script.d.ts +3 -0
  18. package/dist/code-syntax/code-block-enhancer-script.js +165 -0
  19. package/dist/code-syntax/code-block-enhancer.d.ts +22 -0
  20. package/dist/code-syntax/code-block-enhancer.js +13 -0
  21. package/dist/code-syntax/index.d.ts +8 -0
  22. package/dist/code-syntax/index.js +29 -0
  23. package/dist/code-syntax/mermaid-init-script.d.ts +51 -0
  24. package/dist/code-syntax/mermaid-init-script.js +225 -0
  25. package/dist/code-syntax/mermaid-init.d.ts +48 -0
  26. package/dist/code-syntax/mermaid-init.js +14 -0
  27. package/dist/code-syntax/tabs-init-script.d.ts +3 -0
  28. package/dist/code-syntax/tabs-init-script.js +106 -0
  29. package/dist/code-syntax/tabs-init.d.ts +24 -0
  30. package/dist/code-syntax/tabs-init.js +10 -0
  31. package/dist/code-syntax/tabs.d.ts +36 -0
  32. package/dist/code-syntax/tabs.js +62 -0
  33. package/dist/content/component-map.d.ts +51 -0
  34. package/dist/content/component-map.js +29 -0
  35. package/dist/content/content-blockquote.d.ts +11 -0
  36. package/dist/content/content-blockquote.js +14 -0
  37. package/dist/content/content-code.d.ts +26 -0
  38. package/dist/content/content-code.js +39 -0
  39. package/dist/content/content-link.d.ts +12 -0
  40. package/dist/content/content-link.js +43 -0
  41. package/dist/content/content-ol.d.ts +11 -0
  42. package/dist/content/content-ol.js +15 -0
  43. package/dist/content/content-paragraph.d.ts +10 -0
  44. package/dist/content/content-paragraph.js +7 -0
  45. package/dist/content/content-strong.d.ts +11 -0
  46. package/dist/content/content-strong.js +14 -0
  47. package/dist/content/content-table.d.ts +11 -0
  48. package/dist/content/content-table.js +14 -0
  49. package/dist/content/content-ul.d.ts +11 -0
  50. package/dist/content/content-ul.js +15 -0
  51. package/dist/content/heading-h2.d.ts +14 -0
  52. package/dist/content/heading-h2.js +18 -0
  53. package/dist/content/heading-h3.d.ts +14 -0
  54. package/dist/content/heading-h3.js +18 -0
  55. package/dist/content/heading-h4.d.ts +14 -0
  56. package/dist/content/heading-h4.js +18 -0
  57. package/dist/content/index.d.ts +13 -0
  58. package/dist/content/index.js +27 -0
  59. package/dist/details/details.d.ts +26 -0
  60. package/dist/details/details.js +10 -0
  61. package/dist/details/index.d.ts +2 -0
  62. package/dist/details/index.js +4 -0
  63. package/dist/doclayout/anchors.d.ts +55 -0
  64. package/dist/doclayout/anchors.js +42 -0
  65. package/dist/doclayout/doc-layout-with-defaults.d.ts +83 -0
  66. package/dist/doclayout/doc-layout-with-defaults.js +159 -0
  67. package/dist/doclayout/doc-layout.d.ts +121 -0
  68. package/dist/doclayout/doc-layout.js +89 -0
  69. package/dist/doclayout/index.d.ts +6 -0
  70. package/dist/doclayout/index.js +17 -0
  71. package/dist/footer/footer.d.ts +42 -0
  72. package/dist/footer/footer.js +79 -0
  73. package/dist/footer/index.d.ts +3 -0
  74. package/dist/footer/index.js +4 -0
  75. package/dist/footer/types.d.ts +58 -0
  76. package/dist/footer/types.js +0 -0
  77. package/dist/head/doc-head.d.ts +33 -0
  78. package/dist/head/doc-head.js +90 -0
  79. package/dist/head/index.d.ts +5 -0
  80. package/dist/head/index.js +8 -0
  81. package/dist/head/og-tags.d.ts +25 -0
  82. package/dist/head/og-tags.js +16 -0
  83. package/dist/head/twitter-card.d.ts +21 -0
  84. package/dist/head/twitter-card.js +14 -0
  85. package/dist/head/types.d.ts +83 -0
  86. package/dist/head/types.js +0 -0
  87. package/dist/header/header.d.ts +158 -0
  88. package/dist/header/header.js +367 -0
  89. package/dist/header/index.d.ts +6 -0
  90. package/dist/header/index.js +18 -0
  91. package/dist/header/nav-active.d.ts +39 -0
  92. package/dist/header/nav-active.js +24 -0
  93. package/dist/header/nav-overflow-script.d.ts +3 -0
  94. package/dist/header/nav-overflow-script.js +169 -0
  95. package/dist/header/right-items.d.ts +38 -0
  96. package/dist/header/right-items.js +30 -0
  97. package/dist/header/types.d.ts +40 -0
  98. package/dist/header/types.js +0 -0
  99. package/dist/html-preview-wrapper/dedent.d.ts +10 -0
  100. package/dist/html-preview-wrapper/dedent.js +16 -0
  101. package/dist/html-preview-wrapper/highlighted-code.d.ts +18 -0
  102. package/dist/html-preview-wrapper/highlighted-code.js +53 -0
  103. package/dist/html-preview-wrapper/html-preview-wrapper.d.ts +60 -0
  104. package/dist/html-preview-wrapper/html-preview-wrapper.js +36 -0
  105. package/dist/html-preview-wrapper/html-preview.d.ts +35 -0
  106. package/dist/html-preview-wrapper/html-preview.js +75 -0
  107. package/dist/html-preview-wrapper/index.d.ts +5 -0
  108. package/dist/html-preview-wrapper/index.js +12 -0
  109. package/dist/html-preview-wrapper/preflight.d.ts +13 -0
  110. package/dist/html-preview-wrapper/preflight.js +108 -0
  111. package/dist/html-preview-wrapper/preview-base.d.ts +29 -0
  112. package/dist/html-preview-wrapper/preview-base.js +127 -0
  113. package/dist/i18n-version/index.d.ts +5 -0
  114. package/dist/i18n-version/index.js +14 -0
  115. package/dist/i18n-version/language-switcher.d.ts +24 -0
  116. package/dist/i18n-version/language-switcher.js +25 -0
  117. package/dist/i18n-version/types.d.ts +43 -0
  118. package/dist/i18n-version/types.js +0 -0
  119. package/dist/i18n-version/version-banner.d.ts +30 -0
  120. package/dist/i18n-version/version-banner.js +21 -0
  121. package/dist/i18n-version/version-switcher.d.ts +112 -0
  122. package/dist/i18n-version/version-switcher.js +157 -0
  123. package/dist/index.d.ts +2 -0
  124. package/dist/index.js +0 -0
  125. package/dist/integrations/claude-resources/escape-for-mdx.d.ts +8 -0
  126. package/dist/integrations/claude-resources/escape-for-mdx.js +131 -0
  127. package/dist/integrations/claude-resources/generate.d.ts +13 -0
  128. package/dist/integrations/claude-resources/generate.js +404 -0
  129. package/dist/integrations/claude-resources/index.d.ts +46 -0
  130. package/dist/integrations/claude-resources/index.js +24 -0
  131. package/dist/integrations/doc-history/index.d.ts +137 -0
  132. package/dist/integrations/doc-history/index.js +138 -0
  133. package/dist/integrations/doc-history/pre-build.d.ts +58 -0
  134. package/dist/integrations/doc-history/pre-build.js +67 -0
  135. package/dist/integrations/llms-txt/dev-middleware.d.ts +40 -0
  136. package/dist/integrations/llms-txt/dev-middleware.js +76 -0
  137. package/dist/integrations/llms-txt/emit.d.ts +22 -0
  138. package/dist/integrations/llms-txt/emit.js +55 -0
  139. package/dist/integrations/llms-txt/generate.d.ts +26 -0
  140. package/dist/integrations/llms-txt/generate.js +36 -0
  141. package/dist/integrations/llms-txt/index.d.ts +7 -0
  142. package/dist/integrations/llms-txt/index.js +27 -0
  143. package/dist/integrations/llms-txt/load.d.ts +51 -0
  144. package/dist/integrations/llms-txt/load.js +83 -0
  145. package/dist/integrations/llms-txt/strip.d.ts +22 -0
  146. package/dist/integrations/llms-txt/strip.js +10 -0
  147. package/dist/integrations/llms-txt/types.d.ts +145 -0
  148. package/dist/integrations/llms-txt/types.js +0 -0
  149. package/dist/integrations/search-index/build-emitter.d.ts +30 -0
  150. package/dist/integrations/search-index/build-emitter.js +15 -0
  151. package/dist/integrations/search-index/collect.d.ts +12 -0
  152. package/dist/integrations/search-index/collect.js +48 -0
  153. package/dist/integrations/search-index/content-files.d.ts +32 -0
  154. package/dist/integrations/search-index/content-files.js +50 -0
  155. package/dist/integrations/search-index/dev-middleware.d.ts +16 -0
  156. package/dist/integrations/search-index/dev-middleware.js +30 -0
  157. package/dist/integrations/search-index/index.d.ts +5 -0
  158. package/dist/integrations/search-index/index.js +14 -0
  159. package/dist/integrations/search-index/types.d.ts +38 -0
  160. package/dist/integrations/search-index/types.js +6 -0
  161. package/dist/metainfo/doc-metainfo.d.ts +50 -0
  162. package/dist/metainfo/doc-metainfo.js +107 -0
  163. package/dist/metainfo/doc-tags.d.ts +66 -0
  164. package/dist/metainfo/doc-tags.js +53 -0
  165. package/dist/metainfo/frontmatter-preview.d.ts +95 -0
  166. package/dist/metainfo/frontmatter-preview.js +55 -0
  167. package/dist/metainfo/index.d.ts +4 -0
  168. package/dist/metainfo/index.js +28 -0
  169. package/dist/nav-indexing/category-nav.d.ts +28 -0
  170. package/dist/nav-indexing/category-nav.js +41 -0
  171. package/dist/nav-indexing/category-tree-nav.d.ts +27 -0
  172. package/dist/nav-indexing/category-tree-nav.js +49 -0
  173. package/dist/nav-indexing/doc-card-grid.d.ts +38 -0
  174. package/dist/nav-indexing/doc-card-grid.js +40 -0
  175. package/dist/nav-indexing/docs-sitemap.d.ts +25 -0
  176. package/dist/nav-indexing/docs-sitemap.js +40 -0
  177. package/dist/nav-indexing/index.d.ts +10 -0
  178. package/dist/nav-indexing/index.js +18 -0
  179. package/dist/nav-indexing/nav-card-grid.d.ts +31 -0
  180. package/dist/nav-indexing/nav-card-grid.js +43 -0
  181. package/dist/nav-indexing/site-tree-nav-demo.d.ts +39 -0
  182. package/dist/nav-indexing/site-tree-nav-demo.js +65 -0
  183. package/dist/nav-indexing/tag-nav.d.ts +38 -0
  184. package/dist/nav-indexing/tag-nav.js +96 -0
  185. package/dist/nav-indexing/types.d.ts +95 -0
  186. package/dist/nav-indexing/types.js +0 -0
  187. package/dist/nav-indexing/versions-page-content.d.ts +29 -0
  188. package/dist/nav-indexing/versions-page-content.js +76 -0
  189. package/dist/page-loading/index.d.ts +2 -0
  190. package/dist/page-loading/index.js +10 -0
  191. package/dist/page-loading/page-loading-overlay.d.ts +35 -0
  192. package/dist/page-loading/page-loading-overlay.js +50 -0
  193. package/dist/sidebar/index.d.ts +3 -0
  194. package/dist/sidebar/index.js +4 -0
  195. package/dist/sidebar/sidebar.d.ts +54 -0
  196. package/dist/sidebar/sidebar.js +35 -0
  197. package/dist/sidebar/types.d.ts +71 -0
  198. package/dist/sidebar/types.js +0 -0
  199. package/dist/sidebar-resizer/index.d.ts +14 -0
  200. package/dist/sidebar-resizer/index.js +165 -0
  201. package/dist/sidebar-resizer/sidebar-resizer-init.d.ts +20 -0
  202. package/dist/sidebar-resizer/sidebar-resizer-init.js +119 -0
  203. package/dist/sidebar-tree/build-tree.d.ts +43 -0
  204. package/dist/sidebar-tree/build-tree.js +127 -0
  205. package/dist/sidebar-tree/category-meta.d.ts +19 -0
  206. package/dist/sidebar-tree/category-meta.js +63 -0
  207. package/dist/sidebar-tree/index.d.ts +3 -0
  208. package/dist/sidebar-tree/index.js +13 -0
  209. package/dist/sidebar-tree/types.d.ts +120 -0
  210. package/dist/sidebar-tree/types.js +0 -0
  211. package/dist/tab-item/index.d.ts +2 -0
  212. package/dist/tab-item/index.js +5 -0
  213. package/dist/tab-item/tab-item.d.ts +38 -0
  214. package/dist/tab-item/tab-item.js +25 -0
  215. package/dist/theme/color-scheme-provider.d.ts +32 -0
  216. package/dist/theme/color-scheme-provider.js +43 -0
  217. package/dist/theme/color-tweak-export-modal.d.ts +20 -0
  218. package/dist/theme/color-tweak-export-modal.js +138 -0
  219. package/dist/theme/design-token-serde.d.ts +136 -0
  220. package/dist/theme/design-token-serde.js +254 -0
  221. package/dist/theme/design-token-tweak-panel.d.ts +11 -0
  222. package/dist/theme/design-token-tweak-panel.js +10 -0
  223. package/dist/theme/design-token-types.d.ts +19 -0
  224. package/dist/theme/design-token-types.js +6 -0
  225. package/dist/theme/iframe-bridge.d.ts +44 -0
  226. package/dist/theme/iframe-bridge.js +70 -0
  227. package/dist/theme/index.d.ts +9 -0
  228. package/dist/theme/index.js +42 -0
  229. package/dist/theme/theme-toggle.d.ts +17 -0
  230. package/dist/theme/theme-toggle.js +91 -0
  231. package/dist/toc/cx.d.ts +16 -0
  232. package/dist/toc/cx.js +22 -0
  233. package/dist/toc/index.d.ts +5 -0
  234. package/dist/toc/index.js +9 -0
  235. package/dist/toc/mobile-toc.d.ts +46 -0
  236. package/dist/toc/mobile-toc.js +88 -0
  237. package/dist/toc/smart-break.d.ts +27 -0
  238. package/dist/toc/smart-break.js +36 -0
  239. package/dist/toc/toc-title.d.ts +10 -0
  240. package/dist/toc/toc-title.js +14 -0
  241. package/dist/toc/toc.d.ts +60 -0
  242. package/dist/toc/toc.js +56 -0
  243. package/dist/toc/types.d.ts +23 -0
  244. package/dist/toc/types.js +0 -0
  245. package/dist/toc/use-active-heading.d.ts +30 -0
  246. package/dist/toc/use-active-heading.js +106 -0
  247. package/dist/transitions/index.d.ts +1 -0
  248. package/dist/transitions/index.js +12 -0
  249. package/dist/transitions/page-events.d.ts +41 -0
  250. package/dist/transitions/page-events.js +20 -0
  251. package/dist/url-normalizer/index.d.ts +1 -0
  252. package/dist/url-normalizer/index.js +6 -0
  253. package/dist/url-normalizer/normalize.d.ts +104 -0
  254. package/dist/url-normalizer/normalize.js +22 -0
  255. package/package.json +186 -0
@@ -0,0 +1,169 @@
1
+ import { AFTER_NAVIGATE_EVENT } from "../transitions/page-events.js";
2
+ const NAV_OVERFLOW_SCRIPT = `(function () {
3
+ var cleanupNavOverflow = null;
4
+
5
+ function initNavOverflow() {
6
+ if (cleanupNavOverflow) cleanupNavOverflow();
7
+
8
+ var nav = document.querySelector("[data-header-nav]");
9
+ var moreContainer = document.querySelector("[data-nav-more]");
10
+ var moreMenu = document.querySelector("[data-nav-more-menu]");
11
+ var moreToggle = document.querySelector("[data-nav-more-toggle]");
12
+ if (!nav || !moreContainer || !moreMenu || !moreToggle) return;
13
+
14
+ var items = Array.from(nav.querySelectorAll(":scope > [data-nav-item]"));
15
+ if (items.length === 0) return;
16
+
17
+ var controller = new AbortController();
18
+
19
+ function update() {
20
+ items.forEach(function (el) { el.style.display = ""; });
21
+ moreContainer.style.display = "";
22
+ moreMenu.innerHTML = "";
23
+ moreMenu.classList.add("hidden");
24
+ moreToggle.setAttribute("aria-expanded", "false");
25
+
26
+ var itemWidths = items.map(function (el) { return el.offsetWidth; });
27
+ var moreWidth = moreContainer.offsetWidth;
28
+ var navGap = parseFloat(getComputedStyle(nav).columnGap) || 0;
29
+ var available = nav.clientWidth;
30
+
31
+ if (available <= 0) {
32
+ moreContainer.style.display = "none";
33
+ return;
34
+ }
35
+
36
+ var total = 0;
37
+ for (var i = 0; i < itemWidths.length; i++) {
38
+ total += itemWidths[i] + (i > 0 ? navGap : 0);
39
+ }
40
+
41
+ if (total <= available) {
42
+ moreContainer.style.display = "none";
43
+ return;
44
+ }
45
+
46
+ var used = 0;
47
+ var cutoffIndex = 0;
48
+
49
+ for (var i2 = 0; i2 < items.length; i2++) {
50
+ var w = itemWidths[i2] + (i2 > 0 ? navGap : 0);
51
+ if (used + w > available - moreWidth - navGap) break;
52
+ used += w;
53
+ cutoffIndex = i2 + 1;
54
+ }
55
+
56
+ for (var i3 = cutoffIndex; i3 < items.length; i3++) {
57
+ items[i3].style.display = "none";
58
+ }
59
+
60
+ for (var i4 = cutoffIndex; i4 < items.length; i4++) {
61
+ var el = items[i4];
62
+ var isDropdown = el.hasAttribute("data-nav-item-dropdown");
63
+
64
+ if (isDropdown) {
65
+ var parentLink = el.querySelector(":scope > a");
66
+ var childLinks = el.querySelectorAll(":scope > div a");
67
+ if (parentLink) {
68
+ var li = document.createElement("li");
69
+ var a = document.createElement("a");
70
+ a.href = parentLink.href;
71
+ var parentText = parentLink.textContent ? parentLink.textContent.trim().replace(/\\s+/g, " ") : "";
72
+ a.textContent = parentText;
73
+ a.className = "block px-hsp-md py-vsp-2xs text-small font-bold hover:bg-accent/10 hover:underline focus-visible:underline text-fg";
74
+ if (parentLink.getAttribute("aria-current") === "page") {
75
+ a.className += " text-accent";
76
+ }
77
+ li.appendChild(a);
78
+ moreMenu.appendChild(li);
79
+ }
80
+ childLinks.forEach(function (child) {
81
+ var li = document.createElement("li");
82
+ var a = document.createElement("a");
83
+ a.href = child.href;
84
+ a.textContent = child.textContent ? child.textContent.trim() : "";
85
+ var isChildActive = child.hasAttribute("data-active");
86
+ a.className = isChildActive
87
+ ? "block pl-hsp-xl pr-hsp-md py-vsp-2xs text-small font-bold text-accent hover:bg-accent/10 hover:underline focus-visible:underline"
88
+ : "block pl-hsp-xl pr-hsp-md py-vsp-2xs text-small text-muted hover:bg-accent/10 hover:text-fg hover:underline focus-visible:underline";
89
+ li.appendChild(a);
90
+ moreMenu.appendChild(li);
91
+ });
92
+ } else {
93
+ var anchor = el;
94
+ var li2 = document.createElement("li");
95
+ var a2 = document.createElement("a");
96
+ a2.href = anchor.href;
97
+ a2.textContent = anchor.textContent ? anchor.textContent.trim() : "";
98
+ a2.className = "block px-hsp-md py-vsp-2xs text-small hover:bg-accent/10 hover:underline focus-visible:underline text-fg";
99
+ if (anchor.getAttribute("aria-current") === "page") {
100
+ a2.className += " font-bold text-accent";
101
+ }
102
+ li2.appendChild(a2);
103
+ moreMenu.appendChild(li2);
104
+ }
105
+ }
106
+ }
107
+
108
+ moreToggle.addEventListener("click", function () {
109
+ var isOpen = !moreMenu.classList.contains("hidden");
110
+ moreMenu.classList.toggle("hidden", isOpen);
111
+ moreToggle.setAttribute("aria-expanded", String(!isOpen));
112
+ }, { signal: controller.signal });
113
+
114
+ document.addEventListener("click", function (e) {
115
+ if (!moreContainer.contains(e.target)) {
116
+ moreMenu.classList.add("hidden");
117
+ moreToggle.setAttribute("aria-expanded", "false");
118
+ }
119
+ }, { signal: controller.signal });
120
+
121
+ document.addEventListener("keydown", function (e) {
122
+ if (e.key !== "Escape") return;
123
+ if (!moreMenu.classList.contains("hidden")) {
124
+ moreMenu.classList.add("hidden");
125
+ moreToggle.setAttribute("aria-expanded", "false");
126
+ moreToggle.focus();
127
+ return;
128
+ }
129
+ var active = document.activeElement;
130
+ var dropdown = active && active.closest ? active.closest("[data-nav-item-dropdown]") : null;
131
+ if (dropdown && active && active.blur) {
132
+ active.blur();
133
+ }
134
+ }, { signal: controller.signal });
135
+
136
+ var dropdowns = nav.querySelectorAll("[data-nav-item-dropdown]");
137
+ dropdowns.forEach(function (dd) {
138
+ var trigger = dd.querySelector(":scope > a");
139
+ if (!trigger) return;
140
+ function setExpanded(v) {
141
+ trigger.setAttribute("aria-expanded", String(v));
142
+ }
143
+ dd.addEventListener("mouseenter", function () { setExpanded(true); }, { signal: controller.signal });
144
+ dd.addEventListener("mouseleave", function () { setExpanded(false); }, { signal: controller.signal });
145
+ dd.addEventListener("focusin", function () { setExpanded(true); }, { signal: controller.signal });
146
+ dd.addEventListener("focusout", function (e) {
147
+ if (!dd.contains(e.relatedTarget)) {
148
+ setExpanded(false);
149
+ }
150
+ }, { signal: controller.signal });
151
+ });
152
+
153
+ var ro = new ResizeObserver(update);
154
+ ro.observe(nav);
155
+ controller.signal.addEventListener("abort", function () { ro.disconnect(); });
156
+
157
+ document.fonts.ready.then(update);
158
+
159
+ update();
160
+
161
+ cleanupNavOverflow = function () { controller.abort(); };
162
+ }
163
+
164
+ initNavOverflow();
165
+ document.addEventListener(${JSON.stringify(AFTER_NAVIGATE_EVENT)}, initNavOverflow);
166
+ })();`;
167
+ export {
168
+ NAV_OVERFLOW_SCRIPT
169
+ };
@@ -0,0 +1,38 @@
1
+ import { HeaderRightItem } from './types.js';
2
+
3
+ /**
4
+ * Runtime gates for `filterHeaderRightItems`.
5
+ *
6
+ * Mirrors the predicates in the legacy host-side helper (`src/utils/
7
+ * header-right-items.ts` pre-#1729). Each flag corresponds to a specific
8
+ * `settings.*` switch the original implementation consulted directly:
9
+ *
10
+ * - `designTokenPanel` — `settings.designTokenPanel || settings.colorTweakPanel`
11
+ * - `colorTweakPanel` — retained for symmetry; treated as an OR with
12
+ * `designTokenPanel` so callers that still distinguish the deprecated
13
+ * alias get the same gate as the legacy helper.
14
+ * - `aiAssistant` — `settings.aiAssistant`
15
+ * - `colorMode` — `Boolean(settings.colorMode)`
16
+ * - `hasLocales` — `Object.keys(settings.locales).length > 0`
17
+ * - `hasVersions` — `Boolean(settings.versions)`
18
+ * - `hasGithubUrl` — `Boolean(settings.githubUrl)`
19
+ */
20
+ interface HeaderRightItemFlags {
21
+ designTokenPanel: boolean;
22
+ colorTweakPanel: boolean;
23
+ aiAssistant: boolean;
24
+ colorMode: boolean;
25
+ hasLocales: boolean;
26
+ hasVersions: boolean;
27
+ hasGithubUrl: boolean;
28
+ }
29
+ /**
30
+ * Drop header-right items whose gating flag is off. Pure function — the
31
+ * caller is responsible for computing the flags from host config.
32
+ *
33
+ * Items not gated by any flag (links, raw HTML, version-switcher when
34
+ * versions are configured, search, …) pass through untouched.
35
+ */
36
+ declare function filterHeaderRightItems(items: HeaderRightItem[], flags: HeaderRightItemFlags): HeaderRightItem[];
37
+
38
+ export { type HeaderRightItemFlags, filterHeaderRightItems };
@@ -0,0 +1,30 @@
1
+ function filterHeaderRightItems(items, flags) {
2
+ return items.filter((item) => {
3
+ if (item.type === "trigger") {
4
+ if (item.trigger === "design-token-panel") {
5
+ return flags.designTokenPanel || flags.colorTweakPanel;
6
+ }
7
+ if (item.trigger === "ai-chat") {
8
+ return flags.aiAssistant;
9
+ }
10
+ }
11
+ if (item.type === "component") {
12
+ if (item.component === "theme-toggle") {
13
+ return flags.colorMode;
14
+ }
15
+ if (item.component === "language-switcher") {
16
+ return flags.hasLocales;
17
+ }
18
+ if (item.component === "version-switcher") {
19
+ return flags.hasVersions;
20
+ }
21
+ if (item.component === "github-link") {
22
+ return flags.hasGithubUrl;
23
+ }
24
+ }
25
+ return true;
26
+ });
27
+ }
28
+ export {
29
+ filterHeaderRightItems
30
+ };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Locale code as seen by the header. Widened from the host's literal
3
+ * union (`"en" | "ja" | …`) to plain `string` at the v2 boundary so the
4
+ * package can render for any project's locale set without a generic
5
+ * parameter (super-epic #1724, sub-issue #1729).
6
+ */
7
+ type Locale = string;
8
+ interface HeaderNavChildItem {
9
+ label: string;
10
+ labelKey?: string;
11
+ path: string;
12
+ categoryMatch?: string;
13
+ }
14
+ interface HeaderNavItem extends HeaderNavChildItem {
15
+ children?: HeaderNavChildItem[];
16
+ }
17
+ type HeaderRightComponentName = "theme-toggle" | "language-switcher" | "version-switcher" | "github-link" | "search";
18
+ type HeaderRightTriggerName = "design-token-panel" | "ai-chat";
19
+ interface HeaderRightComponentItem {
20
+ type: "component";
21
+ component: HeaderRightComponentName;
22
+ }
23
+ interface HeaderRightTriggerItem {
24
+ type: "trigger";
25
+ trigger: HeaderRightTriggerName;
26
+ }
27
+ interface HeaderRightLinkItem {
28
+ type: "link";
29
+ href: string;
30
+ label?: string;
31
+ ariaLabel?: string;
32
+ icon?: "github";
33
+ }
34
+ interface HeaderRightHtmlItem {
35
+ type: "html";
36
+ html: string;
37
+ }
38
+ type HeaderRightItem = HeaderRightComponentItem | HeaderRightTriggerItem | HeaderRightLinkItem | HeaderRightHtmlItem;
39
+
40
+ export type { HeaderNavChildItem, HeaderNavItem, HeaderRightComponentItem, HeaderRightComponentName, HeaderRightHtmlItem, HeaderRightItem, HeaderRightLinkItem, HeaderRightTriggerItem, HeaderRightTriggerName, Locale };
File without changes
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Strip common leading whitespace from all lines of a template literal string.
3
+ * Similar to Python's textwrap.dedent().
4
+ *
5
+ * Copied from src/utils/dedent.ts so the v2 package has no upward dependency
6
+ * on the host project's source.
7
+ */
8
+ declare function dedent(text: string): string;
9
+
10
+ export { dedent };
@@ -0,0 +1,16 @@
1
+ function dedent(text) {
2
+ const lines = text.split("\n");
3
+ let minIndent = Infinity;
4
+ for (const line of lines) {
5
+ if (line.trim().length === 0) continue;
6
+ const indent = line.match(/^(\s*)/)?.[1].length ?? 0;
7
+ if (indent < minIndent) minIndent = indent;
8
+ }
9
+ if (minIndent === 0 || minIndent === Infinity) {
10
+ return text.trim();
11
+ }
12
+ return lines.map((line) => line.trim().length === 0 ? "" : line.slice(minIndent)).join("\n").trim();
13
+ }
14
+ export {
15
+ dedent
16
+ };
@@ -0,0 +1,18 @@
1
+ import { VNode } from 'preact';
2
+
3
+ /** @jsxRuntime automatic */
4
+ /** @jsxImportSource preact */
5
+
6
+ interface HighlightedCodeProps {
7
+ code: string;
8
+ language: string;
9
+ }
10
+ /**
11
+ * Syntax-highlighted code block backed by Shiki. Falls back to a
12
+ * plain `<pre><code>` block while Shiki is loading or if it fails.
13
+ *
14
+ * JSX port of src/components/html-preview/highlighted-code.tsx.
15
+ */
16
+ declare function HighlightedCode({ code, language, }: HighlightedCodeProps): VNode;
17
+
18
+ export { HighlightedCode, type HighlightedCodeProps };
@@ -0,0 +1,53 @@
1
+ import { jsx } from "preact/jsx-runtime";
2
+ import { useEffect, useState } from "preact/hooks";
3
+ let highlighterPromise = null;
4
+ function getHighlighter() {
5
+ if (!highlighterPromise) {
6
+ highlighterPromise = import("shiki").then(
7
+ ({ createHighlighter }) => createHighlighter({
8
+ themes: ["catppuccin-latte", "vitesse-dark"],
9
+ langs: ["html", "css", "javascript"]
10
+ })
11
+ ).catch((err) => {
12
+ highlighterPromise = null;
13
+ throw err;
14
+ });
15
+ }
16
+ return highlighterPromise;
17
+ }
18
+ function HighlightedCode({
19
+ code,
20
+ language
21
+ }) {
22
+ const [html, setHtml] = useState(null);
23
+ useEffect(() => {
24
+ let cancelled = false;
25
+ getHighlighter().then((highlighter) => {
26
+ if (cancelled) return;
27
+ const lang = highlighter.getLoadedLanguages().includes(language) ? language : "text";
28
+ const result = highlighter.codeToHtml(code, {
29
+ lang,
30
+ themes: { light: "catppuccin-latte", dark: "vitesse-dark" },
31
+ defaultColor: false
32
+ });
33
+ setHtml(result);
34
+ }).catch(() => {
35
+ });
36
+ return () => {
37
+ cancelled = true;
38
+ };
39
+ }, [code, language]);
40
+ if (!html) {
41
+ return /* @__PURE__ */ jsx("pre", { class: "m-0 p-hsp-md bg-code-bg text-caption leading-relaxed overflow-x-auto", children: /* @__PURE__ */ jsx("code", { class: "font-mono whitespace-pre", children: code }) });
42
+ }
43
+ return /* @__PURE__ */ jsx(
44
+ "div",
45
+ {
46
+ class: "zd-html-preview-code",
47
+ dangerouslySetInnerHTML: { __html: html }
48
+ }
49
+ );
50
+ }
51
+ export {
52
+ HighlightedCode
53
+ };
@@ -0,0 +1,60 @@
1
+ import { VNode } from 'preact';
2
+
3
+ /** @jsxRuntime automatic */
4
+ /** @jsxImportSource preact */
5
+
6
+ /**
7
+ * Global HTML preview configuration. Mirrors the `settings.htmlPreview`
8
+ * shape from the host project so callers can pass the resolved config
9
+ * object directly.
10
+ */
11
+ interface HtmlPreviewGlobalConfig {
12
+ /** CSS appended to every preview iframe (e.g. global component library styles). */
13
+ css?: string;
14
+ /** HTML injected into the `<head>` of every preview iframe. */
15
+ head?: string;
16
+ /** JavaScript appended to every preview iframe's `<body>`. */
17
+ js?: string;
18
+ }
19
+ interface HtmlPreviewWrapperProps {
20
+ /**
21
+ * Site-wide HTML preview configuration (resolved from
22
+ * `settings.htmlPreview` by the caller). When provided, its
23
+ * `head`, `css`, and `js` are prepended to the per-usage values so
24
+ * that global styles/scripts apply to every preview.
25
+ *
26
+ * The legacy `html-preview-wrapper.astro` read this directly from
27
+ * `settings`; v2 accepts it as a prop so the component has no
28
+ * upward dependency on the project settings module.
29
+ */
30
+ globalConfig?: HtmlPreviewGlobalConfig | null;
31
+ /** HTML body content to display in the iframe. */
32
+ html: string;
33
+ /** Per-usage CSS injected after the global CSS. */
34
+ css?: string;
35
+ /** Per-usage `<head>` content injected after the global head. */
36
+ head?: string;
37
+ /** Per-usage JavaScript injected after the global JS. */
38
+ js?: string;
39
+ /** Optional title displayed in the preview title bar. */
40
+ title?: string;
41
+ /** Fixed iframe height in pixels. Auto-sizes when omitted. */
42
+ height?: number;
43
+ /** When true, the code section is expanded by default. */
44
+ defaultOpen?: boolean;
45
+ }
46
+ /**
47
+ * HTML preview wrapper — JSX port of
48
+ * `src/components/html-preview-wrapper.astro`.
49
+ *
50
+ * The legacy Astro wrapper merged `settings.htmlPreview` (global config)
51
+ * with per-usage props and forwarded everything to `<HtmlPreview
52
+ * client:visible />`. v2 collapses the merge into the inner shell and
53
+ * wraps it in `<Island when="visible">` here, mirroring the legacy
54
+ * `client:visible` hydration timing — the iframe is heavy and not on
55
+ * the critical path, so we defer hydration until the preview enters
56
+ * the viewport.
57
+ */
58
+ declare function HtmlPreviewWrapper(props: HtmlPreviewWrapperProps): VNode;
59
+
60
+ export { type HtmlPreviewGlobalConfig, HtmlPreviewWrapper, type HtmlPreviewWrapperProps };
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { jsx } from "preact/jsx-runtime";
3
+ import { Island } from "@takazudo/zfb";
4
+ import { HtmlPreview } from "./html-preview.js";
5
+ function HtmlPreviewWrapperInner(props) {
6
+ const { globalConfig, html, css, head, js, title, height, defaultOpen } = props;
7
+ const mergedHead = [globalConfig?.head, head].filter(Boolean).join("\n") || void 0;
8
+ const mergedCss = [globalConfig?.css, css].filter(Boolean).join("\n") || void 0;
9
+ const mergedJs = [globalConfig?.js, js].filter(Boolean).join("\n") || void 0;
10
+ return /* @__PURE__ */ jsx(
11
+ HtmlPreview,
12
+ {
13
+ html,
14
+ css: mergedCss,
15
+ head: mergedHead,
16
+ js: mergedJs,
17
+ title,
18
+ height,
19
+ defaultOpen,
20
+ componentCss: css,
21
+ componentHead: head,
22
+ componentJs: js
23
+ }
24
+ );
25
+ }
26
+ HtmlPreviewWrapperInner.displayName = "HtmlPreviewWrapper";
27
+ function HtmlPreviewWrapper(props) {
28
+ const rendered = Island({
29
+ when: "visible",
30
+ children: /* @__PURE__ */ jsx(HtmlPreviewWrapperInner, { ...props })
31
+ });
32
+ return rendered;
33
+ }
34
+ export {
35
+ HtmlPreviewWrapper
36
+ };
@@ -0,0 +1,35 @@
1
+ import { VNode } from 'preact';
2
+
3
+ /** @jsxRuntime automatic */
4
+ /** @jsxImportSource preact */
5
+
6
+ interface HtmlPreviewProps {
7
+ html: string;
8
+ css?: string;
9
+ head?: string;
10
+ js?: string;
11
+ title?: string;
12
+ height?: number;
13
+ defaultOpen?: boolean;
14
+ /** Per-component css for code block display (before global merge) */
15
+ componentCss?: string;
16
+ /** Per-component head for code block display (before global merge) */
17
+ componentHead?: string;
18
+ /** Per-component js for code block display (before global merge) */
19
+ componentJs?: string;
20
+ }
21
+ /**
22
+ * HTML preview widget — renders an isolated iframe with viewport
23
+ * controls and a collapsible code section.
24
+ *
25
+ * JSX port of src/components/html-preview/html-preview.tsx with
26
+ * React → Preact hook imports.
27
+ *
28
+ * Requires client-side JS (iframe load events, height sync, code
29
+ * toggle). Mount as an island via `<HtmlPreview client:visible />` in
30
+ * Astro, or wire up the SSR-skip placeholder pattern for non-Astro
31
+ * consumers.
32
+ */
33
+ declare function HtmlPreview({ html, css, head, js, title, height, defaultOpen, componentCss, componentHead, componentJs, }: HtmlPreviewProps): VNode;
34
+
35
+ export { HtmlPreview, type HtmlPreviewProps };
@@ -0,0 +1,75 @@
1
+ import { jsx } from "preact/jsx-runtime";
2
+ import { useMemo } from "preact/hooks";
3
+ import { PreviewBase } from "./preview-base.js";
4
+ import { dedent } from "./dedent.js";
5
+ import { preflightCss } from "./preflight.js";
6
+ function containsScript(head, js) {
7
+ if (js) return true;
8
+ if (head && /<script/i.test(head)) return true;
9
+ return false;
10
+ }
11
+ function buildSrcdoc(html, css, head, js) {
12
+ return `<!doctype html>
13
+ <html>
14
+ <head>
15
+ <meta charset="utf-8">
16
+ <meta name="viewport" content="width=device-width,initial-scale=1">
17
+ <style>${preflightCss}</style>
18
+ ${head ?? ""}
19
+ ${css ? `<style>${css}</style>` : ""}
20
+ </head>
21
+ <body>${html}
22
+ ${js ? `<script>${js}</script>` : ""}
23
+ </body>
24
+ </html>`;
25
+ }
26
+ function HtmlPreview({
27
+ html,
28
+ css,
29
+ head,
30
+ js,
31
+ title,
32
+ height,
33
+ defaultOpen,
34
+ componentCss,
35
+ componentHead,
36
+ componentJs
37
+ }) {
38
+ const srcdoc = useMemo(
39
+ () => buildSrcdoc(html, css, head, js),
40
+ [html, css, head, js]
41
+ );
42
+ const hasScripts = containsScript(head, js);
43
+ const syncDelay = hasScripts ? 300 : 0;
44
+ const sandboxValue = hasScripts ? "allow-scripts allow-same-origin" : "allow-same-origin";
45
+ const codeBlocks = useMemo(
46
+ () => [
47
+ { language: "html", title: "HTML", code: dedent(html) },
48
+ ...componentCss ? [{ language: "css", title: "CSS", code: dedent(componentCss) }] : [],
49
+ ...componentHead ? [{ language: "html", title: "Head", code: dedent(componentHead) }] : [],
50
+ ...componentJs ? [
51
+ {
52
+ language: "javascript",
53
+ title: "JS",
54
+ code: dedent(componentJs)
55
+ }
56
+ ] : []
57
+ ],
58
+ [html, componentCss, componentHead, componentJs]
59
+ );
60
+ return /* @__PURE__ */ jsx(
61
+ PreviewBase,
62
+ {
63
+ title,
64
+ height,
65
+ srcdoc,
66
+ defaultOpen,
67
+ sandbox: sandboxValue,
68
+ syncDelay,
69
+ codeBlocks
70
+ }
71
+ );
72
+ }
73
+ export {
74
+ HtmlPreview
75
+ };
@@ -0,0 +1,5 @@
1
+ export { HtmlPreviewGlobalConfig, HtmlPreviewWrapper, HtmlPreviewWrapperProps } from './html-preview-wrapper.js';
2
+ export { HtmlPreview, HtmlPreviewProps } from './html-preview.js';
3
+ export { CodeBlockData, PreviewBase, PreviewBaseProps } from './preview-base.js';
4
+ export { HighlightedCode, HighlightedCodeProps } from './highlighted-code.js';
5
+ import 'preact';
@@ -0,0 +1,12 @@
1
+ import {
2
+ HtmlPreviewWrapper
3
+ } from "./html-preview-wrapper.js";
4
+ import { HtmlPreview } from "./html-preview.js";
5
+ import { PreviewBase } from "./preview-base.js";
6
+ import { HighlightedCode } from "./highlighted-code.js";
7
+ export {
8
+ HighlightedCode,
9
+ HtmlPreview,
10
+ HtmlPreviewWrapper,
11
+ PreviewBase
12
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Tailwind CSS v4 preflight (modern-normalize/reset).
3
+ * Source: https://unpkg.com/tailwindcss@4/preflight.css
4
+ *
5
+ * The --theme() references are replaced with standard fallback values
6
+ * so the reset works standalone inside an iframe.
7
+ *
8
+ * Copied verbatim from src/components/html-preview/preflight.ts so the
9
+ * v2 package has no upward dependency on the host project's source.
10
+ */
11
+ declare const preflightCss = "\n*,\n::after,\n::before,\n::backdrop,\n::file-selector-button {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0 solid;\n}\n\nhtml,\n:host {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n font-family: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n -webkit-tap-highlight-color: transparent;\n}\n\nhr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n}\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\nh1, h2, h3, h4, h5, h6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\na {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n}\n\nb, strong {\n font-weight: bolder;\n}\n\ncode, kbd, samp, pre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;\n font-size: 1em;\n}\n\nsmall {\n font-size: 80%;\n}\n\nsub, sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub { bottom: -0.25em; }\nsup { top: -0.5em; }\n\ntable {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n}\n\nol, ul, menu {\n list-style: none;\n}\n\nimg, svg, video, canvas, audio, iframe, embed, object {\n display: block;\n vertical-align: middle;\n}\n\nimg, video {\n max-width: 100%;\n height: auto;\n}\n\nbutton, input, select, optgroup, textarea, ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n border-radius: 0;\n background-color: transparent;\n opacity: 1;\n}\n\ntextarea {\n resize: vertical;\n}\n\n[hidden]:where(:not([hidden='until-found'])) {\n display: none !important;\n}\n";
12
+
13
+ export { preflightCss };