@perkyzz/emvb 0.9.0 → 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 (160) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/src/admin/agents-api.ts +45 -0
  4. package/src/admin/editor/A11yCopilot.tsx +1 -1
  5. package/src/admin/editor/Editor.tsx +297 -248
  6. package/src/admin/editor/Timeline.tsx +2 -1
  7. package/src/admin/editor/TopBar.tsx +4 -2
  8. package/src/admin/editor/canvas/CanvasFrame.tsx +2 -2
  9. package/src/admin/editor/canvas/DeviceBar.tsx +17 -9
  10. package/src/admin/editor/canvas/canvas-scale.ts +2 -2
  11. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  12. package/src/admin/editor/co-design.ts +190 -0
  13. package/src/admin/editor/dnd/new-element.ts +26 -4
  14. package/src/admin/editor/editor-chrome.tsx +3 -3
  15. package/src/admin/editor/editor-commands.ts +8 -3
  16. package/src/admin/editor/element-chrome.ts +3 -1
  17. package/src/admin/editor/extension-manifests.ts +20 -0
  18. package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
  19. package/src/admin/editor/extensions-context.tsx +27 -0
  20. package/src/admin/editor/feature-css.ts +17 -0
  21. package/src/admin/editor/palette-items.ts +2 -2
  22. package/src/admin/editor/panels/AddPanel.tsx +31 -1
  23. package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
  24. package/src/admin/editor/panels/ClassesSection.tsx +9 -6
  25. package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
  26. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  27. package/src/admin/editor/panels/ElementPanel.tsx +49 -14
  28. package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
  29. package/src/admin/editor/panels/LayersPanel.tsx +10 -6
  30. package/src/admin/editor/panels/LeftPanel.tsx +33 -5
  31. package/src/admin/editor/panels/PageSettings.tsx +4 -0
  32. package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
  33. package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
  34. package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
  35. package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
  36. package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
  37. package/src/admin/editor/panels/settings/EffectsControls.tsx +104 -9
  38. package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
  39. package/src/admin/editor/panels/settings/IconControls.tsx +14 -11
  40. package/src/admin/editor/panels/settings/LengthRow.tsx +27 -16
  41. package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
  42. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
  43. package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
  44. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
  45. package/src/admin/editor/panels/settings/StyleRow.tsx +113 -13
  46. package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
  47. package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
  48. package/src/admin/editor/panels/settings/background-mode.ts +14 -11
  49. package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
  50. package/src/admin/editor/panels/settings/box-sides.ts +22 -14
  51. package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
  52. package/src/admin/editor/panels/settings/length-units.ts +53 -1
  53. package/src/admin/editor/panels/settings/query-style.ts +3 -3
  54. package/src/admin/editor/panels/settings/style-sections.ts +51 -10
  55. package/src/admin/editor/panels/style-target.ts +9 -7
  56. package/src/admin/editor/presence.ts +60 -0
  57. package/src/admin/editor/store.ts +6 -2
  58. package/src/admin/editor/useCoDesign.ts +177 -0
  59. package/src/admin/editor/useEditorCommands.ts +4 -4
  60. package/src/admin/editor/useExtensions.ts +45 -0
  61. package/src/admin/editor/useNodeActions.ts +15 -6
  62. package/src/admin/editor/useProposals.ts +81 -0
  63. package/src/admin/languages-api.ts +61 -0
  64. package/src/admin/pages/AgentSetup.tsx +148 -0
  65. package/src/admin/pages/AgentsPage.tsx +9 -26
  66. package/src/admin/pages/CreateDialog.tsx +15 -0
  67. package/src/admin/pages/ImportButton.tsx +18 -0
  68. package/src/admin/pages/ImportElementorDialog.tsx +669 -0
  69. package/src/admin/pages/ImportPageLinks.tsx +86 -0
  70. package/src/admin/pages/PageList.tsx +15 -1
  71. package/src/admin/pages/ThemePartList.tsx +15 -1
  72. package/src/admin/pages/section-head.tsx +27 -0
  73. package/src/admin/proposals-api.ts +91 -0
  74. package/src/admin/ui.ts +39 -2
  75. package/src/astro/content-port.ts +14 -1
  76. package/src/astro/resolve-theme.ts +14 -1
  77. package/src/astro/resolve.ts +89 -2
  78. package/src/constants.ts +1 -1
  79. package/src/core/a11y/audit.ts +44 -14
  80. package/src/core/arrange.ts +5 -1
  81. package/src/core/bounded-array.ts +31 -0
  82. package/src/core/clipboard.ts +9 -0
  83. package/src/core/contract.ts +285 -0
  84. package/src/core/css/generate.ts +89 -20
  85. package/src/core/css/trace.ts +18 -9
  86. package/src/core/css-keywords.ts +51 -1
  87. package/src/core/design/cascade.ts +12 -9
  88. package/src/core/design/classes.ts +4 -5
  89. package/src/core/design/devices.ts +13 -13
  90. package/src/core/design/states.ts +5 -3
  91. package/src/core/design/transfer.ts +5 -0
  92. package/src/core/design/variables.ts +17 -4
  93. package/src/core/elements/dynamic-elements.ts +3 -3
  94. package/src/core/elements/index.ts +73 -9
  95. package/src/core/extensions/define.ts +13 -0
  96. package/src/core/extensions/index.ts +41 -0
  97. package/src/core/extensions/namespace.ts +82 -0
  98. package/src/core/extensions/normalize.ts +141 -0
  99. package/src/core/extensions/placeholder.ts +41 -0
  100. package/src/core/extensions/registry.ts +94 -0
  101. package/src/core/extensions/render-ext.ts +118 -0
  102. package/src/core/extensions/safe-nodes.ts +93 -0
  103. package/src/core/extensions/schema.ts +112 -0
  104. package/src/core/extensions/types.ts +159 -0
  105. package/src/core/forms/binding.ts +1 -1
  106. package/src/core/history/diff.ts +1 -1
  107. package/src/core/import/elementor/atomic.ts +1595 -0
  108. package/src/core/import/elementor/classes.ts +127 -0
  109. package/src/core/import/elementor/context.ts +429 -0
  110. package/src/core/import/elementor/counter-steps.ts +72 -0
  111. package/src/core/import/elementor/css.ts +445 -0
  112. package/src/core/import/elementor/html.ts +500 -0
  113. package/src/core/import/elementor/index.ts +949 -0
  114. package/src/core/import/elementor/inline-marks.ts +81 -0
  115. package/src/core/import/elementor/snapshots.ts +48 -0
  116. package/src/core/import/elementor/style.ts +409 -0
  117. package/src/core/import/elementor/values.ts +241 -0
  118. package/src/core/import/elementor/widgets.ts +1897 -0
  119. package/src/core/index.ts +82 -0
  120. package/src/core/json-schema.ts +107 -0
  121. package/src/core/limits.ts +19 -0
  122. package/src/core/migrate/index.ts +6 -1
  123. package/src/core/migrate/v18.ts +222 -0
  124. package/src/core/perf/meter.ts +5 -5
  125. package/src/core/proposals-safety.ts +102 -0
  126. package/src/core/proposals.ts +357 -0
  127. package/src/core/recipes/index.ts +2 -2
  128. package/src/core/render/extras.ts +3 -3
  129. package/src/core/render/index.ts +140 -20
  130. package/src/core/render/loop.ts +1 -1
  131. package/src/core/render/section.ts +4 -4
  132. package/src/core/render/vnode.ts +1 -1
  133. package/src/core/sanitize/css.ts +125 -10
  134. package/src/core/sanitize/motion.ts +116 -0
  135. package/src/core/saved-sections.ts +6 -0
  136. package/src/core/schema/descriptors.ts +3 -1
  137. package/src/core/schema/design.ts +2 -1
  138. package/src/core/schema/layout.ts +82 -14
  139. package/src/core/schema/style.ts +251 -114
  140. package/src/core/text-marks.ts +227 -0
  141. package/src/core/theme/dynamic.ts +9 -4
  142. package/src/core/theme/float.ts +1 -0
  143. package/src/core/theme/popup-rules.ts +17 -1
  144. package/src/core/translatable.ts +34 -0
  145. package/src/core/validate.ts +13 -1
  146. package/src/index.ts +24 -0
  147. package/src/mcp/errors.ts +3 -1
  148. package/src/mcp/ports.ts +67 -0
  149. package/src/mcp/prompts.ts +1 -11
  150. package/src/mcp/proposals.ts +281 -0
  151. package/src/mcp/read.ts +10 -9
  152. package/src/mcp/tools.ts +71 -3
  153. package/src/mcp/write.ts +66 -11
  154. package/src/server/agent-settings.ts +5 -1
  155. package/src/server/mcp-routes.ts +15 -0
  156. package/src/server/plugin.ts +35 -2
  157. package/src/server/presence.ts +78 -0
  158. package/src/server/proposals.ts +261 -0
  159. package/src/server/requests.ts +196 -0
  160. package/src/server/tools-served.ts +45 -0
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
+ import { LIST_MARKERS } from "../css-keywords.ts";
2
3
  import { MAX_TEXT_LENGTH } from "../limits.ts";
3
4
  import { ImageEdit } from "../image-edit/schema.ts";
4
- import { DeviceStyles, HiddenOn, Length, StyleProps, StyleStates } from "./style.ts";
5
+ import { ColorValue, DeviceStyles, HiddenOn, Length, StyleProps, StyleStates } from "./style.ts";
5
6
 
6
7
  /**
7
8
  * 16 since W-481 (D-061): an optional editor-only `edit` record on images (image editor).
@@ -15,9 +16,19 @@ import { DeviceStyles, HiddenOn, Length, StyleProps, StyleStates } from "./style
15
16
  * Loop's Empty state element. Every other value is unchanged.
16
17
  * 12 since W-160: gradient type, stop locations, and up to 10 stops. v11 gradients
17
18
  * (`{ angle, from, to }`) become a linear gradient on read.
19
+ * 18 since W-925 (D-065, contract 1.0): the Section reference node is `part-ref`, a node's
20
+ * editor name is `editorLabel`, a Loop's template part is `partId`, and the four motion style
21
+ * keys sit under one `motion` record. Older documents are rewritten on read.
18
22
  * 11 since W-156 and W-157 (D-045): the layout Section element and an editor-only node label.
19
23
  */
20
- export const LAYOUT_SCHEMA_VERSION = 17;
24
+ export const LAYOUT_SCHEMA_VERSION = 18;
25
+
26
+ /**
27
+ * The frozen document contract (W-925, D-065). Within 1.x a new optional key may appear
28
+ * without a schemaVersion bump, and readers keep keys they do not know; a rename or a removal
29
+ * needs 2.0. `schemaVersion` stays a plain number for the migration chain.
30
+ */
31
+ export const CONTRACT_VERSION = "1.0";
21
32
 
22
33
  export const NodeId = z
23
34
  .string()
@@ -163,7 +174,8 @@ const sharedNodeFields = {
163
174
  classes: ClassIds.optional(),
164
175
  htmlId: HtmlId.optional(),
165
176
  attributes: HtmlAttributes.optional(),
166
- label: NodeLabel.optional(),
177
+ /** The name shown in the editor's Navigator (was `label` before schema 18). Never rendered. */
178
+ editorLabel: NodeLabel.optional(),
167
179
  bind: Bindings.optional(),
168
180
  variant: Variant.optional(),
169
181
  audience: Audience.optional(),
@@ -202,6 +214,26 @@ const parentNode = <T extends string, P extends z.ZodType>(type: T, props: P) =>
202
214
  },
203
215
  });
204
216
 
217
+ /** W-950: at most this many formatted ranges in one Heading or Text. */
218
+ export const MAX_TEXT_MARKS = 100;
219
+
220
+ /**
221
+ * W-950: formatting on part of a Heading's or Text's words: characters `start` to `end` (end not
222
+ * included) are bold, italic, in a colour and/or a link. The text stays plain; ranges past its
223
+ * end are clipped when the page is drawn, so changing the text never makes a page invalid.
224
+ */
225
+ export const TextMark = z.strictObject({
226
+ start: z.number().int().min(0).max(MAX_TEXT_LENGTH),
227
+ end: z.number().int().min(1).max(MAX_TEXT_LENGTH),
228
+ bold: z.literal(true).optional(),
229
+ italic: z.literal(true).optional(),
230
+ color: ColorValue.optional(),
231
+ href: z.string().min(1).max(2000).optional(),
232
+ newTab: z.literal(true).optional(),
233
+ });
234
+ export type TextMark = z.infer<typeof TextMark>;
235
+ const TextMarks = z.array(TextMark).max(MAX_TEXT_MARKS);
236
+
205
237
  export const HeadingNode = leafNode(
206
238
  "heading",
207
239
  z.strictObject({
@@ -210,6 +242,8 @@ export const HeadingNode = leafNode(
210
242
  /** Optional link around the text (W-141), like Elementor's Heading link. */
211
243
  href: z.string().max(2000).optional(),
212
244
  newTab: z.boolean().optional(),
245
+ /** W-950: bold, italic, colour and links on part of the text (links only when unlinked). */
246
+ marks: TextMarks.optional(),
213
247
  }),
214
248
  );
215
249
 
@@ -227,6 +261,8 @@ export const TextNode = leafNode(
227
261
  z.strictObject({
228
262
  text: z.string().max(MAX_TEXT_LENGTH),
229
263
  tag: z.enum(TEXT_TAGS).optional(),
264
+ /** W-950: bold, italic, colour and links on part of the text. */
265
+ marks: TextMarks.optional(),
230
266
  }),
231
267
  );
232
268
 
@@ -265,6 +301,10 @@ export const ListNode = leafNode(
265
301
  "list",
266
302
  z.strictObject({
267
303
  ordered: z.boolean().optional(),
304
+ /** W-952: the marker style; a number style or `steps` makes the list numbered. */
305
+ marker: z.enum(LIST_MARKERS).optional(),
306
+ /** W-952: the first number of a numbered list. */
307
+ start: z.number().int().min(1).max(9999).optional(),
268
308
  items: z.array(z.string().max(MAX_TEXT_LENGTH)).max(200),
269
309
  }),
270
310
  );
@@ -560,7 +600,7 @@ export const PostLinkNode = leafNode(
560
600
 
561
601
  /**
562
602
  * Repeats its item template for each post in ThemeDynamicData.posts.
563
- * When `itemPartId` is set, the host supplies that Loop Item layout in loopTemplates;
603
+ * When `partId` is set, the host supplies that Loop Item layout in loopTemplates;
564
604
  * otherwise children are the inline item template.
565
605
  */
566
606
  /** How a Loop lays out its items (W-308): one design, shown as a list, a grid or cards. */
@@ -584,7 +624,7 @@ export const LOOP_ORDERS = ["newest", "oldest", "title"] as const;
584
624
  export const LoopNode = parentNode(
585
625
  "loop",
586
626
  z.strictObject({
587
- itemPartId: z.string().max(128).optional(),
627
+ partId: z.string().max(128).optional(),
588
628
  /** Posts per archive page, 1–50 (W-221). Unset = 20. */
589
629
  perPage: z.number().int().min(1).max(50).optional(),
590
630
  /**
@@ -671,7 +711,7 @@ export const PaginationNode = leafNode(
671
711
  * `sectionTemplates` and the part's children render in place of `children`.
672
712
  */
673
713
  export const SectionNode = parentNode(
674
- "section",
714
+ "part-ref",
675
715
  z.strictObject({
676
716
  partId: z.string().max(128).optional(),
677
717
  }),
@@ -708,7 +748,7 @@ export const KNOWN_ELEMENT_TYPES = [
708
748
  "loop",
709
749
  "loop-empty",
710
750
  "pagination",
711
- "section",
751
+ "part-ref",
712
752
  "div-block",
713
753
  "flexbox",
714
754
  "grid",
@@ -721,6 +761,7 @@ export const KNOWN_ELEMENT_TYPES = [
721
761
  "menu-item",
722
762
  "layout-section",
723
763
  "toc",
764
+ "language-switcher",
724
765
  ] as const;
725
766
 
726
767
  /** Headings on this page, as a list of links. No script (W-345). */
@@ -731,6 +772,17 @@ export const TocNode = leafNode(
731
772
  }),
732
773
  );
733
774
 
775
+ /**
776
+ * W-937: links to this page in its other published languages (EmDash translations), each with
777
+ * hreflang. `label` names the navigation for screen readers. The host fills the links.
778
+ */
779
+ export const LanguageSwitcherNode = leafNode(
780
+ "language-switcher",
781
+ z.strictObject({
782
+ label: z.string().max(80).optional(),
783
+ }),
784
+ );
785
+
734
786
  const knownTypeSet = new Set<string>(KNOWN_ELEMENT_TYPES);
735
787
 
736
788
  /**
@@ -742,7 +794,8 @@ const UnknownNodeSchema = z.strictObject({
742
794
  type: z
743
795
  .string()
744
796
  .min(1)
745
- .max(64)
797
+ // W-927: extension types are ext:<pkg>/<name>; 128 fits the longest allowed id.
798
+ .max(128)
746
799
  .refine((value) => !knownTypeSet.has(value), "Unknown element type"),
747
800
  props: z.record(z.string(), z.unknown()),
748
801
  ...sharedNodeFields,
@@ -762,6 +815,7 @@ const KnownLayoutNode = z.discriminatedUnion("type", [
762
815
  TabPanelNode,
763
816
  HeadingNode,
764
817
  TocNode,
818
+ LanguageSwitcherNode,
765
819
  SpacerNode,
766
820
  DividerNode,
767
821
  TextNode,
@@ -801,6 +855,7 @@ export const KNOWN_NODE_SCHEMAS = KnownLayoutNode.options;
801
855
 
802
856
  export type HeadingNode = z.infer<typeof HeadingNode>;
803
857
  export type TocNode = z.infer<typeof TocNode>;
858
+ export type LanguageSwitcherNode = z.infer<typeof LanguageSwitcherNode>;
804
859
  export type SpacerNode = z.infer<typeof SpacerNode>;
805
860
  export type DividerNode = z.infer<typeof DividerNode>;
806
861
  export type TextNode = z.infer<typeof TextNode>;
@@ -855,7 +910,7 @@ type NodeEnvelope = {
855
910
  classes?: ClassesOf;
856
911
  htmlId?: HtmlIdOf;
857
912
  attributes?: HtmlAttributeOf[];
858
- label?: string;
913
+ editorLabel?: string;
859
914
  } & NodeExtras;
860
915
 
861
916
  /** Manual recursive types so UnknownNode does not poison `z.infer` of the tree. */
@@ -937,7 +992,7 @@ export type FormNode = NodeEnvelope & {
937
992
  export type LoopNode = NodeEnvelope & {
938
993
  type: "loop";
939
994
  props: {
940
- itemPartId?: string;
995
+ partId?: string;
941
996
  perPage?: number;
942
997
  collection?: string;
943
998
  limit?: number;
@@ -955,7 +1010,7 @@ export type LoopEmptyNode = NodeEnvelope & {
955
1010
  };
956
1011
 
957
1012
  export type SectionNode = NodeEnvelope & {
958
- type: "section";
1013
+ type: "part-ref";
959
1014
  props: { partId?: string };
960
1015
  children: LayoutNode[];
961
1016
  };
@@ -999,6 +1054,7 @@ export type LayoutNode =
999
1054
  | SectionNode
1000
1055
  | HeadingNode
1001
1056
  | TocNode
1057
+ | LanguageSwitcherNode
1002
1058
  | SpacerNode
1003
1059
  | DividerNode
1004
1060
  | TextNode
@@ -1081,7 +1137,19 @@ export const isFormNode = (node: LayoutNode): node is FormNode => node.type ===
1081
1137
 
1082
1138
  export const isLoopNode = (node: LayoutNode): node is LoopNode => node.type === "loop";
1083
1139
 
1084
- export const isSectionNode = (node: LayoutNode): node is SectionNode => node.type === "section";
1140
+ /**
1141
+ * The class name an element type renders with (`emvb-<name>`). A Section reference became
1142
+ * `part-ref` in schema 18 (W-925) but keeps its public class `emvb-section`, so site CSS and
1143
+ * the rendered output are unchanged.
1144
+ */
1145
+ export const cssTypeName = (type: string): string => {
1146
+ if (type === "part-ref") return "section";
1147
+ // W-927: every extension element shares the emvb-ext class (type holds : and /).
1148
+ if (type.startsWith("ext:")) return "ext";
1149
+ return type;
1150
+ };
1151
+
1152
+ export const isSectionNode = (node: LayoutNode): node is SectionNode => node.type === "part-ref";
1085
1153
 
1086
1154
  export const isDivBlockNode = (node: LayoutNode): node is DivBlockNode => node.type === "div-block";
1087
1155
 
@@ -1112,7 +1180,7 @@ export const isLayoutParentNode = (
1112
1180
  node.type === "flexbox" ||
1113
1181
  node.type === "grid" ||
1114
1182
  node.type === "tab-panel" ||
1115
- node.type === "section" ||
1183
+ node.type === "part-ref" ||
1116
1184
  node.type === "loop-empty" ||
1117
1185
  node.type === "accordion-item" ||
1118
1186
  node.type === "menu-item";
@@ -1144,7 +1212,7 @@ export const isParentNode = (
1144
1212
  node.type === "form" ||
1145
1213
  node.type === "loop" ||
1146
1214
  node.type === "loop-empty" ||
1147
- node.type === "section" ||
1215
+ node.type === "part-ref" ||
1148
1216
  node.type === "tabs" ||
1149
1217
  node.type === "tab-panel" ||
1150
1218
  node.type === "accordion" ||