@perkyzz/emvb-mcp 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.mjs +730 -148
- package/package.json +2 -2
- package/skill/emvb-page-builder/SKILL.md +3 -0
package/dist/cli.mjs
CHANGED
|
@@ -3132,6 +3132,9 @@ function handlePipeResult(left, next, ctx) {
|
|
|
3132
3132
|
}
|
|
3133
3133
|
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
3134
3134
|
}
|
|
3135
|
+
var $ZodPreprocess = /* @__PURE__ */ $constructor("$ZodPreprocess", (inst, def) => {
|
|
3136
|
+
$ZodPipe.init(inst, def);
|
|
3137
|
+
});
|
|
3135
3138
|
var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
3136
3139
|
$ZodType.init(inst, def);
|
|
3137
3140
|
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
@@ -6198,6 +6201,10 @@ function pipe(in_, out) {
|
|
|
6198
6201
|
out
|
|
6199
6202
|
});
|
|
6200
6203
|
}
|
|
6204
|
+
var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
|
|
6205
|
+
ZodPipe.init(inst, def);
|
|
6206
|
+
$ZodPreprocess.init(inst, def);
|
|
6207
|
+
});
|
|
6201
6208
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
6202
6209
|
$ZodReadonly.init(inst, def);
|
|
6203
6210
|
ZodType.init(inst, def);
|
|
@@ -6233,6 +6240,13 @@ function refine(fn, _params = {}) {
|
|
|
6233
6240
|
function superRefine(fn, params) {
|
|
6234
6241
|
return _superRefine(fn, params);
|
|
6235
6242
|
}
|
|
6243
|
+
function preprocess(fn, schema) {
|
|
6244
|
+
return new ZodPreprocess({
|
|
6245
|
+
type: "pipe",
|
|
6246
|
+
in: transform(fn),
|
|
6247
|
+
out: schema
|
|
6248
|
+
});
|
|
6249
|
+
}
|
|
6236
6250
|
// ../../node_modules/.bun/zod@4.5.4/node_modules/zod/v4/classic/iso.js
|
|
6237
6251
|
function datetime2(params) {
|
|
6238
6252
|
return _isoDateTime(ZodISODateTime, params);
|
|
@@ -6247,7 +6261,7 @@ function duration2(params) {
|
|
|
6247
6261
|
return _isoDuration(ZodISODuration, params);
|
|
6248
6262
|
}
|
|
6249
6263
|
// ../../docs/system/layout-format.md
|
|
6250
|
-
var layout_format_default = "# Layout format (schema 16)\n\nHow EmVB stores a page and its site-wide design, at schema 16 (the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 16,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `16` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`) | none | `<p>` or `<div>` |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered` | none | `<ul>` or `<ol>` with `<li>` |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound) | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `text-input` | `field`, optional `label`, `placeholder` | none | labelled `<input class=\"ec-form-input\">` + `data-error-for` |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\") | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `itemPartId`; `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `section` (shown as \"Theme section\") | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `label` (1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000).\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }` | a colour layer above the image. Hex becomes 8-digit hex; a colour variable becomes `color-mix` |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`. No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`. For example `opacity 200ms ease-out 50ms` |\n| `entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `scrollMotion` (W-319, Normal only) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `iconAnimation` (W-237, Normal only) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear infinite`, `emvb-icon-pulse <ms> ease-in-out infinite alternate` or `none`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `transition`, `entrance`, `iconAnimation` and `scrollMotion`, which belong to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `transition` inside a state is dropped and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"tablet\"?, \"mobile\"? }`. Each is a style object with the same keys as `style`. Only keys that differ from desktop are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Tablet is `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A phone matches both, so mobile wins on a shared key, and a tablet-only key still applies on mobile. The bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1025px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 15,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no `data-emvb-*` attributes and no scripts.\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n";
|
|
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";
|
|
6251
6265
|
|
|
6252
6266
|
// skill/emvb-page-builder/SKILL.md
|
|
6253
6267
|
var SKILL_default = `---
|
|
@@ -6309,6 +6323,9 @@ instructions.
|
|
|
6309
6323
|
replace those references first. Pass \`force: true\` only if the person asked.
|
|
6310
6324
|
- An image \`src\` must be an http(s) URL or a path on the site; \`javascript:\`, \`data:\` and
|
|
6311
6325
|
\`//host\` sources are refused.
|
|
6326
|
+
- \`REFUSED\` on a link or an SVG: the page would drop it (a \`javascript:\` link, \`onload\` or a
|
|
6327
|
+
script in SVG markup); the message gives the reason. A class or variable name another one
|
|
6328
|
+
already has is refused too. A write that changes nothing saves no new version.
|
|
6312
6329
|
- \`PUBLISH_DISABLED\`: leave the draft for review.
|
|
6313
6330
|
- \`FORBIDDEN\`: agent access is off on the site, or the token can't use EmVB; tell the person.
|
|
6314
6331
|
- \`NOT_SET_UP\`: an admin must click "Set up EmVB" in the EmDash admin first; tell the person.
|
|
@@ -6405,6 +6422,15 @@ var MAX_TABS = 12;
|
|
|
6405
6422
|
function clipText(text, max) {
|
|
6406
6423
|
if (text.length <= max)
|
|
6407
6424
|
return text;
|
|
6425
|
+
if (typeof Intl !== "undefined" && "Segmenter" in Intl) {
|
|
6426
|
+
let end = 0;
|
|
6427
|
+
for (const { segment } of new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text.slice(0, max + 32))) {
|
|
6428
|
+
if (end + segment.length > max)
|
|
6429
|
+
break;
|
|
6430
|
+
end += segment.length;
|
|
6431
|
+
}
|
|
6432
|
+
return text.slice(0, end);
|
|
6433
|
+
}
|
|
6408
6434
|
const code = text.charCodeAt(max - 1);
|
|
6409
6435
|
return text.slice(0, code >= 55296 && code <= 56319 ? max - 1 : max);
|
|
6410
6436
|
}
|
|
@@ -6459,7 +6485,15 @@ var Geometry = strictObject({
|
|
|
6459
6485
|
aspectRatio: number2().finite().min(0.01).max(100).nullable()
|
|
6460
6486
|
}).partial();
|
|
6461
6487
|
var FilterLabel = string2().regex(/^[A-Za-z0-9 _-]{1,32}$/, "Filter names are short words");
|
|
6462
|
-
|
|
6488
|
+
function hasUnsafeUrlChar(s) {
|
|
6489
|
+
for (const ch of s) {
|
|
6490
|
+
const code = ch.charCodeAt(0);
|
|
6491
|
+
if (ch === "\\" || code < 32 || code === 127)
|
|
6492
|
+
return true;
|
|
6493
|
+
}
|
|
6494
|
+
return false;
|
|
6495
|
+
}
|
|
6496
|
+
var BlendSrc = string2().max(2000).refine((s) => !hasUnsafeUrlChar(s) && (/^\/(?!\/)/.test(s) || /^https:\/\//i.test(s)), "Blend images must be a site path or an https URL");
|
|
6463
6497
|
var ImageEditRecipe = strictObject({
|
|
6464
6498
|
version: literal(1),
|
|
6465
6499
|
name: string2().max(80).optional(),
|
|
@@ -6575,7 +6609,7 @@ function sanitizeUrl(value, schemes) {
|
|
|
6575
6609
|
return;
|
|
6576
6610
|
if (/[^\S ]|\\/.test(trimmed))
|
|
6577
6611
|
return;
|
|
6578
|
-
if (/^(?:[/?#.]|[
|
|
6612
|
+
if (/^(?:[/?#.]|[\p{L}\p{N}._~-])/u.test(trimmed))
|
|
6579
6613
|
return trimmed;
|
|
6580
6614
|
return;
|
|
6581
6615
|
}
|
|
@@ -7090,7 +7124,8 @@ var SHORTHANDS = new Set(["borderWidth", "borderRadius"]);
|
|
|
7090
7124
|
var TRIGGER_LIMITS = {
|
|
7091
7125
|
maxDelayMs: 120000,
|
|
7092
7126
|
maxScrollPercent: 100,
|
|
7093
|
-
minIdleMs: 1000
|
|
7127
|
+
minIdleMs: 1000,
|
|
7128
|
+
maxClickSelectorLength: 200
|
|
7094
7129
|
};
|
|
7095
7130
|
var POPUP_DEVICES = ["desktop", "tablet", "mobile"];
|
|
7096
7131
|
|
|
@@ -7338,9 +7373,9 @@ var Variant = strictObject({
|
|
|
7338
7373
|
});
|
|
7339
7374
|
var AUDIENCE_DEVICES = ["mobile", "tablet", "desktop"];
|
|
7340
7375
|
var AUDIENCE_SEGMENT = /^[a-z0-9][a-z0-9:_-]{0,63}$/;
|
|
7341
|
-
var SEGMENT_HINT = "Segments are lowercase letters, digits, :, - or _,
|
|
7376
|
+
var SEGMENT_HINT = "Segments are lowercase letters, digits, :, - or _, such as plan:pro";
|
|
7342
7377
|
var Audience = strictObject({
|
|
7343
|
-
countries: array(string2().regex(/^[A-Z]{2}$/, "Two-letter country codes,
|
|
7378
|
+
countries: array(string2().regex(/^[A-Z]{2}$/, "Two-letter country codes, such as CA")).min(1).max(50).optional(),
|
|
7344
7379
|
devices: array(_enum(AUDIENCE_DEVICES)).min(1).max(3).optional(),
|
|
7345
7380
|
visitor: _enum(["new", "returning"]).optional(),
|
|
7346
7381
|
hours: strictObject({ from: number2().int().min(0).max(23), to: number2().int().min(0).max(24) }).optional(),
|
|
@@ -7559,19 +7594,19 @@ var PostLinkNode = leafNode("post-link", strictObject({
|
|
|
7559
7594
|
}));
|
|
7560
7595
|
var LOOP_DISPLAYS = ["list", "grid", "cards"];
|
|
7561
7596
|
var FIELD_SLUG = /^[a-z][a-z0-9_]{0,63}$/;
|
|
7562
|
-
var FIELD_SLUG_HINT = "Use the field's slug,
|
|
7597
|
+
var FIELD_SLUG_HINT = "Use the field's slug, such as photo";
|
|
7563
7598
|
var LOOP_PERMALINK = /^(?=.*\{(?:slug|id)\})\/(?!\/)(?:[A-Za-z0-9._~/-]|\{slug\}|\{id\})*$/;
|
|
7564
7599
|
var LOOP_FILTER = /^\s*[a-z][a-z0-9_]{0,63}\s*=\s*[^;=<>\s](?:[^;=<>]{0,98}[^;=<>\s])?(?:\s*;\s*[a-z][a-z0-9_]{0,63}\s*=\s*[^;=<>\s](?:[^;=<>]{0,98}[^;=<>\s])?)*\s*;?\s*$/;
|
|
7565
7600
|
var LOOP_ORDERS = ["newest", "oldest", "title"];
|
|
7566
7601
|
var LoopNode = parentNode("loop", strictObject({
|
|
7567
7602
|
itemPartId: string2().max(128).optional(),
|
|
7568
7603
|
perPage: number2().int().min(1).max(50).optional(),
|
|
7569
|
-
collection: string2().regex(/^[a-z][a-z0-9_]{0,63}$/, "Use the collection's slug,
|
|
7604
|
+
collection: string2().regex(/^[a-z][a-z0-9_]{0,63}$/, "Use the collection's slug, such as team").optional(),
|
|
7570
7605
|
limit: number2().int().min(1).max(50).optional(),
|
|
7571
7606
|
order: _enum(LOOP_ORDERS).optional(),
|
|
7572
7607
|
display: _enum(LOOP_DISPLAYS).optional(),
|
|
7573
7608
|
columns: number2().int().min(1).max(6).optional(),
|
|
7574
|
-
permalink: string2().max(200).regex(LOOP_PERMALINK, "A site path with {slug} or {id},
|
|
7609
|
+
permalink: string2().max(200).regex(LOOP_PERMALINK, "A site path with {slug} or {id}, such as /team/{slug}").optional(),
|
|
7575
7610
|
imageField: string2().regex(FIELD_SLUG, FIELD_SLUG_HINT).optional(),
|
|
7576
7611
|
excerptField: string2().regex(FIELD_SLUG, FIELD_SLUG_HINT).optional(),
|
|
7577
7612
|
filter: string2().max(300).regex(LOOP_FILTER, "Use field=value pairs separated by ;").optional()
|
|
@@ -7582,7 +7617,12 @@ var PaginationNode = leafNode("pagination", strictObject({
|
|
|
7582
7617
|
nextText: string2().max(40).optional(),
|
|
7583
7618
|
showCount: boolean2().optional(),
|
|
7584
7619
|
countText: string2().max(60).optional(),
|
|
7585
|
-
titleText: string2().max(60).optional()
|
|
7620
|
+
titleText: string2().max(60).optional(),
|
|
7621
|
+
archiveTitle: string2().max(60).optional(),
|
|
7622
|
+
navLabel: string2().max(60).optional(),
|
|
7623
|
+
pageLabel: string2().max(60).optional(),
|
|
7624
|
+
prevLabel: string2().max(60).optional(),
|
|
7625
|
+
nextLabel: string2().max(60).optional()
|
|
7586
7626
|
}));
|
|
7587
7627
|
var SectionNode = parentNode("section", strictObject({
|
|
7588
7628
|
partId: string2().max(128).optional()
|
|
@@ -8053,6 +8093,44 @@ function parseSvg(raw) {
|
|
|
8053
8093
|
return;
|
|
8054
8094
|
return build(tokens);
|
|
8055
8095
|
}
|
|
8096
|
+
function isSafeSvgMarkup(raw) {
|
|
8097
|
+
return sanitizeSvgMarkup(raw) !== undefined;
|
|
8098
|
+
}
|
|
8099
|
+
|
|
8100
|
+
// ../emvb/src/core/elements/svg-ids.ts
|
|
8101
|
+
var URL_REF = /url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/g;
|
|
8102
|
+
var ID_LIST_ATTRS = new Set(["aria-labelledby", "aria-describedby"]);
|
|
8103
|
+
function scopeSvgIds(children, prefix) {
|
|
8104
|
+
const ids = new Set;
|
|
8105
|
+
const collect = (node) => {
|
|
8106
|
+
if (typeof node === "string")
|
|
8107
|
+
return;
|
|
8108
|
+
if (node.attrs.id)
|
|
8109
|
+
ids.add(node.attrs.id);
|
|
8110
|
+
node.children.forEach(collect);
|
|
8111
|
+
};
|
|
8112
|
+
children.forEach(collect);
|
|
8113
|
+
if (ids.size === 0)
|
|
8114
|
+
return children;
|
|
8115
|
+
const scoped = (id) => ids.has(id) ? `${prefix}-${id}` : id;
|
|
8116
|
+
const rewrite = (node) => {
|
|
8117
|
+
if (typeof node === "string")
|
|
8118
|
+
return node;
|
|
8119
|
+
const attrs = {};
|
|
8120
|
+
for (const [name, value] of Object.entries(node.attrs)) {
|
|
8121
|
+
if (name === "id")
|
|
8122
|
+
attrs[name] = scoped(value);
|
|
8123
|
+
else if ((name === "href" || name === "xlink:href") && value.startsWith("#"))
|
|
8124
|
+
attrs[name] = `#${scoped(value.slice(1))}`;
|
|
8125
|
+
else if (ID_LIST_ATTRS.has(name))
|
|
8126
|
+
attrs[name] = value.split(/\s+/).map(scoped).join(" ");
|
|
8127
|
+
else
|
|
8128
|
+
attrs[name] = value.replace(URL_REF, (_m, q, id) => `url(${q}#${scoped(id)}${q})`);
|
|
8129
|
+
}
|
|
8130
|
+
return { ...node, attrs, children: node.children.map(rewrite) };
|
|
8131
|
+
};
|
|
8132
|
+
return children.map(rewrite);
|
|
8133
|
+
}
|
|
8056
8134
|
|
|
8057
8135
|
// ../emvb/src/core/icons/catalog.ts
|
|
8058
8136
|
var BUNDLED_ICONS = [
|
|
@@ -8105,8 +8183,8 @@ var BUNDLED_ICONS = [
|
|
|
8105
8183
|
label: "Circle Alert",
|
|
8106
8184
|
children: [
|
|
8107
8185
|
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "10" } },
|
|
8108
|
-
{ tag: "line", attrs: {} },
|
|
8109
|
-
{ tag: "line", attrs: {} }
|
|
8186
|
+
{ tag: "line", attrs: { x1: "12", x2: "12", y1: "8", y2: "12" } },
|
|
8187
|
+
{ tag: "line", attrs: { x1: "12", x2: "12.01", y1: "16", y2: "16" } }
|
|
8110
8188
|
]
|
|
8111
8189
|
},
|
|
8112
8190
|
{
|
|
@@ -8317,6 +8395,7 @@ var YT_HOSTS = new Set([
|
|
|
8317
8395
|
"youtube.com",
|
|
8318
8396
|
"www.youtube.com",
|
|
8319
8397
|
"m.youtube.com",
|
|
8398
|
+
"music.youtube.com",
|
|
8320
8399
|
"youtu.be",
|
|
8321
8400
|
"www.youtu.be",
|
|
8322
8401
|
"youtube-nocookie.com",
|
|
@@ -8327,9 +8406,20 @@ var matching = (id, pattern) => id && pattern.test(id) ? id : undefined;
|
|
|
8327
8406
|
var YT_ID = /^[\w-]{6,}$/;
|
|
8328
8407
|
var VIMEO_ID = /^\d{6,}$/;
|
|
8329
8408
|
var firstSegment = (path) => path.split("/").find(Boolean);
|
|
8409
|
+
var YT_LIST = /^[\w-]{10,64}$/;
|
|
8410
|
+
function youtubePlaylist(parsed) {
|
|
8411
|
+
const path = parsed.pathname.replace(/\/+$/, "");
|
|
8412
|
+
if (path !== "/embed/videoseries" && path !== "/playlist")
|
|
8413
|
+
return null;
|
|
8414
|
+
const list = matching(parsed.searchParams.get("list") ?? undefined, YT_LIST);
|
|
8415
|
+
return list ? `videoseries?list=${list}` : undefined;
|
|
8416
|
+
}
|
|
8330
8417
|
function youtubeId(parsed) {
|
|
8331
8418
|
const host = parsed.hostname.toLowerCase();
|
|
8332
8419
|
const path = parsed.pathname;
|
|
8420
|
+
const playlist = youtubePlaylist(parsed);
|
|
8421
|
+
if (playlist !== null)
|
|
8422
|
+
return playlist;
|
|
8333
8423
|
if (host === "youtu.be" || host === "www.youtu.be")
|
|
8334
8424
|
return matching(firstSegment(path), YT_ID);
|
|
8335
8425
|
for (const prefix of ["/embed/", "/shorts/", "/live/"]) {
|
|
@@ -8343,7 +8433,7 @@ function vimeoId(parsed) {
|
|
|
8343
8433
|
const parts = parsed.pathname.split("/").filter(Boolean);
|
|
8344
8434
|
const player = parsed.hostname.toLowerCase() === "player.vimeo.com";
|
|
8345
8435
|
const videoIdx = parts.indexOf("video");
|
|
8346
|
-
const at = player ? videoIdx >= 0 ? videoIdx + 1 : 0 : parts[0] === "channels" ? 2 : parts[0] === "groups" && parts[2] === "videos" ? 3 : 0;
|
|
8436
|
+
const at = player ? videoIdx >= 0 ? videoIdx + 1 : 0 : parts[0] === "channels" ? 2 : parts[0] === "groups" && parts[2] === "videos" || parts[0] === "showcase" && parts[2] === "video" ? 3 : 0;
|
|
8347
8437
|
const id = matching(parts[at], VIMEO_ID);
|
|
8348
8438
|
if (!id)
|
|
8349
8439
|
return;
|
|
@@ -8363,7 +8453,7 @@ function startOf(parsed) {
|
|
|
8363
8453
|
const fragment = new URLSearchParams(parsed.hash.replace(/^#/, ""));
|
|
8364
8454
|
return parseStartSeconds(parsed.searchParams.get("t") ?? parsed.searchParams.get("start") ?? fragment.get("t"));
|
|
8365
8455
|
}
|
|
8366
|
-
var withStart = (provider, src, start) => start === undefined ? src : provider === "youtube" ? `${src}?start=${start}` : `${src}#t=${start}s`;
|
|
8456
|
+
var withStart = (provider, src, start) => start === undefined ? src : provider === "youtube" ? `${src}${src.includes("?") ? "&" : "?"}start=${start}` : `${src}#t=${start}s`;
|
|
8367
8457
|
var PROVIDERS = [
|
|
8368
8458
|
{
|
|
8369
8459
|
provider: "youtube",
|
|
@@ -8373,14 +8463,28 @@ var PROVIDERS = [
|
|
|
8373
8463
|
},
|
|
8374
8464
|
{ provider: "vimeo", hosts: VIMEO_HOSTS, id: vimeoId, embed: "https://player.vimeo.com/video/" }
|
|
8375
8465
|
];
|
|
8376
|
-
|
|
8466
|
+
function bareVideoHost(typed) {
|
|
8467
|
+
const slash = typed.indexOf("/");
|
|
8468
|
+
if (slash <= 0)
|
|
8469
|
+
return false;
|
|
8470
|
+
const host = typed.slice(0, slash).toLowerCase();
|
|
8471
|
+
return YT_HOSTS.has(host) || VIMEO_HOSTS.has(host);
|
|
8472
|
+
}
|
|
8473
|
+
function isVideoFilePath(value) {
|
|
8474
|
+
if (value.startsWith("//"))
|
|
8475
|
+
return false;
|
|
8476
|
+
const path = value.split(/[?#]/)[0] ?? "";
|
|
8477
|
+
return /\.(mp4|webm|ogg)$/i.test(path) || path.startsWith("/_emdash/api/media/file/");
|
|
8478
|
+
}
|
|
8377
8479
|
function resolveEmbedUrl(value) {
|
|
8378
8480
|
const typed = value.trim();
|
|
8379
|
-
const trimmed =
|
|
8481
|
+
const trimmed = bareVideoHost(typed) ? `https://${typed}` : typed;
|
|
8380
8482
|
if (trimmed.length === 0 || trimmed.length > 2000)
|
|
8381
8483
|
return;
|
|
8382
8484
|
const hasScheme = /^[a-z][a-z0-9+.-]*:/i.test(trimmed);
|
|
8383
8485
|
if (!hasScheme) {
|
|
8486
|
+
if (!isVideoFilePath(trimmed))
|
|
8487
|
+
return;
|
|
8384
8488
|
const media = sanitizeMediaUrl(trimmed);
|
|
8385
8489
|
if (!media)
|
|
8386
8490
|
return;
|
|
@@ -8437,7 +8541,7 @@ function stampGroup(children, name) {
|
|
|
8437
8541
|
};
|
|
8438
8542
|
});
|
|
8439
8543
|
}
|
|
8440
|
-
function groupItems(children) {
|
|
8544
|
+
function groupItems(children, listClass = "emvb-menu__list emvb-menu__list--sub") {
|
|
8441
8545
|
const out = [];
|
|
8442
8546
|
let batch = [];
|
|
8443
8547
|
const flush = () => {
|
|
@@ -8445,7 +8549,7 @@ function groupItems(children) {
|
|
|
8445
8549
|
return;
|
|
8446
8550
|
out.push({
|
|
8447
8551
|
tag: "ul",
|
|
8448
|
-
attrs: { class:
|
|
8552
|
+
attrs: { class: listClass },
|
|
8449
8553
|
children: batch
|
|
8450
8554
|
});
|
|
8451
8555
|
batch = [];
|
|
@@ -8473,11 +8577,15 @@ var MENU_CSS = [
|
|
|
8473
8577
|
".emvb-menu-item__toggle{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;cursor:pointer;list-style:none}",
|
|
8474
8578
|
".emvb-menu-item__toggle::-webkit-details-marker{display:none}",
|
|
8475
8579
|
".emvb-menu-item__toggle::before{content:'';width:.4rem;height:.4rem;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg) translateY(-1px)}",
|
|
8580
|
+
".emvb-menu-item__toggle--label{width:auto;gap:.6rem;padding-inline-end:.35rem}",
|
|
8581
|
+
".emvb-menu-item__toggle--label::before{order:1}",
|
|
8476
8582
|
".emvb-menu-panel{display:none;position:absolute;z-index:30;top:100%;inset-inline-start:0;min-width:12rem;padding:.75rem;background:canvas;color:canvastext;border:1px solid #00000014;box-shadow:0 12px 32px #00000029}",
|
|
8477
8583
|
".emvb-menu-item__disclosure[open]>.emvb-menu-panel{display:block}",
|
|
8478
|
-
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
|
|
8479
|
-
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
|
|
8584
|
+
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:not([data-emvb-menu-dismissed]):hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:not([data-emvb-menu-dismissed]):focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
|
|
8585
|
+
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:not([data-emvb-menu-dismissed]):hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
|
|
8480
8586
|
".emvb-menu-panel--wide{inset-inline:0;min-width:0}",
|
|
8587
|
+
".emvb-menu--column .emvb-menu-item{position:static}",
|
|
8588
|
+
".emvb-menu--column .emvb-menu-item__bar{position:relative;width:fit-content;max-width:100%}",
|
|
8481
8589
|
".emvb-menu--column .emvb-menu-panel{top:0;inset-inline-start:100%}",
|
|
8482
8590
|
".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}"
|
|
8483
8591
|
].join("");
|
|
@@ -8522,13 +8630,7 @@ var menu = {
|
|
|
8522
8630
|
return {
|
|
8523
8631
|
tag: "nav",
|
|
8524
8632
|
attrs: { ...attrs, class: classes, "aria-label": label },
|
|
8525
|
-
children:
|
|
8526
|
-
{
|
|
8527
|
-
tag: "ul",
|
|
8528
|
-
attrs: { class: "emvb-menu__list" },
|
|
8529
|
-
children: stampGroup(children, `emvb-menu-${node.id}`)
|
|
8530
|
-
}
|
|
8531
|
-
]
|
|
8633
|
+
children: groupItems(stampGroup(children, `emvb-menu-${node.id}`), "emvb-menu__list")
|
|
8532
8634
|
};
|
|
8533
8635
|
}
|
|
8534
8636
|
};
|
|
@@ -8541,11 +8643,11 @@ var menuItem = {
|
|
|
8541
8643
|
group: "content",
|
|
8542
8644
|
defaultTab: "content",
|
|
8543
8645
|
fields: [
|
|
8544
|
-
{ key: "text", kind: "text", label: "
|
|
8646
|
+
{ key: "text", kind: "text", label: "Text" },
|
|
8545
8647
|
{
|
|
8546
8648
|
key: "href",
|
|
8547
8649
|
kind: "href",
|
|
8548
|
-
label: "
|
|
8650
|
+
label: "URL",
|
|
8549
8651
|
optional: true,
|
|
8550
8652
|
message: "Use a full URL such as https://example.com or a path such as /pricing."
|
|
8551
8653
|
},
|
|
@@ -8562,14 +8664,19 @@ var menuItem = {
|
|
|
8562
8664
|
attrs: { class: "emvb-menu-item__link", href, ...newTabAttrs(node.props.newTab) },
|
|
8563
8665
|
children: [node.props.text]
|
|
8564
8666
|
} : { tag: "span", attrs: { class: "emvb-menu-item__label" }, children: [node.props.text] };
|
|
8565
|
-
const
|
|
8667
|
+
const textToggle = !href && children.length > 0;
|
|
8668
|
+
const bar = textToggle ? [] : [label];
|
|
8566
8669
|
if (children.length > 0) {
|
|
8567
8670
|
const panelClass = wide ? "emvb-menu-panel emvb-menu-panel--wide" : "emvb-menu-panel";
|
|
8568
8671
|
bar.push({
|
|
8569
8672
|
tag: "details",
|
|
8570
8673
|
attrs: { class: "emvb-menu-item__disclosure" },
|
|
8571
8674
|
children: [
|
|
8572
|
-
{
|
|
8675
|
+
textToggle ? {
|
|
8676
|
+
tag: "summary",
|
|
8677
|
+
attrs: { class: "emvb-menu-item__toggle emvb-menu-item__toggle--label" },
|
|
8678
|
+
children: [node.props.text]
|
|
8679
|
+
} : {
|
|
8573
8680
|
tag: "summary",
|
|
8574
8681
|
attrs: { class: "emvb-menu-item__toggle", "aria-label": `Open ${node.props.text}` },
|
|
8575
8682
|
children: []
|
|
@@ -8590,6 +8697,9 @@ var menuItem = {
|
|
|
8590
8697
|
}
|
|
8591
8698
|
};
|
|
8592
8699
|
|
|
8700
|
+
// ../emvb/src/core/elements/select-prompt.ts
|
|
8701
|
+
var selectPrompt = (props) => props.placeholder?.trim() || "Choose…";
|
|
8702
|
+
|
|
8593
8703
|
// ../emvb/src/core/elements/field-id.ts
|
|
8594
8704
|
var controlId = (nodeId) => `emvb-field-${nodeId}`;
|
|
8595
8705
|
|
|
@@ -8603,9 +8713,9 @@ var TEXT_FIELDS = [
|
|
|
8603
8713
|
...NAME_AND_LABEL,
|
|
8604
8714
|
{ key: "placeholder", kind: "text", label: "Placeholder", optional: true }
|
|
8605
8715
|
];
|
|
8606
|
-
var FORM_FIELD_CSS = ":where(.emvb-form .emvb-form-label){font-weight:600}" + ":where(.emvb-form .ec-form-input){box-sizing:border-box;width:100%;max-width:100%;margin:0;padding:.625em .75em;font:inherit;color:inherit;background-color:transparent;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 30%,transparent);border-radius:6px}" + ":where(.emvb-form textarea.ec-form-input){min-height:7.5em;resize:vertical}" + ":where(.emvb-form .ec-form-input)::placeholder{color:inherit;opacity:.55}" + ":where(.emvb-form .ec-form-input:focus-visible){outline:2px solid currentColor;outline-offset:1px;border-color:currentColor}" + ':where(.emvb-form .ec-form-input[aria-invalid="true"]){border-color:#b3261e}' + ':where(.emvb-form input[type="checkbox"],.emvb-form input[type="radio"]){width:1.1em;height:1.1em;margin:0;accent-color:currentColor}' + ":where(.emvb-form .emvb-form-checkbox-label,.emvb-form .emvb-form-radio-label){display:inline-flex;align-items:center;gap:.5em}" + ":where(.emvb-form .emvb-radio-group){display:flex;flex-direction:column;gap:6px;margin:0;padding:0;border:0;min-width:0}" + ":where(.emvb-form .emvb-radio-group>legend){float:left;width:100%;margin:0 0 -2px;padding:0}" + ":where(.emvb-form .ec-form-error){font-size:.875em;color:#b3261e}";
|
|
8716
|
+
var FORM_FIELD_CSS = ":where(.emvb-form .emvb-form-label){font-weight:600}" + ":where(.emvb-form .ec-form-input){box-sizing:border-box;width:100%;max-width:100%;margin:0;padding:.625em .75em;font:inherit;color:inherit;background-color:transparent;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 30%,transparent);border-radius:6px}" + ":where(.emvb-form textarea.ec-form-input){min-height:7.5em;resize:vertical}" + ":where(.emvb-form .ec-form-input)::placeholder{color:inherit;opacity:.55}" + ":where(.emvb-form .ec-form-input:focus-visible){outline:2px solid currentColor;outline-offset:1px;border-color:currentColor}" + ':where(.emvb-form .ec-form-input[aria-invalid="true"]){border-color:#b3261e}' + ':where(.emvb-form input[type="checkbox"],.emvb-form input[type="radio"]){width:1.1em;height:1.1em;margin:0;accent-color:currentColor}' + ":where(.emvb-form .emvb-form-checkbox-label,.emvb-form .emvb-form-radio-label){display:inline-flex;align-items:center;gap:.5em;overflow-wrap:anywhere}" + ":where(.emvb-form .emvb-radio-group){display:flex;flex-direction:column;gap:6px;margin:0;padding:0;border:0;min-width:0}" + ":where(.emvb-form .emvb-radio-group>legend){float:left;width:100%;margin:0 0 -2px;padding:0}" + ":where(.emvb-form .ec-form-error){font-size:.875em;color:#b3261e}";
|
|
8607
8717
|
var form = {
|
|
8608
|
-
baseCss: ".emvb-form{display:flex;flex-direction:column;gap:12px;min-width:0}.emvb-form-unbound{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}.ec-form-hp{position:absolute;
|
|
8718
|
+
baseCss: ".emvb-form{display:flex;flex-direction:column;gap:12px;min-width:0}.emvb-form-unbound{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}.emvb-form-field[hidden]{display:none!important}.ec-form-hp{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}" + ":where(.emvb-form-paused){padding:12px 16px;border:1px solid rgba(128,128,128,.5);border:1px solid color-mix(in srgb,currentColor 25%,transparent);border-radius:6px}:where(.emvb-form-paused p){margin:0}" + FORM_FIELD_CSS,
|
|
8609
8719
|
defaults: () => ({ type: "form", props: { formId: "" }, children: [] }),
|
|
8610
8720
|
descriptor: fieldDescriptor("form", "Form", [
|
|
8611
8721
|
{ key: "formId", kind: "text", label: "Form id", message: "Paste a forms-plugin form id." }
|
|
@@ -8616,27 +8726,39 @@ var form = {
|
|
|
8616
8726
|
children
|
|
8617
8727
|
})
|
|
8618
8728
|
};
|
|
8619
|
-
var errorSlot = (name) => ({
|
|
8729
|
+
var errorSlot = (name, controlFor) => ({
|
|
8620
8730
|
tag: "span",
|
|
8621
|
-
attrs: {
|
|
8731
|
+
attrs: {
|
|
8732
|
+
class: "ec-form-error",
|
|
8733
|
+
id: errorId(controlFor),
|
|
8734
|
+
"data-error-for": name,
|
|
8735
|
+
"aria-live": "polite"
|
|
8736
|
+
},
|
|
8622
8737
|
children: []
|
|
8623
8738
|
});
|
|
8739
|
+
var errorId = (controlFor) => `${controlFor}-error`;
|
|
8740
|
+
var describedBy = (controlFor) => ({ "aria-describedby": errorId(controlFor) });
|
|
8624
8741
|
var fieldBox = (attrs, children) => ({
|
|
8625
8742
|
tag: "div",
|
|
8626
8743
|
attrs: { ...attrs, class: `${attrs.class ?? ""} emvb-form-field`.trim() },
|
|
8627
8744
|
children
|
|
8628
8745
|
});
|
|
8629
8746
|
var fieldWrap = (controlFor, name, labelText, control, attrs) => fieldBox(attrs, [
|
|
8630
|
-
...labelText ? [
|
|
8747
|
+
...labelText?.trim() ? [
|
|
8631
8748
|
{
|
|
8632
8749
|
tag: "label",
|
|
8633
8750
|
attrs: { class: "emvb-form-label", for: controlFor },
|
|
8634
8751
|
children: [labelText]
|
|
8635
8752
|
}
|
|
8636
8753
|
] : [],
|
|
8637
|
-
control,
|
|
8638
|
-
errorSlot(name)
|
|
8754
|
+
withDescription(labelText?.trim() ? control : named(control, name), controlFor),
|
|
8755
|
+
errorSlot(name, controlFor)
|
|
8639
8756
|
]);
|
|
8757
|
+
var withDescription = (control, controlFor) => ({
|
|
8758
|
+
...control,
|
|
8759
|
+
attrs: { ...control.attrs, ...describedBy(controlFor) }
|
|
8760
|
+
});
|
|
8761
|
+
var named = (control, name) => control.attrs.placeholder?.trim() || !name.trim() ? control : { ...control, attrs: { ...control.attrs, "aria-label": name } };
|
|
8640
8762
|
var textControl = (tag, props, id) => ({
|
|
8641
8763
|
tag,
|
|
8642
8764
|
attrs: {
|
|
@@ -8663,13 +8785,13 @@ var textareaEl = {
|
|
|
8663
8785
|
var selectEl = {
|
|
8664
8786
|
baseCss: ".emvb-select{display:flex;flex-direction:column;gap:4px}",
|
|
8665
8787
|
defaults: () => ({ type: "select", props: { field: "choice", label: "Choice" } }),
|
|
8666
|
-
descriptor: fieldDescriptor("select", "Select",
|
|
8788
|
+
descriptor: fieldDescriptor("select", "Select", TEXT_FIELDS),
|
|
8667
8789
|
build: (node, attrs) => {
|
|
8668
8790
|
const name = node.props.field;
|
|
8669
8791
|
const control = {
|
|
8670
8792
|
tag: "select",
|
|
8671
8793
|
attrs: { class: "ec-form-input", id: controlId(node.id), name },
|
|
8672
|
-
children: [{ tag: "option", attrs: { value: "" }, children: [
|
|
8794
|
+
children: [{ tag: "option", attrs: { value: "" }, children: [selectPrompt(node.props)] }]
|
|
8673
8795
|
};
|
|
8674
8796
|
return fieldWrap(controlId(node.id), name, node.props.label, control, attrs);
|
|
8675
8797
|
}
|
|
@@ -8682,15 +8804,21 @@ var checkbox = {
|
|
|
8682
8804
|
const name = node.props.field;
|
|
8683
8805
|
const input = {
|
|
8684
8806
|
tag: "input",
|
|
8685
|
-
attrs: {
|
|
8807
|
+
attrs: {
|
|
8808
|
+
type: "checkbox",
|
|
8809
|
+
id: controlId(node.id),
|
|
8810
|
+
name,
|
|
8811
|
+
value: "true",
|
|
8812
|
+
...describedBy(controlId(node.id))
|
|
8813
|
+
},
|
|
8686
8814
|
children: []
|
|
8687
8815
|
};
|
|
8688
8816
|
const labelEl = {
|
|
8689
8817
|
tag: "label",
|
|
8690
8818
|
attrs: { class: "emvb-form-checkbox-label" },
|
|
8691
|
-
children: [input, ` ${node.props.label
|
|
8819
|
+
children: [input, ` ${node.props.label?.trim() || name}`]
|
|
8692
8820
|
};
|
|
8693
|
-
return fieldBox(attrs, [labelEl, errorSlot(name)]);
|
|
8821
|
+
return fieldBox(attrs, [labelEl, errorSlot(name, controlId(node.id))]);
|
|
8694
8822
|
}
|
|
8695
8823
|
};
|
|
8696
8824
|
var radio = {
|
|
@@ -8700,7 +8828,7 @@ var radio = {
|
|
|
8700
8828
|
build: (node, attrs) => {
|
|
8701
8829
|
const name = node.props.field;
|
|
8702
8830
|
const id = controlId(node.id);
|
|
8703
|
-
const legend = node.props.label ? [
|
|
8831
|
+
const legend = node.props.label?.trim() ? [
|
|
8704
8832
|
{
|
|
8705
8833
|
tag: "legend",
|
|
8706
8834
|
attrs: { class: "emvb-form-label", id: `${id}-label` },
|
|
@@ -8709,7 +8837,11 @@ var radio = {
|
|
|
8709
8837
|
] : [];
|
|
8710
8838
|
const control = {
|
|
8711
8839
|
tag: "fieldset",
|
|
8712
|
-
attrs: {
|
|
8840
|
+
attrs: {
|
|
8841
|
+
class: "emvb-radio-group",
|
|
8842
|
+
...describedBy(id),
|
|
8843
|
+
...legend.length || !name.trim() ? {} : { "aria-label": name }
|
|
8844
|
+
},
|
|
8713
8845
|
children: [
|
|
8714
8846
|
...legend,
|
|
8715
8847
|
{
|
|
@@ -8722,11 +8854,11 @@ var radio = {
|
|
|
8722
8854
|
}
|
|
8723
8855
|
]
|
|
8724
8856
|
};
|
|
8725
|
-
return fieldBox(attrs, [control, errorSlot(name)]);
|
|
8857
|
+
return fieldBox(attrs, [control, errorSlot(name, id)]);
|
|
8726
8858
|
}
|
|
8727
8859
|
};
|
|
8728
8860
|
var submit = {
|
|
8729
|
-
baseCss: ".emvb-submit{display:inline-flex}",
|
|
8861
|
+
baseCss: ".emvb-submit{display:inline-flex;max-width:100%;overflow-wrap:anywhere}",
|
|
8730
8862
|
defaults: () => ({ type: "submit", props: { label: "Submit" } }),
|
|
8731
8863
|
descriptor: fieldDescriptor("submit", "Submit", [
|
|
8732
8864
|
{ key: "label", kind: "text", label: "Label", optional: true }
|
|
@@ -8869,7 +9001,7 @@ var postLink = {
|
|
|
8869
9001
|
optional: true,
|
|
8870
9002
|
message: "Leave blank to use the post title."
|
|
8871
9003
|
},
|
|
8872
|
-
{ key: "newTab", kind: "boolean", label: "Open in new tab", optional: true }
|
|
9004
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true }
|
|
8873
9005
|
]
|
|
8874
9006
|
},
|
|
8875
9007
|
build: (_node, attrs) => ({ tag: "a", attrs: { ...attrs, href: "#" }, children: ["Post link"] })
|
|
@@ -8934,28 +9066,28 @@ var loop = {
|
|
|
8934
9066
|
kind: "text",
|
|
8935
9067
|
label: "Link pattern",
|
|
8936
9068
|
optional: true,
|
|
8937
|
-
message: "Where each entry links,
|
|
9069
|
+
message: "Where each entry links, such as /team/{slug}; {slug} and {id} are filled in. Leave it empty for /collection/{slug}."
|
|
8938
9070
|
},
|
|
8939
9071
|
{
|
|
8940
9072
|
key: "imageField",
|
|
8941
9073
|
kind: "text",
|
|
8942
9074
|
label: "Image field",
|
|
8943
9075
|
optional: true,
|
|
8944
|
-
message: "The field Post Image shows,
|
|
9076
|
+
message: "The field Post Image shows, such as photo. Leave it empty for the featured image."
|
|
8945
9077
|
},
|
|
8946
9078
|
{
|
|
8947
9079
|
key: "excerptField",
|
|
8948
9080
|
kind: "text",
|
|
8949
9081
|
label: "Excerpt field",
|
|
8950
9082
|
optional: true,
|
|
8951
|
-
message: "The field Post Excerpt shows,
|
|
9083
|
+
message: "The field Post Excerpt shows, such as role. Leave it empty for the excerpt."
|
|
8952
9084
|
},
|
|
8953
9085
|
{
|
|
8954
9086
|
key: "filter",
|
|
8955
9087
|
kind: "text",
|
|
8956
9088
|
label: "Only entries where",
|
|
8957
9089
|
optional: true,
|
|
8958
|
-
message: "field=value pairs separated by
|
|
9090
|
+
message: "field=value pairs separated by semicolons, such as category=news; team=design. A taxonomy works too. The same field twice matches either value."
|
|
8959
9091
|
},
|
|
8960
9092
|
{
|
|
8961
9093
|
key: "itemPartId",
|
|
@@ -9021,6 +9153,41 @@ var pagination = {
|
|
|
9021
9153
|
label: "Page title text",
|
|
9022
9154
|
optional: true,
|
|
9023
9155
|
message: 'The browser title of page 2 onward. {title} and {page} are filled in; unset is "{title} – page {page}".'
|
|
9156
|
+
},
|
|
9157
|
+
{
|
|
9158
|
+
key: "archiveTitle",
|
|
9159
|
+
kind: "text",
|
|
9160
|
+
label: "Posts archive title",
|
|
9161
|
+
optional: true,
|
|
9162
|
+
message: `Replaces "Posts" as the posts archive's title, in the site's language. Category and tag archives use the term's name.`
|
|
9163
|
+
},
|
|
9164
|
+
{
|
|
9165
|
+
key: "navLabel",
|
|
9166
|
+
kind: "text",
|
|
9167
|
+
label: "Screen reader name",
|
|
9168
|
+
optional: true,
|
|
9169
|
+
message: `What screen readers call the links, in the site's language. Unset is "Pagination".`
|
|
9170
|
+
},
|
|
9171
|
+
{
|
|
9172
|
+
key: "pageLabel",
|
|
9173
|
+
kind: "text",
|
|
9174
|
+
label: "Page number name",
|
|
9175
|
+
optional: true,
|
|
9176
|
+
message: 'What screen readers call each number. {page} is filled in; unset is "Page {page}".'
|
|
9177
|
+
},
|
|
9178
|
+
{
|
|
9179
|
+
key: "prevLabel",
|
|
9180
|
+
kind: "text",
|
|
9181
|
+
label: "Previous name",
|
|
9182
|
+
optional: true,
|
|
9183
|
+
message: 'Read out when Previous text is only an arrow. Unset is "Previous page".'
|
|
9184
|
+
},
|
|
9185
|
+
{
|
|
9186
|
+
key: "nextLabel",
|
|
9187
|
+
kind: "text",
|
|
9188
|
+
label: "Next name",
|
|
9189
|
+
optional: true,
|
|
9190
|
+
message: 'Read out when Next text is only an arrow. Unset is "Next page".'
|
|
9024
9191
|
}
|
|
9025
9192
|
]
|
|
9026
9193
|
},
|
|
@@ -9050,6 +9217,17 @@ var section = {
|
|
|
9050
9217
|
// ../emvb/src/core/elements/index.ts
|
|
9051
9218
|
var HEADING_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
9052
9219
|
var newTabAttrs2 = (newTab) => newTab ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
9220
|
+
var TAG_LABELS = {
|
|
9221
|
+
div: "Div",
|
|
9222
|
+
section: "Section",
|
|
9223
|
+
header: "Header",
|
|
9224
|
+
footer: "Footer",
|
|
9225
|
+
main: "Main",
|
|
9226
|
+
article: "Article",
|
|
9227
|
+
aside: "Aside",
|
|
9228
|
+
nav: "Nav",
|
|
9229
|
+
p: "Paragraph (p)"
|
|
9230
|
+
};
|
|
9053
9231
|
var LINK_MESSAGE = "Use a full URL such as https://example.com or a path such as /pricing.";
|
|
9054
9232
|
var INNER_LINK_FIELDS = [
|
|
9055
9233
|
{ key: "href", kind: "href", label: "Link", optional: true, message: LINK_MESSAGE },
|
|
@@ -9097,10 +9275,11 @@ var heading = {
|
|
|
9097
9275
|
};
|
|
9098
9276
|
var BOX_LINK_FIELDS = [
|
|
9099
9277
|
{ key: "href", kind: "href", label: "Link", optional: true, message: LINK_MESSAGE },
|
|
9100
|
-
{ key: "newTab", kind: "boolean", label: "Open in new tab", optional: true }
|
|
9278
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true }
|
|
9101
9279
|
];
|
|
9280
|
+
var BOX_LINK_CSS = ":where(a.emvb-box-link){color:inherit;text-decoration:inherit}";
|
|
9102
9281
|
var container = {
|
|
9103
|
-
baseCss: ".emvb-container{display:flex;flex-direction:column;min-width:0;overflow-wrap:break-word}",
|
|
9282
|
+
baseCss: ".emvb-container{display:flex;flex-direction:column;min-width:0;overflow-wrap:break-word}" + BOX_LINK_CSS,
|
|
9104
9283
|
defaults: () => ({ type: "container", props: {}, children: [] }),
|
|
9105
9284
|
descriptor: {
|
|
9106
9285
|
type: "container",
|
|
@@ -9113,7 +9292,7 @@ var container = {
|
|
|
9113
9292
|
kind: "select",
|
|
9114
9293
|
label: "HTML tag",
|
|
9115
9294
|
optional: true,
|
|
9116
|
-
options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: tag })),
|
|
9295
|
+
options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
|
|
9117
9296
|
message: "Pick a landmark or div."
|
|
9118
9297
|
},
|
|
9119
9298
|
...BOX_LINK_FIELDS
|
|
@@ -9175,7 +9354,7 @@ var text = {
|
|
|
9175
9354
|
kind: "select",
|
|
9176
9355
|
label: "HTML tag",
|
|
9177
9356
|
optional: true,
|
|
9178
|
-
options: TEXT_TAGS.map((tag) => ({ value: tag, label: tag }))
|
|
9357
|
+
options: TEXT_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] }))
|
|
9179
9358
|
}
|
|
9180
9359
|
]
|
|
9181
9360
|
},
|
|
@@ -9226,7 +9405,7 @@ var link = {
|
|
|
9226
9405
|
}
|
|
9227
9406
|
};
|
|
9228
9407
|
var button = {
|
|
9229
|
-
baseCss: ".emvb-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5em;margin:0;font:inherit;text-decoration:none;cursor:pointer}:where(.emvb-button){color:inherit;background:transparent;border:1px solid currentColor;border-radius:6px;padding:0.625em 1.25em;line-height:1.2}.emvb-button-icon{display:inline-flex;flex:none}.emvb-button-icon svg{width:100%;height:100%;display:block}.emvb-button-icon--sm{width:1em;height:1em}.emvb-button-icon--md{width:1.25em;height:1.25em}.emvb-button-icon--lg{width:1.5em;height:1.5em}
|
|
9408
|
+
baseCss: ".emvb-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5em;overflow-wrap:anywhere;text-align:center;margin:0;font:inherit;text-decoration:none;cursor:pointer}:where(.emvb-button){color:inherit;background:transparent;border:1px solid currentColor;border-radius:6px;padding:0.625em 1.25em;line-height:1.2}.emvb-button-icon{display:inline-flex;flex:none}.emvb-button-icon svg{width:100%;height:100%;display:block}.emvb-button-icon--sm{width:1em;height:1em}.emvb-button-icon--md{width:1.25em;height:1.25em}.emvb-button-icon--lg{width:1.5em;height:1.5em}",
|
|
9230
9409
|
defaults: () => ({ type: "button", props: { text: "Button" } }),
|
|
9231
9410
|
descriptor: {
|
|
9232
9411
|
type: "button",
|
|
@@ -9319,7 +9498,7 @@ function buttonChildren(node) {
|
|
|
9319
9498
|
return node.props.iconPosition === "after" ? [buttonText, icon] : [icon, buttonText];
|
|
9320
9499
|
}
|
|
9321
9500
|
var list = {
|
|
9322
|
-
baseCss: ".emvb-list{margin:0;padding-inline-start:1.25em}.emvb-list li{margin:0}",
|
|
9501
|
+
baseCss: ".emvb-list{margin:0;padding-inline-start:1.25em}.emvb-list li{margin:0}.emvb-list--wide{padding-inline-start:2.25em}",
|
|
9323
9502
|
defaults: () => ({ type: "list", props: { items: ["Item"] } }),
|
|
9324
9503
|
descriptor: {
|
|
9325
9504
|
type: "list",
|
|
@@ -9331,14 +9510,18 @@ var list = {
|
|
|
9331
9510
|
{ key: "items", kind: "list-items", label: "Items" }
|
|
9332
9511
|
]
|
|
9333
9512
|
},
|
|
9334
|
-
build: (node, attrs) =>
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9513
|
+
build: (node, attrs) => {
|
|
9514
|
+
const items = node.props.items.filter((item) => item.trim() !== "");
|
|
9515
|
+
const wide = node.props.ordered === true && items.length >= 100;
|
|
9516
|
+
return {
|
|
9517
|
+
tag: node.props.ordered ? "ol" : "ul",
|
|
9518
|
+
attrs: wide ? { ...attrs, class: `${attrs.class ?? ""} emvb-list--wide`.trim() } : attrs,
|
|
9519
|
+
children: items.map((item) => ({ tag: "li", attrs: {}, children: [item] }))
|
|
9520
|
+
};
|
|
9521
|
+
}
|
|
9339
9522
|
};
|
|
9340
9523
|
var image = {
|
|
9341
|
-
baseCss: ".emvb-image{display:block;max-width:100%;height:auto}:where(img.emvb-image:not([width])){width:fit-content}",
|
|
9524
|
+
baseCss: ".emvb-image{display:block;max-width:100%;height:auto}:where(img.emvb-image:not([width])){width:fit-content}" + ".emvb-figure{margin:0}.emvb-figcaption{margin-top:0.35em}.emvb-image-link{display:contents}",
|
|
9342
9525
|
defaults: () => ({
|
|
9343
9526
|
type: "image",
|
|
9344
9527
|
props: { src: "", alt: "Image", decorative: false }
|
|
@@ -9359,7 +9542,7 @@ var image = {
|
|
|
9359
9542
|
{
|
|
9360
9543
|
key: "decorative",
|
|
9361
9544
|
kind: "boolean",
|
|
9362
|
-
label: "Decorative
|
|
9545
|
+
label: "Decorative",
|
|
9363
9546
|
optional: true
|
|
9364
9547
|
},
|
|
9365
9548
|
{ key: "priority", kind: "boolean", label: "Load right away", optional: true },
|
|
@@ -9443,33 +9626,40 @@ var srcsetUrl = (url) => url?.replaceAll(" ", "%20");
|
|
|
9443
9626
|
function imageSources(src, sources, width) {
|
|
9444
9627
|
if (!sources || sources.length === 0)
|
|
9445
9628
|
return;
|
|
9446
|
-
const
|
|
9447
|
-
const seen = new Set;
|
|
9629
|
+
const main = srcsetUrl(src);
|
|
9448
9630
|
let srcWidth;
|
|
9449
9631
|
for (const source of sources) {
|
|
9450
|
-
const url = srcsetUrl(sanitizeMediaUrl(source.src));
|
|
9451
9632
|
if (!validSourceWidth(source.width))
|
|
9452
9633
|
continue;
|
|
9453
|
-
if (
|
|
9454
|
-
srcWidth
|
|
9455
|
-
|
|
9634
|
+
if (srcsetUrl(sanitizeMediaUrl(source.src)) === main) {
|
|
9635
|
+
srcWidth = source.width;
|
|
9636
|
+
break;
|
|
9456
9637
|
}
|
|
9457
|
-
|
|
9638
|
+
}
|
|
9639
|
+
srcWidth ??= validSourceWidth(width) ? width : undefined;
|
|
9640
|
+
const mainListed = srcWidth !== undefined && main !== undefined && !/[\s,]/.test(main);
|
|
9641
|
+
const parts = [];
|
|
9642
|
+
const seen = new Set;
|
|
9643
|
+
const widths = new Set(mainListed ? [srcWidth] : []);
|
|
9644
|
+
for (const source of sources) {
|
|
9645
|
+
const url = srcsetUrl(sanitizeMediaUrl(source.src));
|
|
9646
|
+
if (!validSourceWidth(source.width) || url === main)
|
|
9647
|
+
continue;
|
|
9648
|
+
if (!url || /[\s,]/.test(url) || seen.has(url) || widths.has(source.width))
|
|
9458
9649
|
continue;
|
|
9459
9650
|
seen.add(url);
|
|
9651
|
+
widths.add(source.width);
|
|
9460
9652
|
parts.push(`${url} ${source.width}w`);
|
|
9461
9653
|
}
|
|
9462
9654
|
if (parts.length === 0)
|
|
9463
9655
|
return;
|
|
9464
|
-
|
|
9465
|
-
const main = srcsetUrl(src);
|
|
9466
|
-
if (srcWidth !== undefined && main && !/[\s,]/.test(main))
|
|
9656
|
+
if (mainListed)
|
|
9467
9657
|
parts.push(`${main} ${srcWidth}w`);
|
|
9468
9658
|
return parts.join(", ");
|
|
9469
9659
|
}
|
|
9470
9660
|
var ICON_STROKE_WIDTHS = ["1", "1.5", "2", "2.5", "3"];
|
|
9471
9661
|
var icon = {
|
|
9472
|
-
baseCss: ".emvb-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}.emvb-icon-link{display:inline-flex;color:inherit}.emvb-icon svg{display:block;rotate:var(--emvb-icon-rotate,0deg);scale:var(--emvb-icon-flip,1 1);filter:var(--emvb-icon-shadow,none);animation:var(--emvb-icon-animation,none);transition:inherit}" + ICON_STROKE_WIDTHS.map((width) => `.emvb-icon-sw${width.replace(".", "_")}{stroke-width:var(--emvb-icon-stroke,${width})}`).join("") + "@keyframes emvb-icon-spin{to{transform:rotate(360deg)}}@keyframes emvb-icon-pulse{from{transform:scale(1)}to{transform:scale(1.15)}}@media (prefers-reduced-motion: reduce){.emvb-icon svg{animation:none}}.emvb-icon-missing{min-width:1em;min-height:1em;background:var(--color-kumo-tint,#eee)}",
|
|
9662
|
+
baseCss: ".emvb-icon{display:inline-flex;align-items:center;justify-content:center;line-height:0;color:inherit}.emvb-icon-link{display:inline-flex;max-width:100%;color:inherit}.emvb-icon svg{display:block;max-width:100%;rotate:var(--emvb-icon-rotate,0deg);scale:var(--emvb-icon-flip,1 1);filter:var(--emvb-icon-shadow,none);animation:var(--emvb-icon-animation,none);transition:inherit}" + ICON_STROKE_WIDTHS.map((width) => `.emvb-icon-sw${width.replace(".", "_")}{stroke-width:var(--emvb-icon-stroke,${width})}`).join("") + "@keyframes emvb-icon-spin{to{transform:rotate(360deg)}}@keyframes emvb-icon-pulse{from{transform:scale(1)}to{transform:scale(1.15)}}@media (prefers-reduced-motion: reduce){.emvb-icon svg{animation:none}}.emvb-icon-missing{min-width:1em;min-height:1em;background:var(--color-kumo-tint,#eee)}",
|
|
9473
9663
|
defaults: () => ({
|
|
9474
9664
|
type: "icon",
|
|
9475
9665
|
props: { iconId: "star", title: "Star", decorative: false, size: 24 }
|
|
@@ -9485,7 +9675,7 @@ var icon = {
|
|
|
9485
9675
|
{
|
|
9486
9676
|
key: "decorative",
|
|
9487
9677
|
kind: "boolean",
|
|
9488
|
-
label: "Decorative
|
|
9678
|
+
label: "Decorative",
|
|
9489
9679
|
optional: true
|
|
9490
9680
|
},
|
|
9491
9681
|
{
|
|
@@ -9637,13 +9827,14 @@ var video = {
|
|
|
9637
9827
|
children: []
|
|
9638
9828
|
};
|
|
9639
9829
|
}
|
|
9830
|
+
const title = String(node.props.title ?? "").trim() || "Video";
|
|
9640
9831
|
if (target.kind === "iframe") {
|
|
9641
9832
|
return {
|
|
9642
9833
|
tag: "iframe",
|
|
9643
9834
|
attrs: {
|
|
9644
9835
|
...attrs,
|
|
9645
9836
|
src: target.src,
|
|
9646
|
-
title
|
|
9837
|
+
title,
|
|
9647
9838
|
loading: "lazy",
|
|
9648
9839
|
referrerpolicy: "strict-origin-when-cross-origin",
|
|
9649
9840
|
allow: "encrypted-media; picture-in-picture; fullscreen",
|
|
@@ -9657,7 +9848,7 @@ var video = {
|
|
|
9657
9848
|
attrs: {
|
|
9658
9849
|
...attrs,
|
|
9659
9850
|
src: target.src,
|
|
9660
|
-
title
|
|
9851
|
+
title,
|
|
9661
9852
|
controls: "",
|
|
9662
9853
|
preload: "metadata"
|
|
9663
9854
|
},
|
|
@@ -9704,7 +9895,7 @@ var svgEl = {
|
|
|
9704
9895
|
{
|
|
9705
9896
|
key: "decorative",
|
|
9706
9897
|
kind: "boolean",
|
|
9707
|
-
label: "Decorative
|
|
9898
|
+
label: "Decorative",
|
|
9708
9899
|
optional: true
|
|
9709
9900
|
},
|
|
9710
9901
|
{
|
|
@@ -9750,7 +9941,7 @@ var svgEl = {
|
|
|
9750
9941
|
return {
|
|
9751
9942
|
tag: "span",
|
|
9752
9943
|
attrs,
|
|
9753
|
-
children: [{ tag: "svg", attrs: svgAttrs, children: tree.children }]
|
|
9944
|
+
children: [{ tag: "svg", attrs: svgAttrs, children: scopeSvgIds(tree.children, node.id) }]
|
|
9754
9945
|
};
|
|
9755
9946
|
}
|
|
9756
9947
|
};
|
|
@@ -9771,7 +9962,7 @@ var tabPanel = {
|
|
|
9771
9962
|
build: (_node, attrs, children) => ({ tag: "div", attrs, children })
|
|
9772
9963
|
};
|
|
9773
9964
|
var tabs = {
|
|
9774
|
-
baseCss: ".emvb-tabs{display:flex;flex-direction:column;min-width:0;gap:0}.emvb-tab-input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}.emvb-tab-list{display:flex;flex-wrap:wrap;gap:0;border-bottom:1px solid currentColor;margin:0;padding:0}.emvb-tab-label{display:inline-block;padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px}.emvb-tab-panels{min-width:0}.emvb-tab-panel{
|
|
9965
|
+
baseCss: ".emvb-tabs{display:flex;flex-direction:column;min-width:0;gap:0}.emvb-tab-input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}.emvb-tab-list{display:flex;flex-wrap:wrap;gap:0;border-bottom:1px solid currentColor;margin:0;padding:0}.emvb-tab-label{display:inline-block;padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;min-width:0;overflow-wrap:anywhere}.emvb-tab-panels{min-width:0}.emvb-tab-panel{padding-top:12px;min-width:0}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(1){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(1):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(1)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(2){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(2):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(2)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(3){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(3):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(3)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(4){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(4):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(4)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(5){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(5):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(5)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(6){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(6):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(6)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(7){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(7):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(7)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(8){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(8):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(8)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(9){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(9):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(9)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(10){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(10):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(10)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(11){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(11):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(11)){display:none!important}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-list > .emvb-tab-label:nth-of-type(12){border-bottom-color:currentColor;font-weight:600}.emvb-tabs:has(> .emvb-tab-input:nth-of-type(12):checked) > .emvb-tab-panels > .emvb-tab-panel:not(:nth-of-type(12)){display:none!important}",
|
|
9775
9966
|
defaults: () => ({
|
|
9776
9967
|
type: "tabs",
|
|
9777
9968
|
props: {},
|
|
@@ -9787,7 +9978,7 @@ var tabs = {
|
|
|
9787
9978
|
build: (_node, attrs, children) => ({ tag: "div", attrs, children })
|
|
9788
9979
|
};
|
|
9789
9980
|
var divBlock = {
|
|
9790
|
-
baseCss: ".emvb-div-block{display:block;min-width:0}",
|
|
9981
|
+
baseCss: ".emvb-div-block{display:block;min-width:0}" + BOX_LINK_CSS,
|
|
9791
9982
|
defaults: () => ({ type: "div-block", props: {}, children: [] }),
|
|
9792
9983
|
descriptor: {
|
|
9793
9984
|
type: "div-block",
|
|
@@ -9830,7 +10021,7 @@ var layoutSection = {
|
|
|
9830
10021
|
kind: "select",
|
|
9831
10022
|
label: "HTML tag",
|
|
9832
10023
|
optional: true,
|
|
9833
|
-
options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: tag })),
|
|
10024
|
+
options: CONTAINER_TAGS.map((tag) => ({ value: tag, label: TAG_LABELS[tag] })),
|
|
9834
10025
|
message: "Pick a landmark or div. A section is a section by default."
|
|
9835
10026
|
}
|
|
9836
10027
|
]
|
|
@@ -9844,7 +10035,7 @@ var layoutSection = {
|
|
|
9844
10035
|
};
|
|
9845
10036
|
var TRACKS_HINT = "Up to 12 tracks, one per line: 1fr, 2fr, 3fr, auto, min-content, max-content, or a length.";
|
|
9846
10037
|
var grid = {
|
|
9847
|
-
baseCss: ".emvb-grid{display:grid;min-width:0}",
|
|
10038
|
+
baseCss: ".emvb-grid{display:grid;min-width:0}" + BOX_LINK_CSS,
|
|
9848
10039
|
defaults: () => ({ type: "grid", props: { columns: 3 }, children: [] }),
|
|
9849
10040
|
descriptor: {
|
|
9850
10041
|
type: "grid",
|
|
@@ -9889,7 +10080,7 @@ var grid = {
|
|
|
9889
10080
|
build: (_node, attrs, children) => ({ tag: "div", attrs, children })
|
|
9890
10081
|
};
|
|
9891
10082
|
var flexbox = {
|
|
9892
|
-
baseCss: ".emvb-flexbox{display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;min-width:0;gap:16px}",
|
|
10083
|
+
baseCss: ".emvb-flexbox{display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;min-width:0;gap:16px;overflow-wrap:anywhere}" + BOX_LINK_CSS,
|
|
9893
10084
|
defaults: () => ({
|
|
9894
10085
|
type: "flexbox",
|
|
9895
10086
|
props: {},
|
|
@@ -9927,11 +10118,12 @@ var accordionItem = {
|
|
|
9927
10118
|
defaultTab: "content",
|
|
9928
10119
|
fields: [
|
|
9929
10120
|
{ key: "summary", kind: "text", label: "Title" },
|
|
9930
|
-
{ key: "open", kind: "boolean", label: "Open", optional: true }
|
|
10121
|
+
{ key: "open", kind: "boolean", label: "Open by default", optional: true }
|
|
9931
10122
|
]
|
|
9932
10123
|
},
|
|
9933
10124
|
build: (node, attrs, children) => {
|
|
9934
|
-
const
|
|
10125
|
+
const title = node.props.summary.trim() || "Details";
|
|
10126
|
+
const summary = { tag: "summary", attrs: {}, children: [title] };
|
|
9935
10127
|
const body = { tag: "div", attrs: { class: "emvb-accordion-body" }, children };
|
|
9936
10128
|
return {
|
|
9937
10129
|
tag: "details",
|
|
@@ -10398,8 +10590,19 @@ function starterLayout(title, random) {
|
|
|
10398
10590
|
}
|
|
10399
10591
|
};
|
|
10400
10592
|
}
|
|
10401
|
-
function
|
|
10402
|
-
|
|
10593
|
+
function pageSlug(text, max = 80) {
|
|
10594
|
+
const slug = text.normalize("NFKC").toLowerCase().replace(/[\s_]+/gu, "-").replace(/[^\p{L}\p{N}\p{M}-]+/gu, "").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
10595
|
+
if (!/[\p{L}\p{N}]/u.test(slug))
|
|
10596
|
+
return "";
|
|
10597
|
+
let out = "";
|
|
10598
|
+
let count = 0;
|
|
10599
|
+
for (const { segment } of new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(slug)) {
|
|
10600
|
+
if (count >= max)
|
|
10601
|
+
break;
|
|
10602
|
+
out += segment;
|
|
10603
|
+
count++;
|
|
10604
|
+
}
|
|
10605
|
+
return out.replace(/-+$/g, "");
|
|
10403
10606
|
}
|
|
10404
10607
|
|
|
10405
10608
|
// ../emvb/src/core/arrange.ts
|
|
@@ -10597,6 +10800,27 @@ function nestingIssues(layout, max = 5) {
|
|
|
10597
10800
|
walk(layout.root, "root", isFormNode(layout.root));
|
|
10598
10801
|
return issues;
|
|
10599
10802
|
}
|
|
10803
|
+
// ../emvb/src/core/stable-json.ts
|
|
10804
|
+
function sorted(value) {
|
|
10805
|
+
if (Array.isArray(value))
|
|
10806
|
+
return value.map(sorted);
|
|
10807
|
+
if (!value || typeof value !== "object")
|
|
10808
|
+
return value;
|
|
10809
|
+
const entries = Object.entries(value).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
10810
|
+
return Object.fromEntries(entries.map(([k, v]) => [k, sorted(v)]));
|
|
10811
|
+
}
|
|
10812
|
+
var stableJson = (value) => JSON.stringify(sorted(value));
|
|
10813
|
+
|
|
10814
|
+
// ../emvb/src/core/design/classes.ts
|
|
10815
|
+
function cleanClassName(name) {
|
|
10816
|
+
const spaced = Array.from(name.normalize("NFC"), (ch) => {
|
|
10817
|
+
const code = ch.charCodeAt(0);
|
|
10818
|
+
return code < 32 || code >= 127 && code <= 159 ? " " : ch;
|
|
10819
|
+
}).join("").replace(/[\u200B\u2060\uFEFF\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "");
|
|
10820
|
+
const spacedTrim = spaced.replace(/ {2,}/g, " ").trim();
|
|
10821
|
+
return clipText(spacedTrim, 60).trim();
|
|
10822
|
+
}
|
|
10823
|
+
var nameKey = (name) => cleanClassName(name).toLowerCase();
|
|
10600
10824
|
// ../emvb/src/core/design/variables.ts
|
|
10601
10825
|
var isVariableRef = (value) => typeof value === "object" && value !== null && ("var" in value) && typeof value.var === "string";
|
|
10602
10826
|
function refMatchesKind(ref, kind) {
|
|
@@ -10639,6 +10863,7 @@ function collectAllUsages(owner, id, kind, hit) {
|
|
|
10639
10863
|
for (const device of RESPONSIVE) {
|
|
10640
10864
|
collectStyleUsages(owner.devices?.[device], id, kind, (prop) => hit(`${device}.${prop}`));
|
|
10641
10865
|
}
|
|
10866
|
+
collectStyleUsages(owner.query?.style, id, kind, (prop) => hit(`query.${prop}`));
|
|
10642
10867
|
}
|
|
10643
10868
|
function findVariableUsages(layout, id, kind) {
|
|
10644
10869
|
const usages = [];
|
|
@@ -10658,6 +10883,24 @@ function findVariableUsagesInDesign(design, id, kind) {
|
|
|
10658
10883
|
}
|
|
10659
10884
|
return usages;
|
|
10660
10885
|
}
|
|
10886
|
+
// ../emvb/src/core/audience/variants.ts
|
|
10887
|
+
function loneAbTests(layout) {
|
|
10888
|
+
const arms = new Map;
|
|
10889
|
+
const walk = (node) => {
|
|
10890
|
+
const v = node.variant;
|
|
10891
|
+
if (v) {
|
|
10892
|
+
const seen = arms.get(v.test) ?? new Set;
|
|
10893
|
+
seen.add(v.arm);
|
|
10894
|
+
arms.set(v.test, seen);
|
|
10895
|
+
}
|
|
10896
|
+
if (isParentNode(node))
|
|
10897
|
+
for (const child of node.children)
|
|
10898
|
+
walk(child);
|
|
10899
|
+
};
|
|
10900
|
+
walk(layout.root);
|
|
10901
|
+
return new Set([...arms].filter(([, seen]) => seen.size < 2).map(([test]) => test));
|
|
10902
|
+
}
|
|
10903
|
+
|
|
10661
10904
|
// ../emvb/src/core/audience/rules.ts
|
|
10662
10905
|
var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
10663
10906
|
var DEVICE_LABELS = { mobile: "mobile", tablet: "tablet", desktop: "desktop" };
|
|
@@ -10679,10 +10922,25 @@ function audienceSummary(audience) {
|
|
|
10679
10922
|
return audience.hide ? `Hidden for ${who}` : `Only ${who}`;
|
|
10680
10923
|
}
|
|
10681
10924
|
|
|
10925
|
+
// ../emvb/src/core/forms/definition.ts
|
|
10926
|
+
var OPTION_TYPES = new Set(["select", "radio", "checkbox-group"]);
|
|
10927
|
+
var FREE_CONTROLS = new Set(["text-input", "textarea", "checkbox"]);
|
|
10928
|
+
|
|
10682
10929
|
// ../emvb/src/core/forms/binding.ts
|
|
10683
10930
|
var FIELD_TYPES = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
|
|
10684
10931
|
var DEVICE_ORDER = ["desktop", "tablet", "mobile"];
|
|
10685
|
-
function
|
|
10932
|
+
function splitKey(node, lone) {
|
|
10933
|
+
const audience = node.audience;
|
|
10934
|
+
if (audience) {
|
|
10935
|
+
const { hide, ...rules } = audience;
|
|
10936
|
+
return `aud:${hide ? 1 : 0}:${stableJson(rules)}`;
|
|
10937
|
+
}
|
|
10938
|
+
if (node.variant && !lone.has(node.variant.test)) {
|
|
10939
|
+
return `ab:${node.variant.test}:${node.variant.arm}`;
|
|
10940
|
+
}
|
|
10941
|
+
return;
|
|
10942
|
+
}
|
|
10943
|
+
function restriction(node, lone) {
|
|
10686
10944
|
const audience = node.audience;
|
|
10687
10945
|
if (audience) {
|
|
10688
10946
|
const { hide, timeZone: _zone, ...rules } = audience;
|
|
@@ -10690,42 +10948,51 @@ function restriction(node) {
|
|
|
10690
10948
|
return audienceSummary(audience);
|
|
10691
10949
|
}
|
|
10692
10950
|
}
|
|
10693
|
-
if (node.variant) {
|
|
10951
|
+
if (node.variant && !lone.has(node.variant.test)) {
|
|
10694
10952
|
return `Variant ${node.variant.arm.toUpperCase()} of A/B test ${node.variant.test}`;
|
|
10695
10953
|
}
|
|
10696
10954
|
return;
|
|
10697
10955
|
}
|
|
10698
10956
|
function boundControls(form) {
|
|
10957
|
+
const lone = loneAbTests({ schemaVersion: LAYOUT_SCHEMA_VERSION, root: form });
|
|
10699
10958
|
const found = new Map;
|
|
10700
10959
|
const walk = (node, inherited, limited) => {
|
|
10701
10960
|
const own = node.hiddenOn ?? [];
|
|
10702
10961
|
const hidden = own.length ? new Set([...inherited, ...own]) : inherited;
|
|
10703
|
-
|
|
10962
|
+
let scope = limited;
|
|
10963
|
+
if (!scope) {
|
|
10964
|
+
const who = restriction(node, lone);
|
|
10965
|
+
if (who)
|
|
10966
|
+
scope = { who, split: splitKey(node, lone) };
|
|
10967
|
+
}
|
|
10704
10968
|
if (FIELD_TYPES.has(node.type)) {
|
|
10705
10969
|
const field = node.props.field;
|
|
10706
10970
|
if (typeof field === "string" && field) {
|
|
10707
10971
|
const control = { nodeId: node.id, hidden: new Set(hidden) };
|
|
10708
|
-
if (
|
|
10709
|
-
control.who = who;
|
|
10972
|
+
if (scope) {
|
|
10973
|
+
control.who = scope.who;
|
|
10974
|
+
if (scope.split)
|
|
10975
|
+
control.split = scope.split;
|
|
10976
|
+
}
|
|
10710
10977
|
found.set(field, [...found.get(field) ?? [], control]);
|
|
10711
10978
|
}
|
|
10712
10979
|
}
|
|
10713
10980
|
for (const child of nodeChildren(node))
|
|
10714
|
-
walk(child, hidden,
|
|
10981
|
+
walk(child, hidden, scope);
|
|
10715
10982
|
};
|
|
10716
10983
|
for (const child of nodeChildren(form))
|
|
10717
10984
|
walk(child, new Set, undefined);
|
|
10718
10985
|
return found;
|
|
10719
10986
|
}
|
|
10720
10987
|
function coversEveryone(controls) {
|
|
10721
|
-
const
|
|
10722
|
-
for (const
|
|
10723
|
-
if (!
|
|
10988
|
+
const splits = new Set(controls.map((control) => control.split));
|
|
10989
|
+
for (const key of splits) {
|
|
10990
|
+
if (!key)
|
|
10724
10991
|
continue;
|
|
10725
|
-
const ab = /^
|
|
10726
|
-
if (ab &&
|
|
10992
|
+
const ab = /^ab:(.*):([ab])$/.exec(key);
|
|
10993
|
+
if (ab && splits.has(`ab:${ab[1]}:${ab[2] === "a" ? "b" : "a"}`))
|
|
10727
10994
|
return true;
|
|
10728
|
-
if (
|
|
10995
|
+
if (key.startsWith("aud:0:") && splits.has(`aud:1:${key.slice(6)}`))
|
|
10729
10996
|
return true;
|
|
10730
10997
|
}
|
|
10731
10998
|
return false;
|
|
@@ -10734,7 +11001,7 @@ function requiredFieldIssues(form, fields) {
|
|
|
10734
11001
|
const controls = boundControls(form);
|
|
10735
11002
|
const issues = [];
|
|
10736
11003
|
for (const field of fields) {
|
|
10737
|
-
if (!field.required)
|
|
11004
|
+
if (!field.required || field.type === "hidden")
|
|
10738
11005
|
continue;
|
|
10739
11006
|
const label = field.label.trim() || field.name;
|
|
10740
11007
|
const bound = controls.get(field.name);
|
|
@@ -10859,8 +11126,9 @@ function tidy(nodes) {
|
|
|
10859
11126
|
var hasText = (nodes) => nodes.some((n) => typeof n === "string" ? n.trim() !== "" : hasText(n.children));
|
|
10860
11127
|
function portableTextToVNodes(value) {
|
|
10861
11128
|
if (typeof value === "string") {
|
|
10862
|
-
|
|
10863
|
-
|
|
11129
|
+
return value.replaceAll(`\r
|
|
11130
|
+
`, `
|
|
11131
|
+
`).split(/\n[ \t]*\n/).map((para) => para.trim()).filter(Boolean).map((para) => ({ tag: "p", attrs: {}, children: withBreaks(para) }));
|
|
10864
11132
|
}
|
|
10865
11133
|
if (!Array.isArray(value))
|
|
10866
11134
|
return [];
|
|
@@ -10904,10 +11172,57 @@ function portableTextToVNodes(value) {
|
|
|
10904
11172
|
const tag = style === "normal" ? "p" : style;
|
|
10905
11173
|
out.push({ tag, attrs: {}, children: inline });
|
|
10906
11174
|
}
|
|
10907
|
-
return out
|
|
11175
|
+
return pruneEmptyLists(out);
|
|
11176
|
+
}
|
|
11177
|
+
var isList = (n) => n.tag === "ul" || n.tag === "ol";
|
|
11178
|
+
function pruneEmptyLists(nodes) {
|
|
11179
|
+
const keep = [];
|
|
11180
|
+
for (const node of nodes) {
|
|
11181
|
+
if (isList(node)) {
|
|
11182
|
+
const items = [];
|
|
11183
|
+
for (const li of node.children) {
|
|
11184
|
+
if (typeof li === "string")
|
|
11185
|
+
continue;
|
|
11186
|
+
li.children = li.children.flatMap((c) => typeof c !== "string" && isList(c) ? pruneEmptyLists([c]) : [c]);
|
|
11187
|
+
if (li.children.length > 0)
|
|
11188
|
+
items.push(li);
|
|
11189
|
+
}
|
|
11190
|
+
node.children = items;
|
|
11191
|
+
if (items.length > 0)
|
|
11192
|
+
keep.push(node);
|
|
11193
|
+
} else
|
|
11194
|
+
keep.push(node);
|
|
11195
|
+
}
|
|
11196
|
+
return keep;
|
|
10908
11197
|
}
|
|
10909
11198
|
|
|
10910
11199
|
// ../emvb/src/core/render/dynamic-post.ts
|
|
11200
|
+
var UNSPACED = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u;
|
|
11201
|
+
var wordSegmenter;
|
|
11202
|
+
function limitWords(text, max) {
|
|
11203
|
+
if (!max || max < 1)
|
|
11204
|
+
return text;
|
|
11205
|
+
let count = 0;
|
|
11206
|
+
for (const chunk of text.matchAll(/\S+/g)) {
|
|
11207
|
+
const start = chunk.index ?? 0;
|
|
11208
|
+
if (!UNSPACED.test(chunk[0])) {
|
|
11209
|
+
count++;
|
|
11210
|
+
if (count === max)
|
|
11211
|
+
return finish(text, start + chunk[0].length);
|
|
11212
|
+
continue;
|
|
11213
|
+
}
|
|
11214
|
+
wordSegmenter ??= new Intl.Segmenter(undefined, { granularity: "word" });
|
|
11215
|
+
for (const piece of wordSegmenter.segment(chunk[0])) {
|
|
11216
|
+
if (!piece.isWordLike)
|
|
11217
|
+
continue;
|
|
11218
|
+
count++;
|
|
11219
|
+
if (count === max)
|
|
11220
|
+
return finish(text, start + piece.index + piece.segment.length);
|
|
11221
|
+
}
|
|
11222
|
+
}
|
|
11223
|
+
return text;
|
|
11224
|
+
}
|
|
11225
|
+
var finish = (text, end) => text.slice(end).trim() === "" ? text : `${text.slice(0, end).trim().replace(/\s+/g, " ")}…`;
|
|
10911
11226
|
var parseIsoDate = (raw) => {
|
|
10912
11227
|
const match = /^(\d{4})-(\d{2})-(\d{2})(?:[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/.exec(raw);
|
|
10913
11228
|
if (!match)
|
|
@@ -10916,13 +11231,22 @@ var parseIsoDate = (raw) => {
|
|
|
10916
11231
|
if (Number.isNaN(parsed))
|
|
10917
11232
|
return Number.NaN;
|
|
10918
11233
|
const day = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])));
|
|
10919
|
-
return day.getUTCDate() === Number(match[3]) && day.getUTCMonth() === Number(match[2]) - 1 ?
|
|
11234
|
+
return day.getUTCDate() === Number(match[3]) && day.getUTCMonth() === Number(match[2]) - 1 ? day.getTime() : Number.NaN;
|
|
10920
11235
|
};
|
|
10921
|
-
function
|
|
11236
|
+
function dateLocale(lang) {
|
|
11237
|
+
if (!lang || !/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/.test(lang))
|
|
11238
|
+
return "en";
|
|
11239
|
+
try {
|
|
11240
|
+
return Intl.DateTimeFormat.supportedLocalesOf([lang])[0] ?? "en";
|
|
11241
|
+
} catch {
|
|
11242
|
+
return "en";
|
|
11243
|
+
}
|
|
11244
|
+
}
|
|
11245
|
+
function formatPostDate(time, format, lang) {
|
|
10922
11246
|
const date = new Date(time);
|
|
10923
11247
|
if (format === "numeric")
|
|
10924
11248
|
return date.toISOString().slice(0, 10);
|
|
10925
|
-
return new Intl.DateTimeFormat(
|
|
11249
|
+
return new Intl.DateTimeFormat(dateLocale(lang), { dateStyle: format, timeZone: "UTC" }).format(date);
|
|
10926
11250
|
}
|
|
10927
11251
|
var props = (node) => node.props;
|
|
10928
11252
|
var POST_FIELDS = new Map([
|
|
@@ -10930,6 +11254,7 @@ var POST_FIELDS = new Map([
|
|
|
10930
11254
|
"post-title",
|
|
10931
11255
|
{
|
|
10932
11256
|
placeholder: (attrs) => ({ tag: "h1", attrs, children: ["Post Title"] }),
|
|
11257
|
+
has: (post) => !!post.title?.trim(),
|
|
10933
11258
|
render: (node, attrs, post) => {
|
|
10934
11259
|
const level = props(node).level ?? 1;
|
|
10935
11260
|
const tag = HEADING_TAGS[Math.min(6, Math.max(1, level)) - 1] ?? "h1";
|
|
@@ -10942,11 +11267,9 @@ var POST_FIELDS = new Map([
|
|
|
10942
11267
|
{
|
|
10943
11268
|
placeholder: (attrs) => ({ tag: "p", attrs, children: ["Post excerpt…"] }),
|
|
10944
11269
|
render: (node, attrs, post) => {
|
|
10945
|
-
if (!post.excerpt)
|
|
11270
|
+
if (!post.excerpt?.trim())
|
|
10946
11271
|
return;
|
|
10947
|
-
const
|
|
10948
|
-
const words = post.excerpt.trim().split(/\s+/);
|
|
10949
|
-
const text = max && words.length > max ? `${words.slice(0, max).join(" ")}…` : post.excerpt;
|
|
11272
|
+
const text = limitWords(post.excerpt, props(node).maxWords);
|
|
10950
11273
|
return { tag: "p", attrs, children: [text] };
|
|
10951
11274
|
}
|
|
10952
11275
|
}
|
|
@@ -10978,7 +11301,7 @@ var POST_FIELDS = new Map([
|
|
|
10978
11301
|
const src = sanitizeMediaUrl(post.featuredImageUrl ?? "");
|
|
10979
11302
|
if (!src)
|
|
10980
11303
|
return;
|
|
10981
|
-
const alt = props(node).decorative ? "" : post.featuredImageAlt?.trim() || post.title || "Featured image";
|
|
11304
|
+
const alt = props(node).decorative ? "" : post.featuredImageAlt?.trim() || post.title?.trim() || "Featured image";
|
|
10982
11305
|
const lazy = inLoop ? { loading: "lazy", decoding: "async" } : {};
|
|
10983
11306
|
return { tag: "img", attrs: { ...attrs, src, alt, ...lazy }, children: [] };
|
|
10984
11307
|
}
|
|
@@ -11020,13 +11343,13 @@ var POST_FIELDS = new Map([
|
|
|
11020
11343
|
{
|
|
11021
11344
|
placeholder: (attrs) => ({ tag: "time", attrs, children: ["Post date"] }),
|
|
11022
11345
|
has: (post) => !!post.publishedAt?.trim(),
|
|
11023
|
-
render: (node, attrs, post) => {
|
|
11346
|
+
render: (node, attrs, post, _inLoop, lang) => {
|
|
11024
11347
|
const raw = post.publishedAt?.trim();
|
|
11025
11348
|
if (!raw)
|
|
11026
11349
|
return;
|
|
11027
11350
|
const parsed = parseIsoDate(raw);
|
|
11028
11351
|
const format = props(node).format ?? "medium";
|
|
11029
|
-
const text = Number.isNaN(parsed) ? raw
|
|
11352
|
+
const text = Number.isNaN(parsed) ? clipText(raw, 80) : formatPostDate(parsed, format, lang);
|
|
11030
11353
|
const timeAttrs = Number.isNaN(parsed) ? attrs : { ...attrs, datetime: raw.slice(0, 80) };
|
|
11031
11354
|
return { tag: "time", attrs: timeAttrs, children: [text] };
|
|
11032
11355
|
}
|
|
@@ -11048,6 +11371,10 @@ var POST_FIELDS = new Map([
|
|
|
11048
11371
|
// ../emvb/src/core/render/form.ts
|
|
11049
11372
|
var INPUT_TYPES = new Set(["email", "tel", "url", "number", "date"]);
|
|
11050
11373
|
var LENGTH_TYPES = new Set(["text", "email", "tel", "url", "textarea"]);
|
|
11374
|
+
var CONDITION_OPS = new Set(["eq", "neq", "filled", "empty"]);
|
|
11375
|
+
|
|
11376
|
+
// ../emvb/src/core/render/section.ts
|
|
11377
|
+
var sizes = new WeakMap;
|
|
11051
11378
|
|
|
11052
11379
|
// ../emvb/src/core/sanitize/escape.ts
|
|
11053
11380
|
var TEXT_ENTITIES = { "&": "&", "<": "<", ">": ">" };
|
|
@@ -11171,8 +11498,59 @@ var FORMS_RUNTIME_ATTRS = new Set([
|
|
|
11171
11498
|
"data-submit-label",
|
|
11172
11499
|
"data-was-required"
|
|
11173
11500
|
]);
|
|
11501
|
+
function childrenOf(node) {
|
|
11502
|
+
return "children" in node && Array.isArray(node.children) ? node.children : [];
|
|
11503
|
+
}
|
|
11504
|
+
var ALWAYS_INTERACTIVE = new Set([
|
|
11505
|
+
"link",
|
|
11506
|
+
"post-link",
|
|
11507
|
+
"button",
|
|
11508
|
+
"menu",
|
|
11509
|
+
"menu-item",
|
|
11510
|
+
"accordion",
|
|
11511
|
+
"accordion-item",
|
|
11512
|
+
"tabs",
|
|
11513
|
+
"video",
|
|
11514
|
+
"form",
|
|
11515
|
+
"text-input",
|
|
11516
|
+
"textarea",
|
|
11517
|
+
"select",
|
|
11518
|
+
"checkbox",
|
|
11519
|
+
"radio",
|
|
11520
|
+
"submit",
|
|
11521
|
+
"pagination",
|
|
11522
|
+
"toc",
|
|
11523
|
+
"post-content"
|
|
11524
|
+
]);
|
|
11525
|
+
function containsInteractive(node) {
|
|
11526
|
+
if (ALWAYS_INTERACTIVE.has(node.type))
|
|
11527
|
+
return true;
|
|
11528
|
+
const props = node.props;
|
|
11529
|
+
if (node.type === "section" && typeof props.partId === "string" && props.partId.trim())
|
|
11530
|
+
return true;
|
|
11531
|
+
if (node.type === "loop" && typeof props.itemPartId === "string" && props.itemPartId.trim()) {
|
|
11532
|
+
return true;
|
|
11533
|
+
}
|
|
11534
|
+
if (BOX.has(node.type) || node.type === "heading" || node.type === "icon" || node.type === "image") {
|
|
11535
|
+
const href = node.props.href;
|
|
11536
|
+
if (typeof href === "string" && href.trim())
|
|
11537
|
+
return true;
|
|
11538
|
+
}
|
|
11539
|
+
return childrenOf(node).some(containsInteractive);
|
|
11540
|
+
}
|
|
11541
|
+
function boxBecomesLink(node) {
|
|
11542
|
+
if (!BOX.has(node.type))
|
|
11543
|
+
return false;
|
|
11544
|
+
const { href, tag } = node.props;
|
|
11545
|
+
if (tag !== undefined && tag !== "div")
|
|
11546
|
+
return false;
|
|
11547
|
+
if (typeof href !== "string" || !href.trim() || !sanitizeHref(href))
|
|
11548
|
+
return false;
|
|
11549
|
+
return !childrenOf(node).some(containsInteractive);
|
|
11550
|
+
}
|
|
11174
11551
|
// ../emvb/src/core/render/index.ts
|
|
11175
11552
|
var FIELD_TYPES2 = new Set(FORM_FIELD_TYPES.filter((type) => type !== "submit"));
|
|
11553
|
+
var MAX_SECTION_ELEMENTS = 20 * MAX_NODES;
|
|
11176
11554
|
// ../emvb/src/core/design/transfer.ts
|
|
11177
11555
|
var MAX_DESIGN_FILE_BYTES = 1024 * 1024;
|
|
11178
11556
|
// ../emvb/src/core/sanitize/svg-upload.ts
|
|
@@ -11235,7 +11613,7 @@ var ConditionsDocSchema = strictObject({
|
|
|
11235
11613
|
// ../emvb/src/core/theme/triggers.ts
|
|
11236
11614
|
var TRIGGERS_SCHEMA_VERSION = 1;
|
|
11237
11615
|
var MAX_POPUP_TRIGGERS = 8;
|
|
11238
|
-
var MAX_CLICK_SELECTOR_LENGTH =
|
|
11616
|
+
var MAX_CLICK_SELECTOR_LENGTH = TRIGGER_LIMITS.maxClickSelectorLength;
|
|
11239
11617
|
var MAX_SHOW_TIMES = 100;
|
|
11240
11618
|
var PageLoadTrigger = strictObject({ type: literal("page_load") });
|
|
11241
11619
|
var DelayTrigger = strictObject({
|
|
@@ -11279,7 +11657,7 @@ var POPUP_CHROME_CSS = `
|
|
|
11279
11657
|
.emvb-popup[hidden]{display:none!important}
|
|
11280
11658
|
.emvb-popup__backdrop{position:absolute;inset:0;background:rgba(15,23,42,.55)}
|
|
11281
11659
|
.emvb-popup__dialog{position:relative;z-index:1;max-width:min(36rem,100%);max-height:min(90vh,100%);overflow:auto;background:#fff;color:#0f172a;border-radius:.75rem;box-shadow:0 25px 50px -12px rgba(0,0,0,.35);padding:1.5rem 1.5rem 1.25rem}
|
|
11282
|
-
.emvb-popup__close{position:
|
|
11660
|
+
.emvb-popup__close{position:sticky;top:-1rem;z-index:1;float:right;margin:-1rem -1rem 0 .5rem;width:2rem;height:2rem;border:0;border-radius:999px;background:inherit;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
|
|
11283
11661
|
.emvb-popup__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
|
|
11284
11662
|
.emvb-popup__content{min-width:12rem}
|
|
11285
11663
|
`.replace(/\n+/g, "").trim();
|
|
@@ -11310,12 +11688,15 @@ var FLOAT_CHROME_CSS = `
|
|
|
11310
11688
|
:where(.emvb-float--surface){background:#fff;color:#0f172a;box-shadow:0 4px 16px -4px rgba(15,23,42,.25);padding:.5rem 1rem}
|
|
11311
11689
|
:where(.emvb-float--surface:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom)){border-radius:.75rem;padding:.75rem 1rem}
|
|
11312
11690
|
.emvb-float__body{min-width:0;flex:1}
|
|
11691
|
+
.emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom){max-width:calc(100% - 2rem)}
|
|
11692
|
+
.emvb-float:is(.emvb-float--start-top,.emvb-float--end-top,.emvb-float--start-bottom,.emvb-float--end-bottom) .emvb-float__body{max-height:calc(100vh - 3.5rem);max-height:calc(100dvh - 3.5rem);overflow:auto}
|
|
11313
11693
|
.emvb-float__close{flex:none;width:2rem;height:2rem;border:0;border-radius:999px;background:transparent;color:inherit;font-size:1.5rem;line-height:1;cursor:pointer}
|
|
11314
11694
|
.emvb-float__close:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
|
|
11315
|
-
html{--emvb-float-top:0px;--emvb-float-bottom:0px}
|
|
11695
|
+
html{--emvb-float-top:0px;--emvb-float-bottom:0px;scroll-padding-top:var(--emvb-float-top);scroll-padding-bottom:var(--emvb-float-bottom)}
|
|
11316
11696
|
body{padding-top:var(--emvb-float-top);padding-bottom:var(--emvb-float-bottom)}
|
|
11317
11697
|
`.replace(/\n+/g, "").trim();
|
|
11318
11698
|
// ../emvb/src/core/a11y/audit.ts
|
|
11699
|
+
var spoken = (value) => String(value ?? "").replace(/[\p{Cf}\u115F\u1160\u2800\u3164\uFFA0]/gu, "").trim();
|
|
11319
11700
|
var WEIGHT = { error: 12, warning: 4 };
|
|
11320
11701
|
var USELESS_ALT = /^(?:image|img|photo|picture|graphic|logo|icon|untitled|\s*)$|\.(?:jpe?g|png|gif|webp|avif|svg)$|^(?:img|dsc|pxl|screen ?shot|whatsapp image)[\s_-]?\d+/i;
|
|
11321
11702
|
var VAGUE = /^(?:click here|here|read more|more|learn more|link|this|go|see more|view more|more info(?:rmation)?|details|find out more|continue reading|read more here|click here to (?:read|learn) more)\s*[.!…:»›→>\u2192\u203a\u00bb-]*$/i;
|
|
@@ -11369,7 +11750,13 @@ var TEXT_TYPES = new Set([
|
|
|
11369
11750
|
]);
|
|
11370
11751
|
var FIELD_TYPES3 = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
|
|
11371
11752
|
var LINKISH = new Set(["link", "button", "menu-item"]);
|
|
11372
|
-
function px(value) {
|
|
11753
|
+
function px(value, design) {
|
|
11754
|
+
if (design && value && typeof value === "object" && "var" in value) {
|
|
11755
|
+
const found = design.variables.fontSizes?.find((v) => v.id === value.var);
|
|
11756
|
+
if (!found)
|
|
11757
|
+
return;
|
|
11758
|
+
return found.fluid ? Math.min(found.fluid.min, found.fluid.max) : px(found.value);
|
|
11759
|
+
}
|
|
11373
11760
|
if (!value || typeof value !== "object" || !("unit" in value))
|
|
11374
11761
|
return;
|
|
11375
11762
|
const v = value;
|
|
@@ -11379,12 +11766,39 @@ function px(value) {
|
|
|
11379
11766
|
return v.value * 16;
|
|
11380
11767
|
return;
|
|
11381
11768
|
}
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11769
|
+
var HEADING_PX = [32, 24, 18.72, 16, 13.28, 10.72];
|
|
11770
|
+
var headingLevel = (node) => {
|
|
11771
|
+
if (node.type !== "heading")
|
|
11772
|
+
return;
|
|
11773
|
+
const level = node.props.level;
|
|
11774
|
+
return typeof level === "number" && level >= 1 && level <= 6 ? level : 2;
|
|
11775
|
+
};
|
|
11776
|
+
function effectiveStyle(node, design) {
|
|
11777
|
+
const level = headingLevel(node);
|
|
11778
|
+
const tagDefaults = level === undefined ? undefined : design.defaults?.[`h${level}`];
|
|
11779
|
+
const classIds = new Set(node.classes ?? []);
|
|
11780
|
+
if (classIds.size === 0 && !tagDefaults)
|
|
11781
|
+
return node.style;
|
|
11782
|
+
const fromClasses = (design.classes ?? []).filter((c) => classIds.has(c.id)).reduce((acc, c) => Object.assign(acc, c.style), { ...tagDefaults });
|
|
11783
|
+
return { ...fromClasses, ...node.style };
|
|
11784
|
+
}
|
|
11785
|
+
function largeText(node, design) {
|
|
11786
|
+
const style = effectiveStyle(node, design);
|
|
11787
|
+
const level = headingLevel(node);
|
|
11788
|
+
const size = px(style?.fontSize, design) ?? (level === undefined ? 16 : HEADING_PX[level - 1] ?? 24);
|
|
11385
11789
|
const weight = typeof style?.fontWeight === "number" ? style.fontWeight : node.type === "heading" ? 700 : 400;
|
|
11386
11790
|
return size >= 24 || size >= 18.66 && weight >= 700;
|
|
11387
11791
|
}
|
|
11792
|
+
function boxHasName(node) {
|
|
11793
|
+
if (node.bind || node.type.startsWith("post-") || node.type === "loop" || node.type === "section")
|
|
11794
|
+
return true;
|
|
11795
|
+
const props = node.props;
|
|
11796
|
+
const decorative = props["decorative"] === true;
|
|
11797
|
+
const named = node.type === "image" || node.type === "icon" || node.type === "svg" ? !decorative && spoken(node.type === "image" ? props["alt"] : props["title"]) !== "" : ["text", "title", "label", "summary", "caption"].some((key) => spoken(props[key]) !== "");
|
|
11798
|
+
if (named)
|
|
11799
|
+
return true;
|
|
11800
|
+
return isParentNode(node) && node.children.some(boxHasName);
|
|
11801
|
+
}
|
|
11388
11802
|
function auditPage(layout, design) {
|
|
11389
11803
|
const issues = [];
|
|
11390
11804
|
const add = (issue) => issues.push({ ...issue, id: `${issue.rule}:${issue.nodeId}` });
|
|
@@ -11408,7 +11822,7 @@ function auditPage(layout, design) {
|
|
|
11408
11822
|
if (before)
|
|
11409
11823
|
[h1s, lastLevel] = [[...before[0]], before[1]];
|
|
11410
11824
|
const outerFade = fade;
|
|
11411
|
-
const opacity = node
|
|
11825
|
+
const opacity = effectiveStyle(node, design)?.opacity;
|
|
11412
11826
|
if (typeof opacity === "number" && opacity >= 0 && opacity < 1)
|
|
11413
11827
|
fade *= opacity;
|
|
11414
11828
|
const outerShown = shownOn;
|
|
@@ -11424,8 +11838,9 @@ function auditPage(layout, design) {
|
|
|
11424
11838
|
};
|
|
11425
11839
|
const visitNode = (node, bg, color) => {
|
|
11426
11840
|
const props = node.props;
|
|
11427
|
-
const style = node
|
|
11428
|
-
const
|
|
11841
|
+
const style = effectiveStyle(node, design);
|
|
11842
|
+
const covered = style?.backgroundImage || style?.backgroundVideo || style?.gradient;
|
|
11843
|
+
const ownBg = covered ? "unknown" : hexOf(style?.backgroundColor, design);
|
|
11429
11844
|
const nextBg = ownBg && ownBg !== "unknown" && bg && bg !== "unknown" ? over(ownBg, bg) : ownBg ?? bg;
|
|
11430
11845
|
const nextColor = hexOf(style?.color, design) ?? color;
|
|
11431
11846
|
const imageLinked = node.type === "image" && typeof props["href"] === "string" && props["href"].trim() !== "";
|
|
@@ -11437,17 +11852,39 @@ function auditPage(layout, design) {
|
|
|
11437
11852
|
message: "This image is a link but is marked decorative, so the link has no name."
|
|
11438
11853
|
});
|
|
11439
11854
|
} else if (node.type === "image" && props["decorative"] !== true) {
|
|
11440
|
-
const alt = typeof props["alt"] === "string" ? props["alt"]
|
|
11855
|
+
const alt = typeof props["alt"] === "string" ? spoken(props["alt"]) : "";
|
|
11441
11856
|
if (USELESS_ALT.test(alt)) {
|
|
11442
11857
|
add({
|
|
11443
11858
|
nodeId: node.id,
|
|
11444
11859
|
rule: "image-alt",
|
|
11445
11860
|
severity: "error",
|
|
11446
|
-
message: alt ? `The alt text "${alt
|
|
11861
|
+
message: alt ? `The alt text "${clipText(alt, 40)}" doesn't describe the image.` : "This image has no alt text.",
|
|
11447
11862
|
...imageLinked ? {} : { fix: { kind: "decorative" }, fixLabel: "Mark as decorative" }
|
|
11448
11863
|
});
|
|
11449
11864
|
}
|
|
11450
11865
|
}
|
|
11866
|
+
if (node.type === "svg" && props["decorative"] !== true && !spoken(props["title"]) && !/<title\b[^>]*>\s*[^<\s]/i.test(String(props["markup"] ?? ""))) {
|
|
11867
|
+
add({
|
|
11868
|
+
nodeId: node.id,
|
|
11869
|
+
rule: "image-alt",
|
|
11870
|
+
severity: "error",
|
|
11871
|
+
message: "This SVG has no title, so screen readers can't say what it shows.",
|
|
11872
|
+
fix: { kind: "decorative" },
|
|
11873
|
+
fixLabel: "Mark as decorative"
|
|
11874
|
+
});
|
|
11875
|
+
}
|
|
11876
|
+
const looping = [node.style, ...Object.values(node.devices ?? {})].some((st) => {
|
|
11877
|
+
const anim = st?.iconAnimation;
|
|
11878
|
+
return anim?.type === "spin" || anim?.type === "pulse";
|
|
11879
|
+
});
|
|
11880
|
+
if (looping) {
|
|
11881
|
+
add({
|
|
11882
|
+
nodeId: node.id,
|
|
11883
|
+
rule: "motion",
|
|
11884
|
+
severity: "warning",
|
|
11885
|
+
message: "This icon animates without end and visitors can't pause it. Keep it only if the motion is essential, such as a loading spinner."
|
|
11886
|
+
});
|
|
11887
|
+
}
|
|
11451
11888
|
if (node.type === "image" && Array.isArray(props["sources"]) && props["sources"].length > 0) {
|
|
11452
11889
|
const width = props["width"];
|
|
11453
11890
|
const widthSet = typeof width === "number" && Number.isInteger(width) && width >= 1;
|
|
@@ -11469,12 +11906,12 @@ function auditPage(layout, design) {
|
|
|
11469
11906
|
message: "This image link opens a new tab without saying so; say so in the alt text."
|
|
11470
11907
|
});
|
|
11471
11908
|
}
|
|
11472
|
-
if (FIELD_TYPES3.has(node.type) && !
|
|
11909
|
+
if (FIELD_TYPES3.has(node.type) && !spoken(props["label"]) && !node.bind) {
|
|
11473
11910
|
add({
|
|
11474
11911
|
nodeId: node.id,
|
|
11475
11912
|
rule: "control-name",
|
|
11476
11913
|
severity: "error",
|
|
11477
|
-
message:
|
|
11914
|
+
message: spoken(props["placeholder"]) ? "This field has only a placeholder, which disappears once you type; give it a label." : "This field has no label, so screen readers can't say what it's for."
|
|
11478
11915
|
});
|
|
11479
11916
|
}
|
|
11480
11917
|
const NAME_PROP = {
|
|
@@ -11483,7 +11920,7 @@ function auditPage(layout, design) {
|
|
|
11483
11920
|
video: "title"
|
|
11484
11921
|
};
|
|
11485
11922
|
if (node.type === "tab-panel" || node.type === "accordion-item" || node.type === "video") {
|
|
11486
|
-
const name =
|
|
11923
|
+
const name = spoken(props[NAME_PROP[node.type]]);
|
|
11487
11924
|
if (!name && !node.bind) {
|
|
11488
11925
|
add({
|
|
11489
11926
|
nodeId: node.id,
|
|
@@ -11494,7 +11931,7 @@ function auditPage(layout, design) {
|
|
|
11494
11931
|
}
|
|
11495
11932
|
}
|
|
11496
11933
|
if (node.type === "menu" && (node.children?.length ?? 0) > 0) {
|
|
11497
|
-
const name =
|
|
11934
|
+
const name = spoken(props["label"]) || "Menu";
|
|
11498
11935
|
const key = name.toLowerCase();
|
|
11499
11936
|
if (menuNames.some((names, i) => shownOn[i] && names.has(key))) {
|
|
11500
11937
|
add({
|
|
@@ -11509,7 +11946,7 @@ function auditPage(layout, design) {
|
|
|
11509
11946
|
names.add(key);
|
|
11510
11947
|
});
|
|
11511
11948
|
}
|
|
11512
|
-
if (node.type === "heading" && !
|
|
11949
|
+
if (node.type === "heading" && !spoken(props["text"]) && !node.bind) {
|
|
11513
11950
|
add({
|
|
11514
11951
|
nodeId: node.id,
|
|
11515
11952
|
rule: "empty-heading",
|
|
@@ -11544,8 +11981,16 @@ function auditPage(layout, design) {
|
|
|
11544
11981
|
}
|
|
11545
11982
|
lastLevel = level;
|
|
11546
11983
|
}
|
|
11984
|
+
if (boxBecomesLink(node) && !boxHasName(node)) {
|
|
11985
|
+
add({
|
|
11986
|
+
nodeId: node.id,
|
|
11987
|
+
rule: "link-name",
|
|
11988
|
+
severity: "error",
|
|
11989
|
+
message: "This box is a link, but nothing inside it has text, so the link has no name."
|
|
11990
|
+
});
|
|
11991
|
+
}
|
|
11547
11992
|
if (LINKISH.has(node.type) || node.type === "icon" && props["href"]) {
|
|
11548
|
-
const text =
|
|
11993
|
+
const text = spoken(props["text"] ?? props["title"]);
|
|
11549
11994
|
const hasHref = typeof props["href"] === "string" && props["href"].trim() !== "";
|
|
11550
11995
|
if (!text && !node.bind) {
|
|
11551
11996
|
add({
|
|
@@ -11573,17 +12018,18 @@ function auditPage(layout, design) {
|
|
|
11573
12018
|
}
|
|
11574
12019
|
if (TEXT_TYPES.has(node.type) && nextColor && nextBg && nextBg !== "unknown") {
|
|
11575
12020
|
const ratio = contrastRatio(over(nextColor, nextBg, fade), nextBg);
|
|
11576
|
-
const needed = largeText(node) ? 3 : 4.5;
|
|
12021
|
+
const needed = largeText(node, design) ? 3 : 4.5;
|
|
11577
12022
|
if (ratio < needed) {
|
|
11578
12023
|
const black = contrastRatio("#000000", nextBg);
|
|
11579
12024
|
const white = contrastRatio("#ffffff", nextBg);
|
|
11580
12025
|
const better = black >= white ? "#111111" : "#ffffff";
|
|
11581
12026
|
const fixable = contrastRatio(over(better, nextBg, fade), nextBg) >= needed;
|
|
12027
|
+
const shown = (Math.floor(ratio * 10) / 10).toFixed(1);
|
|
11582
12028
|
add({
|
|
11583
12029
|
nodeId: node.id,
|
|
11584
12030
|
rule: "contrast",
|
|
11585
12031
|
severity: "error",
|
|
11586
|
-
message: fixable ? `Text contrast is ${
|
|
12032
|
+
message: fixable ? `Text contrast is ${shown}:1; it needs ${needed}:1.` : `Text contrast is ${shown}:1; it needs ${needed}:1. Opacity on this element or a parent fades it; raise the opacity.`,
|
|
11587
12033
|
...fixable ? {
|
|
11588
12034
|
fix: { kind: "text-color", color: better },
|
|
11589
12035
|
fixLabel: better === "#ffffff" ? "Use white text" : "Use dark text"
|
|
@@ -11591,7 +12037,7 @@ function auditPage(layout, design) {
|
|
|
11591
12037
|
});
|
|
11592
12038
|
}
|
|
11593
12039
|
}
|
|
11594
|
-
const focusable = LINKISH.has(node.type) || node.type === "
|
|
12040
|
+
const focusable = LINKISH.has(node.type) || FIELD_TYPES3.has(node.type) || node.type === "submit" || Boolean(props["href"]);
|
|
11595
12041
|
const ownAriaHidden = (node.attributes ?? []).some((a) => a.name === "aria-hidden" && a.value === "true");
|
|
11596
12042
|
if (focusable && ownAriaHidden) {
|
|
11597
12043
|
add({
|
|
@@ -11696,8 +12142,10 @@ function siteTokens(design) {
|
|
|
11696
12142
|
const onAccent = color(pick2(others, /on[- ]?(primary|brand|accent)|inverse|white/));
|
|
11697
12143
|
if (onAccent)
|
|
11698
12144
|
tokens.onAccent = onAccent;
|
|
11699
|
-
else if (accentVar && /^#[0-9a-f]{6}$/i.test(accentVar.value)) {
|
|
11700
|
-
|
|
12145
|
+
else if (accentVar && /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(accentVar.value)) {
|
|
12146
|
+
const h = accentVar.value.slice(1);
|
|
12147
|
+
const hex = `#${(h.length <= 4 ? [...h].map((c) => c + c).join("") : h).slice(0, 6)}`;
|
|
12148
|
+
tokens.onAccent = contrastRatio(hex, "#ffffff") >= contrastRatio(hex, "#111111") ? "#ffffff" : "#111111";
|
|
11701
12149
|
}
|
|
11702
12150
|
const buttonCls = pick2(design.classes, /\b(button|btn)\b/, /cta/);
|
|
11703
12151
|
if (buttonCls) {
|
|
@@ -11993,7 +12441,7 @@ function summaryText(node) {
|
|
|
11993
12441
|
const text = typeof props["text"] === "string" ? props["text"] : undefined;
|
|
11994
12442
|
if (!text)
|
|
11995
12443
|
return;
|
|
11996
|
-
return text.length > 60 ? `${text
|
|
12444
|
+
return text.length > 60 ? `${clipText(text, 57)}…` : text;
|
|
11997
12445
|
}
|
|
11998
12446
|
function stats(layout) {
|
|
11999
12447
|
let nodes = 0;
|
|
@@ -12318,13 +12766,18 @@ var ListVersionsInput = strictObject({
|
|
|
12318
12766
|
var ListVersionsOutput = object({
|
|
12319
12767
|
versions: array(object({ revisionId: string2(), at: string2(), authorId: string2().nullable() }))
|
|
12320
12768
|
});
|
|
12769
|
+
var utcIso = (at) => /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d+)?$/.test(at) ? `${at.replace(" ", "T")}Z` : at;
|
|
12321
12770
|
async function listVersions(ports, input) {
|
|
12322
12771
|
const page = await ports.getPage(input.pageId);
|
|
12323
12772
|
if (!page)
|
|
12324
12773
|
throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}.`);
|
|
12325
12774
|
const revisions = await ports.listRevisions(input.pageId, input.limit ?? 20);
|
|
12326
12775
|
return {
|
|
12327
|
-
versions: revisions.map((r) => ({
|
|
12776
|
+
versions: revisions.map((r) => ({
|
|
12777
|
+
revisionId: r.id,
|
|
12778
|
+
at: utcIso(r.createdAt),
|
|
12779
|
+
authorId: r.authorId
|
|
12780
|
+
}))
|
|
12328
12781
|
};
|
|
12329
12782
|
}
|
|
12330
12783
|
|
|
@@ -12353,9 +12806,26 @@ var KINDS = [
|
|
|
12353
12806
|
["fontSizes", "fontSize"],
|
|
12354
12807
|
["spacings", "spacing"]
|
|
12355
12808
|
];
|
|
12809
|
+
function nestsDeeperThan(value, max) {
|
|
12810
|
+
const stack = [[value, 1]];
|
|
12811
|
+
while (stack.length > 0) {
|
|
12812
|
+
const [item, depth] = stack.pop();
|
|
12813
|
+
if (typeof item !== "object" || item === null)
|
|
12814
|
+
continue;
|
|
12815
|
+
if (depth > max)
|
|
12816
|
+
return true;
|
|
12817
|
+
for (const child of Object.values(item))
|
|
12818
|
+
stack.push([child, depth + 1]);
|
|
12819
|
+
}
|
|
12820
|
+
return false;
|
|
12821
|
+
}
|
|
12822
|
+
var MAX_INPUT_NESTING = 256;
|
|
12356
12823
|
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
12357
12824
|
var isRef = (v) => typeof v["var"] === "string" && Object.keys(v).every((k) => k === "var" || k === "from");
|
|
12358
12825
|
function resolveDesignRefs(value, design) {
|
|
12826
|
+
if (nestsDeeperThan(value, MAX_INPUT_NESTING)) {
|
|
12827
|
+
throw new McpToolError("INVALID_INPUT", "This input nests too deeply.");
|
|
12828
|
+
}
|
|
12359
12829
|
const kinds = new Map;
|
|
12360
12830
|
for (const [key, from] of KINDS) {
|
|
12361
12831
|
for (const v of design.variables[key] ?? [])
|
|
@@ -12455,7 +12925,12 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
|
|
|
12455
12925
|
}
|
|
12456
12926
|
const next = apply(current.layout);
|
|
12457
12927
|
refuseUnsafeImageSources(current.layout, next.layout);
|
|
12928
|
+
refuseUnsafeLinks(current.layout, next.layout);
|
|
12929
|
+
refuseUnsafeSvg(current.layout, next.layout);
|
|
12458
12930
|
const layout = checkLayout(next.layout);
|
|
12931
|
+
if (stableJson(layout) === stableJson(current.layout)) {
|
|
12932
|
+
return { pageId, rev: page.rev, changed: [], summary: `Nothing changed (${tool})` };
|
|
12933
|
+
}
|
|
12459
12934
|
try {
|
|
12460
12935
|
const saved = await ports.savePage(pageId, { layout }, page.rev);
|
|
12461
12936
|
await ports.log({
|
|
@@ -12478,11 +12953,61 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
|
|
|
12478
12953
|
var refused = (reason) => {
|
|
12479
12954
|
throw new McpToolError("REFUSED", reason);
|
|
12480
12955
|
};
|
|
12956
|
+
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
12957
|
+
var propsOf = (node) => isRecord3(node.props) ? node.props : {};
|
|
12958
|
+
function linkValues(root) {
|
|
12959
|
+
const found = new Map;
|
|
12960
|
+
const walk = (node) => {
|
|
12961
|
+
const fields = ELEMENT_DESCRIPTORS.find((d) => d.type === node.type)?.fields ?? [];
|
|
12962
|
+
const props = propsOf(node);
|
|
12963
|
+
for (const field of fields) {
|
|
12964
|
+
const value = props[field.key];
|
|
12965
|
+
if (field.kind === "href" && typeof value === "string")
|
|
12966
|
+
found.set(`${node.id}.${field.key}`, value);
|
|
12967
|
+
}
|
|
12968
|
+
for (const child of nodeChildren(node))
|
|
12969
|
+
walk(child);
|
|
12970
|
+
};
|
|
12971
|
+
walk(root);
|
|
12972
|
+
return found;
|
|
12973
|
+
}
|
|
12974
|
+
function refuseUnsafeLinks(before, after) {
|
|
12975
|
+
const old = linkValues(before.root);
|
|
12976
|
+
for (const [key, href] of linkValues(after.root)) {
|
|
12977
|
+
if (href.trim() === "" || old.get(key) === href || sanitizeHref(href) !== undefined)
|
|
12978
|
+
continue;
|
|
12979
|
+
const [id, prop] = key.split(".");
|
|
12980
|
+
refused(`Element ${id} has the ${prop} ${JSON.stringify(clipText(href, 80))}, which pages can't link to. Use an https:// URL, a path on this site such as /pricing, #section, mailto: or tel:.`);
|
|
12981
|
+
}
|
|
12982
|
+
}
|
|
12983
|
+
function svgValues(root) {
|
|
12984
|
+
const found = new Map;
|
|
12985
|
+
const walk = (node) => {
|
|
12986
|
+
const props = propsOf(node);
|
|
12987
|
+
if (node.type === "svg" && typeof props["markup"] === "string")
|
|
12988
|
+
found.set(`${node.id}.markup`, props["markup"]);
|
|
12989
|
+
if (typeof props["iconSvg"] === "string")
|
|
12990
|
+
found.set(`${node.id}.iconSvg`, props["iconSvg"]);
|
|
12991
|
+
for (const child of nodeChildren(node))
|
|
12992
|
+
walk(child);
|
|
12993
|
+
};
|
|
12994
|
+
walk(root);
|
|
12995
|
+
return found;
|
|
12996
|
+
}
|
|
12997
|
+
function refuseUnsafeSvg(before, after) {
|
|
12998
|
+
const old = svgValues(before.root);
|
|
12999
|
+
for (const [key, markup] of svgValues(after.root)) {
|
|
13000
|
+
if (markup.trim() === "" || old.get(key) === markup || isSafeSvgMarkup(markup))
|
|
13001
|
+
continue;
|
|
13002
|
+
const [id, prop] = key.split(".");
|
|
13003
|
+
refused(`Element ${id} has ${prop} the page can't show. Use plain SVG: no scripts, event handlers such as onload, foreignObject, style blocks, links or external images.`);
|
|
13004
|
+
}
|
|
13005
|
+
}
|
|
12481
13006
|
function imageSources2(root) {
|
|
12482
13007
|
const found = new Map;
|
|
12483
13008
|
const walk = (node) => {
|
|
12484
13009
|
if (node.type === "image") {
|
|
12485
|
-
const props = node
|
|
13010
|
+
const props = propsOf(node);
|
|
12486
13011
|
const list = typeof props.src === "string" ? [props.src] : [];
|
|
12487
13012
|
if (Array.isArray(props.sources)) {
|
|
12488
13013
|
for (const source of props.sources) {
|
|
@@ -12515,6 +13040,17 @@ var ElementSpec = lazy(() => looseObject({
|
|
|
12515
13040
|
props: record(string2(), unknown()).optional(),
|
|
12516
13041
|
children: array(ElementSpec).max(200).optional()
|
|
12517
13042
|
}));
|
|
13043
|
+
var BoundedElementSpec = preprocess((value, ctx) => {
|
|
13044
|
+
if (nestsDeeperThan(value, MAX_DEPTH * 8)) {
|
|
13045
|
+
ctx.addIssue({
|
|
13046
|
+
code: "custom",
|
|
13047
|
+
message: `Elements can be nested at most ${MAX_DEPTH} levels deep.`,
|
|
13048
|
+
input: value
|
|
13049
|
+
});
|
|
13050
|
+
return NEVER;
|
|
13051
|
+
}
|
|
13052
|
+
return value;
|
|
13053
|
+
}, ElementSpec);
|
|
12518
13054
|
function buildNode(spec) {
|
|
12519
13055
|
if (!KNOWN_TYPES.has(spec.type)) {
|
|
12520
13056
|
refused(`Unknown element type ${spec.type}. Call list_element_types.`);
|
|
@@ -12544,8 +13080,20 @@ function promoteHeroHeading(layout, title) {
|
|
|
12544
13080
|
props: { ...node.props, text: title, level: 1 }
|
|
12545
13081
|
}));
|
|
12546
13082
|
}
|
|
13083
|
+
async function slugTaken(ports, slug) {
|
|
13084
|
+
let cursor;
|
|
13085
|
+
for (let i = 0;i < 20; i++) {
|
|
13086
|
+
const batch = await ports.listPages({ limit: 50, ...cursor ? { cursor } : {} });
|
|
13087
|
+
if (batch.pages.some((page) => page.slug === slug))
|
|
13088
|
+
return true;
|
|
13089
|
+
if (!batch.nextCursor)
|
|
13090
|
+
return false;
|
|
13091
|
+
cursor = batch.nextCursor;
|
|
13092
|
+
}
|
|
13093
|
+
return false;
|
|
13094
|
+
}
|
|
12547
13095
|
async function createPage(ports, input) {
|
|
12548
|
-
const slug =
|
|
13096
|
+
const slug = pageSlug(input.title);
|
|
12549
13097
|
if (!slug)
|
|
12550
13098
|
refused("Give the page a title with letters or digits.");
|
|
12551
13099
|
const { design } = await ports.getDesign();
|
|
@@ -12570,8 +13118,7 @@ async function createPage(ports, input) {
|
|
|
12570
13118
|
if (recipes[0] === "hero")
|
|
12571
13119
|
layout = promoteHeroHeading(layout, input.title);
|
|
12572
13120
|
const checked = checkLayout(layout);
|
|
12573
|
-
|
|
12574
|
-
if (taken.pages.some((page) => page.slug === slug)) {
|
|
13121
|
+
if (await slugTaken(ports, slug)) {
|
|
12575
13122
|
throw new McpToolError("REFUSED", `The slug "${slug}" is taken. Choose another title.`);
|
|
12576
13123
|
}
|
|
12577
13124
|
const created = await ports.createPage({ title: input.title, layout: checked });
|
|
@@ -12588,7 +13135,7 @@ var AddElementInput = strictObject({
|
|
|
12588
13135
|
pageId: PageId,
|
|
12589
13136
|
parentId: NodeIdInput,
|
|
12590
13137
|
index: number2().int().min(0).optional(),
|
|
12591
|
-
element:
|
|
13138
|
+
element: BoundedElementSpec,
|
|
12592
13139
|
expectedRev: Rev.optional()
|
|
12593
13140
|
});
|
|
12594
13141
|
async function addElement(ports, input) {
|
|
@@ -12646,7 +13193,6 @@ var UpdateElementInput = strictObject({
|
|
|
12646
13193
|
unset: array(string2().regex(/^[a-zA-Z]+(\.[a-zA-Z0-9_-]+)?$/)).max(50).optional(),
|
|
12647
13194
|
expectedRev: Rev.optional()
|
|
12648
13195
|
});
|
|
12649
|
-
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
12650
13196
|
function dropOldPictureProps(before, setProps, copy) {
|
|
12651
13197
|
if (typeof setProps.src !== "string" || setProps.src === before.src)
|
|
12652
13198
|
return;
|
|
@@ -12828,6 +13374,11 @@ async function updateSiteStyles(ports, input) {
|
|
|
12828
13374
|
}
|
|
12829
13375
|
const draft = structuredClone(state.design);
|
|
12830
13376
|
const changes = [];
|
|
13377
|
+
for (const font of input.variables?.fonts ?? []) {
|
|
13378
|
+
if (typeof font.value === "string" && !isSafeFontStack(font.value)) {
|
|
13379
|
+
throw new McpToolError("INVALID_INPUT", `Font ${String(font.id)}: "${font.value.slice(0, 60)}" can't be used in the site CSS. Use names of letters, digits, spaces, - and _, quoted or not, separated by commas.`);
|
|
13380
|
+
}
|
|
13381
|
+
}
|
|
12831
13382
|
for (const kind of VARIABLE_KINDS) {
|
|
12832
13383
|
const items = input.variables?.[kind];
|
|
12833
13384
|
if (items?.length) {
|
|
@@ -12835,6 +13386,13 @@ async function updateSiteStyles(ports, input) {
|
|
|
12835
13386
|
changes.push(`${items.length} ${kind}`);
|
|
12836
13387
|
}
|
|
12837
13388
|
}
|
|
13389
|
+
const unknown2 = [
|
|
13390
|
+
...(input.removeVariables ?? []).filter(({ kind, id }) => !(draft.variables[kind] ?? []).some((v) => v.id === id)).map(({ kind, id }) => `${kind} ${id}`),
|
|
13391
|
+
...(input.removeClasses ?? []).filter((id) => !(draft.classes ?? []).some((c) => c.id === id)).map((id) => `class ${id}`)
|
|
13392
|
+
];
|
|
13393
|
+
if (unknown2.length > 0) {
|
|
13394
|
+
throw new McpToolError("NOT_FOUND", `Nothing to remove for ${unknown2.join(", ")}. Call get_site_styles for the ids.`);
|
|
13395
|
+
}
|
|
12838
13396
|
if (!input.force && (input.removeVariables?.length || input.removeClasses?.length)) {
|
|
12839
13397
|
const layouts = await allLayouts(ports);
|
|
12840
13398
|
const inUse = [
|
|
@@ -12874,12 +13432,36 @@ async function updateSiteStyles(ports, input) {
|
|
|
12874
13432
|
draft["direction"] = input.direction;
|
|
12875
13433
|
changes.push(`direction ${input.direction}`);
|
|
12876
13434
|
}
|
|
13435
|
+
const clash = (list, touched, what) => {
|
|
13436
|
+
const ids = new Set((touched ?? []).map((item) => item.id));
|
|
13437
|
+
const seen = new Map;
|
|
13438
|
+
for (const item of list ?? []) {
|
|
13439
|
+
const name = item.name;
|
|
13440
|
+
if (typeof name !== "string")
|
|
13441
|
+
continue;
|
|
13442
|
+
const key = nameKey(name);
|
|
13443
|
+
const other = seen.get(key);
|
|
13444
|
+
if (other && (ids.has(item.id) || ids.has(other.id))) {
|
|
13445
|
+
const taken = String(other.name);
|
|
13446
|
+
throw new McpToolError("INVALID_INPUT", `${what} ${item.id} and ${other.id} would both be named "${taken}". Pick another name.`);
|
|
13447
|
+
}
|
|
13448
|
+
if (!other)
|
|
13449
|
+
seen.set(key, item);
|
|
13450
|
+
}
|
|
13451
|
+
};
|
|
13452
|
+
clash(draft.classes, input.classes, "Classes");
|
|
13453
|
+
for (const kind of VARIABLE_KINDS) {
|
|
13454
|
+
clash(draft.variables[kind], input.variables?.[kind], `Variables (${kind})`);
|
|
13455
|
+
}
|
|
12877
13456
|
if (changes.length === 0)
|
|
12878
13457
|
refused("Nothing to change.");
|
|
12879
13458
|
const result = validateDesign(draft);
|
|
12880
13459
|
if (!result.ok) {
|
|
12881
13460
|
throw new McpToolError("INVALID_INPUT", `The site styles would be invalid. ${summarizeIssues(result.issues)}`);
|
|
12882
13461
|
}
|
|
13462
|
+
if (stableJson(result.design) === stableJson(state.design) && state.revision) {
|
|
13463
|
+
return { revision: state.revision, summary: "Nothing changed in the site styles draft" };
|
|
13464
|
+
}
|
|
12883
13465
|
const saved = await ports.saveDesign(result.design, state.revision);
|
|
12884
13466
|
const summary = `Site styles draft: ${changes.join(", ")}`;
|
|
12885
13467
|
await ports.log({ target: "styles", tool: "update_site_styles", summary });
|
|
@@ -13173,7 +13755,7 @@ var PROMPTS = [
|
|
|
13173
13755
|
}
|
|
13174
13756
|
];
|
|
13175
13757
|
// src/bridge.ts
|
|
13176
|
-
var BRIDGE_VERSION = "0.
|
|
13758
|
+
var BRIDGE_VERSION = "0.7.0";
|
|
13177
13759
|
var failure = (message) => ({
|
|
13178
13760
|
content: [{ type: "text", text: message }],
|
|
13179
13761
|
isError: true
|