@endora-commerce/page-builder-core 0.100.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 (208) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/dist/block-name.d.ts +48 -0
  4. package/dist/block-name.d.ts.map +1 -0
  5. package/dist/block-name.js +79 -0
  6. package/dist/block-name.js.map +1 -0
  7. package/dist/block-tree.d.ts +44 -0
  8. package/dist/block-tree.d.ts.map +1 -0
  9. package/dist/block-tree.js +120 -0
  10. package/dist/block-tree.js.map +1 -0
  11. package/dist/client.d.ts +3 -0
  12. package/dist/client.d.ts.map +1 -0
  13. package/dist/client.js +4 -0
  14. package/dist/client.js.map +1 -0
  15. package/dist/color-palette/context.d.ts +18 -0
  16. package/dist/color-palette/context.d.ts.map +1 -0
  17. package/dist/color-palette/context.js +11 -0
  18. package/dist/color-palette/context.js.map +1 -0
  19. package/dist/define-component.d.ts +47 -0
  20. package/dist/define-component.d.ts.map +1 -0
  21. package/dist/define-component.js +74 -0
  22. package/dist/define-component.js.map +1 -0
  23. package/dist/editor/editor-carousel-preview-ui.d.ts +7 -0
  24. package/dist/editor/editor-carousel-preview-ui.d.ts.map +1 -0
  25. package/dist/editor/editor-carousel-preview-ui.js +11 -0
  26. package/dist/editor/editor-carousel-preview-ui.js.map +1 -0
  27. package/dist/editor/editor-carousel-preview.d.ts +31 -0
  28. package/dist/editor/editor-carousel-preview.d.ts.map +1 -0
  29. package/dist/editor/editor-carousel-preview.js +109 -0
  30. package/dist/editor/editor-carousel-preview.js.map +1 -0
  31. package/dist/editor/enhance-component-config.d.ts +7 -0
  32. package/dist/editor/enhance-component-config.d.ts.map +1 -0
  33. package/dist/editor/enhance-component-config.js +55 -0
  34. package/dist/editor/enhance-component-config.js.map +1 -0
  35. package/dist/editor/field-tabs.d.ts +7 -0
  36. package/dist/editor/field-tabs.d.ts.map +1 -0
  37. package/dist/editor/field-tabs.js +29 -0
  38. package/dist/editor/field-tabs.js.map +1 -0
  39. package/dist/editor/fields-tab-panel.d.ts +9 -0
  40. package/dist/editor/fields-tab-panel.d.ts.map +1 -0
  41. package/dist/editor/fields-tab-panel.js +132 -0
  42. package/dist/editor/fields-tab-panel.js.map +1 -0
  43. package/dist/editor/format-outline-label.d.ts +2 -0
  44. package/dist/editor/format-outline-label.d.ts.map +1 -0
  45. package/dist/editor/format-outline-label.js +10 -0
  46. package/dist/editor/format-outline-label.js.map +1 -0
  47. package/dist/editor/outline-data.d.ts +13 -0
  48. package/dist/editor/outline-data.d.ts.map +1 -0
  49. package/dist/editor/outline-data.js +73 -0
  50. package/dist/editor/outline-data.js.map +1 -0
  51. package/dist/editor/outline-dnd.d.ts +15 -0
  52. package/dist/editor/outline-dnd.d.ts.map +1 -0
  53. package/dist/editor/outline-dnd.js +55 -0
  54. package/dist/editor/outline-dnd.js.map +1 -0
  55. package/dist/editor/page-builder-component-overlay.d.ts +13 -0
  56. package/dist/editor/page-builder-component-overlay.d.ts.map +1 -0
  57. package/dist/editor/page-builder-component-overlay.js +14 -0
  58. package/dist/editor/page-builder-component-overlay.js.map +1 -0
  59. package/dist/editor/page-builder-outline.d.ts +10 -0
  60. package/dist/editor/page-builder-outline.d.ts.map +1 -0
  61. package/dist/editor/page-builder-outline.js +133 -0
  62. package/dist/editor/page-builder-outline.js.map +1 -0
  63. package/dist/editor/page-builder-plugin.d.ts +6 -0
  64. package/dist/editor/page-builder-plugin.d.ts.map +1 -0
  65. package/dist/editor/page-builder-plugin.js +31 -0
  66. package/dist/editor/page-builder-plugin.js.map +1 -0
  67. package/dist/editor/preview-viewport-bridge.d.ts +9 -0
  68. package/dist/editor/preview-viewport-bridge.d.ts.map +1 -0
  69. package/dist/editor/preview-viewport-bridge.js +19 -0
  70. package/dist/editor/preview-viewport-bridge.js.map +1 -0
  71. package/dist/editor/preview-viewport-store.d.ts +4 -0
  72. package/dist/editor/preview-viewport-store.d.ts.map +1 -0
  73. package/dist/editor/preview-viewport-store.js +24 -0
  74. package/dist/editor/preview-viewport-store.js.map +1 -0
  75. package/dist/editor/puck-action-guards.d.ts +46 -0
  76. package/dist/editor/puck-action-guards.d.ts.map +1 -0
  77. package/dist/editor/puck-action-guards.js +232 -0
  78. package/dist/editor/puck-action-guards.js.map +1 -0
  79. package/dist/editor/puck-dnd-element.d.ts +3 -0
  80. package/dist/editor/puck-dnd-element.d.ts.map +1 -0
  81. package/dist/editor/puck-dnd-element.js +20 -0
  82. package/dist/editor/puck-dnd-element.js.map +1 -0
  83. package/dist/editor/settings-scope-context.d.ts +13 -0
  84. package/dist/editor/settings-scope-context.d.ts.map +1 -0
  85. package/dist/editor/settings-scope-context.js +30 -0
  86. package/dist/editor/settings-scope-context.js.map +1 -0
  87. package/dist/editor/settings-scope-store.d.ts +5 -0
  88. package/dist/editor/settings-scope-store.d.ts.map +1 -0
  89. package/dist/editor/settings-scope-store.js +22 -0
  90. package/dist/editor/settings-scope-store.js.map +1 -0
  91. package/dist/editor/settings-tab-store.d.ts +5 -0
  92. package/dist/editor/settings-tab-store.d.ts.map +1 -0
  93. package/dist/editor/settings-tab-store.js +22 -0
  94. package/dist/editor/settings-tab-store.js.map +1 -0
  95. package/dist/editor/use-component-scope.d.ts +4 -0
  96. package/dist/editor/use-component-scope.d.ts.map +1 -0
  97. package/dist/editor/use-component-scope.js +15 -0
  98. package/dist/editor/use-component-scope.js.map +1 -0
  99. package/dist/editor/use-page-builder-puck.d.ts +4 -0
  100. package/dist/editor/use-page-builder-puck.d.ts.map +1 -0
  101. package/dist/editor/use-page-builder-puck.js +4 -0
  102. package/dist/editor/use-page-builder-puck.js.map +1 -0
  103. package/dist/editor/use-preview-breakpoint-tier.d.ts +10 -0
  104. package/dist/editor/use-preview-breakpoint-tier.d.ts.map +1 -0
  105. package/dist/editor/use-preview-breakpoint-tier.js +40 -0
  106. package/dist/editor/use-preview-breakpoint-tier.js.map +1 -0
  107. package/dist/editor.d.ts +15 -0
  108. package/dist/editor.d.ts.map +1 -0
  109. package/dist/editor.js +16 -0
  110. package/dist/editor.js.map +1 -0
  111. package/dist/fields/background-field.d.ts +14 -0
  112. package/dist/fields/background-field.d.ts.map +1 -0
  113. package/dist/fields/background-field.js +38 -0
  114. package/dist/fields/background-field.js.map +1 -0
  115. package/dist/fields/border-field.d.ts +5 -0
  116. package/dist/fields/border-field.d.ts.map +1 -0
  117. package/dist/fields/border-field.js +85 -0
  118. package/dist/fields/border-field.js.map +1 -0
  119. package/dist/fields/color-field-utils.d.ts +16 -0
  120. package/dist/fields/color-field-utils.d.ts.map +1 -0
  121. package/dist/fields/color-field-utils.js +45 -0
  122. package/dist/fields/color-field-utils.js.map +1 -0
  123. package/dist/fields/color-field.d.ts +5 -0
  124. package/dist/fields/color-field.d.ts.map +1 -0
  125. package/dist/fields/color-field.js +74 -0
  126. package/dist/fields/color-field.js.map +1 -0
  127. package/dist/fields/color-input-debounce.d.ts +6 -0
  128. package/dist/fields/color-input-debounce.d.ts.map +1 -0
  129. package/dist/fields/color-input-debounce.js +24 -0
  130. package/dist/fields/color-input-debounce.js.map +1 -0
  131. package/dist/fields/editor-name-field.d.ts +3 -0
  132. package/dist/fields/editor-name-field.d.ts.map +1 -0
  133. package/dist/fields/editor-name-field.js +12 -0
  134. package/dist/fields/editor-name-field.js.map +1 -0
  135. package/dist/fields/hide-on-field.d.ts +4 -0
  136. package/dist/fields/hide-on-field.d.ts.map +1 -0
  137. package/dist/fields/hide-on-field.js +26 -0
  138. package/dist/fields/hide-on-field.js.map +1 -0
  139. package/dist/fields/native-color-input.d.ts +12 -0
  140. package/dist/fields/native-color-input.d.ts.map +1 -0
  141. package/dist/fields/native-color-input.js +51 -0
  142. package/dist/fields/native-color-input.js.map +1 -0
  143. package/dist/fields/puck-field-label.d.ts +8 -0
  144. package/dist/fields/puck-field-label.d.ts.map +1 -0
  145. package/dist/fields/puck-field-label.js +8 -0
  146. package/dist/fields/puck-field-label.js.map +1 -0
  147. package/dist/fields/responsive-field-types.d.ts +21 -0
  148. package/dist/fields/responsive-field-types.d.ts.map +1 -0
  149. package/dist/fields/responsive-field-types.js +97 -0
  150. package/dist/fields/responsive-field-types.js.map +1 -0
  151. package/dist/fields/scoped-field.d.ts +19 -0
  152. package/dist/fields/scoped-field.d.ts.map +1 -0
  153. package/dist/fields/scoped-field.js +67 -0
  154. package/dist/fields/scoped-field.js.map +1 -0
  155. package/dist/fields/spacing-field.d.ts +14 -0
  156. package/dist/fields/spacing-field.d.ts.map +1 -0
  157. package/dist/fields/spacing-field.js +71 -0
  158. package/dist/fields/spacing-field.js.map +1 -0
  159. package/dist/index.d.ts +18 -0
  160. package/dist/index.d.ts.map +1 -0
  161. package/dist/index.js +36 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/migration/frozen-block-renames.d.ts +14 -0
  164. package/dist/migration/frozen-block-renames.d.ts.map +1 -0
  165. package/dist/migration/frozen-block-renames.js +132 -0
  166. package/dist/migration/frozen-block-renames.js.map +1 -0
  167. package/dist/migration/index.d.ts +4 -0
  168. package/dist/migration/index.d.ts.map +1 -0
  169. package/dist/migration/index.js +22 -0
  170. package/dist/migration/index.js.map +1 -0
  171. package/dist/migration/rename-block-names-sql.d.ts +28 -0
  172. package/dist/migration/rename-block-names-sql.d.ts.map +1 -0
  173. package/dist/migration/rename-block-names-sql.js +117 -0
  174. package/dist/migration/rename-block-names-sql.js.map +1 -0
  175. package/dist/palette.d.ts +47 -0
  176. package/dist/palette.d.ts.map +1 -0
  177. package/dist/palette.js +84 -0
  178. package/dist/palette.js.map +1 -0
  179. package/dist/render/responsive-styles.d.ts +19 -0
  180. package/dist/render/responsive-styles.d.ts.map +1 -0
  181. package/dist/render/responsive-styles.js +91 -0
  182. package/dist/render/responsive-styles.js.map +1 -0
  183. package/dist/types/background.d.ts +26 -0
  184. package/dist/types/background.d.ts.map +1 -0
  185. package/dist/types/background.js +76 -0
  186. package/dist/types/background.js.map +1 -0
  187. package/dist/types/box-styles.d.ts +67 -0
  188. package/dist/types/box-styles.d.ts.map +1 -0
  189. package/dist/types/box-styles.js +217 -0
  190. package/dist/types/box-styles.js.map +1 -0
  191. package/dist/types/editor-chrome.d.ts +15 -0
  192. package/dist/types/editor-chrome.d.ts.map +1 -0
  193. package/dist/types/editor-chrome.js +8 -0
  194. package/dist/types/editor-chrome.js.map +1 -0
  195. package/dist/types/hide-on.d.ts +6 -0
  196. package/dist/types/hide-on.d.ts.map +1 -0
  197. package/dist/types/hide-on.js +2 -0
  198. package/dist/types/hide-on.js.map +1 -0
  199. package/dist/types/responsive.d.ts +70 -0
  200. package/dist/types/responsive.d.ts.map +1 -0
  201. package/dist/types/responsive.js +91 -0
  202. package/dist/types/responsive.js.map +1 -0
  203. package/dist/visibility/with-hide-on.d.ts +12 -0
  204. package/dist/visibility/with-hide-on.d.ts.map +1 -0
  205. package/dist/visibility/with-hide-on.js +28 -0
  206. package/dist/visibility/with-hide-on.js.map +1 -0
  207. package/package.json +96 -0
  208. package/tailwind.css +14 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Endora sp. z o.o. and the Endora Commerce contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ <!-- Generated by `pnpm --filter backend run manifests:generate`. Delete this line to take the file over; a README without it is never regenerated. -->
2
+
3
+ # @endora-commerce/page-builder-core
4
+
5
+ Shared Page Builder primitives — responsive props, context filtering, and component definition helpers for CMS, email, and invoice builders.
6
+
7
+ ## What this is
8
+
9
+ A shared library package of **Endora Commerce**, the modular B2B/B2C commerce platform. It declares no module manifest, so the platform composes nothing from it: what is published here is what the platform and the modules built on it compile against.
10
+
11
+ ## Entry points
12
+
13
+ - `@endora-commerce/page-builder-core`
14
+ - `@endora-commerce/page-builder-core/*`
15
+ - `@endora-commerce/page-builder-core/client`
16
+ - `@endora-commerce/page-builder-core/editor`
17
+ - `@endora-commerce/page-builder-core/editor/carousel-preview`
18
+ - `@endora-commerce/page-builder-core/editor/puck-guards`
19
+ - `@endora-commerce/page-builder-core/editor/use-page-builder-puck`
20
+ - `@endora-commerce/page-builder-core/fields/hide-on-field`
21
+ - `@endora-commerce/page-builder-core/migration`
22
+ - `@endora-commerce/page-builder-core/tailwind.css`
23
+ - `@endora-commerce/page-builder-core/types/responsive`
24
+
25
+ ## Depends on
26
+
27
+ Everything below is a **peer** dependency, so the application resolves exactly one copy of each — two copies of a host or of React are a runtime failure rather than a type error. An entry marked *optional* is needed only by the layers that use it.
28
+
29
+ **Third-party**
30
+
31
+ - `@measured/puck` * — *optional*
32
+ - `react` ^19.0.0 — *optional*
33
+
34
+ **Bundled dependencies**
35
+
36
+ - `@endora-commerce/contracts`
37
+
38
+ ## What the tarball carries
39
+
40
+ - `dist/` — the compiled JavaScript and its type declarations
41
+ - `tailwind.css` — the Tailwind source declaration
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pnpm add @endora-commerce/page-builder-core
47
+ ```
48
+
49
+ ## Licence
50
+
51
+ MIT — the text is in `LICENSE`, beside this file.
@@ -0,0 +1,48 @@
1
+ /** A block name split into the two things it states. */
2
+ export interface ParsedBlockName {
3
+ /** The declaring module's `id` — the segment before the separator. */
4
+ readonly owner: string;
5
+ /** The PascalCase local name, unique within that module. */
6
+ readonly local: string;
7
+ }
8
+ /**
9
+ * Split a namespaced block name, or answer `null` when the string is not one.
10
+ *
11
+ * **Null rather than a throw**, deliberately: the readers that matter are a
12
+ * migration and an operator report, both of which meet names they do not
13
+ * recognise as a matter of course. FR-014 requires such a name to be left
14
+ * byte-identical and reported, and a classification path that throws cannot do
15
+ * either.
16
+ */
17
+ export declare function parseBlockName(name: string): ParsedBlockName | null;
18
+ /**
19
+ * The module that owns a block name, or `null` when the name states no owner.
20
+ *
21
+ * This is the question every runtime reader actually asks — which module can
22
+ * render this node, is that module present, and whose palette does it belong in.
23
+ */
24
+ export declare function ownerOf(name: string): string | null;
25
+ /**
26
+ * Whether a name is a well-formed namespaced block name.
27
+ *
28
+ * **Stricter than `indexOf('.') !== -1`**, which is how `data-model.md` §3
29
+ * describes the migration's idempotence test, and the difference is deliberate
30
+ * and narrow. No entry in the frozen rename map's domain contains a dot, so the
31
+ * two predicates agree on every name the migration renames. They differ only on
32
+ * a *malformed* dotted name — a hand-edited `acme.banner`, a fork's own
33
+ * spelling — which the lax test would classify as "already namespaced" and hide
34
+ * from the operator's report. Under this one it is unrecognised: reported, left
35
+ * alone, and degrading to the placeholder, which is the FR-014 path it belongs
36
+ * on.
37
+ */
38
+ export declare function isNamespaced(name: string): boolean;
39
+ /**
40
+ * Build a block name from its two parts.
41
+ *
42
+ * **Throws** where {@link parseBlockName} returns `null`, and the asymmetry is
43
+ * the point: reading meets names from a client's database, where an unknown one
44
+ * is expected; writing is a developer composing an identifier that will be
45
+ * persisted forever, where an unparseable one is a row nothing can ever render.
46
+ */
47
+ export declare function formatBlockName(owner: string, local: string): string;
48
+ //# sourceMappingURL=block-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-name.d.ts","sourceRoot":"","sources":["../src/block-name.ts"],"names":[],"mappings":"AAuBA,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAInE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEnD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUpE"}
@@ -0,0 +1,79 @@
1
+ // Page Builder block names — feature 096, T104.
2
+ //
3
+ // A block name is `<ownerModuleId>.<LocalName>` and is the persisted identifier
4
+ // of a Puck node: it is written into a `jsonb` column and never rewritten
5
+ // (`specs/096-page-builder-block-ownership/contracts/block-definition.md` §3).
6
+ // These four functions are the **only** readers of that shape; every file that
7
+ // needs an owner, a local name or a "is this namespaced" answer imports them
8
+ // rather than splitting a string itself.
9
+ //
10
+ // That is the `text-normalization.ts` discipline, and this file has the same
11
+ // reason for it. Six authors wrote their own diacritic fold because the shared
12
+ // one existed under a name they did not find, and four of them were wrong; a
13
+ // private `name.split('.')[0]` is the same defect over a string that ends up in
14
+ // a client's database. `check:block-names` (Phase 7) is what will refuse the
15
+ // second copy.
16
+ //
17
+ // The grammar itself is authored once more centrally still — `blockNameRe` in
18
+ // `@endora-commerce/contracts` — because the Zod schema that refuses a bad
19
+ // declaration needs it and this package cannot be the thing `contracts`
20
+ // depends on.
21
+ import { blockNameRe } from '@endora-commerce/contracts/cms';
22
+ /**
23
+ * Split a namespaced block name, or answer `null` when the string is not one.
24
+ *
25
+ * **Null rather than a throw**, deliberately: the readers that matter are a
26
+ * migration and an operator report, both of which meet names they do not
27
+ * recognise as a matter of course. FR-014 requires such a name to be left
28
+ * byte-identical and reported, and a classification path that throws cannot do
29
+ * either.
30
+ */
31
+ export function parseBlockName(name) {
32
+ if (!blockNameRe.test(name))
33
+ return null;
34
+ const separator = name.indexOf('.');
35
+ return { owner: name.slice(0, separator), local: name.slice(separator + 1) };
36
+ }
37
+ /**
38
+ * The module that owns a block name, or `null` when the name states no owner.
39
+ *
40
+ * This is the question every runtime reader actually asks — which module can
41
+ * render this node, is that module present, and whose palette does it belong in.
42
+ */
43
+ export function ownerOf(name) {
44
+ return parseBlockName(name)?.owner ?? null;
45
+ }
46
+ /**
47
+ * Whether a name is a well-formed namespaced block name.
48
+ *
49
+ * **Stricter than `indexOf('.') !== -1`**, which is how `data-model.md` §3
50
+ * describes the migration's idempotence test, and the difference is deliberate
51
+ * and narrow. No entry in the frozen rename map's domain contains a dot, so the
52
+ * two predicates agree on every name the migration renames. They differ only on
53
+ * a *malformed* dotted name — a hand-edited `acme.banner`, a fork's own
54
+ * spelling — which the lax test would classify as "already namespaced" and hide
55
+ * from the operator's report. Under this one it is unrecognised: reported, left
56
+ * alone, and degrading to the placeholder, which is the FR-014 path it belongs
57
+ * on.
58
+ */
59
+ export function isNamespaced(name) {
60
+ return blockNameRe.test(name);
61
+ }
62
+ /**
63
+ * Build a block name from its two parts.
64
+ *
65
+ * **Throws** where {@link parseBlockName} returns `null`, and the asymmetry is
66
+ * the point: reading meets names from a client's database, where an unknown one
67
+ * is expected; writing is a developer composing an identifier that will be
68
+ * persisted forever, where an unparseable one is a row nothing can ever render.
69
+ */
70
+ export function formatBlockName(owner, local) {
71
+ const name = `${owner}.${local}`;
72
+ if (!blockNameRe.test(name)) {
73
+ throw new Error(`[page-builder-core] "${name}" is not a valid block name (${String(blockNameRe)}) — ` +
74
+ 'the owner segment is a module id and the local name is PascalCase, and the name ' +
75
+ 'is persisted, so it cannot be corrected later.');
76
+ }
77
+ return name;
78
+ }
79
+ //# sourceMappingURL=block-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-name.js","sourceRoot":"","sources":["../src/block-name.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,gFAAgF;AAChF,0EAA0E;AAC1E,+EAA+E;AAC/E,+EAA+E;AAC/E,6EAA6E;AAC7E,yCAAyC;AACzC,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,gFAAgF;AAChF,6EAA6E;AAC7E,eAAe;AACf,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,wEAAwE;AACxE,cAAc;AAEd,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAU7D;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AAC/E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,KAAa;IAC1D,MAAM,IAAI,GAAG,GAAG,KAAK,IAAI,KAAK,EAAE,CAAC;IACjC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,wBAAwB,IAAI,gCAAgC,MAAM,CAAC,WAAW,CAAC,MAAM;YACnF,kFAAkF;YAClF,gDAAgD,CACnD,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Decide what happens to one `type` value found in a node position.
3
+ *
4
+ * Returning a string replaces the value; returning `undefined` leaves it
5
+ * byte-identical. The report returns `undefined` for everything, which is what
6
+ * makes it read-only by construction rather than by discipline.
7
+ */
8
+ export type BlockNameVisitor = (type: string) => string | undefined;
9
+ export interface BlockNameWalkResult {
10
+ /** The rewritten document. Structurally identical where nothing was renamed. */
11
+ readonly value: unknown;
12
+ /** How many node `type` values the visitor replaced. */
13
+ readonly renamed: number;
14
+ /** How many node positions were visited, replaced or not. */
15
+ readonly visited: number;
16
+ }
17
+ /**
18
+ * Walk a stored Puck document and offer every node `type` to `visit`.
19
+ *
20
+ * The returned `value` shares no mutated structure with the input: objects and
21
+ * arrays are rebuilt in place order, so a caller may compare the two for
22
+ * equality to decide whether an `update` is worth issuing.
23
+ */
24
+ export declare function mapBlockNames(doc: unknown, visit: BlockNameVisitor): BlockNameWalkResult;
25
+ /**
26
+ * Apply a rename map to a stored document.
27
+ *
28
+ * **One branch** (`contracts/block-name-migration.md` §3.3). A `type` the map
29
+ * holds is replaced; anything else is left byte-identical — an already
30
+ * namespaced name and an unrecognised one alike, because the map's domain is
31
+ * bare and its codomain is dotted, so the two sets are disjoint and no dot test
32
+ * is needed to tell them apart. That is what makes idempotence a property of the
33
+ * map rather than an outcome a branch has to remember to produce.
34
+ */
35
+ export declare function renameBlockNames(doc: unknown, renames: Readonly<Record<string, string>>): BlockNameWalkResult;
36
+ /**
37
+ * Count every node `type` in a document, writing nothing.
38
+ *
39
+ * The report's half of the shared walk. It returns occurrences per distinct
40
+ * name; the caller aggregates rows into the affected-row count, which is a
41
+ * question about rows and not about nodes.
42
+ */
43
+ export declare function countBlockNames(doc: unknown): Map<string, number>;
44
+ //# sourceMappingURL=block-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-tree.d.ts","sourceRoot":"","sources":["../src/block-tree.ts"],"names":[],"mappings":"AAkDA;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAEpE,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,GAAG,mBAAmB,CAoCxF;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACxC,mBAAmB,CAIrB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAOjE"}
@@ -0,0 +1,120 @@
1
+ // The structural block-name walk — feature 096, T403, moved out of
2
+ // `src/migration/` by T602.
3
+ //
4
+ // **One implementation, used by the five rename migrations, by the operator's
5
+ // pre-flight report, and by the admin editor's degradation merge**
6
+ // (`contracts/block-name-migration.md` §3). The three differ in what they do
7
+ // with a name and agree on how a name is found; two walks would be two answers
8
+ // waiting to disagree about the one thing that must not disagree — which nodes
9
+ // exist.
10
+ //
11
+ // The third reader is why the file sits here rather than under `src/migration/`.
12
+ // That subpath is not a runtime path, because the frozen rename map is in it and
13
+ // a resolver that could reach the map would make this feature the permanent
14
+ // alias map the owner rejected. The **walk** carries no such hazard: it knows
15
+ // nothing about any correspondence and only says which node `type` values a
16
+ // document holds, which is what FR-019's placeholder merge has to ask.
17
+ //
18
+ // ## It is structural, never textual
19
+ //
20
+ // Twelve of the 74 renamed names are ordinary English words that occur
21
+ // throughout shop content: `Row`, `Text`, `Image`, `Map`, `Button`, `Stats`,
22
+ // `Social`, `Column`, `Video`, `Icons`, `Tabs`, `Slide`. A `RawHtml` block's
23
+ // `html` prop, a `Text` block's `text` prop, a heading and every `alt` attribute
24
+ // in the shop are free text that may contain any of them, so a
25
+ // `replace('"Row"', '"cms.Row"')` over the serialised column corrupts content.
26
+ // The walk replaces the value of a `type` property **in a node position** and
27
+ // nothing else.
28
+ //
29
+ // ## What a node is, and what the walk descends into
30
+ //
31
+ // A JSON object is a node when it has a `type` property whose value is a string.
32
+ // `props` is **not** required — a legacy or hand-written node may lack it, and
33
+ // skipping such a node is a silent miss. (`check:block-names` requires the
34
+ // `props` sibling for the opposite reason: its subject is *source text*, where
35
+ // `{ type: 'text', label: 'Gap' }` is a Puck field descriptor and appears
36
+ // hundreds of times. The asymmetry is deliberate and is stated in
37
+ // `contracts/block-name-check.md` §2.1.)
38
+ //
39
+ // The walk descends into **every** value of every object and **every** element
40
+ // of every array. It does not key on `content` and `zones`: both envelope types
41
+ // are declared `& Record<string, unknown>` and round-tripped verbatim, and
42
+ // Puck's slot mechanism places node arrays under arbitrary prop keys — so a walk
43
+ // keyed on two known keys silently misses every slotted child, which in the CMS
44
+ // palette is `Column` inside `Row` and `Slide` inside `ContentSlider`, i.e. most
45
+ // of the tree.
46
+ //
47
+ // Everything that is not a node's `type` is copied through unchanged: prop
48
+ // values, key order within an object, array order, an envelope's `languages`
49
+ // keys and the deprecated `schema_version` key.
50
+ /**
51
+ * Walk a stored Puck document and offer every node `type` to `visit`.
52
+ *
53
+ * The returned `value` shares no mutated structure with the input: objects and
54
+ * arrays are rebuilt in place order, so a caller may compare the two for
55
+ * equality to decide whether an `update` is worth issuing.
56
+ */
57
+ export function mapBlockNames(doc, visit) {
58
+ let renamed = 0;
59
+ let visited = 0;
60
+ const descend = (node) => {
61
+ if (Array.isArray(node)) {
62
+ return node.map(descend);
63
+ }
64
+ if (node === null || typeof node !== 'object') {
65
+ return node;
66
+ }
67
+ const source = node;
68
+ const out = {};
69
+ // Key order is preserved because `Object.entries` yields insertion order and
70
+ // the output is built in that order. `jsonb` does not preserve key order at
71
+ // all, but the report also runs over parsed JS objects and the migration's
72
+ // fallback path re-serialises, so the walk keeps the property rather than
73
+ // relying on the column type to make it moot.
74
+ for (const [key, value] of Object.entries(source)) {
75
+ if (key === 'type' && typeof value === 'string') {
76
+ visited += 1;
77
+ const replacement = visit(value);
78
+ if (replacement !== undefined && replacement !== value) {
79
+ renamed += 1;
80
+ out[key] = replacement;
81
+ continue;
82
+ }
83
+ out[key] = value;
84
+ continue;
85
+ }
86
+ out[key] = descend(value);
87
+ }
88
+ return out;
89
+ };
90
+ return { value: descend(doc), renamed, visited };
91
+ }
92
+ /**
93
+ * Apply a rename map to a stored document.
94
+ *
95
+ * **One branch** (`contracts/block-name-migration.md` §3.3). A `type` the map
96
+ * holds is replaced; anything else is left byte-identical — an already
97
+ * namespaced name and an unrecognised one alike, because the map's domain is
98
+ * bare and its codomain is dotted, so the two sets are disjoint and no dot test
99
+ * is needed to tell them apart. That is what makes idempotence a property of the
100
+ * map rather than an outcome a branch has to remember to produce.
101
+ */
102
+ export function renameBlockNames(doc, renames) {
103
+ return mapBlockNames(doc, (type) => Object.prototype.hasOwnProperty.call(renames, type) ? renames[type] : undefined);
104
+ }
105
+ /**
106
+ * Count every node `type` in a document, writing nothing.
107
+ *
108
+ * The report's half of the shared walk. It returns occurrences per distinct
109
+ * name; the caller aggregates rows into the affected-row count, which is a
110
+ * question about rows and not about nodes.
111
+ */
112
+ export function countBlockNames(doc) {
113
+ const counts = new Map();
114
+ mapBlockNames(doc, (type) => {
115
+ counts.set(type, (counts.get(type) ?? 0) + 1);
116
+ return undefined;
117
+ });
118
+ return counts;
119
+ }
120
+ //# sourceMappingURL=block-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-tree.js","sourceRoot":"","sources":["../src/block-tree.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,4BAA4B;AAC5B,EAAE;AACF,8EAA8E;AAC9E,mEAAmE;AACnE,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAC/E,SAAS;AACT,EAAE;AACF,iFAAiF;AACjF,iFAAiF;AACjF,4EAA4E;AAC5E,8EAA8E;AAC9E,4EAA4E;AAC5E,uEAAuE;AACvE,EAAE;AACF,qCAAqC;AACrC,EAAE;AACF,uEAAuE;AACvE,6EAA6E;AAC7E,6EAA6E;AAC7E,iFAAiF;AACjF,+DAA+D;AAC/D,+EAA+E;AAC/E,8EAA8E;AAC9E,gBAAgB;AAChB,EAAE;AACF,qDAAqD;AACrD,EAAE;AACF,iFAAiF;AACjF,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAC/E,0EAA0E;AAC1E,kEAAkE;AAClE,yCAAyC;AACzC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,2EAA2E;AAC3E,iFAAiF;AACjF,gFAAgF;AAChF,iFAAiF;AACjF,eAAe;AACf,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,gDAAgD;AAoBhD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY,EAAE,KAAuB;IACjE,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,MAAM,OAAO,GAAG,CAAC,IAAa,EAAW,EAAE;QACzC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAA+B,CAAC;QAC/C,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,6EAA6E;QAC7E,4EAA4E;QAC5E,2EAA2E;QAC3E,0EAA0E;QAC1E,8CAA8C;QAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,IAAI,GAAG,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAChD,OAAO,IAAI,CAAC,CAAC;gBACb,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;gBACjC,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;oBACvD,OAAO,IAAI,CAAC,CAAC;oBACb,GAAG,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;oBACvB,SAAS;gBACX,CAAC;gBACD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACjB,SAAS;YACX,CAAC;YACD,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACnD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAY,EACZ,OAAyC;IAEzC,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CACjC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAChF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QAC1B,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9C,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { usePreviewBreakpointTier } from './editor/use-preview-breakpoint-tier.js';
2
+ export { ColorPaletteProvider, useColorPalette, type ColorPaletteEntry, type ColorPaletteContextValue, } from './color-palette/context.js';
3
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,4BAA4B,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,4 @@
1
+ 'use client';
2
+ export { usePreviewBreakpointTier } from './editor/use-preview-breakpoint-tier.js';
3
+ export { ColorPaletteProvider, useColorPalette, } from './color-palette/context.js';
4
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EACL,oBAAoB,EACpB,eAAe,GAGhB,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface ColorPaletteEntry {
3
+ id: string;
4
+ name: string;
5
+ hex: string;
6
+ }
7
+ export interface ColorPaletteContextValue {
8
+ entries: ColorPaletteEntry[];
9
+ openPalette: (onSelect: (hex: string) => void) => void;
10
+ refreshPalette: () => Promise<void>;
11
+ savePalette: (entries: ColorPaletteEntry[]) => Promise<void>;
12
+ }
13
+ export declare function ColorPaletteProvider({ value, children, }: {
14
+ value: ColorPaletteContextValue;
15
+ children: ReactNode;
16
+ }): ReactNode;
17
+ export declare function useColorPalette(): ColorPaletteContextValue | null;
18
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/color-palette/context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC;IACvD,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,WAAW,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAID,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,SAAS,CAEZ;AAED,wBAAgB,eAAe,IAAI,wBAAwB,GAAG,IAAI,CAEjE"}
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from 'react';
4
+ const ColorPaletteContext = createContext(null);
5
+ export function ColorPaletteProvider({ value, children, }) {
6
+ return _jsx(ColorPaletteContext.Provider, { value: value, children: children });
7
+ }
8
+ export function useColorPalette() {
9
+ return useContext(ColorPaletteContext);
10
+ }
11
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/color-palette/context.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAelE,MAAM,mBAAmB,GAAG,aAAa,CAAkC,IAAI,CAAC,CAAC;AAEjF,MAAM,UAAU,oBAAoB,CAAC,EACnC,KAAK,EACL,QAAQ,GAIT;IACC,OAAO,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { ComponentConfig, Config } from '@measured/puck';
2
+ import type { PageBuilderContext } from './types/responsive.js';
3
+ export type ComponentContextMeta = {
4
+ /** Contexts where this component is available. Defaults to `['cms']`. */
5
+ contexts?: readonly PageBuilderContext[];
6
+ /** Prop keys that support per-breakpoint overrides in the CMS editor. */
7
+ responsiveFields?: readonly string[];
8
+ };
9
+ export type PageBuilderComponentDefinition = ComponentConfig & ComponentContextMeta;
10
+ /**
11
+ * Attach Page Builder metadata to a Puck component config. Metadata is stored
12
+ * on the config object for palette filtering; it does not affect Puck runtime.
13
+ */
14
+ export declare function definePageBuilderComponent(definition: PageBuilderComponentDefinition): PageBuilderComponentDefinition;
15
+ export declare function getComponentContexts(config: ComponentConfig): PageBuilderContext[];
16
+ export declare function getResponsiveFields(config: ComponentConfig): string[];
17
+ /** Filter a Puck config palette to components allowed in the given context. */
18
+ /**
19
+ * Does a block declared for `declared` appear in the `target` palette?
20
+ *
21
+ * **`contexts` states what a block is *authored for*; appearance is derived**
22
+ * (feature 096, D-10, normative in
23
+ * `specs/096-page-builder-block-ownership/contracts/block-definition.md` §4.1.1).
24
+ * The one admission the platform grants is `email -> newsletter`: every e-mail
25
+ * block is offered in the newsletter palette, and **no block in the tree
26
+ * declares `newsletter`** — that member of `PageBuilderContext` has never had a
27
+ * block of its own.
28
+ *
29
+ * Extracted because the rule was written **twice in this file** and T305's
30
+ * derived palette would have been the third copy — the `text-normalization.ts`
31
+ * discipline, where a rule with two implementations is a rule with two answers
32
+ * waiting to disagree. The two spellings were proved equivalent before the
33
+ * extraction rather than assumed to be: over all 16 subsets of
34
+ * `PageBuilderContext` against all 4 contexts, 64 combinations, **zero
35
+ * divergences** — including `['newsletter']` alone, which the task note
36
+ * predicted would diverge and does not.
37
+ *
38
+ * It is load-bearing on four live editor surfaces — `newsletter`'s `BlocksPage`
39
+ * (twice), `CampaignEditor` and `AutomationBuilder`, all reaching
40
+ * `EmailEditorPane` — so removing the admission empties the palette every
41
+ * campaign, block and automation step is authored against.
42
+ */
43
+ export declare function contextAdmits(declared: readonly PageBuilderContext[], target: PageBuilderContext): boolean;
44
+ export declare function filterConfigByContext(config: Config, context: PageBuilderContext): Config;
45
+ /** Component names disallowed in a context (for slot `disallow` props). */
46
+ export declare function getDisallowedComponentNames(config: Config, context: PageBuilderContext): string[];
47
+ //# sourceMappingURL=define-component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-component.d.ts","sourceRoot":"","sources":["../src/define-component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,MAAM,MAAM,oBAAoB,GAAG;IACjC,yEAAyE;IACzE,QAAQ,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACzC,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAEpF;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,8BAA8B,GACzC,8BAA8B,CAKhC;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,kBAAkB,EAAE,CAGlF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE,CAGrE;AAED,+EAA+E;AAC/E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,kBAAkB,EAAE,EACvC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAGT;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAiBzF;AAED,2EAA2E;AAC3E,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAKjG"}
@@ -0,0 +1,74 @@
1
+ import { enhancePageBuilderComponent } from './editor/enhance-component-config.js';
2
+ /**
3
+ * Attach Page Builder metadata to a Puck component config. Metadata is stored
4
+ * on the config object for palette filtering; it does not affect Puck runtime.
5
+ */
6
+ export function definePageBuilderComponent(definition) {
7
+ return enhancePageBuilderComponent({
8
+ contexts: ['cms'],
9
+ ...definition,
10
+ });
11
+ }
12
+ export function getComponentContexts(config) {
13
+ const meta = config;
14
+ return [...(meta.contexts ?? ['cms'])];
15
+ }
16
+ export function getResponsiveFields(config) {
17
+ const meta = config;
18
+ return [...(meta.responsiveFields ?? [])];
19
+ }
20
+ /** Filter a Puck config palette to components allowed in the given context. */
21
+ /**
22
+ * Does a block declared for `declared` appear in the `target` palette?
23
+ *
24
+ * **`contexts` states what a block is *authored for*; appearance is derived**
25
+ * (feature 096, D-10, normative in
26
+ * `specs/096-page-builder-block-ownership/contracts/block-definition.md` §4.1.1).
27
+ * The one admission the platform grants is `email -> newsletter`: every e-mail
28
+ * block is offered in the newsletter palette, and **no block in the tree
29
+ * declares `newsletter`** — that member of `PageBuilderContext` has never had a
30
+ * block of its own.
31
+ *
32
+ * Extracted because the rule was written **twice in this file** and T305's
33
+ * derived palette would have been the third copy — the `text-normalization.ts`
34
+ * discipline, where a rule with two implementations is a rule with two answers
35
+ * waiting to disagree. The two spellings were proved equivalent before the
36
+ * extraction rather than assumed to be: over all 16 subsets of
37
+ * `PageBuilderContext` against all 4 contexts, 64 combinations, **zero
38
+ * divergences** — including `['newsletter']` alone, which the task note
39
+ * predicted would diverge and does not.
40
+ *
41
+ * It is load-bearing on four live editor surfaces — `newsletter`'s `BlocksPage`
42
+ * (twice), `CampaignEditor` and `AutomationBuilder`, all reaching
43
+ * `EmailEditorPane` — so removing the admission empties the palette every
44
+ * campaign, block and automation step is authored against.
45
+ */
46
+ export function contextAdmits(declared, target) {
47
+ if (declared.includes(target))
48
+ return true;
49
+ return target === 'newsletter' && declared.includes('email');
50
+ }
51
+ export function filterConfigByContext(config, context) {
52
+ const components = {};
53
+ for (const [name, component] of Object.entries(config.components ?? {})) {
54
+ if (contextAdmits(getComponentContexts(component), context)) {
55
+ components[name] = component;
56
+ }
57
+ }
58
+ const categories = {};
59
+ for (const [key, category] of Object.entries(config.categories ?? {})) {
60
+ const filteredComponents = (category.components ?? []).filter((name) => name in components);
61
+ if (filteredComponents.length > 0) {
62
+ categories[key] = { ...category, components: filteredComponents };
63
+ }
64
+ }
65
+ return { ...config, components, categories };
66
+ }
67
+ /** Component names disallowed in a context (for slot `disallow` props). */
68
+ export function getDisallowedComponentNames(config, context) {
69
+ return Object.keys(config.components ?? {}).filter((name) => {
70
+ const component = config.components[name];
71
+ return !contextAdmits(getComponentContexts(component), context);
72
+ });
73
+ }
74
+ //# sourceMappingURL=define-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-component.js","sourceRoot":"","sources":["../src/define-component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAWnF;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAA0C;IAE1C,OAAO,2BAA2B,CAAC;QACjC,QAAQ,EAAE,CAAC,KAAK,CAAC;QACjB,GAAG,UAAU;KACd,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC1D,MAAM,IAAI,GAAG,MAA8B,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAuB;IACzD,MAAM,IAAI,GAAG,MAA8B,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,+EAA+E;AAC/E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAuC,EACvC,MAA0B;IAE1B,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,MAAM,KAAK,YAAY,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAc,EAAE,OAA2B;IAC/E,MAAM,UAAU,GAAyB,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC;QACxE,IAAI,aAAa,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC;YAC5D,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAyB,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC;QACtE,MAAM,kBAAkB,GAAG,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC;QAC5F,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;QACpE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AAC/C,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,2BAA2B,CAAC,MAAc,EAAE,OAA2B;IACrF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1D,MAAM,SAAS,GAAG,MAAM,CAAC,UAAW,CAAC,IAAI,CAAE,CAAC;QAC5C,OAAO,CAAC,aAAa,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type EditorCarouselPreviewUi = {
2
+ carouselPreviewPages?: Record<string, number>;
3
+ };
4
+ export declare function readEditorCarouselPages(ui: EditorCarouselPreviewUi | undefined): Record<string, number>;
5
+ export declare function getEditorCarouselPageFromUi(ui: EditorCarouselPreviewUi | undefined, carouselId: string): number;
6
+ export declare function carouselEditorPageCount(slideCount: number, slidesPerView: number): number;
7
+ //# sourceMappingURL=editor-carousel-preview-ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-carousel-preview-ui.d.ts","sourceRoot":"","sources":["../../src/editor/editor-carousel-preview-ui.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,uBAAuB,GAAG,SAAS,GACtC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExB;AAED,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,uBAAuB,GAAG,SAAS,EACvC,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAGzF"}
@@ -0,0 +1,11 @@
1
+ export function readEditorCarouselPages(ui) {
2
+ return ui?.carouselPreviewPages ?? {};
3
+ }
4
+ export function getEditorCarouselPageFromUi(ui, carouselId) {
5
+ return readEditorCarouselPages(ui)[carouselId] ?? 0;
6
+ }
7
+ export function carouselEditorPageCount(slideCount, slidesPerView) {
8
+ const perView = Math.max(1, Math.round(slidesPerView));
9
+ return Math.max(1, Math.ceil(Math.max(0, slideCount) / perView));
10
+ }
11
+ //# sourceMappingURL=editor-carousel-preview-ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-carousel-preview-ui.js","sourceRoot":"","sources":["../../src/editor/editor-carousel-preview-ui.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,uBAAuB,CACrC,EAAuC;IAEvC,OAAO,EAAE,EAAE,oBAAoB,IAAI,EAAE,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,EAAuC,EACvC,UAAkB;IAElB,OAAO,uBAAuB,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,UAAkB,EAAE,aAAqB;IAC/E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC"}