@perkyzz/emvb 0.2.1 → 0.4.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 (150) hide show
  1. package/README.md +4 -2
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/package.json +3 -1
  4. package/src/admin/access/role.ts +9 -3
  5. package/src/admin/api.ts +17 -7
  6. package/src/admin/content-api.ts +7 -51
  7. package/src/admin/content-item.ts +22 -0
  8. package/src/admin/design-api.ts +30 -0
  9. package/src/admin/editor/A11yCopilot.tsx +126 -0
  10. package/src/admin/editor/CommandPalette.tsx +118 -0
  11. package/src/admin/editor/Editor.tsx +188 -152
  12. package/src/admin/editor/EditorOverlay.tsx +9 -1
  13. package/src/admin/editor/PerfMeter.tsx +121 -0
  14. package/src/admin/editor/ShareLink.tsx +164 -0
  15. package/src/admin/editor/ShortcutsDialog.tsx +4 -1
  16. package/src/admin/editor/Timeline.tsx +287 -0
  17. package/src/admin/editor/TopBar.tsx +4 -0
  18. package/src/admin/editor/canvas/CanvasFrame.tsx +62 -370
  19. package/src/admin/editor/canvas/DeviceBar.tsx +4 -1
  20. package/src/admin/editor/canvas/SelectionOverlay.tsx +87 -47
  21. package/src/admin/editor/canvas/canvas-scale.ts +20 -0
  22. package/src/admin/editor/canvas/drop-line.ts +24 -0
  23. package/src/admin/editor/canvas/use-canvas-dnd.ts +207 -0
  24. package/src/admin/editor/canvas/use-canvas-session.ts +216 -0
  25. package/src/admin/editor/collection-previews.ts +114 -0
  26. package/src/admin/editor/editor-chrome.tsx +346 -0
  27. package/src/admin/editor/editor-commands.ts +360 -0
  28. package/src/admin/editor/editor-css.ts +5 -3
  29. package/src/admin/editor/element-chrome.ts +89 -0
  30. package/src/admin/editor/feature-css.ts +105 -0
  31. package/src/admin/editor/host.ts +35 -0
  32. package/src/admin/editor/icons/IconLibraryDialog.tsx +64 -218
  33. package/src/admin/editor/icons/library.ts +29 -19
  34. package/src/admin/editor/icons/use-icon-library.ts +315 -0
  35. package/src/admin/editor/live-data.tsx +71 -0
  36. package/src/admin/editor/palette-items.ts +136 -0
  37. package/src/admin/editor/palette.ts +68 -0
  38. package/src/admin/editor/panels/AddPanel.tsx +48 -68
  39. package/src/admin/editor/panels/ClassesSection.tsx +5 -1
  40. package/src/admin/editor/panels/ColorControl.tsx +2 -10
  41. package/src/admin/editor/panels/ElementPanel.tsx +74 -102
  42. package/src/admin/editor/panels/LayersPanel.tsx +72 -63
  43. package/src/admin/editor/panels/LeftPanel.tsx +4 -1
  44. package/src/admin/editor/panels/SettingsPanel.tsx +13 -0
  45. package/src/admin/editor/panels/SiteStylesDrawer.tsx +18 -10
  46. package/src/admin/editor/panels/TokenScales.tsx +168 -0
  47. package/src/admin/editor/panels/VariableSection.tsx +10 -14
  48. package/src/admin/editor/panels/inline-error.tsx +11 -0
  49. package/src/admin/editor/panels/settings/AdvancedFields.tsx +87 -1
  50. package/src/admin/editor/panels/settings/AudienceEditor.tsx +285 -0
  51. package/src/admin/editor/panels/settings/BindingsEditor.tsx +221 -0
  52. package/src/admin/editor/panels/settings/ClassChipInput.tsx +1 -1
  53. package/src/admin/editor/panels/settings/DraftTextField.tsx +4 -0
  54. package/src/admin/editor/panels/settings/EffectsControls.tsx +2 -2
  55. package/src/admin/editor/panels/settings/FormBindControl.tsx +8 -4
  56. package/src/admin/editor/panels/settings/ItemList.tsx +34 -1
  57. package/src/admin/editor/panels/settings/MotionControl.tsx +252 -0
  58. package/src/admin/editor/panels/settings/StateSwitcher.tsx +1 -1
  59. package/src/admin/editor/panels/settings/StyleRow.tsx +26 -2
  60. package/src/admin/editor/panels/settings/StyleSources.tsx +94 -0
  61. package/src/admin/editor/panels/settings/VariableBinding.tsx +1 -1
  62. package/src/admin/editor/panels/settings/VariantEditor.tsx +83 -0
  63. package/src/admin/editor/panels/settings/form-names.ts +7 -11
  64. package/src/admin/editor/panels/settings/length-units.ts +16 -5
  65. package/src/admin/editor/panels/settings/style-sections.ts +7 -2
  66. package/src/admin/editor/panels/style-target.ts +105 -0
  67. package/src/admin/editor/section-templates.ts +43 -21
  68. package/src/admin/editor/shortcuts.ts +6 -1
  69. package/src/admin/editor/store.ts +10 -1
  70. package/src/admin/editor/useClipboardActions.ts +1 -1
  71. package/src/admin/editor/useEditorCommands.ts +61 -13
  72. package/src/admin/editor/useEditorData.ts +7 -1
  73. package/src/admin/editor/useEditorShortcuts.ts +30 -14
  74. package/src/admin/editor/useNodeActions.ts +44 -16
  75. package/src/admin/forms-api.ts +17 -6
  76. package/src/admin/icon-uploads-api.ts +18 -0
  77. package/src/admin/theme-api.ts +5 -18
  78. package/src/admin/ui.ts +4 -4
  79. package/src/astro/content-port.ts +24 -0
  80. package/src/astro/forms/EmVBFormsClient.astro +11 -0
  81. package/src/astro/forms/EmVBFormsRuntime.astro +6 -7
  82. package/src/astro/forms/client.ts +1 -0
  83. package/src/astro/forms-definitions.ts +24 -11
  84. package/src/astro/index.ts +1 -0
  85. package/src/astro/render-session.ts +85 -0
  86. package/src/astro/request-data.ts +109 -0
  87. package/src/astro/resolve-theme.ts +184 -64
  88. package/src/astro/resolve.ts +63 -16
  89. package/src/astro/theme-posts.ts +48 -5
  90. package/src/astro/visitor.ts +204 -0
  91. package/src/constants.ts +1 -1
  92. package/src/core/a11y/audit.ts +282 -0
  93. package/src/core/arrange.ts +150 -34
  94. package/src/core/audience/rules.ts +124 -0
  95. package/src/core/audience/variants.ts +51 -0
  96. package/src/core/canvas-styles.ts +24 -0
  97. package/src/core/clipboard.ts +11 -32
  98. package/src/core/css/generate.ts +29 -2
  99. package/src/core/css/print.ts +12 -0
  100. package/src/core/css/scope.ts +3 -3
  101. package/src/core/css/trace.ts +169 -0
  102. package/src/core/css-keywords.ts +83 -0
  103. package/src/core/data/bindings.ts +255 -0
  104. package/src/core/design/classes.ts +13 -15
  105. package/src/core/design/diff.ts +55 -0
  106. package/src/core/design/merge.ts +127 -0
  107. package/src/core/design/tokens.ts +127 -0
  108. package/src/core/design/variables.ts +25 -21
  109. package/src/core/elements/dynamic-elements.ts +117 -2
  110. package/src/core/elements/form-elements.ts +1 -0
  111. package/src/core/elements/index.ts +185 -7
  112. package/src/core/forms/binding.ts +4 -13
  113. package/src/core/history/diff.ts +152 -0
  114. package/src/core/index.ts +121 -0
  115. package/src/core/local-style.ts +27 -0
  116. package/src/core/migrate/index.ts +12 -4
  117. package/src/core/nesting.ts +4 -22
  118. package/src/core/perf/meter.ts +160 -0
  119. package/src/core/perf/scripts.ts +61 -0
  120. package/src/core/recipes/index.ts +433 -0
  121. package/src/core/record.ts +3 -0
  122. package/src/core/render/context.ts +2 -0
  123. package/src/core/render/dynamic-post.ts +1 -2
  124. package/src/core/render/form.ts +133 -10
  125. package/src/core/render/index.ts +206 -17
  126. package/src/core/render/loop.ts +54 -7
  127. package/src/core/render/pagination.ts +9 -1
  128. package/src/core/render/vnode.ts +12 -2
  129. package/src/core/sanitize/css.ts +129 -80
  130. package/src/core/sanitize/motion.ts +129 -0
  131. package/src/core/sanitize/svg.ts +8 -3
  132. package/src/core/sanitize/url.ts +10 -1
  133. package/src/core/schema/design.ts +29 -8
  134. package/src/core/schema/layout.ts +291 -169
  135. package/src/core/schema/motion.ts +14 -0
  136. package/src/core/schema/style.ts +101 -66
  137. package/src/core/share/link.ts +187 -0
  138. package/src/core/tabs/presence.ts +7 -17
  139. package/src/core/theme/dynamic.ts +242 -32
  140. package/src/core/theme/float.ts +1 -1
  141. package/src/core/theme/pagination.ts +56 -0
  142. package/src/core/tree-ops.ts +57 -0
  143. package/src/index.ts +14 -2
  144. package/src/server/design-routes.ts +4 -1
  145. package/src/server/icon-routes.ts +68 -16
  146. package/src/server/plugin.ts +8 -2
  147. package/src/admin/editor/icons/sets/fontawesome.json +0 -1
  148. package/src/admin/editor/icons/sets/lucide.json +0 -1
  149. package/src/admin/editor/icons/sets/remix.json +0 -1
  150. package/src/admin/editor/icons/sets/tabler.json +0 -1
@@ -1,3 +1,4 @@
1
+ import { isRecord } from "../record.ts";
1
2
  import { LAYOUT_SCHEMA_VERSION } from "../schema/layout.ts";
2
3
 
3
4
  export type Migration = (doc: Record<string, unknown>) => Record<string, unknown>;
@@ -11,13 +12,14 @@ export type Migration = (doc: Record<string, unknown>) => Record<string, unknown
11
12
  * a link on a box, and tag defaults, and v9 → v10 (D-044, D-039) per-side border widths,
12
13
  * per-corner radii and grid columns per device, and v10 → v11 (D-045) the layout Section and node
13
14
  * labels, and v11 → v12 (W-160) rewrites a gradient `{ angle, from, to }` into
14
- * `{ type: "linear", angle, stops }`. Every other value is unchanged.
15
+ * `{ type: "linear", angle, stops }`, and v12 → v13 (W-307 onward) adds optional fields only
16
+ * (bindings, and the rest of the W-307 feature batch), and v13 → v14 (W-329 onward) adds
17
+ * optional fields only (audience segments, Loop options, `ch` and negative margins), and
18
+ * v14 → v15 (W-341 onward) adds optional fields only (direction, image link and caption,
19
+ * button icons, table of contents, container queries). Every other value is unchanged.
15
20
  */
16
21
  const unchanged: Migration = (doc) => doc;
17
22
 
18
- const isRecord = (value: unknown): value is Record<string, unknown> =>
19
- typeof value === "object" && value !== null && !Array.isArray(value);
20
-
21
23
  /** v11 two-stop gradient → v12 stops. A gradient that already has `stops` is left as it is. */
22
24
  function convertGradient(value: unknown): unknown {
23
25
  if (!isRecord(value) || Array.isArray(value["stops"])) return value;
@@ -69,6 +71,9 @@ export const LAYOUT_MIGRATIONS: Readonly<Record<number, Migration>> = {
69
71
  9: unchanged,
70
72
  10: unchanged,
71
73
  11: gradients,
74
+ 12: unchanged,
75
+ 13: unchanged,
76
+ 14: unchanged,
72
77
  };
73
78
 
74
79
  /** `DESIGN_MIGRATIONS[n]` upgrades a version-n design document to version n + 1. */
@@ -84,6 +89,9 @@ export const DESIGN_MIGRATIONS: Readonly<Record<number, Migration>> = {
84
89
  9: unchanged,
85
90
  10: unchanged,
86
91
  11: gradients,
92
+ 12: unchanged,
93
+ 13: unchanged,
94
+ 14: unchanged,
87
95
  };
88
96
 
89
97
  export type UpgradeResult =
@@ -1,12 +1,12 @@
1
- import { REASONS } from "./arrange.ts";
2
- import { isFormFieldType, isFormNode, type Layout, type LayoutNode } from "./schema/layout.ts";
1
+ import { parentChildRefusal } from "./arrange.ts";
2
+ import { isFormNode, type Layout, type LayoutNode } from "./schema/layout.ts";
3
3
  import { nodeChildren } from "./tree-ops.ts";
4
4
  import type { LayoutIssue } from "./validate.ts";
5
5
 
6
6
  /**
7
7
  * Elements in a parent the editor would never let them into: a menu item outside a Menu, a tab
8
8
  * panel outside Tabs, a form field outside a form, a form in a form, and so on (W-225). The
9
- * same rules and messages as drag and drop (arrange.ts DROP_RULES). The editor can't build
9
+ * same rules and messages as drag and drop (`parentChildRefusal`). The editor can't build
10
10
  * these trees, but the content API accepted them and they render broken markup (an orphan
11
11
  * `<li>`, a panel no tab opens). Not part of validateLayout, so stored pages still render and
12
12
  * a copied field can still be pasted; the save hook refuses them instead.
@@ -23,7 +23,7 @@ export function nestingIssues(layout: Layout, max = 5): LayoutIssue[] {
23
23
  for (const [i, child] of kids.entries()) {
24
24
  if (issues.length >= max) return;
25
25
  const at = `${path}.children[${i}]`;
26
- const reason = misplaced(node, child, inForm);
26
+ const reason = parentChildRefusal(node, child, inForm);
27
27
  if (reason) add(at, child, reason);
28
28
  walk(child, at, inForm || isFormNode(child));
29
29
  }
@@ -31,21 +31,3 @@ export function nestingIssues(layout: Layout, max = 5): LayoutIssue[] {
31
31
  walk(layout.root, "root", isFormNode(layout.root));
32
32
  return issues;
33
33
  }
34
-
35
- function misplaced(parent: LayoutNode, child: LayoutNode, inForm: boolean): string | undefined {
36
- if (child.type === "tab-panel" && parent.type !== "tabs") return REASONS.tabOutsideTabs;
37
- if (parent.type === "tabs" && child.type !== "tab-panel") return REASONS.onlyTabPanels;
38
- if (child.type === "accordion-item" && parent.type !== "accordion") {
39
- return REASONS.itemOutsideAccordion;
40
- }
41
- if (parent.type === "accordion" && child.type !== "accordion-item") {
42
- return REASONS.onlyAccordionItems;
43
- }
44
- if (child.type === "menu-item" && parent.type !== "menu" && parent.type !== "menu-item") {
45
- return REASONS.itemOutsideMenu;
46
- }
47
- if (parent.type === "menu" && child.type !== "menu-item") return REASONS.onlyMenuItems;
48
- if (isFormNode(child) && inForm) return REASONS.nestedForm;
49
- if (isFormFieldType(child.type) && !inForm) return REASONS.fieldOutsideForm;
50
- return undefined;
51
- }
@@ -0,0 +1,160 @@
1
+ import type { DesignSystem } from "../schema/design.ts";
2
+ import { isParentNode, type Layout, type LayoutNode } from "../schema/layout.ts";
3
+ import { renderPage } from "../render/index.ts";
4
+ import type { ThemeDynamicData } from "../theme/dynamic.ts";
5
+ import { layoutScripts, SCRIPT_BYTES, type PageScript } from "./scripts.ts";
6
+
7
+ /** Budgets per page (W-310), in bytes over the wire. Generous for a marketing page. */
8
+ export const PERF_BUDGETS = {
9
+ html: 100_000,
10
+ css: 60_000,
11
+ js: 30_000,
12
+ images: 1_500_000,
13
+ } as const;
14
+
15
+ export type PerfKind = keyof typeof PERF_BUDGETS;
16
+
17
+ export type SectionWeight = {
18
+ id: string;
19
+ type: string;
20
+ label?: string;
21
+ bytes: number;
22
+ images: number;
23
+ };
24
+
25
+ export type PerfReport = {
26
+ bytes: Record<PerfKind, number>;
27
+ /** Which kinds go over their budget. */
28
+ over: PerfKind[];
29
+ scripts: { script: PageScript; bytes: number; nodeIds: string[] }[];
30
+ imageCount: number;
31
+ embeds: number;
32
+ /** Top-level sections, heaviest first. */
33
+ sections: SectionWeight[];
34
+ warnings: string[];
35
+ };
36
+
37
+ /** Bytes a string takes as UTF-8; HTML and CSS gzip to about a quarter, which we apply. */
38
+ const utf8 = (text: string) => new TextEncoder().encode(text).length;
39
+ const GZIP = 0.25;
40
+ /** An image with no size is guessed at a typical optimized photo (W-310). */
41
+ const IMAGE_GUESS = 120_000;
42
+ /** A YouTube iframe pulls in roughly this much before the visitor presses play. */
43
+ const EMBED_BYTES = 500_000;
44
+
45
+ function imageBytes(node: LayoutNode): number {
46
+ const props = node.props as { width?: unknown; height?: unknown };
47
+ const w = typeof props.width === "number" ? props.width : 0;
48
+ const h = typeof props.height === "number" ? props.height : 0;
49
+ // About 0.25 bytes per pixel for a WebP/AVIF photo at good quality.
50
+ return w > 0 && h > 0 ? Math.max(5_000, Math.round(w * h * 0.25)) : IMAGE_GUESS;
51
+ }
52
+
53
+ const hasBackgroundImage = (node: LayoutNode): boolean => {
54
+ const sheets = [node.style, ...Object.values(node.devices ?? {})];
55
+ return sheets.some((style) => {
56
+ const value = (style as { backgroundImage?: unknown } | undefined)?.backgroundImage;
57
+ return typeof value === "string" ? value.length > 0 : Boolean(value);
58
+ });
59
+ };
60
+
61
+ /** Images and embeds under a node, with their estimated weight. */
62
+ function media(node: LayoutNode): { images: number; bytes: number; embeds: number } {
63
+ let images = 0;
64
+ let bytes = 0;
65
+ let embeds = 0;
66
+ const walk = (n: LayoutNode): void => {
67
+ if (n.type === "image" || n.type === "post-image") {
68
+ const src = (n.props as { src?: unknown }).src;
69
+ if (n.type === "post-image" || (typeof src === "string" && src.trim())) {
70
+ images += 1;
71
+ bytes += imageBytes(n);
72
+ }
73
+ }
74
+ if (hasBackgroundImage(n)) {
75
+ images += 1;
76
+ bytes += IMAGE_GUESS;
77
+ }
78
+ if (n.type === "video") {
79
+ embeds += 1;
80
+ bytes += EMBED_BYTES;
81
+ }
82
+ if (isParentNode(n)) for (const child of n.children) walk(child);
83
+ };
84
+ walk(node);
85
+ return { images, bytes, embeds };
86
+ }
87
+
88
+ const kb = (bytes: number) => `${Math.round(bytes / 1000)} KB`;
89
+
90
+ /**
91
+ * The page's weight against its budget (W-310): HTML and CSS as rendered (gzipped estimate),
92
+ * the scripts it loads, and its images, with the heaviest top-level section first.
93
+ */
94
+ export function measurePage(
95
+ layout: Layout,
96
+ design: DesignSystem,
97
+ dynamic?: ThemeDynamicData,
98
+ ): PerfReport {
99
+ const rendered = renderPage(layout, design, dynamic ? { dynamic } : {});
100
+ const scripts = [...layoutScripts(layout)].map(([script, nodeIds]) => ({
101
+ script,
102
+ bytes: SCRIPT_BYTES[script],
103
+ nodeIds,
104
+ }));
105
+ const all = media(layout.root);
106
+ const bytes: Record<PerfKind, number> = {
107
+ html: Math.round(utf8(rendered.html) * GZIP),
108
+ css: Math.round(utf8(rendered.css) * GZIP),
109
+ js: scripts.reduce((sum, s) => sum + s.bytes, 0),
110
+ images: all.bytes,
111
+ };
112
+ const over = (Object.keys(PERF_BUDGETS) as PerfKind[]).filter((k) => bytes[k] > PERF_BUDGETS[k]);
113
+ const opts = dynamic ? { dynamic } : {};
114
+ const sections: SectionWeight[] = [];
115
+ for (const child of layout.root.children.slice(0, 100)) {
116
+ const alone: Layout = {
117
+ schemaVersion: layout.schemaVersion,
118
+ root: Object.assign({}, layout.root, { children: [child] }),
119
+ };
120
+ const one = renderPage(alone, design, opts);
121
+ const m = media(child);
122
+ sections.push({
123
+ id: child.id,
124
+ type: child.type,
125
+ ...(child.label ? { label: child.label } : {}),
126
+ bytes: Math.round(utf8(one.html) * GZIP) + m.bytes,
127
+ images: m.images,
128
+ });
129
+ }
130
+ sections.sort((a, b) => b.bytes - a.bytes);
131
+ const warnings: string[] = [];
132
+ for (const kind of over) {
133
+ warnings.push(
134
+ `${kind.toUpperCase()} is ${kb(bytes[kind])}, over the ${kb(PERF_BUDGETS[kind])} budget.`,
135
+ );
136
+ }
137
+ if (all.embeds > 0) {
138
+ warnings.push(
139
+ `${all.embeds} video embed${all.embeds === 1 ? "" : "s"} load a third-party player (about ${kb(EMBED_BYTES)} each).`,
140
+ );
141
+ }
142
+ const first = layout.root.children[0];
143
+ const firstImage = first ? findFirstImage(first) : undefined;
144
+ if (firstImage && !(firstImage.props as { priority?: unknown }).priority) {
145
+ warnings.push(
146
+ "The first section's image isn't marked Priority, so it loads late; mark the hero image Priority.",
147
+ );
148
+ }
149
+ return { bytes, over, scripts, imageCount: all.images, embeds: all.embeds, sections, warnings };
150
+ }
151
+
152
+ function findFirstImage(node: LayoutNode): LayoutNode | undefined {
153
+ if (node.type === "image") return node;
154
+ if (!isParentNode(node)) return undefined;
155
+ for (const child of node.children) {
156
+ const found = findFirstImage(child);
157
+ if (found) return found;
158
+ }
159
+ return undefined;
160
+ }
@@ -0,0 +1,61 @@
1
+ import { isParentNode, type Layout, type LayoutNode } from "../schema/layout.ts";
2
+ import { forEachNode, knownChildren } from "../tree-ops.ts";
3
+
4
+ /** The small scripts an EmVB page can load; everything else is plain HTML and CSS (W-311). */
5
+ export type PageScript = "forms" | "tabs" | "menu";
6
+
7
+ /** What each script is for, for badges and the performance meter (W-311). */
8
+ export const SCRIPT_LABELS: Record<PageScript, string> = {
9
+ forms: "Form submission script",
10
+ tabs: "Tabs keyboard script",
11
+ menu: "Dropdown menu script",
12
+ };
13
+
14
+ /**
15
+ * About how many bytes (minified, gzipped) each script adds (W-310). Measured from the built
16
+ * runtimes; the forms client is the forms plugin's own script.
17
+ */
18
+ export const SCRIPT_BYTES: Record<PageScript, number> = {
19
+ forms: 6_000,
20
+ tabs: 1_400,
21
+ menu: 600,
22
+ };
23
+
24
+ /** Elements that make the page load a script by being there (W-311). */
25
+ const SCRIPT_TYPES: Partial<Record<LayoutNode["type"], PageScript>> = {
26
+ form: "forms",
27
+ tabs: "tabs",
28
+ };
29
+
30
+ /**
31
+ * The script a node adds to the page, or undefined for the zero-JS default (W-311). A Menu item
32
+ * adds the menu script only when it has a dropdown; a Form only once it is connected to a form.
33
+ */
34
+ export function nodeScript(node: LayoutNode): PageScript | undefined {
35
+ if (node.type === "menu-item") {
36
+ return isParentNode(node) && node.children.length > 0 ? "menu" : undefined;
37
+ }
38
+ if (node.type === "form") {
39
+ const formId = (node.props as { formId?: unknown }).formId;
40
+ return typeof formId === "string" && formId.trim() ? "forms" : undefined;
41
+ }
42
+ return SCRIPT_TYPES[node.type];
43
+ }
44
+
45
+ /** Does this element type ever add a script? For the Add panel's JS badge (W-311). */
46
+ export const typeMayAddScript = (type: string): boolean =>
47
+ type === "form" || type === "tabs" || type === "menu" || type === "menu-item";
48
+
49
+ /** Every script the layout loads, with the elements that cause it (W-311). */
50
+ export function layoutScripts(layout: Layout): Map<PageScript, string[]> {
51
+ const found = new Map<PageScript, string[]>();
52
+ forEachNode(
53
+ layout.root,
54
+ (node) => {
55
+ const script = nodeScript(node);
56
+ if (script) found.set(script, [...(found.get(script) ?? []), node.id]);
57
+ },
58
+ knownChildren,
59
+ );
60
+ return found;
61
+ }