@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.
- package/README.md +10 -1
- package/package.json +2 -2
- package/src/admin/agents-api.ts +45 -0
- package/src/admin/bulk-api.ts +67 -0
- package/src/admin/content-api.ts +10 -6
- package/src/admin/copy-rich-text.ts +119 -0
- package/src/admin/dialog-tab-wrap.ts +78 -0
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +311 -250
- package/src/admin/editor/Timeline.tsx +8 -3
- package/src/admin/editor/TopBar.tsx +29 -7
- package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +31 -10
- package/src/admin/editor/canvas/canvas-scale.ts +3 -3
- package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
- package/src/admin/editor/co-design.ts +190 -0
- package/src/admin/editor/dnd/new-element.ts +48 -4
- package/src/admin/editor/editor-chrome.tsx +8 -6
- package/src/admin/editor/editor-commands.ts +15 -4
- package/src/admin/editor/editor-css.ts +2 -1
- package/src/admin/editor/element-chrome.ts +3 -1
- package/src/admin/editor/extension-manifests.ts +20 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
- package/src/admin/editor/extensions-context.tsx +27 -0
- package/src/admin/editor/feature-css.ts +17 -0
- package/src/admin/editor/palette-items.ts +2 -2
- package/src/admin/editor/panels/AddPanel.tsx +31 -1
- package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
- package/src/admin/editor/panels/ClassesSection.tsx +9 -6
- package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ElementPanel.tsx +68 -20
- package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
- package/src/admin/editor/panels/LayersPanel.tsx +10 -6
- package/src/admin/editor/panels/LeftPanel.tsx +33 -5
- package/src/admin/editor/panels/PageSettings.tsx +4 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
- package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
- package/src/admin/editor/panels/settings/EffectsControls.tsx +183 -10
- package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
- package/src/admin/editor/panels/settings/IconControls.tsx +25 -11
- package/src/admin/editor/panels/settings/LengthRow.tsx +63 -19
- package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +19 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
- package/src/admin/editor/panels/settings/StyleRow.tsx +120 -13
- package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
- package/src/admin/editor/panels/settings/background-mode.ts +14 -11
- package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
- package/src/admin/editor/panels/settings/box-sides.ts +22 -14
- package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
- package/src/admin/editor/panels/settings/length-units.ts +68 -4
- package/src/admin/editor/panels/settings/query-style.ts +3 -3
- package/src/admin/editor/panels/settings/style-sections.ts +52 -10
- package/src/admin/editor/panels/style-target.ts +22 -7
- package/src/admin/editor/presence.ts +60 -0
- package/src/admin/editor/section-templates.ts +26 -4
- package/src/admin/editor/store.ts +14 -4
- package/src/admin/editor/useCoDesign.ts +177 -0
- package/src/admin/editor/useEditorCommands.ts +7 -5
- package/src/admin/editor/useExtensions.ts +45 -0
- package/src/admin/editor/useNodeActions.ts +18 -7
- package/src/admin/editor/useProposals.ts +81 -0
- package/src/admin/export-api.ts +221 -0
- package/src/admin/index.tsx +6 -1
- package/src/admin/languages-api.ts +61 -0
- package/src/admin/pages/AgentSetup.tsx +148 -0
- package/src/admin/pages/AgentsPage.tsx +9 -26
- package/src/admin/pages/CreateDialog.tsx +15 -0
- package/src/admin/pages/ExportDialog.tsx +395 -0
- package/src/admin/pages/ImportButton.tsx +18 -0
- package/src/admin/pages/ImportElementorDialog.tsx +669 -0
- package/src/admin/pages/ImportPageLinks.tsx +86 -0
- package/src/admin/pages/PageList.tsx +82 -3
- package/src/admin/pages/ThemePartList.tsx +52 -2
- package/src/admin/pages/bulk.tsx +303 -0
- package/src/admin/pages/section-head.tsx +27 -0
- package/src/admin/proposals-api.ts +91 -0
- package/src/admin/search.ts +20 -0
- package/src/admin/theme-api.ts +4 -0
- package/src/admin/ui.ts +50 -4
- package/src/admin/widgets/CanvasField.tsx +8 -0
- package/src/admin/widgets/ConvertToRichText.tsx +136 -0
- package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
- package/src/admin/widgets/convert-body.ts +73 -2
- package/src/astro/content-port.ts +14 -1
- package/src/astro/render.ts +6 -6
- package/src/astro/resolve-theme.ts +25 -8
- package/src/astro/resolve.ts +89 -2
- package/src/astro/tabs/runtime.ts +16 -6
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +45 -14
- package/src/core/arrange.ts +5 -1
- package/src/core/bounded-array.ts +31 -0
- package/src/core/clipboard.ts +9 -0
- package/src/core/contract.ts +305 -0
- package/src/core/css/generate.ts +151 -20
- package/src/core/css/scope.ts +10 -2
- package/src/core/css/trace.ts +47 -13
- package/src/core/css-keywords.ts +51 -1
- package/src/core/design/cascade.ts +12 -9
- package/src/core/design/classes.ts +28 -9
- package/src/core/design/devices.ts +89 -13
- package/src/core/design/states.ts +5 -3
- package/src/core/design/transfer.ts +5 -0
- package/src/core/design/variables.ts +31 -5
- package/src/core/elements/dynamic-elements.ts +3 -3
- package/src/core/elements/index.ts +73 -9
- package/src/core/export/runtimes.generated.ts +9 -0
- package/src/core/export/site.ts +562 -0
- package/src/core/export/zip.ts +95 -0
- package/src/core/extensions/define.ts +13 -0
- package/src/core/extensions/index.ts +41 -0
- package/src/core/extensions/namespace.ts +82 -0
- package/src/core/extensions/normalize.ts +141 -0
- package/src/core/extensions/placeholder.ts +41 -0
- package/src/core/extensions/registry.ts +94 -0
- package/src/core/extensions/render-ext.ts +118 -0
- package/src/core/extensions/safe-nodes.ts +93 -0
- package/src/core/extensions/schema.ts +112 -0
- package/src/core/extensions/types.ts +159 -0
- package/src/core/forms/binding.ts +1 -1
- package/src/core/history/diff.ts +26 -1
- package/src/core/import/elementor/atomic.ts +1608 -0
- package/src/core/import/elementor/classes.ts +127 -0
- package/src/core/import/elementor/context.ts +429 -0
- package/src/core/import/elementor/counter-steps.ts +72 -0
- package/src/core/import/elementor/css.ts +445 -0
- package/src/core/import/elementor/html.ts +500 -0
- package/src/core/import/elementor/index.ts +967 -0
- package/src/core/import/elementor/inline-marks.ts +81 -0
- package/src/core/import/elementor/snapshots.ts +48 -0
- package/src/core/import/elementor/style.ts +429 -0
- package/src/core/import/elementor/values.ts +241 -0
- package/src/core/import/elementor/widgets.ts +1897 -0
- package/src/core/index.ts +96 -0
- package/src/core/json-schema.ts +114 -0
- package/src/core/limits.ts +19 -0
- package/src/core/migrate/index.ts +6 -1
- package/src/core/migrate/v18.ts +222 -0
- package/src/core/perf/meter.ts +42 -24
- package/src/core/portable-text-export.ts +243 -0
- package/src/core/proposals-safety.ts +102 -0
- package/src/core/proposals.ts +357 -0
- package/src/core/public-attributes.ts +30 -0
- package/src/core/recipes/index.ts +2 -2
- package/src/core/render/extras.ts +3 -3
- package/src/core/render/index.ts +222 -23
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/section.ts +4 -4
- package/src/core/render/tabs.ts +18 -11
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +151 -10
- package/src/core/sanitize/motion.ts +116 -0
- package/src/core/saved-sections.ts +6 -0
- package/src/core/schema/descriptors.ts +3 -1
- package/src/core/schema/design.ts +4 -3
- package/src/core/schema/layout.ts +92 -16
- package/src/core/schema/style.ts +296 -112
- package/src/core/search-text.ts +70 -0
- package/src/core/text-marks.ts +227 -0
- package/src/core/theme/dynamic.ts +9 -4
- package/src/core/theme/float.ts +2 -0
- package/src/core/theme/popup-rules.ts +33 -1
- package/src/core/translatable.ts +34 -0
- package/src/core/validate.ts +13 -1
- package/src/index.ts +24 -0
- package/src/mcp/errors.ts +3 -1
- package/src/mcp/ports.ts +67 -0
- package/src/mcp/prompts.ts +1 -11
- package/src/mcp/proposals.ts +281 -0
- package/src/mcp/read.ts +10 -10
- package/src/mcp/tools.ts +71 -3
- package/src/mcp/write.ts +66 -11
- package/src/server/agent-settings.ts +5 -1
- package/src/server/icon-routes.ts +52 -12
- package/src/server/mcp-routes.ts +15 -0
- package/src/server/plugin.ts +35 -2
- package/src/server/presence.ts +78 -0
- package/src/server/proposals.ts +261 -0
- package/src/server/requests.ts +196 -0
- package/src/server/tools-served.ts +45 -0
package/src/core/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./limits.ts";
|
|
2
2
|
export {
|
|
3
3
|
LAYOUT_SCHEMA_VERSION,
|
|
4
|
+
CONTRACT_VERSION,
|
|
5
|
+
cssTypeName,
|
|
4
6
|
Layout,
|
|
5
7
|
type LayoutNode,
|
|
6
8
|
type UnknownNode,
|
|
@@ -10,6 +12,8 @@ export {
|
|
|
10
12
|
SvgNode,
|
|
11
13
|
TabPanelNode,
|
|
12
14
|
HeadingNode,
|
|
15
|
+
MAX_TEXT_MARKS,
|
|
16
|
+
type TextMark,
|
|
13
17
|
SpacerNode,
|
|
14
18
|
DividerNode,
|
|
15
19
|
TextNode,
|
|
@@ -89,10 +93,16 @@ export {
|
|
|
89
93
|
plainTextOf,
|
|
90
94
|
withPlainText,
|
|
91
95
|
} from "./elements/plain-text.ts";
|
|
96
|
+
export { layoutSearchText } from "./search-text.ts";
|
|
92
97
|
export {
|
|
93
98
|
StyleProps,
|
|
99
|
+
FlatStyleProps,
|
|
100
|
+
Motion,
|
|
101
|
+
type StylePatch,
|
|
94
102
|
StyleStates,
|
|
95
103
|
DeviceStyles,
|
|
104
|
+
OwnStyle,
|
|
105
|
+
WideStyle,
|
|
96
106
|
HiddenOn,
|
|
97
107
|
ColorValue,
|
|
98
108
|
Length,
|
|
@@ -100,6 +110,15 @@ export {
|
|
|
100
110
|
VariableRef,
|
|
101
111
|
} from "./schema/style.ts";
|
|
102
112
|
export { STYLE_STATES, type StyleStateName } from "./schema/state-names.ts";
|
|
113
|
+
export {
|
|
114
|
+
flattenMotion,
|
|
115
|
+
nestMotion,
|
|
116
|
+
patchNestedStyle,
|
|
117
|
+
upgradeLegacyNode,
|
|
118
|
+
FLAT_MOTION_KEYS,
|
|
119
|
+
isFlatMotionKey,
|
|
120
|
+
} from "./migrate/v18.ts";
|
|
121
|
+
export { renderableDesign, renderableLayout, renderableNode, renderableStyle } from "./contract.ts";
|
|
103
122
|
export {
|
|
104
123
|
upgradeLayout,
|
|
105
124
|
isNewerThanSupported,
|
|
@@ -201,13 +220,20 @@ export {
|
|
|
201
220
|
type ImportLosses,
|
|
202
221
|
} from "./design/transfer.ts";
|
|
203
222
|
export {
|
|
223
|
+
hiddenOnDevice,
|
|
224
|
+
hiddenOnEveryDevice,
|
|
204
225
|
patchClassDevices,
|
|
226
|
+
patchClassWide,
|
|
205
227
|
patchDeviceStyle,
|
|
228
|
+
patchWideStyle,
|
|
206
229
|
toggleHidden,
|
|
230
|
+
toggleHiddenOn,
|
|
231
|
+
wideHideIsOwn,
|
|
207
232
|
type ResponsiveDevice,
|
|
208
233
|
} from "./design/devices.ts";
|
|
209
234
|
export {
|
|
210
235
|
renderPage,
|
|
236
|
+
sharedPartCss,
|
|
211
237
|
type RenderMode,
|
|
212
238
|
type RenderResult,
|
|
213
239
|
type RenderWarning,
|
|
@@ -361,6 +387,14 @@ export {
|
|
|
361
387
|
clampScrollPercent,
|
|
362
388
|
deviceForWidth,
|
|
363
389
|
POPUP_DEVICES,
|
|
390
|
+
DEVICES,
|
|
391
|
+
type Device,
|
|
392
|
+
EDITOR_DEVICES,
|
|
393
|
+
type EditorDevice,
|
|
394
|
+
WIDE_MIN_PX,
|
|
395
|
+
WIDE_PREVIEW_PX,
|
|
396
|
+
STYLE_DEVICES,
|
|
397
|
+
type StyleDevice,
|
|
364
398
|
DEVICE_MEDIA,
|
|
365
399
|
DEVICE_PREVIEW_PX,
|
|
366
400
|
matchesPopupDevices,
|
|
@@ -534,6 +568,7 @@ export {
|
|
|
534
568
|
insertSavedSection,
|
|
535
569
|
MAX_SAVED_SECTIONS,
|
|
536
570
|
mergeSectionClasses,
|
|
571
|
+
remapClassIds,
|
|
537
572
|
prepareSavedSection,
|
|
538
573
|
readSavedSection,
|
|
539
574
|
SAVED_SECTION_NAME_MAX,
|
|
@@ -549,3 +584,64 @@ export {
|
|
|
549
584
|
syncedPartLayout,
|
|
550
585
|
} from "./saved-sections.ts";
|
|
551
586
|
export { portableTextToLayout } from "./portable-text.ts";
|
|
587
|
+
export {
|
|
588
|
+
type ElementorImport,
|
|
589
|
+
type ImportNote,
|
|
590
|
+
type ImportOptions,
|
|
591
|
+
importElementor,
|
|
592
|
+
MAX_IMPORT_CHARS,
|
|
593
|
+
} from "./import/elementor/index.ts";
|
|
594
|
+
|
|
595
|
+
export {
|
|
596
|
+
EXTENSION_API_VERSION,
|
|
597
|
+
EXTENSION_PLACEHOLDER_TEXT,
|
|
598
|
+
EXTENSION_PLACEHOLDER_CSS,
|
|
599
|
+
defineExtension,
|
|
600
|
+
rememberExtensions,
|
|
601
|
+
listedExtensionManifests,
|
|
602
|
+
liveExtension,
|
|
603
|
+
liveElement,
|
|
604
|
+
clearExtensions,
|
|
605
|
+
manifestsFromOptions,
|
|
606
|
+
isExtensionType,
|
|
607
|
+
parseExtensionType,
|
|
608
|
+
extensionType,
|
|
609
|
+
extensionNamespaceIssue,
|
|
610
|
+
extensionIdIssue,
|
|
611
|
+
extensionNameIssue,
|
|
612
|
+
validateExtensionProps,
|
|
613
|
+
schemaDefaults,
|
|
614
|
+
safeExtensionOutput,
|
|
615
|
+
renderExtensionNode,
|
|
616
|
+
syncSourceValues,
|
|
617
|
+
extensionPlaceholderLabel,
|
|
618
|
+
extensionPlaceholderVNode,
|
|
619
|
+
normalizeExtension,
|
|
620
|
+
type EmVBExtension,
|
|
621
|
+
type ExtensionManifest,
|
|
622
|
+
type ExtensionElement,
|
|
623
|
+
type ExtensionPanel,
|
|
624
|
+
type ExtensionSource,
|
|
625
|
+
type ExtensionPropSchema,
|
|
626
|
+
type ExtensionField,
|
|
627
|
+
type ExtensionElementManifest,
|
|
628
|
+
type ExtensionPanelManifest,
|
|
629
|
+
type ExtensionSourceManifest,
|
|
630
|
+
type ExtensionRenderContext,
|
|
631
|
+
} from "./extensions/index.ts";
|
|
632
|
+
export {
|
|
633
|
+
ProposalTarget,
|
|
634
|
+
readProposal,
|
|
635
|
+
applyProposal,
|
|
636
|
+
type Proposal,
|
|
637
|
+
type ProposalBase,
|
|
638
|
+
type ProposalRecord,
|
|
639
|
+
type ProposalRefusal,
|
|
640
|
+
} from "./proposals.ts";
|
|
641
|
+
export {
|
|
642
|
+
hasFormat,
|
|
643
|
+
type MarkFormat,
|
|
644
|
+
setFormat,
|
|
645
|
+
unsetFormat,
|
|
646
|
+
withShiftedMarks,
|
|
647
|
+
} from "./text-marks.ts";
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DESIGN_SCHEMA_VERSION, DesignSystem } from "./schema/design.ts";
|
|
3
|
+
import { CONTRACT_VERSION, KNOWN_NODE_SCHEMAS, LAYOUT_SCHEMA_VERSION } from "./schema/layout.ts";
|
|
4
|
+
import { DeviceStyles, OwnStyle, StyleProps, StyleStates, WideStyle } from "./schema/style.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JSON Schema (2020-12) exports of the stored formats (W-925, contract 1.0). They describe the
|
|
8
|
+
* keys this version knows; per D-065 a validator also keeps unknown keys on a node, its props
|
|
9
|
+
* and its style records (see docs/SCHEMA.md), so these schemas are stricter than `validateLayout`.
|
|
10
|
+
*/
|
|
11
|
+
const NOTE =
|
|
12
|
+
"EmVB keeps unknown keys on a node, its props and its style records (D-065, limits in docs/SCHEMA.md); this schema lists the known ones only. An element type this version does not know is kept too.";
|
|
13
|
+
|
|
14
|
+
type Json = Record<string, unknown>;
|
|
15
|
+
const toJson = (schema: z.ZodType): Json => {
|
|
16
|
+
const { $schema: _drop, ...rest } = z.toJSONSchema(schema, {
|
|
17
|
+
io: "input",
|
|
18
|
+
unrepresentable: "any",
|
|
19
|
+
}) as Json;
|
|
20
|
+
return rest;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Replaces every sub-schema equal to a shared one with a `$ref` to it, bottom-up. */
|
|
24
|
+
function withRefs(value: unknown, shared: ReadonlyMap<string, string>): unknown {
|
|
25
|
+
if (Array.isArray(value)) return value.map((item) => withRefs(item, shared));
|
|
26
|
+
if (typeof value !== "object" || value === null) return value;
|
|
27
|
+
const ref = shared.get(JSON.stringify(value));
|
|
28
|
+
if (ref) return { $ref: `#/$defs/${ref}` };
|
|
29
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, withRefs(v, shared)]));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The style records every node and class shares, as `$defs`, and the map that refers to them. */
|
|
33
|
+
function styleDefs(): { defs: Json; shared: Map<string, string> } {
|
|
34
|
+
const style = toJson(StyleProps);
|
|
35
|
+
const states = toJson(StyleStates);
|
|
36
|
+
const devices = toJson(DeviceStyles);
|
|
37
|
+
// A state's style is the style without `motion`; one shared definition for all three states.
|
|
38
|
+
const stateStyle = (states["properties"] as Record<string, Json>)["hover"] as Json;
|
|
39
|
+
const inner = new Map([
|
|
40
|
+
[JSON.stringify(style), "style"],
|
|
41
|
+
[JSON.stringify(stateStyle), "stateStyle"],
|
|
42
|
+
]);
|
|
43
|
+
const defs: Json = {
|
|
44
|
+
style,
|
|
45
|
+
stateStyle,
|
|
46
|
+
states: withRefs(states, inner),
|
|
47
|
+
devices: withRefs(devices, inner),
|
|
48
|
+
};
|
|
49
|
+
// W-959: an element's or class's own style carries `wide`, the Wide screen record.
|
|
50
|
+
const wide = toJson(WideStyle);
|
|
51
|
+
const own = toJson(OwnStyle);
|
|
52
|
+
defs["wideStyle"] = wide;
|
|
53
|
+
defs["ownStyle"] = withRefs(own, new Map([[JSON.stringify(wide), "wideStyle"]]));
|
|
54
|
+
const shared = new Map([
|
|
55
|
+
...inner,
|
|
56
|
+
[JSON.stringify(own), "ownStyle"],
|
|
57
|
+
[JSON.stringify(wide), "wideStyle"],
|
|
58
|
+
[JSON.stringify(states), "states"],
|
|
59
|
+
[JSON.stringify(devices), "devices"],
|
|
60
|
+
]);
|
|
61
|
+
return { defs, shared };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function nodeDefs(): { defs: Json; types: string[] } {
|
|
65
|
+
const { defs, shared } = styleDefs();
|
|
66
|
+
const types: string[] = [];
|
|
67
|
+
for (const schema of KNOWN_NODE_SCHEMAS) {
|
|
68
|
+
const shape = (schema as unknown as { shape: Record<string, z.ZodType> }).shape;
|
|
69
|
+
const type = (shape["type"] as unknown as { value: string }).value;
|
|
70
|
+
types.push(type);
|
|
71
|
+
const json = withRefs(toJson(schema as unknown as z.ZodType), shared) as Json;
|
|
72
|
+
const properties = json["properties"] as Json | undefined;
|
|
73
|
+
if (properties && "children" in properties) {
|
|
74
|
+
properties["children"] = { type: "array", items: { $ref: "#/$defs/node" } };
|
|
75
|
+
}
|
|
76
|
+
defs[`node:${type}`] = json;
|
|
77
|
+
}
|
|
78
|
+
defs["node"] = {
|
|
79
|
+
description: "One element. An element type this version does not know is kept (D-065).",
|
|
80
|
+
anyOf: types.map((type) => ({ $ref: `#/$defs/node:${type}` })),
|
|
81
|
+
};
|
|
82
|
+
return { defs, types };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** JSON Schema of a stored layout, for `emvb://schema/layout` (W-467) and docs/schema. */
|
|
86
|
+
export const layoutJsonSchema = (): Json => {
|
|
87
|
+
const { defs } = nodeDefs();
|
|
88
|
+
return {
|
|
89
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
90
|
+
title: `EmVB layout (schema ${LAYOUT_SCHEMA_VERSION}, contract ${CONTRACT_VERSION})`,
|
|
91
|
+
$comment: NOTE,
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
schemaVersion: { type: "number", const: LAYOUT_SCHEMA_VERSION },
|
|
95
|
+
root: { $ref: "#/$defs/node:container" },
|
|
96
|
+
},
|
|
97
|
+
required: ["schemaVersion", "root"],
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
$defs: defs,
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** JSON Schema of the design system (site styles), for `emvb://schema/design`. */
|
|
104
|
+
export const designJsonSchema = (): Json => {
|
|
105
|
+
const { defs, shared } = styleDefs();
|
|
106
|
+
const body = withRefs(toJson(DesignSystem), shared) as Json;
|
|
107
|
+
return {
|
|
108
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
109
|
+
title: `EmVB design system (schema ${DESIGN_SCHEMA_VERSION}, contract ${CONTRACT_VERSION})`,
|
|
110
|
+
$comment: NOTE,
|
|
111
|
+
...body,
|
|
112
|
+
$defs: defs,
|
|
113
|
+
};
|
|
114
|
+
};
|
package/src/core/limits.ts
CHANGED
|
@@ -28,3 +28,22 @@ export function clipText(text: string, max: number): string {
|
|
|
28
28
|
const code = text.charCodeAt(max - 1);
|
|
29
29
|
return text.slice(0, code >= 0xd800 && code <= 0xdbff ? max - 1 : max);
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* D-065 (W-925): a key this version does not know is kept untouched, on a node, its props and
|
|
34
|
+
* its style records only, and never rendered. These bound what such a key may hold.
|
|
35
|
+
*/
|
|
36
|
+
export const UNKNOWN_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_.:/@-]{0,127}$/;
|
|
37
|
+
export const MAX_UNKNOWN_KEYS = 32;
|
|
38
|
+
export const MAX_UNKNOWN_DEPTH = 16;
|
|
39
|
+
|
|
40
|
+
/** W-928: proposals are bounded separately from the resulting page and site styles. */
|
|
41
|
+
export const MAX_PROPOSAL_OPS = 100;
|
|
42
|
+
export const MAX_PROPOSAL_BYTES = MAX_LAYOUT_BYTES;
|
|
43
|
+
export const MAX_PROPOSALS = 100;
|
|
44
|
+
/** W-933: one page can't hold the whole store; an agent withdraws or waits for review. */
|
|
45
|
+
export const MAX_PENDING_PER_PAGE = 10;
|
|
46
|
+
/** W-931: a request to an agent is a short brief, and a page holds a few at a time. */
|
|
47
|
+
export const MAX_REQUEST_PROMPT = 2000;
|
|
48
|
+
export const MAX_OPEN_REQUESTS_PER_PAGE = 5;
|
|
49
|
+
export const MAX_PROPOSAL_DEPTH = MAX_DEPTH * 2 + 16;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isRecord } from "../record.ts";
|
|
2
2
|
import { LAYOUT_SCHEMA_VERSION } from "../schema/layout.ts";
|
|
3
|
+
import { designTo17, layoutTo18 } from "./v18.ts";
|
|
3
4
|
|
|
4
5
|
export type Migration = (doc: Record<string, unknown>) => Record<string, unknown>;
|
|
5
6
|
|
|
@@ -17,7 +18,9 @@ export type Migration = (doc: Record<string, unknown>) => Record<string, unknown
|
|
|
17
18
|
* optional fields only (audience segments, Loop options, `ch` and negative margins), and
|
|
18
19
|
* v14 → v15 (W-341 onward) adds optional fields only (direction, image link and caption,
|
|
19
20
|
* button icons, table of contents, container queries), and layout v15 → v16 (W-481) adds the
|
|
20
|
-
* optional image `edit` record
|
|
21
|
+
* optional image `edit` record, and layout v17 → v18 / design v16 → v17 (W-925, contract 1.0)
|
|
22
|
+
* rename `section` to `part-ref`, a node's `label` to `editorLabel` and a Loop's `itemPartId` to
|
|
23
|
+
* `partId`, and fold the four motion style keys under `motion`. Every other value is unchanged.
|
|
21
24
|
*/
|
|
22
25
|
const unchanged: Migration = (doc) => doc;
|
|
23
26
|
|
|
@@ -78,6 +81,7 @@ export const LAYOUT_MIGRATIONS: Readonly<Record<number, Migration>> = {
|
|
|
78
81
|
14: unchanged,
|
|
79
82
|
15: unchanged,
|
|
80
83
|
16: unchanged,
|
|
84
|
+
17: layoutTo18,
|
|
81
85
|
};
|
|
82
86
|
|
|
83
87
|
/** `DESIGN_MIGRATIONS[n]` upgrades a version-n design document to version n + 1. */
|
|
@@ -97,6 +101,7 @@ export const DESIGN_MIGRATIONS: Readonly<Record<number, Migration>> = {
|
|
|
97
101
|
13: unchanged,
|
|
98
102
|
14: unchanged,
|
|
99
103
|
15: unchanged,
|
|
104
|
+
16: designTo17,
|
|
100
105
|
};
|
|
101
106
|
|
|
102
107
|
export type UpgradeResult =
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { isRecord } from "../record.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Schema 18 / design 17 (W-925, contract 1.0): the renames and the motion fold. Pure and
|
|
5
|
+
* idempotent, so the same helpers also tidy MCP input that still uses the 0.x names.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** The 0.x flat style key for each part of `motion`, in the order the parts are listed. */
|
|
9
|
+
const MOTION_PARTS = {
|
|
10
|
+
entrance: "entrance",
|
|
11
|
+
scroll: "scrollMotion",
|
|
12
|
+
transition: "transition",
|
|
13
|
+
icon: "iconAnimation",
|
|
14
|
+
// W-938: added in 1.0; the flat key exists only inside EmVB (style rows, CSS).
|
|
15
|
+
loop: "loopMotion",
|
|
16
|
+
} as const;
|
|
17
|
+
export type MotionPart = keyof typeof MOTION_PARTS;
|
|
18
|
+
export type FlatMotionKey = (typeof MOTION_PARTS)[MotionPart];
|
|
19
|
+
|
|
20
|
+
const PART_OF: Readonly<Record<string, MotionPart>> = {
|
|
21
|
+
entrance: "entrance",
|
|
22
|
+
scrollMotion: "scroll",
|
|
23
|
+
transition: "transition",
|
|
24
|
+
iconAnimation: "icon",
|
|
25
|
+
loopMotion: "loop",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const FLAT_MOTION_KEYS: readonly FlatMotionKey[] = Object.values(MOTION_PARTS);
|
|
29
|
+
|
|
30
|
+
export function isFlatMotionKey(key: string): key is FlatMotionKey {
|
|
31
|
+
return Object.hasOwn(PART_OF, key);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The `motion` part a 0.x flat key became, e.g. `scrollMotion` → `scroll`. */
|
|
35
|
+
function motionPartOf(key: FlatMotionKey): MotionPart {
|
|
36
|
+
return PART_OF[key] as MotionPart;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 0.x flat style → nested. `motion` takes the place of the first motion key and keeps the
|
|
41
|
+
* parts in the order they were written, so the CSS comes out in the same order whenever the
|
|
42
|
+
* motion keys were next to each other. A style with no motion key is returned as is.
|
|
43
|
+
*/
|
|
44
|
+
export function nestMotion<T>(style: T): T {
|
|
45
|
+
if (!isRecord(style)) return style;
|
|
46
|
+
if (!Object.keys(style).some(isFlatMotionKey)) return style;
|
|
47
|
+
const out: Record<string, unknown> = {};
|
|
48
|
+
const existing = isRecord(style["motion"]) ? style["motion"] : undefined;
|
|
49
|
+
let motion: Record<string, unknown> | undefined;
|
|
50
|
+
for (const [key, value] of Object.entries(style)) {
|
|
51
|
+
if (key === "motion") {
|
|
52
|
+
if (!motion) motion = out["motion"] = { ...existing };
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!isFlatMotionKey(key)) {
|
|
56
|
+
out[key] = value;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (!motion) motion = out["motion"] = { ...existing };
|
|
60
|
+
const part = motionPartOf(key);
|
|
61
|
+
if (!(part in motion)) motion[part] = value;
|
|
62
|
+
}
|
|
63
|
+
return out as T;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Nested → flat, for the renderer and the editor's style rows, which name the parts by their
|
|
68
|
+
* 0.x keys. The parts take `motion`'s place. Idempotent: a style already flat comes back as is,
|
|
69
|
+
* so cascades and helpers can flatten whatever they are handed. With `motion` present, its
|
|
70
|
+
* parts win over stray top-level 0.x keys (those are unknown keys in a schema-18 document;
|
|
71
|
+
* `withoutStrayMotionKeys` drops them where stored documents are read for rendering).
|
|
72
|
+
*/
|
|
73
|
+
export function flattenMotion<T>(style: T): T {
|
|
74
|
+
if (!isRecord(style)) return style;
|
|
75
|
+
if (!("motion" in style)) return style;
|
|
76
|
+
const out: Record<string, unknown> = {};
|
|
77
|
+
for (const [key, value] of Object.entries(style)) {
|
|
78
|
+
if (isFlatMotionKey(key)) continue;
|
|
79
|
+
if (key !== "motion") {
|
|
80
|
+
out[key] = value;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (!isRecord(value)) continue;
|
|
84
|
+
for (const [part, partValue] of Object.entries(value)) {
|
|
85
|
+
const flat = Object.hasOwn(MOTION_PARTS, part) ? MOTION_PARTS[part as MotionPart] : undefined;
|
|
86
|
+
if (flat && partValue !== undefined) out[flat] = partValue;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return out as T;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A stored (schema-18) style without top-level 0.x motion keys: there they are unknown keys
|
|
94
|
+
* (D-065), kept in the document but never rendered.
|
|
95
|
+
*/
|
|
96
|
+
export function withoutStrayMotionKeys<T>(style: T): T {
|
|
97
|
+
if (!isRecord(style) || !Object.keys(style).some(isFlatMotionKey)) return style;
|
|
98
|
+
const out: Record<string, unknown> = {};
|
|
99
|
+
for (const [key, value] of Object.entries(style)) if (!isFlatMotionKey(key)) out[key] = value;
|
|
100
|
+
return out as T;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Applies a flat style patch (0.x key names, `undefined` clears) to a stored, nested style.
|
|
105
|
+
* Keys the patch does not name are kept as they are, unknown ones included (D-065).
|
|
106
|
+
*/
|
|
107
|
+
export function patchNestedStyle(
|
|
108
|
+
stored: Readonly<Record<string, unknown>> | undefined,
|
|
109
|
+
patch: Readonly<Record<string, unknown>>,
|
|
110
|
+
): Record<string, unknown> {
|
|
111
|
+
const out: Record<string, unknown> = { ...stored };
|
|
112
|
+
let motion: Record<string, unknown> | undefined = isRecord(out["motion"])
|
|
113
|
+
? { ...out["motion"] }
|
|
114
|
+
: undefined;
|
|
115
|
+
let touchedMotion = false;
|
|
116
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
117
|
+
if (key === "motion") {
|
|
118
|
+
motion = isRecord(value) ? { ...value } : undefined;
|
|
119
|
+
touchedMotion = true;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (isFlatMotionKey(key)) {
|
|
123
|
+
const part = motionPartOf(key);
|
|
124
|
+
motion ??= {};
|
|
125
|
+
if (value === undefined) delete motion[part];
|
|
126
|
+
else motion[part] = value;
|
|
127
|
+
touchedMotion = true;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (value === undefined) delete out[key];
|
|
131
|
+
else out[key] = value;
|
|
132
|
+
}
|
|
133
|
+
if (touchedMotion) {
|
|
134
|
+
if (motion && Object.keys(motion).length > 0) out["motion"] = motion;
|
|
135
|
+
else delete out["motion"];
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function foldDevices(devices: unknown): unknown {
|
|
141
|
+
if (!isRecord(devices)) return devices;
|
|
142
|
+
const out: Record<string, unknown> = { ...devices };
|
|
143
|
+
for (const device of ["laptop", "tablet", "mobile"]) {
|
|
144
|
+
if (device in out) out[device] = nestMotion(out[device]);
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* One 0.x node (and its children) in schema-18 names: `section` → `part-ref`, node `label` →
|
|
151
|
+
* `editorLabel`, a Loop's `itemPartId` → `partId`, and motion folded under `motion`. An
|
|
152
|
+
* already-current node comes back equal. Never mutates the input.
|
|
153
|
+
*/
|
|
154
|
+
export function upgradeLegacyNode(node: unknown): unknown {
|
|
155
|
+
if (!isRecord(node)) return node;
|
|
156
|
+
const out: Record<string, unknown> = {};
|
|
157
|
+
for (const [key, value] of Object.entries(node)) {
|
|
158
|
+
if (key === "label" && !("editorLabel" in node)) out["editorLabel"] = value;
|
|
159
|
+
else if (key === "type" && value === "section") out[key] = "part-ref";
|
|
160
|
+
else if (key === "style") out[key] = nestMotion(value);
|
|
161
|
+
else if (key === "devices") out[key] = foldDevices(value);
|
|
162
|
+
else if (key === "query" && isRecord(value))
|
|
163
|
+
out[key] = "style" in value ? { ...value, style: nestMotion(value["style"]) } : value;
|
|
164
|
+
else if (key === "children" && Array.isArray(value))
|
|
165
|
+
out[key] = value.map((child) => upgradeLegacyNode(child));
|
|
166
|
+
else out[key] = value;
|
|
167
|
+
}
|
|
168
|
+
if (out["type"] === "loop" && isRecord(out["props"]) && "itemPartId" in out["props"]) {
|
|
169
|
+
const props: Record<string, unknown> = {};
|
|
170
|
+
for (const [key, value] of Object.entries(out["props"])) {
|
|
171
|
+
if (key !== "itemPartId") props[key] = value;
|
|
172
|
+
else if (!("partId" in out["props"])) props["partId"] = value;
|
|
173
|
+
}
|
|
174
|
+
out["props"] = props;
|
|
175
|
+
}
|
|
176
|
+
return out;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* W-956: before Laptop, "hidden on Desktop" covered every screen from 1025 px, laptops included;
|
|
181
|
+
* a stored 0.x element hidden on Desktop is hidden on Laptop too, so it renders as before.
|
|
182
|
+
*/
|
|
183
|
+
function hiddenWithLaptop(hiddenOn: unknown): unknown {
|
|
184
|
+
if (!Array.isArray(hiddenOn) || !hiddenOn.includes("desktop") || hiddenOn.includes("laptop"))
|
|
185
|
+
return hiddenOn;
|
|
186
|
+
const at = hiddenOn.indexOf("desktop");
|
|
187
|
+
return [...hiddenOn.slice(0, at + 1), "laptop", ...hiddenOn.slice(at + 1)];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function laptopHidden(node: unknown): unknown {
|
|
191
|
+
if (!isRecord(node)) return node;
|
|
192
|
+
const out: Record<string, unknown> = { ...node };
|
|
193
|
+
if ("hiddenOn" in node) out["hiddenOn"] = hiddenWithLaptop(node["hiddenOn"]);
|
|
194
|
+
if (Array.isArray(node["children"])) out["children"] = node["children"].map(laptopHidden);
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Layout v17 → v18. */
|
|
199
|
+
export function layoutTo18(doc: Record<string, unknown>): Record<string, unknown> {
|
|
200
|
+
return "root" in doc ? { ...doc, root: laptopHidden(upgradeLegacyNode(doc["root"])) } : doc;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Design v16 → v17: motion folded in classes (style and devices) and tag defaults. */
|
|
204
|
+
export function designTo17(doc: Record<string, unknown>): Record<string, unknown> {
|
|
205
|
+
const out: Record<string, unknown> = { ...doc };
|
|
206
|
+
if (Array.isArray(doc["classes"])) {
|
|
207
|
+
out["classes"] = doc["classes"].map((cls: unknown) => {
|
|
208
|
+
if (!isRecord(cls)) return cls;
|
|
209
|
+
const next: Record<string, unknown> = { ...cls };
|
|
210
|
+
if ("style" in cls) next["style"] = nestMotion(cls["style"]);
|
|
211
|
+
if ("devices" in cls) next["devices"] = foldDevices(cls["devices"]);
|
|
212
|
+
if ("hiddenOn" in cls) next["hiddenOn"] = hiddenWithLaptop(cls["hiddenOn"]);
|
|
213
|
+
return next;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (isRecord(doc["defaults"])) {
|
|
217
|
+
const defaults: Record<string, unknown> = {};
|
|
218
|
+
for (const [tag, style] of Object.entries(doc["defaults"])) defaults[tag] = nestMotion(style);
|
|
219
|
+
out["defaults"] = defaults;
|
|
220
|
+
}
|
|
221
|
+
return out;
|
|
222
|
+
}
|
package/src/core/perf/meter.ts
CHANGED
|
@@ -74,53 +74,71 @@ const isPlayerEmbed = (node: LayoutNode): boolean => {
|
|
|
74
74
|
return typeof url === "string" && resolveEmbedUrl(url)?.kind === "iframe";
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
type Weight = { images: number; bytes: number; embeds: number };
|
|
78
|
+
const zero = (): Weight => ({ images: 0, bytes: 0, embeds: 0 });
|
|
79
|
+
const add = (a: Weight, b: Weight) => {
|
|
80
|
+
a.images += b.images;
|
|
81
|
+
a.bytes += b.bytes;
|
|
82
|
+
a.embeds += b.embeds;
|
|
83
|
+
};
|
|
84
|
+
|
|
77
85
|
/** Images and embeds under a node, with their estimated weight. */
|
|
78
|
-
function media(
|
|
79
|
-
node: LayoutNode,
|
|
80
|
-
bgClasses: Set<string>,
|
|
81
|
-
dynamic?: ThemeDynamicData,
|
|
82
|
-
): { images: number; bytes: number; embeds: number } {
|
|
83
|
-
let images = 0;
|
|
84
|
-
let bytes = 0;
|
|
85
|
-
let embeds = 0;
|
|
86
|
+
function media(node: LayoutNode, bgClasses: Set<string>, dynamic?: ThemeDynamicData): Weight {
|
|
86
87
|
const seen = new Set<Layout>();
|
|
87
88
|
/** W-671: a synced section or Loop Item part the canvas loaded is weighed with the page. */
|
|
88
89
|
const part = (n: LayoutNode): Layout | undefined => {
|
|
89
|
-
const props = n.props as { partId?: unknown
|
|
90
|
+
const props = n.props as { partId?: unknown };
|
|
90
91
|
const found =
|
|
91
|
-
n.type === "
|
|
92
|
+
n.type === "part-ref" && typeof props.partId === "string"
|
|
92
93
|
? dynamic?.sectionTemplates?.[props.partId.trim()]
|
|
93
|
-
: n.type === "loop" && typeof props.
|
|
94
|
-
? dynamic?.loopTemplates?.[props.
|
|
94
|
+
: n.type === "loop" && typeof props.partId === "string"
|
|
95
|
+
? dynamic?.loopTemplates?.[props.partId.trim()]
|
|
95
96
|
: undefined;
|
|
96
97
|
if (!found || seen.has(found)) return undefined;
|
|
97
98
|
seen.add(found);
|
|
98
99
|
return found;
|
|
99
100
|
};
|
|
100
|
-
|
|
101
|
+
// W-973: a visitor sees one arm of an A/B test, so only the heavier arm's media count.
|
|
102
|
+
const arms = new Map<string, Map<string, Weight>>();
|
|
103
|
+
const walk = (n: LayoutNode): Weight => {
|
|
104
|
+
const own = zero();
|
|
101
105
|
const template = part(n);
|
|
102
|
-
if (template) walk(template.root);
|
|
106
|
+
if (template) add(own, walk(template.root));
|
|
103
107
|
if (n.type === "image" || n.type === "post-image") {
|
|
104
108
|
const src = (n.props as { src?: unknown }).src;
|
|
105
109
|
if (n.type === "post-image" || (typeof src === "string" && src.trim())) {
|
|
106
|
-
images += 1;
|
|
107
|
-
bytes += imageBytes(n);
|
|
110
|
+
own.images += 1;
|
|
111
|
+
own.bytes += imageBytes(n);
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
if (hasBackgroundImage(n, bgClasses)) {
|
|
111
|
-
images += 1;
|
|
112
|
-
bytes += IMAGE_GUESS;
|
|
115
|
+
own.images += 1;
|
|
116
|
+
own.bytes += IMAGE_GUESS;
|
|
113
117
|
}
|
|
114
118
|
// W-508: only a YouTube or Vimeo player is a third-party embed; a media-library video loads
|
|
115
119
|
// its metadata only, and a missing or refused URL renders nothing.
|
|
116
120
|
if (n.type === "video" && isPlayerEmbed(n)) {
|
|
117
|
-
embeds += 1;
|
|
118
|
-
bytes += EMBED_BYTES;
|
|
121
|
+
own.embeds += 1;
|
|
122
|
+
own.bytes += EMBED_BYTES;
|
|
119
123
|
}
|
|
120
|
-
if (isParentNode(n)) for (const child of n.children) walk(child);
|
|
124
|
+
if (isParentNode(n)) for (const child of n.children) add(own, walk(child));
|
|
125
|
+
const variant = n.variant;
|
|
126
|
+
if (variant) {
|
|
127
|
+
const test = arms.get(variant.test) ?? new Map<string, Weight>();
|
|
128
|
+
const arm = test.get(variant.arm) ?? zero();
|
|
129
|
+
add(arm, own);
|
|
130
|
+
test.set(variant.arm, arm);
|
|
131
|
+
arms.set(variant.test, test);
|
|
132
|
+
return zero();
|
|
133
|
+
}
|
|
134
|
+
return own;
|
|
121
135
|
};
|
|
122
|
-
walk(node);
|
|
123
|
-
|
|
136
|
+
const total = walk(node);
|
|
137
|
+
for (const test of arms.values()) {
|
|
138
|
+
const heaviest = [...test.values()].reduce((a, b) => (b.bytes > a.bytes ? b : a), zero());
|
|
139
|
+
add(total, heaviest);
|
|
140
|
+
}
|
|
141
|
+
return total;
|
|
124
142
|
}
|
|
125
143
|
|
|
126
144
|
const kb = (bytes: number) => `${Math.round(bytes / 1000)} KB`;
|
|
@@ -161,7 +179,7 @@ export function measurePage(
|
|
|
161
179
|
sections.push({
|
|
162
180
|
id: child.id,
|
|
163
181
|
type: child.type,
|
|
164
|
-
...(child.
|
|
182
|
+
...(child.editorLabel ? { label: child.editorLabel } : {}),
|
|
165
183
|
bytes: Math.round(utf8(one.html) * GZIP) + m.bytes,
|
|
166
184
|
images: m.images,
|
|
167
185
|
});
|