@perkyzz/emvb-mcp 0.5.0 → 0.7.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 +1 -1
- package/dist/cli.mjs +1321 -190
- package/package.json +2 -2
- package/skill/emvb-page-builder/SKILL.md +9 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/iso.js
|
|
18
|
+
var exports_iso = {};
|
|
19
|
+
__export(exports_iso, {
|
|
20
|
+
ZodISODate: () => ZodISODate,
|
|
21
|
+
ZodISODateTime: () => ZodISODateTime,
|
|
22
|
+
ZodISODuration: () => ZodISODuration,
|
|
23
|
+
ZodISOTime: () => ZodISOTime,
|
|
24
|
+
date: () => date2,
|
|
25
|
+
datetime: () => datetime2,
|
|
26
|
+
duration: () => duration2,
|
|
27
|
+
time: () => time2
|
|
28
|
+
});
|
|
2
29
|
|
|
3
30
|
// src/token-file.ts
|
|
4
31
|
import { readFileSync, statSync } from "node:fs";
|
|
@@ -21,9 +48,11 @@ function parseOptions(argv, env, readFile) {
|
|
|
21
48
|
site = argv[++i];
|
|
22
49
|
else if (arg?.startsWith("--site="))
|
|
23
50
|
site = arg.slice(7);
|
|
24
|
-
else if (arg === "--token-file")
|
|
51
|
+
else if (arg === "--token-file") {
|
|
25
52
|
tokenFile = argv[++i];
|
|
26
|
-
|
|
53
|
+
if (!tokenFile || tokenFile.startsWith("--"))
|
|
54
|
+
throw new OptionsError("--token-file needs a path.");
|
|
55
|
+
} else if (arg === "--allow-publish")
|
|
27
56
|
allowPublish = true;
|
|
28
57
|
else if (arg === "--token" || arg?.startsWith("--token=")) {
|
|
29
58
|
throw new OptionsError("Pass the token in EMVB_TOKEN or --token-file, never on the command line.");
|
|
@@ -52,6 +81,9 @@ ${USAGE}`);
|
|
|
52
81
|
throw new OptionsError(`No token: set EMVB_TOKEN or pass --token-file.
|
|
53
82
|
|
|
54
83
|
${USAGE}`);
|
|
84
|
+
if (/[^!-~]/.test(token)) {
|
|
85
|
+
throw new OptionsError(`The token has a space or line break in it. ${tokenFile ? `${tokenFile} must hold only the token, on one line.` : "EMVB_TOKEN must hold only the token."}`);
|
|
86
|
+
}
|
|
55
87
|
return {
|
|
56
88
|
site: new URL(url.origin),
|
|
57
89
|
endpoint: new URL("/_emdash/api/mcp", url.origin),
|
|
@@ -2591,6 +2623,119 @@ function handleIntersectionResults(result, left, right) {
|
|
|
2591
2623
|
result.value = merged.data;
|
|
2592
2624
|
return result;
|
|
2593
2625
|
}
|
|
2626
|
+
var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
2627
|
+
$ZodType.init(inst, def);
|
|
2628
|
+
const items = def.items;
|
|
2629
|
+
const memo = globalConfig.memoizer;
|
|
2630
|
+
memo?.attach(inst);
|
|
2631
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2632
|
+
const input = payload.value;
|
|
2633
|
+
if (!Array.isArray(input)) {
|
|
2634
|
+
payload.issues.push({
|
|
2635
|
+
input,
|
|
2636
|
+
inst,
|
|
2637
|
+
expected: "tuple",
|
|
2638
|
+
code: "invalid_type"
|
|
2639
|
+
});
|
|
2640
|
+
return payload;
|
|
2641
|
+
}
|
|
2642
|
+
payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
|
|
2643
|
+
const proms = [];
|
|
2644
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
2645
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
2646
|
+
if (!def.rest) {
|
|
2647
|
+
if (input.length < optinStart) {
|
|
2648
|
+
payload.issues.push({
|
|
2649
|
+
code: "too_small",
|
|
2650
|
+
minimum: optinStart,
|
|
2651
|
+
inclusive: true,
|
|
2652
|
+
input,
|
|
2653
|
+
inst,
|
|
2654
|
+
origin: "array"
|
|
2655
|
+
});
|
|
2656
|
+
return payload;
|
|
2657
|
+
}
|
|
2658
|
+
if (input.length > items.length) {
|
|
2659
|
+
payload.issues.push({
|
|
2660
|
+
code: "too_big",
|
|
2661
|
+
maximum: items.length,
|
|
2662
|
+
inclusive: true,
|
|
2663
|
+
input,
|
|
2664
|
+
inst,
|
|
2665
|
+
origin: "array"
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
const itemResults = new Array(items.length);
|
|
2670
|
+
for (let i = 0;i < items.length; i++) {
|
|
2671
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
2672
|
+
if (r instanceof Promise) {
|
|
2673
|
+
proms.push(r.then((rr) => {
|
|
2674
|
+
itemResults[i] = rr;
|
|
2675
|
+
}));
|
|
2676
|
+
} else {
|
|
2677
|
+
itemResults[i] = r;
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
if (def.rest) {
|
|
2681
|
+
let i = items.length - 1;
|
|
2682
|
+
const rest = input.slice(items.length);
|
|
2683
|
+
for (const el of rest) {
|
|
2684
|
+
i++;
|
|
2685
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
2686
|
+
if (result instanceof Promise) {
|
|
2687
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
2688
|
+
} else {
|
|
2689
|
+
handleTupleResult(result, payload, i);
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
if (proms.length) {
|
|
2694
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
2695
|
+
}
|
|
2696
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
2697
|
+
};
|
|
2698
|
+
});
|
|
2699
|
+
function getTupleOptStart(items, key) {
|
|
2700
|
+
for (let i = items.length - 1;i >= 0; i--) {
|
|
2701
|
+
const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
|
|
2702
|
+
if (!omittable)
|
|
2703
|
+
return i + 1;
|
|
2704
|
+
}
|
|
2705
|
+
return 0;
|
|
2706
|
+
}
|
|
2707
|
+
function handleTupleResult(result, final, index) {
|
|
2708
|
+
if (result.issues.length) {
|
|
2709
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
2710
|
+
}
|
|
2711
|
+
final.value[index] = result.value;
|
|
2712
|
+
}
|
|
2713
|
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
2714
|
+
for (let i = 0;i < items.length; i++) {
|
|
2715
|
+
const r = itemResults[i];
|
|
2716
|
+
const isPresent = i < input.length;
|
|
2717
|
+
if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
|
|
2718
|
+
final.value.length = i;
|
|
2719
|
+
break;
|
|
2720
|
+
}
|
|
2721
|
+
if (r.issues.length) {
|
|
2722
|
+
if (!isPresent && i >= optoutStart) {
|
|
2723
|
+
final.value.length = i;
|
|
2724
|
+
break;
|
|
2725
|
+
}
|
|
2726
|
+
final.issues.push(...prefixIssues(i, r.issues));
|
|
2727
|
+
}
|
|
2728
|
+
final.value[i] = r.value;
|
|
2729
|
+
}
|
|
2730
|
+
for (let i = final.value.length - 1;i >= input.length; i--) {
|
|
2731
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
2732
|
+
final.value.length = i;
|
|
2733
|
+
} else {
|
|
2734
|
+
break;
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
return final;
|
|
2738
|
+
}
|
|
2594
2739
|
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
2595
2740
|
$ZodType.init(inst, def);
|
|
2596
2741
|
const memo = globalConfig.memoizer;
|
|
@@ -2987,6 +3132,9 @@ function handlePipeResult(left, next, ctx) {
|
|
|
2987
3132
|
}
|
|
2988
3133
|
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
2989
3134
|
}
|
|
3135
|
+
var $ZodPreprocess = /* @__PURE__ */ $constructor("$ZodPreprocess", (inst, def) => {
|
|
3136
|
+
$ZodPipe.init(inst, def);
|
|
3137
|
+
});
|
|
2990
3138
|
var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
2991
3139
|
$ZodType.init(inst, def);
|
|
2992
3140
|
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
@@ -5781,6 +5929,39 @@ function intersection(left, right) {
|
|
|
5781
5929
|
right
|
|
5782
5930
|
});
|
|
5783
5931
|
}
|
|
5932
|
+
var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
5933
|
+
_ensureDefaultMemoizer();
|
|
5934
|
+
$ZodTuple.init(inst, def);
|
|
5935
|
+
ZodType.init(inst, def);
|
|
5936
|
+
inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
|
|
5937
|
+
}, {
|
|
5938
|
+
rest(rest) {
|
|
5939
|
+
return this.clone({
|
|
5940
|
+
...this._zod.def,
|
|
5941
|
+
rest
|
|
5942
|
+
});
|
|
5943
|
+
},
|
|
5944
|
+
partial() {
|
|
5945
|
+
const def = this._zod.def;
|
|
5946
|
+
if (def.checks?.length)
|
|
5947
|
+
throw new Error(".partial() cannot be used on tuple schemas containing refinements");
|
|
5948
|
+
return this.clone({
|
|
5949
|
+
...def,
|
|
5950
|
+
items: def.items.map((item) => new ZodOptional({ type: "optional", innerType: item }))
|
|
5951
|
+
});
|
|
5952
|
+
}
|
|
5953
|
+
});
|
|
5954
|
+
function tuple(items, _paramsOrRest, _params) {
|
|
5955
|
+
const hasRest = _paramsOrRest instanceof $ZodType;
|
|
5956
|
+
const params = hasRest ? _params : _paramsOrRest;
|
|
5957
|
+
const rest = hasRest ? _paramsOrRest : null;
|
|
5958
|
+
return new ZodTuple({
|
|
5959
|
+
type: "tuple",
|
|
5960
|
+
items,
|
|
5961
|
+
rest,
|
|
5962
|
+
...normalizeParams(params)
|
|
5963
|
+
});
|
|
5964
|
+
}
|
|
5784
5965
|
var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
5785
5966
|
_ensureDefaultMemoizer();
|
|
5786
5967
|
$ZodRecord.init(inst, def);
|
|
@@ -6020,6 +6201,10 @@ function pipe(in_, out) {
|
|
|
6020
6201
|
out
|
|
6021
6202
|
});
|
|
6022
6203
|
}
|
|
6204
|
+
var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
|
|
6205
|
+
ZodPipe.init(inst, def);
|
|
6206
|
+
$ZodPreprocess.init(inst, def);
|
|
6207
|
+
});
|
|
6023
6208
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
6024
6209
|
$ZodReadonly.init(inst, def);
|
|
6025
6210
|
ZodType.init(inst, def);
|
|
@@ -6055,8 +6240,28 @@ function refine(fn, _params = {}) {
|
|
|
6055
6240
|
function superRefine(fn, params) {
|
|
6056
6241
|
return _superRefine(fn, params);
|
|
6057
6242
|
}
|
|
6243
|
+
function preprocess(fn, schema) {
|
|
6244
|
+
return new ZodPreprocess({
|
|
6245
|
+
type: "pipe",
|
|
6246
|
+
in: transform(fn),
|
|
6247
|
+
out: schema
|
|
6248
|
+
});
|
|
6249
|
+
}
|
|
6250
|
+
// ../../node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/iso.js
|
|
6251
|
+
function datetime2(params) {
|
|
6252
|
+
return _isoDateTime(ZodISODateTime, params);
|
|
6253
|
+
}
|
|
6254
|
+
function date2(params) {
|
|
6255
|
+
return _isoDate(ZodISODate, params);
|
|
6256
|
+
}
|
|
6257
|
+
function time2(params) {
|
|
6258
|
+
return _isoTime(ZodISOTime, params);
|
|
6259
|
+
}
|
|
6260
|
+
function duration2(params) {
|
|
6261
|
+
return _isoDuration(ZodISODuration, params);
|
|
6262
|
+
}
|
|
6058
6263
|
// ../../docs/system/layout-format.md
|
|
6059
|
-
var layout_format_default = "# Layout format (schema 15)\n\nHow EmVB stores a page and its site-wide design, at schema 15 (per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 15,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `15` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId` | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\") | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear infinite`, `emvb-icon-pulse <ms> ease-in-out infinite alternate` or `none`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `transition`, `entrance`, `iconAnimation` and `scrollMotion`, which belong to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `transition` inside a state is dropped and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"tablet\"?, \"mobile\"? }`. Each is a style object with the same keys as `style`. Only keys that differ from desktop are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Tablet is `@media (max-width: 1024px)`, then mobile `@media (max-width: 767px)`. A phone matches both, so mobile wins on a shared key, and a tablet-only key still applies on mobile. The bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1025px)`, tablet `(min-width: 768px) and (max-width: 1024px)`, mobile `(max-width: 767px)`.\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 15,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no `data-emvb-*` attributes and no scripts.\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n";
|
|
6264
|
+
var layout_format_default = "# Layout format (schema 16)\n\nHow EmVB stores a page and its site-wide design, at schema 16 (the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 16,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `16` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` (words the empty first choice; unset is \"Choose…\", W-686) | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\"), `titleText` (the paged archive title, `{title}` and `{page}`, W-529), `archiveTitle` (replaces \"Posts\" as the posts archive title, ≤ 60, W-532), and screen reader names `navLabel` (\"Pagination\"), `pageLabel` (\"Page {page}\"), `prevLabel` and `nextLabel` (\"Previous page\" / \"Next page\", used when the text is only an arrow), each ≤ 60 (W-689) | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear infinite`, `emvb-icon-pulse <ms> ease-in-out infinite alternate` or `none`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `transition`, `entrance`, `iconAnimation` and `scrollMotion`, which belong to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `transition` inside a state is dropped and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"tablet\"?, \"mobile\"? }`. Each is a style object with the same keys as `style`. Only keys that differ from desktop are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Tablet is `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A phone matches both, so mobile wins on a shared key, and a tablet-only key still applies on mobile. The bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1025px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 15,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no `data-emvb-*` attributes and no scripts.\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n";
|
|
6060
6265
|
|
|
6061
6266
|
// skill/emvb-page-builder/SKILL.md
|
|
6062
6267
|
var SKILL_default = `---
|
|
@@ -6093,7 +6298,8 @@ instructions.
|
|
|
6093
6298
|
6. **Check accessibility** with \`get_accessibility_findings\` after building and fix every
|
|
6094
6299
|
error. Contrast findings that share one colour: change that colour variable once.
|
|
6095
6300
|
7. **Don't publish** unless the person asked and \`publish_page\` is available. End with
|
|
6096
|
-
\`describe_page\` and a short summary so they can review the draft.
|
|
6301
|
+
\`describe_page\` and a short summary so they can review the draft. Fix its warnings too (an
|
|
6302
|
+
element hidden on every device, a form's required field with no field on the form).
|
|
6097
6303
|
|
|
6098
6304
|
## What the tools can't do
|
|
6099
6305
|
|
|
@@ -6113,7 +6319,13 @@ instructions.
|
|
|
6113
6319
|
value; \`list_element_types\` with the type shows its props, allowed parents and notes.
|
|
6114
6320
|
- \`NESTING\` / \`REFUSED\`: the element can't go there, or the id doesn't exist; re-read the outline.
|
|
6115
6321
|
- \`TOO_LARGE\`: the page is over 512 KB; split it.
|
|
6116
|
-
- \`REFUSED\` on removing a variable:
|
|
6322
|
+
- \`REFUSED\` on removing a variable or class: a page still uses it (the message names the pages);
|
|
6323
|
+
replace those references first. Pass \`force: true\` only if the person asked.
|
|
6324
|
+
- An image \`src\` must be an http(s) URL or a path on the site; \`javascript:\`, \`data:\` and
|
|
6325
|
+
\`//host\` sources are refused.
|
|
6326
|
+
- \`REFUSED\` on a link or an SVG: the page would drop it (a \`javascript:\` link, \`onload\` or a
|
|
6327
|
+
script in SVG markup); the message gives the reason. A class or variable name another one
|
|
6328
|
+
already has is refused too. A write that changes nothing saves no new version.
|
|
6117
6329
|
- \`PUBLISH_DISABLED\`: leave the draft for review.
|
|
6118
6330
|
- \`FORBIDDEN\`: agent access is off on the site, or the token can't use EmVB; tell the person.
|
|
6119
6331
|
- \`NOT_SET_UP\`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.
|
|
@@ -6207,6 +6419,116 @@ var MAX_DEPTH = 24;
|
|
|
6207
6419
|
var MAX_NODES = 2000;
|
|
6208
6420
|
var MAX_TEXT_LENGTH = 2000;
|
|
6209
6421
|
var MAX_TABS = 12;
|
|
6422
|
+
function clipText(text, max) {
|
|
6423
|
+
if (text.length <= max)
|
|
6424
|
+
return text;
|
|
6425
|
+
if (typeof Intl !== "undefined" && "Segmenter" in Intl) {
|
|
6426
|
+
let end = 0;
|
|
6427
|
+
for (const { segment } of new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text.slice(0, max + 32))) {
|
|
6428
|
+
if (end + segment.length > max)
|
|
6429
|
+
break;
|
|
6430
|
+
end += segment.length;
|
|
6431
|
+
}
|
|
6432
|
+
return text.slice(0, end);
|
|
6433
|
+
}
|
|
6434
|
+
const code = text.charCodeAt(max - 1);
|
|
6435
|
+
return text.slice(0, code >= 55296 && code <= 56319 ? max - 1 : max);
|
|
6436
|
+
}
|
|
6437
|
+
// ../emvb/src/core/image-edit/schema.ts
|
|
6438
|
+
var IMAGE_EDIT_RECIPE_MAX_BYTES = 16 * 1024;
|
|
6439
|
+
var IMAGE_EDIT_CURVE_POINTS_MAX = 32;
|
|
6440
|
+
var Slider = number2().finite().min(-1).max(1);
|
|
6441
|
+
var Unit = number2().finite().min(0).max(1);
|
|
6442
|
+
var Lights = strictObject({
|
|
6443
|
+
brightness: Slider,
|
|
6444
|
+
exposure: Slider,
|
|
6445
|
+
gamma: Slider,
|
|
6446
|
+
contrast: Slider,
|
|
6447
|
+
shadows: Slider,
|
|
6448
|
+
highlights: Slider,
|
|
6449
|
+
bloom: Slider
|
|
6450
|
+
}).partial();
|
|
6451
|
+
var Colors = strictObject({
|
|
6452
|
+
temperature: Slider,
|
|
6453
|
+
tint: Slider,
|
|
6454
|
+
vibrance: Slider,
|
|
6455
|
+
saturation: Slider,
|
|
6456
|
+
sepia: Slider
|
|
6457
|
+
}).partial();
|
|
6458
|
+
var Effects = strictObject({ clarity: Slider, noise: Slider, vignette: Slider }).partial();
|
|
6459
|
+
var Blur = strictObject({
|
|
6460
|
+
bokehstrength: Unit,
|
|
6461
|
+
bokehlensout: Unit,
|
|
6462
|
+
gaussianstrength: Unit,
|
|
6463
|
+
gaussianlensout: Unit,
|
|
6464
|
+
centerX: Unit,
|
|
6465
|
+
centerY: Unit
|
|
6466
|
+
}).partial();
|
|
6467
|
+
var CurvePoint = tuple([Unit, Unit]);
|
|
6468
|
+
var CurveChannel = array(CurvePoint).min(2).max(IMAGE_EDIT_CURVE_POINTS_MAX).nullable();
|
|
6469
|
+
var Curves = tuple([CurveChannel, CurveChannel, CurveChannel, CurveChannel]);
|
|
6470
|
+
var Corner = tuple([number2().finite().min(-2).max(3), number2().finite().min(-2).max(3)]);
|
|
6471
|
+
var Rect = strictObject({
|
|
6472
|
+
x: Unit,
|
|
6473
|
+
y: Unit,
|
|
6474
|
+
width: number2().finite().gt(0).max(1),
|
|
6475
|
+
height: number2().finite().gt(0).max(1)
|
|
6476
|
+
}).refine((r) => r.x + r.width <= 1.000001 && r.y + r.height <= 1.000001, "The crop must stay inside the image");
|
|
6477
|
+
var Geometry = strictObject({
|
|
6478
|
+
quarterTurns: union([literal(0), literal(1), literal(2), literal(3)]),
|
|
6479
|
+
flipX: boolean2(),
|
|
6480
|
+
straighten: number2().finite().min(-45).max(45),
|
|
6481
|
+
perspectiveX: Slider,
|
|
6482
|
+
perspectiveY: Slider,
|
|
6483
|
+
corners: tuple([Corner, Corner, Corner, Corner]).nullable(),
|
|
6484
|
+
crop: Rect.nullable(),
|
|
6485
|
+
aspectRatio: number2().finite().min(0.01).max(100).nullable()
|
|
6486
|
+
}).partial();
|
|
6487
|
+
var FilterLabel = string2().regex(/^[A-Za-z0-9 _-]{1,32}$/, "Filter names are short words");
|
|
6488
|
+
function hasUnsafeUrlChar(s) {
|
|
6489
|
+
for (const ch of s) {
|
|
6490
|
+
const code = ch.charCodeAt(0);
|
|
6491
|
+
if (ch === "\\" || code < 32 || code === 127)
|
|
6492
|
+
return true;
|
|
6493
|
+
}
|
|
6494
|
+
return false;
|
|
6495
|
+
}
|
|
6496
|
+
var BlendSrc = string2().max(2000).refine((s) => !hasUnsafeUrlChar(s) && (/^\/(?!\/)/.test(s) || /^https:\/\//i.test(s)), "Blend images must be a site path or an https URL");
|
|
6497
|
+
var ImageEditRecipe = strictObject({
|
|
6498
|
+
version: literal(1),
|
|
6499
|
+
name: string2().max(80).optional(),
|
|
6500
|
+
lights: Lights.optional(),
|
|
6501
|
+
colors: Colors.optional(),
|
|
6502
|
+
effects: Effects.optional(),
|
|
6503
|
+
blur: Blur.optional(),
|
|
6504
|
+
curves: Curves.optional(),
|
|
6505
|
+
blend: strictObject({ src: BlendSrc, mix: Unit }).optional(),
|
|
6506
|
+
filters: strictObject({ label: FilterLabel, strength: Unit.optional() }).optional(),
|
|
6507
|
+
geometry: Geometry.optional()
|
|
6508
|
+
});
|
|
6509
|
+
var IMAGE_EDIT_FORMATS = ["webp", "jpeg", "png"];
|
|
6510
|
+
var ImageEditOutput = strictObject({
|
|
6511
|
+
format: _enum(IMAGE_EDIT_FORMATS),
|
|
6512
|
+
quality: number2().finite().min(0.1).max(1).optional(),
|
|
6513
|
+
maxSide: number2().int().min(16).max(1e4).optional(),
|
|
6514
|
+
stripGps: boolean2()
|
|
6515
|
+
});
|
|
6516
|
+
function byteLength(value) {
|
|
6517
|
+
return new TextEncoder().encode(JSON.stringify(value)).length;
|
|
6518
|
+
}
|
|
6519
|
+
var ImageEdit = strictObject({
|
|
6520
|
+
v: literal(1),
|
|
6521
|
+
engine: literal("photocn"),
|
|
6522
|
+
engineVersion: string2().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]{1,32})?$/, "A version like 0.1.2"),
|
|
6523
|
+
recipe: ImageEditRecipe.refine((r) => byteLength(r) <= IMAGE_EDIT_RECIPE_MAX_BYTES, {
|
|
6524
|
+
message: `The edit recipe is larger than ${IMAGE_EDIT_RECIPE_MAX_BYTES / 1024} KB`
|
|
6525
|
+
}),
|
|
6526
|
+
originalMediaId: string2().min(1).max(128).optional(),
|
|
6527
|
+
originalSrc: string2().min(1).max(2000),
|
|
6528
|
+
output: ImageEditOutput,
|
|
6529
|
+
editedAt: exports_iso.datetime({ offset: true })
|
|
6530
|
+
});
|
|
6531
|
+
|
|
6210
6532
|
// ../emvb/src/core/css-keywords.ts
|
|
6211
6533
|
var HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
6212
6534
|
var LENGTH_UNITS = ["px", "rem", "em", "%", "vw", "vh", "ch"];
|
|
@@ -6287,7 +6609,7 @@ function sanitizeUrl(value, schemes) {
|
|
|
6287
6609
|
return;
|
|
6288
6610
|
if (/[^\S ]|\\/.test(trimmed))
|
|
6289
6611
|
return;
|
|
6290
|
-
if (/^(?:[/?#.]|[
|
|
6612
|
+
if (/^(?:[/?#.]|[\p{L}\p{N}._~-])/u.test(trimmed))
|
|
6291
6613
|
return trimmed;
|
|
6292
6614
|
return;
|
|
6293
6615
|
}
|
|
@@ -6802,7 +7124,8 @@ var SHORTHANDS = new Set(["borderWidth", "borderRadius"]);
|
|
|
6802
7124
|
var TRIGGER_LIMITS = {
|
|
6803
7125
|
maxDelayMs: 120000,
|
|
6804
7126
|
maxScrollPercent: 100,
|
|
6805
|
-
minIdleMs: 1000
|
|
7127
|
+
minIdleMs: 1000,
|
|
7128
|
+
maxClickSelectorLength: 200
|
|
6806
7129
|
};
|
|
6807
7130
|
var POPUP_DEVICES = ["desktop", "tablet", "mobile"];
|
|
6808
7131
|
|
|
@@ -7014,7 +7337,7 @@ var DeviceStyles = strictObject({
|
|
|
7014
7337
|
var HiddenOn = array(_enum(POPUP_DEVICES)).max(3);
|
|
7015
7338
|
|
|
7016
7339
|
// ../emvb/src/core/schema/layout.ts
|
|
7017
|
-
var LAYOUT_SCHEMA_VERSION =
|
|
7340
|
+
var LAYOUT_SCHEMA_VERSION = 16;
|
|
7018
7341
|
var NodeId = string2().regex(/^[A-Za-z0-9_-]{4,24}$/, "Ids are 4-24 letters, digits, _ or -");
|
|
7019
7342
|
var ClassIds = array(string2().regex(/^[a-z0-9-]{1,40}$/)).max(20);
|
|
7020
7343
|
var HtmlId = string2().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/, "CSS ids start with a letter and are at most 64 characters");
|
|
@@ -7050,9 +7373,9 @@ var Variant = strictObject({
|
|
|
7050
7373
|
});
|
|
7051
7374
|
var AUDIENCE_DEVICES = ["mobile", "tablet", "desktop"];
|
|
7052
7375
|
var AUDIENCE_SEGMENT = /^[a-z0-9][a-z0-9:_-]{0,63}$/;
|
|
7053
|
-
var SEGMENT_HINT = "Segments are lowercase letters, digits, :, - or _,
|
|
7376
|
+
var SEGMENT_HINT = "Segments are lowercase letters, digits, :, - or _, such as plan:pro";
|
|
7054
7377
|
var Audience = strictObject({
|
|
7055
|
-
countries: array(string2().regex(/^[A-Z]{2}$/, "Two-letter country codes,
|
|
7378
|
+
countries: array(string2().regex(/^[A-Z]{2}$/, "Two-letter country codes, such as CA")).min(1).max(50).optional(),
|
|
7056
7379
|
devices: array(_enum(AUDIENCE_DEVICES)).min(1).max(3).optional(),
|
|
7057
7380
|
visitor: _enum(["new", "returning"]).optional(),
|
|
7058
7381
|
hours: strictObject({ from: number2().int().min(0).max(23), to: number2().int().min(0).max(24) }).optional(),
|
|
@@ -7171,7 +7494,8 @@ var ImageNode = leafNode("image", strictObject({
|
|
|
7171
7494
|
sources: array(strictObject({
|
|
7172
7495
|
src: string2().max(2000),
|
|
7173
7496
|
width: number2().int().min(1).max(8000)
|
|
7174
|
-
})).max(6).optional()
|
|
7497
|
+
})).max(6).optional(),
|
|
7498
|
+
edit: ImageEdit.optional()
|
|
7175
7499
|
})).refine((node) => node.props.decorative === true || node.props.alt.length > 0, {
|
|
7176
7500
|
message: "Alt text is required unless the image is marked decorative.",
|
|
7177
7501
|
path: ["props", "alt"]
|
|
@@ -7270,19 +7594,19 @@ var PostLinkNode = leafNode("post-link", strictObject({
|
|
|
7270
7594
|
}));
|
|
7271
7595
|
var LOOP_DISPLAYS = ["list", "grid", "cards"];
|
|
7272
7596
|
var FIELD_SLUG = /^[a-z][a-z0-9_]{0,63}$/;
|
|
7273
|
-
var FIELD_SLUG_HINT = "Use the field's slug,
|
|
7597
|
+
var FIELD_SLUG_HINT = "Use the field's slug, such as photo";
|
|
7274
7598
|
var LOOP_PERMALINK = /^(?=.*\{(?:slug|id)\})\/(?!\/)(?:[A-Za-z0-9._~/-]|\{slug\}|\{id\})*$/;
|
|
7275
7599
|
var LOOP_FILTER = /^\s*[a-z][a-z0-9_]{0,63}\s*=\s*[^;=<>\s](?:[^;=<>]{0,98}[^;=<>\s])?(?:\s*;\s*[a-z][a-z0-9_]{0,63}\s*=\s*[^;=<>\s](?:[^;=<>]{0,98}[^;=<>\s])?)*\s*;?\s*$/;
|
|
7276
7600
|
var LOOP_ORDERS = ["newest", "oldest", "title"];
|
|
7277
7601
|
var LoopNode = parentNode("loop", strictObject({
|
|
7278
7602
|
itemPartId: string2().max(128).optional(),
|
|
7279
7603
|
perPage: number2().int().min(1).max(50).optional(),
|
|
7280
|
-
collection: string2().regex(/^[a-z][a-z0-9_]{0,63}$/, "Use the collection's slug,
|
|
7604
|
+
collection: string2().regex(/^[a-z][a-z0-9_]{0,63}$/, "Use the collection's slug, such as team").optional(),
|
|
7281
7605
|
limit: number2().int().min(1).max(50).optional(),
|
|
7282
7606
|
order: _enum(LOOP_ORDERS).optional(),
|
|
7283
7607
|
display: _enum(LOOP_DISPLAYS).optional(),
|
|
7284
7608
|
columns: number2().int().min(1).max(6).optional(),
|
|
7285
|
-
permalink: string2().max(200).regex(LOOP_PERMALINK, "A site path with {slug} or {id},
|
|
7609
|
+
permalink: string2().max(200).regex(LOOP_PERMALINK, "A site path with {slug} or {id}, such as /team/{slug}").optional(),
|
|
7286
7610
|
imageField: string2().regex(FIELD_SLUG, FIELD_SLUG_HINT).optional(),
|
|
7287
7611
|
excerptField: string2().regex(FIELD_SLUG, FIELD_SLUG_HINT).optional(),
|
|
7288
7612
|
filter: string2().max(300).regex(LOOP_FILTER, "Use field=value pairs separated by ;").optional()
|
|
@@ -7292,7 +7616,13 @@ var PaginationNode = leafNode("pagination", strictObject({
|
|
|
7292
7616
|
prevText: string2().max(40).optional(),
|
|
7293
7617
|
nextText: string2().max(40).optional(),
|
|
7294
7618
|
showCount: boolean2().optional(),
|
|
7295
|
-
countText: string2().max(60).optional()
|
|
7619
|
+
countText: string2().max(60).optional(),
|
|
7620
|
+
titleText: string2().max(60).optional(),
|
|
7621
|
+
archiveTitle: string2().max(60).optional(),
|
|
7622
|
+
navLabel: string2().max(60).optional(),
|
|
7623
|
+
pageLabel: string2().max(60).optional(),
|
|
7624
|
+
prevLabel: string2().max(60).optional(),
|
|
7625
|
+
nextLabel: string2().max(60).optional()
|
|
7296
7626
|
}));
|
|
7297
7627
|
var SectionNode = parentNode("section", strictObject({
|
|
7298
7628
|
partId: string2().max(128).optional()
|
|
@@ -7763,6 +8093,44 @@ function parseSvg(raw) {
|
|
|
7763
8093
|
return;
|
|
7764
8094
|
return build(tokens);
|
|
7765
8095
|
}
|
|
8096
|
+
function isSafeSvgMarkup(raw) {
|
|
8097
|
+
return sanitizeSvgMarkup(raw) !== undefined;
|
|
8098
|
+
}
|
|
8099
|
+
|
|
8100
|
+
// ../emvb/src/core/elements/svg-ids.ts
|
|
8101
|
+
var URL_REF = /url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/g;
|
|
8102
|
+
var ID_LIST_ATTRS = new Set(["aria-labelledby", "aria-describedby"]);
|
|
8103
|
+
function scopeSvgIds(children, prefix) {
|
|
8104
|
+
const ids = new Set;
|
|
8105
|
+
const collect = (node) => {
|
|
8106
|
+
if (typeof node === "string")
|
|
8107
|
+
return;
|
|
8108
|
+
if (node.attrs.id)
|
|
8109
|
+
ids.add(node.attrs.id);
|
|
8110
|
+
node.children.forEach(collect);
|
|
8111
|
+
};
|
|
8112
|
+
children.forEach(collect);
|
|
8113
|
+
if (ids.size === 0)
|
|
8114
|
+
return children;
|
|
8115
|
+
const scoped = (id) => ids.has(id) ? `${prefix}-${id}` : id;
|
|
8116
|
+
const rewrite = (node) => {
|
|
8117
|
+
if (typeof node === "string")
|
|
8118
|
+
return node;
|
|
8119
|
+
const attrs = {};
|
|
8120
|
+
for (const [name, value] of Object.entries(node.attrs)) {
|
|
8121
|
+
if (name === "id")
|
|
8122
|
+
attrs[name] = scoped(value);
|
|
8123
|
+
else if ((name === "href" || name === "xlink:href") && value.startsWith("#"))
|
|
8124
|
+
attrs[name] = `#${scoped(value.slice(1))}`;
|
|
8125
|
+
else if (ID_LIST_ATTRS.has(name))
|
|
8126
|
+
attrs[name] = value.split(/\s+/).map(scoped).join(" ");
|
|
8127
|
+
else
|
|
8128
|
+
attrs[name] = value.replace(URL_REF, (_m, q, id) => `url(${q}#${scoped(id)}${q})`);
|
|
8129
|
+
}
|
|
8130
|
+
return { ...node, attrs, children: node.children.map(rewrite) };
|
|
8131
|
+
};
|
|
8132
|
+
return children.map(rewrite);
|
|
8133
|
+
}
|
|
7766
8134
|
|
|
7767
8135
|
// ../emvb/src/core/icons/catalog.ts
|
|
7768
8136
|
var BUNDLED_ICONS = [
|
|
@@ -7815,8 +8183,8 @@ var BUNDLED_ICONS = [
|
|
|
7815
8183
|
label: "Circle Alert",
|
|
7816
8184
|
children: [
|
|
7817
8185
|
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "10" } },
|
|
7818
|
-
{ tag: "line", attrs: {} },
|
|
7819
|
-
{ tag: "line", attrs: {} }
|
|
8186
|
+
{ tag: "line", attrs: { x1: "12", x2: "12", y1: "8", y2: "12" } },
|
|
8187
|
+
{ tag: "line", attrs: { x1: "12", x2: "12.01", y1: "16", y2: "16" } }
|
|
7820
8188
|
]
|
|
7821
8189
|
},
|
|
7822
8190
|
{
|
|
@@ -8027,6 +8395,7 @@ var YT_HOSTS = new Set([
|
|
|
8027
8395
|
"youtube.com",
|
|
8028
8396
|
"www.youtube.com",
|
|
8029
8397
|
"m.youtube.com",
|
|
8398
|
+
"music.youtube.com",
|
|
8030
8399
|
"youtu.be",
|
|
8031
8400
|
"www.youtu.be",
|
|
8032
8401
|
"youtube-nocookie.com",
|
|
@@ -8037,9 +8406,20 @@ var matching = (id, pattern) => id && pattern.test(id) ? id : undefined;
|
|
|
8037
8406
|
var YT_ID = /^[\w-]{6,}$/;
|
|
8038
8407
|
var VIMEO_ID = /^\d{6,}$/;
|
|
8039
8408
|
var firstSegment = (path) => path.split("/").find(Boolean);
|
|
8409
|
+
var YT_LIST = /^[\w-]{10,64}$/;
|
|
8410
|
+
function youtubePlaylist(parsed) {
|
|
8411
|
+
const path = parsed.pathname.replace(/\/+$/, "");
|
|
8412
|
+
if (path !== "/embed/videoseries" && path !== "/playlist")
|
|
8413
|
+
return null;
|
|
8414
|
+
const list = matching(parsed.searchParams.get("list") ?? undefined, YT_LIST);
|
|
8415
|
+
return list ? `videoseries?list=${list}` : undefined;
|
|
8416
|
+
}
|
|
8040
8417
|
function youtubeId(parsed) {
|
|
8041
8418
|
const host = parsed.hostname.toLowerCase();
|
|
8042
8419
|
const path = parsed.pathname;
|
|
8420
|
+
const playlist = youtubePlaylist(parsed);
|
|
8421
|
+
if (playlist !== null)
|
|
8422
|
+
return playlist;
|
|
8043
8423
|
if (host === "youtu.be" || host === "www.youtu.be")
|
|
8044
8424
|
return matching(firstSegment(path), YT_ID);
|
|
8045
8425
|
for (const prefix of ["/embed/", "/shorts/", "/live/"]) {
|
|
@@ -8053,7 +8433,7 @@ function vimeoId(parsed) {
|
|
|
8053
8433
|
const parts = parsed.pathname.split("/").filter(Boolean);
|
|
8054
8434
|
const player = parsed.hostname.toLowerCase() === "player.vimeo.com";
|
|
8055
8435
|
const videoIdx = parts.indexOf("video");
|
|
8056
|
-
const at = player ? videoIdx >= 0 ? videoIdx + 1 : 0 : parts[0] === "channels" ? 2 : parts[0] === "groups" && parts[2] === "videos" ? 3 : 0;
|
|
8436
|
+
const at = player ? videoIdx >= 0 ? videoIdx + 1 : 0 : parts[0] === "channels" ? 2 : parts[0] === "groups" && parts[2] === "videos" || parts[0] === "showcase" && parts[2] === "video" ? 3 : 0;
|
|
8057
8437
|
const id = matching(parts[at], VIMEO_ID);
|
|
8058
8438
|
if (!id)
|
|
8059
8439
|
return;
|
|
@@ -8073,7 +8453,7 @@ function startOf(parsed) {
|
|
|
8073
8453
|
const fragment = new URLSearchParams(parsed.hash.replace(/^#/, ""));
|
|
8074
8454
|
return parseStartSeconds(parsed.searchParams.get("t") ?? parsed.searchParams.get("start") ?? fragment.get("t"));
|
|
8075
8455
|
}
|
|
8076
|
-
var withStart = (provider, src, start) => start === undefined ? src : provider === "youtube" ? `${src}?start=${start}` : `${src}#t=${start}s`;
|
|
8456
|
+
var withStart = (provider, src, start) => start === undefined ? src : provider === "youtube" ? `${src}${src.includes("?") ? "&" : "?"}start=${start}` : `${src}#t=${start}s`;
|
|
8077
8457
|
var PROVIDERS = [
|
|
8078
8458
|
{
|
|
8079
8459
|
provider: "youtube",
|
|
@@ -8083,14 +8463,28 @@ var PROVIDERS = [
|
|
|
8083
8463
|
},
|
|
8084
8464
|
{ provider: "vimeo", hosts: VIMEO_HOSTS, id: vimeoId, embed: "https://player.vimeo.com/video/" }
|
|
8085
8465
|
];
|
|
8086
|
-
|
|
8466
|
+
function bareVideoHost(typed) {
|
|
8467
|
+
const slash = typed.indexOf("/");
|
|
8468
|
+
if (slash <= 0)
|
|
8469
|
+
return false;
|
|
8470
|
+
const host = typed.slice(0, slash).toLowerCase();
|
|
8471
|
+
return YT_HOSTS.has(host) || VIMEO_HOSTS.has(host);
|
|
8472
|
+
}
|
|
8473
|
+
function isVideoFilePath(value) {
|
|
8474
|
+
if (value.startsWith("//"))
|
|
8475
|
+
return false;
|
|
8476
|
+
const path = value.split(/[?#]/)[0] ?? "";
|
|
8477
|
+
return /\.(mp4|webm|ogg)$/i.test(path) || path.startsWith("/_emdash/api/media/file/");
|
|
8478
|
+
}
|
|
8087
8479
|
function resolveEmbedUrl(value) {
|
|
8088
8480
|
const typed = value.trim();
|
|
8089
|
-
const trimmed =
|
|
8481
|
+
const trimmed = bareVideoHost(typed) ? `https://${typed}` : typed;
|
|
8090
8482
|
if (trimmed.length === 0 || trimmed.length > 2000)
|
|
8091
8483
|
return;
|
|
8092
8484
|
const hasScheme = /^[a-z][a-z0-9+.-]*:/i.test(trimmed);
|
|
8093
8485
|
if (!hasScheme) {
|
|
8486
|
+
if (!isVideoFilePath(trimmed))
|
|
8487
|
+
return;
|
|
8094
8488
|
const media = sanitizeMediaUrl(trimmed);
|
|
8095
8489
|
if (!media)
|
|
8096
8490
|
return;
|
|
@@ -8147,7 +8541,7 @@ function stampGroup(children, name) {
|
|
|
8147
8541
|
};
|
|
8148
8542
|
});
|
|
8149
8543
|
}
|
|
8150
|
-
function groupItems(children) {
|
|
8544
|
+
function groupItems(children, listClass = "emvb-menu__list emvb-menu__list--sub") {
|
|
8151
8545
|
const out = [];
|
|
8152
8546
|
let batch = [];
|
|
8153
8547
|
const flush = () => {
|
|
@@ -8155,7 +8549,7 @@ function groupItems(children) {
|
|
|
8155
8549
|
return;
|
|
8156
8550
|
out.push({
|
|
8157
8551
|
tag: "ul",
|
|
8158
|
-
attrs: { class:
|
|
8552
|
+
attrs: { class: listClass },
|
|
8159
8553
|
children: batch
|
|
8160
8554
|
});
|
|
8161
8555
|
batch = [];
|
|
@@ -8183,11 +8577,15 @@ var MENU_CSS = [
|
|
|
8183
8577
|
".emvb-menu-item__toggle{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;cursor:pointer;list-style:none}",
|
|
8184
8578
|
".emvb-menu-item__toggle::-webkit-details-marker{display:none}",
|
|
8185
8579
|
".emvb-menu-item__toggle::before{content:'';width:.4rem;height:.4rem;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg) translateY(-1px)}",
|
|
8580
|
+
".emvb-menu-item__toggle--label{width:auto;gap:.6rem;padding-inline-end:.35rem}",
|
|
8581
|
+
".emvb-menu-item__toggle--label::before{order:1}",
|
|
8186
8582
|
".emvb-menu-panel{display:none;position:absolute;z-index:30;top:100%;inset-inline-start:0;min-width:12rem;padding:.75rem;background:canvas;color:canvastext;border:1px solid #00000014;box-shadow:0 12px 32px #00000029}",
|
|
8187
8583
|
".emvb-menu-item__disclosure[open]>.emvb-menu-panel{display:block}",
|
|
8188
|
-
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
|
|
8189
|
-
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
|
|
8584
|
+
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:not([data-emvb-menu-dismissed]):hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:not([data-emvb-menu-dismissed]):focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
|
|
8585
|
+
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:not([data-emvb-menu-dismissed]):hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
|
|
8190
8586
|
".emvb-menu-panel--wide{inset-inline:0;min-width:0}",
|
|
8587
|
+
".emvb-menu--column .emvb-menu-item{position:static}",
|
|
8588
|
+
".emvb-menu--column .emvb-menu-item__bar{position:relative;width:fit-content;max-width:100%}",
|
|
8191
8589
|
".emvb-menu--column .emvb-menu-panel{top:0;inset-inline-start:100%}",
|
|
8192
8590
|
".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}"
|
|
8193
8591
|
].join("");
|
|
@@ -8232,13 +8630,7 @@ var menu = {
|
|
|
8232
8630
|
return {
|
|
8233
8631
|
tag: "nav",
|
|
8234
8632
|
attrs: { ...attrs, class: classes, "aria-label": label },
|
|
8235
|
-
children:
|
|
8236
|
-
{
|
|
8237
|
-
tag: "ul",
|
|
8238
|
-
attrs: { class: "emvb-menu__list" },
|
|
8239
|
-
children: stampGroup(children, `emvb-menu-${node.id}`)
|
|
8240
|
-
}
|
|
8241
|
-
]
|
|
8633
|
+
children: groupItems(stampGroup(children, `emvb-menu-${node.id}`), "emvb-menu__list")
|
|
8242
8634
|
};
|
|
8243
8635
|
}
|
|
8244
8636
|
};
|
|
@@ -8251,11 +8643,11 @@ var menuItem = {
|
|
|
8251
8643
|
group: "content",
|
|
8252
8644
|
defaultTab: "content",
|
|
8253
8645
|
fields: [
|
|
8254
|
-
{ key: "text", kind: "text", label: "
|
|
8646
|
+
{ key: "text", kind: "text", label: "Text" },
|
|
8255
8647
|
{
|
|
8256
8648
|
key: "href",
|
|
8257
8649
|
kind: "href",
|
|
8258
|
-
label: "
|
|
8650
|
+
label: "URL",
|
|
8259
8651
|
optional: true,
|
|
8260
8652
|
message: "Use a full URL such as https://example.com or a path such as /pricing."
|
|
8261
8653
|
},
|
|
@@ -8272,14 +8664,19 @@ var menuItem = {
|
|
|
8272
8664
|
attrs: { class: "emvb-menu-item__link", href, ...newTabAttrs(node.props.newTab) },
|
|
8273
8665
|
children: [node.props.text]
|
|
8274
8666
|
} : { tag: "span", attrs: { class: "emvb-menu-item__label" }, children: [node.props.text] };
|
|
8275
|
-
const
|
|
8667
|
+
const textToggle = !href && children.length > 0;
|
|
8668
|
+
const bar = textToggle ? [] : [label];
|
|
8276
8669
|
if (children.length > 0) {
|
|
8277
8670
|
const panelClass = wide ? "emvb-menu-panel emvb-menu-panel--wide" : "emvb-menu-panel";
|
|
8278
8671
|
bar.push({
|
|
8279
8672
|
tag: "details",
|
|
8280
8673
|
attrs: { class: "emvb-menu-item__disclosure" },
|
|
8281
8674
|
children: [
|
|
8282
|
-
{
|
|
8675
|
+
textToggle ? {
|
|
8676
|
+
tag: "summary",
|
|
8677
|
+
attrs: { class: "emvb-menu-item__toggle emvb-menu-item__toggle--label" },
|
|
8678
|
+
children: [node.props.text]
|
|
8679
|
+
} : {
|
|
8283
8680
|
tag: "summary",
|
|
8284
8681
|
attrs: { class: "emvb-menu-item__toggle", "aria-label": `Open ${node.props.text}` },
|
|
8285
8682
|
children: []
|
|
@@ -8300,6 +8697,9 @@ var menuItem = {
|
|
|
8300
8697
|
}
|
|
8301
8698
|
};
|
|
8302
8699
|
|
|
8700
|
+
// ../emvb/src/core/elements/select-prompt.ts
|
|
8701
|
+
var selectPrompt = (props) => props.placeholder?.trim() || "Choose…";
|
|
8702
|
+
|
|
8303
8703
|
// ../emvb/src/core/elements/field-id.ts
|
|
8304
8704
|
var controlId = (nodeId) => `emvb-field-${nodeId}`;
|
|
8305
8705
|
|
|
@@ -8313,9 +8713,9 @@ var TEXT_FIELDS = [
|
|
|
8313
8713
|
...NAME_AND_LABEL,
|
|
8314
8714
|
{ key: "placeholder", kind: "text", label: "Placeholder", optional: true }
|
|
8315
8715
|
];
|
|
8316
|
-
var FORM_FIELD_CSS = ":where(.emvb-form .emvb-form-label){font-weight:600}" + ":where(.emvb-form .ec-form-input){box-sizing:border-box;width:100%;max-width:100%;margin:0;padding:.625em .75em;font:inherit;color:inherit;background-color:transparent;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 30%,transparent);border-radius:6px}" + ":where(.emvb-form textarea.ec-form-input){min-height:7.5em;resize:vertical}" + ":where(.emvb-form .ec-form-input)::placeholder{color:inherit;opacity:.55}" + ":where(.emvb-form .ec-form-input:focus-visible){outline:2px solid currentColor;outline-offset:1px;border-color:currentColor}" + ':where(.emvb-form .ec-form-input[aria-invalid="true"]){border-color:#b3261e}' + ':where(.emvb-form input[type="checkbox"],.emvb-form input[type="radio"]){width:1.1em;height:1.1em;margin:0;accent-color:currentColor}' + ":where(.emvb-form .emvb-form-checkbox-label,.emvb-form .emvb-form-radio-label){display:inline-flex;align-items:center;gap:.5em}" + ":where(.emvb-form .emvb-radio-group){display:flex;flex-direction:column;gap:6px;margin:0;padding:0;border:0}" + ":where(.emvb-form .ec-form-error){font-size:.875em;color:#b3261e}";
|
|
8716
|
+
var FORM_FIELD_CSS = ":where(.emvb-form .emvb-form-label){font-weight:600}" + ":where(.emvb-form .ec-form-input){box-sizing:border-box;width:100%;max-width:100%;margin:0;padding:.625em .75em;font:inherit;color:inherit;background-color:transparent;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 30%,transparent);border-radius:6px}" + ":where(.emvb-form textarea.ec-form-input){min-height:7.5em;resize:vertical}" + ":where(.emvb-form .ec-form-input)::placeholder{color:inherit;opacity:.55}" + ":where(.emvb-form .ec-form-input:focus-visible){outline:2px solid currentColor;outline-offset:1px;border-color:currentColor}" + ':where(.emvb-form .ec-form-input[aria-invalid="true"]){border-color:#b3261e}' + ':where(.emvb-form input[type="checkbox"],.emvb-form input[type="radio"]){width:1.1em;height:1.1em;margin:0;accent-color:currentColor}' + ":where(.emvb-form .emvb-form-checkbox-label,.emvb-form .emvb-form-radio-label){display:inline-flex;align-items:center;gap:.5em;overflow-wrap:anywhere}" + ":where(.emvb-form .emvb-radio-group){display:flex;flex-direction:column;gap:6px;margin:0;padding:0;border:0;min-width:0}" + ":where(.emvb-form .emvb-radio-group>legend){float:left;width:100%;margin:0 0 -2px;padding:0}" + ":where(.emvb-form .ec-form-error){font-size:.875em;color:#b3261e}";
|
|
8317
8717
|
var form = {
|
|
8318
|
-
baseCss: ".emvb-form{display:flex;flex-direction:column;gap:12px;min-width:0}.emvb-form-unbound{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}.ec-form-hp{position:absolute;
|
|
8718
|
+
baseCss: ".emvb-form{display:flex;flex-direction:column;gap:12px;min-width:0}.emvb-form-unbound{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}.emvb-form-field[hidden]{display:none!important}.ec-form-hp{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}" + ":where(.emvb-form-paused){padding:12px 16px;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 25%,transparent);border-radius:6px}:where(.emvb-form-paused p){margin:0}" + FORM_FIELD_CSS,
|
|
8319
8719
|
defaults: () => ({ type: "form", props: { formId: "" }, children: [] }),
|
|
8320
8720
|
descriptor: fieldDescriptor("form", "Form", [
|
|
8321
8721
|
{ key: "formId", kind: "text", label: "Form id", message: "Paste a forms-plugin form id." }
|
|
@@ -8326,27 +8726,39 @@ var form = {
|
|
|
8326
8726
|
children
|
|
8327
8727
|
})
|
|
8328
8728
|
};
|
|
8329
|
-
var errorSlot = (name) => ({
|
|
8729
|
+
var errorSlot = (name, controlFor) => ({
|
|
8330
8730
|
tag: "span",
|
|
8331
|
-
attrs: {
|
|
8731
|
+
attrs: {
|
|
8732
|
+
class: "ec-form-error",
|
|
8733
|
+
id: errorId(controlFor),
|
|
8734
|
+
"data-error-for": name,
|
|
8735
|
+
"aria-live": "polite"
|
|
8736
|
+
},
|
|
8332
8737
|
children: []
|
|
8333
8738
|
});
|
|
8739
|
+
var errorId = (controlFor) => `${controlFor}-error`;
|
|
8740
|
+
var describedBy = (controlFor) => ({ "aria-describedby": errorId(controlFor) });
|
|
8334
8741
|
var fieldBox = (attrs, children) => ({
|
|
8335
8742
|
tag: "div",
|
|
8336
8743
|
attrs: { ...attrs, class: `${attrs.class ?? ""} emvb-form-field`.trim() },
|
|
8337
8744
|
children
|
|
8338
8745
|
});
|
|
8339
8746
|
var fieldWrap = (controlFor, name, labelText, control, attrs) => fieldBox(attrs, [
|
|
8340
|
-
...labelText ? [
|
|
8747
|
+
...labelText?.trim() ? [
|
|
8341
8748
|
{
|
|
8342
8749
|
tag: "label",
|
|
8343
8750
|
attrs: { class: "emvb-form-label", for: controlFor },
|
|
8344
8751
|
children: [labelText]
|
|
8345
8752
|
}
|
|
8346
8753
|
] : [],
|
|
8347
|
-
control,
|
|
8348
|
-
errorSlot(name)
|
|
8754
|
+
withDescription(labelText?.trim() ? control : named(control, name), controlFor),
|
|
8755
|
+
errorSlot(name, controlFor)
|
|
8349
8756
|
]);
|
|
8757
|
+
var withDescription = (control, controlFor) => ({
|
|
8758
|
+
...control,
|
|
8759
|
+
attrs: { ...control.attrs, ...describedBy(controlFor) }
|
|
8760
|
+
});
|
|
8761
|
+
var named = (control, name) => control.attrs.placeholder?.trim() || !name.trim() ? control : { ...control, attrs: { ...control.attrs, "aria-label": name } };
|
|
8350
8762
|
var textControl = (tag, props, id) => ({
|
|
8351
8763
|
tag,
|
|
8352
8764
|
attrs: {
|
|
@@ -8373,13 +8785,13 @@ var textareaEl = {
|
|
|
8373
8785
|
var selectEl = {
|
|
8374
8786
|
baseCss: ".emvb-select{display:flex;flex-direction:column;gap:4px}",
|
|
8375
8787
|
defaults: () => ({ type: "select", props: { field: "choice", label: "Choice" } }),
|
|
8376
|
-
descriptor: fieldDescriptor("select", "Select",
|
|
8788
|
+
descriptor: fieldDescriptor("select", "Select", TEXT_FIELDS),
|
|
8377
8789
|
build: (node, attrs) => {
|
|
8378
8790
|
const name = node.props.field;
|
|
8379
8791
|
const control = {
|
|
8380
8792
|
tag: "select",
|
|
8381
8793
|
attrs: { class: "ec-form-input", id: controlId(node.id), name },
|
|
8382
|
-
children: [{ tag: "option", attrs: { value: "" }, children: [
|
|
8794
|
+
children: [{ tag: "option", attrs: { value: "" }, children: [selectPrompt(node.props)] }]
|
|
8383
8795
|
};
|
|
8384
8796
|
return fieldWrap(controlId(node.id), name, node.props.label, control, attrs);
|
|
8385
8797
|
}
|
|
@@ -8392,15 +8804,21 @@ var checkbox = {
|
|
|
8392
8804
|
const name = node.props.field;
|
|
8393
8805
|
const input = {
|
|
8394
8806
|
tag: "input",
|
|
8395
|
-
attrs: {
|
|
8807
|
+
attrs: {
|
|
8808
|
+
type: "checkbox",
|
|
8809
|
+
id: controlId(node.id),
|
|
8810
|
+
name,
|
|
8811
|
+
value: "true",
|
|
8812
|
+
...describedBy(controlId(node.id))
|
|
8813
|
+
},
|
|
8396
8814
|
children: []
|
|
8397
8815
|
};
|
|
8398
8816
|
const labelEl = {
|
|
8399
8817
|
tag: "label",
|
|
8400
8818
|
attrs: { class: "emvb-form-checkbox-label" },
|
|
8401
|
-
children: [input, ` ${node.props.label
|
|
8819
|
+
children: [input, ` ${node.props.label?.trim() || name}`]
|
|
8402
8820
|
};
|
|
8403
|
-
return fieldBox(attrs, [labelEl, errorSlot(name)]);
|
|
8821
|
+
return fieldBox(attrs, [labelEl, errorSlot(name, controlId(node.id))]);
|
|
8404
8822
|
}
|
|
8405
8823
|
};
|
|
8406
8824
|
var radio = {
|
|
@@ -8410,11 +8828,22 @@ var radio = {
|
|
|
8410
8828
|
build: (node, attrs) => {
|
|
8411
8829
|
const name = node.props.field;
|
|
8412
8830
|
const id = controlId(node.id);
|
|
8413
|
-
const
|
|
8831
|
+
const legend = node.props.label?.trim() ? [
|
|
8832
|
+
{
|
|
8833
|
+
tag: "legend",
|
|
8834
|
+
attrs: { class: "emvb-form-label", id: `${id}-label` },
|
|
8835
|
+
children: [node.props.label]
|
|
8836
|
+
}
|
|
8837
|
+
] : [];
|
|
8414
8838
|
const control = {
|
|
8415
8839
|
tag: "fieldset",
|
|
8416
|
-
attrs: {
|
|
8840
|
+
attrs: {
|
|
8841
|
+
class: "emvb-radio-group",
|
|
8842
|
+
...describedBy(id),
|
|
8843
|
+
...legend.length || !name.trim() ? {} : { "aria-label": name }
|
|
8844
|
+
},
|
|
8417
8845
|
children: [
|
|
8846
|
+
...legend,
|
|
8418
8847
|
{
|
|
8419
8848
|
tag: "label",
|
|
8420
8849
|
attrs: { class: "emvb-form-radio-label" },
|
|
@@ -8425,18 +8854,11 @@ var radio = {
|
|
|
8425
8854
|
}
|
|
8426
8855
|
]
|
|
8427
8856
|
};
|
|
8428
|
-
|
|
8429
|
-
{
|
|
8430
|
-
tag: "label",
|
|
8431
|
-
attrs: { class: "emvb-form-label", id: `${id}-label` },
|
|
8432
|
-
children: [node.props.label]
|
|
8433
|
-
}
|
|
8434
|
-
] : [];
|
|
8435
|
-
return fieldBox(attrs, [...label, control, errorSlot(name)]);
|
|
8857
|
+
return fieldBox(attrs, [control, errorSlot(name, id)]);
|
|
8436
8858
|
}
|
|
8437
8859
|
};
|
|
8438
8860
|
var submit = {
|
|
8439
|
-
baseCss: ".emvb-submit{display:inline-flex}",
|
|
8861
|
+
baseCss: ".emvb-submit{display:inline-flex;max-width:100%;overflow-wrap:anywhere}",
|
|
8440
8862
|
defaults: () => ({ type: "submit", props: { label: "Submit" } }),
|
|
8441
8863
|
descriptor: fieldDescriptor("submit", "Submit", [
|
|
8442
8864
|
{ key: "label", kind: "text", label: "Label", optional: true }
|
|
@@ -8579,7 +9001,7 @@ var postLink = {
|
|
|
8579
9001
|
optional: true,
|
|
8580
9002
|
message: "Leave blank to use the post title."
|
|
8581
9003
|
},
|
|
8582
|
-
{ key: "newTab", kind: "boolean", label: "Open in new tab", optional: true }
|
|
9004
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true }
|
|
8583
9005
|
]
|
|
8584
9006
|
},
|
|
8585
9007
|
build: (_node, attrs) => ({ tag: "a", attrs: { ...attrs, href: "#" }, children: ["Post link"] })
|
|
@@ -8590,7 +9012,7 @@ var DISPLAY_OPTIONS = [
|
|
|
8590
9012
|
{ value: "cards", label: "Cards" }
|
|
8591
9013
|
];
|
|
8592
9014
|
var loop = {
|
|
8593
|
-
baseCss: ".emvb-loop{display:flex;flex-direction:column;min-width:0;gap:1rem}.emvb-loop[data-emvb-loop-empty]{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}" + ".emvb-loop-grid,.emvb-loop-cards{display:grid;grid-template-columns:repeat(var(--emvb-loop-columns,3),minmax(0,1fr))}" + ".emvb-loop-cards>.emvb-loop-item{padding:1rem;border:1px solid color-mix(in srgb,currentColor 15%,transparent);border-radius:12px;background:color-mix(in srgb,currentColor 3%,transparent)}" + ".emvb-loop-grid>.emvb-loop-empty,.emvb-loop-cards>.emvb-loop-empty{grid-column:1/-1}" + "@media (max-width:
|
|
9015
|
+
baseCss: ".emvb-loop{display:flex;flex-direction:column;min-width:0;gap:1rem}.emvb-loop[data-emvb-loop-empty]{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}" + ".emvb-loop-grid,.emvb-loop-cards{display:grid;grid-template-columns:repeat(var(--emvb-loop-columns,3),minmax(0,1fr))}" + ".emvb-loop-cards>.emvb-loop-item{padding:1rem;border:1px solid color-mix(in srgb,currentColor 15%,transparent);border-radius:12px;background:color-mix(in srgb,currentColor 3%,transparent)}" + ".emvb-loop-grid>.emvb-loop-empty,.emvb-loop-cards>.emvb-loop-empty{grid-column:1/-1}" + "@media (max-width: 767.98px){.emvb-loop-grid,.emvb-loop-cards{grid-template-columns:minmax(0,1fr)}}",
|
|
8594
9016
|
defaults: () => ({ type: "loop", props: {}, children: [] }),
|
|
8595
9017
|
descriptor: {
|
|
8596
9018
|
type: "loop",
|
|
@@ -8644,28 +9066,28 @@ var loop = {
|
|
|
8644
9066
|
kind: "text",
|
|
8645
9067
|
label: "Link pattern",
|
|
8646
9068
|
optional: true,
|
|
8647
|
-
message: "Where each entry links,
|
|
9069
|
+
message: "Where each entry links, such as /team/{slug}; {slug} and {id} are filled in. Leave it empty for /collection/{slug}."
|
|
8648
9070
|
},
|
|
8649
9071
|
{
|
|
8650
9072
|
key: "imageField",
|
|
8651
9073
|
kind: "text",
|
|
8652
9074
|
label: "Image field",
|
|
8653
9075
|
optional: true,
|
|
8654
|
-
message: "The field Post Image shows,
|
|
9076
|
+
message: "The field Post Image shows, such as photo. Leave it empty for the featured image."
|
|
8655
9077
|
},
|
|
8656
9078
|
{
|
|
8657
9079
|
key: "excerptField",
|
|
8658
9080
|
kind: "text",
|
|
8659
9081
|
label: "Excerpt field",
|
|
8660
9082
|
optional: true,
|
|
8661
|
-
message: "The field Post Excerpt shows,
|
|
9083
|
+
message: "The field Post Excerpt shows, such as role. Leave it empty for the excerpt."
|
|
8662
9084
|
},
|
|
8663
9085
|
{
|
|
8664
9086
|
key: "filter",
|
|
8665
9087
|
kind: "text",
|
|
8666
9088
|
label: "Only entries where",
|
|
8667
9089
|
optional: true,
|
|
8668
|
-
message: "field=value pairs separated by
|
|
9090
|
+
message: "field=value pairs separated by semicolons, such as category=news; team=design. A taxonomy works too. The same field twice matches either value."
|
|
8669
9091
|
},
|
|
8670
9092
|
{
|
|
8671
9093
|
key: "itemPartId",
|
|
@@ -8724,6 +9146,48 @@ var pagination = {
|
|
|
8724
9146
|
label: "Count text",
|
|
8725
9147
|
optional: true,
|
|
8726
9148
|
message: `{page} and {total} are filled in. EmDash 1.2 doesn't report a total, so the count shows "Page N" until it does.`
|
|
9149
|
+
},
|
|
9150
|
+
{
|
|
9151
|
+
key: "titleText",
|
|
9152
|
+
kind: "text",
|
|
9153
|
+
label: "Page title text",
|
|
9154
|
+
optional: true,
|
|
9155
|
+
message: 'The browser title of page 2 onward. {title} and {page} are filled in; unset is "{title} – page {page}".'
|
|
9156
|
+
},
|
|
9157
|
+
{
|
|
9158
|
+
key: "archiveTitle",
|
|
9159
|
+
kind: "text",
|
|
9160
|
+
label: "Posts archive title",
|
|
9161
|
+
optional: true,
|
|
9162
|
+
message: `Replaces "Posts" as the posts archive's title, in the site's language. Category and tag archives use the term's name.`
|
|
9163
|
+
},
|
|
9164
|
+
{
|
|
9165
|
+
key: "navLabel",
|
|
9166
|
+
kind: "text",
|
|
9167
|
+
label: "Screen reader name",
|
|
9168
|
+
optional: true,
|
|
9169
|
+
message: `What screen readers call the links, in the site's language. Unset is "Pagination".`
|
|
9170
|
+
},
|
|
9171
|
+
{
|
|
9172
|
+
key: "pageLabel",
|
|
9173
|
+
kind: "text",
|
|
9174
|
+
label: "Page number name",
|
|
9175
|
+
optional: true,
|
|
9176
|
+
message: 'What screen readers call each number. {page} is filled in; unset is "Page {page}".'
|
|
9177
|
+
},
|
|
9178
|
+
{
|
|
9179
|
+
key: "prevLabel",
|
|
9180
|
+
kind: "text",
|
|
9181
|
+
label: "Previous name",
|
|
9182
|
+
optional: true,
|
|
9183
|
+
message: 'Read out when Previous text is only an arrow. Unset is "Previous page".'
|
|
9184
|
+
},
|
|
9185
|
+
{
|
|
9186
|
+
key: "nextLabel",
|
|
9187
|
+
kind: "text",
|
|
9188
|
+
label: "Next name",
|
|
9189
|
+
optional: true,
|
|
9190
|
+
message: 'Read out when Next text is only an arrow. Unset is "Next page".'
|
|
8727
9191
|
}
|
|
8728
9192
|
]
|
|
8729
9193
|
},
|
|
@@ -8753,6 +9217,17 @@ var section = {
|
|
|
8753
9217
|
// ../emvb/src/core/elements/index.ts
|
|
8754
9218
|
var HEADING_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
8755
9219
|
var newTabAttrs2 = (newTab) => newTab ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
9220
|
+
var TAG_LABELS = {
|
|
9221
|
+
div: "Div",
|
|
9222
|
+
section: "Section",
|
|
9223
|
+
header: "Header",
|
|
9224
|
+
footer: "Footer",
|
|
9225
|
+
main: "Main",
|
|
9226
|
+
article: "Article",
|
|
9227
|
+
aside: "Aside",
|
|
9228
|
+
nav: "Nav",
|
|
9229
|
+
p: "Paragraph (p)"
|
|
9230
|
+
};
|
|
8756
9231
|
var LINK_MESSAGE = "Use a full URL such as https://example.com or a path such as /pricing.";
|
|
8757
9232
|
var INNER_LINK_FIELDS = [
|
|
8758
9233
|
{ key: "href", kind: "href", label: "Link", optional: true, message: LINK_MESSAGE },
|
|
@@ -8800,10 +9275,11 @@ var heading = {
|
|
|
8800
9275
|
};
|
|
8801
9276
|
var BOX_LINK_FIELDS = [
|
|
8802
9277
|
{ key: "href", kind: "href", label: "Link", optional: true, message: LINK_MESSAGE },
|
|
8803
|
-
{ key: "newTab", kind: "boolean", label: "Open in new tab", optional: true }
|
|
9278
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true }
|
|
8804
9279
|
];
|
|
9280
|
+
var BOX_LINK_CSS = ":where(a.emvb-box-link){color:inherit;text-decoration:inherit}";
|
|
8805
9281
|
var container = {
|
|
8806
|
-
baseCss: ".emvb-container{display:flex;flex-direction:column;min-width:0;overflow-wrap:break-word}",
|
|
9282
|
+
baseCss: ".emvb-container{display:flex;flex-direction:column;min-width:0;overflow-wrap:break-word}" + BOX_LINK_CSS,
|
|
8807
9283
|
defaults: () => ({ type: "container", props: {}, children: [] }),
|
|
8808
9284
|
descriptor: {
|
|
8809
9285
|
type: "container",
|
|
@@ -8816,7 +9292,7 @@ var container = {
|
|
|
8816
9292
|
kind: "select",
|
|
8817
9293
|
label: "HTML tag",
|
|
8818
9294
|
optional: true,
|
|
8819
|
-
options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: tag })),
|
|
9295
|
+
options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
|
|
8820
9296
|
message: "Pick a landmark or div."
|
|
8821
9297
|
},
|
|
8822
9298
|
...BOX_LINK_FIELDS
|
|
@@ -8878,7 +9354,7 @@ var text = {
|
|
|
8878
9354
|
kind: "select",
|
|
8879
9355
|
label: "HTML tag",
|
|
8880
9356
|
optional: true,
|
|
8881
|
-
options: TEXT_TAGS.map((tag) => ({ value: tag, label: tag }))
|
|
9357
|
+
options: TEXT_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] }))
|
|
8882
9358
|
}
|
|
8883
9359
|
]
|
|
8884
9360
|
},
|
|
@@ -8929,7 +9405,7 @@ var link = {
|
|
|
8929
9405
|
}
|
|
8930
9406
|
};
|
|
8931
9407
|
var button = {
|
|
8932
|
-
baseCss: ".emvb-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5em;margin:0;font:inherit;text-decoration:none;cursor:pointer}:where(.emvb-button){color:inherit;background:transparent;border:1px solid currentColor;border-radius:6px;padding:0.625em 1.25em;line-height:1.2}.emvb-button-icon{display:inline-flex;flex:none}.emvb-button-icon svg{width:100%;height:100%;display:block}.emvb-button-icon--sm{width:1em;height:1em}.emvb-button-icon--md{width:1.25em;height:1.25em}.emvb-button-icon--lg{width:1.5em;height:1.5em}
|
|
9408
|
+
baseCss: ".emvb-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5em;overflow-wrap:anywhere;text-align:center;margin:0;font:inherit;text-decoration:none;cursor:pointer}:where(.emvb-button){color:inherit;background:transparent;border:1px solid currentColor;border-radius:6px;padding:0.625em 1.25em;line-height:1.2}.emvb-button-icon{display:inline-flex;flex:none}.emvb-button-icon svg{width:100%;height:100%;display:block}.emvb-button-icon--sm{width:1em;height:1em}.emvb-button-icon--md{width:1.25em;height:1.25em}.emvb-button-icon--lg{width:1.5em;height:1.5em}",
|
|
8933
9409
|
defaults: () => ({ type: "button", props: { text: "Button" } }),
|
|
8934
9410
|
descriptor: {
|
|
8935
9411
|
type: "button",
|
|
@@ -9022,7 +9498,7 @@ function buttonChildren(node) {
|
|
|
9022
9498
|
return node.props.iconPosition === "after" ? [buttonText, icon] : [icon, buttonText];
|
|
9023
9499
|
}
|
|
9024
9500
|
var list = {
|
|
9025
|
-
baseCss: ".emvb-list{margin:0;padding-inline-start:1.25em}.emvb-list li{margin:0}",
|
|
9501
|
+
baseCss: ".emvb-list{margin:0;padding-inline-start:1.25em}.emvb-list li{margin:0}.emvb-list--wide{padding-inline-start:2.25em}",
|
|
9026
9502
|
defaults: () => ({ type: "list", props: { items: ["Item"] } }),
|
|
9027
9503
|
descriptor: {
|
|
9028
9504
|
type: "list",
|
|
@@ -9034,14 +9510,18 @@ var list = {
|
|
|
9034
9510
|
{ key: "items", kind: "list-items", label: "Items" }
|
|
9035
9511
|
]
|
|
9036
9512
|
},
|
|
9037
|
-
build: (node, attrs) =>
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9513
|
+
build: (node, attrs) => {
|
|
9514
|
+
const items = node.props.items.filter((item) => item.trim() !== "");
|
|
9515
|
+
const wide = node.props.ordered === true && items.length >= 100;
|
|
9516
|
+
return {
|
|
9517
|
+
tag: node.props.ordered ? "ol" : "ul",
|
|
9518
|
+
attrs: wide ? { ...attrs, class: `${attrs.class ?? ""} emvb-list--wide`.trim() } : attrs,
|
|
9519
|
+
children: items.map((item) => ({ tag: "li", attrs: {}, children: [item] }))
|
|
9520
|
+
};
|
|
9521
|
+
}
|
|
9042
9522
|
};
|
|
9043
9523
|
var image = {
|
|
9044
|
-
baseCss: ".emvb-image{display:block;max-width:100%;height:auto}:where(img.emvb-image:not([width])){width:fit-content}",
|
|
9524
|
+
baseCss: ".emvb-image{display:block;max-width:100%;height:auto}:where(img.emvb-image:not([width])){width:fit-content}" + ".emvb-figure{margin:0}.emvb-figcaption{margin-top:0.35em}.emvb-image-link{display:contents}",
|
|
9045
9525
|
defaults: () => ({
|
|
9046
9526
|
type: "image",
|
|
9047
9527
|
props: { src: "", alt: "Image", decorative: false }
|
|
@@ -9062,7 +9542,7 @@ var image = {
|
|
|
9062
9542
|
{
|
|
9063
9543
|
key: "decorative",
|
|
9064
9544
|
kind: "boolean",
|
|
9065
|
-
label: "Decorative
|
|
9545
|
+
label: "Decorative",
|
|
9066
9546
|
optional: true
|
|
9067
9547
|
},
|
|
9068
9548
|
{ key: "priority", kind: "boolean", label: "Load right away", optional: true },
|
|
@@ -9146,33 +9626,40 @@ var srcsetUrl = (url) => url?.replaceAll(" ", "%20");
|
|
|
9146
9626
|
function imageSources(src, sources, width) {
|
|
9147
9627
|
if (!sources || sources.length === 0)
|
|
9148
9628
|
return;
|
|
9149
|
-
const
|
|
9150
|
-
const seen = new Set;
|
|
9629
|
+
const main = srcsetUrl(src);
|
|
9151
9630
|
let srcWidth;
|
|
9152
9631
|
for (const source of sources) {
|
|
9153
|
-
const url = srcsetUrl(sanitizeMediaUrl(source.src));
|
|
9154
9632
|
if (!validSourceWidth(source.width))
|
|
9155
9633
|
continue;
|
|
9156
|
-
if (
|
|
9157
|
-
srcWidth
|
|
9158
|
-
|
|
9634
|
+
if (srcsetUrl(sanitizeMediaUrl(source.src)) === main) {
|
|
9635
|
+
srcWidth = source.width;
|
|
9636
|
+
break;
|
|
9159
9637
|
}
|
|
9160
|
-
|
|
9638
|
+
}
|
|
9639
|
+
srcWidth ??= validSourceWidth(width) ? width : undefined;
|
|
9640
|
+
const mainListed = srcWidth !== undefined && main !== undefined && !/[\s,]/.test(main);
|
|
9641
|
+
const parts = [];
|
|
9642
|
+
const seen = new Set;
|
|
9643
|
+
const widths = new Set(mainListed ? [srcWidth] : []);
|
|
9644
|
+
for (const source of sources) {
|
|
9645
|
+
const url = srcsetUrl(sanitizeMediaUrl(source.src));
|
|
9646
|
+
if (!validSourceWidth(source.width) || url === main)
|
|
9647
|
+
continue;
|
|
9648
|
+
if (!url || /[\s,]/.test(url) || seen.has(url) || widths.has(source.width))
|
|
9161
9649
|
continue;
|
|
9162
9650
|
seen.add(url);
|
|
9651
|
+
widths.add(source.width);
|
|
9163
9652
|
parts.push(`${url} ${source.width}w`);
|
|
9164
9653
|
}
|
|
9165
9654
|
if (parts.length === 0)
|
|
9166
9655
|
return;
|
|
9167
|
-
|
|
9168
|
-
const main = srcsetUrl(src);
|
|
9169
|
-
if (srcWidth !== undefined && main && !/[\s,]/.test(main))
|
|
9656
|
+
if (mainListed)
|
|
9170
9657
|
parts.push(`${main} ${srcWidth}w`);
|
|
9171
9658
|
return parts.join(", ");
|
|
9172
9659
|
}
|
|
9173
9660
|
var ICON_STROKE_WIDTHS = ["1", "1.5", "2", "2.5", "3"];
|
|
9174
9661
|
var icon = {
|
|
9175
|
-
baseCss: ".emvb-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}.emvb-icon-link{display:inline-flex;color:inherit}.emvb-icon svg{display:block;rotate:var(--emvb-icon-rotate,0deg);scale:var(--emvb-icon-flip,1 1);filter:var(--emvb-icon-shadow,none);animation:var(--emvb-icon-animation,none);transition:inherit}" + ICON_STROKE_WIDTHS.map((width) => `.emvb-icon-sw${width.replace(".", "_")}{stroke-width:var(--emvb-icon-stroke,${width})}`).join("") + "@keyframes emvb-icon-spin{to{transform:rotate(360deg)}}@keyframes emvb-icon-pulse{from{transform:scale(1)}to{transform:scale(1.15)}}@media (prefers-reduced-motion: reduce){.emvb-icon svg{animation:none}}.emvb-icon-missing{min-width:1em;min-height:1em;background:var(--color-kumo-tint,#eee)}",
|
|
9662
|
+
baseCss: ".emvb-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}.emvb-icon-link{display:inline-flex;max-width:100%;color:inherit}.emvb-icon svg{display:block;max-width:100%;rotate:var(--emvb-icon-rotate,0deg);scale:var(--emvb-icon-flip,1 1);filter:var(--emvb-icon-shadow,none);animation:var(--emvb-icon-animation,none);transition:inherit}" + ICON_STROKE_WIDTHS.map((width) => `.emvb-icon-sw${width.replace(".", "_")}{stroke-width:var(--emvb-icon-stroke,${width})}`).join("") + "@keyframes emvb-icon-spin{to{transform:rotate(360deg)}}@keyframes emvb-icon-pulse{from{transform:scale(1)}to{transform:scale(1.15)}}@media (prefers-reduced-motion: reduce){.emvb-icon svg{animation:none}}.emvb-icon-missing{min-width:1em;min-height:1em;background:var(--color-kumo-tint,#eee)}",
|
|
9176
9663
|
defaults: () => ({
|
|
9177
9664
|
type: "icon",
|
|
9178
9665
|
props: { iconId: "star", title: "Star", decorative: false, size: 24 }
|
|
@@ -9188,7 +9675,7 @@ var icon = {
|
|
|
9188
9675
|
{
|
|
9189
9676
|
key: "decorative",
|
|
9190
9677
|
kind: "boolean",
|
|
9191
|
-
label: "Decorative
|
|
9678
|
+
label: "Decorative",
|
|
9192
9679
|
optional: true
|
|
9193
9680
|
},
|
|
9194
9681
|
{
|
|
@@ -9340,13 +9827,14 @@ var video = {
|
|
|
9340
9827
|
children: []
|
|
9341
9828
|
};
|
|
9342
9829
|
}
|
|
9830
|
+
const title = String(node.props.title ?? "").trim() || "Video";
|
|
9343
9831
|
if (target.kind === "iframe") {
|
|
9344
9832
|
return {
|
|
9345
9833
|
tag: "iframe",
|
|
9346
9834
|
attrs: {
|
|
9347
9835
|
...attrs,
|
|
9348
9836
|
src: target.src,
|
|
9349
|
-
title
|
|
9837
|
+
title,
|
|
9350
9838
|
loading: "lazy",
|
|
9351
9839
|
referrerpolicy: "strict-origin-when-cross-origin",
|
|
9352
9840
|
allow: "encrypted-media; picture-in-picture; fullscreen",
|
|
@@ -9360,7 +9848,7 @@ var video = {
|
|
|
9360
9848
|
attrs: {
|
|
9361
9849
|
...attrs,
|
|
9362
9850
|
src: target.src,
|
|
9363
|
-
title
|
|
9851
|
+
title,
|
|
9364
9852
|
controls: "",
|
|
9365
9853
|
preload: "metadata"
|
|
9366
9854
|
},
|
|
@@ -9407,7 +9895,7 @@ var svgEl = {
|
|
|
9407
9895
|
{
|
|
9408
9896
|
key: "decorative",
|
|
9409
9897
|
kind: "boolean",
|
|
9410
|
-
label: "Decorative
|
|
9898
|
+
label: "Decorative",
|
|
9411
9899
|
optional: true
|
|
9412
9900
|
},
|
|
9413
9901
|
{
|
|
@@ -9453,7 +9941,7 @@ var svgEl = {
|
|
|
9453
9941
|
return {
|
|
9454
9942
|
tag: "span",
|
|
9455
9943
|
attrs,
|
|
9456
|
-
children: [{ tag: "svg", attrs: svgAttrs, children: tree.children }]
|
|
9944
|
+
children: [{ tag: "svg", attrs: svgAttrs, children: scopeSvgIds(tree.children, node.id) }]
|
|
9457
9945
|
};
|
|
9458
9946
|
}
|
|
9459
9947
|
};
|
|
@@ -9474,7 +9962,7 @@ var tabPanel = {
|
|
|
9474
9962
|
build: (_node, attrs, children) => ({ tag: "div", attrs, children })
|
|
9475
9963
|
};
|
|
9476
9964
|
var tabs = {
|
|
9477
|
-
baseCss: ".emvb-tabs{display:flex;flex-direction:column;min-width:0;gap:0}.emvb-tab-input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}.emvb-tab-list{display:flex;flex-wrap:wrap;gap:0;border-bottom:1px solid currentColor;margin:0;padding:0}.emvb-tab-label{display:inline-block;padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px}.emvb-tab-panels{min-width:0}.emvb-tab-panel{
|
|
9965
|
+
baseCss: ".emvb-tabs{display:flex;flex-direction:column;min-width:0;gap:0}.emvb-tab-input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}.emvb-tab-list{display:flex;flex-wrap:wrap;gap:0;border-bottom:1px solid currentColor;margin:0;padding:0}.emvb-tab-label{display:inline-block;padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;min-width:0;overflow-wrap:anywhere}.emvb-tab-panels{min-width:0}.emvb-tab-panel{padding-top:12px;min-width:0}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(1){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(1)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(2){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(2)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(3){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(3)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(4){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(4)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(5){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(5)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(6){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(6)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(7){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(7)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(8){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(8)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(9){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(9)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(10){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(10)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(11){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(11)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(12){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(12)){display:none!important}",
|
|
9478
9966
|
defaults: () => ({
|
|
9479
9967
|
type: "tabs",
|
|
9480
9968
|
props: {},
|
|
@@ -9490,7 +9978,7 @@ var tabs = {
|
|
|
9490
9978
|
build: (_node, attrs, children) => ({ tag: "div", attrs, children })
|
|
9491
9979
|
};
|
|
9492
9980
|
var divBlock = {
|
|
9493
|
-
baseCss: ".emvb-div-block{display:block;min-width:0}",
|
|
9981
|
+
baseCss: ".emvb-div-block{display:block;min-width:0}" + BOX_LINK_CSS,
|
|
9494
9982
|
defaults: () => ({ type: "div-block", props: {}, children: [] }),
|
|
9495
9983
|
descriptor: {
|
|
9496
9984
|
type: "div-block",
|
|
@@ -9533,7 +10021,7 @@ var layoutSection = {
|
|
|
9533
10021
|
kind: "select",
|
|
9534
10022
|
label: "HTML tag",
|
|
9535
10023
|
optional: true,
|
|
9536
|
-
options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: tag })),
|
|
10024
|
+
options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
|
|
9537
10025
|
message: "Pick a landmark or div. A section is a section by default."
|
|
9538
10026
|
}
|
|
9539
10027
|
]
|
|
@@ -9547,7 +10035,7 @@ var layoutSection = {
|
|
|
9547
10035
|
};
|
|
9548
10036
|
var TRACKS_HINT = "Up to 12 tracks, one per line: 1fr, 2fr, 3fr, auto, min-content, max-content, or a length.";
|
|
9549
10037
|
var grid = {
|
|
9550
|
-
baseCss: ".emvb-grid{display:grid;min-width:0}",
|
|
10038
|
+
baseCss: ".emvb-grid{display:grid;min-width:0}" + BOX_LINK_CSS,
|
|
9551
10039
|
defaults: () => ({ type: "grid", props: { columns: 3 }, children: [] }),
|
|
9552
10040
|
descriptor: {
|
|
9553
10041
|
type: "grid",
|
|
@@ -9592,7 +10080,7 @@ var grid = {
|
|
|
9592
10080
|
build: (_node, attrs, children) => ({ tag: "div", attrs, children })
|
|
9593
10081
|
};
|
|
9594
10082
|
var flexbox = {
|
|
9595
|
-
baseCss: ".emvb-flexbox{display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;min-width:0;gap:16px}",
|
|
10083
|
+
baseCss: ".emvb-flexbox{display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;min-width:0;gap:16px;overflow-wrap:anywhere}" + BOX_LINK_CSS,
|
|
9596
10084
|
defaults: () => ({
|
|
9597
10085
|
type: "flexbox",
|
|
9598
10086
|
props: {},
|
|
@@ -9630,11 +10118,12 @@ var accordionItem = {
|
|
|
9630
10118
|
defaultTab: "content",
|
|
9631
10119
|
fields: [
|
|
9632
10120
|
{ key: "summary", kind: "text", label: "Title" },
|
|
9633
|
-
{ key: "open", kind: "boolean", label: "Open", optional: true }
|
|
10121
|
+
{ key: "open", kind: "boolean", label: "Open by default", optional: true }
|
|
9634
10122
|
]
|
|
9635
10123
|
},
|
|
9636
10124
|
build: (node, attrs, children) => {
|
|
9637
|
-
const
|
|
10125
|
+
const title = node.props.summary.trim() || "Details";
|
|
10126
|
+
const summary = { tag: "summary", attrs: {}, children: [title] };
|
|
9638
10127
|
const body = { tag: "div", attrs: { class: "emvb-accordion-body" }, children };
|
|
9639
10128
|
return {
|
|
9640
10129
|
tag: "details",
|
|
@@ -9763,7 +10252,8 @@ var LAYOUT_MIGRATIONS = {
|
|
|
9763
10252
|
11: gradients,
|
|
9764
10253
|
12: unchanged,
|
|
9765
10254
|
13: unchanged,
|
|
9766
|
-
14: unchanged
|
|
10255
|
+
14: unchanged,
|
|
10256
|
+
15: unchanged
|
|
9767
10257
|
};
|
|
9768
10258
|
var DESIGN_MIGRATIONS = {
|
|
9769
10259
|
1: unchanged,
|
|
@@ -9870,7 +10360,7 @@ var DesignSystem = strictObject({
|
|
|
9870
10360
|
function summarizeIssues(issues, max = 3) {
|
|
9871
10361
|
return issues.slice(0, max).map((issue) => issue.path ? `${issue.path}: ${issue.message}` : issue.message).join("; ");
|
|
9872
10362
|
}
|
|
9873
|
-
function
|
|
10363
|
+
function byteLength2(value) {
|
|
9874
10364
|
return new TextEncoder().encode(JSON.stringify(value)).length;
|
|
9875
10365
|
}
|
|
9876
10366
|
function formatPath(path) {
|
|
@@ -9941,7 +10431,7 @@ function duplicateIds(layout) {
|
|
|
9941
10431
|
function checkSize(input, limit, what) {
|
|
9942
10432
|
let bytes;
|
|
9943
10433
|
try {
|
|
9944
|
-
bytes =
|
|
10434
|
+
bytes = byteLength2(input);
|
|
9945
10435
|
} catch (error) {
|
|
9946
10436
|
if (!(error instanceof RangeError))
|
|
9947
10437
|
throw error;
|
|
@@ -10100,8 +10590,19 @@ function starterLayout(title, random) {
|
|
|
10100
10590
|
}
|
|
10101
10591
|
};
|
|
10102
10592
|
}
|
|
10103
|
-
function
|
|
10104
|
-
|
|
10593
|
+
function pageSlug(text, max = 80) {
|
|
10594
|
+
const slug = text.normalize("NFKC").toLowerCase().replace(/[\s_]+/gu, "-").replace(/[^\p{L}\p{N}\p{M}-]+/gu, "").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
10595
|
+
if (!/[\p{L}\p{N}]/u.test(slug))
|
|
10596
|
+
return "";
|
|
10597
|
+
let out = "";
|
|
10598
|
+
let count = 0;
|
|
10599
|
+
for (const { segment } of new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(slug)) {
|
|
10600
|
+
if (count >= max)
|
|
10601
|
+
break;
|
|
10602
|
+
out += segment;
|
|
10603
|
+
count++;
|
|
10604
|
+
}
|
|
10605
|
+
return out.replace(/-+$/g, "");
|
|
10105
10606
|
}
|
|
10106
10607
|
|
|
10107
10608
|
// ../emvb/src/core/arrange.ts
|
|
@@ -10240,6 +10741,8 @@ function moveNode(layout, id, parentId, index) {
|
|
|
10240
10741
|
const from = locate(layout, id);
|
|
10241
10742
|
const sameParent = from.parent.id === parentId;
|
|
10242
10743
|
const at = sameParent && from.index < index ? index - 1 : index;
|
|
10744
|
+
if (sameParent && at === from.index)
|
|
10745
|
+
return { ok: true, layout, selected: id };
|
|
10243
10746
|
const { layout: without, removed } = removeNode(layout, id);
|
|
10244
10747
|
if (!removed)
|
|
10245
10748
|
return refuse(REASONS.missing);
|
|
@@ -10297,6 +10800,27 @@ function nestingIssues(layout, max = 5) {
|
|
|
10297
10800
|
walk(layout.root, "root", isFormNode(layout.root));
|
|
10298
10801
|
return issues;
|
|
10299
10802
|
}
|
|
10803
|
+
// ../emvb/src/core/stable-json.ts
|
|
10804
|
+
function sorted(value) {
|
|
10805
|
+
if (Array.isArray(value))
|
|
10806
|
+
return value.map(sorted);
|
|
10807
|
+
if (!value || typeof value !== "object")
|
|
10808
|
+
return value;
|
|
10809
|
+
const entries = Object.entries(value).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
10810
|
+
return Object.fromEntries(entries.map(([k, v]) => [k, sorted(v)]));
|
|
10811
|
+
}
|
|
10812
|
+
var stableJson = (value) => JSON.stringify(sorted(value));
|
|
10813
|
+
|
|
10814
|
+
// ../emvb/src/core/design/classes.ts
|
|
10815
|
+
function cleanClassName(name) {
|
|
10816
|
+
const spaced = Array.from(name.normalize("NFC"), (ch) => {
|
|
10817
|
+
const code = ch.charCodeAt(0);
|
|
10818
|
+
return code < 32 || code >= 127 && code <= 159 ? " " : ch;
|
|
10819
|
+
}).join("").replace(/[\u200B\u2060\uFEFF\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "");
|
|
10820
|
+
const spacedTrim = spaced.replace(/ {2,}/g, " ").trim();
|
|
10821
|
+
return clipText(spacedTrim, 60).trim();
|
|
10822
|
+
}
|
|
10823
|
+
var nameKey = (name) => cleanClassName(name).toLowerCase();
|
|
10300
10824
|
// ../emvb/src/core/design/variables.ts
|
|
10301
10825
|
var isVariableRef = (value) => typeof value === "object" && value !== null && ("var" in value) && typeof value.var === "string";
|
|
10302
10826
|
function refMatchesKind(ref, kind) {
|
|
@@ -10339,6 +10863,7 @@ function collectAllUsages(owner, id, kind, hit) {
|
|
|
10339
10863
|
for (const device of RESPONSIVE) {
|
|
10340
10864
|
collectStyleUsages(owner.devices?.[device], id, kind, (prop) => hit(`${device}.${prop}`));
|
|
10341
10865
|
}
|
|
10866
|
+
collectStyleUsages(owner.query?.style, id, kind, (prop) => hit(`query.${prop}`));
|
|
10342
10867
|
}
|
|
10343
10868
|
function findVariableUsages(layout, id, kind) {
|
|
10344
10869
|
const usages = [];
|
|
@@ -10358,6 +10883,168 @@ function findVariableUsagesInDesign(design, id, kind) {
|
|
|
10358
10883
|
}
|
|
10359
10884
|
return usages;
|
|
10360
10885
|
}
|
|
10886
|
+
// ../emvb/src/core/audience/variants.ts
|
|
10887
|
+
function loneAbTests(layout) {
|
|
10888
|
+
const arms = new Map;
|
|
10889
|
+
const walk = (node) => {
|
|
10890
|
+
const v = node.variant;
|
|
10891
|
+
if (v) {
|
|
10892
|
+
const seen = arms.get(v.test) ?? new Set;
|
|
10893
|
+
seen.add(v.arm);
|
|
10894
|
+
arms.set(v.test, seen);
|
|
10895
|
+
}
|
|
10896
|
+
if (isParentNode(node))
|
|
10897
|
+
for (const child of node.children)
|
|
10898
|
+
walk(child);
|
|
10899
|
+
};
|
|
10900
|
+
walk(layout.root);
|
|
10901
|
+
return new Set([...arms].filter(([, seen]) => seen.size < 2).map(([test]) => test));
|
|
10902
|
+
}
|
|
10903
|
+
|
|
10904
|
+
// ../emvb/src/core/audience/rules.ts
|
|
10905
|
+
var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
10906
|
+
var DEVICE_LABELS = { mobile: "mobile", tablet: "tablet", desktop: "desktop" };
|
|
10907
|
+
function audienceSummary(audience) {
|
|
10908
|
+
const parts = [];
|
|
10909
|
+
if (audience.countries)
|
|
10910
|
+
parts.push(audience.countries.slice(0, 3).join(", ") + (audience.countries.length > 3 ? "…" : ""));
|
|
10911
|
+
if (audience.devices)
|
|
10912
|
+
parts.push(audience.devices.map((d) => DEVICE_LABELS[d]).join("/"));
|
|
10913
|
+
if (audience.visitor)
|
|
10914
|
+
parts.push(audience.visitor === "new" ? "new visitors" : "returning");
|
|
10915
|
+
if (audience.segments)
|
|
10916
|
+
parts.push(audience.segments.slice(0, 3).join("/") + (audience.segments.length > 3 ? "…" : ""));
|
|
10917
|
+
if (audience.hours)
|
|
10918
|
+
parts.push(`${audience.hours.from}:00–${audience.hours.to}:00`);
|
|
10919
|
+
if (audience.days)
|
|
10920
|
+
parts.push(audience.days.map((d) => WEEKDAYS[d]).join(" "));
|
|
10921
|
+
const who = parts.join(" · ") || "everyone";
|
|
10922
|
+
return audience.hide ? `Hidden for ${who}` : `Only ${who}`;
|
|
10923
|
+
}
|
|
10924
|
+
|
|
10925
|
+
// ../emvb/src/core/forms/definition.ts
|
|
10926
|
+
var OPTION_TYPES = new Set(["select", "radio", "checkbox-group"]);
|
|
10927
|
+
var FREE_CONTROLS = new Set(["text-input", "textarea", "checkbox"]);
|
|
10928
|
+
|
|
10929
|
+
// ../emvb/src/core/forms/binding.ts
|
|
10930
|
+
var FIELD_TYPES = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
|
|
10931
|
+
var DEVICE_ORDER = ["desktop", "tablet", "mobile"];
|
|
10932
|
+
function splitKey(node, lone) {
|
|
10933
|
+
const audience = node.audience;
|
|
10934
|
+
if (audience) {
|
|
10935
|
+
const { hide, ...rules } = audience;
|
|
10936
|
+
return `aud:${hide ? 1 : 0}:${stableJson(rules)}`;
|
|
10937
|
+
}
|
|
10938
|
+
if (node.variant && !lone.has(node.variant.test)) {
|
|
10939
|
+
return `ab:${node.variant.test}:${node.variant.arm}`;
|
|
10940
|
+
}
|
|
10941
|
+
return;
|
|
10942
|
+
}
|
|
10943
|
+
function restriction(node, lone) {
|
|
10944
|
+
const audience = node.audience;
|
|
10945
|
+
if (audience) {
|
|
10946
|
+
const { hide, timeZone: _zone, ...rules } = audience;
|
|
10947
|
+
if (hide || Object.values(rules).some((rule) => rule !== undefined)) {
|
|
10948
|
+
return audienceSummary(audience);
|
|
10949
|
+
}
|
|
10950
|
+
}
|
|
10951
|
+
if (node.variant && !lone.has(node.variant.test)) {
|
|
10952
|
+
return `Variant ${node.variant.arm.toUpperCase()} of A/B test ${node.variant.test}`;
|
|
10953
|
+
}
|
|
10954
|
+
return;
|
|
10955
|
+
}
|
|
10956
|
+
function boundControls(form) {
|
|
10957
|
+
const lone = loneAbTests({ schemaVersion: LAYOUT_SCHEMA_VERSION, root: form });
|
|
10958
|
+
const found = new Map;
|
|
10959
|
+
const walk = (node, inherited, limited) => {
|
|
10960
|
+
const own = node.hiddenOn ?? [];
|
|
10961
|
+
const hidden = own.length ? new Set([...inherited, ...own]) : inherited;
|
|
10962
|
+
let scope = limited;
|
|
10963
|
+
if (!scope) {
|
|
10964
|
+
const who = restriction(node, lone);
|
|
10965
|
+
if (who)
|
|
10966
|
+
scope = { who, split: splitKey(node, lone) };
|
|
10967
|
+
}
|
|
10968
|
+
if (FIELD_TYPES.has(node.type)) {
|
|
10969
|
+
const field = node.props.field;
|
|
10970
|
+
if (typeof field === "string" && field) {
|
|
10971
|
+
const control = { nodeId: node.id, hidden: new Set(hidden) };
|
|
10972
|
+
if (scope) {
|
|
10973
|
+
control.who = scope.who;
|
|
10974
|
+
if (scope.split)
|
|
10975
|
+
control.split = scope.split;
|
|
10976
|
+
}
|
|
10977
|
+
found.set(field, [...found.get(field) ?? [], control]);
|
|
10978
|
+
}
|
|
10979
|
+
}
|
|
10980
|
+
for (const child of nodeChildren(node))
|
|
10981
|
+
walk(child, hidden, scope);
|
|
10982
|
+
};
|
|
10983
|
+
for (const child of nodeChildren(form))
|
|
10984
|
+
walk(child, new Set, undefined);
|
|
10985
|
+
return found;
|
|
10986
|
+
}
|
|
10987
|
+
function coversEveryone(controls) {
|
|
10988
|
+
const splits = new Set(controls.map((control) => control.split));
|
|
10989
|
+
for (const key of splits) {
|
|
10990
|
+
if (!key)
|
|
10991
|
+
continue;
|
|
10992
|
+
const ab = /^ab:(.*):([ab])$/.exec(key);
|
|
10993
|
+
if (ab && splits.has(`ab:${ab[1]}:${ab[2] === "a" ? "b" : "a"}`))
|
|
10994
|
+
return true;
|
|
10995
|
+
if (key.startsWith("aud:0:") && splits.has(`aud:1:${key.slice(6)}`))
|
|
10996
|
+
return true;
|
|
10997
|
+
}
|
|
10998
|
+
return false;
|
|
10999
|
+
}
|
|
11000
|
+
function requiredFieldIssues(form, fields) {
|
|
11001
|
+
const controls = boundControls(form);
|
|
11002
|
+
const issues = [];
|
|
11003
|
+
for (const field of fields) {
|
|
11004
|
+
if (!field.required || field.type === "hidden")
|
|
11005
|
+
continue;
|
|
11006
|
+
const label = field.label.trim() || field.name;
|
|
11007
|
+
const bound = controls.get(field.name);
|
|
11008
|
+
if (!bound?.length) {
|
|
11009
|
+
issues.push({ kind: "missing", formNodeId: form.id, field: field.name, label });
|
|
11010
|
+
continue;
|
|
11011
|
+
}
|
|
11012
|
+
const devices = DEVICE_ORDER.filter((device) => bound.every((c) => c.hidden.has(device)));
|
|
11013
|
+
if (devices.length) {
|
|
11014
|
+
issues.push({
|
|
11015
|
+
kind: "hidden",
|
|
11016
|
+
formNodeId: form.id,
|
|
11017
|
+
field: field.name,
|
|
11018
|
+
label,
|
|
11019
|
+
nodeId: bound[0].nodeId,
|
|
11020
|
+
devices
|
|
11021
|
+
});
|
|
11022
|
+
continue;
|
|
11023
|
+
}
|
|
11024
|
+
const first = bound[0];
|
|
11025
|
+
if (bound.every((control) => control.who !== undefined) && !coversEveryone(bound)) {
|
|
11026
|
+
issues.push({
|
|
11027
|
+
kind: "audience",
|
|
11028
|
+
formNodeId: form.id,
|
|
11029
|
+
field: field.name,
|
|
11030
|
+
label,
|
|
11031
|
+
nodeId: first.nodeId,
|
|
11032
|
+
who: first.who
|
|
11033
|
+
});
|
|
11034
|
+
}
|
|
11035
|
+
}
|
|
11036
|
+
return issues;
|
|
11037
|
+
}
|
|
11038
|
+
function requiredFieldIssueText(issue) {
|
|
11039
|
+
if (issue.kind === "missing") {
|
|
11040
|
+
return `“${issue.label}” is required by the form but has no field here, so the form can't be sent. Add a field bound to ${issue.field}, or make it optional in Forms.`;
|
|
11041
|
+
}
|
|
11042
|
+
if (issue.kind === "audience") {
|
|
11043
|
+
return `“${issue.label}” is required but shown only to some visitors (${issue.who}), so everyone else can't send the form. Remove the rule from the field, or make it optional in Forms.`;
|
|
11044
|
+
}
|
|
11045
|
+
const where = issue.devices.length === 3 ? "on every device" : `on ${issue.devices.join(" and ")}`;
|
|
11046
|
+
return `“${issue.label}” is required but hidden ${where}, so visitors there can't send the form. Show the field there, or make it optional in Forms.`;
|
|
11047
|
+
}
|
|
10361
11048
|
// ../emvb/src/core/theme/dynamic.ts
|
|
10362
11049
|
var BLOCK_STYLES = new Set(["normal", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote"]);
|
|
10363
11050
|
var DECORATORS = {
|
|
@@ -10380,22 +11067,33 @@ function linkDefs(block) {
|
|
|
10380
11067
|
}
|
|
10381
11068
|
return links;
|
|
10382
11069
|
}
|
|
10383
|
-
function
|
|
11070
|
+
function withBreaks(text) {
|
|
11071
|
+
const out = [];
|
|
11072
|
+
text.split(`
|
|
11073
|
+
`).forEach((part, i) => {
|
|
11074
|
+
if (i > 0)
|
|
11075
|
+
out.push({ tag: "br", attrs: {}, children: [] });
|
|
11076
|
+
if (part)
|
|
11077
|
+
out.push(part);
|
|
11078
|
+
});
|
|
11079
|
+
return out;
|
|
11080
|
+
}
|
|
11081
|
+
function spanNodes(span, links) {
|
|
10384
11082
|
const text = typeof span["text"] === "string" ? span["text"] : "";
|
|
10385
11083
|
if (!text)
|
|
10386
|
-
return
|
|
11084
|
+
return [];
|
|
10387
11085
|
const marks = Array.isArray(span["marks"]) ? span["marks"].filter((m) => typeof m === "string") : [];
|
|
10388
|
-
let
|
|
11086
|
+
let nodes = withBreaks(text);
|
|
10389
11087
|
const link = marks.find((mark) => !DECORATORS[mark] && links.has(mark));
|
|
10390
11088
|
for (const mark of new Set(marks.toReversed())) {
|
|
10391
11089
|
const tag = DECORATORS[mark];
|
|
10392
11090
|
if (tag)
|
|
10393
|
-
|
|
11091
|
+
nodes = [{ tag, attrs: {}, children: nodes }];
|
|
10394
11092
|
else if (mark === link) {
|
|
10395
|
-
|
|
11093
|
+
nodes = [{ tag: "a", attrs: { href: links.get(mark) }, children: nodes }];
|
|
10396
11094
|
}
|
|
10397
11095
|
}
|
|
10398
|
-
return
|
|
11096
|
+
return nodes;
|
|
10399
11097
|
}
|
|
10400
11098
|
function inlineNodes(block) {
|
|
10401
11099
|
const links = linkDefs(block);
|
|
@@ -10404,20 +11102,7 @@ function inlineNodes(block) {
|
|
|
10404
11102
|
for (const child of children) {
|
|
10405
11103
|
if (!isRecord(child) || child["_type"] !== undefined && child["_type"] !== "span")
|
|
10406
11104
|
continue;
|
|
10407
|
-
|
|
10408
|
-
if (node === null)
|
|
10409
|
-
continue;
|
|
10410
|
-
if (typeof node === "string" && node.includes(`
|
|
10411
|
-
`)) {
|
|
10412
|
-
node.split(`
|
|
10413
|
-
`).forEach((part, i) => {
|
|
10414
|
-
if (i > 0)
|
|
10415
|
-
out.push({ tag: "br", attrs: {}, children: [] });
|
|
10416
|
-
if (part)
|
|
10417
|
-
out.push(part);
|
|
10418
|
-
});
|
|
10419
|
-
} else
|
|
10420
|
-
out.push(node);
|
|
11105
|
+
out.push(...spanNodes(child, links));
|
|
10421
11106
|
}
|
|
10422
11107
|
return out;
|
|
10423
11108
|
}
|
|
@@ -10441,8 +11126,9 @@ function tidy(nodes) {
|
|
|
10441
11126
|
var hasText = (nodes) => nodes.some((n) => typeof n === "string" ? n.trim() !== "" : hasText(n.children));
|
|
10442
11127
|
function portableTextToVNodes(value) {
|
|
10443
11128
|
if (typeof value === "string") {
|
|
10444
|
-
|
|
10445
|
-
|
|
11129
|
+
return value.replaceAll(`\r
|
|
11130
|
+
`, `
|
|
11131
|
+
`).split(/\n[ \t]*\n/).map((para) => para.trim()).filter(Boolean).map((para) => ({ tag: "p", attrs: {}, children: withBreaks(para) }));
|
|
10446
11132
|
}
|
|
10447
11133
|
if (!Array.isArray(value))
|
|
10448
11134
|
return [];
|
|
@@ -10486,10 +11172,57 @@ function portableTextToVNodes(value) {
|
|
|
10486
11172
|
const tag = style === "normal" ? "p" : style;
|
|
10487
11173
|
out.push({ tag, attrs: {}, children: inline });
|
|
10488
11174
|
}
|
|
10489
|
-
return out
|
|
11175
|
+
return pruneEmptyLists(out);
|
|
11176
|
+
}
|
|
11177
|
+
var isList = (n) => n.tag === "ul" || n.tag === "ol";
|
|
11178
|
+
function pruneEmptyLists(nodes) {
|
|
11179
|
+
const keep = [];
|
|
11180
|
+
for (const node of nodes) {
|
|
11181
|
+
if (isList(node)) {
|
|
11182
|
+
const items = [];
|
|
11183
|
+
for (const li of node.children) {
|
|
11184
|
+
if (typeof li === "string")
|
|
11185
|
+
continue;
|
|
11186
|
+
li.children = li.children.flatMap((c) => typeof c !== "string" && isList(c) ? pruneEmptyLists([c]) : [c]);
|
|
11187
|
+
if (li.children.length > 0)
|
|
11188
|
+
items.push(li);
|
|
11189
|
+
}
|
|
11190
|
+
node.children = items;
|
|
11191
|
+
if (items.length > 0)
|
|
11192
|
+
keep.push(node);
|
|
11193
|
+
} else
|
|
11194
|
+
keep.push(node);
|
|
11195
|
+
}
|
|
11196
|
+
return keep;
|
|
10490
11197
|
}
|
|
10491
11198
|
|
|
10492
11199
|
// ../emvb/src/core/render/dynamic-post.ts
|
|
11200
|
+
var UNSPACED = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u;
|
|
11201
|
+
var wordSegmenter;
|
|
11202
|
+
function limitWords(text, max) {
|
|
11203
|
+
if (!max || max < 1)
|
|
11204
|
+
return text;
|
|
11205
|
+
let count = 0;
|
|
11206
|
+
for (const chunk of text.matchAll(/\S+/g)) {
|
|
11207
|
+
const start = chunk.index ?? 0;
|
|
11208
|
+
if (!UNSPACED.test(chunk[0])) {
|
|
11209
|
+
count++;
|
|
11210
|
+
if (count === max)
|
|
11211
|
+
return finish(text, start + chunk[0].length);
|
|
11212
|
+
continue;
|
|
11213
|
+
}
|
|
11214
|
+
wordSegmenter ??= new Intl.Segmenter(undefined, { granularity: "word" });
|
|
11215
|
+
for (const piece of wordSegmenter.segment(chunk[0])) {
|
|
11216
|
+
if (!piece.isWordLike)
|
|
11217
|
+
continue;
|
|
11218
|
+
count++;
|
|
11219
|
+
if (count === max)
|
|
11220
|
+
return finish(text, start + piece.index + piece.segment.length);
|
|
11221
|
+
}
|
|
11222
|
+
}
|
|
11223
|
+
return text;
|
|
11224
|
+
}
|
|
11225
|
+
var finish = (text, end) => text.slice(end).trim() === "" ? text : `${text.slice(0, end).trim().replace(/\s+/g, " ")}…`;
|
|
10493
11226
|
var parseIsoDate = (raw) => {
|
|
10494
11227
|
const match = /^(\d{4})-(\d{2})-(\d{2})(?:[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/.exec(raw);
|
|
10495
11228
|
if (!match)
|
|
@@ -10498,13 +11231,22 @@ var parseIsoDate = (raw) => {
|
|
|
10498
11231
|
if (Number.isNaN(parsed))
|
|
10499
11232
|
return Number.NaN;
|
|
10500
11233
|
const day = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])));
|
|
10501
|
-
return day.getUTCDate() === Number(match[3]) && day.getUTCMonth() === Number(match[2]) - 1 ?
|
|
11234
|
+
return day.getUTCDate() === Number(match[3]) && day.getUTCMonth() === Number(match[2]) - 1 ? day.getTime() : Number.NaN;
|
|
10502
11235
|
};
|
|
10503
|
-
function
|
|
11236
|
+
function dateLocale(lang) {
|
|
11237
|
+
if (!lang || !/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/.test(lang))
|
|
11238
|
+
return "en";
|
|
11239
|
+
try {
|
|
11240
|
+
return Intl.DateTimeFormat.supportedLocalesOf([lang])[0] ?? "en";
|
|
11241
|
+
} catch {
|
|
11242
|
+
return "en";
|
|
11243
|
+
}
|
|
11244
|
+
}
|
|
11245
|
+
function formatPostDate(time, format, lang) {
|
|
10504
11246
|
const date = new Date(time);
|
|
10505
11247
|
if (format === "numeric")
|
|
10506
11248
|
return date.toISOString().slice(0, 10);
|
|
10507
|
-
return new Intl.DateTimeFormat(
|
|
11249
|
+
return new Intl.DateTimeFormat(dateLocale(lang), { dateStyle: format, timeZone: "UTC" }).format(date);
|
|
10508
11250
|
}
|
|
10509
11251
|
var props = (node) => node.props;
|
|
10510
11252
|
var POST_FIELDS = new Map([
|
|
@@ -10512,6 +11254,7 @@ var POST_FIELDS = new Map([
|
|
|
10512
11254
|
"post-title",
|
|
10513
11255
|
{
|
|
10514
11256
|
placeholder: (attrs) => ({ tag: "h1", attrs, children: ["Post Title"] }),
|
|
11257
|
+
has: (post) => !!post.title?.trim(),
|
|
10515
11258
|
render: (node, attrs, post) => {
|
|
10516
11259
|
const level = props(node).level ?? 1;
|
|
10517
11260
|
const tag = HEADING_TAGS[Math.min(6, Math.max(1, level)) - 1] ?? "h1";
|
|
@@ -10524,11 +11267,9 @@ var POST_FIELDS = new Map([
|
|
|
10524
11267
|
{
|
|
10525
11268
|
placeholder: (attrs) => ({ tag: "p", attrs, children: ["Post excerpt…"] }),
|
|
10526
11269
|
render: (node, attrs, post) => {
|
|
10527
|
-
if (!post.excerpt)
|
|
11270
|
+
if (!post.excerpt?.trim())
|
|
10528
11271
|
return;
|
|
10529
|
-
const
|
|
10530
|
-
const words = post.excerpt.trim().split(/\s+/);
|
|
10531
|
-
const text = max && words.length > max ? `${words.slice(0, max).join(" ")}…` : post.excerpt;
|
|
11272
|
+
const text = limitWords(post.excerpt, props(node).maxWords);
|
|
10532
11273
|
return { tag: "p", attrs, children: [text] };
|
|
10533
11274
|
}
|
|
10534
11275
|
}
|
|
@@ -10560,7 +11301,7 @@ var POST_FIELDS = new Map([
|
|
|
10560
11301
|
const src = sanitizeMediaUrl(post.featuredImageUrl ?? "");
|
|
10561
11302
|
if (!src)
|
|
10562
11303
|
return;
|
|
10563
|
-
const alt = props(node).decorative ? "" : post.featuredImageAlt?.trim() || post.title || "Featured image";
|
|
11304
|
+
const alt = props(node).decorative ? "" : post.featuredImageAlt?.trim() || post.title?.trim() || "Featured image";
|
|
10564
11305
|
const lazy = inLoop ? { loading: "lazy", decoding: "async" } : {};
|
|
10565
11306
|
return { tag: "img", attrs: { ...attrs, src, alt, ...lazy }, children: [] };
|
|
10566
11307
|
}
|
|
@@ -10602,13 +11343,13 @@ var POST_FIELDS = new Map([
|
|
|
10602
11343
|
{
|
|
10603
11344
|
placeholder: (attrs) => ({ tag: "time", attrs, children: ["Post date"] }),
|
|
10604
11345
|
has: (post) => !!post.publishedAt?.trim(),
|
|
10605
|
-
render: (node, attrs, post) => {
|
|
11346
|
+
render: (node, attrs, post, _inLoop, lang) => {
|
|
10606
11347
|
const raw = post.publishedAt?.trim();
|
|
10607
11348
|
if (!raw)
|
|
10608
11349
|
return;
|
|
10609
11350
|
const parsed = parseIsoDate(raw);
|
|
10610
11351
|
const format = props(node).format ?? "medium";
|
|
10611
|
-
const text = Number.isNaN(parsed) ? raw
|
|
11352
|
+
const text = Number.isNaN(parsed) ? clipText(raw, 80) : formatPostDate(parsed, format, lang);
|
|
10612
11353
|
const timeAttrs = Number.isNaN(parsed) ? attrs : { ...attrs, datetime: raw.slice(0, 80) };
|
|
10613
11354
|
return { tag: "time", attrs: timeAttrs, children: [text] };
|
|
10614
11355
|
}
|
|
@@ -10621,7 +11362,7 @@ var POST_FIELDS = new Map([
|
|
|
10621
11362
|
has: (post) => !!post.authorName?.trim(),
|
|
10622
11363
|
render: (_node, attrs, post) => {
|
|
10623
11364
|
const name = post.authorName?.trim();
|
|
10624
|
-
return name ? { tag: "span", attrs, children: [name
|
|
11365
|
+
return name ? { tag: "span", attrs, children: [clipText(name, 200)] } : undefined;
|
|
10625
11366
|
}
|
|
10626
11367
|
}
|
|
10627
11368
|
]
|
|
@@ -10630,6 +11371,10 @@ var POST_FIELDS = new Map([
|
|
|
10630
11371
|
// ../emvb/src/core/render/form.ts
|
|
10631
11372
|
var INPUT_TYPES = new Set(["email", "tel", "url", "number", "date"]);
|
|
10632
11373
|
var LENGTH_TYPES = new Set(["text", "email", "tel", "url", "textarea"]);
|
|
11374
|
+
var CONDITION_OPS = new Set(["eq", "neq", "filled", "empty"]);
|
|
11375
|
+
|
|
11376
|
+
// ../emvb/src/core/render/section.ts
|
|
11377
|
+
var sizes = new WeakMap;
|
|
10633
11378
|
|
|
10634
11379
|
// ../emvb/src/core/sanitize/escape.ts
|
|
10635
11380
|
var TEXT_ENTITIES = { "&": "&", "<": "<", ">": ">" };
|
|
@@ -10753,8 +11498,59 @@ var FORMS_RUNTIME_ATTRS = new Set([
|
|
|
10753
11498
|
"data-submit-label",
|
|
10754
11499
|
"data-was-required"
|
|
10755
11500
|
]);
|
|
11501
|
+
function childrenOf(node) {
|
|
11502
|
+
return "children" in node && Array.isArray(node.children) ? node.children : [];
|
|
11503
|
+
}
|
|
11504
|
+
var ALWAYS_INTERACTIVE = new Set([
|
|
11505
|
+
"link",
|
|
11506
|
+
"post-link",
|
|
11507
|
+
"button",
|
|
11508
|
+
"menu",
|
|
11509
|
+
"menu-item",
|
|
11510
|
+
"accordion",
|
|
11511
|
+
"accordion-item",
|
|
11512
|
+
"tabs",
|
|
11513
|
+
"video",
|
|
11514
|
+
"form",
|
|
11515
|
+
"text-input",
|
|
11516
|
+
"textarea",
|
|
11517
|
+
"select",
|
|
11518
|
+
"checkbox",
|
|
11519
|
+
"radio",
|
|
11520
|
+
"submit",
|
|
11521
|
+
"pagination",
|
|
11522
|
+
"toc",
|
|
11523
|
+
"post-content"
|
|
11524
|
+
]);
|
|
11525
|
+
function containsInteractive(node) {
|
|
11526
|
+
if (ALWAYS_INTERACTIVE.has(node.type))
|
|
11527
|
+
return true;
|
|
11528
|
+
const props = node.props;
|
|
11529
|
+
if (node.type === "section" && typeof props.partId === "string" && props.partId.trim())
|
|
11530
|
+
return true;
|
|
11531
|
+
if (node.type === "loop" && typeof props.itemPartId === "string" && props.itemPartId.trim()) {
|
|
11532
|
+
return true;
|
|
11533
|
+
}
|
|
11534
|
+
if (BOX.has(node.type) || node.type === "heading" || node.type === "icon" || node.type === "image") {
|
|
11535
|
+
const href = node.props.href;
|
|
11536
|
+
if (typeof href === "string" && href.trim())
|
|
11537
|
+
return true;
|
|
11538
|
+
}
|
|
11539
|
+
return childrenOf(node).some(containsInteractive);
|
|
11540
|
+
}
|
|
11541
|
+
function boxBecomesLink(node) {
|
|
11542
|
+
if (!BOX.has(node.type))
|
|
11543
|
+
return false;
|
|
11544
|
+
const { href, tag } = node.props;
|
|
11545
|
+
if (tag !== undefined && tag !== "div")
|
|
11546
|
+
return false;
|
|
11547
|
+
if (typeof href !== "string" || !href.trim() || !sanitizeHref(href))
|
|
11548
|
+
return false;
|
|
11549
|
+
return !childrenOf(node).some(containsInteractive);
|
|
11550
|
+
}
|
|
10756
11551
|
// ../emvb/src/core/render/index.ts
|
|
10757
|
-
var
|
|
11552
|
+
var FIELD_TYPES2 = new Set(FORM_FIELD_TYPES.filter((type) => type !== "submit"));
|
|
11553
|
+
var MAX_SECTION_ELEMENTS = 20 * MAX_NODES;
|
|
10758
11554
|
// ../emvb/src/core/design/transfer.ts
|
|
10759
11555
|
var MAX_DESIGN_FILE_BYTES = 1024 * 1024;
|
|
10760
11556
|
// ../emvb/src/core/sanitize/svg-upload.ts
|
|
@@ -10817,7 +11613,7 @@ var ConditionsDocSchema = strictObject({
|
|
|
10817
11613
|
// ../emvb/src/core/theme/triggers.ts
|
|
10818
11614
|
var TRIGGERS_SCHEMA_VERSION = 1;
|
|
10819
11615
|
var MAX_POPUP_TRIGGERS = 8;
|
|
10820
|
-
var MAX_CLICK_SELECTOR_LENGTH =
|
|
11616
|
+
var MAX_CLICK_SELECTOR_LENGTH = TRIGGER_LIMITS.maxClickSelectorLength;
|
|
10821
11617
|
var MAX_SHOW_TIMES = 100;
|
|
10822
11618
|
var PageLoadTrigger = strictObject({ type: literal("page_load") });
|
|
10823
11619
|
var DelayTrigger = strictObject({
|
|
@@ -10861,7 +11657,7 @@ var POPUP_CHROME_CSS = `
|
|
|
10861
11657
|
.emvb-popup[hidden]{display:none!important}
|
|
10862
11658
|
.emvb-popup__backdrop{position:absolute;inset:0;background:rgba(15,23,42,.55)}
|
|
10863
11659
|
.emvb-popup__dialog{position:relative;z-index:1;max-width:min(36rem,100%);max-height:min(90vh,100%);overflow:auto;background:#fff;color:#0f172a;border-radius:.75rem;box-shadow:0 25px 50px -12px rgba(0,0,0,.35);padding:1.5rem 1.5rem 1.25rem}
|
|
10864
|
-
.emvb-popup__close{position:
|
|
11660
|
+
.emvb-popup__close{position:sticky;top:-1rem;z-index:1;float:right;margin:-1rem -1rem 0 .5rem;width:2rem;height:2rem;border:0;border-radius:999px;background:inherit;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
|
|
10865
11661
|
.emvb-popup__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
|
|
10866
11662
|
.emvb-popup__content{min-width:12rem}
|
|
10867
11663
|
`.replace(/\n+/g, "").trim();
|
|
@@ -10892,12 +11688,15 @@ var FLOAT_CHROME_CSS = `
|
|
|
10892
11688
|
:where(.emvb-float--surface){background:#fff;color:#0f172a;box-shadow:0 4px 16px -4px rgba(15,23,42,.25);padding:.5rem 1rem}
|
|
10893
11689
|
:where(.emvb-float--surface:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom)){border-radius:.75rem;padding:.75rem 1rem}
|
|
10894
11690
|
.emvb-float__body{min-width:0;flex:1}
|
|
11691
|
+
.emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom){max-width:calc(100% - 2rem)}
|
|
11692
|
+
.emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom) .emvb-float__body{max-height:calc(100vh - 3.5rem);max-height:calc(100dvh - 3.5rem);overflow:auto}
|
|
10895
11693
|
.emvb-float__close{flex:none;width:2rem;height:2rem;border:0;border-radius:999px;background:transparent;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
|
|
10896
11694
|
.emvb-float__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
|
|
10897
|
-
html{--emvb-float-top:0px;--emvb-float-bottom:0px}
|
|
11695
|
+
html{--emvb-float-top:0px;--emvb-float-bottom:0px;scroll-padding-top:var(--emvb-float-top);scroll-padding-bottom:var(--emvb-float-bottom)}
|
|
10898
11696
|
body{padding-top:var(--emvb-float-top);padding-bottom:var(--emvb-float-bottom)}
|
|
10899
11697
|
`.replace(/\n+/g, "").trim();
|
|
10900
11698
|
// ../emvb/src/core/a11y/audit.ts
|
|
11699
|
+
var spoken = (value) => String(value ?? "").replace(/[\p{Cf}\u115F\u1160\u2800\u3164\uFFA0]/gu, "").trim();
|
|
10901
11700
|
var WEIGHT = { error: 12, warning: 4 };
|
|
10902
11701
|
var USELESS_ALT = /^(?:image|img|photo|picture|graphic|logo|icon|untitled|\s*)$|\.(?:jpe?g|png|gif|webp|avif|svg)$|^(?:img|dsc|pxl|screen ?shot|whatsapp image)[\s_-]?\d+/i;
|
|
10903
11702
|
var VAGUE = /^(?:click here|here|read more|more|learn more|link|this|go|see more|view more|more info(?:rmation)?|details|find out more|continue reading|read more here|click here to (?:read|learn) more)\s*[.!…:»›→>\u2192\u203a\u00bb-]*$/i;
|
|
@@ -10949,9 +11748,15 @@ var TEXT_TYPES = new Set([
|
|
|
10949
11748
|
"post-title",
|
|
10950
11749
|
"post-excerpt"
|
|
10951
11750
|
]);
|
|
10952
|
-
var
|
|
11751
|
+
var FIELD_TYPES3 = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
|
|
10953
11752
|
var LINKISH = new Set(["link", "button", "menu-item"]);
|
|
10954
|
-
function px(value) {
|
|
11753
|
+
function px(value, design) {
|
|
11754
|
+
if (design && value && typeof value === "object" && "var" in value) {
|
|
11755
|
+
const found = design.variables.fontSizes?.find((v) => v.id === value.var);
|
|
11756
|
+
if (!found)
|
|
11757
|
+
return;
|
|
11758
|
+
return found.fluid ? Math.min(found.fluid.min, found.fluid.max) : px(found.value);
|
|
11759
|
+
}
|
|
10955
11760
|
if (!value || typeof value !== "object" || !("unit" in value))
|
|
10956
11761
|
return;
|
|
10957
11762
|
const v = value;
|
|
@@ -10961,12 +11766,39 @@ function px(value) {
|
|
|
10961
11766
|
return v.value * 16;
|
|
10962
11767
|
return;
|
|
10963
11768
|
}
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
11769
|
+
var HEADING_PX = [32, 24, 18.72, 16, 13.28, 10.72];
|
|
11770
|
+
var headingLevel = (node) => {
|
|
11771
|
+
if (node.type !== "heading")
|
|
11772
|
+
return;
|
|
11773
|
+
const level = node.props.level;
|
|
11774
|
+
return typeof level === "number" && level >= 1 && level <= 6 ? level : 2;
|
|
11775
|
+
};
|
|
11776
|
+
function effectiveStyle(node, design) {
|
|
11777
|
+
const level = headingLevel(node);
|
|
11778
|
+
const tagDefaults = level === undefined ? undefined : design.defaults?.[`h${level}`];
|
|
11779
|
+
const classIds = new Set(node.classes ?? []);
|
|
11780
|
+
if (classIds.size === 0 && !tagDefaults)
|
|
11781
|
+
return node.style;
|
|
11782
|
+
const fromClasses = (design.classes ?? []).filter((c) => classIds.has(c.id)).reduce((acc, c) => Object.assign(acc, c.style), { ...tagDefaults });
|
|
11783
|
+
return { ...fromClasses, ...node.style };
|
|
11784
|
+
}
|
|
11785
|
+
function largeText(node, design) {
|
|
11786
|
+
const style = effectiveStyle(node, design);
|
|
11787
|
+
const level = headingLevel(node);
|
|
11788
|
+
const size = px(style?.fontSize, design) ?? (level === undefined ? 16 : HEADING_PX[level - 1] ?? 24);
|
|
10967
11789
|
const weight = typeof style?.fontWeight === "number" ? style.fontWeight : node.type === "heading" ? 700 : 400;
|
|
10968
11790
|
return size >= 24 || size >= 18.66 && weight >= 700;
|
|
10969
11791
|
}
|
|
11792
|
+
function boxHasName(node) {
|
|
11793
|
+
if (node.bind || node.type.startsWith("post-") || node.type === "loop" || node.type === "section")
|
|
11794
|
+
return true;
|
|
11795
|
+
const props = node.props;
|
|
11796
|
+
const decorative = props["decorative"] === true;
|
|
11797
|
+
const named = node.type === "image" || node.type === "icon" || node.type === "svg" ? !decorative && spoken(node.type === "image" ? props["alt"] : props["title"]) !== "" : ["text", "title", "label", "summary", "caption"].some((key) => spoken(props[key]) !== "");
|
|
11798
|
+
if (named)
|
|
11799
|
+
return true;
|
|
11800
|
+
return isParentNode(node) && node.children.some(boxHasName);
|
|
11801
|
+
}
|
|
10970
11802
|
function auditPage(layout, design) {
|
|
10971
11803
|
const issues = [];
|
|
10972
11804
|
const add = (issue) => issues.push({ ...issue, id: `${issue.rule}:${issue.nodeId}` });
|
|
@@ -10990,7 +11822,7 @@ function auditPage(layout, design) {
|
|
|
10990
11822
|
if (before)
|
|
10991
11823
|
[h1s, lastLevel] = [[...before[0]], before[1]];
|
|
10992
11824
|
const outerFade = fade;
|
|
10993
|
-
const opacity = node
|
|
11825
|
+
const opacity = effectiveStyle(node, design)?.opacity;
|
|
10994
11826
|
if (typeof opacity === "number" && opacity >= 0 && opacity < 1)
|
|
10995
11827
|
fade *= opacity;
|
|
10996
11828
|
const outerShown = shownOn;
|
|
@@ -11006,8 +11838,9 @@ function auditPage(layout, design) {
|
|
|
11006
11838
|
};
|
|
11007
11839
|
const visitNode = (node, bg, color) => {
|
|
11008
11840
|
const props = node.props;
|
|
11009
|
-
const style = node
|
|
11010
|
-
const
|
|
11841
|
+
const style = effectiveStyle(node, design);
|
|
11842
|
+
const covered = style?.backgroundImage || style?.backgroundVideo || style?.gradient;
|
|
11843
|
+
const ownBg = covered ? "unknown" : hexOf(style?.backgroundColor, design);
|
|
11011
11844
|
const nextBg = ownBg && ownBg !== "unknown" && bg && bg !== "unknown" ? over(ownBg, bg) : ownBg ?? bg;
|
|
11012
11845
|
const nextColor = hexOf(style?.color, design) ?? color;
|
|
11013
11846
|
const imageLinked = node.type === "image" && typeof props["href"] === "string" && props["href"].trim() !== "";
|
|
@@ -11019,17 +11852,39 @@ function auditPage(layout, design) {
|
|
|
11019
11852
|
message: "This image is a link but is marked decorative, so the link has no name."
|
|
11020
11853
|
});
|
|
11021
11854
|
} else if (node.type === "image" && props["decorative"] !== true) {
|
|
11022
|
-
const alt = typeof props["alt"] === "string" ? props["alt"]
|
|
11855
|
+
const alt = typeof props["alt"] === "string" ? spoken(props["alt"]) : "";
|
|
11023
11856
|
if (USELESS_ALT.test(alt)) {
|
|
11024
11857
|
add({
|
|
11025
11858
|
nodeId: node.id,
|
|
11026
11859
|
rule: "image-alt",
|
|
11027
11860
|
severity: "error",
|
|
11028
|
-
message: alt ? `The alt text "${alt
|
|
11861
|
+
message: alt ? `The alt text "${clipText(alt, 40)}" doesn't describe the image.` : "This image has no alt text.",
|
|
11029
11862
|
...imageLinked ? {} : { fix: { kind: "decorative" }, fixLabel: "Mark as decorative" }
|
|
11030
11863
|
});
|
|
11031
11864
|
}
|
|
11032
11865
|
}
|
|
11866
|
+
if (node.type === "svg" && props["decorative"] !== true && !spoken(props["title"]) && !/<title\b[^>]*>\s*[^<\s]/i.test(String(props["markup"] ?? ""))) {
|
|
11867
|
+
add({
|
|
11868
|
+
nodeId: node.id,
|
|
11869
|
+
rule: "image-alt",
|
|
11870
|
+
severity: "error",
|
|
11871
|
+
message: "This SVG has no title, so screen readers can't say what it shows.",
|
|
11872
|
+
fix: { kind: "decorative" },
|
|
11873
|
+
fixLabel: "Mark as decorative"
|
|
11874
|
+
});
|
|
11875
|
+
}
|
|
11876
|
+
const looping = [node.style, ...Object.values(node.devices ?? {})].some((st) => {
|
|
11877
|
+
const anim = st?.iconAnimation;
|
|
11878
|
+
return anim?.type === "spin" || anim?.type === "pulse";
|
|
11879
|
+
});
|
|
11880
|
+
if (looping) {
|
|
11881
|
+
add({
|
|
11882
|
+
nodeId: node.id,
|
|
11883
|
+
rule: "motion",
|
|
11884
|
+
severity: "warning",
|
|
11885
|
+
message: "This icon animates without end and visitors can't pause it. Keep it only if the motion is essential, such as a loading spinner."
|
|
11886
|
+
});
|
|
11887
|
+
}
|
|
11033
11888
|
if (node.type === "image" && Array.isArray(props["sources"]) && props["sources"].length > 0) {
|
|
11034
11889
|
const width = props["width"];
|
|
11035
11890
|
const widthSet = typeof width === "number" && Number.isInteger(width) && width >= 1;
|
|
@@ -11051,12 +11906,12 @@ function auditPage(layout, design) {
|
|
|
11051
11906
|
message: "This image link opens a new tab without saying so; say so in the alt text."
|
|
11052
11907
|
});
|
|
11053
11908
|
}
|
|
11054
|
-
if (
|
|
11909
|
+
if (FIELD_TYPES3.has(node.type) && !spoken(props["label"]) && !node.bind) {
|
|
11055
11910
|
add({
|
|
11056
11911
|
nodeId: node.id,
|
|
11057
11912
|
rule: "control-name",
|
|
11058
11913
|
severity: "error",
|
|
11059
|
-
message:
|
|
11914
|
+
message: spoken(props["placeholder"]) ? "This field has only a placeholder, which disappears once you type; give it a label." : "This field has no label, so screen readers can't say what it's for."
|
|
11060
11915
|
});
|
|
11061
11916
|
}
|
|
11062
11917
|
const NAME_PROP = {
|
|
@@ -11065,7 +11920,7 @@ function auditPage(layout, design) {
|
|
|
11065
11920
|
video: "title"
|
|
11066
11921
|
};
|
|
11067
11922
|
if (node.type === "tab-panel" || node.type === "accordion-item" || node.type === "video") {
|
|
11068
|
-
const name =
|
|
11923
|
+
const name = spoken(props[NAME_PROP[node.type]]);
|
|
11069
11924
|
if (!name && !node.bind) {
|
|
11070
11925
|
add({
|
|
11071
11926
|
nodeId: node.id,
|
|
@@ -11076,7 +11931,7 @@ function auditPage(layout, design) {
|
|
|
11076
11931
|
}
|
|
11077
11932
|
}
|
|
11078
11933
|
if (node.type === "menu" && (node.children?.length ?? 0) > 0) {
|
|
11079
|
-
const name =
|
|
11934
|
+
const name = spoken(props["label"]) || "Menu";
|
|
11080
11935
|
const key = name.toLowerCase();
|
|
11081
11936
|
if (menuNames.some((names, i) => shownOn[i] && names.has(key))) {
|
|
11082
11937
|
add({
|
|
@@ -11091,7 +11946,7 @@ function auditPage(layout, design) {
|
|
|
11091
11946
|
names.add(key);
|
|
11092
11947
|
});
|
|
11093
11948
|
}
|
|
11094
|
-
if (node.type === "heading" && !
|
|
11949
|
+
if (node.type === "heading" && !spoken(props["text"]) && !node.bind) {
|
|
11095
11950
|
add({
|
|
11096
11951
|
nodeId: node.id,
|
|
11097
11952
|
rule: "empty-heading",
|
|
@@ -11126,8 +11981,16 @@ function auditPage(layout, design) {
|
|
|
11126
11981
|
}
|
|
11127
11982
|
lastLevel = level;
|
|
11128
11983
|
}
|
|
11984
|
+
if (boxBecomesLink(node) && !boxHasName(node)) {
|
|
11985
|
+
add({
|
|
11986
|
+
nodeId: node.id,
|
|
11987
|
+
rule: "link-name",
|
|
11988
|
+
severity: "error",
|
|
11989
|
+
message: "This box is a link, but nothing inside it has text, so the link has no name."
|
|
11990
|
+
});
|
|
11991
|
+
}
|
|
11129
11992
|
if (LINKISH.has(node.type) || node.type === "icon" && props["href"]) {
|
|
11130
|
-
const text =
|
|
11993
|
+
const text = spoken(props["text"] ?? props["title"]);
|
|
11131
11994
|
const hasHref = typeof props["href"] === "string" && props["href"].trim() !== "";
|
|
11132
11995
|
if (!text && !node.bind) {
|
|
11133
11996
|
add({
|
|
@@ -11155,17 +12018,18 @@ function auditPage(layout, design) {
|
|
|
11155
12018
|
}
|
|
11156
12019
|
if (TEXT_TYPES.has(node.type) && nextColor && nextBg && nextBg !== "unknown") {
|
|
11157
12020
|
const ratio = contrastRatio(over(nextColor, nextBg, fade), nextBg);
|
|
11158
|
-
const needed = largeText(node) ? 3 : 4.5;
|
|
12021
|
+
const needed = largeText(node, design) ? 3 : 4.5;
|
|
11159
12022
|
if (ratio < needed) {
|
|
11160
12023
|
const black = contrastRatio("#000000", nextBg);
|
|
11161
12024
|
const white = contrastRatio("#ffffff", nextBg);
|
|
11162
12025
|
const better = black >= white ? "#111111" : "#ffffff";
|
|
11163
12026
|
const fixable = contrastRatio(over(better, nextBg, fade), nextBg) >= needed;
|
|
12027
|
+
const shown = (Math.floor(ratio * 10) / 10).toFixed(1);
|
|
11164
12028
|
add({
|
|
11165
12029
|
nodeId: node.id,
|
|
11166
12030
|
rule: "contrast",
|
|
11167
12031
|
severity: "error",
|
|
11168
|
-
message: fixable ? `Text contrast is ${
|
|
12032
|
+
message: fixable ? `Text contrast is ${shown}:1; it needs ${needed}:1.` : `Text contrast is ${shown}:1; it needs ${needed}:1. Opacity on this element or a parent fades it; raise the opacity.`,
|
|
11169
12033
|
...fixable ? {
|
|
11170
12034
|
fix: { kind: "text-color", color: better },
|
|
11171
12035
|
fixLabel: better === "#ffffff" ? "Use white text" : "Use dark text"
|
|
@@ -11173,7 +12037,7 @@ function auditPage(layout, design) {
|
|
|
11173
12037
|
});
|
|
11174
12038
|
}
|
|
11175
12039
|
}
|
|
11176
|
-
const focusable = LINKISH.has(node.type) || node.type === "
|
|
12040
|
+
const focusable = LINKISH.has(node.type) || FIELD_TYPES3.has(node.type) || node.type === "submit" || Boolean(props["href"]);
|
|
11177
12041
|
const ownAriaHidden = (node.attributes ?? []).some((a) => a.name === "aria-hidden" && a.value === "true");
|
|
11178
12042
|
if (focusable && ownAriaHidden) {
|
|
11179
12043
|
add({
|
|
@@ -11278,8 +12142,10 @@ function siteTokens(design) {
|
|
|
11278
12142
|
const onAccent = color(pick2(others, /on[- ]?(primary|brand|accent)|inverse|white/));
|
|
11279
12143
|
if (onAccent)
|
|
11280
12144
|
tokens.onAccent = onAccent;
|
|
11281
|
-
else if (accentVar && /^#[0-9a-f]{6}$/i.test(accentVar.value)) {
|
|
11282
|
-
|
|
12145
|
+
else if (accentVar && /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(accentVar.value)) {
|
|
12146
|
+
const h = accentVar.value.slice(1);
|
|
12147
|
+
const hex = `#${(h.length <= 4 ? [...h].map((c) => c + c).join("") : h).slice(0, 6)}`;
|
|
12148
|
+
tokens.onAccent = contrastRatio(hex, "#ffffff") >= contrastRatio(hex, "#111111") ? "#ffffff" : "#111111";
|
|
11283
12149
|
}
|
|
11284
12150
|
const buttonCls = pick2(design.classes, /\b(button|btn)\b/, /cta/);
|
|
11285
12151
|
if (buttonCls) {
|
|
@@ -11575,7 +12441,7 @@ function summaryText(node) {
|
|
|
11575
12441
|
const text = typeof props["text"] === "string" ? props["text"] : undefined;
|
|
11576
12442
|
if (!text)
|
|
11577
12443
|
return;
|
|
11578
|
-
return text.length > 60 ? `${text
|
|
12444
|
+
return text.length > 60 ? `${clipText(text, 57)}…` : text;
|
|
11579
12445
|
}
|
|
11580
12446
|
function stats(layout) {
|
|
11581
12447
|
let nodes = 0;
|
|
@@ -11587,7 +12453,7 @@ function stats(layout) {
|
|
|
11587
12453
|
walk(child, d + 1);
|
|
11588
12454
|
};
|
|
11589
12455
|
walk(layout.root, 1);
|
|
11590
|
-
return { nodes, depth, bytes:
|
|
12456
|
+
return { nodes, depth, bytes: byteLength2(layout) };
|
|
11591
12457
|
}
|
|
11592
12458
|
var ListPagesInput = strictObject({
|
|
11593
12459
|
cursor: string2().max(512).optional(),
|
|
@@ -11755,6 +12621,7 @@ var DescribePageOutput = object({
|
|
|
11755
12621
|
media: number2()
|
|
11756
12622
|
})),
|
|
11757
12623
|
headingOutline: array(string2()),
|
|
12624
|
+
warnings: array(object({ nodeId: string2(), message: string2() })).optional(),
|
|
11758
12625
|
wordCount: number2(),
|
|
11759
12626
|
images: array(object({ id: string2(), alt: string2(), src: string2(), decorative: boolean2() })).optional()
|
|
11760
12627
|
});
|
|
@@ -11776,6 +12643,53 @@ function imagesOf(root) {
|
|
|
11776
12643
|
walk(root);
|
|
11777
12644
|
return found;
|
|
11778
12645
|
}
|
|
12646
|
+
function hiddenEverywhere(root) {
|
|
12647
|
+
const warnings = [];
|
|
12648
|
+
const walk = (node) => {
|
|
12649
|
+
const hidden = new Set(node.hiddenOn ?? []);
|
|
12650
|
+
if (hidden.has("desktop") && hidden.has("tablet") && hidden.has("mobile")) {
|
|
12651
|
+
warnings.push({
|
|
12652
|
+
nodeId: node.id,
|
|
12653
|
+
message: node.id === root.id ? "The whole page is hidden on every device, so visitors see an empty page. Unset hiddenOn on the root." : `${node.label ?? node.type} ${node.id} is hidden on every device, so it and everything inside it never show. Unset hiddenOn, or remove it.`
|
|
12654
|
+
});
|
|
12655
|
+
return;
|
|
12656
|
+
}
|
|
12657
|
+
for (const child of nodeChildren(node))
|
|
12658
|
+
walk(child);
|
|
12659
|
+
};
|
|
12660
|
+
walk(root);
|
|
12661
|
+
return warnings.slice(0, 50);
|
|
12662
|
+
}
|
|
12663
|
+
async function requiredFieldWarnings(ports, root) {
|
|
12664
|
+
const forms = [];
|
|
12665
|
+
forEachNode(root, (node) => {
|
|
12666
|
+
if (isFormNode(node) && node.props.formId.trim() && forms.length < 20)
|
|
12667
|
+
forms.push(node);
|
|
12668
|
+
});
|
|
12669
|
+
if (forms.length === 0 || !ports.formFields)
|
|
12670
|
+
return [];
|
|
12671
|
+
let fields;
|
|
12672
|
+
try {
|
|
12673
|
+
fields = await ports.formFields([
|
|
12674
|
+
...new Set(forms.map((form) => form.props.formId.trim()))
|
|
12675
|
+
]);
|
|
12676
|
+
} catch {
|
|
12677
|
+
return [];
|
|
12678
|
+
}
|
|
12679
|
+
const warnings = [];
|
|
12680
|
+
for (const form of forms) {
|
|
12681
|
+
const defined = fields.get(form.props.formId.trim());
|
|
12682
|
+
if (!defined)
|
|
12683
|
+
continue;
|
|
12684
|
+
for (const issue of requiredFieldIssues(form, defined)) {
|
|
12685
|
+
warnings.push({
|
|
12686
|
+
nodeId: issue.kind === "missing" ? issue.formNodeId : issue.nodeId,
|
|
12687
|
+
message: issue.kind === "hidden" ? `${requiredFieldIssueText(issue)} (Unset hiddenOn on ${issue.nodeId} or the box around it.)` : issue.kind === "audience" ? `${requiredFieldIssueText(issue)} (Unset audience or variant on ${issue.nodeId} or the box around it.)` : `${requiredFieldIssueText(issue)} (Form ${issue.formNodeId}, field name ${issue.field}.)`
|
|
12688
|
+
});
|
|
12689
|
+
}
|
|
12690
|
+
}
|
|
12691
|
+
return warnings;
|
|
12692
|
+
}
|
|
11779
12693
|
var clip = (text, max) => text.length > max ? `${text.slice(0, max - 1)}…` : text;
|
|
11780
12694
|
async function describePage(ports, input) {
|
|
11781
12695
|
const { page, layout } = await loadPage(ports, input.pageId);
|
|
@@ -11797,6 +12711,10 @@ async function describePage(ports, input) {
|
|
|
11797
12711
|
return section;
|
|
11798
12712
|
});
|
|
11799
12713
|
const wordCount = all.text.join(" ").split(/\s+/).filter(Boolean).length;
|
|
12714
|
+
const warnings = [
|
|
12715
|
+
...hiddenEverywhere(layout.root),
|
|
12716
|
+
...await requiredFieldWarnings(ports, layout.root)
|
|
12717
|
+
].slice(0, 50);
|
|
11800
12718
|
const summary = clip(`"${page.title}" (/${page.slug}, ${page.status}${page.hasDraft ? ", unpublished changes" : ""}): ` + `${sections.length} top-level section${sections.length === 1 ? "" : "s"}, ` + `${all.headings.length} heading${all.headings.length === 1 ? "" : "s"}, ${all.media} image or video, ` + `${wordCount} words.`, 1200);
|
|
11801
12719
|
return {
|
|
11802
12720
|
pageId: page.id,
|
|
@@ -11805,7 +12723,8 @@ async function describePage(ports, input) {
|
|
|
11805
12723
|
sections,
|
|
11806
12724
|
headingOutline: all.headings,
|
|
11807
12725
|
wordCount,
|
|
11808
|
-
images: imagesOf(layout.root)
|
|
12726
|
+
images: imagesOf(layout.root),
|
|
12727
|
+
...warnings.length ? { warnings } : {}
|
|
11809
12728
|
};
|
|
11810
12729
|
}
|
|
11811
12730
|
var A11yInput = strictObject({ pageId: string2().min(1).max(128) });
|
|
@@ -11847,13 +12766,18 @@ var ListVersionsInput = strictObject({
|
|
|
11847
12766
|
var ListVersionsOutput = object({
|
|
11848
12767
|
versions: array(object({ revisionId: string2(), at: string2(), authorId: string2().nullable() }))
|
|
11849
12768
|
});
|
|
12769
|
+
var utcIso = (at) => /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d+)?$/.test(at) ? `${at.replace(" ", "T")}Z` : at;
|
|
11850
12770
|
async function listVersions(ports, input) {
|
|
11851
12771
|
const page = await ports.getPage(input.pageId);
|
|
11852
12772
|
if (!page)
|
|
11853
12773
|
throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}.`);
|
|
11854
12774
|
const revisions = await ports.listRevisions(input.pageId, input.limit ?? 20);
|
|
11855
12775
|
return {
|
|
11856
|
-
versions: revisions.map((r) => ({
|
|
12776
|
+
versions: revisions.map((r) => ({
|
|
12777
|
+
revisionId: r.id,
|
|
12778
|
+
at: utcIso(r.createdAt),
|
|
12779
|
+
authorId: r.authorId
|
|
12780
|
+
}))
|
|
11857
12781
|
};
|
|
11858
12782
|
}
|
|
11859
12783
|
|
|
@@ -11882,9 +12806,26 @@ var KINDS = [
|
|
|
11882
12806
|
["fontSizes", "fontSize"],
|
|
11883
12807
|
["spacings", "spacing"]
|
|
11884
12808
|
];
|
|
12809
|
+
function nestsDeeperThan(value, max) {
|
|
12810
|
+
const stack = [[value, 1]];
|
|
12811
|
+
while (stack.length > 0) {
|
|
12812
|
+
const [item, depth] = stack.pop();
|
|
12813
|
+
if (typeof item !== "object" || item === null)
|
|
12814
|
+
continue;
|
|
12815
|
+
if (depth > max)
|
|
12816
|
+
return true;
|
|
12817
|
+
for (const child of Object.values(item))
|
|
12818
|
+
stack.push([child, depth + 1]);
|
|
12819
|
+
}
|
|
12820
|
+
return false;
|
|
12821
|
+
}
|
|
12822
|
+
var MAX_INPUT_NESTING = 256;
|
|
11885
12823
|
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
11886
12824
|
var isRef = (v) => typeof v["var"] === "string" && Object.keys(v).every((k) => k === "var" || k === "from");
|
|
11887
12825
|
function resolveDesignRefs(value, design) {
|
|
12826
|
+
if (nestsDeeperThan(value, MAX_INPUT_NESTING)) {
|
|
12827
|
+
throw new McpToolError("INVALID_INPUT", "This input nests too deeply.");
|
|
12828
|
+
}
|
|
11888
12829
|
const kinds = new Map;
|
|
11889
12830
|
for (const [key, from] of KINDS) {
|
|
11890
12831
|
for (const v of design.variables[key] ?? [])
|
|
@@ -11945,7 +12886,7 @@ var PageId = string2().min(1).max(128);
|
|
|
11945
12886
|
var NodeIdInput = string2().min(1).max(64);
|
|
11946
12887
|
var Rev = string2().min(1).max(256);
|
|
11947
12888
|
function checkLayout(candidate) {
|
|
11948
|
-
const size =
|
|
12889
|
+
const size = byteLength2(candidate);
|
|
11949
12890
|
if (size > MAX_LAYOUT_BYTES) {
|
|
11950
12891
|
throw new McpToolError("TOO_LARGE", `The page would be ${size} bytes; the limit is ${MAX_LAYOUT_BYTES}. Split it into smaller pages or remove content.`);
|
|
11951
12892
|
}
|
|
@@ -11957,7 +12898,7 @@ function checkLayout(candidate) {
|
|
|
11957
12898
|
if (misplaced.length > 0) {
|
|
11958
12899
|
throw new McpToolError("NESTING", `Elements are in the wrong place. ${misplaced.map((issue) => issue.message).join("; ")}`);
|
|
11959
12900
|
}
|
|
11960
|
-
const bytes =
|
|
12901
|
+
const bytes = byteLength2(result.layout);
|
|
11961
12902
|
if (bytes > MAX_LAYOUT_BYTES) {
|
|
11962
12903
|
throw new McpToolError("TOO_LARGE", `The page would be ${bytes} bytes; the limit is ${MAX_LAYOUT_BYTES}.`);
|
|
11963
12904
|
}
|
|
@@ -11983,7 +12924,13 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
|
|
|
11983
12924
|
throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
|
|
11984
12925
|
}
|
|
11985
12926
|
const next = apply(current.layout);
|
|
12927
|
+
refuseUnsafeImageSources(current.layout, next.layout);
|
|
12928
|
+
refuseUnsafeLinks(current.layout, next.layout);
|
|
12929
|
+
refuseUnsafeSvg(current.layout, next.layout);
|
|
11986
12930
|
const layout = checkLayout(next.layout);
|
|
12931
|
+
if (stableJson(layout) === stableJson(current.layout)) {
|
|
12932
|
+
return { pageId, rev: page.rev, changed: [], summary: `Nothing changed (${tool})` };
|
|
12933
|
+
}
|
|
11987
12934
|
try {
|
|
11988
12935
|
const saved = await ports.savePage(pageId, { layout }, page.rev);
|
|
11989
12936
|
await ports.log({
|
|
@@ -12006,12 +12953,104 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
|
|
|
12006
12953
|
var refused = (reason) => {
|
|
12007
12954
|
throw new McpToolError("REFUSED", reason);
|
|
12008
12955
|
};
|
|
12956
|
+
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
12957
|
+
var propsOf = (node) => isRecord3(node.props) ? node.props : {};
|
|
12958
|
+
function linkValues(root) {
|
|
12959
|
+
const found = new Map;
|
|
12960
|
+
const walk = (node) => {
|
|
12961
|
+
const fields = ELEMENT_DESCRIPTORS.find((d) => d.type === node.type)?.fields ?? [];
|
|
12962
|
+
const props = propsOf(node);
|
|
12963
|
+
for (const field of fields) {
|
|
12964
|
+
const value = props[field.key];
|
|
12965
|
+
if (field.kind === "href" && typeof value === "string")
|
|
12966
|
+
found.set(`${node.id}.${field.key}`, value);
|
|
12967
|
+
}
|
|
12968
|
+
for (const child of nodeChildren(node))
|
|
12969
|
+
walk(child);
|
|
12970
|
+
};
|
|
12971
|
+
walk(root);
|
|
12972
|
+
return found;
|
|
12973
|
+
}
|
|
12974
|
+
function refuseUnsafeLinks(before, after) {
|
|
12975
|
+
const old = linkValues(before.root);
|
|
12976
|
+
for (const [key, href] of linkValues(after.root)) {
|
|
12977
|
+
if (href.trim() === "" || old.get(key) === href || sanitizeHref(href) !== undefined)
|
|
12978
|
+
continue;
|
|
12979
|
+
const [id, prop] = key.split(".");
|
|
12980
|
+
refused(`Element ${id} has the ${prop} ${JSON.stringify(clipText(href, 80))}, which pages can't link to. Use an https:// URL, a path on this site such as /pricing, #section, mailto: or tel:.`);
|
|
12981
|
+
}
|
|
12982
|
+
}
|
|
12983
|
+
function svgValues(root) {
|
|
12984
|
+
const found = new Map;
|
|
12985
|
+
const walk = (node) => {
|
|
12986
|
+
const props = propsOf(node);
|
|
12987
|
+
if (node.type === "svg" && typeof props["markup"] === "string")
|
|
12988
|
+
found.set(`${node.id}.markup`, props["markup"]);
|
|
12989
|
+
if (typeof props["iconSvg"] === "string")
|
|
12990
|
+
found.set(`${node.id}.iconSvg`, props["iconSvg"]);
|
|
12991
|
+
for (const child of nodeChildren(node))
|
|
12992
|
+
walk(child);
|
|
12993
|
+
};
|
|
12994
|
+
walk(root);
|
|
12995
|
+
return found;
|
|
12996
|
+
}
|
|
12997
|
+
function refuseUnsafeSvg(before, after) {
|
|
12998
|
+
const old = svgValues(before.root);
|
|
12999
|
+
for (const [key, markup] of svgValues(after.root)) {
|
|
13000
|
+
if (markup.trim() === "" || old.get(key) === markup || isSafeSvgMarkup(markup))
|
|
13001
|
+
continue;
|
|
13002
|
+
const [id, prop] = key.split(".");
|
|
13003
|
+
refused(`Element ${id} has ${prop} the page can't show. Use plain SVG: no scripts, event handlers such as onload, foreignObject, style blocks, links or external images.`);
|
|
13004
|
+
}
|
|
13005
|
+
}
|
|
13006
|
+
function imageSources2(root) {
|
|
13007
|
+
const found = new Map;
|
|
13008
|
+
const walk = (node) => {
|
|
13009
|
+
if (node.type === "image") {
|
|
13010
|
+
const props = propsOf(node);
|
|
13011
|
+
const list = typeof props.src === "string" ? [props.src] : [];
|
|
13012
|
+
if (Array.isArray(props.sources)) {
|
|
13013
|
+
for (const source of props.sources) {
|
|
13014
|
+
if (typeof source?.src === "string")
|
|
13015
|
+
list.push(source.src);
|
|
13016
|
+
}
|
|
13017
|
+
}
|
|
13018
|
+
found.set(node.id, list);
|
|
13019
|
+
}
|
|
13020
|
+
for (const child of nodeChildren(node))
|
|
13021
|
+
walk(child);
|
|
13022
|
+
};
|
|
13023
|
+
walk(root);
|
|
13024
|
+
return found;
|
|
13025
|
+
}
|
|
13026
|
+
function refuseUnsafeImageSources(before, after) {
|
|
13027
|
+
const old = imageSources2(before.root);
|
|
13028
|
+
for (const [id, list] of imageSources2(after.root)) {
|
|
13029
|
+
const kept = new Set(old.get(id) ?? []);
|
|
13030
|
+
for (const src of list) {
|
|
13031
|
+
if (src.trim() === "" || kept.has(src) || sanitizeMediaUrl(src))
|
|
13032
|
+
continue;
|
|
13033
|
+
refused(`Image ${id} has the source ${JSON.stringify(src.slice(0, 80))}, which pages can't show. Use an https:// URL or a path on this site such as /_emdash/api/media/file/photo.jpg (upload in the EmDash media library first).`);
|
|
13034
|
+
}
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
12009
13037
|
var KNOWN_TYPES = new Set(ELEMENT_DESCRIPTORS.map((d) => d.type));
|
|
12010
13038
|
var ElementSpec = lazy(() => looseObject({
|
|
12011
13039
|
type: string2().min(1).max(64),
|
|
12012
13040
|
props: record(string2(), unknown()).optional(),
|
|
12013
13041
|
children: array(ElementSpec).max(200).optional()
|
|
12014
13042
|
}));
|
|
13043
|
+
var BoundedElementSpec = preprocess((value, ctx) => {
|
|
13044
|
+
if (nestsDeeperThan(value, MAX_DEPTH * 8)) {
|
|
13045
|
+
ctx.addIssue({
|
|
13046
|
+
code: "custom",
|
|
13047
|
+
message: `Elements can be nested at most ${MAX_DEPTH} levels deep.`,
|
|
13048
|
+
input: value
|
|
13049
|
+
});
|
|
13050
|
+
return NEVER;
|
|
13051
|
+
}
|
|
13052
|
+
return value;
|
|
13053
|
+
}, ElementSpec);
|
|
12015
13054
|
function buildNode(spec) {
|
|
12016
13055
|
if (!KNOWN_TYPES.has(spec.type)) {
|
|
12017
13056
|
refused(`Unknown element type ${spec.type}. Call list_element_types.`);
|
|
@@ -12041,8 +13080,20 @@ function promoteHeroHeading(layout, title) {
|
|
|
12041
13080
|
props: { ...node.props, text: title, level: 1 }
|
|
12042
13081
|
}));
|
|
12043
13082
|
}
|
|
13083
|
+
async function slugTaken(ports, slug) {
|
|
13084
|
+
let cursor;
|
|
13085
|
+
for (let i = 0;i < 20; i++) {
|
|
13086
|
+
const batch = await ports.listPages({ limit: 50, ...cursor ? { cursor } : {} });
|
|
13087
|
+
if (batch.pages.some((page) => page.slug === slug))
|
|
13088
|
+
return true;
|
|
13089
|
+
if (!batch.nextCursor)
|
|
13090
|
+
return false;
|
|
13091
|
+
cursor = batch.nextCursor;
|
|
13092
|
+
}
|
|
13093
|
+
return false;
|
|
13094
|
+
}
|
|
12044
13095
|
async function createPage(ports, input) {
|
|
12045
|
-
const slug =
|
|
13096
|
+
const slug = pageSlug(input.title);
|
|
12046
13097
|
if (!slug)
|
|
12047
13098
|
refused("Give the page a title with letters or digits.");
|
|
12048
13099
|
const { design } = await ports.getDesign();
|
|
@@ -12067,8 +13118,7 @@ async function createPage(ports, input) {
|
|
|
12067
13118
|
if (recipes[0] === "hero")
|
|
12068
13119
|
layout = promoteHeroHeading(layout, input.title);
|
|
12069
13120
|
const checked = checkLayout(layout);
|
|
12070
|
-
|
|
12071
|
-
if (taken.pages.some((page) => page.slug === slug)) {
|
|
13121
|
+
if (await slugTaken(ports, slug)) {
|
|
12072
13122
|
throw new McpToolError("REFUSED", `The slug "${slug}" is taken. Choose another title.`);
|
|
12073
13123
|
}
|
|
12074
13124
|
const created = await ports.createPage({ title: input.title, layout: checked });
|
|
@@ -12085,7 +13135,7 @@ var AddElementInput = strictObject({
|
|
|
12085
13135
|
pageId: PageId,
|
|
12086
13136
|
parentId: NodeIdInput,
|
|
12087
13137
|
index: number2().int().min(0).optional(),
|
|
12088
|
-
element:
|
|
13138
|
+
element: BoundedElementSpec,
|
|
12089
13139
|
expectedRev: Rev.optional()
|
|
12090
13140
|
});
|
|
12091
13141
|
async function addElement(ports, input) {
|
|
@@ -12143,7 +13193,23 @@ var UpdateElementInput = strictObject({
|
|
|
12143
13193
|
unset: array(string2().regex(/^[a-zA-Z]+(\.[a-zA-Z0-9_-]+)?$/)).max(50).optional(),
|
|
12144
13194
|
expectedRev: Rev.optional()
|
|
12145
13195
|
});
|
|
12146
|
-
|
|
13196
|
+
function dropOldPictureProps(before, setProps, copy) {
|
|
13197
|
+
if (typeof setProps.src !== "string" || setProps.src === before.src)
|
|
13198
|
+
return;
|
|
13199
|
+
const props = copy.props;
|
|
13200
|
+
if (!isRecord3(props))
|
|
13201
|
+
return;
|
|
13202
|
+
for (const key of ["sources", "edit", "mediaId"]) {
|
|
13203
|
+
if (!(key in setProps))
|
|
13204
|
+
delete props[key];
|
|
13205
|
+
}
|
|
13206
|
+
if (before.mediaId !== undefined && !("mediaId" in setProps)) {
|
|
13207
|
+
if (!("width" in setProps))
|
|
13208
|
+
delete props.width;
|
|
13209
|
+
if (!("height" in setProps))
|
|
13210
|
+
delete props.height;
|
|
13211
|
+
}
|
|
13212
|
+
}
|
|
12147
13213
|
async function updateElement(ports, input) {
|
|
12148
13214
|
const set = resolveDesignRefs(input.set ?? {}, (await ports.getDesign()).design);
|
|
12149
13215
|
return mutatePage(ports, "update_element", input.pageId, input.expectedRev, (layout) => {
|
|
@@ -12156,6 +13222,9 @@ async function updateElement(ports, input) {
|
|
|
12156
13222
|
continue;
|
|
12157
13223
|
copy[key] = isRecord3(value) && isRecord3(copy[key]) ? { ...copy[key], ...value } : value;
|
|
12158
13224
|
}
|
|
13225
|
+
if (node.type === "image" && isRecord3(set.props)) {
|
|
13226
|
+
dropOldPictureProps(node.props, set.props, copy);
|
|
13227
|
+
}
|
|
12159
13228
|
for (const path of input.unset ?? []) {
|
|
12160
13229
|
const [top, sub] = path.split(".");
|
|
12161
13230
|
if (top === "id" || top === "type" || top === "children")
|
|
@@ -12255,8 +13324,7 @@ var KIND_OF = {
|
|
|
12255
13324
|
fontSizes: "fontSize",
|
|
12256
13325
|
spacings: "spacing"
|
|
12257
13326
|
};
|
|
12258
|
-
async function
|
|
12259
|
-
const where = findVariableUsagesInDesign(design, id, kind).map((u) => `class ${u.classId}`);
|
|
13327
|
+
async function allLayouts(ports) {
|
|
12260
13328
|
const pages = [];
|
|
12261
13329
|
let cursor;
|
|
12262
13330
|
for (let i = 0;i < 20; i++) {
|
|
@@ -12267,14 +13335,26 @@ async function variableUses(ports, design, id, kind) {
|
|
|
12267
13335
|
cursor = batch.nextCursor;
|
|
12268
13336
|
}
|
|
12269
13337
|
const records = await Promise.all(pages.map((page) => ports.getPage(page.id)));
|
|
13338
|
+
const out = [];
|
|
12270
13339
|
records.forEach((record2, i) => {
|
|
12271
13340
|
const layout = record2 ? validateLayout(record2.layout) : null;
|
|
12272
|
-
if (layout?.ok
|
|
12273
|
-
|
|
12274
|
-
}
|
|
13341
|
+
if (layout?.ok)
|
|
13342
|
+
out.push({ title: pages[i]?.title ?? "", layout: layout.layout });
|
|
12275
13343
|
});
|
|
13344
|
+
return out;
|
|
13345
|
+
}
|
|
13346
|
+
function variableUses(layouts, design, id, kind) {
|
|
13347
|
+
const where = findVariableUsagesInDesign(design, id, kind).map((u) => `class ${u.classId}`);
|
|
13348
|
+
for (const { title, layout } of layouts) {
|
|
13349
|
+
if (findVariableUsages(layout, id, kind).length > 0)
|
|
13350
|
+
where.push(`page "${title}"`);
|
|
13351
|
+
}
|
|
12276
13352
|
return where;
|
|
12277
13353
|
}
|
|
13354
|
+
function classUses(layouts, id) {
|
|
13355
|
+
const uses = (node) => (node.classes ?? []).includes(id) || nodeChildren(node).some(uses);
|
|
13356
|
+
return layouts.filter(({ layout }) => uses(layout.root)).map(({ title }) => `page "${title}"`);
|
|
13357
|
+
}
|
|
12278
13358
|
var upsert = (list, items) => {
|
|
12279
13359
|
const next = [...list ?? []];
|
|
12280
13360
|
for (const item of items) {
|
|
@@ -12294,6 +13374,11 @@ async function updateSiteStyles(ports, input) {
|
|
|
12294
13374
|
}
|
|
12295
13375
|
const draft = structuredClone(state.design);
|
|
12296
13376
|
const changes = [];
|
|
13377
|
+
for (const font of input.variables?.fonts ?? []) {
|
|
13378
|
+
if (typeof font.value === "string" && !isSafeFontStack(font.value)) {
|
|
13379
|
+
throw new McpToolError("INVALID_INPUT", `Font ${String(font.id)}: "${font.value.slice(0, 60)}" can't be used in the site CSS. Use names of letters, digits, spaces, - and _, quoted or not, separated by commas.`);
|
|
13380
|
+
}
|
|
13381
|
+
}
|
|
12297
13382
|
for (const kind of VARIABLE_KINDS) {
|
|
12298
13383
|
const items = input.variables?.[kind];
|
|
12299
13384
|
if (items?.length) {
|
|
@@ -12301,11 +13386,22 @@ async function updateSiteStyles(ports, input) {
|
|
|
12301
13386
|
changes.push(`${items.length} ${kind}`);
|
|
12302
13387
|
}
|
|
12303
13388
|
}
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
13389
|
+
const unknown2 = [
|
|
13390
|
+
...(input.removeVariables ?? []).filter(({ kind, id }) => !(draft.variables[kind] ?? []).some((v) => v.id === id)).map(({ kind, id }) => `${kind} ${id}`),
|
|
13391
|
+
...(input.removeClasses ?? []).filter((id) => !(draft.classes ?? []).some((c) => c.id === id)).map((id) => `class ${id}`)
|
|
13392
|
+
];
|
|
13393
|
+
if (unknown2.length > 0) {
|
|
13394
|
+
throw new McpToolError("NOT_FOUND", `Nothing to remove for ${unknown2.join(", ")}. Call get_site_styles for the ids.`);
|
|
13395
|
+
}
|
|
13396
|
+
if (!input.force && (input.removeVariables?.length || input.removeClasses?.length)) {
|
|
13397
|
+
const layouts = await allLayouts(ports);
|
|
13398
|
+
const inUse = [
|
|
13399
|
+
...(input.removeVariables ?? []).map(({ kind, id }) => ({
|
|
13400
|
+
id,
|
|
13401
|
+
where: variableUses(layouts, state.design, id, KIND_OF[kind])
|
|
13402
|
+
})),
|
|
13403
|
+
...(input.removeClasses ?? []).map((id) => ({ id, where: classUses(layouts, id) }))
|
|
13404
|
+
];
|
|
12309
13405
|
const blocked = inUse.filter((u) => u.where.length > 0);
|
|
12310
13406
|
if (blocked.length > 0) {
|
|
12311
13407
|
throw new McpToolError("REFUSED", `Still in use: ${blocked.map((u) => `${u.id} (${u.where.slice(0, 5).join(", ")})`).join("; ")}. Replace those references first, or pass force: true.`);
|
|
@@ -12336,12 +13432,36 @@ async function updateSiteStyles(ports, input) {
|
|
|
12336
13432
|
draft["direction"] = input.direction;
|
|
12337
13433
|
changes.push(`direction ${input.direction}`);
|
|
12338
13434
|
}
|
|
13435
|
+
const clash = (list, touched, what) => {
|
|
13436
|
+
const ids = new Set((touched ?? []).map((item) => item.id));
|
|
13437
|
+
const seen = new Map;
|
|
13438
|
+
for (const item of list ?? []) {
|
|
13439
|
+
const name = item.name;
|
|
13440
|
+
if (typeof name !== "string")
|
|
13441
|
+
continue;
|
|
13442
|
+
const key = nameKey(name);
|
|
13443
|
+
const other = seen.get(key);
|
|
13444
|
+
if (other && (ids.has(item.id) || ids.has(other.id))) {
|
|
13445
|
+
const taken = String(other.name);
|
|
13446
|
+
throw new McpToolError("INVALID_INPUT", `${what} ${item.id} and ${other.id} would both be named "${taken}". Pick another name.`);
|
|
13447
|
+
}
|
|
13448
|
+
if (!other)
|
|
13449
|
+
seen.set(key, item);
|
|
13450
|
+
}
|
|
13451
|
+
};
|
|
13452
|
+
clash(draft.classes, input.classes, "Classes");
|
|
13453
|
+
for (const kind of VARIABLE_KINDS) {
|
|
13454
|
+
clash(draft.variables[kind], input.variables?.[kind], `Variables (${kind})`);
|
|
13455
|
+
}
|
|
12339
13456
|
if (changes.length === 0)
|
|
12340
13457
|
refused("Nothing to change.");
|
|
12341
13458
|
const result = validateDesign(draft);
|
|
12342
13459
|
if (!result.ok) {
|
|
12343
13460
|
throw new McpToolError("INVALID_INPUT", `The site styles would be invalid. ${summarizeIssues(result.issues)}`);
|
|
12344
13461
|
}
|
|
13462
|
+
if (stableJson(result.design) === stableJson(state.design) && state.revision) {
|
|
13463
|
+
return { revision: state.revision, summary: "Nothing changed in the site styles draft" };
|
|
13464
|
+
}
|
|
12345
13465
|
const saved = await ports.saveDesign(result.design, state.revision);
|
|
12346
13466
|
const summary = `Site styles draft: ${changes.join(", ")}`;
|
|
12347
13467
|
await ports.log({ target: "styles", tool: "update_site_styles", summary });
|
|
@@ -12409,7 +13529,7 @@ var READ_TOOLS = [
|
|
|
12409
13529
|
tool({
|
|
12410
13530
|
name: "get_layout",
|
|
12411
13531
|
title: "Get a page layout",
|
|
12412
|
-
description: "Returns a page's layout (schema
|
|
13532
|
+
description: "Returns a page's layout (schema 16) and its revision `rev`. Use format \"outline\" first for a cheap tree of ids, types and labels; pass nodeId for one element's subtree.",
|
|
12413
13533
|
input: GetLayoutInput,
|
|
12414
13534
|
output: GetLayoutOutput,
|
|
12415
13535
|
readOnly: true,
|
|
@@ -12635,7 +13755,7 @@ var PROMPTS = [
|
|
|
12635
13755
|
}
|
|
12636
13756
|
];
|
|
12637
13757
|
// src/bridge.ts
|
|
12638
|
-
var BRIDGE_VERSION = "0.
|
|
13758
|
+
var BRIDGE_VERSION = "0.7.0";
|
|
12639
13759
|
var failure = (message) => ({
|
|
12640
13760
|
content: [{ type: "text", text: message }],
|
|
12641
13761
|
isError: true
|
|
@@ -12741,6 +13861,13 @@ function registerPrompts(server) {
|
|
|
12741
13861
|
|
|
12742
13862
|
// src/remote.ts
|
|
12743
13863
|
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
13864
|
+
function redactToken(error, token) {
|
|
13865
|
+
if (!token || !(error instanceof Error) || !error.message.includes(token))
|
|
13866
|
+
return error;
|
|
13867
|
+
const clean = new Error(error.message.split(token).join("[token]"));
|
|
13868
|
+
clean.name = error.name;
|
|
13869
|
+
return clean;
|
|
13870
|
+
}
|
|
12744
13871
|
function httpRemote(endpoint, token, version) {
|
|
12745
13872
|
let connected = null;
|
|
12746
13873
|
const connect = () => {
|
|
@@ -12759,8 +13886,12 @@ function httpRemote(endpoint, token, version) {
|
|
|
12759
13886
|
};
|
|
12760
13887
|
return {
|
|
12761
13888
|
async call(name, args) {
|
|
12762
|
-
|
|
12763
|
-
|
|
13889
|
+
try {
|
|
13890
|
+
const client = await connect();
|
|
13891
|
+
return await client.callTool({ name, arguments: args });
|
|
13892
|
+
} catch (error) {
|
|
13893
|
+
throw redactToken(error, token);
|
|
13894
|
+
}
|
|
12764
13895
|
},
|
|
12765
13896
|
async close() {
|
|
12766
13897
|
if (connected)
|