@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,156 @@
1
+ import { CAPTURE_ISLANDS_READY_GLOBAL } from "../../packages/internal/format-geometry/dist/capture.js";
2
+ import "../../packages/internal/format-geometry/dist/index.js";
3
+ import { islandRuntimeFile } from "../dev/islands.js";
4
+ import { javascriptOutput, runPass } from "./esbuild.js";
5
+ import { ISLAND_REACT_EXTERNALS, sanitizeKey } from "./sections.js";
6
+ import { dirname, extname, join } from "node:path";
7
+ import { fileURLToPath, pathToFileURL } from "node:url";
8
+ import { readFile } from "node:fs/promises";
9
+ import { createHash } from "node:crypto";
10
+ import { build } from "esbuild";
11
+ import { createRequire } from "node:module";
12
+
13
+ //#region src/cli/build/static.ts
14
+ function sha256(bytes) {
15
+ return createHash("sha256").update(bytes).digest("hex");
16
+ }
17
+ function bundleOf(stem, ext, bytes) {
18
+ const contentHash = sha256(bytes);
19
+ return {
20
+ filename: `${stem}-${contentHash}${ext}`,
21
+ contentHash,
22
+ bytes
23
+ };
24
+ }
25
+ const FROM_SOURCE = extname(fileURLToPath(import.meta.url)) === ".ts";
26
+ function packageFile(sourcePath, distPath) {
27
+ const here = dirname(fileURLToPath(import.meta.url));
28
+ return FROM_SOURCE ? join(here, "..", "..", sourcePath) : join(here, "..", "..", distPath);
29
+ }
30
+ /** The page-level stylesheet: layer order, reset gaps, the primitives' own classes. */
31
+ async function baseCssBundle() {
32
+ const bytes = await readFile(packageFile("css/base.css", "base.css"));
33
+ return bundleOf("base", ".css", new Uint8Array(bytes));
34
+ }
35
+ /**
36
+ * The island runtime chunk every page with an island loads once: hydrates each marker
37
+ * from the island map the document carries, and publishes the capture-readiness promise
38
+ * a capturer awaits. React stays external, resolved through the page's import map, so
39
+ * the runtime and every island share one React.
40
+ */
41
+ async function islandRuntimeBundle() {
42
+ const source = [
43
+ `import { hydrateIslands, islandsCaptureReady } from ${JSON.stringify(islandRuntimeFile())};`,
44
+ `const map = window.__TR_ISLAND_MAP || {};`,
45
+ `const moduleUrl = (key) => { const url = map[key]; return url ? new URL(url, document.baseURI).href : null; };`,
46
+ `let hydrationFailure = null;`,
47
+ `const hydrated = hydrateIslands({`,
48
+ ` load: (key) => { const url = moduleUrl(key); return url ? import(url) : Promise.reject(new Error("no island module for " + key)); },`,
49
+ ` moduleUrl,`,
50
+ ` schedule: window.__TR_ISLAND_SCHEDULE,`,
51
+ ` onError: (e, ctx) => {`,
52
+ ` console.error("island failed to hydrate:", ctx && ctx.key, e);`,
53
+ ` if (!hydrationFailure) hydrationFailure = new Error("island " + (ctx && ctx.key) + " failed to hydrate: " + ((e && e.message) || e));`,
54
+ ` },`,
55
+ `});`,
56
+ `const ready = hydrated.then(async (handles) => { await islandsCaptureReady(handles); if (hydrationFailure) throw hydrationFailure; });`,
57
+ `window.${CAPTURE_ISLANDS_READY_GLOBAL} = ready;`,
58
+ `ready.catch(() => {});`
59
+ ].join("\n");
60
+ return bundleOf("island-runtime", ".mjs", await runPass("The island runtime chunk", async () => {
61
+ return javascriptOutput((await build({
62
+ stdin: {
63
+ contents: source,
64
+ resolveDir: dirname(islandRuntimeFile()),
65
+ loader: "js"
66
+ },
67
+ bundle: true,
68
+ format: "esm",
69
+ target: "es2022",
70
+ platform: "browser",
71
+ minify: true,
72
+ write: false,
73
+ external: [...ISLAND_REACT_EXTERNALS],
74
+ logLevel: "silent"
75
+ })).outputFiles, "the island runtime chunk");
76
+ }));
77
+ }
78
+ function coreNamespace(specifier) {
79
+ return `M_${specifier.replace(/[^a-z0-9]+/gi, "_")}`;
80
+ }
81
+ function externalCorePlugin() {
82
+ return {
83
+ name: "concrete-build:react-vendor-core",
84
+ setup(api) {
85
+ api.onResolve({ filter: /^\.\/react-vendor-core-[0-9a-f]{64}\.mjs$/ }, (args) => ({
86
+ path: args.path,
87
+ external: true
88
+ }));
89
+ }
90
+ };
91
+ }
92
+ async function bundleVendorModule(contents, resolveDir, plugins = []) {
93
+ return runPass("The React vendor graph", async () => {
94
+ return javascriptOutput((await build({
95
+ stdin: {
96
+ contents,
97
+ resolveDir,
98
+ loader: "js"
99
+ },
100
+ bundle: true,
101
+ format: "esm",
102
+ target: "es2022",
103
+ platform: "browser",
104
+ minify: true,
105
+ write: false,
106
+ define: { "process.env.NODE_ENV": JSON.stringify("production") },
107
+ plugins,
108
+ logLevel: "silent"
109
+ })).outputFiles, "a React vendor module");
110
+ });
111
+ }
112
+ /**
113
+ * React for the browser, from the workspace's own React: one CORE bundling every island
114
+ * specifier in a single pass (so React is instantiated once), and one FACADE per
115
+ * specifier re-exporting from the core by its hashed URL. The page's import map points
116
+ * the bare specifiers at the facades; nothing names the core but the facades.
117
+ */
118
+ async function reactVendorBundles(root) {
119
+ const requireFromRoot = createRequire(join(root, "package.json"));
120
+ const resolved = new Map(ISLAND_REACT_EXTERNALS.map((specifier) => [specifier, requireFromRoot.resolve(specifier)]));
121
+ const core = bundleOf("react-vendor-core", ".mjs", await bundleVendorModule([...resolved].map(([specifier, file]) => `export { default as ${coreNamespace(specifier)} } from ${JSON.stringify(file)};`).join("\n"), root));
122
+ const facades = /* @__PURE__ */ new Map();
123
+ for (const [specifier, file] of resolved) {
124
+ const mod = await import(pathToFileURL(file).href);
125
+ const names = Object.keys(mod).filter((name) => name !== "default" && /^[A-Za-z_$][\w$]*$/.test(name)).sort();
126
+ const bytes = await bundleVendorModule([
127
+ `import { ${coreNamespace(specifier)} as M } from ${JSON.stringify(`./${core.filename}`)};`,
128
+ `export default M;`,
129
+ ...names.map((name) => `export const ${name} = M[${JSON.stringify(name)}];`)
130
+ ].join("\n"), root, [externalCorePlugin()]);
131
+ facades.set(specifier, bundleOf(`react-vendor-${sanitizeKey(specifier)}`, ".mjs", bytes));
132
+ }
133
+ return {
134
+ core,
135
+ facades
136
+ };
137
+ }
138
+ /** The published-site analytics beacon and integrations runtime, as one standalone script. */
139
+ async function analyticsBundle() {
140
+ const entry = packageFile("site-runtime/analytics-entry.ts", "site-analytics.js");
141
+ return bundleOf("analytics", ".js", await runPass("The analytics bundle", async () => {
142
+ return javascriptOutput((await build({
143
+ entryPoints: [entry],
144
+ bundle: true,
145
+ format: "esm",
146
+ target: "es2022",
147
+ platform: "browser",
148
+ minify: true,
149
+ write: false,
150
+ logLevel: "silent"
151
+ })).outputFiles, "the analytics bundle");
152
+ }));
153
+ }
154
+
155
+ //#endregion
156
+ export { analyticsBundle, baseCssBundle, islandRuntimeBundle, reactVendorBundles };
@@ -0,0 +1,37 @@
1
+ import { zipSync } from "../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js";
2
+
3
+ //#region src/cli/capture/bundle.ts
4
+ /**
5
+ * Disambiguate names that collide.
6
+ *
7
+ * Page filenames come from the author's own labels and are explicitly not
8
+ * unique — a template labelling two pages identically produces two identical
9
+ * names. Inside a zip that is not cosmetic: the second entry would replace the
10
+ * first and the archive would silently be short a page.
11
+ */
12
+ function uniqueName(taken, name) {
13
+ if (!taken.has(name)) {
14
+ taken.add(name);
15
+ return name;
16
+ }
17
+ const dot = name.lastIndexOf(".");
18
+ const stem = dot > 0 ? name.slice(0, dot) : name;
19
+ const extension = dot > 0 ? name.slice(dot) : "";
20
+ for (let n = 2;; n += 1) {
21
+ const candidate = `${stem} (${n})${extension}`;
22
+ if (!taken.has(candidate)) {
23
+ taken.add(candidate);
24
+ return candidate;
25
+ }
26
+ }
27
+ }
28
+ /** Pack the entries, in the order given — which is the canvas's page order. */
29
+ function bundlePages(entries) {
30
+ const taken = /* @__PURE__ */ new Set();
31
+ const members = {};
32
+ for (const entry of entries) members[uniqueName(taken, entry.name)] = entry.bytes;
33
+ return Buffer.from(zipSync(members, { level: 0 }));
34
+ }
35
+
36
+ //#endregion
37
+ export { bundlePages };
@@ -0,0 +1,51 @@
1
+ //#region src/cli/capture/capture-browser.ts
2
+ /**
3
+ * Close a capture request's page. A capture closes its page in a `finally`,
4
+ * after the artifact has already been written to the response — so a rejection
5
+ * here cannot change what the client received, and letting it out of the handler
6
+ * only produces an unhandled rejection (see request-error.ts). The trigger in
7
+ * practice is the shared browser going away first: the server shutting down
8
+ * mid-capture, or Chromium being reaped under load. Both mean the page is gone
9
+ * already, which is the outcome this call wanted.
10
+ *
11
+ * This is deliberately narrow. It makes CLEANUP non-fatal and nothing else — the
12
+ * capture itself, and every pool failure that precedes the response, still
13
+ * decides the request's status code, so a broken capture can never ship a
14
+ * partial artifact at HTTP 200.
15
+ */
16
+ async function closeCapturePage(page) {
17
+ try {
18
+ await page.close();
19
+ } catch (err) {
20
+ console.warn(`[dev] capture page failed to close: ${err instanceof Error ? err.message : String(err)}`);
21
+ }
22
+ }
23
+ function createCaptureBrowserPool(launch) {
24
+ let pending = null;
25
+ return {
26
+ async acquire() {
27
+ const existing = pending;
28
+ if (existing) {
29
+ const settled = await existing.catch(() => null);
30
+ if (settled?.isConnected()) return settled;
31
+ if (pending === existing) pending = null;
32
+ }
33
+ const started = launch();
34
+ pending = started;
35
+ started.catch(() => {
36
+ if (pending === started) pending = null;
37
+ });
38
+ return started;
39
+ },
40
+ async close() {
41
+ const started = pending;
42
+ pending = null;
43
+ if (!started) return;
44
+ const browser = await started.catch(() => null);
45
+ if (browser?.isConnected()) await browser.close();
46
+ }
47
+ };
48
+ }
49
+
50
+ //#endregion
51
+ export { closeCapturePage, createCaptureBrowserPool };
@@ -0,0 +1,121 @@
1
+ import { CAPTURE_WAIT_UNTIL, captureViewport, printPageSize, settleCapture } from "../../packages/internal/format-geometry/dist/capture.js";
2
+ import "../../packages/internal/format-geometry/dist/index.js";
3
+ import { bundlePages } from "./bundle.js";
4
+ import { closeCapturePage, createCaptureBrowserPool } from "./capture-browser.js";
5
+ import { join } from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+ import { createRequire } from "node:module";
8
+
9
+ //#region src/cli/capture/capture.ts
10
+ /** A capture tool that is not installed — carries the install line. */
11
+ var CaptureUnavailableError = class extends Error {};
12
+ const INSTALL_LINE = "captures need Playwright: npm i -D @playwright/test && npx playwright install chromium";
13
+ async function importPlaywright(root, packageRoot) {
14
+ for (const base of [root, packageRoot]) {
15
+ let resolved;
16
+ try {
17
+ resolved = createRequire(pathToFileURL(join(base, "package.json"))).resolve("@playwright/test");
18
+ } catch {
19
+ continue;
20
+ }
21
+ const mod = await import(pathToFileURL(resolved).href);
22
+ const chromium = mod.chromium ?? mod.default?.chromium;
23
+ if (chromium !== void 0) return { chromium };
24
+ }
25
+ throw new CaptureUnavailableError(INSTALL_LINE);
26
+ }
27
+ function settleHost(page) {
28
+ return {
29
+ evaluate: (expression) => page.evaluate(expression),
30
+ onNetworkActivity: (listener) => {
31
+ page.on("request", listener);
32
+ page.on("requestfinished", listener);
33
+ page.on("requestfailed", listener);
34
+ return () => {
35
+ page.off("request", listener);
36
+ page.off("requestfinished", listener);
37
+ page.off("requestfailed", listener);
38
+ };
39
+ }
40
+ };
41
+ }
42
+ function createCapturer(options) {
43
+ const pool = createCaptureBrowserPool(options.launch ?? (async () => {
44
+ const { chromium } = await importPlaywright(options.root, options.packageRoot);
45
+ try {
46
+ return await chromium.launch();
47
+ } catch (err) {
48
+ throw new CaptureUnavailableError(`chromium is not available — run: npx playwright install chromium\n(${err instanceof Error ? err.message : String(err)})`);
49
+ }
50
+ }));
51
+ const withPage = async (format, run) => {
52
+ const browser = await pool.acquire();
53
+ const viewport = captureViewport(format);
54
+ const page = await browser.newPage({
55
+ viewport: {
56
+ width: viewport.width,
57
+ height: viewport.height
58
+ },
59
+ deviceScaleFactor: viewport.deviceScaleFactor
60
+ });
61
+ try {
62
+ return await run(page);
63
+ } finally {
64
+ await closeCapturePage(page);
65
+ }
66
+ };
67
+ const shoot = async (page, url) => {
68
+ await page.goto(url, { waitUntil: CAPTURE_WAIT_UNTIL });
69
+ await settleCapture(settleHost(page));
70
+ return new Uint8Array(await page.screenshot({ fullPage: false }));
71
+ };
72
+ return {
73
+ screenshot: (url, format) => withPage(format, (page) => shoot(page, url)),
74
+ bundle: (entries, format) => withPage(format, async (page) => {
75
+ const members = [];
76
+ for (const entry of entries) members.push({
77
+ name: entry.name,
78
+ bytes: await shoot(page, entry.url)
79
+ });
80
+ return new Uint8Array(bundlePages(members));
81
+ }),
82
+ print: (url, format) => withPage(format, async (page) => {
83
+ await page.emulateMedia({ media: "screen" });
84
+ await page.goto(url, { waitUntil: CAPTURE_WAIT_UNTIL });
85
+ await settleCapture(settleHost(page));
86
+ const paper = printPageSize(format);
87
+ return new Uint8Array(await page.pdf({
88
+ width: paper.width,
89
+ height: paper.height,
90
+ margin: {
91
+ top: "0",
92
+ right: "0",
93
+ bottom: "0",
94
+ left: "0"
95
+ },
96
+ printBackground: true
97
+ }));
98
+ }),
99
+ close: () => pool.close()
100
+ };
101
+ }
102
+ /**
103
+ * The bytes of one capture the host validated: its documents, resolved against the origin
104
+ * serving the host, shot by `capturer`. The host names the documents and has already
105
+ * dropped every page the fixture switches off; this function only shoots what it is given.
106
+ * Throws {@link CaptureUnavailableError} when the capture tool is not installed.
107
+ */
108
+ async function captureFixture(capturer, origin, request) {
109
+ const entries = request.documents.map((document) => ({
110
+ url: new URL(document.path, origin).href,
111
+ name: document.name
112
+ }));
113
+ const [first] = entries;
114
+ if (first === void 0) throw new Error(`A ${request.kind} capture of "${request.fixture}" names no document.`);
115
+ if (request.kind === "screenshot") return capturer.screenshot(first.url, request.format);
116
+ if (request.kind === "bundle") return capturer.bundle(entries, request.format);
117
+ return capturer.print(first.url, request.format);
118
+ }
119
+
120
+ //#endregion
121
+ export { CaptureUnavailableError, captureFixture, createCapturer };
@@ -0,0 +1,95 @@
1
+ import { CHECK_STAGES, ruleById } from "../../rules/registry.js";
2
+ import { CONCRETE_CLI_VERSION } from "../version.js";
3
+ import { reportViolation } from "./report.js";
4
+ import { bundlesStage } from "./stages/bundles.js";
5
+ import { compositionStage } from "./stages/composition.js";
6
+ import { contractsStage } from "./stages/contracts.js";
7
+ import { dependencyGates } from "./stages/dependencies.js";
8
+ import { fixturesStage } from "./stages/fixtures.js";
9
+ import { lintStage } from "./stages/lint.js";
10
+ import { logicStage } from "./stages/logic.js";
11
+ import { renderStage } from "./stages/render.js";
12
+ import { sectionsStage } from "./stages/sections.js";
13
+ import { stylesheetStage } from "./stages/stylesheet.js";
14
+ import { typecheckStage } from "./stages/typecheck.js";
15
+ import { workspaceStage } from "./stages/workspace.js";
16
+
17
+ //#region src/cli/check/analyze.ts
18
+ const RUNNERS = {
19
+ workspace: workspaceStage,
20
+ typecheck: typecheckStage,
21
+ lint: lintStage,
22
+ composition: compositionStage,
23
+ stylesheet: stylesheetStage,
24
+ logic: logicStage,
25
+ fixtures: fixturesStage,
26
+ sections: sectionsStage,
27
+ contracts: contractsStage,
28
+ render: renderStage,
29
+ bundles: bundlesStage,
30
+ dependencies: (ctx) => dependencyGates(ctx.root, ctx.runCommand)
31
+ };
32
+ async function analyzeCheck(options) {
33
+ return (await analyzeWorkspace(options)).report;
34
+ }
35
+ /**
36
+ * The check run and what its stages produced: the loaded workspace, the composition,
37
+ * the materialized sections. `build` reads the context of a green run rather than
38
+ * loading the workspace a second time, so what it writes is exactly what was graded.
39
+ */
40
+ async function analyzeWorkspace(options) {
41
+ const ctx = {
42
+ root: options.root,
43
+ runCommand: options.runCommand
44
+ };
45
+ const stages = [];
46
+ for (const { id } of CHECK_STAGES) {
47
+ if (options.only !== void 0 && !options.only.includes(id)) continue;
48
+ const outcome = await RUNNERS[id](ctx);
49
+ if ("skipped" in outcome) {
50
+ stages.push({
51
+ id,
52
+ status: "skipped",
53
+ violations: [],
54
+ skipped: outcome.skipped
55
+ });
56
+ continue;
57
+ }
58
+ for (const violation of outcome.violations) {
59
+ const rule = ruleById(violation.rule);
60
+ if (rule.stage !== id) throw new Error(`check: the ${id} stage reported ${violation.rule}, which the rule registry places in the ${rule.stage} stage.`);
61
+ }
62
+ const unmeasured = (outcome.unmeasured ?? []).map((u) => ({
63
+ rule: reportViolation({
64
+ rule: u.rule,
65
+ file: "",
66
+ message: ""
67
+ }).rule,
68
+ gates: u.gates.map((gate) => reportViolation({
69
+ rule: gate,
70
+ file: "",
71
+ message: ""
72
+ }).rule),
73
+ reason: u.reason,
74
+ fix: u.fix
75
+ }));
76
+ stages.push({
77
+ id,
78
+ status: outcome.violations.length === 0 ? "passed" : "failed",
79
+ violations: outcome.violations.map(reportViolation),
80
+ ...unmeasured.length === 0 ? {} : { unmeasured }
81
+ });
82
+ }
83
+ return {
84
+ report: {
85
+ ok: stages.every((stage) => stage.status === "passed"),
86
+ concreteVersion: CONCRETE_CLI_VERSION,
87
+ stages,
88
+ weights: ctx.weights ?? []
89
+ },
90
+ context: ctx
91
+ };
92
+ }
93
+
94
+ //#endregion
95
+ export { analyzeCheck, analyzeWorkspace };
@@ -0,0 +1,19 @@
1
+ import { booleanFlag, parseSpec } from "../commands.js";
2
+ import { formatHuman, toJson } from "./report.js";
3
+ import { analyzeCheck } from "./analyze.js";
4
+ import { findWorkspaceRoot } from "../workspace.js";
5
+ import { parseArgs } from "node:util";
6
+
7
+ //#region src/cli/check/index.ts
8
+ const runCheck = async (argv, io) => {
9
+ const { values } = parseArgs({
10
+ args: [...argv],
11
+ ...parseSpec("check")
12
+ });
13
+ const report = await analyzeCheck({ root: await findWorkspaceRoot(io.cwd) });
14
+ io.stdout.write(booleanFlag(values, "json") ? toJson(report) : formatHuman(report));
15
+ return report.ok ? 0 : 1;
16
+ };
17
+
18
+ //#endregion
19
+ export { runCheck };
@@ -0,0 +1,119 @@
1
+ import { isTemplate } from "../../template/define-template.js";
2
+ import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "../../fixtures/media-plugin.js";
3
+ import { runningCopyPlugin } from "../../template/running-copy.js";
4
+ import { listModules } from "../../section/discovery.js";
5
+ import { existsSync } from "node:fs";
6
+ import { join, relative, sep } from "node:path";
7
+ import { pathToFileURL } from "node:url";
8
+ import { build } from "esbuild";
9
+
10
+ //#region src/cli/check/load-workspace.ts
11
+ /** The one reserved file: the root of the import graph. */
12
+ const TEMPLATE_FILE = "template.ts";
13
+ /** Workspace-relative, `/` separators. */
14
+ function workspacePath(root, file) {
15
+ return relative(root, file).split(sep).join("/");
16
+ }
17
+ function buildMessages(err) {
18
+ const messages = err.errors;
19
+ return Array.isArray(messages) ? messages : null;
20
+ }
21
+ let importSerial = 0;
22
+ /** Build and import the workspace. Every fault is a violation; nothing here throws for an author's mistake. */
23
+ async function loadWorkspace(root) {
24
+ const templateFile = join(root, TEMPLATE_FILE);
25
+ if (!existsSync(templateFile)) return {
26
+ root,
27
+ template: null,
28
+ modules: /* @__PURE__ */ new Map(),
29
+ assets: /* @__PURE__ */ new Map(),
30
+ violations: [{
31
+ rule: "workspace/template-missing",
32
+ file: TEMPLATE_FILE,
33
+ message: `The workspace has no ${TEMPLATE_FILE}. It is the one reserved file: default-export a defineTemplate() value from it.`
34
+ }]
35
+ };
36
+ const files = listModules(root);
37
+ const media = createFixtureMediaPlugin(root);
38
+ let result;
39
+ try {
40
+ result = await build({
41
+ entryPoints: files,
42
+ bundle: true,
43
+ splitting: true,
44
+ format: "esm",
45
+ platform: "node",
46
+ target: "node22",
47
+ outdir: join(root, ".concrete", "cache", "check"),
48
+ outbase: root,
49
+ absWorkingDir: root,
50
+ packages: "external",
51
+ jsx: "automatic",
52
+ loader: {
53
+ ".css": "empty",
54
+ ...MEDIA_LOADERS
55
+ },
56
+ plugins: [
57
+ runningCopyPlugin(),
58
+ externalOutsideWorkspace(root),
59
+ media.plugin
60
+ ],
61
+ sourcemap: "inline",
62
+ metafile: true,
63
+ write: true,
64
+ logLevel: "silent"
65
+ });
66
+ } catch (err) {
67
+ const messages = buildMessages(err);
68
+ if (messages === null) throw err;
69
+ return {
70
+ root,
71
+ template: null,
72
+ modules: /* @__PURE__ */ new Map(),
73
+ assets: /* @__PURE__ */ new Map(),
74
+ violations: messages.map((m) => ({
75
+ rule: "workspace/module-invalid",
76
+ file: m.location?.file ?? "template.ts",
77
+ ...m.location?.line === void 0 ? {} : { line: m.location.line },
78
+ message: m.text
79
+ }))
80
+ };
81
+ }
82
+ process.setSourceMapsEnabled(true);
83
+ const outputByInput = /* @__PURE__ */ new Map();
84
+ for (const [out, meta] of Object.entries(result.metafile.outputs)) if (meta.entryPoint !== void 0) outputByInput.set(join(root, meta.entryPoint), join(root, out));
85
+ const violations = [];
86
+ const modules = /* @__PURE__ */ new Map();
87
+ for (const file of files) {
88
+ const out = outputByInput.get(file);
89
+ if (out === void 0) throw new Error(`check: esbuild produced no output for ${workspacePath(root, file)}.`);
90
+ const url = `${pathToFileURL(out).href}?load=${String(Date.now())}-${String(importSerial++)}`;
91
+ try {
92
+ modules.set(file, await import(url));
93
+ } catch (cause) {
94
+ violations.push({
95
+ rule: "workspace/module-invalid",
96
+ file: workspacePath(root, file),
97
+ message: `${workspacePath(root, file)} throws when it is evaluated: ${cause instanceof Error ? cause.message : String(cause)}`
98
+ });
99
+ }
100
+ }
101
+ const templateModule = modules.get(templateFile);
102
+ let template = null;
103
+ if (templateModule !== void 0) if (isTemplate(templateModule.default)) template = templateModule.default;
104
+ else violations.push({
105
+ rule: "workspace/template-invalid",
106
+ file: TEMPLATE_FILE,
107
+ message: `${TEMPLATE_FILE} does not default-export a defineTemplate() value. Write \`export default defineTemplate({ … })\`.`
108
+ });
109
+ return {
110
+ root,
111
+ template,
112
+ modules,
113
+ assets: media.assets,
114
+ violations
115
+ };
116
+ }
117
+
118
+ //#endregion
119
+ export { TEMPLATE_FILE, loadWorkspace, workspacePath };
@@ -0,0 +1,16 @@
1
+ //#region src/cli/check/messages.ts
2
+ function issuesOf(cause) {
3
+ const issues = cause?.issues;
4
+ return Array.isArray(issues) ? issues : null;
5
+ }
6
+ function describeError(cause) {
7
+ const issues = issuesOf(cause);
8
+ if (issues !== null) return issues.map((issue) => {
9
+ const path = issue.path.map(String).join(".");
10
+ return path === "" ? issue.message : `${path}: ${issue.message}`;
11
+ }).join("\n");
12
+ return cause instanceof Error ? cause.message : String(cause);
13
+ }
14
+
15
+ //#endregion
16
+ export { describeError };
@@ -0,0 +1,39 @@
1
+ //#region src/cli/check/render/class-conflicts.ts
2
+ const SECTION_ROOT_CLASS = "tr-section";
3
+ const MARGIN_UTILITY = /^-?m(?:[trblxyse])?-/;
4
+ const MARGIN_ARBITRARY = /^\[margin(?:-[a-z-]+)?:/;
5
+ function utilityOf(token) {
6
+ let depth = 0;
7
+ let cut = -1;
8
+ for (let i = 0; i < token.length; i++) {
9
+ const ch = token[i];
10
+ if (ch === "[") depth += 1;
11
+ else if (ch === "]") depth -= 1;
12
+ else if (ch === ":" && depth === 0) cut = i;
13
+ }
14
+ return token.slice(cut + 1);
15
+ }
16
+ /**
17
+ * Every framework-owned-box class conflict in one rendered fixture, one entry per
18
+ * distinct offending token per rule — a token repeated across a responsive tree is one
19
+ * defect for the author to fix.
20
+ */
21
+ function checkClassConflicts(html) {
22
+ const marginTokens = /* @__PURE__ */ new Set();
23
+ for (const [tag] of html.matchAll(/<[a-zA-Z][^>]*>/g)) {
24
+ const classAttr = /\sclass\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(tag);
25
+ if (!classAttr) continue;
26
+ const tokens = (classAttr[1] ?? classAttr[2] ?? "").split(/\s+/).filter(Boolean);
27
+ if (tokens.includes(SECTION_ROOT_CLASS)) for (const token of tokens) {
28
+ const utility = utilityOf(token);
29
+ if (MARGIN_UTILITY.test(utility) || MARGIN_ARBITRARY.test(utility)) marginTokens.add(token);
30
+ }
31
+ }
32
+ return [...marginTokens].map((token) => ({
33
+ rule: "section-root-margin",
34
+ token
35
+ }));
36
+ }
37
+
38
+ //#endregion
39
+ export { checkClassConflicts };