@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,331 @@
1
+ import { fillMark, getFill } from "./fill-declaration.js";
2
+ import { itemLayoutFromRows } from "./layout.js";
3
+
4
+ //#region src/schema/slot-builders.ts
5
+ function head(opts) {
6
+ return {
7
+ ...opts.locked === true ? { locked: true } : {},
8
+ ...opts.source !== void 0 ? { source: opts.source } : {},
9
+ ...opts.writeback !== void 0 ? { writeback: opts.writeback } : {},
10
+ label: opts.label,
11
+ ...opts.placeholder !== void 0 ? { placeholder: opts.placeholder } : {},
12
+ ...opts.when !== void 0 ? { when: opts.when } : {}
13
+ };
14
+ }
15
+ function textOfSize(size) {
16
+ return (opts) => ({
17
+ type: "text",
18
+ size,
19
+ ...head(opts),
20
+ ...opts.cap !== void 0 ? { cap: opts.cap } : {},
21
+ ...fillMark(opts.fill)
22
+ });
23
+ }
24
+ /**
25
+ * The text slot, sized by the member you pick: `text.short` / `.medium` / `.long`.
26
+ *
27
+ * `cap` is the slot's character budget and the ONLY declaration of it: it bounds
28
+ * what a user may type in the editor, and the `textBlock` filling the slot inherits
29
+ * it as the budget the model is asked to write to. A slot an AI fill decision
30
+ * targets must declare one. `fill` takes that `textBlock` — the alternative to
31
+ * `source`, never its companion.
32
+ * @example
33
+ * ```ts
34
+ * import { text, textBlock } from "@homepages/concrete";
35
+ *
36
+ * text.medium({
37
+ * cap: 60,
38
+ * label: "Headline",
39
+ * fill: textBlock({
40
+ * structure: "single_sentence",
41
+ * perspective: "third",
42
+ * voice: "Confident premium-listing voice.",
43
+ * content: "Write a marketing headline.",
44
+ * }),
45
+ * });
46
+ * ```
47
+ */
48
+ const text = {
49
+ short: textOfSize("short"),
50
+ medium: textOfSize("medium"),
51
+ long: textOfSize("long")
52
+ };
53
+ /**
54
+ * A numeric slot. `prefix`/`suffix` are rendered strings (such as `"$"` /
55
+ * `" sq ft"`), `thousandsSep` toggles grouping-separator formatting, `decimals`
56
+ * toggles decimal display, and `maxDigits` caps the digit count — all read by
57
+ * the renderer's number formatting, not enforced as an input range.
58
+ *
59
+ * Binding-only: no fill decision produces a number, so this builder takes no
60
+ * `fill` — the value comes from `source`.
61
+ * @example
62
+ * ```ts
63
+ * import { fact, number } from "@homepages/concrete";
64
+ *
65
+ * number({ source: fact.unit.sqft, writeback: true, label: "Square feet", thousandsSep: true, suffix: "sqft", maxDigits: 7 });
66
+ * ```
67
+ */
68
+ function number(opts) {
69
+ return {
70
+ type: "number",
71
+ ...head(opts),
72
+ ...opts.prefix !== void 0 ? { prefix: opts.prefix } : {},
73
+ ...opts.suffix !== void 0 ? { suffix: opts.suffix } : {},
74
+ ...opts.thousandsSep !== void 0 ? { thousandsSep: opts.thousandsSep } : {},
75
+ ...opts.decimals !== void 0 ? { decimals: opts.decimals } : {},
76
+ ...opts.maxDigits !== void 0 ? { maxDigits: opts.maxDigits } : {}
77
+ };
78
+ }
79
+ function selectFn(opts) {
80
+ const source = opts.source;
81
+ return {
82
+ type: "select",
83
+ ...head(opts),
84
+ ...source?.kind === "direct" ? { options: { source: source.field } } : {},
85
+ ...opts.creatable !== void 0 ? { creatable: opts.creatable } : {}
86
+ };
87
+ }
88
+ function selectOf(values, opts) {
89
+ return {
90
+ type: "select",
91
+ ...head(opts),
92
+ values: [...values],
93
+ ...opts.creatable !== void 0 ? { creatable: opts.creatable } : {},
94
+ ...fillMark(opts.fill === void 0 ? void 0 : selectAssignOf(opts.fill))
95
+ };
96
+ }
97
+ /** The row planner's spelling of a select field's choice: `{ type: "select-assign", pick }`. */
98
+ function selectAssignOf(choice) {
99
+ return {
100
+ type: "select-assign",
101
+ pick: choice.pick
102
+ };
103
+ }
104
+ function displaySelect(cases, opts) {
105
+ return {
106
+ cases: [...cases],
107
+ ...opts.locked === true ? { locked: true } : {},
108
+ ...opts.source !== void 0 ? { source: opts.source } : {},
109
+ ...opts.fill !== void 0 ? { fill: opts.fill } : {}
110
+ };
111
+ }
112
+ function selectDispatch(a, b) {
113
+ return Array.isArray(a) ? displaySelect(a, b) : selectFn(a);
114
+ }
115
+ /**
116
+ * The select slot AND the `meta.display` entry, told apart by the call shape.
117
+ *
118
+ * As a slot: `select({ from })` for a fact-derived vocabulary, `select.of([…])`
119
+ * for a hand-authored one. A top-level select is bound with `source` and takes
120
+ * no `fill`. Inside a record item, `select.of` is written one of two ways: by
121
+ * the list's own counted `chooseFrom` origination, which picks the ROWS from
122
+ * this field's vocabulary, or — on a row that already exists, a fact-baked
123
+ * comparable say — by its own countless `chooseFrom({ pick })`, which picks
124
+ * this one field's key per row in the list's batched call.
125
+ *
126
+ * As a display entry: `select(cases, { source: compute(fn) })` or
127
+ * `select(cases, { fill: chooseFrom({ pick }) })` declares a `meta.display`
128
+ * `visibility`/`variant` — the first case is the default and the failure
129
+ * posture, `locked: true` opts a variant out of user switching, and the entry
130
+ * takes exactly one origin.
131
+ * @example
132
+ * ```ts
133
+ * import { chooseFrom, compute, select } from "@homepages/concrete";
134
+ *
135
+ * select.of(["for_sale", "sold"], { label: "Status" });
136
+ * select.of(["regular", "highlight"], { label: "Comparable status", fill: chooseFrom({ pick: "Highlight the two or three strongest sales." }) });
137
+ * select(["visible", "hidden"], { source: compute((f) => (f.tours.length > 0 ? "visible" : "hidden")) });
138
+ * select(["classic", "editorial"], { fill: chooseFrom({ pick: "Prefer editorial for story-driven narratives." }) });
139
+ * ```
140
+ */
141
+ const select = Object.assign(selectDispatch, { of: selectOf });
142
+ /**
143
+ * A URL string slot. `accepts` names a single link kind (such as `"tour"`) or
144
+ * link-provider id (such as `"matterport"`) the value must match. A link kind
145
+ * with no provider behind it admits no url at all, which the type cannot say —
146
+ * check time rejects those.
147
+ *
148
+ * Binding-only: no fill decision produces a url, so this builder takes no
149
+ * `fill` — the value comes from `source`.
150
+ * @example
151
+ * ```ts
152
+ * import { url } from "@homepages/concrete";
153
+ *
154
+ * url({ label: "Tour URL", accepts: "tour" });
155
+ * ```
156
+ */
157
+ function url(opts) {
158
+ return {
159
+ type: "url",
160
+ ...head(opts),
161
+ ...opts.accepts !== void 0 ? { accepts: opts.accepts } : {}
162
+ };
163
+ }
164
+ /**
165
+ * A single image slot — the resolved value is always one `ImageValue`, never a
166
+ * list, so it carries no count bounds (a list of them does). `crop` is the asset's
167
+ * contract — the editor's cropper and `<Image>`'s mobile-crop switch read it; the box
168
+ * the image renders in is the section's own classes. `sourceFilter` narrows the
169
+ * candidate pool the editor offers, routing the slot to a dedicated picker.
170
+ * `fill` takes an `imageAssign`, or a `contactAssign` naming one of a contact's
171
+ * image fields — the alternative to `source`, never its companion.
172
+ * @example
173
+ * ```ts
174
+ * import { image } from "@homepages/concrete";
175
+ *
176
+ * image({ label: "Floor plan", sourceFilter: "floorplans" });
177
+ * ```
178
+ */
179
+ function image(opts) {
180
+ return {
181
+ type: "image",
182
+ ...head(opts),
183
+ ...opts.sourceFilter !== void 0 ? { sourceFilter: opts.sourceFilter } : {},
184
+ ...opts.crop !== void 0 ? { crop: opts.crop } : {},
185
+ ...fillMark(opts.fill)
186
+ };
187
+ }
188
+ /**
189
+ * A single video slot, resolved as a `VideoValue`. Unlike `image`, there is no
190
+ * `crop` — a video is selected, never re-edited. `sources` opts into which
191
+ * origins the value may come from (`"upload"`, `"link"`); omitted means
192
+ * upload-only. `playback` configures the renderer's `<Video>`; the box it plays
193
+ * in is your own classes.
194
+ * `fill` takes a `videoAssign` — the alternative to `source`, never its companion.
195
+ * @example
196
+ * ```ts
197
+ * import { video } from "@homepages/concrete";
198
+ *
199
+ * video({ label: "Property video", playback: { controls: true }, sources: ["upload", "link"] });
200
+ * ```
201
+ */
202
+ function video(opts) {
203
+ return {
204
+ type: "video",
205
+ ...head(opts),
206
+ ...opts.playback !== void 0 ? { playback: opts.playback } : {},
207
+ ...opts.sources !== void 0 ? { sources: opts.sources } : {},
208
+ ...fillMark(opts.fill)
209
+ };
210
+ }
211
+ /**
212
+ * A single 3D-tour slot, resolved as a `TourValue`. Its own kind rather than a
213
+ * third video source: `playback` is meaningless on a walkthrough, and the fill
214
+ * pool would otherwise mix videos with tour models. It has no type-specific
215
+ * option at all — no `crop` (a tour is selected, never edited), no `playback`,
216
+ * no `sources` and no `accepts`; which providers are admitted widens in the
217
+ * link-provider catalog, never on a slot, and the box the embed fills is your
218
+ * own classes.
219
+ *
220
+ * Render it with `<Slot.Tour>` for the embed, `<Slot.Image>` for the tour's
221
+ * thumbnail, or both — two positions from one selection.
222
+ * `fill` takes a `tourAssign` — the alternative to `source`, never its companion.
223
+ * @example
224
+ * ```ts
225
+ * import { tour, tourAssign } from "@homepages/concrete";
226
+ *
227
+ * tour({ label: "3D tour", fill: tourAssign({ pick: "The whole-home walkthrough." }) });
228
+ * ```
229
+ */
230
+ function tour(opts) {
231
+ return {
232
+ type: "tour",
233
+ ...head(opts),
234
+ ...fillMark(opts.fill)
235
+ };
236
+ }
237
+ const HEAD_KEYS = ["locked"];
238
+ function stripElementHead(element) {
239
+ const bare = {};
240
+ for (const [key, value] of Object.entries(element)) if (!HEAD_KEYS.includes(key)) bare[key] = value;
241
+ return bare;
242
+ }
243
+ function listOfElement(element, opts) {
244
+ if (getFill(element) !== void 0) throw new Error(`list.of: the element of "${opts.label}" declares a fill — one decision produces the whole list, so \`fill:\` belongs on the list slot.`);
245
+ return {
246
+ type: "list",
247
+ ...head(opts),
248
+ element: stripElementHead(element),
249
+ ...opts.min !== void 0 ? { min: opts.min } : {},
250
+ ...opts.max !== void 0 ? { max: opts.max } : {},
251
+ ...opts.unique !== void 0 ? { unique: opts.unique } : {},
252
+ ...fillMark(opts.fill)
253
+ };
254
+ }
255
+ function listOfRecord(fields, opts) {
256
+ return {
257
+ type: "list",
258
+ ...head(opts),
259
+ fields,
260
+ ...opts.layout !== void 0 ? { layout: itemLayoutFromRows(opts.layout) } : {},
261
+ ...opts.title !== void 0 ? { title: opts.title } : {},
262
+ ...opts.min !== void 0 ? { min: opts.min } : {},
263
+ ...opts.max !== void 0 ? { max: opts.max } : {},
264
+ ...fillMark(opts.fill)
265
+ };
266
+ }
267
+ function listOf(item, opts) {
268
+ return typeof item.type === "string" ? listOfElement(item, opts) : listOfRecord(item, opts);
269
+ }
270
+ /**
271
+ * The list slot — one primitive for everything multi-item. The item is a
272
+ * single slot (`list.of(text.short({ label: "Feature", cap: 80 }), { label: "Features" })`,
273
+ * `list.of(image({ label: "Photo", crop }), { min: 3, label: "Photos" })`,
274
+ * `list.of(poi({ label: "Restaurant" }), { max: 6, label: "Restaurants" })`)
275
+ * or a record of slots
276
+ * (`list.of({ photo: image({ label: "Photo" }), caption: text.short({ label: "Caption", cap: 80 }) }, { label: "Slides" })`).
277
+ * A single item emits `element`; a record emits `fields` with the optional
278
+ * `layout`/`title` row surface. Depth is fixed: an item is never a list, a
279
+ * record field is never a record, and a field-level list holds a single
280
+ * non-record item — each violation is a compile error here and a parse error
281
+ * on the wire.
282
+ */
283
+ const list = { of: listOf };
284
+ /**
285
+ * A single point of interest — one platform-built place (a `PoiRow`), picked
286
+ * in the editor's place search. The platform owns the row's content; there is
287
+ * nothing to configure beyond the head. Usable standalone or as a list item
288
+ * (`list.of(poi({ label: "Restaurant" }), { label: "Restaurants" })`).
289
+ * @example
290
+ * ```ts
291
+ * import { poi } from "@homepages/concrete";
292
+ *
293
+ * poi({ label: "Nearest station", placeholder: "Search places…" });
294
+ * ```
295
+ */
296
+ function poi(opts) {
297
+ return {
298
+ type: "poi",
299
+ ...head(opts)
300
+ };
301
+ }
302
+ /**
303
+ * A single platform-hosted document — a pdf, spreadsheet, or office file the
304
+ * visitor opens in the browser or downloads. The value resolves to one
305
+ * `DocumentValue` (served url plus filename, type and size); render it with
306
+ * `Slot.Document`, which is one anchor.
307
+ *
308
+ * Reach for `url({ accepts: "file" })` instead when the file lives somewhere
309
+ * else — a Drive or Dropbox link the platform neither stores nor serves.
310
+ *
311
+ * `fill` takes a `documentAssign`, which picks one file out of the documents
312
+ * stored on the property. Usable standalone or as a list item — a
313
+ * `list.of(document(...))` carries its own `listFill` and picks a SET from the
314
+ * same pool.
315
+ * @example
316
+ * ```ts
317
+ * import { document, documentAssign } from "@homepages/concrete";
318
+ *
319
+ * document({ label: "Offering brochure", fill: documentAssign({ pick: "The full property brochure." }) });
320
+ * ```
321
+ */
322
+ function document(opts) {
323
+ return {
324
+ type: "document",
325
+ ...head(opts),
326
+ ...fillMark(opts.fill)
327
+ };
328
+ }
329
+
330
+ //#endregion
331
+ export { document, image, list, number, poi, select, text, tour, url, video };
@@ -0,0 +1,110 @@
1
+ import { FILL, SlotFill } from "./fill-declaration.js";
2
+ import { z } from "zod";
3
+ //#region src/schema/slot-types.d.ts
4
+ type SlotBase = {
5
+ [FILL]?: SlotFill;
6
+ locked?: boolean;
7
+ source?: {
8
+ kind: string;
9
+ field?: string;
10
+ transform?: string;
11
+ };
12
+ writeback?: boolean;
13
+ label: string;
14
+ placeholder?: string;
15
+ variant?: {
16
+ cases: readonly string[];
17
+ };
18
+ };
19
+ /** Kind-level def type for a `text` slot — `SlotBinding<TextSlot>` accepts any text slot. */
20
+ type TextSlot = SlotBase & {
21
+ type: "text";
22
+ size?: string;
23
+ cap?: number;
24
+ };
25
+ /** Kind-level def type for a `number` slot — `SlotBinding<NumberSlot>` accepts any number slot. */
26
+ type NumberSlot = SlotBase & {
27
+ type: "number";
28
+ prefix?: string;
29
+ suffix?: string;
30
+ thousandsSep?: boolean;
31
+ decimals?: boolean;
32
+ maxDigits?: number;
33
+ };
34
+ /** Kind-level def type for a `select` slot — `SlotBinding<SelectSlot>` accepts any select slot. */
35
+ type SelectSlot = SlotBase & {
36
+ type: "select";
37
+ values?: (string | {
38
+ value: string;
39
+ label: string;
40
+ })[];
41
+ options?: {
42
+ source: string;
43
+ };
44
+ creatable?: boolean;
45
+ };
46
+ /** Kind-level def type for an `image` slot — `SlotBinding<ImageSlot>` accepts any image slot. */
47
+ type ImageSlot = SlotBase & {
48
+ type: "image";
49
+ sourceFilter?: string;
50
+ crop?: unknown;
51
+ };
52
+ /** Kind-level def type for a `video` slot — `SlotBinding<VideoSlot>` accepts any video slot. */
53
+ type VideoSlot = SlotBase & {
54
+ type: "video";
55
+ playback?: unknown;
56
+ sources?: unknown;
57
+ };
58
+ /** Kind-level def type for a `tour` slot — `SlotBinding<TourSlot>` accepts any tour slot. */
59
+ type TourSlot = SlotBase & {
60
+ type: "tour";
61
+ };
62
+ /** Kind-level def type for a `list` slot — the item is `element` (a single primitive) XOR `fields` (a record of slots). */
63
+ type ListSlot = SlotBase & {
64
+ type: "list";
65
+ min?: number;
66
+ max?: number;
67
+ unique?: boolean;
68
+ element?: Slot;
69
+ fields?: Record<string, ListFieldSlot>;
70
+ title?: string;
71
+ /** CI-stamped order-stable field order for a record item — JSONB drops key order. */
72
+ item_order?: string[];
73
+ /**
74
+ * A record item's nestable field layout: a bare id is full-width, an
75
+ * `[a, b]` tuple is one 2-up row. CI emits `item_order = flatten(layout)`.
76
+ */
77
+ layout?: (string | [string, string])[];
78
+ };
79
+ /** Kind-level def type for a `poi` slot — one platform-built place; `SlotBinding<PoiSlot>` accepts any poi slot. */
80
+ type PoiSlot = SlotBase & {
81
+ type: "poi";
82
+ };
83
+ /** Kind-level def type for a `url` slot — `SlotBinding<UrlSlot>` accepts any url slot. */
84
+ type UrlSlot = SlotBase & {
85
+ type: "url";
86
+ accepts?: string;
87
+ };
88
+ /** Kind-level def type for a `document` slot — `SlotBinding<DocumentSlot>` accepts any document slot. */
89
+ type DocumentSlot = SlotBase & {
90
+ type: "document";
91
+ };
92
+ /** Every slot kind an author may declare at a section's top level. */
93
+ type Slot = ListItemSlot | ListSlot;
94
+ /**
95
+ * The slot kinds legal as a list's single item — any value primitive, never a
96
+ * list and never a record. The type half of the depth rules; the slot Zod
97
+ * union enforces the same rules at parse time.
98
+ */
99
+ type ListItemSlot = TextSlot | NumberSlot | SelectSlot | ImageSlot | VideoSlot | TourSlot | PoiSlot | UrlSlot | DocumentSlot;
100
+ /**
101
+ * The slot kinds legal as a record item's field — any value primitive, or a
102
+ * field-level list whose own item is a single non-record slot. A record (a
103
+ * `fields`-carrying list) is never a field: identity is a flat 4-tuple, and
104
+ * there is no fifth element to address through.
105
+ */
106
+ type ListFieldSlot = ListItemSlot | (ListSlot & {
107
+ fields?: never;
108
+ });
109
+ //#endregion
110
+ export { DocumentSlot, ImageSlot, ListFieldSlot, ListItemSlot, ListSlot, NumberSlot, PoiSlot, SelectSlot, Slot, TextSlot, TourSlot, UrlSlot, VideoSlot };
@@ -0,0 +1,187 @@
1
+ import { SLOT_TYPES, VIDEO_SOURCES } from "../packages/internal/template-contracts/dist/slot-catalog.js";
2
+ import { z } from "zod";
3
+
4
+ //#region src/schema/slot-types.ts
5
+ const slotHeadShape = { locked: z.boolean().optional() };
6
+ const cropConfigShape = { crop: z.object({
7
+ mode: z.enum(["locked", "free"]),
8
+ aspect: z.number().positive().optional(),
9
+ aspectLabel: z.string().optional(),
10
+ mobile: z.object({
11
+ aspect: z.number().positive(),
12
+ breakpoint: z.number().int().positive()
13
+ }).strict().optional()
14
+ }).strict().refine((c) => c.mode !== "locked" || c.aspect != null, { message: "locked crop requires an aspect" }).refine((c) => c.mobile == null || c.aspect != null, { message: "a mobile crop needs a desktop aspect to differ from" }).refine((c) => c.mobile == null || c.aspect == null || Math.abs(c.mobile.aspect - c.aspect) > 1e-4, { message: "a mobile crop equal to the desktop aspect declares nothing — omit it" }).optional() };
15
+ const playbackConfigShape = { playback: z.object({
16
+ autoplay: z.boolean().optional(),
17
+ loop: z.boolean().optional(),
18
+ muted: z.boolean().optional(),
19
+ controls: z.boolean().optional(),
20
+ playsinline: z.boolean().optional(),
21
+ preload: z.enum([
22
+ "none",
23
+ "metadata",
24
+ "auto"
25
+ ]).optional()
26
+ }).strict().refine((p) => p.autoplay !== true || p.muted === true, { message: "autoplay requires muted (browsers block unmuted autoplay)" }).optional() };
27
+ const videoSourcesShape = { sources: z.array(z.enum(VIDEO_SOURCES)).nonempty().optional() };
28
+ const slotMetadataShape = {
29
+ label: z.string().min(1),
30
+ placeholder: z.string().optional(),
31
+ variant: z.object({ cases: z.array(z.string().min(1)).min(1) }).strict().optional(),
32
+ source: z.discriminatedUnion("kind", [
33
+ z.object({ kind: z.literal("authored") }),
34
+ z.object({
35
+ kind: z.literal("direct"),
36
+ field: z.string()
37
+ }).strict(),
38
+ z.object({
39
+ kind: z.literal("derived"),
40
+ transform: z.string()
41
+ }).strict()
42
+ ]).optional(),
43
+ writeback: z.boolean().optional()
44
+ };
45
+ /**
46
+ * The per-slot-type anchor: one entry per slot type declaring that type's
47
+ * type-specific Zod field shape and its fresh default runtime value.
48
+ * `SlotDef` and `defaultForSlotType` are both derived from this table.
49
+ */
50
+ const SLOT_TYPE_DESCRIPTORS = {
51
+ text: {
52
+ shape: {
53
+ size: z.enum([
54
+ "short",
55
+ "medium",
56
+ "long"
57
+ ]).optional(),
58
+ cap: z.number().int().positive().optional()
59
+ },
60
+ default: () => ""
61
+ },
62
+ number: {
63
+ shape: {
64
+ prefix: z.string().optional(),
65
+ suffix: z.string().optional(),
66
+ thousandsSep: z.boolean().optional(),
67
+ decimals: z.boolean().optional(),
68
+ maxDigits: z.number().int().positive().optional()
69
+ },
70
+ default: () => null
71
+ },
72
+ select: {
73
+ shape: {
74
+ values: z.array(z.union([z.string(), z.object({
75
+ value: z.string(),
76
+ label: z.string()
77
+ }).strict()])).optional(),
78
+ options: z.object({ source: z.string() }).strict().optional(),
79
+ creatable: z.boolean().optional()
80
+ },
81
+ default: () => null
82
+ },
83
+ image: {
84
+ shape: {
85
+ sourceFilter: z.string().optional(),
86
+ ...cropConfigShape
87
+ },
88
+ default: () => ({
89
+ url: "",
90
+ alt: ""
91
+ })
92
+ },
93
+ video: {
94
+ shape: {
95
+ ...playbackConfigShape,
96
+ ...videoSourcesShape
97
+ },
98
+ default: () => ({
99
+ url: "",
100
+ poster: "",
101
+ alt: ""
102
+ })
103
+ },
104
+ tour: {
105
+ shape: {},
106
+ default: () => ({
107
+ tour_id: "",
108
+ url: "",
109
+ poster: "",
110
+ alt: ""
111
+ })
112
+ },
113
+ list: {
114
+ shape: {
115
+ min: z.number().int().nonnegative().optional(),
116
+ max: z.number().int().positive().optional(),
117
+ unique: z.boolean().optional(),
118
+ element: z.lazy(() => ListItemDef).optional(),
119
+ fields: z.record(z.string(), z.lazy(() => ListFieldDef)).optional(),
120
+ title: z.string().optional(),
121
+ item_order: z.array(z.string()).optional(),
122
+ layout: z.array(z.union([z.string(), z.tuple([z.string(), z.string()])])).optional()
123
+ },
124
+ default: () => []
125
+ },
126
+ poi: {
127
+ shape: {},
128
+ default: () => null
129
+ },
130
+ url: {
131
+ shape: { accepts: z.string().optional() },
132
+ default: () => ""
133
+ },
134
+ document: {
135
+ shape: {},
136
+ default: () => null
137
+ }
138
+ };
139
+ function slotMember(type, shape) {
140
+ return z.object({
141
+ type: z.literal(type),
142
+ ...slotHeadShape,
143
+ ...shape,
144
+ ...slotMetadataShape
145
+ }).strict();
146
+ }
147
+ const LIST_ITEM_DEF_MEMBERS = [
148
+ slotMember("text", SLOT_TYPE_DESCRIPTORS.text.shape),
149
+ slotMember("number", SLOT_TYPE_DESCRIPTORS.number.shape),
150
+ slotMember("select", SLOT_TYPE_DESCRIPTORS.select.shape),
151
+ slotMember("image", SLOT_TYPE_DESCRIPTORS.image.shape),
152
+ slotMember("video", SLOT_TYPE_DESCRIPTORS.video.shape),
153
+ slotMember("tour", SLOT_TYPE_DESCRIPTORS.tour.shape),
154
+ slotMember("poi", SLOT_TYPE_DESCRIPTORS.poi.shape),
155
+ slotMember("url", SLOT_TYPE_DESCRIPTORS.url.shape),
156
+ slotMember("document", SLOT_TYPE_DESCRIPTORS.document.shape)
157
+ ];
158
+ /** The Zod union a list's single item (`element`) validates against — any value primitive, never a list or a record. */
159
+ const ListItemDef = z.discriminatedUnion("type", [...LIST_ITEM_DEF_MEMBERS]);
160
+ const FIELD_LIST_DEF_MEMBER = slotMember("list", {
161
+ min: z.number().int().nonnegative().optional(),
162
+ max: z.number().int().positive().optional(),
163
+ unique: z.boolean().optional(),
164
+ element: z.lazy(() => ListItemDef).optional()
165
+ });
166
+ /** The Zod union a record item's field validates against — any value primitive or a field-level list, never a record. */
167
+ const ListFieldDef = z.discriminatedUnion("type", [...LIST_ITEM_DEF_MEMBERS, FIELD_LIST_DEF_MEMBER]);
168
+ const SLOT_DEF_MEMBERS = [...LIST_ITEM_DEF_MEMBERS, slotMember("list", SLOT_TYPE_DESCRIPTORS.list.shape)];
169
+ /**
170
+ * The Zod discriminated union validating an authored slot definition, built
171
+ * from `SLOT_TYPE_DESCRIPTORS`. Covers every slot kind; a list's item and a
172
+ * record item's field each validate against their own narrower union, which is
173
+ * what makes the depth rules unrepresentable on the wire.
174
+ */
175
+ const SlotDef = z.discriminatedUnion("type", [...SLOT_DEF_MEMBERS]);
176
+ /**
177
+ * The fresh default runtime value for a slot of the given type, derived from
178
+ * `SLOT_TYPE_DESCRIPTORS`. Returns a NEW value on every call — never a shared
179
+ * reference — and `null` for a type absent from the catalog.
180
+ */
181
+ function defaultForSlotType(type) {
182
+ if (!SLOT_TYPES.includes(type)) return null;
183
+ return SLOT_TYPE_DESCRIPTORS[type].default();
184
+ }
185
+
186
+ //#endregion
187
+ export { ListFieldDef, ListItemDef, SLOT_TYPE_DESCRIPTORS, SlotDef, defaultForSlotType };
@@ -0,0 +1,44 @@
1
+ import { Slot } from "../schema/slot-types.js";
2
+ import { DefinedSchema, DisplayInput } from "../schema/define-schema.js";
3
+ //#region src/section/declare.d.ts
4
+ /** The first argument of `section()`: identity plus the schema declaration. */
5
+ interface SectionOptions<Key extends string, Slots extends Record<string, Slot>, Display extends DisplayInput> {
6
+ /**
7
+ * The section's platform identity — its key in the catalog, its in-page fragment,
8
+ * and the default instance id's stem (`<key>-1`). Explicit, never derived from an
9
+ * export or file name: renaming a variable must not mint a new section and orphan
10
+ * its content.
11
+ */
12
+ readonly key: Key;
13
+ /** The section's name in the editor (`meta.displayName`). */
14
+ readonly label: string;
15
+ /** A required section is required wherever it is placed. Defaults to `false`. */
16
+ readonly required?: boolean;
17
+ /** Section `visibility` / `variant`, each an optional `select(cases, …)` entry. */
18
+ readonly display?: Display;
19
+ /** The slot declarations, in editor order. */
20
+ readonly slots: Slots;
21
+ }
22
+ /** The schema a section's options materialize to — `defineSchema`'s own shape. */
23
+ type SectionSchemaOf<Slots extends Record<string, Slot>, Display extends DisplayInput> = DefinedSchema<Slots, Display, readonly []>;
24
+ /**
25
+ * A slot of a section, by name — what a reconcile rule reads and sets. Both halves
26
+ * are literal on a section value (`Hero.slots.hero_image` is
27
+ * `SlotRef<"hero", "hero_image">`), which is what types a rule's `site` view.
28
+ */
29
+ interface SlotRef<Section extends string = string, SlotId extends string = string> {
30
+ readonly section: Section;
31
+ readonly slot: SlotId;
32
+ }
33
+ /** One `SlotRef` per declared slot, keyed by slot id. */
34
+ type SlotRefsOf<Key extends string, Slots extends Record<string, Slot>> = { readonly [K in keyof Slots & string]: SlotRef<Key, K>; };
35
+ /** What the options declare, before a component is wrapped around it. */
36
+ interface SectionDeclaration<Key extends string, Slots extends Record<string, Slot>, Display extends DisplayInput> {
37
+ readonly key: Key;
38
+ readonly label: string;
39
+ readonly required: boolean;
40
+ readonly schema: SectionSchemaOf<Slots, Display>;
41
+ readonly slots: SlotRefsOf<Key, Slots>;
42
+ }
43
+ //#endregion
44
+ export { SectionDeclaration, SectionOptions, SectionSchemaOf, SlotRef, SlotRefsOf };
@@ -0,0 +1,27 @@
1
+ import { defineSchema } from "../schema/define-schema.js";
2
+
3
+ //#region src/section/declare.ts
4
+ /** Materialize the options: the schema through `defineSchema`, a ref per slot. */
5
+ function declareSection(options) {
6
+ const { key, label, required = false } = options;
7
+ const schema = defineSchema({
8
+ label,
9
+ display: options.display,
10
+ slots: options.slots
11
+ });
12
+ const refs = {};
13
+ for (const slot of Object.keys(options.slots)) refs[slot] = {
14
+ section: key,
15
+ slot
16
+ };
17
+ return {
18
+ key,
19
+ label,
20
+ required,
21
+ schema,
22
+ slots: Object.freeze(refs)
23
+ };
24
+ }
25
+
26
+ //#endregion
27
+ export { declareSection };