@homepages/concrete 1.0.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 (327) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +174 -0
  3. package/codemods/manifest.json +9 -0
  4. package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
  5. package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
  6. package/dist/artifact/playground/client/index.html +13 -0
  7. package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
  8. package/dist/artifact/playground/host.mjs +127 -0
  9. package/dist/asset-modules.d.ts +99 -0
  10. package/dist/base.css +220 -0
  11. package/dist/browser/site-config.d.ts +18 -0
  12. package/dist/browser/site-config.js +56 -0
  13. package/dist/browser/submit-lead.d.ts +98 -0
  14. package/dist/browser/submit-lead.js +188 -0
  15. package/dist/browser.d.ts +3 -0
  16. package/dist/browser.js +4 -0
  17. package/dist/cli/build/artifact.js +225 -0
  18. package/dist/cli/build/captures.js +67 -0
  19. package/dist/cli/build/esbuild.js +127 -0
  20. package/dist/cli/build/fixtures.js +96 -0
  21. package/dist/cli/build/icons.js +76 -0
  22. package/dist/cli/build/index.js +38 -0
  23. package/dist/cli/build/playground.js +31 -0
  24. package/dist/cli/build/sections.js +236 -0
  25. package/dist/cli/build/source.js +62 -0
  26. package/dist/cli/build/static.js +156 -0
  27. package/dist/cli/capture/bundle.js +37 -0
  28. package/dist/cli/capture/capture-browser.js +51 -0
  29. package/dist/cli/capture/capture.js +121 -0
  30. package/dist/cli/check/analyze.js +95 -0
  31. package/dist/cli/check/index.js +19 -0
  32. package/dist/cli/check/load-workspace.js +119 -0
  33. package/dist/cli/check/messages.js +16 -0
  34. package/dist/cli/check/render/class-conflicts.js +39 -0
  35. package/dist/cli/check/render/html.js +86 -0
  36. package/dist/cli/check/render/inputs.js +53 -0
  37. package/dist/cli/check/render/invariants.js +58 -0
  38. package/dist/cli/check/render/island-frames.js +72 -0
  39. package/dist/cli/check/render/marker-coverage.js +102 -0
  40. package/dist/cli/check/render/nav.js +64 -0
  41. package/dist/cli/check/report.js +73 -0
  42. package/dist/cli/check/stages/bundles.js +129 -0
  43. package/dist/cli/check/stages/composition.js +67 -0
  44. package/dist/cli/check/stages/contracts.js +22 -0
  45. package/dist/cli/check/stages/dependencies.js +261 -0
  46. package/dist/cli/check/stages/fixtures.js +74 -0
  47. package/dist/cli/check/stages/lint.js +41 -0
  48. package/dist/cli/check/stages/logic.js +63 -0
  49. package/dist/cli/check/stages/render.js +144 -0
  50. package/dist/cli/check/stages/sections.js +83 -0
  51. package/dist/cli/check/stages/stylesheet.js +31 -0
  52. package/dist/cli/check/stages/typecheck.js +68 -0
  53. package/dist/cli/check/stages/workspace.js +26 -0
  54. package/dist/cli/commands.js +342 -0
  55. package/dist/cli/currency/cache.js +89 -0
  56. package/dist/cli/currency/decide.js +65 -0
  57. package/dist/cli/currency/opt-out.js +16 -0
  58. package/dist/cli/currency/preamble.js +183 -0
  59. package/dist/cli/currency/prompt.js +28 -0
  60. package/dist/cli/currency/refresh.js +44 -0
  61. package/dist/cli/currency/resolve-latest.js +185 -0
  62. package/dist/cli/currency/version-order.js +38 -0
  63. package/dist/cli/dev/crop.js +22 -0
  64. package/dist/cli/dev/hmr.js +26 -0
  65. package/dist/cli/dev/http.js +129 -0
  66. package/dist/cli/dev/index.js +70 -0
  67. package/dist/cli/dev/islands.js +390 -0
  68. package/dist/cli/dev/load-template.js +46 -0
  69. package/dist/cli/dev/request-error.js +22 -0
  70. package/dist/cli/dev/server.js +307 -0
  71. package/dist/cli/dev/tsconfig-paths.js +95 -0
  72. package/dist/cli/dev/vite.js +85 -0
  73. package/dist/cli/dev/workspace-reader.js +274 -0
  74. package/dist/cli/io.d.ts +14 -0
  75. package/dist/cli/media/cache.js +125 -0
  76. package/dist/cli/media/derive.js +252 -0
  77. package/dist/cli/media/deriver-plugin.js +71 -0
  78. package/dist/cli/property/index.js +180 -0
  79. package/dist/cli/property/library.js +137 -0
  80. package/dist/cli/publish/client.js +119 -0
  81. package/dist/cli/publish/freshness.js +66 -0
  82. package/dist/cli/publish/git.js +43 -0
  83. package/dist/cli/publish/index.js +207 -0
  84. package/dist/cli/publish/pack.js +78 -0
  85. package/dist/cli/publish/report.js +98 -0
  86. package/dist/cli/publish/target.js +87 -0
  87. package/dist/cli/publish/wire.js +29 -0
  88. package/dist/cli/tar.js +87 -0
  89. package/dist/cli/upgrade/codemod.js +56 -0
  90. package/dist/cli/upgrade/index.js +263 -0
  91. package/dist/cli/upgrade/manifest.js +72 -0
  92. package/dist/cli/upgrade/plan.js +68 -0
  93. package/dist/cli/upgrade/stage.js +71 -0
  94. package/dist/cli/version.d.ts +12 -0
  95. package/dist/cli/version.js +15 -0
  96. package/dist/cli/workspace.js +108 -0
  97. package/dist/cli.d.ts +6 -0
  98. package/dist/cli.js +94 -0
  99. package/dist/css/compile.js +77 -0
  100. package/dist/css/graph.js +109 -0
  101. package/dist/css/inline.js +132 -0
  102. package/dist/css/rules.js +65 -0
  103. package/dist/design-system/format-variants.js +127 -0
  104. package/dist/eslint/authoring.js +46 -0
  105. package/dist/eslint/correctness.js +42 -0
  106. package/dist/eslint/rules/editor-declaration.js +103 -0
  107. package/dist/eslint/rules/editor-reason.js +135 -0
  108. package/dist/eslint/rules/island-imports.js +20 -0
  109. package/dist/eslint/rules/jsx-visitor.js +20 -0
  110. package/dist/eslint/rules/no-client-runtime.js +88 -0
  111. package/dist/eslint/rules/no-editor-globals.js +60 -0
  112. package/dist/eslint/rules/no-hard-coded-color.js +183 -0
  113. package/dist/eslint/rules/no-inline-style.js +24 -0
  114. package/dist/eslint/rules/no-marker-literal.js +37 -0
  115. package/dist/eslint/rules/no-nondeterminism.js +44 -0
  116. package/dist/eslint/rules/no-px-breakpoint.js +44 -0
  117. package/dist/eslint/rules/no-raw-values.js +45 -0
  118. package/dist/eslint/rules/serializable-props.js +95 -0
  119. package/dist/eslint.d.ts +6 -0
  120. package/dist/eslint.js +26 -0
  121. package/dist/fixtures/brand.d.ts +4 -0
  122. package/dist/fixtures/brand.js +9 -0
  123. package/dist/fixtures/bundle-rule.js +67 -0
  124. package/dist/fixtures/canonical.d.ts +149 -0
  125. package/dist/fixtures/image-dimensions.js +59 -0
  126. package/dist/fixtures/load.js +154 -0
  127. package/dist/fixtures/media-plugin.js +141 -0
  128. package/dist/fixtures/media.js +165 -0
  129. package/dist/fixtures/property.js +210 -0
  130. package/dist/fixtures/resolve.js +202 -0
  131. package/dist/fixtures/rows.js +108 -0
  132. package/dist/fixtures/synthesize-empties.js +42 -0
  133. package/dist/fixtures.d.ts +213 -0
  134. package/dist/fixtures.js +37 -0
  135. package/dist/index.d.ts +53 -0
  136. package/dist/index.js +37 -0
  137. package/dist/islands/client-module.js +97 -0
  138. package/dist/islands/marker.d.ts +43 -0
  139. package/dist/islands/marker.js +44 -0
  140. package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
  141. package/dist/packages/external/concrete/package.js +5 -0
  142. package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
  143. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
  144. package/dist/packages/internal/fill-bake/dist/display.js +9 -0
  145. package/dist/packages/internal/fill-bake/dist/index.js +6 -0
  146. package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
  147. package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
  148. package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
  149. package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
  150. package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
  151. package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
  152. package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
  153. package/dist/packages/internal/format-geometry/dist/index.js +4 -0
  154. package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
  155. package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
  156. package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
  157. package/dist/packages/internal/image-ladder/dist/index.js +4 -0
  158. package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
  159. package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
  160. package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
  161. package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
  162. package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
  163. package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
  164. package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
  165. package/dist/packages/internal/island-runtime/dist/index.js +163 -0
  166. package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
  167. package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
  168. package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
  169. package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
  170. package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
  171. package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
  172. package/dist/packages/internal/property-facts/dist/index.js +3 -0
  173. package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
  174. package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
  175. package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
  176. package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
  177. package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
  178. package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
  179. package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
  180. package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
  181. package/dist/packages/internal/section-contracts/dist/index.js +26 -0
  182. package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
  183. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
  184. package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
  185. package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
  186. package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
  187. package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
  188. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
  189. package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
  190. package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
  191. package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
  192. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
  193. package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
  194. package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
  195. package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
  196. package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
  197. package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
  198. package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
  199. package/dist/packages/internal/source-resolution/dist/index.js +222 -0
  200. package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
  201. package/dist/packages/internal/template-artifact/dist/index.js +7 -0
  202. package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
  203. package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
  204. package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
  205. package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
  206. package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
  207. package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
  208. package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
  209. package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
  210. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
  211. package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
  212. package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
  213. package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
  214. package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
  215. package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
  216. package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
  217. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
  218. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
  219. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
  220. package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
  221. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
  222. package/dist/playground/host/page-state.js +12 -0
  223. package/dist/playground/host/paths.js +9 -0
  224. package/dist/playground/layout.js +24 -0
  225. package/dist/playground/wire.js +36 -0
  226. package/dist/playground-island-runtime.d.ts +3 -0
  227. package/dist/playground-island-runtime.js +4 -0
  228. package/dist/primitives/FrameShell.d.ts +29 -0
  229. package/dist/primitives/FrameShell.js +34 -0
  230. package/dist/primitives/Image.d.ts +119 -0
  231. package/dist/primitives/Image.js +173 -0
  232. package/dist/primitives/Section.d.ts +22 -0
  233. package/dist/primitives/Section.js +26 -0
  234. package/dist/primitives/Tour.d.ts +43 -0
  235. package/dist/primitives/Tour.js +72 -0
  236. package/dist/primitives/Video.d.ts +57 -0
  237. package/dist/primitives/Video.js +116 -0
  238. package/dist/primitives/embed-playback.js +50 -0
  239. package/dist/primitives/index.d.ts +11 -0
  240. package/dist/primitives/marker-attrs.js +44 -0
  241. package/dist/primitives/object-fit.js +11 -0
  242. package/dist/primitives/picture-sources.d.ts +24 -0
  243. package/dist/primitives/picture-sources.js +52 -0
  244. package/dist/primitives/probe-context.js +24 -0
  245. package/dist/primitives/slot-bindings.d.ts +96 -0
  246. package/dist/primitives/slot-bindings.js +226 -0
  247. package/dist/primitives/slot-document.d.ts +35 -0
  248. package/dist/primitives/slot-document.js +37 -0
  249. package/dist/primitives/slot-group.d.ts +40 -0
  250. package/dist/primitives/slot-group.js +45 -0
  251. package/dist/primitives/slot-list.d.ts +21 -0
  252. package/dist/primitives/slot-list.js +23 -0
  253. package/dist/primitives/slot-media.d.ts +71 -0
  254. package/dist/primitives/slot-media.js +98 -0
  255. package/dist/primitives/slot-scalar.d.ts +53 -0
  256. package/dist/primitives/slot-scalar.js +98 -0
  257. package/dist/primitives/slot.d.ts +26 -0
  258. package/dist/primitives/slot.js +28 -0
  259. package/dist/rules/registry.js +479 -0
  260. package/dist/schema/compute.d.ts +22 -0
  261. package/dist/schema/compute.js +30 -0
  262. package/dist/schema/define-schema.d.ts +27 -0
  263. package/dist/schema/define-schema.js +73 -0
  264. package/dist/schema/extract-fill-spec.js +246 -0
  265. package/dist/schema/extract-used-facts.js +176 -0
  266. package/dist/schema/fact.d.ts +65 -0
  267. package/dist/schema/fact.js +33 -0
  268. package/dist/schema/fill-builders.d.ts +387 -0
  269. package/dist/schema/fill-builders.js +263 -0
  270. package/dist/schema/fill-declaration.d.ts +76 -0
  271. package/dist/schema/fill-declaration.js +43 -0
  272. package/dist/schema/fill-spec.d.ts +18 -0
  273. package/dist/schema/fill-spec.js +170 -0
  274. package/dist/schema/format-presets.d.ts +27 -0
  275. package/dist/schema/format-presets.js +76 -0
  276. package/dist/schema/format.d.ts +22 -0
  277. package/dist/schema/format.js +40 -0
  278. package/dist/schema/formats.d.ts +6 -0
  279. package/dist/schema/formats.js +7 -0
  280. package/dist/schema/layout.d.ts +32 -0
  281. package/dist/schema/layout.js +30 -0
  282. package/dist/schema/manifest.js +300 -0
  283. package/dist/schema/property-facts.d.ts +83 -0
  284. package/dist/schema/runtime-values.d.ts +88 -0
  285. package/dist/schema/section-nav.d.ts +38 -0
  286. package/dist/schema/section-nav.js +29 -0
  287. package/dist/schema/section-props.d.ts +98 -0
  288. package/dist/schema/section-schema.d.ts +53 -0
  289. package/dist/schema/section-schema.js +54 -0
  290. package/dist/schema/slot-builders.d.ts +497 -0
  291. package/dist/schema/slot-builders.js +331 -0
  292. package/dist/schema/slot-types.d.ts +110 -0
  293. package/dist/schema/slot-types.js +187 -0
  294. package/dist/section/declare.d.ts +44 -0
  295. package/dist/section/declare.js +27 -0
  296. package/dist/section/discovery.js +76 -0
  297. package/dist/section/groups.js +74 -0
  298. package/dist/section/materialize.js +28 -0
  299. package/dist/section/placements.js +28 -0
  300. package/dist/section/section.d.ts +69 -0
  301. package/dist/section/section.js +101 -0
  302. package/dist/site-analytics.d.ts +1 -0
  303. package/dist/site-analytics.js +15 -0
  304. package/dist/site-runtime/analytics.js +97 -0
  305. package/dist/site-runtime/site-integrations.js +97 -0
  306. package/dist/styles.css +60 -0
  307. package/dist/template/define-template.d.ts +139 -0
  308. package/dist/template/define-template.js +98 -0
  309. package/dist/template/logic-build.js +191 -0
  310. package/dist/template/logic-shim.d.ts +43 -0
  311. package/dist/template/logic-shim.js +52 -0
  312. package/dist/template/logic-transform.js +92 -0
  313. package/dist/template/materialize.js +107 -0
  314. package/dist/template/reconcile.d.ts +67 -0
  315. package/dist/template/reconcile.js +25 -0
  316. package/dist/template/running-copy.js +58 -0
  317. package/guide/reference/cli/INDEX.md +79 -0
  318. package/guide/reference/cli/build.md +48 -0
  319. package/guide/reference/cli/check.md +49 -0
  320. package/guide/reference/cli/dev.md +46 -0
  321. package/guide/reference/cli/property-add.md +53 -0
  322. package/guide/reference/cli/property-list.md +46 -0
  323. package/guide/reference/cli/publish.md +54 -0
  324. package/guide/reference/cli/upgrade.md +48 -0
  325. package/guide/reference/rules/INDEX.md +190 -0
  326. package/package.json +137 -0
  327. package/tsconfig.base.json +16 -0
@@ -0,0 +1,86 @@
1
+ import { ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE } from "../../../packages/internal/template-contracts/dist/markers.js";
2
+
3
+ //#region src/cli/check/render/html.ts
4
+ const VOID_TAGS = /* @__PURE__ */ new Set([
5
+ "area",
6
+ "base",
7
+ "br",
8
+ "col",
9
+ "embed",
10
+ "hr",
11
+ "img",
12
+ "input",
13
+ "link",
14
+ "meta",
15
+ "param",
16
+ "source",
17
+ "track",
18
+ "wbr"
19
+ ]);
20
+ const TAG_RE = /<(\/)?([a-zA-Z][a-zA-Z0-9-]*)((?:\s[^<>]*?)?)(\/?)>/g;
21
+ const ATTR_RE = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*"([^"]*)")?/g;
22
+ function parseAttrs(raw) {
23
+ const out = {};
24
+ ATTR_RE.lastIndex = 0;
25
+ let m;
26
+ while (m = ATTR_RE.exec(raw)) out[m[1]] = m[2] ?? "";
27
+ return out;
28
+ }
29
+ function decode(s) {
30
+ return s.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&#39;/g, "'");
31
+ }
32
+ /** Parse server-rendered HTML into a tree under a synthetic `#root` node. */
33
+ function parseHtml(html) {
34
+ html = html.replace(/<!--[\s\S]*?-->/g, "");
35
+ const root = {
36
+ tag: "#root",
37
+ classes: [],
38
+ children: []
39
+ };
40
+ const stack = [root];
41
+ let last = 0;
42
+ TAG_RE.lastIndex = 0;
43
+ let m;
44
+ while (m = TAG_RE.exec(html)) {
45
+ const between = decode(html.slice(last, m.index)).replace(/\s+/g, " ").trim();
46
+ last = TAG_RE.lastIndex;
47
+ if (between) {
48
+ const top = stack[stack.length - 1];
49
+ top.text = top.text ? top.text + " " + between : between;
50
+ }
51
+ const closing = m[1];
52
+ const tag = m[2];
53
+ const rawAttrs = m[3] ?? "";
54
+ const selfClose = m[4] === "/";
55
+ if (closing) {
56
+ for (let i = stack.length - 1; i > 0; i--) if (stack[i].tag === tag) {
57
+ stack.length = i;
58
+ break;
59
+ }
60
+ continue;
61
+ }
62
+ const attrs = parseAttrs(rawAttrs);
63
+ const node = {
64
+ tag,
65
+ classes: attrs.class ? attrs.class.split(/\s+/).filter(Boolean) : [],
66
+ children: []
67
+ };
68
+ if (attrs["data-slot-id"]) node.slotId = attrs[ATTR_SLOT_ID];
69
+ if (attrs["data-slot-group"]) node.slotGroup = attrs[ATTR_SLOT_GROUP];
70
+ if (attrs["data-slot-field"]) node.slotField = attrs[ATTR_SLOT_FIELD];
71
+ if ("data-slot-item" in attrs) {
72
+ const idx = Number(attrs[ATTR_SLOT_ITEM]);
73
+ if (Number.isInteger(idx)) node.slotItem = idx;
74
+ }
75
+ if ("data-slot-text-leaf" in attrs) node.textLeaf = true;
76
+ if ("data-slot-unselectable" in attrs) node.unselectable = true;
77
+ if ("data-tr-enhance" in attrs) node.enhance = true;
78
+ if (attrs["data-section-instance-id"]) node.sectionInstance = true;
79
+ stack[stack.length - 1].children.push(node);
80
+ if (!selfClose && !VOID_TAGS.has(tag)) stack.push(node);
81
+ }
82
+ return root;
83
+ }
84
+
85
+ //#endregion
86
+ export { parseHtml };
@@ -0,0 +1,53 @@
1
+ import { renderInstanceSlots } from "../../../fixtures/media.js";
2
+ import { resolveNav } from "./nav.js";
3
+
4
+ //#region src/cli/check/render/inputs.ts
5
+ function* renderInputs(composition, sections, corpus) {
6
+ const byKey = new Map(sections.map((entry) => [entry.key, entry]));
7
+ const { manifest } = composition;
8
+ for (const entry of corpus) {
9
+ const { fixture } = entry;
10
+ const enabled = (instanceId) => fixture.contentDoc.instances.find((i) => i.instance_id === instanceId)?.enabled === true;
11
+ const navPages = manifest.pages.map((page) => ({
12
+ id: page.id,
13
+ label: page.label,
14
+ path: page.path ?? `/${page.id}`,
15
+ sections: page.sections.map((s) => ({
16
+ key: s.section,
17
+ anchor: s.section,
18
+ enabled: enabled(s.instance_id)
19
+ }))
20
+ }));
21
+ for (const page of manifest.pages) {
22
+ const { anchors, pages } = resolveNav({
23
+ pages: navPages,
24
+ currentPageId: page.id
25
+ });
26
+ for (const placed of page.sections) {
27
+ const section = byKey.get(placed.section);
28
+ const instance = fixture.contentDoc.instances.find((i) => i.instance_id === placed.instance_id);
29
+ if (section === void 0 || instance === void 0 || !instance.enabled) continue;
30
+ const firstCase = (section.schema.display?.variant?.cases ?? [])[0];
31
+ yield {
32
+ corpus: entry,
33
+ pageId: page.id,
34
+ instanceId: placed.instance_id,
35
+ entry: section,
36
+ props: {
37
+ slots: renderInstanceSlots(instance, section.section, fixture.media),
38
+ nav: {
39
+ selfAnchor: section.schema.anchor,
40
+ anchors,
41
+ pages
42
+ },
43
+ variant: instance.variant ?? firstCase ?? ""
44
+ },
45
+ where: `fixture "${fixture.id}", page "${page.id}", instance "${placed.instance_id}"`
46
+ };
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ //#endregion
53
+ export { renderInputs };
@@ -0,0 +1,58 @@
1
+ import { FIXTURE_MEDIA_PATH } from "../../../fixtures/media-plugin.js";
2
+
3
+ //#region src/cli/check/render/invariants.ts
4
+ function mediaUrlsIn(html) {
5
+ const urls = [];
6
+ for (const m of html.matchAll(/(?:src|poster|href)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) urls.push((m[1] ?? m[2] ?? "").trim());
7
+ for (const m of html.matchAll(/srcset\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) for (const rung of (m[1] ?? m[2] ?? "").split(",")) {
8
+ const url = rung.trim().split(/\s+/)[0];
9
+ if (url) urls.push(url);
10
+ }
11
+ return urls;
12
+ }
13
+ function decodeAttr(value) {
14
+ return value.replace(/&quot;/g, "\"").replace(/&#x27;|&#39;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
15
+ }
16
+ function fixtureMediaPathOf(url) {
17
+ if (!url.startsWith("/") || url.startsWith("//")) return null;
18
+ const path = url.replace(/[?#].*$/, "");
19
+ return path.startsWith(`${"/fixture-media"}/`) ? path : null;
20
+ }
21
+ /**
22
+ * The render invariants over one fixture's rendered HTML. `carriesMedia` answers
23
+ * whether a fixture media URL (its path, decoded, query and fragment dropped) names
24
+ * bytes the fixture load served; no other URL is ever passed to it.
25
+ */
26
+ function checkRenderInvariants(html, carriesMedia) {
27
+ const violations = [];
28
+ const graded = /* @__PURE__ */ new Set();
29
+ for (const raw of mediaUrlsIn(html)) {
30
+ const url = fixtureMediaPathOf(decodeAttr(raw));
31
+ if (url === null || graded.has(url)) continue;
32
+ graded.add(url);
33
+ if (!carriesMedia(url)) violations.push({
34
+ rule: "unresolved-media",
35
+ detail: `media URL "${url}" names no file the fixture's media serves`
36
+ });
37
+ }
38
+ if (html.includes("[object Object]")) violations.push({
39
+ rule: "sentinel-text",
40
+ detail: "rendered text contains \"[object Object]\""
41
+ });
42
+ for (const m of html.matchAll(/>\s*(null|undefined|NaN)\s*</g)) violations.push({
43
+ rule: "sentinel-text",
44
+ detail: `rendered leaf is the bare sentinel "${m[1]}"`
45
+ });
46
+ for (const m of html.matchAll(/<img\b[^>]*>/g)) {
47
+ const attr = /\ssrc\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(m[0]);
48
+ const src = attr ? attr[1] ?? attr[2] : void 0;
49
+ if (src === void 0 || src.trim() === "" || src === "undefined" || src === "null") violations.push({
50
+ rule: "broken-image",
51
+ detail: `<img> with ${src === void 0 ? "no src" : `src="${src}"`}`
52
+ });
53
+ }
54
+ return violations;
55
+ }
56
+
57
+ //#endregion
58
+ export { checkRenderInvariants };
@@ -0,0 +1,72 @@
1
+ import { ATTR_ISLAND_KEY, ISLAND_ELEMENT } from "../../../packages/internal/island-runtime/dist/contract.js";
2
+
3
+ //#region src/cli/check/render/island-frames.ts
4
+ /**
5
+ * Elements that ARE content even when empty, so their presence in a server render is
6
+ * something a `serverFrame = false` declaration would delete.
7
+ *
8
+ * `canvas` is deliberately absent, and it is the distinction this check turns on: a
9
+ * canvas is an empty box until code draws into it, which is exactly the island the
10
+ * declaration exists for. A nested island marker counts: whatever it wrapped is markup
11
+ * the parent's render carried.
12
+ */
13
+ const CONTENT_ELEMENTS = /* @__PURE__ */ new Set([
14
+ "img",
15
+ "svg",
16
+ "picture",
17
+ "video",
18
+ "audio",
19
+ "iframe",
20
+ "object",
21
+ "embed",
22
+ "input",
23
+ "select",
24
+ "textarea",
25
+ "hr",
26
+ ISLAND_ELEMENT
27
+ ]);
28
+ const TAG = /<([a-zA-Z][a-zA-Z0-9-]*)/g;
29
+ /**
30
+ * Whether a server-rendered subtree carries anything a visitor or a crawler gets with no
31
+ * JavaScript: text, or one of {@link CONTENT_ELEMENTS}.
32
+ *
33
+ * Empty containers do not count, and that is the point: `<div class="map"></div>` is a
34
+ * box an island fills at runtime, not content. `<script>` and `<style>` bodies do not
35
+ * count either; a nested island's props payload is a `<script>` that would otherwise
36
+ * read as content for the island that wrapped it.
37
+ */
38
+ function carriesContent(html) {
39
+ const stripped = html.replace(/<!--[\s\S]*?-->/g, "").replace(/<script\b[^<>]*>[\s\S]*?<\/script\s*>/gi, "").replace(/<style\b[^<>]*>[\s\S]*?<\/style\s*>/gi, "");
40
+ for (const match of stripped.matchAll(TAG)) if (CONTENT_ELEMENTS.has(match[1].toLowerCase())) return true;
41
+ return stripped.replace(/<[^<>]*>/g, "").trim() !== "";
42
+ }
43
+ const MARKER_TOKEN = new RegExp(`<(/?)${ISLAND_ELEMENT}(\\s[^<>]*)?>`, "g");
44
+ const KEY_ATTR = new RegExp(`${ATTR_ISLAND_KEY}="([^"]*)"`);
45
+ function unescapeAttribute(value) {
46
+ return value.replace(/&quot;/g, "\"").replace(/&#x27;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
47
+ }
48
+ /**
49
+ * Every island marker in rendered HTML, innermost first within a nest.
50
+ *
51
+ * A token scan rather than a parse: React escapes `<` in every attribute value and the
52
+ * props payload escapes it too, so the only `<tr-island` in the output is a real marker.
53
+ * Markers nest (an island rendering another), so open tags stack.
54
+ */
55
+ function islandMarkers(html) {
56
+ const out = [];
57
+ const open = [];
58
+ for (const match of html.matchAll(MARKER_TOKEN)) if (match[1] === "/") {
59
+ const start = open.pop();
60
+ if (start !== void 0) out.push({
61
+ islandKey: start.islandKey,
62
+ inner: html.slice(start.start, match.index)
63
+ });
64
+ } else open.push({
65
+ islandKey: unescapeAttribute(KEY_ATTR.exec(match[2] ?? "")?.[1] ?? ""),
66
+ start: match.index + match[0].length
67
+ });
68
+ return out;
69
+ }
70
+
71
+ //#endregion
72
+ export { carriesContent, islandMarkers };
@@ -0,0 +1,102 @@
1
+ //#region src/cli/check/render/marker-coverage.ts
2
+ function push(map, key, value) {
3
+ const existing = map.get(key);
4
+ if (existing) existing.push(value);
5
+ else map.set(key, [value]);
6
+ }
7
+ /** Walk one parsed render and record every marker it offers the editor. */
8
+ function collectMarkerCoverage(root) {
9
+ const coverage = {
10
+ slotIds: /* @__PURE__ */ new Set(),
11
+ selectableSlotIds: /* @__PURE__ */ new Set(),
12
+ itemScopesBySlot: /* @__PURE__ */ new Map(),
13
+ rowFieldsBySlot: /* @__PURE__ */ new Map(),
14
+ enclosingGroupsBySlot: /* @__PURE__ */ new Map()
15
+ };
16
+ const walk = (node, parentScope, parentItemSlot, parentGroups) => {
17
+ const opensScope = node.slotId !== void 0 || node.slotField !== void 0;
18
+ let scope = parentScope;
19
+ if (opensScope) {
20
+ scope = {
21
+ slotId: node.slotId,
22
+ fieldName: node.slotField
23
+ };
24
+ if (node.slotId !== void 0) {
25
+ scope.items = {
26
+ unselectable: node.unselectable === true,
27
+ ownItem: node.slotItem !== void 0,
28
+ indices: [],
29
+ selectableIndices: []
30
+ };
31
+ push(coverage.itemScopesBySlot, node.slotId, scope.items);
32
+ }
33
+ }
34
+ const groups = node.slotGroup ? /* @__PURE__ */ new Set([...parentGroups, node.slotGroup]) : parentGroups;
35
+ if (node.slotId !== void 0) {
36
+ coverage.slotIds.add(node.slotId);
37
+ if (node.unselectable !== true) {
38
+ coverage.selectableSlotIds.add(node.slotId);
39
+ push(coverage.enclosingGroupsBySlot, node.slotId, new Set(groups));
40
+ }
41
+ }
42
+ if (node.slotField !== void 0 && parentItemSlot !== void 0 && node.unselectable !== true) {
43
+ const seen = coverage.rowFieldsBySlot.get(parentItemSlot) ?? /* @__PURE__ */ new Set();
44
+ seen.add(node.slotField);
45
+ coverage.rowFieldsBySlot.set(parentItemSlot, seen);
46
+ }
47
+ let itemSlot = parentItemSlot;
48
+ if (node.slotItem !== void 0 && scope !== void 0) {
49
+ if (scope.items !== void 0) {
50
+ scope.items.indices.push(node.slotItem);
51
+ if (node.unselectable !== true) scope.items.selectableIndices.push(node.slotItem);
52
+ }
53
+ itemSlot = scope.slotId;
54
+ }
55
+ for (const child of node.children) walk(child, scope, itemSlot, groups);
56
+ };
57
+ walk(root, void 0, void 0, /* @__PURE__ */ new Set());
58
+ return coverage;
59
+ }
60
+ /**
61
+ * Item coverage for ONE per-item collection slot in ONE fixture.
62
+ *
63
+ * Three requirements, mirroring how the editor resolves items:
64
+ *
65
+ * - Somewhere on the page, every index `0..rowCount-1` must appear on a selectable
66
+ * item element — a row no selectable element carries can never be selected.
67
+ * - Each full rendering of the collection (a container scope that is neither a
68
+ * containerless row nor flagged non-selectable) must itself mark every row: the
69
+ * editor targets every live copy, so a copy missing a row shows selection on some
70
+ * copies and not others.
71
+ * - No index may fall outside `0..rowCount-1`, on ANY element — flagged copies
72
+ * included, because patching reaches them too and a wrong index patches the
73
+ * wrong row.
74
+ *
75
+ * A repeat index is never reported: within a scope it is the same row rendered
76
+ * twice (a live copy), across scopes the same collection rendered twice, and the
77
+ * editor targets every copy of either kind.
78
+ */
79
+ function checkItemIndices(rowCount, scopes) {
80
+ const problems = [];
81
+ const selectable = /* @__PURE__ */ new Set();
82
+ const all = /* @__PURE__ */ new Set();
83
+ for (const scope of scopes) {
84
+ for (const index of scope.indices) all.add(index);
85
+ for (const index of scope.selectableIndices) selectable.add(index);
86
+ }
87
+ const rowRange = [...Array(rowCount).keys()];
88
+ const missingEverywhere = rowRange.filter((index) => !selectable.has(index));
89
+ if (missingEverywhere.length > 0) problems.push(`${missingEverywhere.length} of ${rowCount} rows carry no selectable data-slot-item (missing ${missingEverywhere.join(", ")}), so the editor cannot select them`);
90
+ for (const scope of scopes) {
91
+ if (scope.unselectable || scope.ownItem) continue;
92
+ const withinScope = new Set(scope.selectableIndices);
93
+ const missingHere = rowRange.filter((index) => !withinScope.has(index) && selectable.has(index));
94
+ if (missingHere.length > 0) problems.push(`a rendered copy of the collection marks ${withinScope.size} of its ${rowCount} rows (missing data-slot-item ${missingHere.join(", ")}) — the editor targets every copy, so each one must mark every row, or opt out of selection entirely`);
95
+ }
96
+ const stray = [...all].filter((index) => index < 0 || index >= rowCount).sort((a, b) => a - b);
97
+ if (stray.length > 0) problems.push(`data-slot-item ${stray.join(", ")} ${stray.length === 1 ? "is" : "are"} outside the ${rowCount} row${rowCount === 1 ? "" : "s"} this fixture renders — the index must be the array position`);
98
+ return problems;
99
+ }
100
+
101
+ //#endregion
102
+ export { checkItemIndices, collectMarkerCoverage };
@@ -0,0 +1,64 @@
1
+ //#region src/cli/check/render/nav.ts
2
+ /**
3
+ * A page's canonical URL: the directory form, always trailing-slash, under
4
+ * `basePath`. `("/", "/")` → `/`; `("/", "/gallery")` → `/gallery/`;
5
+ * `("/template/spw", "/gallery")` → `/template/spw/gallery/`.
6
+ */
7
+ function pageHref(basePath, path) {
8
+ const base = basePath.replace(/\/+$/, "");
9
+ return path === "/" ? `${base}/` : `${base}${path}/`;
10
+ }
11
+ /**
12
+ * The section key → href map for a render of `currentPageId`, plus that
13
+ * render's `nav.pages`.
14
+ *
15
+ * A target on the current page resolves to a bare `#anchor`; a target on
16
+ * another page to that page's `pageHref` plus the fragment. A target listed on
17
+ * several pages prefers the current page, then the first ENABLED page in page
18
+ * order.
19
+ *
20
+ * `anchors` obeys page visibility exactly as `pages` does: a target reachable
21
+ * only through disabled pages is ABSENT from the map rather than resolving to a
22
+ * page that publishes nothing. Absence is the renderer's signal to omit the
23
+ * control entirely — a resolved href would 404, and an `undefined` one React
24
+ * drops leaves a dead, href-less `<a>`. The current page always counts as
25
+ * reachable for its own render: a disabled page is never published, and an
26
+ * editor canvas renders it only for itself, where same-page `#anchor` links
27
+ * must keep working.
28
+ *
29
+ * Section visibility omits by the same rule, one level down: a disabled section
30
+ * ref is not a target on the page that lists it, so a section disabled on every
31
+ * page it appears on is absent from the map, and one disabled on some pages
32
+ * resolves to a page where it still renders. There is no current-page exception
33
+ * here — the page exception exists because a disabled page is still rendered for
34
+ * its own canvas, whereas a disabled section renders nothing anywhere, the page
35
+ * being rendered included, so a bare `#anchor` to it would be dead too.
36
+ *
37
+ * @throws when `currentPageId` names no page in `pages`.
38
+ */
39
+ function resolveNav(input) {
40
+ const { pages, currentPageId, basePath = "/" } = input;
41
+ const current = pages.find((p) => p.id === currentPageId);
42
+ if (!current) throw new Error(`resolveNav: current page "${currentPageId}" is not one of the declared pages (${pages.map((p) => p.id).join(", ")}).`);
43
+ const anchors = {};
44
+ for (const target of targetOrder(pages, current)) for (const section of target.sections) {
45
+ if (section.enabled === false) continue;
46
+ if (section.key in anchors) continue;
47
+ anchors[section.key] = target.id === current.id ? `#${section.anchor}` : `${pageHref(basePath, target.path)}#${section.anchor}`;
48
+ }
49
+ return {
50
+ anchors,
51
+ pages: pages.filter((p) => p.enabled !== false).map((p) => ({
52
+ id: p.id,
53
+ label: p.label,
54
+ href: pageHref(basePath, p.path),
55
+ current: p.id === current.id
56
+ }))
57
+ };
58
+ }
59
+ function targetOrder(pages, current) {
60
+ return [current, ...pages.filter((p) => p.id !== current.id).filter((p) => p.enabled !== false)];
61
+ }
62
+
63
+ //#endregion
64
+ export { pageHref, resolveNav };
@@ -0,0 +1,73 @@
1
+ import { CHECK_STAGES, qualify } from "../../rules/registry.js";
2
+
3
+ //#region src/cli/check/report.ts
4
+ /** A violation as the report carries it. */
5
+ function reportViolation(violation) {
6
+ return {
7
+ rule: qualify(violation.rule),
8
+ file: violation.file,
9
+ ...violation.line === void 0 ? {} : { line: violation.line },
10
+ message: violation.message
11
+ };
12
+ }
13
+ function toJson(report) {
14
+ return `${JSON.stringify(report, null, 2)}\n`;
15
+ }
16
+ const SUMMARY = new Map(CHECK_STAGES.map((stage) => [stage.id, stage.summary]));
17
+ /** Terminal text: one line per stage, each violation under it as `file:line rule message`. */
18
+ function formatHuman(report) {
19
+ const lines = [];
20
+ for (const stage of report.stages) {
21
+ if (stage.status === "skipped") {
22
+ lines.push(`- ${stage.id}: skipped, ${stage.skipped ?? "its input is missing"}`);
23
+ continue;
24
+ }
25
+ const count = stage.violations.length;
26
+ lines.push(stage.status === "passed" ? `✓ ${stage.id}` : `✗ ${stage.id} (${String(count)} ${count === 1 ? "violation" : "violations"})`);
27
+ for (const v of stage.violations) {
28
+ const at = v.line === void 0 ? v.file : `${v.file}:${String(v.line)}`;
29
+ lines.push(` ${at} ${v.rule}`);
30
+ for (const text of v.message.split("\n")) lines.push(` ${text}`);
31
+ }
32
+ if (stage.id === "bundles") lines.push(...formatWeights(report.weights));
33
+ for (const u of stage.unmeasured ?? []) {
34
+ lines.push(` not measured: ${u.gates.join(", ")}. ${u.reason}`);
35
+ lines.push(` ${u.fix}`);
36
+ }
37
+ }
38
+ const failed = report.stages.filter((s) => s.status === "failed");
39
+ const skipped = report.stages.filter((s) => s.status === "skipped");
40
+ const total = failed.reduce((n, s) => n + s.violations.length, 0);
41
+ lines.push("");
42
+ if (report.ok) lines.push(`concrete check passed: ${String(report.stages.length)} stages.`);
43
+ else {
44
+ const parts = [`${String(total)} ${total === 1 ? "violation" : "violations"} in ${String(failed.length)} ${failed.length === 1 ? "stage" : "stages"}`];
45
+ if (skipped.length > 0) parts.push(`${String(skipped.length)} skipped`);
46
+ lines.push(`concrete check failed: ${parts.join(", ")}.`);
47
+ }
48
+ return `${lines.join("\n")}\n`;
49
+ }
50
+ function kb(bytes) {
51
+ return `${(bytes / 1024).toFixed(1)} KB`;
52
+ }
53
+ /** One line per section under the bundles stage: the weights print on every run, not only past a ceiling. */
54
+ function formatWeights(weights) {
55
+ const width = Math.max(0, ...weights.map((w) => w.section.length));
56
+ return weights.map((w) => {
57
+ const name = w.section.padEnd(width);
58
+ if (!w.measured) return ` ${name} not measured`;
59
+ const parts = [`renderer ${kb(w.rendererGzip)} gzip`];
60
+ if (w.islands.length > 0) {
61
+ const largest = Math.max(...w.islands.map((i) => i.gzip));
62
+ parts.push(`${String(w.islands.length)} ${w.islands.length === 1 ? "island" : "islands"}, largest ${kb(largest)} gzip`);
63
+ }
64
+ if (w.assets.length > 0) {
65
+ const total = w.assets.reduce((sum, a) => sum + a.bytes, 0);
66
+ parts.push(`${String(w.assets.length)} ${w.assets.length === 1 ? "asset" : "assets"}, ${kb(total)}`);
67
+ }
68
+ return ` ${name} ${parts.join(" · ")}`;
69
+ });
70
+ }
71
+
72
+ //#endregion
73
+ export { formatHuman, reportViolation, toJson };
@@ -0,0 +1,129 @@
1
+ import { publishedSectionKey } from "../../../packages/internal/template-artifact/dist/layout.js";
2
+ import "../../../packages/internal/template-artifact/dist/index.js";
3
+ import { buildFramedRenderer, buildSection, framedRendererPath } from "../../build/sections.js";
4
+ import { workspacePath } from "../load-workspace.js";
5
+ import { describeError } from "../messages.js";
6
+ import { renderInputs } from "../render/inputs.js";
7
+ import { carriesContent, islandMarkers } from "../render/island-frames.js";
8
+ import { createElement } from "react";
9
+ import { dirname, join } from "node:path";
10
+ import { pathToFileURL } from "node:url";
11
+ import { mkdir, writeFile } from "node:fs/promises";
12
+ import { gzipSync } from "node:zlib";
13
+ import { renderToStaticMarkup } from "react-dom/server";
14
+
15
+ //#region src/cli/check/stages/bundles.ts
16
+ /** Gzipped bytes of a section's renderer bundle above which check fails. */
17
+ const RENDERER_GZIP_CEILING = 300 * 1024;
18
+ /** Gzipped bytes of one island chunk above which check fails. */
19
+ const ISLAND_GZIP_CEILING = 1024 * 1024;
20
+ /** `412.3 KB`: the unit a size message speaks in. */
21
+ function formatBytes(bytes) {
22
+ if (bytes < 1024) return `${String(bytes)} B`;
23
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
24
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
25
+ }
26
+ const gzipBytes = (bytes) => gzipSync(bytes).byteLength;
27
+ async function bundlesStage(ctx) {
28
+ const template = ctx.workspace?.template ?? null;
29
+ const { composition, sections, discovered } = ctx;
30
+ if (template === null || composition === void 0 || sections === void 0 || discovered === void 0) return { skipped: "the sections stage could not materialize the placed sections" };
31
+ const violations = [];
32
+ const weights = [];
33
+ const built = /* @__PURE__ */ new Map();
34
+ for (const entry of [...sections].sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0)) {
35
+ const site = discovered.find((candidate) => candidate.section === entry.section);
36
+ if (site === void 0) continue;
37
+ const input = {
38
+ root: ctx.root,
39
+ key: publishedSectionKey(template.key, entry.key),
40
+ module: join(ctx.root, site.module),
41
+ exportName: site.exportName
42
+ };
43
+ let section;
44
+ try {
45
+ section = await buildSection(input);
46
+ } catch (cause) {
47
+ violations.push({
48
+ rule: "bundles/build-failed",
49
+ file: entry.file,
50
+ message: `Section "${entry.key}" does not bundle the way \`concrete build\` bundles it, so it could not be weighed and would not build: ${describeError(cause)}`
51
+ });
52
+ weights.push({
53
+ section: entry.key,
54
+ file: entry.file,
55
+ measured: false,
56
+ rendererGzip: 0,
57
+ islands: [],
58
+ assets: []
59
+ });
60
+ continue;
61
+ }
62
+ built.set(entry.key, section);
63
+ const rendererGzip = gzipBytes(section.renderer);
64
+ const islands = section.islands.map((island) => ({
65
+ file: workspacePath(ctx.root, island.file),
66
+ gzip: gzipBytes(island.bytes)
67
+ }));
68
+ weights.push({
69
+ section: entry.key,
70
+ file: entry.file,
71
+ measured: true,
72
+ rendererGzip,
73
+ islands,
74
+ assets: section.sources
75
+ });
76
+ if (rendererGzip > 307200) violations.push({
77
+ rule: "bundles/renderer-size",
78
+ file: entry.file,
79
+ message: `The renderer bundle of section "${entry.key}" is ${formatBytes(rendererGzip)} gzip, over the ${formatBytes(RENDERER_GZIP_CEILING)} ceiling. Every platform process that renders the section loads the whole bundle and keeps it. A renderer this heavy is usually carrying a data file, a whole library barrel or a build tool: import only what the render uses.`
80
+ });
81
+ for (const island of islands) {
82
+ if (island.gzip <= 1048576) continue;
83
+ violations.push({
84
+ rule: "bundles/island-size",
85
+ file: island.file,
86
+ message: `The island chunk of ${island.file} is ${formatBytes(island.gzip)} gzip, over the ${formatBytes(ISLAND_GZIP_CEILING)} ceiling. A visitor downloads it when the island comes into view. Import only what the island uses, or split it.`
87
+ });
88
+ }
89
+ if (ctx.corpus !== void 0 && section.islands.some((island) => island.frameless)) violations.push(...await gradeServerFrames(ctx, input, entry, section, composition, sections, ctx.corpus));
90
+ }
91
+ ctx.built = built;
92
+ ctx.weights = weights;
93
+ return { violations };
94
+ }
95
+ /**
96
+ * Render the section's framed renderer (every island wrapped for real) over the corpus,
97
+ * and fail each `serverFrame = false` island whose server render carries content.
98
+ * A render that throws is the render stage's finding, never this rule's.
99
+ */
100
+ async function gradeServerFrames(ctx, input, entry, section, composition, sections, corpus) {
101
+ const frameless = new Map(section.islands.filter((island) => island.frameless).map((island) => [island.islandKey, island]));
102
+ const bytes = await buildFramedRenderer(input);
103
+ const path = framedRendererPath(ctx.root, input.key, bytes);
104
+ await mkdir(dirname(path), { recursive: true });
105
+ await writeFile(path, bytes);
106
+ const Component = (await import(pathToFileURL(path).href)).default;
107
+ const proven = /* @__PURE__ */ new Map();
108
+ for (const render of renderInputs(composition, sections, corpus)) {
109
+ if (render.entry.key !== entry.key) continue;
110
+ let html;
111
+ try {
112
+ html = renderToStaticMarkup(createElement(Component, render.props));
113
+ } catch {
114
+ continue;
115
+ }
116
+ for (const marker of islandMarkers(html)) if (frameless.has(marker.islandKey) && !proven.has(marker.islandKey) && carriesContent(marker.inner)) proven.set(marker.islandKey, render.where);
117
+ }
118
+ return [...proven].map(([islandKey, where]) => {
119
+ const file = workspacePath(ctx.root, frameless.get(islandKey).file);
120
+ return {
121
+ rule: "islands/server-frame",
122
+ file,
123
+ message: `${file} declares \`serverFrame = false\`, but its server render carries content (${where}). The build drops a frameless island's server render, so that content never reaches a published page, a crawler or a visitor without JavaScript. Remove the declaration; declare it only for an island whose content does not exist until a browser draws it, such as a canvas.`
124
+ };
125
+ });
126
+ }
127
+
128
+ //#endregion
129
+ export { ISLAND_GZIP_CEILING, RENDERER_GZIP_CEILING, bundlesStage, formatBytes };