@zazz-ui/core 0.4.1 → 0.5.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 (331) hide show
  1. package/AUTHORING.md +158 -0
  2. package/CHANGELOG.md +331 -0
  3. package/README.md +55 -23
  4. package/dist/scroll-state-C8mA5gq6.js +1 -0
  5. package/dist/sri.json +124 -72
  6. package/dist/zazz.css +1 -1
  7. package/dist/zazz.js +1 -1
  8. package/editor/zazz.css-data.json +116794 -0
  9. package/editor/zazz.html-data.json +1683 -0
  10. package/editor/zazz.language-data.json +5001 -0
  11. package/editor/zazz.lint-data.json +152 -0
  12. package/package.json +12 -5
  13. package/src/base/_breakpoints.css +12 -0
  14. package/src/base/_layers.css +8 -9
  15. package/src/base/_properties-2xl.css +171 -0
  16. package/src/base/_properties-active.css +107 -0
  17. package/src/base/_properties-checked.css +107 -0
  18. package/src/base/_properties-current.css +107 -0
  19. package/src/base/_properties-disabled.css +107 -0
  20. package/src/base/_properties-focus-visible.css +107 -0
  21. package/src/base/_properties-focus-within.css +107 -0
  22. package/src/base/_properties-hover.css +107 -0
  23. package/src/base/_properties-lg.css +171 -0
  24. package/src/base/_properties-md.css +171 -0
  25. package/src/base/_properties-open.css +107 -0
  26. package/src/base/_properties-sm.css +171 -0
  27. package/src/base/_properties-starting.css +55 -0
  28. package/src/base/_properties-stuck.css +55 -0
  29. package/src/base/_properties-xl.css +171 -0
  30. package/src/base/_properties.css +555 -0
  31. package/src/base/_reset.css +67 -75
  32. package/src/base/_switches.css +145 -0
  33. package/src/base/_typography.css +437 -370
  34. package/src/base/_utilities-box.css +142 -0
  35. package/src/base/_utilities-color.css +290 -0
  36. package/src/base/_utilities-effects.css +235 -0
  37. package/src/base/_utilities-flow.css +312 -0
  38. package/src/base/_utilities-grid.css +143 -0
  39. package/src/base/_utilities-margin.css +376 -0
  40. package/src/base/_utilities-pseudo.css +426 -0
  41. package/src/base/_utilities-sizing.css +259 -0
  42. package/src/base/_utilities-spacing.css +190 -0
  43. package/src/base/_utilities-tier-2xl.css +93 -0
  44. package/src/base/_utilities-tier-active.css +61 -0
  45. package/src/base/_utilities-tier-checked.css +61 -0
  46. package/src/base/_utilities-tier-current.css +61 -0
  47. package/src/base/_utilities-tier-disabled.css +61 -0
  48. package/src/base/_utilities-tier-focus-visible.css +61 -0
  49. package/src/base/_utilities-tier-focus-within.css +61 -0
  50. package/src/base/_utilities-tier-hover.css +63 -0
  51. package/src/base/_utilities-tier-lg.css +93 -0
  52. package/src/base/_utilities-tier-md.css +93 -0
  53. package/src/base/_utilities-tier-open.css +61 -0
  54. package/src/base/_utilities-tier-sm.css +93 -0
  55. package/src/base/_utilities-tier-starting.css +35 -0
  56. package/src/base/_utilities-tier-stuck.css +114 -0
  57. package/src/base/_utilities-tier-xl.css +93 -0
  58. package/src/base/_utilities-typography.css +141 -0
  59. package/src/base/_variables.css +323 -372
  60. package/src/base/_view-transitions.css +10 -12
  61. package/src/base/command-score.d.ts.map +1 -1
  62. package/src/base/command-score.js +1 -2
  63. package/src/base/command-score.ts +1 -2
  64. package/src/base/dialog-lifecycle.js +1 -1
  65. package/src/base/dialog-lifecycle.ts +1 -1
  66. package/src/base/embla.d.ts +6 -7
  67. package/src/base/embla.d.ts.map +1 -1
  68. package/src/base/embla.js +89 -55
  69. package/src/base/embla.ts +89 -55
  70. package/src/base/hotkeys.d.ts +0 -5
  71. package/src/base/hotkeys.d.ts.map +1 -1
  72. package/src/base/hotkeys.ts +0 -5
  73. package/src/base/navigation.d.ts +12 -1
  74. package/src/base/navigation.d.ts.map +1 -1
  75. package/src/base/navigation.js +229 -86
  76. package/src/base/navigation.ts +224 -92
  77. package/src/base/reveal.js +14 -14
  78. package/src/base/reveal.ts +14 -14
  79. package/src/base/scroll-state.d.ts +21 -0
  80. package/src/base/scroll-state.d.ts.map +1 -0
  81. package/src/base/scroll-state.js +177 -0
  82. package/src/base/scroll-state.ts +188 -0
  83. package/src/base/signals.d.ts +1 -2
  84. package/src/base/signals.d.ts.map +1 -1
  85. package/src/base/signals.js +4 -6
  86. package/src/base/signals.ts +4 -6
  87. package/src/base/style-format.d.ts +33 -0
  88. package/src/base/style-format.d.ts.map +1 -0
  89. package/src/base/style-format.js +160 -0
  90. package/src/base/style-format.ts +180 -0
  91. package/src/base/typeahead.d.ts +19 -4
  92. package/src/base/typeahead.d.ts.map +1 -1
  93. package/src/base/typeahead.js +68 -21
  94. package/src/base/typeahead.ts +73 -23
  95. package/src/base/utilities.d.ts +188 -0
  96. package/src/base/utilities.d.ts.map +1 -0
  97. package/src/base/utilities.js +750 -0
  98. package/src/base/utilities.ts +865 -0
  99. package/src/base/utils.d.ts +3 -7
  100. package/src/base/utils.d.ts.map +1 -1
  101. package/src/base/utils.js +4 -8
  102. package/src/base/utils.ts +4 -8
  103. package/src/base/zazz-element.d.ts +14 -8
  104. package/src/base/zazz-element.d.ts.map +1 -1
  105. package/src/base/zazz-element.js +14 -8
  106. package/src/base/zazz-element.ts +15 -8
  107. package/src/globals.d.ts +1 -1
  108. package/src/head.d.ts +50 -4
  109. package/src/head.d.ts.map +1 -1
  110. package/src/head.js +119 -38
  111. package/src/head.ts +172 -41
  112. package/src/index.css +57 -14
  113. package/src/index.js +5 -0
  114. package/src/index.ts +6 -0
  115. package/src/manifest.d.ts +36 -5
  116. package/src/manifest.d.ts.map +1 -1
  117. package/src/manifest.js +150 -6
  118. package/src/manifest.ts +167 -9
  119. package/src/primitives/accordion/accordion.css +18 -17
  120. package/src/primitives/accordion/accordion.html +42 -9
  121. package/src/primitives/alert-dialog/alert-dialog.css +13 -13
  122. package/src/primitives/alert-dialog/alert-dialog.html +26 -12
  123. package/src/primitives/autocomplete/autocomplete-groups.html +64 -33
  124. package/src/primitives/autocomplete/autocomplete.css +43 -39
  125. package/src/primitives/autocomplete/autocomplete.d.ts +6 -5
  126. package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -1
  127. package/src/primitives/autocomplete/autocomplete.html +38 -26
  128. package/src/primitives/autocomplete/autocomplete.js +6 -5
  129. package/src/primitives/autocomplete/autocomplete.ts +6 -5
  130. package/src/primitives/avatar/avatar.html +110 -15
  131. package/src/primitives/badge/badge-icon.html +22 -8
  132. package/src/primitives/badge/badge.css +401 -128
  133. package/src/primitives/badge/badge.html +12 -6
  134. package/src/primitives/breadcrumbs/breadcrumbs.html +25 -5
  135. package/src/primitives/button/button-icon-only.html +17 -11
  136. package/src/primitives/button/button-icon.html +9 -3
  137. package/src/primitives/button/button.css +408 -164
  138. package/src/primitives/button/button.html +14 -7
  139. package/src/primitives/button-group/button-group-vertical.html +5 -5
  140. package/src/primitives/button-group/button-group.css +53 -25
  141. package/src/primitives/button-group/button-group.html +18 -12
  142. package/src/primitives/callout/callout.css +114 -0
  143. package/src/primitives/callout/callout.html +188 -0
  144. package/src/primitives/card/card-subgrid.html +249 -34
  145. package/src/primitives/card/card.css +125 -0
  146. package/src/primitives/card/card.html +141 -20
  147. package/src/primitives/carousel/carousel.css +30 -20
  148. package/src/primitives/carousel/carousel.d.ts +7 -10
  149. package/src/primitives/carousel/carousel.d.ts.map +1 -1
  150. package/src/primitives/carousel/carousel.html +420 -84
  151. package/src/primitives/carousel/carousel.js +1 -1
  152. package/src/primitives/carousel/carousel.ts +8 -11
  153. package/src/primitives/checkbox/checkbox-tasklist.html +6 -6
  154. package/src/primitives/checkbox/checkbox.css +98 -40
  155. package/src/primitives/checkbox/checkbox.d.ts.map +1 -1
  156. package/src/primitives/checkbox/checkbox.html +13 -8
  157. package/src/primitives/checkbox/checkbox.js +7 -9
  158. package/src/primitives/checkbox/checkbox.ts +7 -15
  159. package/src/primitives/combobox/combobox-multiselect.html +53 -33
  160. package/src/primitives/combobox/combobox.css +145 -122
  161. package/src/primitives/combobox/combobox.d.ts +12 -11
  162. package/src/primitives/combobox/combobox.d.ts.map +1 -1
  163. package/src/primitives/combobox/combobox.html +48 -28
  164. package/src/primitives/combobox/combobox.js +46 -51
  165. package/src/primitives/combobox/combobox.ts +48 -55
  166. package/src/primitives/command/command-actions.d.ts +2 -3
  167. package/src/primitives/command/command-actions.d.ts.map +1 -1
  168. package/src/primitives/command/command-actions.html +48 -33
  169. package/src/primitives/command/command-actions.js +12 -10
  170. package/src/primitives/command/command-actions.ts +12 -13
  171. package/src/primitives/command/command-dialog.html +49 -25
  172. package/src/primitives/command/command.css +52 -42
  173. package/src/primitives/command/command.d.ts +10 -7
  174. package/src/primitives/command/command.d.ts.map +1 -1
  175. package/src/primitives/command/command.html +95 -46
  176. package/src/primitives/command/command.js +30 -13
  177. package/src/primitives/command/command.ts +30 -12
  178. package/src/primitives/debug/audit-core.d.ts +64 -0
  179. package/src/primitives/debug/audit-core.d.ts.map +1 -0
  180. package/src/primitives/debug/audit-core.js +356 -0
  181. package/src/primitives/debug/audit-core.ts +535 -0
  182. package/src/primitives/debug/debug.d.ts +50 -0
  183. package/src/primitives/debug/debug.d.ts.map +1 -0
  184. package/src/primitives/debug/debug.js +168 -0
  185. package/src/primitives/debug/debug.ts +211 -0
  186. package/src/primitives/dialog/dialog-with-form.html +67 -45
  187. package/src/primitives/dialog/dialog.css +87 -61
  188. package/src/primitives/dialog/dialog.html +25 -17
  189. package/src/primitives/fields/fields.css +108 -134
  190. package/src/primitives/fields/fields.html +39 -0
  191. package/src/primitives/input/input-icon-leading.html +3 -3
  192. package/src/primitives/input/input-icon-trailing.html +3 -3
  193. package/src/primitives/input/input.css +87 -49
  194. package/src/primitives/input/input.html +15 -15
  195. package/src/primitives/input-group/input-group-password-group.html +15 -15
  196. package/src/primitives/input-group/input-group.css +118 -75
  197. package/src/primitives/input-group/input-group.html +42 -30
  198. package/src/primitives/kbd/kbd-group.html +15 -2
  199. package/src/primitives/kbd/kbd.css +44 -31
  200. package/src/primitives/kbd/kbd.html +7 -1
  201. package/src/primitives/layout/layout.css +159 -0
  202. package/src/primitives/layout/layout.html +35 -0
  203. package/src/primitives/lightbox/lightbox.css +178 -105
  204. package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
  205. package/src/primitives/lightbox/lightbox.html +138 -166
  206. package/src/primitives/lightbox/lightbox.js +10 -13
  207. package/src/primitives/lightbox/lightbox.ts +12 -13
  208. package/src/primitives/menu/menu-interest.html +60 -18
  209. package/src/primitives/menu/menu.css +22 -17
  210. package/src/primitives/menu/menu.d.ts +5 -5
  211. package/src/primitives/menu/menu.html +195 -40
  212. package/src/primitives/menu/menu.js +8 -8
  213. package/src/primitives/menu/menu.ts +8 -8
  214. package/src/primitives/menubar/menubar-help-search.html +78 -32
  215. package/src/primitives/menubar/menubar.html +166 -38
  216. package/src/primitives/meter/meter.css +41 -38
  217. package/src/primitives/meter/meter.html +44 -9
  218. package/src/primitives/mobile-menu/mobile-menu.css +47 -40
  219. package/src/primitives/mobile-menu/mobile-menu.html +1460 -179
  220. package/src/primitives/navigation-menu/navigation-menu-featured.html +155 -33
  221. package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +222 -47
  222. package/src/primitives/navigation-menu/navigation-menu-interest.html +130 -38
  223. package/src/primitives/navigation-menu/navigation-menu-megamenu.html +402 -72
  224. package/src/primitives/navigation-menu/navigation-menu-simple.html +90 -40
  225. package/src/primitives/navigation-menu/navigation-menu.css +104 -106
  226. package/src/primitives/navigation-menu/navigation-menu.html +554 -158
  227. package/src/primitives/otp/otp.css +43 -44
  228. package/src/primitives/otp/otp.d.ts +4 -5
  229. package/src/primitives/otp/otp.d.ts.map +1 -1
  230. package/src/primitives/otp/otp.html +7 -6
  231. package/src/primitives/otp/otp.js +13 -18
  232. package/src/primitives/otp/otp.ts +12 -19
  233. package/src/primitives/password-group/password-group.css +132 -107
  234. package/src/primitives/password-group/password-group.d.ts.map +1 -1
  235. package/src/primitives/password-group/password-group.html +23 -16
  236. package/src/primitives/password-group/password-group.js +11 -12
  237. package/src/primitives/password-group/password-group.ts +11 -12
  238. package/src/primitives/popover/popover.css +88 -95
  239. package/src/primitives/popover/popover.html +18 -0
  240. package/src/primitives/progress/progress-indeterminate.html +1 -1
  241. package/src/primitives/progress/progress.css +34 -35
  242. package/src/primitives/progress/progress.html +18 -4
  243. package/src/primitives/prose/prose.html +19 -12
  244. package/src/primitives/radio/radio.css +83 -46
  245. package/src/primitives/radio/radio.html +16 -11
  246. package/src/primitives/reveal/reveal.css +37 -46
  247. package/src/primitives/reveal/reveal.html +15 -0
  248. package/src/primitives/scroll-fade/scroll-fade.css +115 -0
  249. package/src/primitives/scroll-fade/scroll-fade.html +69 -0
  250. package/src/primitives/select/multiselect.d.ts +8 -10
  251. package/src/primitives/select/multiselect.d.ts.map +1 -1
  252. package/src/primitives/select/multiselect.js +23 -27
  253. package/src/primitives/select/multiselect.ts +23 -29
  254. package/src/primitives/select/select-align.html +79 -16
  255. package/src/primitives/select/select-multiple.html +8 -4
  256. package/src/primitives/select/select-sides.html +104 -21
  257. package/src/primitives/select/select.css +297 -186
  258. package/src/primitives/select/select.html +24 -5
  259. package/src/primitives/separator/separator.css +15 -18
  260. package/src/primitives/separator/separator.html +37 -10
  261. package/src/primitives/slider/slider.css +48 -38
  262. package/src/primitives/slider/slider.html +9 -1
  263. package/src/primitives/style-guard/style-guard.d.ts +19 -0
  264. package/src/primitives/style-guard/style-guard.d.ts.map +1 -0
  265. package/src/primitives/style-guard/style-guard.js +125 -0
  266. package/src/primitives/style-guard/style-guard.ts +153 -0
  267. package/src/primitives/switch/switch.css +42 -33
  268. package/src/primitives/switch/switch.html +11 -6
  269. package/src/primitives/table/table-alternating.html +1 -1
  270. package/src/primitives/table/table-grid.html +5 -5
  271. package/src/primitives/table/table-size-sm.html +1 -1
  272. package/src/primitives/table/table.css +64 -61
  273. package/src/primitives/table/table.html +7 -7
  274. package/src/primitives/tabs/tabs.css +167 -166
  275. package/src/primitives/tabs/tabs.d.ts +10 -11
  276. package/src/primitives/tabs/tabs.d.ts.map +1 -1
  277. package/src/primitives/tabs/tabs.html +192 -36
  278. package/src/primitives/tabs/tabs.js +14 -15
  279. package/src/primitives/tabs/tabs.ts +14 -15
  280. package/src/primitives/textarea/textarea.css +69 -44
  281. package/src/primitives/textarea/textarea.html +3 -3
  282. package/src/primitives/toaster/toaster.css +90 -92
  283. package/src/primitives/toaster/toaster.d.ts +0 -6
  284. package/src/primitives/toaster/toaster.d.ts.map +1 -1
  285. package/src/primitives/toaster/toaster.html +22 -18
  286. package/src/primitives/toaster/toaster.js +64 -72
  287. package/src/primitives/toaster/toaster.ts +71 -87
  288. package/src/primitives/toggle/toggle.css +368 -153
  289. package/src/primitives/toggle/toggle.html +27 -9
  290. package/src/primitives/toggle-group/toggle-group-multiple.html +3 -3
  291. package/src/primitives/toggle-group/toggle-group-vertical.html +4 -4
  292. package/src/primitives/toggle-group/toggle-group.css +71 -23
  293. package/src/primitives/toggle-group/toggle-group.html +3 -3
  294. package/src/primitives/toolbar/toolbar.html +35 -13
  295. package/src/primitives/tooltip/tooltip-disabled.html +3 -3
  296. package/src/primitives/tooltip/tooltip-sides.html +36 -14
  297. package/src/primitives/tooltip/tooltip-with-kbd.html +5 -5
  298. package/src/primitives/tooltip/tooltip.css +111 -80
  299. package/src/primitives/tooltip/tooltip.html +3 -3
  300. package/src/primitives/utilities/aspect-ratio.html +51 -7
  301. package/src/primitives/utilities/basis.html +64 -11
  302. package/src/primitives/utilities/col-span.html +65 -9
  303. package/src/primitives/utilities/compose.html +48 -10
  304. package/src/primitives/utilities/flex-align.html +89 -19
  305. package/src/primitives/utilities/flex-direction.html +111 -13
  306. package/src/primitives/utilities/flex-grow.html +41 -7
  307. package/src/primitives/utilities/gap.html +158 -19
  308. package/src/primitives/utilities/grid-cols.html +75 -7
  309. package/src/primitives/utilities/grid-responsive.html +111 -12
  310. package/src/primitives/utilities/margin-auto.html +38 -7
  311. package/src/primitives/utilities/object-fit.html +75 -13
  312. package/src/primitives/utilities/order.html +40 -4
  313. package/src/primitives/utilities/overflow.html +74 -20
  314. package/src/primitives/utilities/padding-compose.html +67 -10
  315. package/src/primitives/utilities/padding.html +84 -13
  316. package/src/primitives/utilities/pile.html +29 -0
  317. package/src/primitives/utilities/position.html +65 -8
  318. package/src/primitives/utilities/responsive-flex.html +54 -7
  319. package/src/primitives/utilities/responsive-grid.html +115 -12
  320. package/src/primitives/utilities/size.html +120 -16
  321. package/src/primitives/utilities/width.html +123 -16
  322. package/examples/about.html +0 -583
  323. package/examples/components.html +0 -1028
  324. package/examples/forms.html +0 -504
  325. package/examples/index.html +0 -261
  326. package/examples/layout.html +0 -313
  327. package/examples/products.html +0 -839
  328. package/examples/responsive.html +0 -332
  329. package/src/base/_layout.css +0 -571
  330. package/src/base/_utilities.css +0 -6758
  331. package/src/primitives/utilities/grid-pile.html +0 -5
@@ -3,15 +3,11 @@
3
3
  * @description Shared helpers for converting HTML data-attribute strings into
4
4
  * typed JavaScript values.
5
5
  *
6
- * This is a **public, consumer-facing** surface (`window.Utils`, documented at
7
- * /docs/scripts/utils), not just kit plumbing: data-attribute configuration
8
- * is the kit's documented pattern for authoring a component
9
- * (CONVENTIONS.scripts.md), so anyone writing a component in the Zazz idiom
10
- * needs this exact parser to match kit behaviour. Keep it here rather than
11
- * folding it into a caller — see docs/adr/0004-keep-utils-public.md.
6
+ * Public surface (`window.Utils`): consumers writing a component in the Zazz
7
+ * idiom need this exact parser to match kit behaviour.
12
8
  *
13
9
  * Callers that need a typed result should wrap it at their own boundary (see
14
- * `readCarouselOptions` in embla.ts) rather than narrowing at each call.
10
+ * `readCarouselOptions` in embla.ts).
15
11
  */
16
12
  /**
17
13
  * @description Converts string values to their appropriate JavaScript types.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAIH;;;;;;;;;;;GAWG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,MAAM,CAexE;AAID;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,mBAAmB,SAAU,OAAO,UAAU,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAYlF,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,KAAK;;;CAGV,CAAC;AAQF,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAIH;;;;;;;;;;;GAWG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,MAAM,CAexE;AAID;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,mBAAmB,SAAU,OAAO,UAAU,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAYlF,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,KAAK;;;CAGV,CAAC;AAQF,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/src/base/utils.js CHANGED
@@ -4,15 +4,11 @@
4
4
  * @description Shared helpers for converting HTML data-attribute strings into
5
5
  * typed JavaScript values.
6
6
  *
7
- * This is a **public, consumer-facing** surface (`window.Utils`, documented at
8
- * /docs/scripts/utils), not just kit plumbing: data-attribute configuration
9
- * is the kit's documented pattern for authoring a component
10
- * (CONVENTIONS.scripts.md), so anyone writing a component in the Zazz idiom
11
- * needs this exact parser to match kit behaviour. Keep it here rather than
12
- * folding it into a caller — see docs/adr/0004-keep-utils-public.md.
7
+ * Public surface (`window.Utils`): consumers writing a component in the Zazz
8
+ * idiom need this exact parser to match kit behaviour.
13
9
  *
14
10
  * Callers that need a typed result should wrap it at their own boundary (see
15
- * `readCarouselOptions` in embla.ts) rather than narrowing at each call.
11
+ * `readCarouselOptions` in embla.ts).
16
12
  */
17
13
  // --- Data type conversion ---
18
14
  /**
@@ -81,7 +77,7 @@ const Utils = {
81
77
  parseDataAttributes,
82
78
  };
83
79
  // Attach to window for the documented public API (`window.Utils`), and export
84
- // for module consumers (embla.js imports it via the main.js bundle).
80
+ // for module consumers (embla.js imports it via the index.js entry).
85
81
  if (typeof window !== "undefined") {
86
82
  window.Utils = Utils;
87
83
  }
package/src/base/utils.ts CHANGED
@@ -5,15 +5,11 @@
5
5
  * @description Shared helpers for converting HTML data-attribute strings into
6
6
  * typed JavaScript values.
7
7
  *
8
- * This is a **public, consumer-facing** surface (`window.Utils`, documented at
9
- * /docs/scripts/utils), not just kit plumbing: data-attribute configuration
10
- * is the kit's documented pattern for authoring a component
11
- * (CONVENTIONS.scripts.md), so anyone writing a component in the Zazz idiom
12
- * needs this exact parser to match kit behaviour. Keep it here rather than
13
- * folding it into a caller — see docs/adr/0004-keep-utils-public.md.
8
+ * Public surface (`window.Utils`): consumers writing a component in the Zazz
9
+ * idiom need this exact parser to match kit behaviour.
14
10
  *
15
11
  * Callers that need a typed result should wrap it at their own boundary (see
16
- * `readCarouselOptions` in embla.ts) rather than narrowing at each call.
12
+ * `readCarouselOptions` in embla.ts).
17
13
  */
18
14
 
19
15
  // --- Data type conversion ---
@@ -90,7 +86,7 @@ const Utils = {
90
86
  };
91
87
 
92
88
  // Attach to window for the documented public API (`window.Utils`), and export
93
- // for module consumers (embla.js imports it via the main.js bundle).
89
+ // for module consumers (embla.js imports it via the index.js entry).
94
90
  if (typeof window !== "undefined") {
95
91
  window.Utils = Utils;
96
92
  }
@@ -2,8 +2,8 @@
2
2
  * @fileoverview The component runtime: a thin base element + the refresh registry.
3
3
  * @description Two small pieces every behavioral component shares:
4
4
  *
5
- * **`ZazzElement`** owns the lifecycle envelope each HTML web component used to
6
- * repeat: the `AbortController`, the reconnect guard, teardown-on-disconnect.
5
+ * **`ZazzElement`** owns the lifecycle envelope of an HTML web component: the
6
+ * `AbortController`, the reconnect guard, teardown-on-disconnect.
7
7
  * Subclasses implement `setup(signal)` (bind everything with `{ signal }`) and,
8
8
  * only when they hold resources an abort can't release, `teardown()`.
9
9
  * Deliberately thin: anything beyond the envelope belongs in the component.
@@ -11,18 +11,24 @@
11
11
  * **`defineZazzElement(tag, cls)`** is the registration guard (safe under
12
12
  * double script loads). Only behavioral components register; the CSS-only
13
13
  * tag forms (`ui-tooltip`, `ui-accordion`, `ui-button-group`,
14
- * `ui-toggle-group`) stay unregistered by design (ADR-0001).
14
+ * `ui-toggle-group`) stay unregistered.
15
15
  *
16
- * **The refresh registry** replaces hand-listing components in navigation.ts:
17
- * a module whose work is scoped to page content (reveal observer, class-form
18
- * carousel init) registers a refresh hook; after a SPA `<main>` swap the
19
- * navigation module calls `refreshAll(newMain)` and never names a component.
16
+ * **The refresh registry** lets navigation.ts re-scan swapped content without
17
+ * naming components: a module whose work is scoped to page content (reveal observer, class-form
18
+ * carousel init) registers a refresh hook, and after a navigation swap the
19
+ * navigation module calls `refreshAll(newMain)`.
20
20
  * Custom elements do not need hooks: their lifecycle rides the swap natively.
21
21
  */
22
22
  /** Base class for Zazz HTML web components: lifecycle envelope only. */
23
23
  declare abstract class ZazzElement extends HTMLElement {
24
24
  #private;
25
25
  connectedCallback(): void;
26
+ /**
27
+ * A `moveBefore()` move (a `data-ui-persist` element riding a navigation swap)
28
+ * keeps the element connected: without this, the browser would fire
29
+ * disconnect + connect and the element would tear down and set up again.
30
+ */
31
+ connectedMoveCallback(): void;
26
32
  disconnectedCallback(): void;
27
33
  /** Bind listeners, observers, and effects here: always with `{ signal }`. */
28
34
  protected abstract setup(signal: AbortSignal): void;
@@ -33,7 +39,7 @@ declare abstract class ZazzElement extends HTMLElement {
33
39
  declare function defineZazzElement(tag: string, cls: CustomElementConstructor): void;
34
40
  type RefreshHook = (scope: Element) => void;
35
41
  /**
36
- * @description Registers a hook to re-scan swapped-in content (SPA `<main>`
42
+ * @description Registers a hook to re-scan swapped-in content (in-page navigation
37
43
  * replacement). Hooks must be idempotent: already-initialized nodes are the
38
44
  * hook's own job to skip.
39
45
  */
@@ -1 +1 @@
1
- {"version":3,"file":"zazz-element.d.ts","sourceRoot":"","sources":["zazz-element.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;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K,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAG5C;;;;GAIG;AACH,iBAAS,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAEhD;AAED,kFAAkF;AAClF,iBAAS,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAExC;AAED,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC"}
@@ -3,8 +3,8 @@
3
3
  * @fileoverview The component runtime: a thin base element + the refresh registry.
4
4
  * @description Two small pieces every behavioral component shares:
5
5
  *
6
- * **`ZazzElement`** owns the lifecycle envelope each HTML web component used to
7
- * repeat: the `AbortController`, the reconnect guard, teardown-on-disconnect.
6
+ * **`ZazzElement`** owns the lifecycle envelope of an HTML web component: the
7
+ * `AbortController`, the reconnect guard, teardown-on-disconnect.
8
8
  * Subclasses implement `setup(signal)` (bind everything with `{ signal }`) and,
9
9
  * only when they hold resources an abort can't release, `teardown()`.
10
10
  * Deliberately thin: anything beyond the envelope belongs in the component.
@@ -12,12 +12,12 @@
12
12
  * **`defineZazzElement(tag, cls)`** is the registration guard (safe under
13
13
  * double script loads). Only behavioral components register; the CSS-only
14
14
  * tag forms (`ui-tooltip`, `ui-accordion`, `ui-button-group`,
15
- * `ui-toggle-group`) stay unregistered by design (ADR-0001).
15
+ * `ui-toggle-group`) stay unregistered.
16
16
  *
17
- * **The refresh registry** replaces hand-listing components in navigation.ts:
18
- * a module whose work is scoped to page content (reveal observer, class-form
19
- * carousel init) registers a refresh hook; after a SPA `<main>` swap the
20
- * navigation module calls `refreshAll(newMain)` and never names a component.
17
+ * **The refresh registry** lets navigation.ts re-scan swapped content without
18
+ * naming components: a module whose work is scoped to page content (reveal observer, class-form
19
+ * carousel init) registers a refresh hook, and after a navigation swap the
20
+ * navigation module calls `refreshAll(newMain)`.
21
21
  * Custom elements do not need hooks: their lifecycle rides the swap natively.
22
22
  */
23
23
  /** Base class for Zazz HTML web components: lifecycle envelope only. */
@@ -29,6 +29,12 @@ class ZazzElement extends HTMLElement {
29
29
  this.#controller = new AbortController();
30
30
  this.setup(this.#controller.signal);
31
31
  }
32
+ /**
33
+ * A `moveBefore()` move (a `data-ui-persist` element riding a navigation swap)
34
+ * keeps the element connected: without this, the browser would fire
35
+ * disconnect + connect and the element would tear down and set up again.
36
+ */
37
+ connectedMoveCallback() { }
32
38
  disconnectedCallback() {
33
39
  this.#controller?.abort();
34
40
  this.#controller = null;
@@ -44,7 +50,7 @@ function defineZazzElement(tag, cls) {
44
50
  }
45
51
  const refreshHooks = [];
46
52
  /**
47
- * @description Registers a hook to re-scan swapped-in content (SPA `<main>`
53
+ * @description Registers a hook to re-scan swapped-in content (in-page navigation
48
54
  * replacement). Hooks must be idempotent: already-initialized nodes are the
49
55
  * hook's own job to skip.
50
56
  */
@@ -4,8 +4,8 @@
4
4
  * @fileoverview The component runtime: a thin base element + the refresh registry.
5
5
  * @description Two small pieces every behavioral component shares:
6
6
  *
7
- * **`ZazzElement`** owns the lifecycle envelope each HTML web component used to
8
- * repeat: the `AbortController`, the reconnect guard, teardown-on-disconnect.
7
+ * **`ZazzElement`** owns the lifecycle envelope of an HTML web component: the
8
+ * `AbortController`, the reconnect guard, teardown-on-disconnect.
9
9
  * Subclasses implement `setup(signal)` (bind everything with `{ signal }`) and,
10
10
  * only when they hold resources an abort can't release, `teardown()`.
11
11
  * Deliberately thin: anything beyond the envelope belongs in the component.
@@ -13,12 +13,12 @@
13
13
  * **`defineZazzElement(tag, cls)`** is the registration guard (safe under
14
14
  * double script loads). Only behavioral components register; the CSS-only
15
15
  * tag forms (`ui-tooltip`, `ui-accordion`, `ui-button-group`,
16
- * `ui-toggle-group`) stay unregistered by design (ADR-0001).
16
+ * `ui-toggle-group`) stay unregistered.
17
17
  *
18
- * **The refresh registry** replaces hand-listing components in navigation.ts:
19
- * a module whose work is scoped to page content (reveal observer, class-form
20
- * carousel init) registers a refresh hook; after a SPA `<main>` swap the
21
- * navigation module calls `refreshAll(newMain)` and never names a component.
18
+ * **The refresh registry** lets navigation.ts re-scan swapped content without
19
+ * naming components: a module whose work is scoped to page content (reveal observer, class-form
20
+ * carousel init) registers a refresh hook, and after a navigation swap the
21
+ * navigation module calls `refreshAll(newMain)`.
22
22
  * Custom elements do not need hooks: their lifecycle rides the swap natively.
23
23
  */
24
24
 
@@ -32,6 +32,13 @@ abstract class ZazzElement extends HTMLElement {
32
32
  this.setup(this.#controller.signal);
33
33
  }
34
34
 
35
+ /**
36
+ * A `moveBefore()` move (a `data-ui-persist` element riding a navigation swap)
37
+ * keeps the element connected: without this, the browser would fire
38
+ * disconnect + connect and the element would tear down and set up again.
39
+ */
40
+ connectedMoveCallback(): void {}
41
+
35
42
  disconnectedCallback(): void {
36
43
  this.#controller?.abort();
37
44
  this.#controller = null;
@@ -57,7 +64,7 @@ type RefreshHook = (scope: Element) => void;
57
64
  const refreshHooks: RefreshHook[] = [];
58
65
 
59
66
  /**
60
- * @description Registers a hook to re-scan swapped-in content (SPA `<main>`
67
+ * @description Registers a hook to re-scan swapped-in content (in-page navigation
61
68
  * replacement). Hooks must be idempotent: already-initialized nodes are the
62
69
  * hook's own job to skip.
63
70
  */
package/src/globals.d.ts CHANGED
@@ -60,7 +60,7 @@ interface CommandEvent extends Event {
60
60
 
61
61
  interface HTMLElementEventMap {
62
62
  command: CommandEvent;
63
- /** Dialog lifecycle events emitted by base/dialog-lifecycle.ts (ADR-0003). */
63
+ /** Dialog lifecycle events emitted by base/dialog-lifecycle.ts. */
64
64
  "zazz:dialog-open": Event;
65
65
  "zazz:dialog-close": Event;
66
66
  }
package/src/head.d.ts CHANGED
@@ -32,16 +32,15 @@ declare const ESM_DEPENDENCIES: readonly CdnDependency[];
32
32
  * **Interest Invokers** (`interestfor`), which drives tooltip triggers and the
33
33
  * optional hover/focus open on menu, menubar, and navigation-menu. Chromium
34
34
  * 142+ ships it; Firefox and Safari do not, so this is the kit's one API below
35
- * the browser-support floor that a polyfill can cover (ADR-0011).
35
+ * the browser-support floor that a polyfill can cover.
36
36
  *
37
- * Deliberately *not* polyfilled any more (all native across the support
38
- * window): the **Popover API** (Chrome 114, Firefox 125, Safari 17, iOS 18.3)
37
+ * Not polyfilled (native across the support window): the **Popover API** (Chrome 114, Firefox 125, Safari 17, iOS 18.3)
39
38
  * and **Invoker Commands** `command`/`commandfor` (Chrome 135, Firefox 144,
40
39
  * Safari 26.2). CSS anchor positioning is below the floor but has no polyfill
41
40
  * here — the components gate it behind `@supports` instead.
42
41
  */
43
42
  declare const POLYFILLS: readonly CdnDependency[];
44
- /** CDN mode for `buildHead` — kit files served from jsDelivr (ticket 06). */
43
+ /** CDN mode for `buildHead` — kit files served from jsDelivr. */
45
44
  export interface CdnHeadOptions {
46
45
  /** Exact published `@zazz-ui/core` version (`"0.1.0"`; never a dist-tag). */
47
46
  version: string;
@@ -82,6 +81,13 @@ export interface HeadOptions {
82
81
  fontDisplay?: "swap" | "optional" | false;
83
82
  /** Include the inline theme-persistence script (last in head). Default `true`. */
84
83
  theme?: boolean;
84
+ /**
85
+ * Local granular grain: the primitives this page uses, loaded file by file
86
+ * from `base` (base layers, the closure's stylesheets in cascade order, one
87
+ * module tag per closure script) instead of `index.css` / `index.js`. For CDN
88
+ * mode, set `cdn.primitives`.
89
+ */
90
+ primitives?: string[];
85
91
  }
86
92
  /**
87
93
  * @description Builds the canonical Zazz `<head>` contents: meta tags, fonts,
@@ -99,4 +105,44 @@ export interface HeadOptions {
99
105
  export declare function buildHead(options?: HeadOptions): string;
100
106
  export { ESM_DEPENDENCIES, POLYFILLS, cdnUrl };
101
107
  export type { CdnDependency };
108
+ /**
109
+ * A page's generated head: the markup between `<!-- zazz:head … -->` and
110
+ * `<!-- /zazz:head -->`. The opening marker may carry the `buildHead` options
111
+ * as JSON (`<!-- zazz:head {"base":"./zazz","primitives":["dialog"]} -->`), so
112
+ * tools can re-render it with another primitive; a bare marker means the
113
+ * default head (the whole kit).
114
+ */
115
+ export interface HeadBlock {
116
+ /** Offset of the opening marker. */
117
+ markerStart: number;
118
+ /** Offset just past the opening marker. */
119
+ start: number;
120
+ /** Offset of the closing marker. */
121
+ end: number;
122
+ options: HeadOptions;
123
+ /** The opening marker's indentation. */
124
+ indent: string;
125
+ }
126
+ /** The opening marker recording `options` (bare when there are none). */
127
+ export declare function headMarker(options?: HeadOptions): string;
128
+ /** The page's head block, or `undefined` without both markers (or with unreadable options). */
129
+ export declare function findHeadBlock(html: string): HeadBlock | undefined;
130
+ /**
131
+ * @description The edit that renders `head` between the page's markers,
132
+ * indented like the opening marker (and, with `options`, rewrites the marker to
133
+ * record them). `undefined` when the page has no head block or the block is
134
+ * already current, modulo formatting.
135
+ *
136
+ * @param html - The page.
137
+ * @param head - The head markup (`buildHead` output).
138
+ * @param options - Options to record in the opening marker (default: keep it).
139
+ * @returns The replaced range and its new text.
140
+ */
141
+ export declare function headBlockEdit(html: string, head: string, options?: HeadOptions): {
142
+ start: number;
143
+ end: number;
144
+ text: string;
145
+ } | undefined;
146
+ /** `html` with its head block rendered from `head` (unchanged when current or absent). */
147
+ export declare function replaceHeadBlock(html: string, head: string, options?: HeadOptions): string;
102
148
  //# sourceMappingURL=head.d.ts.map
package/src/head.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"head.d.ts","sourceRoot":"","sources":["head.ts"],"names":[],"mappings":"AA8BA,wDAAwD;AACxD,UAAU,aAAa;IACrB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AA2CD;;;;;;GAMG;AACH,iBAAS,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAE1C;AAED;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,EAAE,SAAS,aAAa,EA+B7C,CAAC;AAEF;;;;;;;;;;;;G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+F;AAC/F,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAgBjE;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,GACpB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAa1D;AAED,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAG1F"}
package/src/head.js CHANGED
@@ -4,10 +4,9 @@
4
4
  * @description The single owner of everything a Zazz page loads before its own
5
5
  * content: meta tags, the Geist fonts block, the one `index.css` stylesheet
6
6
  * link, the feature polyfill, the third-party **import map**, the `index.js`
7
- * module tag, and the theme-persistence script. The docs preview iframe, the
8
- * kit's example pages (via `scripts/generate-heads.mjs`), and the docs page
9
- * that teaches head structure all render from this module: there is no other
10
- * copy to drift.
7
+ * module tag, and the theme-persistence script. The docs preview iframe and the
8
+ * docs page that teaches head structure both render from this module: there is
9
+ * no other copy to drift.
11
10
  *
12
11
  * This is a Node/server-side string builder (used at build/render time), not a
13
12
  * browser runtime module; it attaches nothing to `window`.
@@ -22,7 +21,7 @@
22
21
  * import { buildHead } from "@zazz-ui/core/head";
23
22
  * const head = buildHead({ base: "./zazz" });
24
23
  */
25
- import { PRIMITIVES, resolveClosure } from "./manifest.js";
24
+ import { BASE_CSS_POST, BASE_CSS_PRE, PRIMITIVES, resolveClosure } from "./manifest.js";
26
25
  /** The one CDN provider for every third-party resource. */
27
26
  const CDN = "https://cdn.jsdelivr.net/npm";
28
27
  /** The kit's own published package name (CDN mode serves files out of it). */
@@ -30,23 +29,15 @@ const PACKAGE_NAME = "@zazz-ui/core";
30
29
  /**
31
30
  * Exact-version pin required in every kit CDN URL. SRI hashes are per-byte,
32
31
  * so floating specs (`latest`, `0.3`) would break integrity on each release —
33
- * and unpinned URLs defeat jsDelivr's permanent caching (ticket 06).
32
+ * and unpinned URLs defeat jsDelivr's permanent caching.
34
33
  */
35
34
  const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
36
35
  /**
37
36
  * Base stylesheets in the exact order `src/index.css` loads them around the
38
37
  * primitive imports: `PRE` before (layer declaration first), `POST` after
39
- * (utilities and layout stay the final normal override layer). The granular
38
+ * (the generated utilities stay the final normal override layer). The granular
40
39
  * CDN head mirrors this split; `head.test.ts` guards it against `index.css`.
41
40
  */
42
- const BASE_CSS_PRE = [
43
- "base/_layers.css",
44
- "base/_variables.css",
45
- "base/_reset.css",
46
- "base/_typography.css",
47
- "base/_view-transitions.css",
48
- ];
49
- const BASE_CSS_POST = ["base/_utilities.css", "base/_layout.css"];
50
41
  /**
51
42
  * Core runtime modules reached by relative import from primitive scripts
52
43
  * (never via their own script tag, except `dialog-lifecycle`, which is a
@@ -58,6 +49,8 @@ const CORE_RUNTIME_JS = [
58
49
  "base/utils.js",
59
50
  "base/signals.js",
60
51
  "base/zazz-element.js",
52
+ // dynamically imported by index.js where container scroll-state queries are unsupported
53
+ "base/scroll-state.js",
61
54
  ];
62
55
  /**
63
56
  * @description Builds the pinned jsDelivr URL for a dependency.
@@ -112,10 +105,9 @@ const ESM_DEPENDENCIES = [
112
105
  * **Interest Invokers** (`interestfor`), which drives tooltip triggers and the
113
106
  * optional hover/focus open on menu, menubar, and navigation-menu. Chromium
114
107
  * 142+ ships it; Firefox and Safari do not, so this is the kit's one API below
115
- * the browser-support floor that a polyfill can cover (ADR-0011).
108
+ * the browser-support floor that a polyfill can cover.
116
109
  *
117
- * Deliberately *not* polyfilled any more (all native across the support
118
- * window): the **Popover API** (Chrome 114, Firefox 125, Safari 17, iOS 18.3)
110
+ * Not polyfilled (native across the support window): the **Popover API** (Chrome 114, Firefox 125, Safari 17, iOS 18.3)
119
111
  * and **Invoker Commands** `command`/`commandfor` (Chrome 135, Firefox 144,
120
112
  * Safari 26.2). CSS anchor positioning is below the floor but has no polyfill
121
113
  * here — the components gate it behind `@supports` instead.
@@ -180,7 +172,7 @@ function polyfillsBlock() {
180
172
  }
181
173
  /**
182
174
  * The theme-persistence script. Runs inline (no `defer`) while the parser is
183
- * still in `<head>`, so `.dark` lands on `<html>` before first paint. The
175
+ * still in `<head>`, so `data-ui-theme` lands on `<html>` before first paint. The
184
176
  * try/catch covers contexts where storage access throws (sandboxed iframes,
185
177
  * blocked site data).
186
178
  */
@@ -188,15 +180,14 @@ const THEME_SCRIPT = `<!-- Theme: apply the persisted (or preferred) scheme befo
188
180
  <script>
189
181
  (() => {
190
182
  try {
183
+ // A stored choice pins the scheme with data-ui-theme; with no
184
+ // choice the attribute stays off and the page follows the system scheme.
191
185
  const storedTheme = localStorage.getItem("theme");
192
- const prefersDark = matchMedia("(prefers-color-scheme: dark)").matches;
193
- const theme = storedTheme ?? (prefersDark ? "dark" : "light");
194
- document.documentElement.classList.toggle("dark", theme === "dark");
186
+ if (storedTheme === "dark" || storedTheme === "light") {
187
+ document.documentElement.setAttribute("data-ui-theme", storedTheme);
188
+ }
195
189
  } catch {
196
- document.documentElement.classList.toggle(
197
- "dark",
198
- matchMedia("(prefers-color-scheme: dark)").matches,
199
- );
190
+ /* no storage access: follow the system scheme */
200
191
  }
201
192
  })();
202
193
  </script>`;
@@ -226,6 +217,9 @@ export function buildHead(options = {}) {
226
217
  if (cdn) {
227
218
  parts.push(...cdnBlocks(cdn, scripts));
228
219
  }
220
+ else if (options.primitives) {
221
+ parts.push(...granularBlocks(options.primitives, (path) => `${base}/${path}`, () => "", scripts));
222
+ }
229
223
  else {
230
224
  parts.push(`<!-- Zazz styles: one bundle (index.css @imports every layer in cascade order) -->`, `<link rel="stylesheet" href="${base}/index.css">`);
231
225
  if (scripts) {
@@ -271,13 +265,39 @@ function cdnBlocks(cdn, scripts) {
271
265
  }
272
266
  return parts;
273
267
  }
268
+ // Transitively imported core modules never get a tag, so their integrity
269
+ // rides in the import map's integrity section instead.
270
+ const transitive = {};
271
+ if (sri) {
272
+ for (const path of CORE_RUNTIME_JS) {
273
+ const hash = sri[`src/${path}`];
274
+ if (hash)
275
+ transitive[url(`src/${path}`)] = hash;
276
+ }
277
+ }
278
+ return granularBlocks(primitives, (path) => url(`src/${path}`), (path) => attrs(`src/${path}`), scripts, transitive);
279
+ }
280
+ /**
281
+ * @description The granular grain, local or CDN: base layers in cascade order,
282
+ * the dependency closure's stylesheets, and one module tag per closure script.
283
+ *
284
+ * @param primitives - The primitives the page uses (their closure loads).
285
+ * @param url - A `src/`-relative kit path → its URL.
286
+ * @param attrs - A `src/`-relative kit path → extra tag attributes (SRI).
287
+ * @param scripts - Whether behavior loads at all.
288
+ * @param transitive - Import-map integrity for modules that get no tag.
289
+ * @returns The head fragments between the fonts block and the theme script.
290
+ * @private
291
+ */
292
+ function granularBlocks(primitives, url, attrs, scripts, transitive = {}) {
293
+ const parts = [];
274
294
  const closure = resolveClosure(primitives);
275
295
  const css = [
276
296
  ...BASE_CSS_PRE,
277
297
  ...closure.flatMap((name) => PRIMITIVES[name]?.css ?? []),
278
298
  ...BASE_CSS_POST,
279
299
  ];
280
- parts.push(`<!-- Zazz styles: base layers, then ${closure.join(", ")} in cascade order -->`, ...css.map((path) => `<link rel="stylesheet" href="${url(`src/${path}`)}"${attrs(`src/${path}`)}>`));
300
+ parts.push(`<!-- Zazz styles: base layers, then ${closure.join(", ")} in cascade order -->`, ...css.map((path) => `<link rel="stylesheet" href="${url(path)}"${attrs(path)}>`));
281
301
  if (scripts) {
282
302
  // Side-effect modules need their own tag (nothing imports them); the rest
283
303
  // of each primitive's chain loads through native relative imports. The
@@ -293,18 +313,79 @@ function cdnBlocks(cdn, scripts) {
293
313
  }),
294
314
  ]),
295
315
  ];
296
- // Transitively imported core modules never get a tag, so their integrity
297
- // rides in the import map's integrity section instead.
298
- const transitive = {};
299
- if (sri) {
300
- for (const path of CORE_RUNTIME_JS) {
301
- const hash = sri[`src/${path}`];
302
- if (hash)
303
- transitive[url(`src/${path}`)] = hash;
304
- }
305
- }
306
- parts.push(importMapBlock(transitive), polyfillsBlock(), `<!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->`, ...scriptFiles.map((path) => `<script type="module" src="${url(`src/${path}`)}"${attrs(`src/${path}`)}></script>`));
316
+ parts.push(importMapBlock(transitive), polyfillsBlock(), `<!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->`, ...scriptFiles.map((path) => `<script type="module" src="${url(path)}"${attrs(path)}></script>`));
307
317
  }
308
318
  return parts;
309
319
  }
310
320
  export { ESM_DEPENDENCIES, POLYFILLS, cdnUrl };
321
+ const HEAD_START = /<!--\s*zazz:head(\s+\{[\s\S]*?\})?\s*-->/;
322
+ const HEAD_END = "<!-- /zazz:head -->";
323
+ /** The opening marker recording `options` (bare when there are none). */
324
+ export function headMarker(options = {}) {
325
+ return Object.keys(options).length
326
+ ? `<!-- zazz:head ${JSON.stringify(options)} -->`
327
+ : "<!-- zazz:head -->";
328
+ }
329
+ /** The page's head block, or `undefined` without both markers (or with unreadable options). */
330
+ export function findHeadBlock(html) {
331
+ const open = HEAD_START.exec(html);
332
+ if (!open)
333
+ return undefined;
334
+ const start = open.index + open[0].length;
335
+ const end = html.indexOf(HEAD_END, start);
336
+ if (end === -1)
337
+ return undefined;
338
+ let options = {};
339
+ if (open[1]) {
340
+ try {
341
+ options = JSON.parse(open[1]);
342
+ }
343
+ catch {
344
+ return undefined;
345
+ }
346
+ }
347
+ const indent = /(?:^|\n)([ \t]*)$/.exec(html.slice(0, open.index))?.[1] ?? "";
348
+ return { markerStart: open.index, start, end, options, indent };
349
+ }
350
+ /**
351
+ * Formatting-insensitive comparison: oxfmt rewraps attributes and self-closes
352
+ * void elements, and those differences don't make a head block out of date.
353
+ */
354
+ function normalizeHead(html) {
355
+ return html
356
+ .replace(/\s+/g, " ")
357
+ .replace(/\s*\/>/g, ">")
358
+ .replace(/\s+>/g, ">")
359
+ .trim();
360
+ }
361
+ /**
362
+ * @description The edit that renders `head` between the page's markers,
363
+ * indented like the opening marker (and, with `options`, rewrites the marker to
364
+ * record them). `undefined` when the page has no head block or the block is
365
+ * already current, modulo formatting.
366
+ *
367
+ * @param html - The page.
368
+ * @param head - The head markup (`buildHead` output).
369
+ * @param options - Options to record in the opening marker (default: keep it).
370
+ * @returns The replaced range and its new text.
371
+ */
372
+ export function headBlockEdit(html, head, options) {
373
+ const block = findHeadBlock(html);
374
+ if (!block)
375
+ return undefined;
376
+ const marker = options ? headMarker(options) : html.slice(block.markerStart, block.start);
377
+ const sameMarker = marker === html.slice(block.markerStart, block.start);
378
+ if (sameMarker && normalizeHead(html.slice(block.start, block.end)) === normalizeHead(head)) {
379
+ return undefined;
380
+ }
381
+ const body = head
382
+ .split("\n")
383
+ .map((line) => (line ? block.indent + line : line))
384
+ .join("\n");
385
+ return { start: block.markerStart, end: block.end, text: `${marker}\n${body}\n${block.indent}` };
386
+ }
387
+ /** `html` with its head block rendered from `head` (unchanged when current or absent). */
388
+ export function replaceHeadBlock(html, head, options) {
389
+ const edit = headBlockEdit(html, head, options);
390
+ return edit ? html.slice(0, edit.start) + edit.text + html.slice(edit.end) : html;
391
+ }