@perkyzz/emvb 0.8.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 (179) hide show
  1. package/README.md +3 -3
  2. package/package.json +4 -4
  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 +325 -239
  6. package/src/admin/editor/FieldPreview.tsx +164 -0
  7. package/src/admin/editor/Timeline.tsx +2 -1
  8. package/src/admin/editor/TopBar.tsx +36 -3
  9. package/src/admin/editor/canvas/CanvasFrame.tsx +2 -2
  10. package/src/admin/editor/canvas/DeviceBar.tsx +17 -9
  11. package/src/admin/editor/canvas/canvas-scale.ts +2 -2
  12. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  13. package/src/admin/editor/co-design.ts +190 -0
  14. package/src/admin/editor/dnd/new-element.ts +26 -4
  15. package/src/admin/editor/editor-chrome.tsx +3 -3
  16. package/src/admin/editor/editor-commands.ts +8 -3
  17. package/src/admin/editor/editor-css.ts +3 -0
  18. package/src/admin/editor/element-chrome.ts +3 -1
  19. package/src/admin/editor/extension-manifests.ts +20 -0
  20. package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
  21. package/src/admin/editor/extensions-context.tsx +27 -0
  22. package/src/admin/editor/feature-css.ts +17 -0
  23. package/src/admin/editor/host.ts +6 -0
  24. package/src/admin/editor/palette-items.ts +2 -2
  25. package/src/admin/editor/panels/AddPanel.tsx +31 -1
  26. package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
  27. package/src/admin/editor/panels/ClassesSection.tsx +9 -6
  28. package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
  29. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  30. package/src/admin/editor/panels/ElementPanel.tsx +53 -15
  31. package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
  32. package/src/admin/editor/panels/LayersPanel.tsx +10 -6
  33. package/src/admin/editor/panels/LeftPanel.tsx +33 -5
  34. package/src/admin/editor/panels/PageSettings.tsx +4 -0
  35. package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
  36. package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
  37. package/src/admin/editor/panels/settings/BackgroundControls.tsx +76 -20
  38. package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
  39. package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
  40. package/src/admin/editor/panels/settings/EffectsControls.tsx +104 -9
  41. package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
  42. package/src/admin/editor/panels/settings/IconControls.tsx +14 -11
  43. package/src/admin/editor/panels/settings/LengthRow.tsx +27 -16
  44. package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
  45. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
  46. package/src/admin/editor/panels/settings/MediaPicker.tsx +5 -5
  47. package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
  48. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
  49. package/src/admin/editor/panels/settings/StyleRow.tsx +113 -13
  50. package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
  51. package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
  52. package/src/admin/editor/panels/settings/background-mode.ts +14 -11
  53. package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
  54. package/src/admin/editor/panels/settings/box-sides.ts +22 -14
  55. package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
  56. package/src/admin/editor/panels/settings/length-units.ts +55 -2
  57. package/src/admin/editor/panels/settings/query-style.ts +3 -3
  58. package/src/admin/editor/panels/settings/style-sections.ts +51 -10
  59. package/src/admin/editor/panels/style-target.ts +9 -7
  60. package/src/admin/editor/presence.ts +60 -0
  61. package/src/admin/editor/store.ts +6 -2
  62. package/src/admin/editor/useCoDesign.ts +177 -0
  63. package/src/admin/editor/useEditorCommands.ts +4 -4
  64. package/src/admin/editor/useExtensions.ts +45 -0
  65. package/src/admin/editor/useNodeActions.ts +15 -6
  66. package/src/admin/editor/useProposals.ts +81 -0
  67. package/src/admin/index.tsx +5 -1
  68. package/src/admin/languages-api.ts +61 -0
  69. package/src/admin/media-api.ts +27 -0
  70. package/src/admin/pages/AgentSetup.tsx +148 -0
  71. package/src/admin/pages/AgentsPage.tsx +11 -28
  72. package/src/admin/pages/CollectionsPage.tsx +215 -0
  73. package/src/admin/pages/CreateDialog.tsx +15 -0
  74. package/src/admin/pages/ImportButton.tsx +18 -0
  75. package/src/admin/pages/ImportElementorDialog.tsx +669 -0
  76. package/src/admin/pages/ImportPageLinks.tsx +86 -0
  77. package/src/admin/pages/PageList.tsx +15 -1
  78. package/src/admin/pages/ThemePartList.tsx +15 -1
  79. package/src/admin/pages/section-head.tsx +27 -0
  80. package/src/admin/proposals-api.ts +91 -0
  81. package/src/admin/setup/host-collections.ts +100 -0
  82. package/src/admin/ui.ts +39 -2
  83. package/src/admin/widgets/CanvasField.tsx +202 -0
  84. package/src/admin/widgets/convert-body.ts +54 -0
  85. package/src/admin/widgets/field-fetcher.ts +79 -0
  86. package/src/astro/content-port.ts +14 -1
  87. package/src/astro/index.ts +2 -0
  88. package/src/astro/page-count.ts +77 -0
  89. package/src/astro/resolve-theme.ts +58 -3
  90. package/src/astro/resolve.ts +128 -5
  91. package/src/astro/responsive-images.ts +99 -0
  92. package/src/constants.ts +1 -1
  93. package/src/core/a11y/audit.ts +44 -14
  94. package/src/core/arrange.ts +5 -1
  95. package/src/core/bounded-array.ts +31 -0
  96. package/src/core/canvas-collections.ts +20 -0
  97. package/src/core/clipboard.ts +9 -0
  98. package/src/core/contract.ts +285 -0
  99. package/src/core/css/generate.ts +89 -20
  100. package/src/core/css/trace.ts +18 -9
  101. package/src/core/css-keywords.ts +51 -1
  102. package/src/core/design/cascade.ts +12 -9
  103. package/src/core/design/classes.ts +4 -5
  104. package/src/core/design/devices.ts +13 -13
  105. package/src/core/design/states.ts +5 -3
  106. package/src/core/design/transfer.ts +5 -0
  107. package/src/core/design/variables.ts +17 -4
  108. package/src/core/elements/dynamic-elements.ts +19 -4
  109. package/src/core/elements/index.ts +73 -9
  110. package/src/core/extensions/define.ts +13 -0
  111. package/src/core/extensions/index.ts +41 -0
  112. package/src/core/extensions/namespace.ts +82 -0
  113. package/src/core/extensions/normalize.ts +141 -0
  114. package/src/core/extensions/placeholder.ts +41 -0
  115. package/src/core/extensions/registry.ts +94 -0
  116. package/src/core/extensions/render-ext.ts +118 -0
  117. package/src/core/extensions/safe-nodes.ts +93 -0
  118. package/src/core/extensions/schema.ts +112 -0
  119. package/src/core/extensions/types.ts +159 -0
  120. package/src/core/forms/binding.ts +1 -1
  121. package/src/core/history/diff.ts +1 -1
  122. package/src/core/import/elementor/atomic.ts +1595 -0
  123. package/src/core/import/elementor/classes.ts +127 -0
  124. package/src/core/import/elementor/context.ts +429 -0
  125. package/src/core/import/elementor/counter-steps.ts +72 -0
  126. package/src/core/import/elementor/css.ts +445 -0
  127. package/src/core/import/elementor/html.ts +500 -0
  128. package/src/core/import/elementor/index.ts +949 -0
  129. package/src/core/import/elementor/inline-marks.ts +81 -0
  130. package/src/core/import/elementor/snapshots.ts +48 -0
  131. package/src/core/import/elementor/style.ts +409 -0
  132. package/src/core/import/elementor/values.ts +241 -0
  133. package/src/core/import/elementor/widgets.ts +1897 -0
  134. package/src/core/index.ts +84 -0
  135. package/src/core/json-schema.ts +107 -0
  136. package/src/core/limits.ts +19 -0
  137. package/src/core/migrate/index.ts +6 -1
  138. package/src/core/migrate/v18.ts +222 -0
  139. package/src/core/perf/meter.ts +5 -5
  140. package/src/core/portable-text.ts +127 -0
  141. package/src/core/proposals-safety.ts +102 -0
  142. package/src/core/proposals.ts +357 -0
  143. package/src/core/recipes/index.ts +2 -2
  144. package/src/core/render/extras.ts +3 -3
  145. package/src/core/render/index.ts +140 -20
  146. package/src/core/render/loop.ts +1 -1
  147. package/src/core/render/pagination.ts +20 -1
  148. package/src/core/render/section.ts +4 -4
  149. package/src/core/render/vnode.ts +1 -1
  150. package/src/core/sanitize/css.ts +125 -10
  151. package/src/core/sanitize/motion.ts +116 -0
  152. package/src/core/saved-sections.ts +6 -0
  153. package/src/core/schema/descriptors.ts +3 -1
  154. package/src/core/schema/design.ts +2 -1
  155. package/src/core/schema/layout.ts +87 -14
  156. package/src/core/schema/style.ts +251 -114
  157. package/src/core/text-marks.ts +227 -0
  158. package/src/core/theme/dynamic.ts +9 -4
  159. package/src/core/theme/float.ts +1 -0
  160. package/src/core/theme/pagination.ts +9 -0
  161. package/src/core/theme/popup-rules.ts +17 -1
  162. package/src/core/translatable.ts +34 -0
  163. package/src/core/validate.ts +13 -1
  164. package/src/index.ts +35 -1
  165. package/src/mcp/errors.ts +3 -1
  166. package/src/mcp/ports.ts +67 -0
  167. package/src/mcp/prompts.ts +1 -11
  168. package/src/mcp/proposals.ts +281 -0
  169. package/src/mcp/read.ts +10 -9
  170. package/src/mcp/tools.ts +71 -3
  171. package/src/mcp/write.ts +66 -11
  172. package/src/server/agent-settings.ts +21 -2
  173. package/src/server/hooks.ts +81 -0
  174. package/src/server/mcp-routes.ts +15 -0
  175. package/src/server/plugin.ts +53 -5
  176. package/src/server/presence.ts +78 -0
  177. package/src/server/proposals.ts +261 -0
  178. package/src/server/requests.ts +196 -0
  179. package/src/server/tools-served.ts +45 -0
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  ALIGN_ITEMS,
3
+ ALIGN_SELF,
3
4
  BACKGROUND_POSITIONS,
4
5
  BACKGROUND_REPEATS,
5
6
  BACKGROUND_SIZES,
@@ -7,22 +8,26 @@ import {
7
8
  CURSORS,
8
9
  FLEX_DIRECTIONS as FLEX_DIRECTION_VALUES,
9
10
  FLEX_WRAPS as FLEX_WRAP_VALUES,
11
+ FONT_STYLES,
10
12
  FONT_WEIGHTS,
11
13
  HEX_COLOR,
12
14
  JUSTIFY_CONTENT,
13
15
  LENGTH_UNITS,
14
16
  OBJECT_FITS,
17
+ OVERFLOW_WRAPS,
15
18
  OVERFLOWS,
16
19
  POSITIONS,
17
20
  TEXT_ALIGNS,
18
21
  TEXT_DECORATIONS,
19
22
  TEXT_TRANSFORMS,
23
+ WHITE_SPACES,
20
24
  TRANSITION_EASINGS as TRANSITION_EASING_VALUES,
21
25
  } from "../css-keywords.ts";
22
26
  import { STYLE_STATES, type StyleStateName } from "../schema/state-names.ts";
23
- import type { StyleProps } from "../schema/style.ts";
27
+ import type { FlatStyleProps } from "../schema/style.ts";
28
+ import { fluidClamp } from "../design/tokens.ts";
24
29
  import { sanitizeMediaUrl } from "./media-url.ts";
25
- import { motionDeclarations, withMotion } from "./motion.ts";
30
+ import { loopDeclarations, motionDeclarations, withLoop, withMotion } from "./motion.ts";
26
31
  import { isRecord } from "../record.ts";
27
32
  import { iconAnimationRuns } from "../icons/animation-runs.ts";
28
33
 
@@ -38,6 +43,10 @@ const TEXT_DECORATION = setOf(TEXT_DECORATIONS);
38
43
  const BORDER_STYLE = setOf(BORDER_STYLES);
39
44
  const OVERFLOW = setOf(OVERFLOWS);
40
45
  const OBJECT_FIT = setOf(OBJECT_FITS);
46
+ const ALIGN_SELF_SET = setOf(ALIGN_SELF);
47
+ const FONT_STYLE = setOf(FONT_STYLES);
48
+ const WHITE_SPACE = setOf(WHITE_SPACES);
49
+ const OVERFLOW_WRAP = setOf(OVERFLOW_WRAPS);
41
50
  const POSITION = setOf(POSITIONS);
42
51
  const CURSOR = setOf(CURSORS);
43
52
  const ASPECT_RATIO = /^([1-9]\d{0,3})\/([1-9]\d{0,3})$/;
@@ -132,6 +141,7 @@ function cssFontFamily(value: unknown): string | undefined {
132
141
 
133
142
  export function cssLength(value: unknown): string | undefined {
134
143
  if (typeof value !== "object" || value === null) return undefined;
144
+ if ("fluid" in value) return cssFluid((value as { fluid: unknown }).fluid);
135
145
  const ref = refOf(value);
136
146
  if (ref) {
137
147
  if (ref.from === "fontSize") {
@@ -150,6 +160,19 @@ export function cssLength(value: unknown): string | undefined {
150
160
  return `${n}${unit}`;
151
161
  }
152
162
 
163
+ /**
164
+ * W-955: `{ min, max }` px as a `clamp()` that grows between 360 and 1280 px wide screens. Both
165
+ * are checked here as well as by the schema, so a stored page can't emit anything else.
166
+ */
167
+ function cssFluid(fluid: unknown): string | undefined {
168
+ if (!isRecord(fluid)) return undefined;
169
+ const { min, max } = fluid;
170
+ return fluidPx(min) && fluidPx(max) ? fluidClamp(min, max) : undefined;
171
+ }
172
+
173
+ const fluidPx = (n: unknown): n is number =>
174
+ typeof n === "number" && Number.isFinite(n) && n >= 0 && n <= 10_000;
175
+
153
176
  /** A length, or `auto` where the property allows it (W-088). */
154
177
  const cssLengthOrAuto = (value: unknown): string | undefined =>
155
178
  value === "auto" ? "auto" : cssLength(value);
@@ -157,7 +180,8 @@ const cssLengthOrAuto = (value: unknown): string | undefined =>
157
180
  /** An offset: `auto`, a variable, or a length from -10000 to 10000 (W-088). */
158
181
  function cssOffset(value: unknown): string | undefined {
159
182
  if (value === "auto") return "auto";
160
- if (typeof value !== "object" || value === null || "var" in value) return cssLength(value);
183
+ if (typeof value !== "object" || value === null || "var" in value || "fluid" in value)
184
+ return cssLength(value);
161
185
  const { value: n, unit } = value as { value?: unknown; unit?: unknown };
162
186
  if (typeof n !== "number" || !Number.isFinite(n) || n < -10_000 || n > 10_000) return undefined;
163
187
  if (typeof unit !== "string" || !UNITS.has(unit)) return undefined;
@@ -169,6 +193,17 @@ const cssZIndex = (value: unknown): string | undefined =>
169
193
  ? String(value)
170
194
  : undefined;
171
195
 
196
+ /** W-954: a grow or shrink factor, 0–100. */
197
+ const cssFlexFactor = (value: unknown): string | undefined =>
198
+ typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 100
199
+ ? String(value)
200
+ : undefined;
201
+
202
+ const cssOrder = (value: unknown): string | undefined =>
203
+ Number.isInteger(value) && (value as number) >= -99 && (value as number) <= 99
204
+ ? String(value)
205
+ : undefined;
206
+
172
207
  const ENTRANCES = new Set(["fade", "fade-up", "fade-down", "slide-up", "slide-down", "scale"]);
173
208
 
174
209
  /** `emvb-<type> <ms> ease-out [delay] both`. A bad trigger drops the whole entrance. */
@@ -317,6 +352,7 @@ const TRANSITION_PROPERTIES: Readonly<Record<string, readonly string[]>> = {
317
352
  opacity: ["opacity"],
318
353
  shadow: ["box-shadow"],
319
354
  filter: ["filter"],
355
+ transform: ["translate", "scale", "rotate"],
320
356
  };
321
357
  const TRANSITION_KEYS = new Set(["duration", "delay", "easing", "property"]);
322
358
 
@@ -440,7 +476,11 @@ function cssAngle(value: unknown, fallback: number): number | undefined {
440
476
  return angle as number;
441
477
  }
442
478
 
443
- function cssGradient(value: unknown): string | undefined {
479
+ function cssGradient(
480
+ value: unknown,
481
+ /** W-949: a gradient overlay fades every stop by its opacity. */
482
+ paint: (color: string) => string | undefined = (color) => color,
483
+ ): string | undefined {
444
484
  if (!isRecord(value)) return undefined;
445
485
  if (
446
486
  Object.keys(value).some(
@@ -455,7 +495,8 @@ function cssGradient(value: unknown): string | undefined {
455
495
  for (const stop of stops) {
456
496
  if (!isRecord(stop) || Object.keys(stop).some((key) => key !== "color" && key !== "at"))
457
497
  return undefined;
458
- const color = cssColor(stop["color"]);
498
+ const base = cssColor(stop["color"]);
499
+ const color = base ? paint(base) : undefined;
459
500
  const at = stop["at"];
460
501
  if (!color || !Number.isInteger(at) || (at as number) < 0 || (at as number) > 100)
461
502
  return undefined;
@@ -502,6 +543,14 @@ function overlayPaint(color: string, opacity: number): string | undefined {
502
543
 
503
544
  function cssOverlay(value: unknown): string | undefined {
504
545
  if (!isRecord(value)) return undefined;
546
+ if ("gradient" in value) {
547
+ // W-949: a gradient overlay; `opacity` (default 1) fades each stop.
548
+ if (Object.keys(value).some((key) => key !== "gradient" && key !== "opacity")) return undefined;
549
+ const opacity = value["opacity"] === undefined ? 1 : value["opacity"];
550
+ if (typeof opacity !== "number" || !Number.isFinite(opacity) || opacity < 0 || opacity > 1)
551
+ return undefined;
552
+ return cssGradient(value["gradient"], (color) => overlayPaint(color, opacity));
553
+ }
505
554
  if (Object.keys(value).some((key) => key !== "color" && key !== "opacity")) return undefined;
506
555
  const color = cssColor(value["color"]);
507
556
  const opacity = value["opacity"];
@@ -590,7 +639,10 @@ function composeBackground(style: Record<string, unknown>): {
590
639
  }
591
640
 
592
641
  const PROPERTY_MAP: {
593
- [K in keyof Required<StyleProps>]: { css: string; toValue: (v: unknown) => string | undefined };
642
+ [K in keyof Required<FlatStyleProps>]: {
643
+ css: string;
644
+ toValue: (v: unknown) => string | undefined;
645
+ };
594
646
  } = {
595
647
  flexDirection: { css: "flex-direction", toValue: cssFlexDirection },
596
648
  flexWrap: { css: "flex-wrap", toValue: keyword(FLEX_WRAPS) },
@@ -609,8 +661,11 @@ const PROPERTY_MAP: {
609
661
  minHeight: { css: "min-height", toValue: cssLength },
610
662
  maxHeight: { css: "max-height", toValue: cssLength },
611
663
  overflow: { css: "overflow", toValue: keyword(OVERFLOW) },
664
+ overflowX: { css: "overflow-x", toValue: keyword(OVERFLOW) },
665
+ overflowY: { css: "overflow-y", toValue: keyword(OVERFLOW) },
612
666
  aspectRatio: { css: "aspect-ratio", toValue: cssAspectRatio },
613
667
  objectFit: { css: "object-fit", toValue: keyword(OBJECT_FIT) },
668
+ objectPosition: { css: "object-position", toValue: keyword(BACKGROUND_POSITION) },
614
669
  paddingTop: { css: "padding-top", toValue: cssLength },
615
670
  paddingRight: { css: "padding-inline-end", toValue: cssLength },
616
671
  paddingBottom: { css: "padding-bottom", toValue: cssLength },
@@ -625,6 +680,11 @@ const PROPERTY_MAP: {
625
680
  bottom: { css: "bottom", toValue: cssOffset },
626
681
  left: { css: "inset-inline-start", toValue: cssOffset },
627
682
  zIndex: { css: "z-index", toValue: cssZIndex },
683
+ flexGrow: { css: "flex-grow", toValue: cssFlexFactor },
684
+ flexShrink: { css: "flex-shrink", toValue: cssFlexFactor },
685
+ flexBasis: { css: "flex-basis", toValue: cssLengthOrAuto },
686
+ alignSelf: { css: "align-self", toValue: keyword(ALIGN_SELF_SET) },
687
+ order: { css: "order", toValue: cssOrder },
628
688
  fontFamily: { css: "font-family", toValue: cssFontFamily },
629
689
  fontSize: { css: "font-size", toValue: cssLength },
630
690
  fontWeight: { css: "font-weight", toValue: cssFontWeight },
@@ -633,6 +693,12 @@ const PROPERTY_MAP: {
633
693
  textAlign: { css: "text-align", toValue: cssTextAlign },
634
694
  textTransform: { css: "text-transform", toValue: keyword(TEXT_TRANSFORM) },
635
695
  textDecoration: { css: "text-decoration", toValue: keyword(TEXT_DECORATION) },
696
+ // W-952: read by the list marker rules (sent only when a page uses them).
697
+ markerColor: { css: "--emvb-marker-color", toValue: cssColor },
698
+ markerSize: { css: "--emvb-marker-size", toValue: cssLength },
699
+ fontStyle: { css: "font-style", toValue: keyword(FONT_STYLE) },
700
+ whiteSpace: { css: "white-space", toValue: keyword(WHITE_SPACE) },
701
+ overflowWrap: { css: "overflow-wrap", toValue: keyword(OVERFLOW_WRAP) },
636
702
  color: { css: "color", toValue: cssColor },
637
703
  backgroundColor: { css: "background-color", toValue: cssColor },
638
704
  backgroundImage: { css: "background-image", toValue: cssBackgroundImage },
@@ -657,11 +723,16 @@ const PROPERTY_MAP: {
657
723
  opacity: { css: "opacity", toValue: cssOpacity },
658
724
  boxShadow: { css: "box-shadow", toValue: cssBoxShadow },
659
725
  filter: { css: "filter", toValue: cssFilter },
726
+ backdropFilter: { css: "backdrop-filter", toValue: cssFilter },
727
+ // Written by `transformDeclarations` (three properties); never a declaration of its own.
728
+ transform: { css: "translate", toValue: () => undefined },
660
729
  cursor: { css: "cursor", toValue: keyword(CURSOR) },
661
730
  transition: { css: "transition", toValue: cssTransition },
662
731
  entrance: { css: "animation", toValue: cssEntrance },
663
732
  // W-319: written by `motionDeclarations` in `styleDeclarations`; this entry only names it.
664
733
  scrollMotion: { css: "animation", toValue: () => undefined },
734
+ // W-938: written by `loopDeclarations` in `styleDeclarations`; this entry only names it.
735
+ loopMotion: { css: "animation", toValue: () => undefined },
665
736
  iconRotate: { css: "--emvb-icon-rotate", toValue: cssIconRotate },
666
737
  iconFlip: { css: "--emvb-icon-flip", toValue: cssIconFlip },
667
738
  iconScale: { css: "scale", toValue: cssIconScale },
@@ -686,6 +757,36 @@ const shorthandsFirst = (record: Record<string, unknown>): [string, unknown][] =
686
757
  };
687
758
 
688
759
  /** Converts style props into safe declarations; anything that fails validation is dropped and reported. */
760
+ const TRANSFORM_KEYS = new Set(["x", "y", "scale", "rotate"]);
761
+ const int = (v: unknown, min: number, max: number) =>
762
+ typeof v === "number" && Number.isInteger(v) && v >= min && v <= max;
763
+
764
+ /** W-953: `{ x?, y?, scale?, rotate? }` → `translate`, `scale`, `rotate` (only those set). */
765
+ function transformDeclarations(value: unknown): Declaration[] | undefined {
766
+ if (!isRecord(value) || Object.keys(value).some((key) => !TRANSFORM_KEYS.has(key)))
767
+ return undefined;
768
+ const { x, y, scale, rotate } = value;
769
+ if ([x, y, scale, rotate].every((v) => v === undefined)) return undefined;
770
+ const out: Declaration[] = [];
771
+ if (x !== undefined || y !== undefined) {
772
+ if ((x !== undefined && !int(x, -2000, 2000)) || (y !== undefined && !int(y, -2000, 2000)))
773
+ return undefined;
774
+ out.push({
775
+ property: "translate",
776
+ value: `${(x as number | undefined) ?? 0}px ${(y as number | undefined) ?? 0}px`,
777
+ });
778
+ }
779
+ if (scale !== undefined) {
780
+ if (!int(scale, 10, 400)) return undefined;
781
+ out.push({ property: "scale", value: String((scale as number) / 100) });
782
+ }
783
+ if (rotate !== undefined) {
784
+ if (!int(rotate, -360, 360)) return undefined;
785
+ out.push({ property: "rotate", value: `${rotate as number}deg` });
786
+ }
787
+ return out;
788
+ }
789
+
689
790
  export function styleDeclarations(style: unknown): {
690
791
  declarations: Declaration[];
691
792
  rejected: string[];
@@ -695,6 +796,7 @@ export function styleDeclarations(style: unknown): {
695
796
  if (typeof style !== "object" || style === null) return { declarations, rejected };
696
797
  const record = style as Record<string, unknown>;
697
798
  let motion: Declaration[] = [];
799
+ let loop: Declaration[] = [];
698
800
  for (const [key, raw] of shorthandsFirst(record)) {
699
801
  if (BACKGROUND_KEYS.has(key)) continue;
700
802
  if (
@@ -705,6 +807,18 @@ export function styleDeclarations(style: unknown): {
705
807
  ) {
706
808
  continue;
707
809
  }
810
+ if (key === "loopMotion") {
811
+ const found = loopDeclarations(raw);
812
+ if (found && found.every((d) => isSafeCssValue(d.value))) loop = found;
813
+ else rejected.push(key);
814
+ continue;
815
+ }
816
+ if (key === "transform") {
817
+ const found = transformDeclarations(raw);
818
+ if (found) declarations.push(...found);
819
+ else rejected.push(key);
820
+ continue;
821
+ }
708
822
  if (key === "scrollMotion") {
709
823
  const found = motionDeclarations(raw);
710
824
  if (found && found.every((d) => isSafeCssValue(d.value))) motion = found;
@@ -712,7 +826,7 @@ export function styleDeclarations(style: unknown): {
712
826
  continue;
713
827
  }
714
828
  const entry = Object.hasOwn(PROPERTY_MAP, key)
715
- ? PROPERTY_MAP[key as keyof StyleProps]
829
+ ? PROPERTY_MAP[key as keyof FlatStyleProps]
716
830
  : undefined;
717
831
  const value = entry?.toValue(raw);
718
832
  const safe =
@@ -748,11 +862,11 @@ export function styleDeclarations(style: unknown): {
748
862
  if (column.badSpan) rejected.push("gridColumnSpan");
749
863
  if (row.badStart) rejected.push("gridRowStart");
750
864
  if (row.badSpan) rejected.push("gridRowSpan");
751
- return { declarations: withMotion(declarations, motion), rejected };
865
+ return { declarations: withLoop(withMotion(declarations, motion), loop), rejected };
752
866
  }
753
867
 
754
868
  /** Normal only (W-089, W-237): a state's `transition` and `iconAnimation` are dropped and reported. */
755
- const NORMAL_ONLY = ["transition", "iconAnimation", "scrollMotion"] as const;
869
+ const NORMAL_ONLY = ["transition", "iconAnimation", "scrollMotion", "loopMotion"] as const;
756
870
  const withoutTransition = (style: unknown): unknown => {
757
871
  if (typeof style !== "object" || style === null) return style;
758
872
  if (!NORMAL_ONLY.some((key) => key in style)) return style;
@@ -760,6 +874,7 @@ const withoutTransition = (style: unknown): unknown => {
760
874
  transition: _drop,
761
875
  iconAnimation: _loop,
762
876
  scrollMotion: _scroll,
877
+ loopMotion: _loopMotion,
763
878
  ...rest
764
879
  } = style as Record<string, unknown>;
765
880
  return rest;
@@ -810,7 +925,7 @@ const BACKGROUND_LAYER_KEYS = [
810
925
  * gradient) are filled in from `inherited` here. Otherwise they vanish on that device.
811
926
  */
812
927
  /** Both write `animation` (W-319), so one set alone would drop the other it inherits. */
813
- const ANIMATION_KEYS = ["entrance", "scrollMotion"] as const;
928
+ const ANIMATION_KEYS = ["entrance", "scrollMotion", "loopMotion"] as const;
814
929
 
815
930
  /**
816
931
  * A style that sets an entrance or scroll motion keeps the other one it inherits from a wider
@@ -127,3 +127,119 @@ export function withMotion(declarations: Declaration[], motion: Declaration[]):
127
127
  ...vars,
128
128
  ];
129
129
  }
130
+
131
+ /** W-938: time-based loop keyframes, one per CSS property, read from `--emvb-l*` values. */
132
+ const LOOP_KEYFRAMES_BY_NAME: Record<string, string> = {
133
+ lo: "opacity",
134
+ lt: "translate",
135
+ ls: "scale",
136
+ lr: "rotate",
137
+ lb: "filter",
138
+ };
139
+
140
+ /**
141
+ * The loop keyframes (W-938). Only for visitors who haven't asked for reduced motion; anywhere
142
+ * else `emvb-l*` names nothing and the element stays still.
143
+ */
144
+ export const LOOP_KEYFRAMES = `@media (prefers-reduced-motion: no-preference){${Object.entries(
145
+ LOOP_KEYFRAMES_BY_NAME,
146
+ )
147
+ .map(
148
+ ([name, prop]) =>
149
+ `@keyframes emvb-${name}{from{${prop}:var(--emvb-${name}0)}to{${prop}:var(--emvb-${name}1)}}`,
150
+ )
151
+ .join("")}}`;
152
+
153
+ const LOOP_EASINGS = new Set(["ease", "ease-in", "ease-out", "ease-in-out", "linear"]);
154
+ /** About 5 seconds of motion unless it loops forever (as an Icon's spin, D-057/D-059). */
155
+ const LOOP_STOP_MS = 5000;
156
+
157
+ /**
158
+ * Declarations for a `loopMotion` value (W-938): `animation` (one per animated property, a time
159
+ * timeline), and the `--emvb-l*` values. Undefined for a bad value; `{ type: "none" }` is
160
+ * `animation: none`. Bounded: 200 ms to 20 s, the effects' own limits, at most 5 s unless `loop`.
161
+ */
162
+ export function loopDeclarations(value: unknown): Declaration[] | undefined {
163
+ if (typeof value !== "object" || value === null) return undefined;
164
+ const record = value as Record<string, unknown>;
165
+ if (record["type"] === "none" && Object.keys(record).length === 1) {
166
+ return [{ property: "animation", value: "none" }];
167
+ }
168
+ const allowed = new Set(["effects", "duration", "easing", "alternate", "loop"]);
169
+ if (Object.keys(record).some((key) => !allowed.has(key))) return undefined;
170
+ const { effects, duration, easing, alternate, loop } = record;
171
+ if (!Number.isInteger(duration) || (duration as number) < 200 || (duration as number) > 20_000)
172
+ return undefined;
173
+ if (easing !== undefined && (typeof easing !== "string" || !LOOP_EASINGS.has(easing)))
174
+ return undefined;
175
+ if (alternate !== undefined && typeof alternate !== "boolean") return undefined;
176
+ if (loop !== undefined && loop !== true) return undefined;
177
+ if (!Array.isArray(effects) || effects.length === 0 || effects.length > MOTION_EFFECTS.length) {
178
+ return undefined;
179
+ }
180
+ if (!effects.every(isEffect)) return undefined;
181
+ const by = new Map(effects.map((e) => [e.type, e]));
182
+ if (by.size !== effects.length) return undefined;
183
+ const frames: [string, string, string][] = [];
184
+ const fade = by.get("fade");
185
+ if (fade) frames.push(["lo", num(fade.from / 100), num(fade.to / 100)]);
186
+ const x = by.get("move-x");
187
+ const y = by.get("move-y");
188
+ if (x || y) {
189
+ frames.push([
190
+ "lt",
191
+ `${num(x?.from ?? 0)}px ${num(y?.from ?? 0)}px`,
192
+ `${num(x?.to ?? 0)}px ${num(y?.to ?? 0)}px`,
193
+ ]);
194
+ }
195
+ const scale = by.get("scale");
196
+ if (scale) frames.push(["ls", num(scale.from / 100), num(scale.to / 100)]);
197
+ const rotate = by.get("rotate");
198
+ if (rotate) frames.push(["lr", `${num(rotate.from)}deg`, `${num(rotate.to)}deg`]);
199
+ const blur = by.get("blur");
200
+ if (blur) frames.push(["lb", `blur(${num(blur.from)}px)`, `blur(${num(blur.to)}px)`]);
201
+ const ms = duration as number;
202
+ const runs = loop ? "infinite" : String(Math.max(1, Math.floor(LOOP_STOP_MS / ms)));
203
+ const direction = alternate === false ? "normal" : "alternate";
204
+ const timing = `${ms}ms ${(easing as string | undefined) ?? "ease-in-out"} ${runs} ${direction}`;
205
+ return [
206
+ { property: "animation", value: frames.map(([n]) => `emvb-${n} ${timing}`).join(", ") },
207
+ { property: "animation-timeline", value: frames.map(() => "auto").join(", ") },
208
+ { property: "animation-range", value: frames.map(() => "normal").join(", ") },
209
+ ...frames.flatMap(([n, from, to]) => [
210
+ { property: `--emvb-${n}0`, value: from },
211
+ { property: `--emvb-${n}1`, value: to },
212
+ ]),
213
+ ];
214
+ }
215
+
216
+ /**
217
+ * W-938: adds a loop to declarations that may already animate (an entrance, scroll motion). The
218
+ * lists are joined, the loop last, with timelines and ranges kept per animation; a loop `none`
219
+ * leaves the others alone.
220
+ */
221
+ export function withLoop(declarations: Declaration[], loop: Declaration[]): Declaration[] {
222
+ const [animation, timeline, range, ...vars] = loop;
223
+ if (!animation) return declarations;
224
+ const current = declarations.find((d) => d.property === "animation");
225
+ if (!current) return [...declarations, ...loop];
226
+ if (animation.value === "none" || !timeline || !range) return declarations;
227
+ const count = current.value.split(",").length;
228
+ const currentTimeline = declarations.find((d) => d.property === "animation-timeline");
229
+ const currentRange = declarations.find((d) => d.property === "animation-range");
230
+ const rest = declarations.filter(
231
+ (d) => d !== current && d !== currentTimeline && d !== currentRange,
232
+ );
233
+ const fill = (found: Declaration | undefined, value: string) =>
234
+ found?.value ?? Array.from({ length: count }, () => value).join(", ");
235
+ return [
236
+ ...rest,
237
+ { property: "animation", value: `${current.value}, ${animation.value}` },
238
+ {
239
+ property: "animation-timeline",
240
+ value: `${fill(currentTimeline, "auto")}, ${timeline.value}`,
241
+ },
242
+ { property: "animation-range", value: `${fill(currentRange, "normal")}, ${range.value}` },
243
+ ...vars,
244
+ ];
245
+ }
@@ -242,6 +242,12 @@ function withClassIds(node: LayoutNode, ids: ReadonlyMap<string, string>): Layou
242
242
  return next;
243
243
  }
244
244
 
245
+ /** W-958: a whole layout with its class refs moved to the ids a merge gave them. */
246
+ export const remapClassIds = (layout: Layout, ids: ReadonlyMap<string, string>): Layout => ({
247
+ ...layout,
248
+ root: withClassIds(layout.root, ids) as Layout["root"],
249
+ });
250
+
245
251
  export type PreparedSection = {
246
252
  node: LayoutNode;
247
253
  design: DesignSystem;
@@ -10,7 +10,9 @@ export type FieldKind =
10
10
  | "media"
11
11
  | "icon"
12
12
  | "list-items"
13
- | "image-sources";
13
+ | "image-sources"
14
+ /** W-950: formatting (bold, italic, colour, link) on words of the element's Text. */
15
+ | "marks";
14
16
 
15
17
  export type FieldOption = { value: string | number | boolean; label: string };
16
18
 
@@ -3,12 +3,13 @@ import { HEX_COLOR } from "../css-keywords.ts";
3
3
  import { DeviceStyles, HiddenOn, StyleProps, StyleStates } from "./style.ts";
4
4
 
5
5
  /**
6
+ * 17 since W-925 (contract 1.0): the motion style keys sit under one `motion` record.
6
7
  * 15 since W-341, in step with layouts (optional fields only; the design document itself is unchanged).
7
8
  * 14 since W-329, in step with layouts (optional fields only: `ch` lengths, negative margins).
8
9
  * 13 since W-307, in step with layouts (the W-307 batch only adds optional fields).
9
10
  * 12 since W-160: class gradients use the same stops as layouts. v11 `{ angle, from, to }` upgrades on read.
10
11
  */
11
- export const DESIGN_SCHEMA_VERSION = 16;
12
+ export const DESIGN_SCHEMA_VERSION = 17;
12
13
 
13
14
  /** Tags a site can give a starting style. Classes and local styles still win. */
14
15
  export const DEFAULT_STYLE_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "a", "button"] as const;