@perkyzz/emvb 0.9.0 → 1.1.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 (187) hide show
  1. package/README.md +10 -1
  2. package/package.json +2 -2
  3. package/src/admin/agents-api.ts +45 -0
  4. package/src/admin/bulk-api.ts +67 -0
  5. package/src/admin/content-api.ts +10 -6
  6. package/src/admin/copy-rich-text.ts +119 -0
  7. package/src/admin/dialog-tab-wrap.ts +78 -0
  8. package/src/admin/editor/A11yCopilot.tsx +3 -1
  9. package/src/admin/editor/Editor.tsx +311 -250
  10. package/src/admin/editor/Timeline.tsx +8 -3
  11. package/src/admin/editor/TopBar.tsx +29 -7
  12. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  13. package/src/admin/editor/canvas/DeviceBar.tsx +31 -10
  14. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  15. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  16. package/src/admin/editor/co-design.ts +190 -0
  17. package/src/admin/editor/dnd/new-element.ts +48 -4
  18. package/src/admin/editor/editor-chrome.tsx +8 -6
  19. package/src/admin/editor/editor-commands.ts +15 -4
  20. package/src/admin/editor/editor-css.ts +2 -1
  21. package/src/admin/editor/element-chrome.ts +3 -1
  22. package/src/admin/editor/extension-manifests.ts +20 -0
  23. package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
  24. package/src/admin/editor/extensions-context.tsx +27 -0
  25. package/src/admin/editor/feature-css.ts +17 -0
  26. package/src/admin/editor/palette-items.ts +2 -2
  27. package/src/admin/editor/panels/AddPanel.tsx +31 -1
  28. package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
  29. package/src/admin/editor/panels/ClassesSection.tsx +9 -6
  30. package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
  31. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  32. package/src/admin/editor/panels/ElementPanel.tsx +68 -20
  33. package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
  34. package/src/admin/editor/panels/LayersPanel.tsx +10 -6
  35. package/src/admin/editor/panels/LeftPanel.tsx +33 -5
  36. package/src/admin/editor/panels/PageSettings.tsx +4 -0
  37. package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
  38. package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
  39. package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
  40. package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
  41. package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
  42. package/src/admin/editor/panels/settings/EffectsControls.tsx +183 -10
  43. package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
  44. package/src/admin/editor/panels/settings/IconControls.tsx +25 -11
  45. package/src/admin/editor/panels/settings/LengthRow.tsx +63 -19
  46. package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
  47. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +19 -1
  48. package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
  49. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
  50. package/src/admin/editor/panels/settings/StyleRow.tsx +120 -13
  51. package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
  52. package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
  53. package/src/admin/editor/panels/settings/background-mode.ts +14 -11
  54. package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
  55. package/src/admin/editor/panels/settings/box-sides.ts +22 -14
  56. package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
  57. package/src/admin/editor/panels/settings/length-units.ts +68 -4
  58. package/src/admin/editor/panels/settings/query-style.ts +3 -3
  59. package/src/admin/editor/panels/settings/style-sections.ts +52 -10
  60. package/src/admin/editor/panels/style-target.ts +22 -7
  61. package/src/admin/editor/presence.ts +60 -0
  62. package/src/admin/editor/section-templates.ts +26 -4
  63. package/src/admin/editor/store.ts +14 -4
  64. package/src/admin/editor/useCoDesign.ts +177 -0
  65. package/src/admin/editor/useEditorCommands.ts +7 -5
  66. package/src/admin/editor/useExtensions.ts +45 -0
  67. package/src/admin/editor/useNodeActions.ts +18 -7
  68. package/src/admin/editor/useProposals.ts +81 -0
  69. package/src/admin/export-api.ts +221 -0
  70. package/src/admin/index.tsx +6 -1
  71. package/src/admin/languages-api.ts +61 -0
  72. package/src/admin/pages/AgentSetup.tsx +148 -0
  73. package/src/admin/pages/AgentsPage.tsx +9 -26
  74. package/src/admin/pages/CreateDialog.tsx +15 -0
  75. package/src/admin/pages/ExportDialog.tsx +395 -0
  76. package/src/admin/pages/ImportButton.tsx +18 -0
  77. package/src/admin/pages/ImportElementorDialog.tsx +669 -0
  78. package/src/admin/pages/ImportPageLinks.tsx +86 -0
  79. package/src/admin/pages/PageList.tsx +82 -3
  80. package/src/admin/pages/ThemePartList.tsx +52 -2
  81. package/src/admin/pages/bulk.tsx +303 -0
  82. package/src/admin/pages/section-head.tsx +27 -0
  83. package/src/admin/proposals-api.ts +91 -0
  84. package/src/admin/search.ts +20 -0
  85. package/src/admin/theme-api.ts +4 -0
  86. package/src/admin/ui.ts +50 -4
  87. package/src/admin/widgets/CanvasField.tsx +8 -0
  88. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  89. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  90. package/src/admin/widgets/convert-body.ts +73 -2
  91. package/src/astro/content-port.ts +14 -1
  92. package/src/astro/render.ts +6 -6
  93. package/src/astro/resolve-theme.ts +25 -8
  94. package/src/astro/resolve.ts +89 -2
  95. package/src/astro/tabs/runtime.ts +16 -6
  96. package/src/constants.ts +1 -1
  97. package/src/core/a11y/audit.ts +45 -14
  98. package/src/core/arrange.ts +5 -1
  99. package/src/core/bounded-array.ts +31 -0
  100. package/src/core/clipboard.ts +9 -0
  101. package/src/core/contract.ts +305 -0
  102. package/src/core/css/generate.ts +151 -20
  103. package/src/core/css/scope.ts +10 -2
  104. package/src/core/css/trace.ts +47 -13
  105. package/src/core/css-keywords.ts +51 -1
  106. package/src/core/design/cascade.ts +12 -9
  107. package/src/core/design/classes.ts +28 -9
  108. package/src/core/design/devices.ts +89 -13
  109. package/src/core/design/states.ts +5 -3
  110. package/src/core/design/transfer.ts +5 -0
  111. package/src/core/design/variables.ts +31 -5
  112. package/src/core/elements/dynamic-elements.ts +3 -3
  113. package/src/core/elements/index.ts +73 -9
  114. package/src/core/export/runtimes.generated.ts +9 -0
  115. package/src/core/export/site.ts +562 -0
  116. package/src/core/export/zip.ts +95 -0
  117. package/src/core/extensions/define.ts +13 -0
  118. package/src/core/extensions/index.ts +41 -0
  119. package/src/core/extensions/namespace.ts +82 -0
  120. package/src/core/extensions/normalize.ts +141 -0
  121. package/src/core/extensions/placeholder.ts +41 -0
  122. package/src/core/extensions/registry.ts +94 -0
  123. package/src/core/extensions/render-ext.ts +118 -0
  124. package/src/core/extensions/safe-nodes.ts +93 -0
  125. package/src/core/extensions/schema.ts +112 -0
  126. package/src/core/extensions/types.ts +159 -0
  127. package/src/core/forms/binding.ts +1 -1
  128. package/src/core/history/diff.ts +26 -1
  129. package/src/core/import/elementor/atomic.ts +1608 -0
  130. package/src/core/import/elementor/classes.ts +127 -0
  131. package/src/core/import/elementor/context.ts +429 -0
  132. package/src/core/import/elementor/counter-steps.ts +72 -0
  133. package/src/core/import/elementor/css.ts +445 -0
  134. package/src/core/import/elementor/html.ts +500 -0
  135. package/src/core/import/elementor/index.ts +967 -0
  136. package/src/core/import/elementor/inline-marks.ts +81 -0
  137. package/src/core/import/elementor/snapshots.ts +48 -0
  138. package/src/core/import/elementor/style.ts +429 -0
  139. package/src/core/import/elementor/values.ts +241 -0
  140. package/src/core/import/elementor/widgets.ts +1897 -0
  141. package/src/core/index.ts +96 -0
  142. package/src/core/json-schema.ts +114 -0
  143. package/src/core/limits.ts +19 -0
  144. package/src/core/migrate/index.ts +6 -1
  145. package/src/core/migrate/v18.ts +222 -0
  146. package/src/core/perf/meter.ts +42 -24
  147. package/src/core/portable-text-export.ts +243 -0
  148. package/src/core/proposals-safety.ts +102 -0
  149. package/src/core/proposals.ts +357 -0
  150. package/src/core/public-attributes.ts +30 -0
  151. package/src/core/recipes/index.ts +2 -2
  152. package/src/core/render/extras.ts +3 -3
  153. package/src/core/render/index.ts +222 -23
  154. package/src/core/render/loop.ts +1 -1
  155. package/src/core/render/section.ts +4 -4
  156. package/src/core/render/tabs.ts +18 -11
  157. package/src/core/render/vnode.ts +1 -1
  158. package/src/core/sanitize/css.ts +151 -10
  159. package/src/core/sanitize/motion.ts +116 -0
  160. package/src/core/saved-sections.ts +6 -0
  161. package/src/core/schema/descriptors.ts +3 -1
  162. package/src/core/schema/design.ts +4 -3
  163. package/src/core/schema/layout.ts +92 -16
  164. package/src/core/schema/style.ts +296 -112
  165. package/src/core/search-text.ts +70 -0
  166. package/src/core/text-marks.ts +227 -0
  167. package/src/core/theme/dynamic.ts +9 -4
  168. package/src/core/theme/float.ts +2 -0
  169. package/src/core/theme/popup-rules.ts +33 -1
  170. package/src/core/translatable.ts +34 -0
  171. package/src/core/validate.ts +13 -1
  172. package/src/index.ts +24 -0
  173. package/src/mcp/errors.ts +3 -1
  174. package/src/mcp/ports.ts +67 -0
  175. package/src/mcp/prompts.ts +1 -11
  176. package/src/mcp/proposals.ts +281 -0
  177. package/src/mcp/read.ts +10 -10
  178. package/src/mcp/tools.ts +71 -3
  179. package/src/mcp/write.ts +66 -11
  180. package/src/server/agent-settings.ts +5 -1
  181. package/src/server/icon-routes.ts +52 -12
  182. package/src/server/mcp-routes.ts +15 -0
  183. package/src/server/plugin.ts +35 -2
  184. package/src/server/presence.ts +78 -0
  185. package/src/server/proposals.ts +261 -0
  186. package/src/server/requests.ts +196 -0
  187. package/src/server/tools-served.ts +45 -0
@@ -1,9 +1,10 @@
1
1
  import type { DefaultStyleTag, DesignSystem } from "../schema/design.ts";
2
2
  import type { LayoutNode } from "../schema/layout.ts";
3
3
  import type { StyleStateName } from "../schema/state-names.ts";
4
- import type { StyleProps } from "../schema/style.ts";
4
+ import { flattenMotion } from "../migrate/v18.ts";
5
+ import type { FlatStyleProps, OwnStyle, StyleProps } from "../schema/style.ts";
5
6
 
6
- export type TraceDevice = "desktop" | "tablet" | "mobile";
7
+ export type TraceDevice = "wide" | "desktop" | "laptop" | "tablet" | "mobile";
7
8
 
8
9
  /** Where one style value comes from (W-318). */
9
10
  export type StyleSource = {
@@ -38,7 +39,24 @@ export function defaultTagFor(node: LayoutNode): DefaultStyleTag | undefined {
38
39
  }
39
40
  }
40
41
 
41
- const LAYER = { desktop: "Desktop", tablet: "Tablet", mobile: "Mobile" } as const;
42
+ const LAYER = {
43
+ wide: "Wide screen",
44
+ desktop: "Desktop",
45
+ laptop: "Laptop",
46
+ tablet: "Tablet",
47
+ mobile: "Mobile",
48
+ } as const;
49
+
50
+ /** W-959: an own style's Desktop values and its Wide screen ones (without `hidden`), apart. */
51
+ function splitWide(style: OwnStyle | undefined): { desktop?: StyleProps; wide?: StyleProps } {
52
+ if (!style) return {};
53
+ const { wide, ...desktop } = style;
54
+ const { hidden: _hidden, ...values } = wide ?? {};
55
+ return {
56
+ desktop,
57
+ ...(Object.keys(values).length > 0 ? { wide: values } : {}),
58
+ };
59
+ }
42
60
  const STATE_LABEL: Record<StyleStateName, string> = {
43
61
  hover: "Hover",
44
62
  focus: "Focus",
@@ -49,8 +67,9 @@ type Owner = {
49
67
  kind: "class" | "local";
50
68
  label: string;
51
69
  classId?: string;
52
- style?: StyleProps;
53
- devices?: { tablet?: StyleProps; mobile?: StyleProps };
70
+ desktop?: StyleProps;
71
+ wide?: StyleProps;
72
+ devices?: { laptop?: StyleProps; tablet?: StyleProps; mobile?: StyleProps };
54
73
  states?: Partial<Record<StyleStateName, StyleProps>>;
55
74
  };
56
75
 
@@ -65,7 +84,7 @@ export function styleLayers(
65
84
  design: DesignSystem,
66
85
  device: TraceDevice = "desktop",
67
86
  state: StyleStateName | "normal" = "normal",
68
- ): { source: Omit<StyleSource, "value">; style: StyleProps }[] {
87
+ ): { source: Omit<StyleSource, "value">; style: FlatStyleProps }[] {
69
88
  const layers: { source: Omit<StyleSource, "value">; style: StyleProps }[] = [];
70
89
  const tag = defaultTagFor(node);
71
90
  const tagStyle = tag ? design.defaults?.[tag] : undefined;
@@ -83,7 +102,7 @@ export function styleLayers(
83
102
  kind: "class",
84
103
  label: `.${cls.name}`,
85
104
  classId: cls.id,
86
- style: cls.style,
105
+ ...splitWide(cls.style),
87
106
  };
88
107
  if (cls.devices) owner.devices = cls.devices;
89
108
  if (cls.states) owner.states = cls.states;
@@ -92,7 +111,7 @@ export function styleLayers(
92
111
  owners.push({
93
112
  kind: "local",
94
113
  label: "This element",
95
- ...(node.style ? { style: node.style } : {}),
114
+ ...(node.style ? splitWide(node.style) : {}),
96
115
  ...(node.devices ? { devices: node.devices } : {}),
97
116
  ...(node.states ? { states: node.states as Owner["states"] } : {}),
98
117
  });
@@ -102,8 +121,18 @@ export function styleLayers(
102
121
  label: owner.label,
103
122
  ...(owner.classId ? { classId: owner.classId } : {}),
104
123
  };
105
- if (owner.style) layers.push({ source: { ...base, layer: LAYER.desktop }, style: owner.style });
106
- if (device !== "desktop" && owner.devices?.tablet) {
124
+ if (owner.desktop)
125
+ layers.push({ source: { ...base, layer: LAYER.desktop }, style: owner.desktop });
126
+ if (device === "wide" && owner.wide) {
127
+ layers.push({ source: { ...base, layer: LAYER.wide }, style: owner.wide });
128
+ }
129
+ if (
130
+ (device === "laptop" || device === "tablet" || device === "mobile") &&
131
+ owner.devices?.laptop
132
+ ) {
133
+ layers.push({ source: { ...base, layer: LAYER.laptop }, style: owner.devices.laptop });
134
+ }
135
+ if ((device === "tablet" || device === "mobile") && owner.devices?.tablet) {
107
136
  layers.push({ source: { ...base, layer: LAYER.tablet }, style: owner.devices.tablet });
108
137
  }
109
138
  if (device === "mobile" && owner.devices?.mobile) {
@@ -125,7 +154,12 @@ export function styleLayers(
125
154
  });
126
155
  }
127
156
  }
128
- return layers;
157
+ // W-925: traced by the flat motion keys the style rows use.
158
+ const traced: { source: Omit<StyleSource, "value">; style: FlatStyleProps }[] = [];
159
+ for (const { source, style } of layers) {
160
+ traced.push({ source, style: flattenMotion(style) as FlatStyleProps });
161
+ }
162
+ return traced;
129
163
  }
130
164
 
131
165
  /** Where each set property of a node comes from (W-318), by property name. */
@@ -160,10 +194,10 @@ export function inheritedStyle(
160
194
  design: DesignSystem,
161
195
  device: TraceDevice,
162
196
  state: StyleStateName | "normal",
163
- ): StyleProps {
197
+ ): FlatStyleProps {
164
198
  const layers = styleLayers(node, design, device, state);
165
199
  // Drop the layer being edited: the element's own on this device and state.
166
200
  const editing = state !== "normal" ? STATE_LABEL[state] : LAYER[device];
167
201
  const below = layers.filter((l) => !(l.source.kind === "local" && l.source.layer === editing));
168
- return Object.assign({}, ...below.map((l) => l.style)) as StyleProps;
202
+ return Object.assign({}, ...below.map((l) => l.style)) as FlatStyleProps;
169
203
  }
@@ -22,6 +22,9 @@ export const JUSTIFY_CONTENT = [
22
22
 
23
23
  export const ALIGN_ITEMS = ["stretch", "flex-start", "flex-end", "center", "baseline"] as const;
24
24
 
25
+ /** W-954: one child's own cross-axis alignment; `auto` follows the parent's Align. */
26
+ export const ALIGN_SELF = ["auto", ...ALIGN_ITEMS] as const;
27
+
25
28
  export const TEXT_ALIGNS = ["left", "center", "right", "justify"] as const;
26
29
 
27
30
  export const TEXT_TRANSFORMS = ["none", "uppercase", "lowercase", "capitalize"] as const;
@@ -32,6 +35,45 @@ export const BORDER_STYLES = ["none", "solid", "dashed", "dotted"] as const;
32
35
 
33
36
  export const OVERFLOWS = ["visible", "hidden", "clip", "scroll", "auto"] as const;
34
37
 
38
+ /**
39
+ * W-952: how a List marks its items. Number styles make it numbered; `steps` puts each number
40
+ * in a circle (numbered steps).
41
+ */
42
+ export const LIST_MARKERS = [
43
+ "disc",
44
+ "circle",
45
+ "square",
46
+ "decimal",
47
+ "decimal-leading-zero",
48
+ "lower-alpha",
49
+ "upper-alpha",
50
+ "lower-roman",
51
+ "upper-roman",
52
+ "steps",
53
+ "none",
54
+ ] as const;
55
+ export type ListMarker = (typeof LIST_MARKERS)[number];
56
+
57
+ /** List markers that count (the list is an `<ol>`). */
58
+ export const NUMBERED_MARKERS: ReadonlySet<string> = new Set([
59
+ "decimal",
60
+ "decimal-leading-zero",
61
+ "lower-alpha",
62
+ "upper-alpha",
63
+ "lower-roman",
64
+ "upper-roman",
65
+ "steps",
66
+ ]);
67
+
68
+ /** W-957: upright or italic text. */
69
+ export const FONT_STYLES = ["normal", "italic"] as const;
70
+
71
+ /** W-957: how spaces and line breaks wrap. */
72
+ export const WHITE_SPACES = ["normal", "nowrap", "pre-line", "pre-wrap"] as const;
73
+
74
+ /** W-957: whether long words may break to fit. */
75
+ export const OVERFLOW_WRAPS = ["normal", "break-word", "anywhere"] as const;
76
+
35
77
  export const OBJECT_FITS = ["fill", "contain", "cover", "none", "scale-down"] as const;
36
78
 
37
79
  export const POSITIONS = ["static", "relative", "absolute", "fixed", "sticky"] as const;
@@ -64,7 +106,15 @@ export const FONT_WEIGHTS = [
64
106
 
65
107
  export const TRANSITION_EASINGS = ["ease", "ease-in", "ease-out", "ease-in-out", "linear"] as const;
66
108
 
67
- export const TRANSITION_PROPERTIES = ["all", "colors", "opacity", "shadow", "filter"] as const;
109
+ export const TRANSITION_PROPERTIES = [
110
+ "all",
111
+ "colors",
112
+ "opacity",
113
+ "shadow",
114
+ "filter",
115
+ // W-953: the move, scale and rotate of a transform (a hover lift).
116
+ "transform",
117
+ ] as const;
68
118
 
69
119
  export const BACKGROUND_SIZES = ["auto", "cover", "contain"] as const;
70
120
 
@@ -1,10 +1,11 @@
1
- import type { StyleProps } from "../schema/style.ts";
1
+ import { flattenMotion } from "../migrate/v18.ts";
2
+ import type { FlatStyleProps, StyleProps } from "../schema/style.ts";
2
3
 
3
4
  /** Classes the element uses, in Site styles list order. Later entries win, matching the CSS. */
4
5
  export function classStylesInListOrder(
5
- classes: ReadonlyArray<{ id: string; style?: StyleProps }> | undefined,
6
+ classes: ReadonlyArray<{ id: string; style?: StyleProps | FlatStyleProps }> | undefined,
6
7
  appliedIds: readonly string[],
7
- ): Array<StyleProps | undefined> {
8
+ ): Array<StyleProps | FlatStyleProps | undefined> {
8
9
  const applied = new Set(appliedIds);
9
10
  return (classes ?? []).filter((cls) => applied.has(cls.id)).map((cls) => cls.style);
10
11
  }
@@ -13,16 +14,18 @@ export function classStylesInListOrder(
13
14
  * Merge class styles, then local. Later entries win (R-021 / W-030).
14
15
  * Pass classes from `classStylesInListOrder`, not from the order written on the element.
15
16
  * Pure — does not consult CSS; used for editor computed-style tables and unit tests.
17
+ * The result uses the flat motion keys (W-925), so a class's entrance and another's scroll motion
18
+ * both survive, as they do in the CSS.
16
19
  */
17
20
  export function resolveCascade(
18
- classStylesInAppliedOrder: ReadonlyArray<StyleProps | undefined>,
19
- local?: StyleProps,
20
- ): StyleProps {
21
+ classStylesInAppliedOrder: ReadonlyArray<StyleProps | FlatStyleProps | undefined>,
22
+ local?: StyleProps | FlatStyleProps,
23
+ ): FlatStyleProps {
21
24
  const out: Record<string, unknown> = {};
22
25
  for (const style of classStylesInAppliedOrder) {
23
26
  if (!style) continue;
24
- Object.assign(out, style);
27
+ Object.assign(out, flattenMotion(style));
25
28
  }
26
- if (local) Object.assign(out, local);
27
- return out as StyleProps;
29
+ if (local) Object.assign(out, flattenMotion(local));
30
+ return out as FlatStyleProps;
28
31
  }
@@ -1,7 +1,8 @@
1
1
  import { clipText } from "../limits.ts";
2
2
  import type { DesignSystem } from "../schema/design.ts";
3
3
  import type { Layout, LayoutNode } from "../schema/layout.ts";
4
- import type { StyleProps } from "../schema/style.ts";
4
+ import { patchNestedStyle } from "../migrate/v18.ts";
5
+ import type { OwnStyle, StylePatch, StyleProps } from "../schema/style.ts";
5
6
  import { localStyleOf, withLocalStyle } from "../local-style.ts";
6
7
  import { forEachNode, slugify, updateNode } from "../tree-ops.ts";
7
8
 
@@ -81,10 +82,26 @@ const filled = (style: object | undefined) =>
81
82
  !!style && Object.values(style).some((value) => value !== undefined);
82
83
 
83
84
  /** Whether an element has local styles: base, hover/focus/active or tablet/mobile (W-134). */
85
+ /**
86
+ * W-983: an own style split into what moves to a class and the Wide screen hide
87
+ * (`style.wide.hidden`), which is visibility and stays on the element like `hiddenOn`.
88
+ */
89
+ function splitWideHide(style: OwnStyle | undefined): {
90
+ style: OwnStyle | undefined;
91
+ hidden: boolean | undefined;
92
+ } {
93
+ const hidden = style?.wide?.hidden;
94
+ if (!style || hidden === undefined) return { style, hidden: undefined };
95
+ const { wide, ...rest } = style;
96
+ const { hidden: _hidden, ...values } = wide ?? {};
97
+ const next: OwnStyle = Object.keys(values).length > 0 ? { ...rest, wide: values } : rest;
98
+ return { style: Object.keys(next).length > 0 ? next : undefined, hidden };
99
+ }
100
+
84
101
  export function hasLocalStyles(node: LayoutNode): boolean {
85
102
  const local = localStyleOf(node);
86
103
  return (
87
- filled(local.style) ||
104
+ filled(splitWideHide(local.style).style) ||
88
105
  Object.values(local.states ?? {}).some(filled) ||
89
106
  Object.values(local.devices ?? {}).some(filled)
90
107
  );
@@ -119,7 +136,7 @@ export function localToClassRefusal(design: DesignSystem, node: LayoutNode): str
119
136
  /**
120
137
  * Moves an element's local, state and tablet/mobile styles into a new class, applied last on the
121
138
  * element and added last in Site styles, so it wins over the element's other classes as the local
122
- * styles did (W-134). Visibility (`hiddenOn`) stays on the element. Null when it can't run. Pure.
139
+ * styles did (W-134). Visibility (`hiddenOn`, and W-983 the Wide screen hide) stays on the element. Null when it can't run. Pure.
123
140
  */
124
141
  export function localStylesToClass(
125
142
  design: DesignSystem,
@@ -134,14 +151,18 @@ export function localStylesToClass(
134
151
  let id = base;
135
152
  for (let n = 2; taken.has(id); n++) id = `${base}-${n}`;
136
153
  const local = localStyleOf(node);
154
+ const { style: moved, hidden: wideHidden } = splitWideHide(local.style);
137
155
  const cls = {
138
156
  id,
139
157
  name: trimmed,
140
- style: (local.style ?? {}) as StyleProps,
158
+ style: (moved ?? {}) as StyleProps,
141
159
  ...(local.states ? { states: local.states } : {}),
142
160
  ...(local.devices ? { devices: local.devices } : {}),
143
161
  };
144
- const cleared = withLocalStyle(node, local.hiddenOn ? { hiddenOn: local.hiddenOn } : {});
162
+ const cleared = withLocalStyle(node, {
163
+ ...(local.hiddenOn ? { hiddenOn: local.hiddenOn } : {}),
164
+ ...(wideHidden !== undefined ? { style: { wide: { hidden: wideHidden } } } : {}),
165
+ });
145
166
  return {
146
167
  design: { ...design, classes: [...classes, cls] },
147
168
  node: { ...cleared, classes: addClassId(node.classes ?? [], id) },
@@ -230,12 +251,10 @@ export function editClass(
230
251
  export function patchClassStyle(
231
252
  design: DesignSystem,
232
253
  classId: string,
233
- patch: Partial<StyleProps>,
254
+ patch: StylePatch,
234
255
  ): DesignSystem {
235
256
  return editClass(design, classId, (next) => {
236
- const style: Record<string, unknown> = { ...next.style, ...patch };
237
- for (const [key, value] of Object.entries(patch)) if (value === undefined) delete style[key];
238
- next.style = style as StyleProps;
257
+ next.style = patchNestedStyle(next.style, patch) as StyleProps;
239
258
  return next;
240
259
  });
241
260
  }
@@ -1,9 +1,10 @@
1
1
  import type { DesignSystem } from "../schema/design.ts";
2
2
  import { editClass } from "./classes.ts";
3
- import type { DeviceStyles, StyleProps } from "../schema/style.ts";
4
- import { POPUP_DEVICES, type PopupDevice } from "../theme/popup-rules.ts";
3
+ import { patchNestedStyle } from "../migrate/v18.ts";
4
+ import type { DeviceStyles, OwnStyle, StylePatch, StyleProps, WideStyle } from "../schema/style.ts";
5
+ import { DEVICES, type Device, type EditorDevice, type StyleDevice } from "../theme/popup-rules.ts";
5
6
 
6
- export type ResponsiveDevice = "tablet" | "mobile";
7
+ export type ResponsiveDevice = StyleDevice;
7
8
 
8
9
  /**
9
10
  * Merge `patch` into one device's overrides (W-096). `undefined` clears a key. An emptied device
@@ -12,14 +13,13 @@ export type ResponsiveDevice = "tablet" | "mobile";
12
13
  export function patchDeviceStyle(
13
14
  devices: DeviceStyles | undefined,
14
15
  device: ResponsiveDevice,
15
- patch: Partial<StyleProps>,
16
+ patch: StylePatch,
16
17
  ): DeviceStyles | undefined {
17
- const merged: Record<string, unknown> = { ...devices?.[device], ...patch };
18
- for (const key of Object.keys(merged)) if (merged[key] === undefined) delete merged[key];
18
+ const merged = patchNestedStyle(devices?.[device], patch);
19
19
  const next: DeviceStyles = { ...devices };
20
20
  if (Object.keys(merged).length > 0) next[device] = merged as StyleProps;
21
21
  else delete next[device];
22
- return next.tablet || next.mobile ? next : undefined;
22
+ return next.laptop || next.tablet || next.mobile ? next : undefined;
23
23
  }
24
24
 
25
25
  /** `patchDeviceStyle` on a design class. Pure. */
@@ -27,7 +27,7 @@ export function patchClassDevices(
27
27
  design: DesignSystem,
28
28
  classId: string,
29
29
  device: ResponsiveDevice,
30
- patch: Partial<StyleProps>,
30
+ patch: StylePatch,
31
31
  ): DesignSystem {
32
32
  return editClass(design, classId, (next) => {
33
33
  const devices = patchDeviceStyle(next.devices, device, patch);
@@ -37,14 +37,90 @@ export function patchClassDevices(
37
37
  });
38
38
  }
39
39
 
40
- /** Add or remove one device. The result stays in desktop, tablet, mobile order, or undefined. */
40
+ /** Add or remove one device. The result stays in desktop, laptop, tablet, mobile order, or undefined. */
41
41
  export function toggleHidden(
42
- hidden: readonly PopupDevice[] | undefined,
43
- device: PopupDevice,
44
- ): PopupDevice[] | undefined {
42
+ hidden: readonly Device[] | undefined,
43
+ device: Device,
44
+ ): Device[] | undefined {
45
45
  const set = new Set(hidden ?? []);
46
46
  if (set.has(device)) set.delete(device);
47
47
  else set.add(device);
48
- const next = POPUP_DEVICES.filter((item) => set.has(item));
48
+ const next = DEVICES.filter((item) => set.has(item));
49
49
  return next.length > 0 ? next : undefined;
50
50
  }
51
+
52
+ /**
53
+ * W-959: merge `patch` into an own style's Wide screen record (`style.wide`), keeping its
54
+ * `hidden`. An emptied record is dropped. Pure.
55
+ */
56
+ export function patchWideStyle<T extends OwnStyle | undefined>(
57
+ style: T,
58
+ patch: StylePatch,
59
+ ): OwnStyle | undefined {
60
+ const { wide, ...desktop } = style ?? {};
61
+ const { hidden, ...values } = wide ?? {};
62
+ const merged = patchNestedStyle(values, patch) as StyleProps;
63
+ const nextWide: WideStyle = { ...merged, ...(hidden === undefined ? {} : { hidden }) };
64
+ const next: OwnStyle =
65
+ Object.keys(nextWide).length > 0 ? { ...desktop, wide: nextWide } : desktop;
66
+ return Object.keys(next).length > 0 ? next : undefined;
67
+ }
68
+
69
+ /** `patchWideStyle` on a design class. Pure. */
70
+ export function patchClassWide(
71
+ design: DesignSystem,
72
+ classId: string,
73
+ patch: StylePatch,
74
+ ): DesignSystem {
75
+ return editClass(design, classId, (next) => {
76
+ next.style = patchWideStyle(next.style, patch) ?? {};
77
+ return next;
78
+ });
79
+ }
80
+
81
+ /** An element or class whose hide can be read and toggled per device. */
82
+ type Hideable = { hiddenOn?: readonly Device[] | undefined; style?: OwnStyle | undefined };
83
+
84
+ /** Whether it is hidden on `device`. Wide screen follows Desktop unless `wide.hidden` is set. */
85
+ export function hiddenOnDevice(owner: Hideable, device: EditorDevice): boolean {
86
+ if (device === "wide") return owner.style?.wide?.hidden ?? !!owner.hiddenOn?.includes("desktop");
87
+ return !!owner.hiddenOn?.includes(device);
88
+ }
89
+
90
+ /**
91
+ * W-959: hide or show on one device, Wide screen included. Wide screen follows Desktop until it is
92
+ * set on its own: toggling Desktop never touches `wide.hidden`, so hiding on Desktop hides on wide
93
+ * screens too. Toggling Wide screen stores its choice, and drops it when it matches Desktop again
94
+ * (back to following Desktop). Returns the new `hiddenOn` and `style` (either may be undefined).
95
+ * Pure.
96
+ */
97
+ export function toggleHiddenOn(
98
+ owner: Hideable,
99
+ device: EditorDevice,
100
+ ): { hiddenOn: Device[] | undefined; style: OwnStyle | undefined } {
101
+ if (device !== "wide")
102
+ return { hiddenOn: toggleHidden(owner.hiddenOn, device), style: owner.style };
103
+ const desktop = !!owner.hiddenOn?.includes("desktop");
104
+ const wide = !hiddenOnDevice(owner, "wide");
105
+ const { wide: oldWide, ...rest } = owner.style ?? {};
106
+ const { hidden: _old, ...values } = oldWide ?? {};
107
+ const nextWide: WideStyle = { ...values, ...(wide === desktop ? {} : { hidden: wide }) };
108
+ const style: OwnStyle = Object.keys(nextWide).length > 0 ? { ...rest, wide: nextWide } : rest;
109
+ return {
110
+ hiddenOn: owner.hiddenOn && owner.hiddenOn.length > 0 ? [...owner.hiddenOn] : undefined,
111
+ style: Object.keys(style).length > 0 ? style : undefined,
112
+ };
113
+ }
114
+
115
+ /** W-959: whether Wide screen's hide is its own choice, or still follows Desktop. */
116
+ export const wideHideIsOwn = (owner: Hideable): boolean => owner.style?.wide?.hidden !== undefined;
117
+
118
+ /**
119
+ * Hidden on every device, so it never shows (W-409, W-413, W-500). W-959: an element hidden on
120
+ * all four that Wide screen shows again (`wide.hidden: false`) still shows on wide screens. Reads
121
+ * a stored node (`style.wide.hidden`) or a rendered one (`wideHidden`).
122
+ */
123
+ export function hiddenOnEveryDevice(owner: Hideable & { wideHidden?: boolean }): boolean {
124
+ if (!DEVICES.every((device) => owner.hiddenOn?.includes(device))) return false;
125
+ return (owner.wideHidden ?? owner.style?.wide?.hidden) !== false;
126
+ }
@@ -1,7 +1,7 @@
1
1
  import type { DesignSystem } from "../schema/design.ts";
2
2
  import { editClass } from "./classes.ts";
3
3
  import { STYLE_STATES, type StyleStateName } from "../schema/state-names.ts";
4
- import type { StyleProps, StyleStates } from "../schema/style.ts";
4
+ import type { StylePatch, StyleStates } from "../schema/style.ts";
5
5
 
6
6
  type StateStyle = NonNullable<StyleStates[StyleStateName]>;
7
7
 
@@ -12,11 +12,13 @@ type StateStyle = NonNullable<StyleStates[StyleStateName]>;
12
12
  export function patchStates(
13
13
  states: StyleStates | undefined,
14
14
  state: StyleStateName,
15
- patch: Partial<StyleProps>,
15
+ patch: StylePatch,
16
16
  ): StyleStates | undefined {
17
17
  const merged: Record<string, unknown> = { ...states?.[state], ...patch };
18
18
  for (const key of Object.keys(merged)) if (merged[key] === undefined) delete merged[key];
19
+ // Motion is not a state style; the flat `transition` key is the one the editor sends.
19
20
  delete merged["transition"];
21
+ delete merged["motion"];
20
22
  const next: StyleStates = { ...states };
21
23
  if (Object.keys(merged).length > 0) next[state] = merged as StateStyle;
22
24
  else delete next[state];
@@ -32,7 +34,7 @@ export function patchClassState(
32
34
  design: DesignSystem,
33
35
  classId: string,
34
36
  state: StyleStateName,
35
- patch: Partial<StyleProps>,
37
+ patch: StylePatch,
36
38
  ): DesignSystem {
37
39
  return editClass(design, classId, (next) => {
38
40
  const states = patchStates(next.states, state, patch);
@@ -1,6 +1,7 @@
1
1
  import { clipText, MAX_DESIGN_BYTES } from "../limits.ts";
2
2
  import { DesignSystem as DesignSystemSchema, DESIGN_SCHEMA_VERSION } from "../schema/design.ts";
3
3
  import type { DesignSystem } from "../schema/design.ts";
4
+ import { restoreExtras, splitDesignExtras } from "../contract.ts";
4
5
  import { DESIGN_MIGRATIONS, upgradeLayout } from "../migrate/index.ts";
5
6
  import type { Layout } from "../schema/layout.ts";
6
7
  import { findClassUsages, nameKey } from "./classes.ts";
@@ -100,8 +101,12 @@ export function designFromJson(text: string): DesignImport {
100
101
  : "That file is not an EmVB design document.",
101
102
  };
102
103
  }
104
+ const extras = splitDesignExtras(upgraded.doc);
105
+ if (extras.issues.length > 0)
106
+ return { ok: false, message: "That file is not an EmVB design document." };
103
107
  const result = DesignSystemSchema.safeParse(upgraded.doc);
104
108
  if (!result.success) return { ok: false, message: "That file is not an EmVB design document." };
109
+ restoreExtras(result.data, extras.extras);
105
110
  // W-619: every reference points at an id, so two classes (or two variables of one kind) with
106
111
  // the same id can't both be kept; the editor never writes such a file.
107
112
  const repeated = repeatedId(result.data);
@@ -33,7 +33,7 @@ export function refMatchesKind(ref: VariableRefLike, kind: VariableKind): boolea
33
33
  const matches = (value: unknown, id: string, kind: VariableKind | undefined) =>
34
34
  isVariableRef(value) && value.var === id && (kind === undefined || refMatchesKind(value, kind));
35
35
 
36
- const NESTED_COLOR_KEYS = new Set(["boxShadow", "iconShadow", "gradient", "overlay"]);
36
+ const NESTED_COLOR_KEYS = new Set(["boxShadow", "iconShadow", "gradient", "overlay", "wide"]);
37
37
 
38
38
  /** Every value that can be a variable, including nested colours (W-356). */
39
39
  export function forEachStyleRef(
@@ -50,7 +50,16 @@ export function forEachStyleRef(
50
50
  style.gradient?.stops.forEach((stop, index) => {
51
51
  visit(stop.color, `gradient.stops.${index}`);
52
52
  });
53
- if (style.overlay) visit(style.overlay.color, "overlay.color");
53
+ const overlay = style.overlay;
54
+ if (overlay && "color" in overlay) visit(overlay.color, "overlay.color");
55
+ if (overlay && "gradient" in overlay) {
56
+ overlay.gradient.stops.forEach((stop, index) => {
57
+ visit(stop.color, `overlay.gradient.stops.${index}`);
58
+ });
59
+ }
60
+ // W-959: an own style's Wide screen values use variables too.
61
+ const wide = (style as { wide?: StyleProps }).wide;
62
+ if (wide) forEachStyleRef(wide, (value, path) => visit(value, `wide.${path}`));
54
63
  }
55
64
 
56
65
  function collectStyleUsages(
@@ -64,7 +73,7 @@ function collectStyleUsages(
64
73
  });
65
74
  }
66
75
 
67
- const RESPONSIVE = ["tablet", "mobile"] as const;
76
+ const RESPONSIVE = ["laptop", "tablet", "mobile"] as const;
68
77
 
69
78
  /** Style, state styles and device overrides. A nested usage is `<state|device>.<prop>`. */
70
79
  function collectAllUsages(
@@ -150,10 +159,27 @@ function stripRefsFromStyle(
150
159
  delete next["gradient"];
151
160
  changed = true;
152
161
  }
153
- if (style.overlay && matches(style.overlay.color, id, kind)) {
162
+ // W-949: a gradient overlay goes with any of its stops, as a gradient does.
163
+ const overlay = style.overlay;
164
+ if (
165
+ overlay &&
166
+ ("color" in overlay
167
+ ? matches(overlay.color, id, kind)
168
+ : overlay.gradient.stops.some((stop) => matches(stop.color, id, kind)))
169
+ ) {
154
170
  delete next["overlay"];
155
171
  changed = true;
156
172
  }
173
+ // W-959: and in the own style's Wide screen values (`hidden` stays when they all go).
174
+ const wide = (style as { wide?: StyleProps & { hidden?: boolean } }).wide;
175
+ if (wide) {
176
+ const stripped = stripRefsFromStyle(wide, id, kind);
177
+ if (stripped !== wide) {
178
+ changed = true;
179
+ if (stripped) next["wide"] = stripped;
180
+ else delete next["wide"];
181
+ }
182
+ }
157
183
  if (!changed) return style;
158
184
  return Object.keys(next).length === 0 ? undefined : (next as StyleProps);
159
185
  }
@@ -194,7 +220,7 @@ function stripRefsFromDevices(
194
220
  else delete next[device];
195
221
  }
196
222
  if (!changed) return devices;
197
- return next.tablet || next.mobile ? next : undefined;
223
+ return next.laptop || next.tablet || next.mobile ? next : undefined;
198
224
  }
199
225
 
200
226
  /** Style, states and device overrides with the refs removed. Same object when nothing changed. */
@@ -248,7 +248,7 @@ export const loop: ElementDefinition<LoopNode> = {
248
248
  "field=value pairs separated by semicolons, such as category=news; team=design. A taxonomy works too. The same field twice matches either value.",
249
249
  },
250
250
  {
251
- key: "itemPartId",
251
+ key: "partId",
252
252
  kind: "text",
253
253
  label: "Loop item",
254
254
  optional: true,
@@ -380,9 +380,9 @@ export const pagination: ElementDefinition<PaginationNode> = {
380
380
 
381
381
  export const section: ElementDefinition<SectionNode> = {
382
382
  baseCss: ".emvb-section{display:flex;flex-direction:column;min-width:0}",
383
- defaults: () => ({ type: "section", props: {}, children: [] }),
383
+ defaults: () => ({ type: "part-ref", props: {}, children: [] }),
384
384
  descriptor: {
385
- type: "section",
385
+ type: "part-ref",
386
386
  // "Theme section": it embeds a Section theme part; the layout Section is its own element (W-155).
387
387
  name: "Theme section",
388
388
  group: "layout",