@perkyzz/emvb-mcp 0.5.0 → 0.6.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 CHANGED
@@ -34,7 +34,7 @@ element and site style resources, each page's draft and accessibility findings,
34
34
  `emvb-page-builder` skill with its references (also in `skill/`).
35
35
 
36
36
  Needs Node 20+ on the agent's computer, and on the site EmDash 1.2+ with `mcp: true`,
37
- `@perkyzz/emvb` 0.5.0+ with **Set up EmVB** done, and agents turned on in **Pages VisualBuilder →
37
+ `@perkyzz/emvb` 0.5.0+ (0.6.0 recommended) with **Set up EmVB** done, and agents turned on in **Pages VisualBuilder →
38
38
  AI agents**. Full guide:
39
39
  <https://github.com/PerkyZZ999/EmVB/blob/main/docs/guides/mcp.md>.
40
40
 
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
- else if (arg === "--allow-publish")
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;
@@ -5781,6 +5926,39 @@ function intersection(left, right) {
5781
5926
  right
5782
5927
  });
5783
5928
  }
5929
+ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
5930
+ _ensureDefaultMemoizer();
5931
+ $ZodTuple.init(inst, def);
5932
+ ZodType.init(inst, def);
5933
+ inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
5934
+ }, {
5935
+ rest(rest) {
5936
+ return this.clone({
5937
+ ...this._zod.def,
5938
+ rest
5939
+ });
5940
+ },
5941
+ partial() {
5942
+ const def = this._zod.def;
5943
+ if (def.checks?.length)
5944
+ throw new Error(".partial() cannot be used on tuple schemas containing refinements");
5945
+ return this.clone({
5946
+ ...def,
5947
+ items: def.items.map((item) => new ZodOptional({ type: "optional", innerType: item }))
5948
+ });
5949
+ }
5950
+ });
5951
+ function tuple(items, _paramsOrRest, _params) {
5952
+ const hasRest = _paramsOrRest instanceof $ZodType;
5953
+ const params = hasRest ? _params : _paramsOrRest;
5954
+ const rest = hasRest ? _paramsOrRest : null;
5955
+ return new ZodTuple({
5956
+ type: "tuple",
5957
+ items,
5958
+ rest,
5959
+ ...normalizeParams(params)
5960
+ });
5961
+ }
5784
5962
  var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
5785
5963
  _ensureDefaultMemoizer();
5786
5964
  $ZodRecord.init(inst, def);
@@ -6055,8 +6233,21 @@ function refine(fn, _params = {}) {
6055
6233
  function superRefine(fn, params) {
6056
6234
  return _superRefine(fn, params);
6057
6235
  }
6236
+ // ../../node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/iso.js
6237
+ function datetime2(params) {
6238
+ return _isoDateTime(ZodISODateTime, params);
6239
+ }
6240
+ function date2(params) {
6241
+ return _isoDate(ZodISODate, params);
6242
+ }
6243
+ function time2(params) {
6244
+ return _isoTime(ZodISOTime, params);
6245
+ }
6246
+ function duration2(params) {
6247
+ return _isoDuration(ZodISODuration, params);
6248
+ }
6058
6249
  // ../../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";
6250
+ 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` | 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\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
6251
 
6061
6252
  // skill/emvb-page-builder/SKILL.md
6062
6253
  var SKILL_default = `---
@@ -6093,7 +6284,8 @@ instructions.
6093
6284
  6. **Check accessibility** with \`get_accessibility_findings\` after building and fix every
6094
6285
  error. Contrast findings that share one colour: change that colour variable once.
6095
6286
  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.
6287
+ \`describe_page\` and a short summary so they can review the draft. Fix its warnings too (an
6288
+ element hidden on every device, a form's required field with no field on the form).
6097
6289
 
6098
6290
  ## What the tools can't do
6099
6291
 
@@ -6113,7 +6305,10 @@ instructions.
6113
6305
  value; \`list_element_types\` with the type shows its props, allowed parents and notes.
6114
6306
  - \`NESTING\` / \`REFUSED\`: the element can't go there, or the id doesn't exist; re-read the outline.
6115
6307
  - \`TOO_LARGE\`: the page is over 512 KB; split it.
6116
- - \`REFUSED\` on removing a variable: it's still used; replace those references first.
6308
+ - \`REFUSED\` on removing a variable or class: a page still uses it (the message names the pages);
6309
+ replace those references first. Pass \`force: true\` only if the person asked.
6310
+ - An image \`src\` must be an http(s) URL or a path on the site; \`javascript:\`, \`data:\` and
6311
+ \`//host\` sources are refused.
6117
6312
  - \`PUBLISH_DISABLED\`: leave the draft for review.
6118
6313
  - \`FORBIDDEN\`: agent access is off on the site, or the token can't use EmVB; tell the person.
6119
6314
  - \`NOT_SET_UP\`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.
@@ -6207,6 +6402,99 @@ var MAX_DEPTH = 24;
6207
6402
  var MAX_NODES = 2000;
6208
6403
  var MAX_TEXT_LENGTH = 2000;
6209
6404
  var MAX_TABS = 12;
6405
+ function clipText(text, max) {
6406
+ if (text.length <= max)
6407
+ return text;
6408
+ const code = text.charCodeAt(max - 1);
6409
+ return text.slice(0, code >= 55296 && code <= 56319 ? max - 1 : max);
6410
+ }
6411
+ // ../emvb/src/core/image-edit/schema.ts
6412
+ var IMAGE_EDIT_RECIPE_MAX_BYTES = 16 * 1024;
6413
+ var IMAGE_EDIT_CURVE_POINTS_MAX = 32;
6414
+ var Slider = number2().finite().min(-1).max(1);
6415
+ var Unit = number2().finite().min(0).max(1);
6416
+ var Lights = strictObject({
6417
+ brightness: Slider,
6418
+ exposure: Slider,
6419
+ gamma: Slider,
6420
+ contrast: Slider,
6421
+ shadows: Slider,
6422
+ highlights: Slider,
6423
+ bloom: Slider
6424
+ }).partial();
6425
+ var Colors = strictObject({
6426
+ temperature: Slider,
6427
+ tint: Slider,
6428
+ vibrance: Slider,
6429
+ saturation: Slider,
6430
+ sepia: Slider
6431
+ }).partial();
6432
+ var Effects = strictObject({ clarity: Slider, noise: Slider, vignette: Slider }).partial();
6433
+ var Blur = strictObject({
6434
+ bokehstrength: Unit,
6435
+ bokehlensout: Unit,
6436
+ gaussianstrength: Unit,
6437
+ gaussianlensout: Unit,
6438
+ centerX: Unit,
6439
+ centerY: Unit
6440
+ }).partial();
6441
+ var CurvePoint = tuple([Unit, Unit]);
6442
+ var CurveChannel = array(CurvePoint).min(2).max(IMAGE_EDIT_CURVE_POINTS_MAX).nullable();
6443
+ var Curves = tuple([CurveChannel, CurveChannel, CurveChannel, CurveChannel]);
6444
+ var Corner = tuple([number2().finite().min(-2).max(3), number2().finite().min(-2).max(3)]);
6445
+ var Rect = strictObject({
6446
+ x: Unit,
6447
+ y: Unit,
6448
+ width: number2().finite().gt(0).max(1),
6449
+ height: number2().finite().gt(0).max(1)
6450
+ }).refine((r) => r.x + r.width <= 1.000001 && r.y + r.height <= 1.000001, "The crop must stay inside the image");
6451
+ var Geometry = strictObject({
6452
+ quarterTurns: union([literal(0), literal(1), literal(2), literal(3)]),
6453
+ flipX: boolean2(),
6454
+ straighten: number2().finite().min(-45).max(45),
6455
+ perspectiveX: Slider,
6456
+ perspectiveY: Slider,
6457
+ corners: tuple([Corner, Corner, Corner, Corner]).nullable(),
6458
+ crop: Rect.nullable(),
6459
+ aspectRatio: number2().finite().min(0.01).max(100).nullable()
6460
+ }).partial();
6461
+ var FilterLabel = string2().regex(/^[A-Za-z0-9 _-]{1,32}$/, "Filter names are short words");
6462
+ var BlendSrc = string2().max(2000).refine((s) => /^\/(?!\/)/.test(s) || /^https:\/\//i.test(s), "Blend images must be a site path or an https URL");
6463
+ var ImageEditRecipe = strictObject({
6464
+ version: literal(1),
6465
+ name: string2().max(80).optional(),
6466
+ lights: Lights.optional(),
6467
+ colors: Colors.optional(),
6468
+ effects: Effects.optional(),
6469
+ blur: Blur.optional(),
6470
+ curves: Curves.optional(),
6471
+ blend: strictObject({ src: BlendSrc, mix: Unit }).optional(),
6472
+ filters: strictObject({ label: FilterLabel, strength: Unit.optional() }).optional(),
6473
+ geometry: Geometry.optional()
6474
+ });
6475
+ var IMAGE_EDIT_FORMATS = ["webp", "jpeg", "png"];
6476
+ var ImageEditOutput = strictObject({
6477
+ format: _enum(IMAGE_EDIT_FORMATS),
6478
+ quality: number2().finite().min(0.1).max(1).optional(),
6479
+ maxSide: number2().int().min(16).max(1e4).optional(),
6480
+ stripGps: boolean2()
6481
+ });
6482
+ function byteLength(value) {
6483
+ return new TextEncoder().encode(JSON.stringify(value)).length;
6484
+ }
6485
+ var ImageEdit = strictObject({
6486
+ v: literal(1),
6487
+ engine: literal("photocn"),
6488
+ engineVersion: string2().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]{1,32})?$/, "A version like 0.1.2"),
6489
+ recipe: ImageEditRecipe.refine((r) => byteLength(r) <= IMAGE_EDIT_RECIPE_MAX_BYTES, {
6490
+ message: `The edit recipe is larger than ${IMAGE_EDIT_RECIPE_MAX_BYTES / 1024} KB`
6491
+ }),
6492
+ originalMediaId: string2().min(1).max(128).optional(),
6493
+ originalSrc: string2().min(1).max(2000),
6494
+ output: ImageEditOutput,
6495
+ editedAt: exports_iso.datetime({ offset: true })
6496
+ });
6497
+
6210
6498
  // ../emvb/src/core/css-keywords.ts
6211
6499
  var HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
6212
6500
  var LENGTH_UNITS = ["px", "rem", "em", "%", "vw", "vh", "ch"];
@@ -7014,7 +7302,7 @@ var DeviceStyles = strictObject({
7014
7302
  var HiddenOn = array(_enum(POPUP_DEVICES)).max(3);
7015
7303
 
7016
7304
  // ../emvb/src/core/schema/layout.ts
7017
- var LAYOUT_SCHEMA_VERSION = 15;
7305
+ var LAYOUT_SCHEMA_VERSION = 16;
7018
7306
  var NodeId = string2().regex(/^[A-Za-z0-9_-]{4,24}$/, "Ids are 4-24 letters, digits, _ or -");
7019
7307
  var ClassIds = array(string2().regex(/^[a-z0-9-]{1,40}$/)).max(20);
7020
7308
  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");
@@ -7171,7 +7459,8 @@ var ImageNode = leafNode("image", strictObject({
7171
7459
  sources: array(strictObject({
7172
7460
  src: string2().max(2000),
7173
7461
  width: number2().int().min(1).max(8000)
7174
- })).max(6).optional()
7462
+ })).max(6).optional(),
7463
+ edit: ImageEdit.optional()
7175
7464
  })).refine((node) => node.props.decorative === true || node.props.alt.length > 0, {
7176
7465
  message: "Alt text is required unless the image is marked decorative.",
7177
7466
  path: ["props", "alt"]
@@ -7292,7 +7581,8 @@ var PaginationNode = leafNode("pagination", strictObject({
7292
7581
  prevText: string2().max(40).optional(),
7293
7582
  nextText: string2().max(40).optional(),
7294
7583
  showCount: boolean2().optional(),
7295
- countText: string2().max(60).optional()
7584
+ countText: string2().max(60).optional(),
7585
+ titleText: string2().max(60).optional()
7296
7586
  }));
7297
7587
  var SectionNode = parentNode("section", strictObject({
7298
7588
  partId: string2().max(128).optional()
@@ -8313,7 +8603,7 @@ var TEXT_FIELDS = [
8313
8603
  ...NAME_AND_LABEL,
8314
8604
  { key: "placeholder", kind: "text", label: "Placeholder", optional: true }
8315
8605
  ];
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}";
8606
+ 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;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
8607
  var form = {
8318
8608
  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;left:-9999px}" + ":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
8609
  defaults: () => ({ type: "form", props: { formId: "" }, children: [] }),
@@ -8410,11 +8700,18 @@ var radio = {
8410
8700
  build: (node, attrs) => {
8411
8701
  const name = node.props.field;
8412
8702
  const id = controlId(node.id);
8413
- const labelled = node.props.label ? { "aria-labelledby": `${id}-label` } : {};
8703
+ const legend = node.props.label ? [
8704
+ {
8705
+ tag: "legend",
8706
+ attrs: { class: "emvb-form-label", id: `${id}-label` },
8707
+ children: [node.props.label]
8708
+ }
8709
+ ] : [];
8414
8710
  const control = {
8415
8711
  tag: "fieldset",
8416
- attrs: { class: "emvb-radio-group", ...labelled },
8712
+ attrs: { class: "emvb-radio-group" },
8417
8713
  children: [
8714
+ ...legend,
8418
8715
  {
8419
8716
  tag: "label",
8420
8717
  attrs: { class: "emvb-form-radio-label" },
@@ -8425,14 +8722,7 @@ var radio = {
8425
8722
  }
8426
8723
  ]
8427
8724
  };
8428
- const label = node.props.label ? [
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)]);
8725
+ return fieldBox(attrs, [control, errorSlot(name)]);
8436
8726
  }
8437
8727
  };
8438
8728
  var submit = {
@@ -8590,7 +8880,7 @@ var DISPLAY_OPTIONS = [
8590
8880
  { value: "cards", label: "Cards" }
8591
8881
  ];
8592
8882
  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: 767px){.emvb-loop-grid,.emvb-loop-cards{grid-template-columns:minmax(0,1fr)}}",
8883
+ 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
8884
  defaults: () => ({ type: "loop", props: {}, children: [] }),
8595
8885
  descriptor: {
8596
8886
  type: "loop",
@@ -8724,6 +9014,13 @@ var pagination = {
8724
9014
  label: "Count text",
8725
9015
  optional: true,
8726
9016
  message: `{page} and {total} are filled in. EmDash 1.2 doesn't report a total, so the count shows "Page N" until it does.`
9017
+ },
9018
+ {
9019
+ key: "titleText",
9020
+ kind: "text",
9021
+ label: "Page title text",
9022
+ optional: true,
9023
+ message: 'The browser title of page 2 onward. {title} and {page} are filled in; unset is "{title} – page {page}".'
8727
9024
  }
8728
9025
  ]
8729
9026
  },
@@ -9763,7 +10060,8 @@ var LAYOUT_MIGRATIONS = {
9763
10060
  11: gradients,
9764
10061
  12: unchanged,
9765
10062
  13: unchanged,
9766
- 14: unchanged
10063
+ 14: unchanged,
10064
+ 15: unchanged
9767
10065
  };
9768
10066
  var DESIGN_MIGRATIONS = {
9769
10067
  1: unchanged,
@@ -9870,7 +10168,7 @@ var DesignSystem = strictObject({
9870
10168
  function summarizeIssues(issues, max = 3) {
9871
10169
  return issues.slice(0, max).map((issue) => issue.path ? `${issue.path}: ${issue.message}` : issue.message).join("; ");
9872
10170
  }
9873
- function byteLength(value) {
10171
+ function byteLength2(value) {
9874
10172
  return new TextEncoder().encode(JSON.stringify(value)).length;
9875
10173
  }
9876
10174
  function formatPath(path) {
@@ -9941,7 +10239,7 @@ function duplicateIds(layout) {
9941
10239
  function checkSize(input, limit, what) {
9942
10240
  let bytes;
9943
10241
  try {
9944
- bytes = byteLength(input);
10242
+ bytes = byteLength2(input);
9945
10243
  } catch (error) {
9946
10244
  if (!(error instanceof RangeError))
9947
10245
  throw error;
@@ -10240,6 +10538,8 @@ function moveNode(layout, id, parentId, index) {
10240
10538
  const from = locate(layout, id);
10241
10539
  const sameParent = from.parent.id === parentId;
10242
10540
  const at = sameParent && from.index < index ? index - 1 : index;
10541
+ if (sameParent && at === from.index)
10542
+ return { ok: true, layout, selected: id };
10243
10543
  const { layout: without, removed } = removeNode(layout, id);
10244
10544
  if (!removed)
10245
10545
  return refuse(REASONS.missing);
@@ -10358,6 +10658,126 @@ function findVariableUsagesInDesign(design, id, kind) {
10358
10658
  }
10359
10659
  return usages;
10360
10660
  }
10661
+ // ../emvb/src/core/audience/rules.ts
10662
+ var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
10663
+ var DEVICE_LABELS = { mobile: "mobile", tablet: "tablet", desktop: "desktop" };
10664
+ function audienceSummary(audience) {
10665
+ const parts = [];
10666
+ if (audience.countries)
10667
+ parts.push(audience.countries.slice(0, 3).join(", ") + (audience.countries.length > 3 ? "…" : ""));
10668
+ if (audience.devices)
10669
+ parts.push(audience.devices.map((d) => DEVICE_LABELS[d]).join("/"));
10670
+ if (audience.visitor)
10671
+ parts.push(audience.visitor === "new" ? "new visitors" : "returning");
10672
+ if (audience.segments)
10673
+ parts.push(audience.segments.slice(0, 3).join("/") + (audience.segments.length > 3 ? "…" : ""));
10674
+ if (audience.hours)
10675
+ parts.push(`${audience.hours.from}:00–${audience.hours.to}:00`);
10676
+ if (audience.days)
10677
+ parts.push(audience.days.map((d) => WEEKDAYS[d]).join(" "));
10678
+ const who = parts.join(" · ") || "everyone";
10679
+ return audience.hide ? `Hidden for ${who}` : `Only ${who}`;
10680
+ }
10681
+
10682
+ // ../emvb/src/core/forms/binding.ts
10683
+ var FIELD_TYPES = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
10684
+ var DEVICE_ORDER = ["desktop", "tablet", "mobile"];
10685
+ function restriction(node) {
10686
+ const audience = node.audience;
10687
+ if (audience) {
10688
+ const { hide, timeZone: _zone, ...rules } = audience;
10689
+ if (hide || Object.values(rules).some((rule) => rule !== undefined)) {
10690
+ return audienceSummary(audience);
10691
+ }
10692
+ }
10693
+ if (node.variant) {
10694
+ return `Variant ${node.variant.arm.toUpperCase()} of A/B test ${node.variant.test}`;
10695
+ }
10696
+ return;
10697
+ }
10698
+ function boundControls(form) {
10699
+ const found = new Map;
10700
+ const walk = (node, inherited, limited) => {
10701
+ const own = node.hiddenOn ?? [];
10702
+ const hidden = own.length ? new Set([...inherited, ...own]) : inherited;
10703
+ const who = limited ?? restriction(node);
10704
+ if (FIELD_TYPES.has(node.type)) {
10705
+ const field = node.props.field;
10706
+ if (typeof field === "string" && field) {
10707
+ const control = { nodeId: node.id, hidden: new Set(hidden) };
10708
+ if (who)
10709
+ control.who = who;
10710
+ found.set(field, [...found.get(field) ?? [], control]);
10711
+ }
10712
+ }
10713
+ for (const child of nodeChildren(node))
10714
+ walk(child, hidden, who);
10715
+ };
10716
+ for (const child of nodeChildren(form))
10717
+ walk(child, new Set, undefined);
10718
+ return found;
10719
+ }
10720
+ function coversEveryone(controls) {
10721
+ const who = new Set(controls.map((control) => control.who));
10722
+ for (const label of who) {
10723
+ if (!label)
10724
+ continue;
10725
+ const ab = /^Variant ([AB]) of (A\/B test .+)$/.exec(label);
10726
+ if (ab && who.has(`Variant ${ab[1] === "A" ? "B" : "A"} of ${ab[2]}`))
10727
+ return true;
10728
+ if (label.startsWith("Only ") && who.has(`Hidden for ${label.slice(5)}`))
10729
+ return true;
10730
+ }
10731
+ return false;
10732
+ }
10733
+ function requiredFieldIssues(form, fields) {
10734
+ const controls = boundControls(form);
10735
+ const issues = [];
10736
+ for (const field of fields) {
10737
+ if (!field.required)
10738
+ continue;
10739
+ const label = field.label.trim() || field.name;
10740
+ const bound = controls.get(field.name);
10741
+ if (!bound?.length) {
10742
+ issues.push({ kind: "missing", formNodeId: form.id, field: field.name, label });
10743
+ continue;
10744
+ }
10745
+ const devices = DEVICE_ORDER.filter((device) => bound.every((c) => c.hidden.has(device)));
10746
+ if (devices.length) {
10747
+ issues.push({
10748
+ kind: "hidden",
10749
+ formNodeId: form.id,
10750
+ field: field.name,
10751
+ label,
10752
+ nodeId: bound[0].nodeId,
10753
+ devices
10754
+ });
10755
+ continue;
10756
+ }
10757
+ const first = bound[0];
10758
+ if (bound.every((control) => control.who !== undefined) && !coversEveryone(bound)) {
10759
+ issues.push({
10760
+ kind: "audience",
10761
+ formNodeId: form.id,
10762
+ field: field.name,
10763
+ label,
10764
+ nodeId: first.nodeId,
10765
+ who: first.who
10766
+ });
10767
+ }
10768
+ }
10769
+ return issues;
10770
+ }
10771
+ function requiredFieldIssueText(issue) {
10772
+ if (issue.kind === "missing") {
10773
+ 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.`;
10774
+ }
10775
+ if (issue.kind === "audience") {
10776
+ 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.`;
10777
+ }
10778
+ const where = issue.devices.length === 3 ? "on every device" : `on ${issue.devices.join(" and ")}`;
10779
+ 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.`;
10780
+ }
10361
10781
  // ../emvb/src/core/theme/dynamic.ts
10362
10782
  var BLOCK_STYLES = new Set(["normal", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote"]);
10363
10783
  var DECORATORS = {
@@ -10380,22 +10800,33 @@ function linkDefs(block) {
10380
10800
  }
10381
10801
  return links;
10382
10802
  }
10383
- function spanNode(span, links) {
10803
+ function withBreaks(text) {
10804
+ const out = [];
10805
+ text.split(`
10806
+ `).forEach((part, i) => {
10807
+ if (i > 0)
10808
+ out.push({ tag: "br", attrs: {}, children: [] });
10809
+ if (part)
10810
+ out.push(part);
10811
+ });
10812
+ return out;
10813
+ }
10814
+ function spanNodes(span, links) {
10384
10815
  const text = typeof span["text"] === "string" ? span["text"] : "";
10385
10816
  if (!text)
10386
- return null;
10817
+ return [];
10387
10818
  const marks = Array.isArray(span["marks"]) ? span["marks"].filter((m) => typeof m === "string") : [];
10388
- let node = text;
10819
+ let nodes = withBreaks(text);
10389
10820
  const link = marks.find((mark) => !DECORATORS[mark] && links.has(mark));
10390
10821
  for (const mark of new Set(marks.toReversed())) {
10391
10822
  const tag = DECORATORS[mark];
10392
10823
  if (tag)
10393
- node = { tag, attrs: {}, children: [node] };
10824
+ nodes = [{ tag, attrs: {}, children: nodes }];
10394
10825
  else if (mark === link) {
10395
- node = { tag: "a", attrs: { href: links.get(mark) }, children: [node] };
10826
+ nodes = [{ tag: "a", attrs: { href: links.get(mark) }, children: nodes }];
10396
10827
  }
10397
10828
  }
10398
- return node;
10829
+ return nodes;
10399
10830
  }
10400
10831
  function inlineNodes(block) {
10401
10832
  const links = linkDefs(block);
@@ -10404,20 +10835,7 @@ function inlineNodes(block) {
10404
10835
  for (const child of children) {
10405
10836
  if (!isRecord(child) || child["_type"] !== undefined && child["_type"] !== "span")
10406
10837
  continue;
10407
- const node = spanNode(child, links);
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);
10838
+ out.push(...spanNodes(child, links));
10421
10839
  }
10422
10840
  return out;
10423
10841
  }
@@ -10621,7 +11039,7 @@ var POST_FIELDS = new Map([
10621
11039
  has: (post) => !!post.authorName?.trim(),
10622
11040
  render: (_node, attrs, post) => {
10623
11041
  const name = post.authorName?.trim();
10624
- return name ? { tag: "span", attrs, children: [name.slice(0, 200)] } : undefined;
11042
+ return name ? { tag: "span", attrs, children: [clipText(name, 200)] } : undefined;
10625
11043
  }
10626
11044
  }
10627
11045
  ]
@@ -10754,7 +11172,7 @@ var FORMS_RUNTIME_ATTRS = new Set([
10754
11172
  "data-was-required"
10755
11173
  ]);
10756
11174
  // ../emvb/src/core/render/index.ts
10757
- var FIELD_TYPES = new Set(FORM_FIELD_TYPES.filter((type) => type !== "submit"));
11175
+ var FIELD_TYPES2 = new Set(FORM_FIELD_TYPES.filter((type) => type !== "submit"));
10758
11176
  // ../emvb/src/core/design/transfer.ts
10759
11177
  var MAX_DESIGN_FILE_BYTES = 1024 * 1024;
10760
11178
  // ../emvb/src/core/sanitize/svg-upload.ts
@@ -10949,7 +11367,7 @@ var TEXT_TYPES = new Set([
10949
11367
  "post-title",
10950
11368
  "post-excerpt"
10951
11369
  ]);
10952
- var FIELD_TYPES2 = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
11370
+ var FIELD_TYPES3 = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
10953
11371
  var LINKISH = new Set(["link", "button", "menu-item"]);
10954
11372
  function px(value) {
10955
11373
  if (!value || typeof value !== "object" || !("unit" in value))
@@ -11051,7 +11469,7 @@ function auditPage(layout, design) {
11051
11469
  message: "This image link opens a new tab without saying so; say so in the alt text."
11052
11470
  });
11053
11471
  }
11054
- if (FIELD_TYPES2.has(node.type) && !String(props["label"] ?? "").trim() && !node.bind) {
11472
+ if (FIELD_TYPES3.has(node.type) && !String(props["label"] ?? "").trim() && !node.bind) {
11055
11473
  add({
11056
11474
  nodeId: node.id,
11057
11475
  rule: "control-name",
@@ -11587,7 +12005,7 @@ function stats(layout) {
11587
12005
  walk(child, d + 1);
11588
12006
  };
11589
12007
  walk(layout.root, 1);
11590
- return { nodes, depth, bytes: byteLength(layout) };
12008
+ return { nodes, depth, bytes: byteLength2(layout) };
11591
12009
  }
11592
12010
  var ListPagesInput = strictObject({
11593
12011
  cursor: string2().max(512).optional(),
@@ -11755,6 +12173,7 @@ var DescribePageOutput = object({
11755
12173
  media: number2()
11756
12174
  })),
11757
12175
  headingOutline: array(string2()),
12176
+ warnings: array(object({ nodeId: string2(), message: string2() })).optional(),
11758
12177
  wordCount: number2(),
11759
12178
  images: array(object({ id: string2(), alt: string2(), src: string2(), decorative: boolean2() })).optional()
11760
12179
  });
@@ -11776,6 +12195,53 @@ function imagesOf(root) {
11776
12195
  walk(root);
11777
12196
  return found;
11778
12197
  }
12198
+ function hiddenEverywhere(root) {
12199
+ const warnings = [];
12200
+ const walk = (node) => {
12201
+ const hidden = new Set(node.hiddenOn ?? []);
12202
+ if (hidden.has("desktop") && hidden.has("tablet") && hidden.has("mobile")) {
12203
+ warnings.push({
12204
+ nodeId: node.id,
12205
+ 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.`
12206
+ });
12207
+ return;
12208
+ }
12209
+ for (const child of nodeChildren(node))
12210
+ walk(child);
12211
+ };
12212
+ walk(root);
12213
+ return warnings.slice(0, 50);
12214
+ }
12215
+ async function requiredFieldWarnings(ports, root) {
12216
+ const forms = [];
12217
+ forEachNode(root, (node) => {
12218
+ if (isFormNode(node) && node.props.formId.trim() && forms.length < 20)
12219
+ forms.push(node);
12220
+ });
12221
+ if (forms.length === 0 || !ports.formFields)
12222
+ return [];
12223
+ let fields;
12224
+ try {
12225
+ fields = await ports.formFields([
12226
+ ...new Set(forms.map((form) => form.props.formId.trim()))
12227
+ ]);
12228
+ } catch {
12229
+ return [];
12230
+ }
12231
+ const warnings = [];
12232
+ for (const form of forms) {
12233
+ const defined = fields.get(form.props.formId.trim());
12234
+ if (!defined)
12235
+ continue;
12236
+ for (const issue of requiredFieldIssues(form, defined)) {
12237
+ warnings.push({
12238
+ nodeId: issue.kind === "missing" ? issue.formNodeId : issue.nodeId,
12239
+ 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}.)`
12240
+ });
12241
+ }
12242
+ }
12243
+ return warnings;
12244
+ }
11779
12245
  var clip = (text, max) => text.length > max ? `${text.slice(0, max - 1)}…` : text;
11780
12246
  async function describePage(ports, input) {
11781
12247
  const { page, layout } = await loadPage(ports, input.pageId);
@@ -11797,6 +12263,10 @@ async function describePage(ports, input) {
11797
12263
  return section;
11798
12264
  });
11799
12265
  const wordCount = all.text.join(" ").split(/\s+/).filter(Boolean).length;
12266
+ const warnings = [
12267
+ ...hiddenEverywhere(layout.root),
12268
+ ...await requiredFieldWarnings(ports, layout.root)
12269
+ ].slice(0, 50);
11800
12270
  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
12271
  return {
11802
12272
  pageId: page.id,
@@ -11805,7 +12275,8 @@ async function describePage(ports, input) {
11805
12275
  sections,
11806
12276
  headingOutline: all.headings,
11807
12277
  wordCount,
11808
- images: imagesOf(layout.root)
12278
+ images: imagesOf(layout.root),
12279
+ ...warnings.length ? { warnings } : {}
11809
12280
  };
11810
12281
  }
11811
12282
  var A11yInput = strictObject({ pageId: string2().min(1).max(128) });
@@ -11945,7 +12416,7 @@ var PageId = string2().min(1).max(128);
11945
12416
  var NodeIdInput = string2().min(1).max(64);
11946
12417
  var Rev = string2().min(1).max(256);
11947
12418
  function checkLayout(candidate) {
11948
- const size = byteLength(candidate);
12419
+ const size = byteLength2(candidate);
11949
12420
  if (size > MAX_LAYOUT_BYTES) {
11950
12421
  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
12422
  }
@@ -11957,7 +12428,7 @@ function checkLayout(candidate) {
11957
12428
  if (misplaced.length > 0) {
11958
12429
  throw new McpToolError("NESTING", `Elements are in the wrong place. ${misplaced.map((issue) => issue.message).join("; ")}`);
11959
12430
  }
11960
- const bytes = byteLength(result.layout);
12431
+ const bytes = byteLength2(result.layout);
11961
12432
  if (bytes > MAX_LAYOUT_BYTES) {
11962
12433
  throw new McpToolError("TOO_LARGE", `The page would be ${bytes} bytes; the limit is ${MAX_LAYOUT_BYTES}.`);
11963
12434
  }
@@ -11983,6 +12454,7 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
11983
12454
  throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
11984
12455
  }
11985
12456
  const next = apply(current.layout);
12457
+ refuseUnsafeImageSources(current.layout, next.layout);
11986
12458
  const layout = checkLayout(next.layout);
11987
12459
  try {
11988
12460
  const saved = await ports.savePage(pageId, { layout }, page.rev);
@@ -12006,6 +12478,37 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
12006
12478
  var refused = (reason) => {
12007
12479
  throw new McpToolError("REFUSED", reason);
12008
12480
  };
12481
+ function imageSources2(root) {
12482
+ const found = new Map;
12483
+ const walk = (node) => {
12484
+ if (node.type === "image") {
12485
+ const props = node.props;
12486
+ const list = typeof props.src === "string" ? [props.src] : [];
12487
+ if (Array.isArray(props.sources)) {
12488
+ for (const source of props.sources) {
12489
+ if (typeof source?.src === "string")
12490
+ list.push(source.src);
12491
+ }
12492
+ }
12493
+ found.set(node.id, list);
12494
+ }
12495
+ for (const child of nodeChildren(node))
12496
+ walk(child);
12497
+ };
12498
+ walk(root);
12499
+ return found;
12500
+ }
12501
+ function refuseUnsafeImageSources(before, after) {
12502
+ const old = imageSources2(before.root);
12503
+ for (const [id, list] of imageSources2(after.root)) {
12504
+ const kept = new Set(old.get(id) ?? []);
12505
+ for (const src of list) {
12506
+ if (src.trim() === "" || kept.has(src) || sanitizeMediaUrl(src))
12507
+ continue;
12508
+ 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).`);
12509
+ }
12510
+ }
12511
+ }
12009
12512
  var KNOWN_TYPES = new Set(ELEMENT_DESCRIPTORS.map((d) => d.type));
12010
12513
  var ElementSpec = lazy(() => looseObject({
12011
12514
  type: string2().min(1).max(64),
@@ -12144,6 +12647,23 @@ var UpdateElementInput = strictObject({
12144
12647
  expectedRev: Rev.optional()
12145
12648
  });
12146
12649
  var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
12650
+ function dropOldPictureProps(before, setProps, copy) {
12651
+ if (typeof setProps.src !== "string" || setProps.src === before.src)
12652
+ return;
12653
+ const props = copy.props;
12654
+ if (!isRecord3(props))
12655
+ return;
12656
+ for (const key of ["sources", "edit", "mediaId"]) {
12657
+ if (!(key in setProps))
12658
+ delete props[key];
12659
+ }
12660
+ if (before.mediaId !== undefined && !("mediaId" in setProps)) {
12661
+ if (!("width" in setProps))
12662
+ delete props.width;
12663
+ if (!("height" in setProps))
12664
+ delete props.height;
12665
+ }
12666
+ }
12147
12667
  async function updateElement(ports, input) {
12148
12668
  const set = resolveDesignRefs(input.set ?? {}, (await ports.getDesign()).design);
12149
12669
  return mutatePage(ports, "update_element", input.pageId, input.expectedRev, (layout) => {
@@ -12156,6 +12676,9 @@ async function updateElement(ports, input) {
12156
12676
  continue;
12157
12677
  copy[key] = isRecord3(value) && isRecord3(copy[key]) ? { ...copy[key], ...value } : value;
12158
12678
  }
12679
+ if (node.type === "image" && isRecord3(set.props)) {
12680
+ dropOldPictureProps(node.props, set.props, copy);
12681
+ }
12159
12682
  for (const path of input.unset ?? []) {
12160
12683
  const [top, sub] = path.split(".");
12161
12684
  if (top === "id" || top === "type" || top === "children")
@@ -12255,8 +12778,7 @@ var KIND_OF = {
12255
12778
  fontSizes: "fontSize",
12256
12779
  spacings: "spacing"
12257
12780
  };
12258
- async function variableUses(ports, design, id, kind) {
12259
- const where = findVariableUsagesInDesign(design, id, kind).map((u) => `class ${u.classId}`);
12781
+ async function allLayouts(ports) {
12260
12782
  const pages = [];
12261
12783
  let cursor;
12262
12784
  for (let i = 0;i < 20; i++) {
@@ -12267,14 +12789,26 @@ async function variableUses(ports, design, id, kind) {
12267
12789
  cursor = batch.nextCursor;
12268
12790
  }
12269
12791
  const records = await Promise.all(pages.map((page) => ports.getPage(page.id)));
12792
+ const out = [];
12270
12793
  records.forEach((record2, i) => {
12271
12794
  const layout = record2 ? validateLayout(record2.layout) : null;
12272
- if (layout?.ok && findVariableUsages(layout.layout, id, kind).length > 0) {
12273
- where.push(`page "${pages[i]?.title ?? ""}"`);
12274
- }
12795
+ if (layout?.ok)
12796
+ out.push({ title: pages[i]?.title ?? "", layout: layout.layout });
12275
12797
  });
12798
+ return out;
12799
+ }
12800
+ function variableUses(layouts, design, id, kind) {
12801
+ const where = findVariableUsagesInDesign(design, id, kind).map((u) => `class ${u.classId}`);
12802
+ for (const { title, layout } of layouts) {
12803
+ if (findVariableUsages(layout, id, kind).length > 0)
12804
+ where.push(`page "${title}"`);
12805
+ }
12276
12806
  return where;
12277
12807
  }
12808
+ function classUses(layouts, id) {
12809
+ const uses = (node) => (node.classes ?? []).includes(id) || nodeChildren(node).some(uses);
12810
+ return layouts.filter(({ layout }) => uses(layout.root)).map(({ title }) => `page "${title}"`);
12811
+ }
12278
12812
  var upsert = (list, items) => {
12279
12813
  const next = [...list ?? []];
12280
12814
  for (const item of items) {
@@ -12301,11 +12835,15 @@ async function updateSiteStyles(ports, input) {
12301
12835
  changes.push(`${items.length} ${kind}`);
12302
12836
  }
12303
12837
  }
12304
- if (!input.force) {
12305
- const inUse = await Promise.all((input.removeVariables ?? []).map(async ({ kind, id }) => ({
12306
- id,
12307
- where: await variableUses(ports, state.design, id, KIND_OF[kind])
12308
- })));
12838
+ if (!input.force && (input.removeVariables?.length || input.removeClasses?.length)) {
12839
+ const layouts = await allLayouts(ports);
12840
+ const inUse = [
12841
+ ...(input.removeVariables ?? []).map(({ kind, id }) => ({
12842
+ id,
12843
+ where: variableUses(layouts, state.design, id, KIND_OF[kind])
12844
+ })),
12845
+ ...(input.removeClasses ?? []).map((id) => ({ id, where: classUses(layouts, id) }))
12846
+ ];
12309
12847
  const blocked = inUse.filter((u) => u.where.length > 0);
12310
12848
  if (blocked.length > 0) {
12311
12849
  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.`);
@@ -12409,7 +12947,7 @@ var READ_TOOLS = [
12409
12947
  tool({
12410
12948
  name: "get_layout",
12411
12949
  title: "Get a page layout",
12412
- description: "Returns a page's layout (schema 15) and its revision `rev`. Use format \"outline\" first for a cheap tree of ids, types and labels; pass nodeId for one element's subtree.",
12950
+ 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
12951
  input: GetLayoutInput,
12414
12952
  output: GetLayoutOutput,
12415
12953
  readOnly: true,
@@ -12635,7 +13173,7 @@ var PROMPTS = [
12635
13173
  }
12636
13174
  ];
12637
13175
  // src/bridge.ts
12638
- var BRIDGE_VERSION = "0.5.0";
13176
+ var BRIDGE_VERSION = "0.6.0";
12639
13177
  var failure = (message) => ({
12640
13178
  content: [{ type: "text", text: message }],
12641
13179
  isError: true
@@ -12741,6 +13279,13 @@ function registerPrompts(server) {
12741
13279
 
12742
13280
  // src/remote.ts
12743
13281
  import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
13282
+ function redactToken(error, token) {
13283
+ if (!token || !(error instanceof Error) || !error.message.includes(token))
13284
+ return error;
13285
+ const clean = new Error(error.message.split(token).join("[token]"));
13286
+ clean.name = error.name;
13287
+ return clean;
13288
+ }
12744
13289
  function httpRemote(endpoint, token, version) {
12745
13290
  let connected = null;
12746
13291
  const connect = () => {
@@ -12759,8 +13304,12 @@ function httpRemote(endpoint, token, version) {
12759
13304
  };
12760
13305
  return {
12761
13306
  async call(name, args) {
12762
- const client = await connect();
12763
- return await client.callTool({ name, arguments: args });
13307
+ try {
13308
+ const client = await connect();
13309
+ return await client.callTool({ name, arguments: args });
13310
+ } catch (error) {
13311
+ throw redactToken(error, token);
13312
+ }
12764
13313
  },
12765
13314
  async close() {
12766
13315
  if (connected)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perkyzz/emvb-mcp",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Local (stdio) MCP server for EmVB pages: lets AI agents build EmDash pages through your site's EmDash MCP endpoint.",
5
5
  "keywords": [
6
6
  "emdash",
@@ -41,7 +41,7 @@
41
41
  "@modelcontextprotocol/server": "2.3.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@perkyzz/emvb": "0.5.0",
44
+ "@perkyzz/emvb": "0.6.0",
45
45
  "zod": "~4.5.4"
46
46
  },
47
47
  "engines": {
@@ -32,7 +32,8 @@ instructions.
32
32
  6. **Check accessibility** with `get_accessibility_findings` after building and fix every
33
33
  error. Contrast findings that share one colour: change that colour variable once.
34
34
  7. **Don't publish** unless the person asked and `publish_page` is available. End with
35
- `describe_page` and a short summary so they can review the draft.
35
+ `describe_page` and a short summary so they can review the draft. Fix its warnings too (an
36
+ element hidden on every device, a form's required field with no field on the form).
36
37
 
37
38
  ## What the tools can't do
38
39
 
@@ -52,7 +53,10 @@ instructions.
52
53
  value; `list_element_types` with the type shows its props, allowed parents and notes.
53
54
  - `NESTING` / `REFUSED`: the element can't go there, or the id doesn't exist; re-read the outline.
54
55
  - `TOO_LARGE`: the page is over 512 KB; split it.
55
- - `REFUSED` on removing a variable: it's still used; replace those references first.
56
+ - `REFUSED` on removing a variable or class: a page still uses it (the message names the pages);
57
+ replace those references first. Pass `force: true` only if the person asked.
58
+ - An image `src` must be an http(s) URL or a path on the site; `javascript:`, `data:` and
59
+ `//host` sources are refused.
56
60
  - `PUBLISH_DISABLED`: leave the draft for review.
57
61
  - `FORBIDDEN`: agent access is off on the site, or the token can't use EmVB; tell the person.
58
62
  - `NOT_SET_UP`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.