@perkyzz/emvb-mcp 0.7.0 → 0.9.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+ (0.7.0 recommended) with **Set up EmVB** done, and agents turned on in **Pages VisualBuilder →
37
+ `@perkyzz/emvb` 0.5.0+ (0.8.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
@@ -6261,12 +6261,12 @@ function duration2(params) {
6261
6261
  return _isoDuration(ZodISODuration, params);
6262
6262
  }
6263
6263
  // ../../docs/system/layout-format.md
6264
- var layout_format_default = "# Layout format (schema 16)\n\nHow EmVB stores a page and its site-wide design, at schema 16 (the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 16,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `16` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` (words the empty first choice; unset is \"Choose…\", W-686) | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\"), `titleText` (the paged archive title, `{title}` and `{page}`, W-529), `archiveTitle` (replaces \"Posts\" as the posts archive title, ≤ 60, W-532), and screen reader names `navLabel` (\"Pagination\"), `pageLabel` (\"Page {page}\"), `prevLabel` and `nextLabel` (\"Previous page\" / \"Next page\", used when the text is only an arrow), each ≤ 60 (W-689) | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear infinite`, `emvb-icon-pulse <ms> ease-in-out infinite alternate` or `none`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `transition`, `entrance`, `iconAnimation` and `scrollMotion`, which belong to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `transition` inside a state is dropped and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"tablet\"?, \"mobile\"? }`. Each is a style object with the same keys as `style`. Only keys that differ from desktop are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Tablet is `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A phone matches both, so mobile wins on a shared key, and a tablet-only key still applies on mobile. The bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1025px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 15,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no `data-emvb-*` attributes and no scripts.\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n";
6264
+ var layout_format_default = "# Layout format (schema 17)\n\nHow EmVB stores a page and its site-wide design, at layout schema 17 and design schema 16 (Loop forever on an icon animation in W-853, D-059; 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\": 17,\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 `17` (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, W-885; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` (words the empty first choice; unset is \"Choose…\", W-686) | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\"), `titleText` (the paged archive title, `{title}` and `{page}`, W-529), `archiveTitle` (replaces \"Posts\" as the posts archive title, ≤ 60, W-532), and screen reader names `navLabel` (\"Pagination\"), `pageLabel` (\"Page {page}\"), `prevLabel` and `nextLabel` (\"Previous page\" / \"Next page\", used when the text is only an arrow), each ≤ 60 (W-689) | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000; optional `loop: true` (W-853, D-059) keeps it running forever. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear <runs>`, `emvb-icon-pulse <ms> ease-in-out <runs> alternate` or `none`; W-848: `<runs>` is as many whole runs as fit in 5 s, at least one, even for a pulse; with `loop: true` it is `infinite`); 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\": 16,\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";
6265
6265
 
6266
6266
  // skill/emvb-page-builder/SKILL.md
6267
6267
  var SKILL_default = `---
6268
6268
  name: emvb-page-builder
6269
- description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
6269
+ description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, insert_saved_section, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
6270
6270
  ---
6271
6271
 
6272
6272
  # EmVB page builder
@@ -6295,6 +6295,10 @@ instructions.
6295
6295
  \`recipes\` or \`apply_section_recipe\`), then replace every placeholder with real copy using
6296
6296
  \`update_element\`. Start with "hero" so its heading is the page's one h1. For anything the
6297
6297
  recipes don't cover, \`add_element\` takes a whole section with nested \`children\` in one call.
6298
+ The site's own saved sections come first when one fits: \`list_saved_sections\`, then
6299
+ \`insert_saved_section\` (it adds the classes the section uses to the styles draft; a class whose
6300
+ look changed comes in as a numbered copy such as "Card 2", never overwriting the site's).
6301
+ \`save_section\` saves an element for reuse; \`delete_saved_section\` only when the person asks.
6298
6302
  6. **Check accessibility** with \`get_accessibility_findings\` after building and fix every
6299
6303
  error. Contrast findings that share one colour: change that colour variable once.
6300
6304
  7. **Don't publish** unless the person asked and \`publish_page\` is available. End with
@@ -6326,6 +6330,8 @@ instructions.
6326
6330
  - \`REFUSED\` on a link or an SVG: the page would drop it (a \`javascript:\` link, \`onload\` or a
6327
6331
  script in SVG markup); the message gives the reason. A class or variable name another one
6328
6332
  already has is refused too. A write that changes nothing saves no new version.
6333
+ - \`REFUSED\` on \`insert_saved_section\`: the place can't take the section, or the site is at 100
6334
+ classes; nothing was added to the styles draft. Pick another \`parentId\` or ask the person.
6329
6335
  - \`PUBLISH_DISABLED\`: leave the draft for review.
6330
6336
  - \`FORBIDDEN\`: agent access is off on the site, or the token can't use EmVB; tell the person.
6331
6337
  - \`NOT_SET_UP\`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.
@@ -6654,6 +6660,14 @@ var MOTION_KEYFRAMES = `@media (prefers-reduced-motion: no-preference){@supports
6654
6660
  // ../emvb/src/core/record.ts
6655
6661
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
6656
6662
 
6663
+ // ../emvb/src/core/icons/animation-runs.ts
6664
+ var ICON_ANIMATION_LIMIT_MS = 5000;
6665
+ function iconAnimationRuns(type, durationMs) {
6666
+ if (type === "spin")
6667
+ return Math.max(1, Math.floor(ICON_ANIMATION_LIMIT_MS / durationMs));
6668
+ return 2 * Math.max(1, Math.floor(ICON_ANIMATION_LIMIT_MS / (2 * durationMs)));
6669
+ }
6670
+
6657
6671
  // ../emvb/src/core/sanitize/css.ts
6658
6672
  var setOf = (values) => new Set(values);
6659
6673
  var VAR_ID = /^[a-z0-9-]{1,40}$/;
@@ -6918,22 +6932,25 @@ function cssIconShadow(value) {
6918
6932
  return `drop-shadow(${decimal(x)}px ${decimal(y)}px ${decimal(blur)}px${color ? ` ${color}` : ""})`;
6919
6933
  }
6920
6934
  var ICON_ANIMATIONS = {
6921
- spin: "emvb-icon-spin {ms} linear infinite",
6922
- pulse: "emvb-icon-pulse {ms} ease-in-out infinite alternate"
6935
+ spin: "emvb-icon-spin {ms} linear {runs}",
6936
+ pulse: "emvb-icon-pulse {ms} ease-in-out {runs} alternate"
6923
6937
  };
6924
6938
  function cssIconAnimation(value) {
6925
6939
  if (!isRecord(value))
6926
6940
  return;
6927
- if (Object.keys(value).some((key) => key !== "type" && key !== "duration"))
6941
+ if (Object.keys(value).some((key) => key !== "type" && key !== "duration" && key !== "loop"))
6942
+ return;
6943
+ const { type, duration, loop } = value;
6944
+ if (loop !== undefined && (loop !== true || type === "none"))
6928
6945
  return;
6929
- const { type, duration } = value;
6930
6946
  if (type === "none")
6931
6947
  return duration === undefined ? "none" : undefined;
6932
6948
  if (typeof type !== "string" || !Object.hasOwn(ICON_ANIMATIONS, type))
6933
6949
  return;
6934
6950
  if (!Number.isInteger(duration) || !inRangeNumber(duration, 200, 1e4))
6935
6951
  return;
6936
- return ICON_ANIMATIONS[type]?.replace("{ms}", `${duration}ms`);
6952
+ const runs = loop ? "infinite" : iconAnimationRuns(type === "spin" ? "spin" : "pulse", duration);
6953
+ return ICON_ANIMATIONS[type]?.replace("{ms}", `${duration}ms`).replace("{runs}", String(runs));
6937
6954
  }
6938
6955
  var BACKGROUND_SIZE = setOf(BACKGROUND_SIZES);
6939
6956
  var BACKGROUND_POSITION = setOf(BACKGROUND_POSITIONS);
@@ -7282,7 +7299,8 @@ var StyleProps = strictObject({
7282
7299
  iconAnimation: union([
7283
7300
  strictObject({
7284
7301
  type: _enum(["spin", "pulse"]),
7285
- duration: number2().int().min(200).max(1e4)
7302
+ duration: number2().int().min(200).max(1e4),
7303
+ loop: literal(true).optional()
7286
7304
  }),
7287
7305
  strictObject({ type: literal("none") })
7288
7306
  ]).optional(),
@@ -7337,7 +7355,7 @@ var DeviceStyles = strictObject({
7337
7355
  var HiddenOn = array(_enum(POPUP_DEVICES)).max(3);
7338
7356
 
7339
7357
  // ../emvb/src/core/schema/layout.ts
7340
- var LAYOUT_SCHEMA_VERSION = 16;
7358
+ var LAYOUT_SCHEMA_VERSION = 17;
7341
7359
  var NodeId = string2().regex(/^[A-Za-z0-9_-]{4,24}$/, "Ids are 4-24 letters, digits, _ or -");
7342
7360
  var ClassIds = array(string2().regex(/^[a-z0-9-]{1,40}$/)).max(20);
7343
7361
  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");
@@ -7617,6 +7635,9 @@ var PaginationNode = leafNode("pagination", strictObject({
7617
7635
  nextText: string2().max(40).optional(),
7618
7636
  showCount: boolean2().optional(),
7619
7637
  countText: string2().max(60).optional(),
7638
+ showLast: boolean2().optional(),
7639
+ lastText: string2().max(40).optional(),
7640
+ lastLabel: string2().max(60).optional(),
7620
7641
  titleText: string2().max(60).optional(),
7621
7642
  archiveTitle: string2().max(60).optional(),
7622
7643
  navLabel: string2().max(60).optional(),
@@ -8587,7 +8608,8 @@ var MENU_CSS = [
8587
8608
  ".emvb-menu--column .emvb-menu-item{position:static}",
8588
8609
  ".emvb-menu--column .emvb-menu-item__bar{position:relative;width:fit-content;max-width:100%}",
8589
8610
  ".emvb-menu--column .emvb-menu-panel{top:0;inset-inline-start:100%}",
8590
- ".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}"
8611
+ ".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}",
8612
+ "@media (max-width: 767.98px){.emvb-menu--column .emvb-menu-panel,.emvb-menu--column .emvb-menu-panel--wide{top:100%;inset-inline:auto;inset-inline-start:0;min-width:min(12rem,calc(100vw - 2rem));max-width:calc(100vw - 2rem)}}"
8591
8613
  ].join("");
8592
8614
  var menu = {
8593
8615
  baseCss: MENU_CSS,
@@ -8880,7 +8902,7 @@ var postTitle = {
8880
8902
  defaults: () => ({ type: "post-title", props: { level: 1 } }),
8881
8903
  descriptor: {
8882
8904
  type: "post-title",
8883
- name: "Post Title",
8905
+ name: "Post title",
8884
8906
  group: "dynamic",
8885
8907
  defaultTab: "content",
8886
8908
  fields: [
@@ -8900,7 +8922,7 @@ var postExcerpt = {
8900
8922
  defaults: () => ({ type: "post-excerpt", props: {} }),
8901
8923
  descriptor: {
8902
8924
  type: "post-excerpt",
8903
- name: "Post Excerpt",
8925
+ name: "Post excerpt",
8904
8926
  group: "dynamic",
8905
8927
  defaultTab: "style",
8906
8928
  fields: [
@@ -8920,7 +8942,7 @@ var postContent = {
8920
8942
  defaults: () => ({ type: "post-content", props: {} }),
8921
8943
  descriptor: {
8922
8944
  type: "post-content",
8923
- name: "Post Content",
8945
+ name: "Post content",
8924
8946
  group: "dynamic",
8925
8947
  defaultTab: "style",
8926
8948
  fields: []
@@ -8936,7 +8958,7 @@ var postImage = {
8936
8958
  defaults: () => ({ type: "post-image", props: { decorative: false } }),
8937
8959
  descriptor: {
8938
8960
  type: "post-image",
8939
- name: "Post Image",
8961
+ name: "Post image",
8940
8962
  group: "dynamic",
8941
8963
  defaultTab: "content",
8942
8964
  fields: [{ key: "decorative", kind: "boolean", label: "Decorative", optional: true }]
@@ -8952,7 +8974,7 @@ var postDate = {
8952
8974
  defaults: () => ({ type: "post-date", props: {} }),
8953
8975
  descriptor: {
8954
8976
  type: "post-date",
8955
- name: "Post Date",
8977
+ name: "Post date",
8956
8978
  group: "dynamic",
8957
8979
  defaultTab: "style",
8958
8980
  fields: [
@@ -8978,7 +9000,7 @@ var postAuthor = {
8978
9000
  defaults: () => ({ type: "post-author", props: {} }),
8979
9001
  descriptor: {
8980
9002
  type: "post-author",
8981
- name: "Post Author",
9003
+ name: "Post author",
8982
9004
  group: "dynamic",
8983
9005
  defaultTab: "style",
8984
9006
  fields: []
@@ -8990,7 +9012,7 @@ var postLink = {
8990
9012
  defaults: () => ({ type: "post-link", props: {} }),
8991
9013
  descriptor: {
8992
9014
  type: "post-link",
8993
- name: "Post Link",
9015
+ name: "Post link",
8994
9016
  group: "dynamic",
8995
9017
  defaultTab: "content",
8996
9018
  fields: [
@@ -9073,14 +9095,14 @@ var loop = {
9073
9095
  kind: "text",
9074
9096
  label: "Image field",
9075
9097
  optional: true,
9076
- message: "The field Post Image shows, such as photo. Leave it empty for the featured image."
9098
+ message: "The field Post image shows, such as photo. Leave it empty for the featured image."
9077
9099
  },
9078
9100
  {
9079
9101
  key: "excerptField",
9080
9102
  kind: "text",
9081
9103
  label: "Excerpt field",
9082
9104
  optional: true,
9083
- message: "The field Post Excerpt shows, such as role. Leave it empty for the excerpt."
9105
+ message: "The field Post excerpt shows, such as role. Leave it empty for the excerpt."
9084
9106
  },
9085
9107
  {
9086
9108
  key: "filter",
@@ -9092,9 +9114,9 @@ var loop = {
9092
9114
  {
9093
9115
  key: "itemPartId",
9094
9116
  kind: "text",
9095
- label: "Loop Item",
9117
+ label: "Loop item",
9096
9118
  optional: true,
9097
- message: "Optional published Loop Item theme part. Leave blank to use nested elements as the item template."
9119
+ message: "Optional published Loop item theme part. Leave blank to use nested elements as the item template."
9098
9120
  },
9099
9121
  {
9100
9122
  key: "perPage",
@@ -9145,8 +9167,16 @@ var pagination = {
9145
9167
  kind: "text",
9146
9168
  label: "Count text",
9147
9169
  optional: true,
9148
- message: `{page} and {total} are filled in. EmDash 1.2 doesn't report a total, so the count shows "Page N" until it does.`
9170
+ message: `{page} and {total} are filled in. EmDash doesn't report a total, so the count shows "Page N" unless the site turns on page counting.`
9171
+ },
9172
+ {
9173
+ key: "showLast",
9174
+ kind: "boolean",
9175
+ label: "Show Last link",
9176
+ optional: true,
9177
+ message: "Links to the last page when the site counts pages; otherwise it's left out."
9149
9178
  },
9179
+ { key: "lastText", kind: "text", label: "Last text", optional: true },
9150
9180
  {
9151
9181
  key: "titleText",
9152
9182
  kind: "text",
@@ -9188,6 +9218,13 @@ var pagination = {
9188
9218
  label: "Next name",
9189
9219
  optional: true,
9190
9220
  message: 'Read out when Next text is only an arrow. Unset is "Next page".'
9221
+ },
9222
+ {
9223
+ key: "lastLabel",
9224
+ kind: "text",
9225
+ label: "Last name",
9226
+ optional: true,
9227
+ message: 'Read out when Last text is only an arrow. Unset is "Last page".'
9191
9228
  }
9192
9229
  ]
9193
9230
  },
@@ -9982,7 +10019,7 @@ var divBlock = {
9982
10019
  defaults: () => ({ type: "div-block", props: {}, children: [] }),
9983
10020
  descriptor: {
9984
10021
  type: "div-block",
9985
- name: "Div Block",
10022
+ name: "Div block",
9986
10023
  group: "layout",
9987
10024
  defaultTab: "style",
9988
10025
  fields: BOX_LINK_FIELDS
@@ -10253,7 +10290,8 @@ var LAYOUT_MIGRATIONS = {
10253
10290
  12: unchanged,
10254
10291
  13: unchanged,
10255
10292
  14: unchanged,
10256
- 15: unchanged
10293
+ 15: unchanged,
10294
+ 16: unchanged
10257
10295
  };
10258
10296
  var DESIGN_MIGRATIONS = {
10259
10297
  1: unchanged,
@@ -10269,7 +10307,8 @@ var DESIGN_MIGRATIONS = {
10269
10307
  11: gradients,
10270
10308
  12: unchanged,
10271
10309
  13: unchanged,
10272
- 14: unchanged
10310
+ 14: unchanged,
10311
+ 15: unchanged
10273
10312
  };
10274
10313
  function versionOf(doc) {
10275
10314
  if (typeof doc !== "object" || doc === null)
@@ -10295,7 +10334,7 @@ function upgradeLayout(doc, migrations = LAYOUT_MIGRATIONS, current = LAYOUT_SCH
10295
10334
  return { ok: true, doc: result, from };
10296
10335
  }
10297
10336
  // ../emvb/src/core/schema/design.ts
10298
- var DESIGN_SCHEMA_VERSION = 15;
10337
+ var DESIGN_SCHEMA_VERSION = 16;
10299
10338
  var VariableId = string2().regex(/^[a-z0-9-]{1,40}$/, "Ids are 1-40 lowercase letters, digits or -");
10300
10339
  var ColorVariable = strictObject({
10301
10340
  id: VariableId,
@@ -10604,6 +10643,9 @@ function pageSlug(text, max = 80) {
10604
10643
  }
10605
10644
  return out.replace(/-+$/g, "");
10606
10645
  }
10646
+ function slugify2(text) {
10647
+ return text.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80).replace(/-+$/g, "");
10648
+ }
10607
10649
 
10608
10650
  // ../emvb/src/core/arrange.ts
10609
10651
  var REASONS = {
@@ -10811,7 +10853,20 @@ function sorted(value) {
10811
10853
  }
10812
10854
  var stableJson = (value) => JSON.stringify(sorted(value));
10813
10855
 
10856
+ // ../emvb/src/core/local-style.ts
10857
+ var LOCAL_STYLE_KEYS = ["style", "states", "devices", "hiddenOn"];
10858
+ function localStyleOf(node) {
10859
+ const copied = {};
10860
+ for (const key of LOCAL_STYLE_KEYS) {
10861
+ const value = node[key];
10862
+ if (value !== undefined)
10863
+ copied[key] = structuredClone(value);
10864
+ }
10865
+ return copied;
10866
+ }
10867
+
10814
10868
  // ../emvb/src/core/design/classes.ts
10869
+ var MAX_CLASSES = 100;
10815
10870
  function cleanClassName(name) {
10816
10871
  const spaced = Array.from(name.normalize("NFC"), (ch) => {
10817
10872
  const code = ch.charCodeAt(0);
@@ -10883,6 +10938,106 @@ function findVariableUsagesInDesign(design, id, kind) {
10883
10938
  }
10884
10939
  return usages;
10885
10940
  }
10941
+ function stripRefsFromStyle(style, id, kind) {
10942
+ if (!style)
10943
+ return;
10944
+ let changed = false;
10945
+ const next = { ...style };
10946
+ for (const [prop, value] of Object.entries(style)) {
10947
+ if (!matches(value, id, kind))
10948
+ continue;
10949
+ delete next[prop];
10950
+ changed = true;
10951
+ }
10952
+ if (style.boxShadow && matches(style.boxShadow.color, id, kind)) {
10953
+ const { color: _drop, ...shadow } = style.boxShadow;
10954
+ next["boxShadow"] = shadow;
10955
+ changed = true;
10956
+ }
10957
+ if (style.iconShadow && matches(style.iconShadow.color, id, kind)) {
10958
+ const { color: _drop, ...shadow } = style.iconShadow;
10959
+ next["iconShadow"] = shadow;
10960
+ changed = true;
10961
+ }
10962
+ if (style.gradient?.stops.some((stop) => matches(stop.color, id, kind))) {
10963
+ delete next["gradient"];
10964
+ changed = true;
10965
+ }
10966
+ if (style.overlay && matches(style.overlay.color, id, kind)) {
10967
+ delete next["overlay"];
10968
+ changed = true;
10969
+ }
10970
+ if (!changed)
10971
+ return style;
10972
+ return Object.keys(next).length === 0 ? undefined : next;
10973
+ }
10974
+ function stripRefsFromStates(states, id, kind) {
10975
+ if (!states)
10976
+ return;
10977
+ let changed = false;
10978
+ const next = {};
10979
+ for (const state of STYLE_STATES) {
10980
+ const style = states[state];
10981
+ if (!style)
10982
+ continue;
10983
+ const stripped = stripRefsFromStyle(style, id, kind);
10984
+ if (stripped !== style)
10985
+ changed = true;
10986
+ if (stripped)
10987
+ next[state] = stripped;
10988
+ }
10989
+ if (!changed)
10990
+ return states;
10991
+ return Object.keys(next).length === 0 ? undefined : next;
10992
+ }
10993
+ function stripRefsFromDevices(devices, id, kind) {
10994
+ if (!devices)
10995
+ return;
10996
+ let changed = false;
10997
+ const next = { ...devices };
10998
+ for (const device of RESPONSIVE) {
10999
+ const style = stripRefsFromStyle(devices[device], id, kind);
11000
+ if (style === devices[device])
11001
+ continue;
11002
+ changed = true;
11003
+ if (style)
11004
+ next[device] = style;
11005
+ else
11006
+ delete next[device];
11007
+ }
11008
+ if (!changed)
11009
+ return devices;
11010
+ return next.tablet || next.mobile ? next : undefined;
11011
+ }
11012
+ function stripOwner(owner, id, kind) {
11013
+ const style = stripRefsFromStyle(owner.style, id, kind);
11014
+ const states = stripRefsFromStates(owner.states, id, kind);
11015
+ const devices = stripRefsFromDevices(owner.devices, id, kind);
11016
+ const queryStyle = owner.query ? stripRefsFromStyle(owner.query.style, id, kind) : undefined;
11017
+ const queryChanged = owner.query !== undefined && queryStyle !== owner.query.style;
11018
+ if (style === owner.style && states === owner.states && devices === owner.devices && !queryChanged) {
11019
+ return owner;
11020
+ }
11021
+ const next = { ...owner, style, states, devices };
11022
+ if (style === undefined)
11023
+ delete next.style;
11024
+ if (states === undefined)
11025
+ delete next.states;
11026
+ if (devices === undefined)
11027
+ delete next.devices;
11028
+ if (queryChanged && owner.query)
11029
+ next.query = { ...owner.query, style: queryStyle ?? {} };
11030
+ return next;
11031
+ }
11032
+ function clearVariableRefs(layout, id, kind) {
11033
+ let next = layout;
11034
+ const usages = findVariableUsages(layout, id, kind);
11035
+ const nodeIds = [...new Set(usages.map((u) => u.nodeId))];
11036
+ for (const nodeId of nodeIds) {
11037
+ next = updateNode(next, nodeId, (node) => stripOwner(node, id, kind));
11038
+ }
11039
+ return next;
11040
+ }
10886
11041
  // ../emvb/src/core/audience/variants.ts
10887
11042
  function loneAbTests(layout) {
10888
11043
  const arms = new Map;
@@ -11379,6 +11534,12 @@ var sizes = new WeakMap;
11379
11534
  // ../emvb/src/core/sanitize/escape.ts
11380
11535
  var TEXT_ENTITIES = { "&": "&amp;", "<": "&lt;", ">": "&gt;" };
11381
11536
  var ATTR_ENTITIES = { ...TEXT_ENTITIES, '"': "&quot;", "'": "&#39;" };
11537
+ function escapeText(value) {
11538
+ return value.replace(/[&<>]/g, (ch) => TEXT_ENTITIES[ch] ?? ch);
11539
+ }
11540
+ function escapeAttr(value) {
11541
+ return value.replace(/[&<>"']/g, (ch) => ATTR_ENTITIES[ch] ?? ch);
11542
+ }
11382
11543
 
11383
11544
  // ../emvb/src/core/render/vnode.ts
11384
11545
  var TAGS = new Set([
@@ -11453,6 +11614,22 @@ var TAGS = new Set([
11453
11614
  "tspan"
11454
11615
  ]);
11455
11616
  var VOID = new Set(["hr", "img", "input", "br"]);
11617
+ var ATTR_NAME = /^(?:class|id|href|src|srcset|sizes|alt|width|height|loading|decoding|fetchpriority|dir|role|type|checked|target|rel|aria-[a-z][a-z0-9-]*|title|allow|referrerpolicy|preload|controls|allowfullscreen|sandbox|xmlns|viewBox|fill|stroke|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-opacity|fill-opacity|opacity|transform|focusable|d|cx|cy|r|x|y|x1|y1|x2|y2|points|rx|ry|xlink:href|preserveAspectRatio|gradientUnits|gradientTransform|offset|stop-color|stop-opacity|clipPathUnits|maskUnits|maskContentUnits|patternUnits|patternContentUnits|patternTransform|markerUnits|markerWidth|markerHeight|refX|refY|orient|font-size|font-family|font-weight|text-anchor|dominant-baseline|dx|dy|clip-path|method|action|name|value|placeholder|for|tabindex|autocomplete|open|datetime|muted|loop|playsinline|autoplay|required|novalidate|minlength|maxlength|min|max|pattern|step|data-[a-z][a-z0-9-]*)$/;
11618
+ function serialize(node) {
11619
+ if (typeof node === "string")
11620
+ return escapeText(node);
11621
+ if (!TAGS.has(node.tag))
11622
+ throw new Error(`EmVB: tag "${node.tag}" is not allowed`);
11623
+ let attrs = "";
11624
+ for (const [name, value] of Object.entries(node.attrs)) {
11625
+ if (!ATTR_NAME.test(name))
11626
+ throw new Error(`EmVB: attribute "${name}" is not allowed`);
11627
+ attrs += ` ${name}="${escapeAttr(value)}"`;
11628
+ }
11629
+ if (VOID.has(node.tag))
11630
+ return `<${node.tag}${attrs}>`;
11631
+ return `<${node.tag}${attrs}>${node.children.map(serialize).join("")}</${node.tag}>`;
11632
+ }
11456
11633
 
11457
11634
  // ../emvb/src/core/data/bindings.ts
11458
11635
  var TEXT = (label = "Text") => ({ key: "text", label, kind: "text" });
@@ -11690,11 +11867,157 @@ var FLOAT_CHROME_CSS = `
11690
11867
  .emvb-float__body{min-width:0;flex:1}
11691
11868
  .emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom){max-width:calc(100% - 2rem)}
11692
11869
  .emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom) .emvb-float__body{max-height:calc(100vh - 3.5rem);max-height:calc(100dvh - 3.5rem);overflow:auto}
11870
+ .emvb-float:is(.emvb-float--top,.emvb-float--bottom) .emvb-float__body{max-height:50vh;max-height:50dvh;overflow:auto}
11693
11871
  .emvb-float__close{flex:none;width:2rem;height:2rem;border:0;border-radius:999px;background:transparent;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
11694
11872
  .emvb-float__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
11695
11873
  html{--emvb-float-top:0px;--emvb-float-bottom:0px;scroll-padding-top:var(--emvb-float-top);scroll-padding-bottom:var(--emvb-float-bottom)}
11696
11874
  body{padding-top:var(--emvb-float-top);padding-bottom:var(--emvb-float-bottom)}
11697
11875
  `.replace(/\n+/g, "").trim();
11876
+ // ../emvb/src/core/clipboard.ts
11877
+ var WRAPPER_ID = "emvb_clip";
11878
+ var styleOf = localStyleOf;
11879
+ var none = () => ({ classes: 0, variables: 0, htmlIds: 0, unsafe: 0 });
11880
+ var VARIABLE_LISTS = {
11881
+ color: "colors",
11882
+ font: "fonts",
11883
+ fontSize: "fontSizes",
11884
+ spacing: "spacings"
11885
+ };
11886
+ var asRef = (value) => isRecord(value) && typeof value["var"] === "string" ? { var: value["var"], kind: value["from"] ?? "color" } : null;
11887
+ function refsInStyle(style) {
11888
+ const refs = [];
11889
+ forEachStyleRef(style, (value) => {
11890
+ const ref = asRef(value);
11891
+ if (ref)
11892
+ refs.push(ref);
11893
+ });
11894
+ return refs;
11895
+ }
11896
+ var refsOf = (owner) => [
11897
+ ...refsInStyle(owner.style),
11898
+ ...STYLE_STATES.flatMap((state) => refsInStyle(owner.states?.[state])),
11899
+ ...refsInStyle(owner.devices?.tablet),
11900
+ ...refsInStyle(owner.devices?.mobile),
11901
+ ...refsInStyle(owner.query?.style)
11902
+ ];
11903
+ var hasVariable = (design, ref) => (design.variables[VARIABLE_LISTS[ref.kind]] ?? []).some((v) => v.id === ref.var);
11904
+ function withKnownVariables(node, design, dropped) {
11905
+ const missing = refsOf(node).filter((ref) => !hasVariable(design, ref));
11906
+ if (missing.length === 0)
11907
+ return node;
11908
+ dropped.variables += missing.length;
11909
+ let wrapper = {
11910
+ schemaVersion: LAYOUT_SCHEMA_VERSION,
11911
+ root: { id: WRAPPER_ID, type: "container", props: {}, children: [node] }
11912
+ };
11913
+ for (const ref of missing)
11914
+ wrapper = clearVariableRefs(wrapper, ref.var, ref.kind);
11915
+ return wrapper.root.children[0];
11916
+ }
11917
+ var SANITIZERS = {
11918
+ href: sanitizeHref,
11919
+ media: sanitizeMediaUrl
11920
+ };
11921
+ function withSafeProps(node, dropped) {
11922
+ const type = node.type;
11923
+ if (!(type in ELEMENTS))
11924
+ return node;
11925
+ const props = { ...node.props };
11926
+ const defaults = ELEMENTS[type].defaults().props;
11927
+ let changed = false;
11928
+ const fallBack = (key, optional) => {
11929
+ dropped.unsafe++;
11930
+ changed = true;
11931
+ if (optional || defaults[key] === undefined)
11932
+ delete props[key];
11933
+ else
11934
+ props[key] = defaults[key];
11935
+ };
11936
+ const fields = ELEMENT_DESCRIPTORS.find((d) => d.type === type)?.fields ?? [];
11937
+ for (const field of fields) {
11938
+ if (field.kind !== "href" && field.kind !== "media")
11939
+ continue;
11940
+ const value = props[field.key];
11941
+ if (typeof value !== "string" || value.trim() === "")
11942
+ continue;
11943
+ const safe = SANITIZERS[field.kind](value);
11944
+ if (safe === undefined)
11945
+ fallBack(field.key, field.optional);
11946
+ else if (safe !== value) {
11947
+ props[field.key] = safe;
11948
+ changed = true;
11949
+ }
11950
+ }
11951
+ if (type === "icon" && typeof props["iconSvg"] === "string") {
11952
+ const report = sanitizeSvgReport(props["iconSvg"]);
11953
+ if (!report.tree) {
11954
+ dropped.unsafe++;
11955
+ changed = true;
11956
+ delete props["iconSvg"];
11957
+ } else if (report.images > 0) {
11958
+ props["iconSvg"] = serialize(report.tree);
11959
+ dropped.images = (dropped.images ?? 0) + report.images;
11960
+ changed = true;
11961
+ }
11962
+ }
11963
+ if (type === "svg" && typeof props["markup"] === "string") {
11964
+ const report = sanitizeSvgReport(props["markup"]);
11965
+ if (!report.tree)
11966
+ fallBack("markup", false);
11967
+ else if (report.images > 0) {
11968
+ props["markup"] = serialize(report.tree);
11969
+ dropped.images = (dropped.images ?? 0) + report.images;
11970
+ changed = true;
11971
+ }
11972
+ }
11973
+ return changed ? { ...node, props } : node;
11974
+ }
11975
+ function htmlIdsOf(node, into = new Set) {
11976
+ if (node.htmlId)
11977
+ into.add(node.htmlId);
11978
+ for (const child of nodeChildren(node))
11979
+ htmlIdsOf(child, into);
11980
+ return into;
11981
+ }
11982
+ function cleanNode(node, design, usedHtmlIds, dropped) {
11983
+ let next = withSafeProps(withKnownVariables(node, design, dropped), dropped);
11984
+ if (next.classes) {
11985
+ const known = new Set((design.classes ?? []).map((cls) => cls.id));
11986
+ const kept = next.classes.filter((id) => known.has(id));
11987
+ if (kept.length !== next.classes.length) {
11988
+ dropped.classes += next.classes.length - kept.length;
11989
+ next = { ...next, classes: kept };
11990
+ if (kept.length === 0)
11991
+ delete next.classes;
11992
+ }
11993
+ }
11994
+ if (next.htmlId && usedHtmlIds.has(next.htmlId)) {
11995
+ dropped.htmlIds++;
11996
+ next = { ...next };
11997
+ delete next.htmlId;
11998
+ }
11999
+ if (next.variant) {
12000
+ next = { ...next };
12001
+ delete next.variant;
12002
+ }
12003
+ const kids = nodeChildren(next);
12004
+ if (kids.length === 0)
12005
+ return next;
12006
+ return {
12007
+ ...next,
12008
+ children: kids.map((child) => cleanNode(child, design, usedHtmlIds, dropped))
12009
+ };
12010
+ }
12011
+ function prepareElement(node, layout, design, random = Math.random) {
12012
+ const dropped = none();
12013
+ const cleaned = cleanNode(node, design, htmlIdsOf(layout.root), dropped);
12014
+ return { node: withFreshIds(layout, cleaned, random), dropped };
12015
+ }
12016
+ function prepareStyle(style, design) {
12017
+ const dropped = none();
12018
+ const holder = withKnownVariables({ id: WRAPPER_ID, type: "divider", props: {}, ...style }, design, dropped);
12019
+ return { style: styleOf(holder), dropped };
12020
+ }
11698
12021
  // ../emvb/src/core/a11y/audit.ts
11699
12022
  var spoken = (value) => String(value ?? "").replace(/[\p{Cf}\u115F\u1160\u2800\u3164\uFFA0]/gu, "").trim();
11700
12023
  var WEIGHT = { error: 12, warning: 4 };
@@ -11782,6 +12105,20 @@ function effectiveStyle(node, design) {
11782
12105
  const fromClasses = (design.classes ?? []).filter((c) => classIds.has(c.id)).reduce((acc, c) => Object.assign(acc, c.style), { ...tagDefaults });
11783
12106
  return { ...fromClasses, ...node.style };
11784
12107
  }
12108
+ function deviceStyles(node, design) {
12109
+ const ids = new Set(node.classes ?? []);
12110
+ const merged = {};
12111
+ const layers = [
12112
+ ...(design.classes ?? []).filter((c) => ids.has(c.id)).map((c) => c.devices),
12113
+ node.devices
12114
+ ];
12115
+ for (const devices of layers) {
12116
+ for (const [key, st] of Object.entries(devices ?? {})) {
12117
+ merged[key] = { ...merged[key], ...st };
12118
+ }
12119
+ }
12120
+ return Object.values(merged);
12121
+ }
11785
12122
  function largeText(node, design) {
11786
12123
  const style = effectiveStyle(node, design);
11787
12124
  const level = headingLevel(node);
@@ -11873,16 +12210,21 @@ function auditPage(layout, design) {
11873
12210
  fixLabel: "Mark as decorative"
11874
12211
  });
11875
12212
  }
11876
- const looping = [node.style, ...Object.values(node.devices ?? {})].some((st) => {
12213
+ const tooLong = [effectiveStyle(node, design), ...deviceStyles(node, design)].some((st) => {
11877
12214
  const anim = st?.iconAnimation;
11878
- return anim?.type === "spin" || anim?.type === "pulse";
12215
+ if (anim?.type !== "spin" && anim?.type !== "pulse")
12216
+ return false;
12217
+ if (anim.loop === true)
12218
+ return true;
12219
+ const ms = typeof anim.duration === "number" ? anim.duration : 0;
12220
+ return iconAnimationRuns(anim.type, ms) * ms > ICON_ANIMATION_LIMIT_MS;
11879
12221
  });
11880
- if (looping) {
12222
+ if (tooLong) {
11881
12223
  add({
11882
12224
  nodeId: node.id,
11883
12225
  rule: "motion",
11884
12226
  severity: "warning",
11885
- message: "This icon animates without end and visitors can't pause it. Keep it only if the motion is essential, such as a loading spinner."
12227
+ message: "This icon animates for more than 5 seconds and visitors can't pause it. Shorten the duration, or keep it only if the motion is essential."
11886
12228
  });
11887
12229
  }
11888
12230
  if (node.type === "image" && Array.isArray(props["sources"]) && props["sources"].length > 0) {
@@ -12386,6 +12728,144 @@ function recipeNode(id, design, layout, random = Math.random) {
12386
12728
  }
12387
12729
  // ../emvb/src/core/share/link.ts
12388
12730
  var MAX_UNPACKED_BYTES = MAX_LAYOUT_BYTES + MAX_DESIGN_BYTES + 4096;
12731
+ // ../emvb/src/core/canvas-collections.ts
12732
+ var OWN = new Set(["emvb_pages", "emvb_theme_parts"]);
12733
+ // ../emvb/src/core/saved-sections.ts
12734
+ var SAVED_SECTION_VERSION = 1;
12735
+ var SAVED_SECTION_NAME_MAX = 60;
12736
+ var SAVED_SECTION_REASONS = {
12737
+ name: "Give the section a name.",
12738
+ root: "Choose an element inside the page; the page itself can't be saved as a section.",
12739
+ missing: REASONS.missing,
12740
+ tooBig: "This section is too big to save.",
12741
+ damaged: "This saved section can't be read.",
12742
+ tooManyClasses: `Inserting this section would go over ${MAX_CLASSES} classes on this site.`
12743
+ };
12744
+ var refuse2 = (reason) => ({ ok: false, reason });
12745
+ var WRAPPER_ID2 = "savedsection";
12746
+ var savedSectionName = (raw) => clipText(cleanClassName(raw), SAVED_SECTION_NAME_MAX).trim();
12747
+ function withoutVariants(node) {
12748
+ const { variant: _variant, ...rest } = node;
12749
+ const kids = nodeChildren(node);
12750
+ if (kids.length === 0)
12751
+ return rest;
12752
+ return { ...rest, children: kids.map(withoutVariants) };
12753
+ }
12754
+ function classIdsIn(node, into = new Set) {
12755
+ for (const id of node.classes ?? [])
12756
+ into.add(id);
12757
+ for (const child of nodeChildren(node))
12758
+ classIdsIn(child, into);
12759
+ return into;
12760
+ }
12761
+ var wrap = (node) => ({
12762
+ schemaVersion: LAYOUT_SCHEMA_VERSION,
12763
+ root: { id: WRAPPER_ID2, type: "container", props: {}, children: [node] }
12764
+ });
12765
+ function snapshotSection(layout, nodeId, design, rawName, now) {
12766
+ const name = savedSectionName(rawName);
12767
+ if (!name)
12768
+ return refuse2(SAVED_SECTION_REASONS.name);
12769
+ if (nodeId === layout.root.id)
12770
+ return refuse2(SAVED_SECTION_REASONS.root);
12771
+ const found = findNode(layout, nodeId);
12772
+ if (!found)
12773
+ return refuse2(SAVED_SECTION_REASONS.missing);
12774
+ const node = withoutVariants(structuredClone(found));
12775
+ const used = classIdsIn(node);
12776
+ const classes = (design.classes ?? []).filter((c) => used.has(c.id)).map((c) => structuredClone(c));
12777
+ const record = {
12778
+ version: SAVED_SECTION_VERSION,
12779
+ name,
12780
+ layout: wrap(node),
12781
+ designSchemaVersion: DESIGN_SCHEMA_VERSION,
12782
+ classes,
12783
+ createdAt: now,
12784
+ updatedAt: now
12785
+ };
12786
+ if (byteLength2(record) > MAX_LAYOUT_BYTES)
12787
+ return refuse2(SAVED_SECTION_REASONS.tooBig);
12788
+ const checked = validateLayout(record.layout);
12789
+ if (!checked.ok)
12790
+ return refuse2(summarizeIssues(checked.issues));
12791
+ return { ok: true, record };
12792
+ }
12793
+ function lookOf(cls) {
12794
+ const sorted = (value) => Array.isArray(value) ? value.map(sorted) : isRecord(value) ? Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, sorted(value[key])])) : value;
12795
+ const { id: _id, name: _name, ...look } = cls;
12796
+ return JSON.stringify(sorted(look));
12797
+ }
12798
+ function mergeSectionClasses(design, incoming) {
12799
+ const classes = [...design.classes ?? []];
12800
+ const merge = { design, ids: new Map, added: [], reused: [], renamed: [] };
12801
+ for (const raw of incoming) {
12802
+ const { style } = prepareStyle(raw, design);
12803
+ const cls = { id: raw.id, name: raw.name, style: style.style ?? {} };
12804
+ if (style.states)
12805
+ cls.states = style.states;
12806
+ if (style.devices)
12807
+ cls.devices = style.devices;
12808
+ if (style.hiddenOn)
12809
+ cls.hiddenOn = style.hiddenOn;
12810
+ const look = lookOf(cls);
12811
+ const same = classes.find((c) => (c.id === cls.id || nameKey(c.name) === nameKey(cls.name)) && lookOf(c) === look);
12812
+ if (same) {
12813
+ merge.ids.set(raw.id, same.id);
12814
+ merge.reused.push(same.name);
12815
+ continue;
12816
+ }
12817
+ if (classes.length >= MAX_CLASSES)
12818
+ return refuse2(SAVED_SECTION_REASONS.tooManyClasses);
12819
+ const names = new Set(classes.map((c) => nameKey(c.name)));
12820
+ let name = cls.name;
12821
+ for (let n = 2;names.has(nameKey(name)); n++) {
12822
+ name = `${clipText(cls.name, 54).trim()} ${n}`;
12823
+ }
12824
+ const ids = new Set(classes.map((c) => c.id));
12825
+ const base = ids.has(cls.id) ? slugify2(name).slice(0, 34).replace(/-+$/, "") || "class" : cls.id;
12826
+ let id = base;
12827
+ for (let n = 2;ids.has(id); n++)
12828
+ id = `${base}-${n}`.slice(0, 40);
12829
+ classes.push({ ...cls, id, name });
12830
+ merge.ids.set(raw.id, id);
12831
+ if (name === cls.name)
12832
+ merge.added.push(name);
12833
+ else
12834
+ merge.renamed.push({ from: cls.name, to: name });
12835
+ }
12836
+ merge.design = { ...design, classes };
12837
+ return merge;
12838
+ }
12839
+ function withClassIds(node, ids) {
12840
+ const kids = nodeChildren(node);
12841
+ const next = { ...node };
12842
+ if (node.classes)
12843
+ next.classes = node.classes.map((id) => ids.get(id) ?? id);
12844
+ if (kids.length > 0) {
12845
+ next.children = kids.map((kid) => withClassIds(kid, ids));
12846
+ }
12847
+ return next;
12848
+ }
12849
+ function prepareSavedSection(section, layout, design, random = Math.random, merged) {
12850
+ const merge = merged ?? mergeSectionClasses(design, section.classes);
12851
+ if ("ok" in merge)
12852
+ return merge;
12853
+ const remapped = withClassIds(section.node, merge.ids);
12854
+ const { node, dropped } = prepareElement(remapped, layout, merge.design, random);
12855
+ return { ok: true, node, design: merge.design, merge, dropped };
12856
+ }
12857
+ function classMergeNotice(merge) {
12858
+ const parts = [];
12859
+ if (merge.added.length > 0)
12860
+ parts.push(`${merge.added.length} added`);
12861
+ if (merge.renamed.length > 0) {
12862
+ const list = merge.renamed.map(({ from, to }) => `${from} → ${to}`).join(", ");
12863
+ parts.push(`${merge.renamed.length} added as a copy (${list})`);
12864
+ }
12865
+ return parts.length > 0 ? `Classes: ${parts.join("; ")}.` : null;
12866
+ }
12867
+ // ../emvb/src/core/portable-text.ts
12868
+ var IMAGE_SCHEMES = new Set(["https:", "http:"]);
12389
12869
  // ../emvb/src/mcp/errors.ts
12390
12870
  var STATUS = {
12391
12871
  INVALID_INPUT: 400,
@@ -13513,6 +13993,139 @@ async function publishSiteStyles(ports, input) {
13513
13993
  });
13514
13994
  }
13515
13995
 
13996
+ // ../emvb/src/mcp/sections.ts
13997
+ var SectionId = string2().regex(/^[0-9a-f]{16}$/, "Section ids are 16 hex characters");
13998
+ var portOf = (ports) => {
13999
+ if (!ports.savedSections) {
14000
+ throw new McpToolError("NOT_SET_UP", "Saved sections aren't available on this site.");
14001
+ }
14002
+ return ports.savedSections;
14003
+ };
14004
+ var SectionSummary = object({
14005
+ id: string2(),
14006
+ name: string2(),
14007
+ updatedAt: string2(),
14008
+ classCount: number2(),
14009
+ damaged: literal(true).optional()
14010
+ });
14011
+ var ListSavedSectionsInput = strictObject({});
14012
+ var ListSavedSectionsOutput = object({ sections: array(SectionSummary) });
14013
+ var listSavedSections = async (ports) => ({
14014
+ sections: await portOf(ports).list()
14015
+ });
14016
+ var SaveSectionInput = strictObject({
14017
+ pageId: PageId,
14018
+ elementId: NodeIdInput,
14019
+ name: string2().min(1).max(255)
14020
+ });
14021
+ var SaveSectionOutput = object({
14022
+ id: string2(),
14023
+ name: string2(),
14024
+ summary: string2()
14025
+ });
14026
+ async function saveSection(ports, input) {
14027
+ const port = portOf(ports);
14028
+ const page = await ports.getPage(input.pageId);
14029
+ if (!page) {
14030
+ throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}. Call list_pages.`);
14031
+ }
14032
+ const layout = validateLayout(page.layout);
14033
+ if (!layout.ok) {
14034
+ throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
14035
+ }
14036
+ const { design } = await ports.getDesign();
14037
+ const now = new Date().toISOString();
14038
+ const snap = snapshotSection(layout.layout, input.elementId, design, input.name, now);
14039
+ if (!snap.ok)
14040
+ throw new McpToolError("REFUSED", snap.reason);
14041
+ const made = await port.create(snap.record);
14042
+ if ("ok" in made)
14043
+ throw new McpToolError("REFUSED", made.reason);
14044
+ const summary = `Saved ${input.elementId} as the section "${snap.record.name}"`;
14045
+ return { id: made.id, name: snap.record.name, summary };
14046
+ }
14047
+ async function sectionOf(port, id) {
14048
+ const found = await port.get(id);
14049
+ if (!found) {
14050
+ throw new McpToolError("NOT_FOUND", `No saved section ${id}. Call list_saved_sections.`);
14051
+ }
14052
+ if ("ok" in found)
14053
+ throw new McpToolError("REFUSED", found.reason);
14054
+ return found;
14055
+ }
14056
+ var InsertSavedSectionInput = strictObject({
14057
+ pageId: PageId,
14058
+ sectionId: SectionId,
14059
+ parentId: NodeIdInput.optional(),
14060
+ index: number2().int().min(0).optional(),
14061
+ expectedRev: Rev.optional()
14062
+ });
14063
+ var InsertSavedSectionOutput = WriteOutput.extend({ classes: string2().nullable() });
14064
+ async function insertSavedSection2(ports, input) {
14065
+ const section = await sectionOf(portOf(ports), input.sectionId);
14066
+ const place = (root) => ({
14067
+ parentId: input.parentId ?? root,
14068
+ index: input.index ?? Number.MAX_SAFE_INTEGER
14069
+ });
14070
+ return queued("styles", async () => {
14071
+ const state = await ports.getDesign();
14072
+ const page = await ports.getPage(input.pageId);
14073
+ if (!page) {
14074
+ throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}. Call list_pages.`);
14075
+ }
14076
+ if (input.expectedRev !== undefined && page.rev !== input.expectedRev) {
14077
+ throw new McpToolError("CONFLICT", "The page changed since you read it. Call get_layout again and retry with its rev.", { rev: page.rev });
14078
+ }
14079
+ const current = validateLayout(page.layout);
14080
+ if (!current.ok) {
14081
+ throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
14082
+ }
14083
+ const tried = prepareSavedSection(section, current.layout, state.design);
14084
+ if (!tried.ok)
14085
+ throw new McpToolError("REFUSED", tried.reason);
14086
+ const fits = addNode(current.layout, tried.node, place(current.layout.root.id));
14087
+ if (!fits.ok)
14088
+ throw new McpToolError("REFUSED", fits.reason);
14089
+ const merge = mergeSectionClasses(state.design, section.classes);
14090
+ if ("ok" in merge)
14091
+ throw new McpToolError("REFUSED", merge.reason);
14092
+ const notice = classMergeNotice(merge);
14093
+ if (notice) {
14094
+ const checked = validateDesign(merge.design);
14095
+ if (!checked.ok)
14096
+ throw new McpToolError("REFUSED", "The section's classes can't be added.");
14097
+ await ports.saveDesign(checked.design, state.revision);
14098
+ await ports.log({ target: "styles", tool: "insert_saved_section", summary: notice });
14099
+ }
14100
+ const design = merge.design;
14101
+ const result = await mutatePage(ports, "insert_saved_section", input.pageId, input.expectedRev, (layout) => {
14102
+ const prepared = prepareSavedSection(section, layout, design, Math.random, merge);
14103
+ if (!prepared.ok)
14104
+ throw new McpToolError("REFUSED", prepared.reason);
14105
+ const added = addNode(layout, prepared.node, place(layout.root.id));
14106
+ if (!added.ok)
14107
+ throw new McpToolError("REFUSED", added.reason);
14108
+ return {
14109
+ layout: added.layout,
14110
+ changed: [prepared.node.id],
14111
+ summary: `Added the saved section "${section.name}" as ${prepared.node.id}`
14112
+ };
14113
+ });
14114
+ return { ...result, classes: notice };
14115
+ });
14116
+ }
14117
+ var DeleteSavedSectionInput = strictObject({ sectionId: SectionId });
14118
+ var DeleteSavedSectionOutput = object({ id: string2(), summary: string2() });
14119
+ async function deleteSavedSection(ports, input) {
14120
+ if (!await portOf(ports).remove(input.sectionId)) {
14121
+ throw new McpToolError("NOT_FOUND", `No saved section ${input.sectionId}. Call list_saved_sections.`);
14122
+ }
14123
+ return {
14124
+ id: input.sectionId,
14125
+ summary: "Deleted the saved section. Pages that already use a copy keep it."
14126
+ };
14127
+ }
14128
+
13516
14129
  // ../emvb/src/mcp/tools.ts
13517
14130
  var tool = (def) => def;
13518
14131
  var READ_TOOLS = [
@@ -13595,6 +14208,16 @@ var READ_TOOLS = [
13595
14208
  readOnly: true,
13596
14209
  destructive: false,
13597
14210
  run: (ports, input) => listVersions(ports, input)
14211
+ }),
14212
+ tool({
14213
+ name: "list_saved_sections",
14214
+ title: "List saved sections",
14215
+ description: "Lists the site's saved sections (My sections) by id and name, newest first. Insert one with insert_saved_section.",
14216
+ input: ListSavedSectionsInput,
14217
+ output: ListSavedSectionsOutput,
14218
+ readOnly: true,
14219
+ destructive: false,
14220
+ run: (ports) => listSavedSections(ports)
13598
14221
  })
13599
14222
  ];
13600
14223
  var WRITE_TOOLS = [
@@ -13677,6 +14300,36 @@ var WRITE_TOOLS = [
13677
14300
  readOnly: false,
13678
14301
  destructive: false,
13679
14302
  run: (ports, input) => restoreVersion(ports, input)
14303
+ }),
14304
+ tool({
14305
+ name: "save_section",
14306
+ title: "Save an element as a section",
14307
+ description: "Saves a copy of an element and its children, with the classes they use, to My sections under a name. Copies only: synced sections are made in the editor.",
14308
+ input: SaveSectionInput,
14309
+ output: SaveSectionOutput,
14310
+ readOnly: false,
14311
+ destructive: false,
14312
+ run: (ports, input) => saveSection(ports, input)
14313
+ }),
14314
+ tool({
14315
+ name: "insert_saved_section",
14316
+ title: "Insert a saved section",
14317
+ description: "Adds a copy of a saved section at parentId/index (default: end of the page). Classes it uses are added to the site styles draft when missing; a class with the same name but a different look is added as a numbered copy, never overwritten.",
14318
+ input: InsertSavedSectionInput,
14319
+ output: InsertSavedSectionOutput,
14320
+ readOnly: false,
14321
+ destructive: false,
14322
+ run: (ports, input) => insertSavedSection2(ports, input)
14323
+ }),
14324
+ tool({
14325
+ name: "delete_saved_section",
14326
+ title: "Delete a saved section",
14327
+ description: "Removes a section from My sections. Pages that already hold a copy keep it.",
14328
+ input: DeleteSavedSectionInput,
14329
+ output: DeleteSavedSectionOutput,
14330
+ readOnly: false,
14331
+ destructive: true,
14332
+ run: (ports, input) => deleteSavedSection(ports, input)
13680
14333
  })
13681
14334
  ];
13682
14335
  var PUBLISH_TOOLS = [
@@ -13754,8 +14407,66 @@ var PROMPTS = [
13754
14407
  text: (a) => `Review page ${q(a["pageId"])} without editing it: call describe_page (sections, heading outline, images with their alt text) and get_accessibility_findings, and get_layout when you need styles or ids. Then write a short review covering structure, copy, images and alt text, accessibility, and consistency with the site styles, with the element ids for each suggestion.`
13755
14408
  }
13756
14409
  ];
14410
+ // src/remote.ts
14411
+ import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
14412
+ function redactToken(error, token) {
14413
+ if (!token || !(error instanceof Error) || !error.message.includes(token))
14414
+ return error;
14415
+ const clean = new Error(error.message.split(token).join("[token]"));
14416
+ clean.name = error.name;
14417
+ return clean;
14418
+ }
14419
+ var CALL_TIMEOUT_MS = 60000;
14420
+ var CONNECT_RETRY_DELAYS_MS = [250, 1000];
14421
+ function isRetryableConnectError(error) {
14422
+ const message = error instanceof Error ? error.message : String(error);
14423
+ return !/40[13]|unauthori[sz]ed|forbidden|invalid[_ ](or expired )?token|expired token|scope/i.test(message);
14424
+ }
14425
+ async function connectWithRetry(attempt, sleep = (ms) => new Promise((r) => setTimeout(r, ms)), delays = CONNECT_RETRY_DELAYS_MS) {
14426
+ try {
14427
+ return await attempt();
14428
+ } catch (error) {
14429
+ const [wait, ...rest] = delays;
14430
+ if (wait === undefined || !isRetryableConnectError(error))
14431
+ throw error;
14432
+ await sleep(wait);
14433
+ return connectWithRetry(attempt, sleep, rest);
14434
+ }
14435
+ }
14436
+ function httpRemote(endpoint, token, version) {
14437
+ let connected = null;
14438
+ const connect = () => {
14439
+ connected ??= connectWithRetry(async () => {
14440
+ const client = new Client({ name: "emvb-mcp", version });
14441
+ const transport = new StreamableHTTPClientTransport(endpoint, {
14442
+ requestInit: { headers: { authorization: `Bearer ${token}` } }
14443
+ });
14444
+ await client.connect(transport, { timeout: CALL_TIMEOUT_MS });
14445
+ return client;
14446
+ }).catch((error) => {
14447
+ connected = null;
14448
+ throw error;
14449
+ });
14450
+ return connected;
14451
+ };
14452
+ return {
14453
+ async call(name, args) {
14454
+ try {
14455
+ const client = await connect();
14456
+ return await client.callTool({ name, arguments: args }, { timeout: CALL_TIMEOUT_MS });
14457
+ } catch (error) {
14458
+ throw redactToken(error, token);
14459
+ }
14460
+ },
14461
+ async close() {
14462
+ if (connected)
14463
+ await (await connected).close();
14464
+ }
14465
+ };
14466
+ }
14467
+
13757
14468
  // src/bridge.ts
13758
- var BRIDGE_VERSION = "0.7.0";
14469
+ var BRIDGE_VERSION = "0.9.0";
13759
14470
  var failure = (message) => ({
13760
14471
  content: [{ type: "text", text: message }],
13761
14472
  isError: true
@@ -13771,6 +14482,9 @@ function explain(error, tool) {
13771
14482
  if (/not found|unknown tool/i.test(message)) {
13772
14483
  return failure(`The site doesn't offer emvb__${tool}. Check that EmDash's MCP is on (mcp: true, EmDash 1.2+) and that an admin approved the EmVB tools.`);
13773
14484
  }
14485
+ if (/timed out|timeout/i.test(message)) {
14486
+ return failure(`The site didn't answer within ${CALL_TIMEOUT_MS / 1000} s. It may be down or slow; try again.`);
14487
+ }
13774
14488
  return failure(`Couldn't reach the site: ${message}`);
13775
14489
  }
13776
14490
  function createBridgeServer(options) {
@@ -13859,47 +14573,6 @@ function registerPrompts(server) {
13859
14573
  }
13860
14574
  }
13861
14575
 
13862
- // src/remote.ts
13863
- import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
13864
- function redactToken(error, token) {
13865
- if (!token || !(error instanceof Error) || !error.message.includes(token))
13866
- return error;
13867
- const clean = new Error(error.message.split(token).join("[token]"));
13868
- clean.name = error.name;
13869
- return clean;
13870
- }
13871
- function httpRemote(endpoint, token, version) {
13872
- let connected = null;
13873
- const connect = () => {
13874
- connected ??= (async () => {
13875
- const client = new Client({ name: "emvb-mcp", version });
13876
- const transport = new StreamableHTTPClientTransport(endpoint, {
13877
- requestInit: { headers: { authorization: `Bearer ${token}` } }
13878
- });
13879
- await client.connect(transport);
13880
- return client;
13881
- })().catch((error) => {
13882
- connected = null;
13883
- throw error;
13884
- });
13885
- return connected;
13886
- };
13887
- return {
13888
- async call(name, args) {
13889
- try {
13890
- const client = await connect();
13891
- return await client.callTool({ name, arguments: args });
13892
- } catch (error) {
13893
- throw redactToken(error, token);
13894
- }
13895
- },
13896
- async close() {
13897
- if (connected)
13898
- await (await connected).close();
13899
- }
13900
- };
13901
- }
13902
-
13903
14576
  // src/cli.ts
13904
14577
  var log = (message) => process.stderr.write(`[emvb-mcp] ${message}
13905
14578
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perkyzz/emvb-mcp",
3
- "version": "0.7.0",
3
+ "version": "0.9.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",
@@ -37,11 +37,11 @@
37
37
  "prepack": "bun run build"
38
38
  },
39
39
  "dependencies": {
40
- "@modelcontextprotocol/client": "2.3.1",
41
- "@modelcontextprotocol/server": "2.3.1"
40
+ "@modelcontextprotocol/client": "2.4.0",
41
+ "@modelcontextprotocol/server": "2.4.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@perkyzz/emvb": "0.7.0",
44
+ "@perkyzz/emvb": "0.9.0",
45
45
  "zod": "~4.5.4"
46
46
  },
47
47
  "engines": {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: emvb-page-builder
3
- description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
3
+ description: Build, restyle and review EmVB visual pages on an EmDash site through the EmVB MCP tools (list_pages, get_layout, create_page, add_element, update_element, apply_section_recipe, insert_saved_section, update_site_styles, get_accessibility_findings). Use when asked to create, change, restyle, review or fix the accessibility of pages on a site built with EmVB or EmDash, including landing pages, menus, portfolios and pages with tabs, accordions, forms or post loops.
4
4
  ---
5
5
 
6
6
  # EmVB page builder
@@ -29,6 +29,10 @@ instructions.
29
29
  `recipes` or `apply_section_recipe`), then replace every placeholder with real copy using
30
30
  `update_element`. Start with "hero" so its heading is the page's one h1. For anything the
31
31
  recipes don't cover, `add_element` takes a whole section with nested `children` in one call.
32
+ The site's own saved sections come first when one fits: `list_saved_sections`, then
33
+ `insert_saved_section` (it adds the classes the section uses to the styles draft; a class whose
34
+ look changed comes in as a numbered copy such as "Card 2", never overwriting the site's).
35
+ `save_section` saves an element for reuse; `delete_saved_section` only when the person asks.
32
36
  6. **Check accessibility** with `get_accessibility_findings` after building and fix every
33
37
  error. Contrast findings that share one colour: change that colour variable once.
34
38
  7. **Don't publish** unless the person asked and `publish_page` is available. End with
@@ -60,6 +64,8 @@ instructions.
60
64
  - `REFUSED` on a link or an SVG: the page would drop it (a `javascript:` link, `onload` or a
61
65
  script in SVG markup); the message gives the reason. A class or variable name another one
62
66
  already has is refused too. A write that changes nothing saves no new version.
67
+ - `REFUSED` on `insert_saved_section`: the place can't take the section, or the site is at 100
68
+ classes; nothing was added to the styles draft. Pick another `parentId` or ask the person.
63
69
  - `PUBLISH_DISABLED`: leave the draft for review.
64
70
  - `FORBIDDEN`: agent access is off on the site, or the token can't use EmVB; tell the person.
65
71
  - `NOT_SET_UP`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.