@eldrajs/theme-core 0.0.0 → 0.2.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +311 -0
  2. package/LICENSE +21 -0
  3. package/README.md +68 -1
  4. package/dist/bridge-CLi2P6Wh.js +314 -0
  5. package/dist/bridge.d.ts +2 -0
  6. package/dist/bridge.js +2 -0
  7. package/dist/design-tokens.d.ts +68 -0
  8. package/dist/design-tokens.js +486 -0
  9. package/dist/dynamic-route.d.ts +2 -0
  10. package/dist/dynamic-route.js +3 -0
  11. package/dist/dynamicRoute-CxXY-Y_8.js +126 -0
  12. package/dist/dynamicRoute-pRTBoYT6.d.ts +55 -0
  13. package/dist/i18n.d.ts +107 -0
  14. package/dist/i18n.js +192 -0
  15. package/dist/image-framing.d.ts +2 -0
  16. package/dist/image-framing.js +109 -0
  17. package/dist/imageFraming-BUZ-yqho.d.ts +51 -0
  18. package/dist/index-DxrkKyG4.d.ts +488 -0
  19. package/dist/index.d.ts +449 -0
  20. package/dist/index.js +1141 -0
  21. package/dist/layout-CWq_v6ws.d.ts +244 -0
  22. package/dist/layout.d.ts +2 -0
  23. package/dist/layout.js +930 -0
  24. package/dist/links.d.ts +113 -0
  25. package/dist/links.js +184 -0
  26. package/dist/overlay-Bgi0tIbN.d.ts +201 -0
  27. package/dist/overlay-C8-F1jzU.js +2908 -0
  28. package/dist/overlay.d.ts +2 -0
  29. package/dist/overlay.js +6 -0
  30. package/dist/preview-router.d.ts +2 -0
  31. package/dist/preview-router.js +130 -0
  32. package/dist/reusable.d.ts +66 -0
  33. package/dist/reusable.js +92 -0
  34. package/dist/reusableExpansion-Bqm83nCJ.js +229 -0
  35. package/dist/reusableExpansion-CXvs_ckx.d.ts +42 -0
  36. package/dist/stega.d.ts +17 -0
  37. package/dist/stega.js +69 -0
  38. package/dist/template-layout.d.ts +3 -0
  39. package/dist/template-layout.js +3 -0
  40. package/dist/templateLayout-CpZb6EEg.js +382 -0
  41. package/dist/templateLayout-MjNs0gbF.d.ts +254 -0
  42. package/package.json +89 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,311 @@
1
+ # @eldrajs/theme-core changelog
2
+
3
+ Hand-maintained: every change a consumer can see gets a line under Unreleased in the same change.
4
+ Release-please writes the generated notes from commit messages and does not replace this.
5
+
6
+ ## Unreleased
7
+
8
+ - New `themeId` helpers, framework-free: `blockApiIdOf(schemaApiId, themeId)` (the wire spelling
9
+ `<themeId>:<apiId>` to the bare block id, stripping only the given theme's own prefix, so
10
+ `catalog:product` and another theme's `starter:hero` pass through) and
11
+ `themeSchemaApiId(blockApiId, themeId)` (the reverse, idempotent), plus `THEME_ID_PATTERN`,
12
+ `RESERVED_THEME_IDS`, `registerThemeId`/`getRegisteredThemeId`. **Breaking:** `registerBlockFields(fields,
13
+ themeId)` now requires the theme's own id and registers it, so `isBlockFieldLocalized`,
14
+ `isBlockFieldSelect` (and the select unwrap and stega skip that use it) and a template block's
15
+ entry/placement match resolve a block entry whose `schemaApiId` is `<themeId>:<apiId>`. Bare ids
16
+ keep working. The bridge's `theme:ready` reports `manifestVersion: 2`.
17
+
18
+ - New subpath, `@eldrajs/theme-core/i18n`, framework-free: `flattenMessages`/`unflattenMessages`
19
+ (nested vue-i18n JSON ↔ the manifest's own flat dotted keys), `mergeMessageCatalogues(themeDefaults,
20
+ platform)` (the platform's theme-message overrides win per key; a locale the theme never shipped
21
+ is added whole), and `resolveMessageCatalogue(themeDefaults, platform, orgLocales,
22
+ orgDefaultLocale)`, implementing the contract's five-tier per-key fallback to the letter — tier 5
23
+ (`theme(themeDefault)`) always reads the theme's own unmerged default-locale text, never an
24
+ override of it, which is why `themeDefaults` and `platform` are taken separately rather than only
25
+ a pre-merged catalogue — so a build with **no** gateway still produces a full key set for every
26
+ organisation locale from the manifest alone. `isForbiddenLocaleTag`/`sanitizeLocaleMessages` guard
27
+ an untrusted locale tag (`__proto__`/`prototype`/`constructor`) against corrupting an object's
28
+ prototype, shared by every caller instead of each re-implementing the check. `ThemeMessages` and
29
+ the fallback constant `EMPTY_THEME_MESSAGES` are exported types/values. `@eldrajs/theme-nuxt`'s
30
+ module is the one caller today; the starter's `vue-i18n` wiring is next.
31
+
32
+ - `@eldrajs/theme-core/bridge`'s `BridgePayloads` gains `editor:theme-messages`
33
+ (`{ revision, locales }`, `ResolvedThemeMessagesPayload`): a theme-message override save from
34
+ Studio's "Theme texts" page, handled the same way `editor:design-tokens` is.
35
+
36
+ - **A `link` field's untranslated sub-fields fall back to the default locale's node, field by
37
+ field.** A `link` field's value is a per-locale record (`{ "en-US": {kind,label,group,children…},
38
+ "is-IS": {…} }`), and `createEldraClient` used to take the active locale's node whole (exact
39
+ locale, then language, then the first key) — a column heading set only on the English node
40
+ rendered as no heading at all on every other locale. `createEldraClient` now takes
41
+ `defaultLocale?: string | null` (the organisation's default content locale); when set and the
42
+ default locale's node exists and differs from the chosen one, each field the chosen node leaves
43
+ untranslated (missing, `null`, an empty or whitespace-only string, an empty array or object, or a
44
+ rich-text document with no text) is filled from the default node's value for that field, applied
45
+ recursively — a `children` array that is missing or empty takes the default's whole array, and two
46
+ arrays of the same length merge position by position (the platform's link control mirrors the
47
+ tree across locales, so position n is the same link in both); different lengths keep the active
48
+ locale's own list. `undefined`/omitted (the default) disables the fallback entirely: today's
49
+ behaviour, unchanged. Exported `isTranslatedValue` mirrors the gateway's own rule for a
50
+ localization row, so a theme that needs the same "is this field translated" check has one
51
+ definition to call rather than a second copy that can drift. **This is a minor**: the fallback is
52
+ a repair, but `defaultLocale` is a new public option.
53
+
54
+ - **A gateway read that answered `429` or `503` is retried instead of failing.** The gateway
55
+ rate-limits a client by requests per minute, which a static build of a real site meets routinely:
56
+ `429 too many requests; slow down and try again` used to surface as a failed route resolution and,
57
+ under `nitro.prerender.failOnError`, as a failed build. `createEldraClient` now repeats an
58
+ **idempotent** request (`GET`/`HEAD`/`OPTIONS` — a `POST` that timed out may well have been
59
+ applied) that answered `429` or `503`, and one whose connection dropped (`fetch failed`,
60
+ `ECONNRESET` and the rest), honouring `Retry-After` in seconds or as an HTTP-date (up to a minute)
61
+ and otherwise waiting `250 ms × 2^attempt` capped at 5 s with jitter, for at most five attempts
62
+ including the first. Configurable as `retry: { attempts, baseDelayMs, maxDelayMs }` on
63
+ `createEldraClient`; `{ attempts: 0 }` is one request and no waiting. Every other status is
64
+ unchanged — a `404` is still a `404` on the first answer, and a preview `401` still reaches
65
+ `onRequestError` immediately, so the editor's preview-token recovery is untouched. A caller's
66
+ `AbortSignal` ends a retry during the wait as well as during the request, rejecting with the
67
+ signal's own reason. A dropped connection is told apart from a **malformed** request by the shape
68
+ `fetch` reports (a known network message, or a retryable `code` on the error or its `cause`): an
69
+ unparseable URL, an invalid header name or a `GET` with a body fails on the first attempt, because
70
+ repeating it can only fail the same way. **This is a minor**: the behaviour is a repair, but
71
+ `retry` is a new public option and `EldraRetryOptions` a new exported type.
72
+
73
+ - **A route template's trailing parameter may be a catch-all: `/categories/:path*`.** It must be the
74
+ last segment, it matches **one or more** segments, and the parameter's value is the remainder
75
+ joined with `/` and no leading slash (`/categories/billinn/bilstolar` → `path:
76
+ "billinn/bilstolar"`). `parseDynamicRoutePattern` reports it as `catchAll: true` and keeps the star
77
+ out of `paramName`, so a template's own `slugField` is still compared against `path`;
78
+ `matchDynamicRoutePattern`/`resolveRoute` match it, and `buildDynamicRoutePath` encodes each
79
+ segment of such a value while keeping the separators (and refuses an empty one — a leading,
80
+ trailing or doubled slash is not a canonical path). Existing single-segment patterns are unchanged,
81
+ and `*` stays forbidden everywhere else: in a static prefix, doubled, or anywhere but immediately
82
+ after the final parameter's name.
83
+ - `catalogRouteTarget` recognises `catalog:category` as the `category` kind, beside `catalog:product`
84
+ and `catalog:collection`.
85
+ - **`catalog.listCategories` answers the categories again.** `GET /catalog/v1/categories` serves the
86
+ whole tree as a top-level **array** rather than a `{data, meta}` page — it takes no paging — and
87
+ the list normaliser read that as "an object with no `data`", so every category read came back
88
+ empty: a `link` field pointing at a category resolved to nothing, and a build generated no
89
+ category routes, with no error anywhere to say so. A bare array is now read as the list itself,
90
+ reported as one whole final page. The two paged endpoints are unchanged: they answer an object,
91
+ and an object must still carry an array under `data` or the read throws.
92
+ - `LinkTargetInfo` gains an optional `path` — a target's canonical path **inside** the route
93
+ template's prefix, without a leading slash. `resolveLink` reads it instead of `slug` when the
94
+ serving template's pattern is a catch-all, because such a route is canonical-only: a leaf slug on
95
+ its own would build a path the site answers with its not-found shell. A target under a catch-all
96
+ pattern that carries no `path` therefore resolves to **no href**, which a theme renders as plain
97
+ text rather than as a link that 404s.
98
+
99
+ - A page layout's `block` node may carry `locked: true` — the platform sets it on a node created
100
+ from a theme's `pageSeeds[].blocks[].required`, and it is stored on the node. The layout validator
101
+ used to fail the whole document on it as an unknown key, which rendered every page holding one as
102
+ `data-eldra-invalid-layout`; it is now admitted (and type-checked as a boolean). Nothing renders
103
+ differently for it: "the author may not delete this node" is an editing rule, so the normalized
104
+ node is the same one an unlocked block produces.
105
+
106
+ - The browser's own undo and redo (⌘Z / ⇧⌘Z) now keep working in a field being edited on the canvas
107
+ while the editor saves and echoes drafts back. A renderer re-states a field's whole text as
108
+ `element.textContent = value`, the browser answers that by replacing the field's text node, and the
109
+ undo stack of the contenteditable is bound to that node — so every `editor:content-update`, every
110
+ autosave included, discarded everything the operator had typed from the undo history. In edit mode
111
+ the overlay now filters that write on the fields it has marked: an echo that re-states the text
112
+ already on screen (the renderer's string differs from the live text by the stega payload alone, so
113
+ its own "has this changed?" check could never see that it had not) and an echo that is behind
114
+ keystrokes the editor has not answered yet both write nothing at all, instead of landing and being
115
+ undone a pass later. Anything that really does change the field's text still lands, and a preview
116
+ that is not editing — like a published page — keeps the platform setter untouched.
117
+ - Inline canvas editing no longer depends on when the overlay's own `input` handler runs relative
118
+ to the MutationObserver that sees the keystroke land, nor on how long the editor's round trip
119
+ takes. `restoreEditingFocus` answers every characterData mutation in the document, so it can run
120
+ *before* `onInput` — a single `input` listener anywhere on the page registered ahead of the
121
+ overlay's own puts a microtask checkpoint between the two, and a checkpoint is where queued
122
+ observer records are delivered. It used to re-place the caret from the remembered offset on every
123
+ such pass, which put the caret back in front of the character just typed and, because the next
124
+ record was taken from that moved caret, made every further keystroke insert there too. A caret
125
+ already sitting in the field's own text node is now left exactly where the browser put it, and a
126
+ text difference across a node the record was taken against is read as the operator's newer typing
127
+ rather than something to overwrite.
128
+ - An `editor:content-update` is no longer trusted to describe what the operator typed just because
129
+ the field's `theme:text-edited` debounce has flushed: the round trip is bounded by nothing the
130
+ theme controls, and an echo that lands after the next keystroke was posted still carries the older
131
+ draft. A posted value is now held until the editor echoes it back, and only that acknowledgement
132
+ hands the field over — held only while the operator is still editing it in a focused frame, so a
133
+ write the editor refuses cannot own the field indefinitely.
134
+
135
+ - New bridge message `theme:request-failed` (`{status, path}`) and a new optional
136
+ `EldraClient.onRequestError(listener)` behind it. A preview token is one hash per organization, so
137
+ minting one anywhere else — another browser, another device, a test run — revokes the one a live
138
+ preview is using and the gateway answers every draft read with 401. The editor cannot see that
139
+ answer, so the client now reports a failed request and `startEldraPreview` forwards it; Studio
140
+ mints a fresh token and re-sends `editor:init`, which is both the hand-off and the retry. A
141
+ failure is reported only while the preview token that request carried is still the one the client
142
+ holds, so the editor's own recovery — whose in-flight reads reject against the replaced token —
143
+ does not read as a second failure. `onRequestError` is optional on the interface: a hand-written
144
+ client predating it simply reports nothing, as every client did before.
145
+
146
+ - Inline text editing on the canvas no longer loses a keystroke or the caret to the editor's own
147
+ echo. A `theme:text-edited` post is debounced, so an `editor:content-update` that arrives inside
148
+ that window carries a draft one keystroke behind the DOM; the overlay used to drop its
149
+ preservation on `acceptExternalUpdate`, let the renderer draw that stale value over the field
150
+ (which replaces the text node the caret lives in, collapsing the caret to offset 0 of the field)
151
+ and then write it a second time in `reconcileExternalDrafts`. A field whose own debounce is still
152
+ armed is now owned by the overlay — the editor cannot have been told about those keystrokes yet —
153
+ so the text and the caret are both put back, and `acceptExternalUpdate` retires the dirty flag
154
+ instead of discarding the record the caret is restored from. An external draft still wins for
155
+ text the editor has actually seen. `restoreEditingFocus` also no longer takes focus while the
156
+ preview frame is not the focused one, the same rule `restoreRichTextSelection` already followed.
157
+
158
+ - `safeLinkHref` is the same allowlist the platform's write side applies, rule for rule, so a value
159
+ a theme renders is a value an author can save and a value that is stored is a value that renders.
160
+ The cap is 2048 **bytes** rather than UTF-16 units; the whole Cc category counts as control
161
+ characters (C1, U+0080–U+009F, not only C0 and DEL); a `#`, `mailto:` or `tel:` needs something
162
+ after it, since a bare `#` addresses nothing; and an absolute url is tested by its
163
+ `http://`/`https://` prefix plus a host rather than by `new URL(href).protocol`, which accepts
164
+ `https:example.com` and `http:/example.com`, neither of which addresses the host it appears to.
165
+
166
+ - `resolveLink` returns `label` and `group` exactly as they were authored, markers and all, because
167
+ those are the strings a theme renders and in a Studio preview each carries the invisible payload
168
+ that makes it inline-editable; only the strings a route is derived from (`kind`, the target's
169
+ `_type`/`id`/`slug`, a `kind: "url"` href) are stega-stripped.
170
+
171
+ - `resolveLink` understands `kind: "none"`, a heading that groups the links under it: it resolves to
172
+ a label and its children and never to an href, so a theme renders it as a heading rather than an
173
+ anchor.
174
+
175
+ - New `@eldrajs/theme-core/links` entry: `resolveLink(value, context)` turns a `link` field's value
176
+ into `{ href, label, newTab, group, children }` against the site's own pages and route templates —
177
+ a product through the template serving `catalog:product`, a collection through
178
+ `catalog:collection`, a category through `catalog:category`, an entry through the template serving
179
+ its own schema, a page through the page tree, and a `kind: "url"` through the href allowlist. A
180
+ target that is unknown, has no slug, or that no route template serves gives `href: null`, so a
181
+ theme renders the label as plain text rather than a dead anchor; the label is the value's own when
182
+ it has one, else the target's title, else null. `linkTargetKeys(value)` returns the
183
+ `` `${_type}:${id}` `` keys a value names, children included and deduplicated, so a site can read
184
+ its targets in one batch per type. `safeLinkHref(value)` is the kit's single href allowlist — a
185
+ rooted path that is not protocol-relative, an in-page hash, or `https:`/`http:`/`mailto:`/`tel:`,
186
+ stega-stripped, at most 2048 bytes, no backslash and no control characters.
187
+
188
+ - `EldraCatalogReader` gains an **optional** `listCategories?(query?)`
189
+ (`GET /catalog/v1/categories`), the one read a category link target needs. It is optional so that
190
+ an implementation written against an earlier version — a test double, a custom transport — still
191
+ satisfies the interface; `createEldraClient` provides it, and a reader that does not resolves no
192
+ category targets, which renders those links without a destination exactly as a category no route
193
+ template serves already does.
194
+
195
+ - Feat: a new theme → editor bridge message, `theme:block-hovered`, reports the block the pointer
196
+ is over — `{ entryId, rect, layoutNodeId?, reusablePlacementId? }`, or `null` once it leaves — so
197
+ the editor can anchor an affordance (an "add block" control on the block's bottom edge) to the
198
+ same geometry the theme already outlines. It is posted when the hovered *block* changes, not on
199
+ every pointer move inside it, and re-posted whenever the theme's geometry may have moved, so a
200
+ re-post can repeat the rect it last sent. Edit mode only, and gated on the new `block-hover`
201
+ capability: an editor that does not advertise it receives nothing. The theme's own hover outline
202
+ is unchanged.
203
+ - Feat: a layout node the author hid at a breakpoint (`style.visible` false there) stays on the
204
+ Studio canvas in edit mode instead of disappearing. The generated layout CSS no longer puts
205
+ `display:none` in the node's own rule: inside that breakpoint's `@media` block it emits
206
+ `.<node>:not([data-eldra-edit-mode]){display:none}` plus
207
+ `.<node>[data-eldra-edit-mode]:not([data-eldra-edit-mode] *){opacity:0.35}`, and the overlay runtime
208
+ sets `data-eldra-edit-mode` on the nodes a framework binding marked `data-eldra-hidden` whenever the
209
+ bridge mode is `edit` (after mount, like every other overlay decoration, so server and client
210
+ render the same DOM). Preview, static generation and the published site never carry the marker, so
211
+ they hide the node exactly as before. The dimming rule's `:not([data-eldra-edit-mode] *)` applies
212
+ the 35 % once per hidden subtree: the marker is on every element carrying the node's class — the
213
+ `display:none` gate is per element, and a binding may put that class on more than one nested
214
+ element — and `opacity`, unlike `display:none`, multiplies through nesting.
215
+ - Feat: `hiddenLayoutBreakpoints(style)` returns the breakpoints a layout style hides its node at,
216
+ in `normal, tablet, mobile` order and through the grammar's own inheritance. It is the value of
217
+ the `data-eldra-hidden` attribute a framework binding puts on the layout node, space separated.
218
+ `activeLayoutBreakpoint(width, breakpoints?)` resolves a viewport width to the breakpoint whose
219
+ `@media` block is in force, from the same ranges the CSS is generated with.
220
+ `EDIT_MODE_HIDDEN_OPACITY` is the 35 % the canvas dims a hidden node to.
221
+ - Feat: `createOverlayRuntime` takes the theme's `breakpoints`, so it can say which breakpoint the
222
+ viewport is in. Omitted, the kit defaults are used.
223
+ - Feat: `theme:block-clicked` and each entry of `theme:blocks-rendered` may now carry
224
+ `hiddenAtBreakpoint: true` — the block's **own** layout node is hidden at the breakpoint the theme
225
+ is rendering at. A block hidden only because an ancestor node is hidden does not carry it.
226
+ Additive and present only when true, so an editor that does not know the field sees
227
+ byte-identical messages.
228
+ - Feat: a route-template layout may now hold reusable component placements (`{ id, type: 'reusable', componentId }`) alongside its `template-block` leaves, and
229
+ `createTemplateLayoutRenderModel` takes a `reusableComponentProjection` to expand them with.
230
+ Expansion is the same implementation page layouts use, so a component renders identically
231
+ wherever it is placed: its nodes keep their authored ids and carry `renderId`/`placementId`, and
232
+ a missing, foreign or stale component fails closed with the code a page reports for it. An
233
+ absent projection is an empty one, and a placement may not be the root.
234
+ - Fix: a route-template layout may contain `block` nodes. Core serves a template in two shapes —
235
+ the preview read keeps the `reusable` node and the projection, while the **public** read (what
236
+ `resolveRoute` and every prerender see) has already replaced each placement with the component's
237
+ own container of blocks and stripped the projection, exactly as a public page read is expanded
238
+ and redacted. `createTemplateLayoutRenderModel` used to refuse that shape outright, failing every
239
+ public template route carrying a header or footer role closed. A block in a template is held to
240
+ the page block-node rules (closed keys, a uuid `entryId` inside the allowlist, never the root)
241
+ and rendered like a page block; no `template-block` placement is registered for one. Both shapes
242
+ produce the same document, the same stylesheet and the same DOM identity — the preview shape
243
+ additionally carries the `renderId`/`placementId` Studio addresses a placement by.
244
+ - Fix: `decodeStega` and `stripStega` now read a payload whose closing delimiter is missing at the
245
+ end of the string. The delimiter is U+FEFF, which `String.prototype.trim()` counts as whitespace,
246
+ so a theme that renders `value.trim()` used to hand the overlay a run that no longer decoded — the
247
+ field stopped being editable in Studio's preview and the invisible characters stayed in the DOM.
248
+ A U+FEFF anywhere else in a value is still only a delimiter when a second one closes the run, so
249
+ text that contains one of its own is untouched. The encoder is unchanged.
250
+ - Feat: a route template's `template-block` binding source may now name a list element by index —
251
+ `images.0.url`, `variants.0.price` — alongside the field names it already accepted, so a block
252
+ field can be bound to one item of a list on the route's entry (a product's first image or first
253
+ variant price, or a CMS entry's own list field). A segment is an index only when it is a
254
+ canonical non-negative integer (`0`, `12`); `-1`, `01` and `1a` are field names, and an index
255
+ against a non-array or past the end of a list is not found — the same failure as a binding to a
256
+ key the entry does not have. The `{{ }}` text-template grammar is unchanged: its paths stay
257
+ identifier-only.
258
+ - Feat: the gateway client gained `client.catalog` — `getProduct(idOrSlug)`, `listProducts()`,
259
+ `getCollection(slug)` and `listCollections()` over the public catalog endpoints, so a theme can
260
+ render and prerender a catalog-backed route template without a second HTTP client. Catalog
261
+ documents are returned as the gateway serves them: never stega-encoded and never locale-projected
262
+ (they are commerce records, not merchant-authored content, and the gateway resolves their
263
+ translations from the `locale` query), and a list page reports `data: null` as an empty array.
264
+ - Feat: `catalogRouteTarget(schemaApiId)` recognises a route template's `catalog:product` or
265
+ `catalog:collection` schema id (stega-stripped, exact match) and returns `'product'` /
266
+ `'collection'` / `null`, so a theme's catalog route template can tell which storefront view to
267
+ render without re-parsing the schema id itself.
268
+ - Fix: a resolved catalog reference — a product or a collection a `reference` field points at
269
+ (`{ id, _type: 'collection', slug, … }`, or the depth-0 stub `{ id, _type }`) — is now an opaque
270
+ leaf in both preview walks. `encodeEntryDataStega` no longer stega-encodes the strings inside it
271
+ (a theme block hands that `slug` straight to the storefront, and the invisible characters sent
272
+ the request after a collection nobody has), and `projectEntryDataLocale` no longer mistakes its
273
+ locale-keyed `translations` map for one of the theme's own localized fields and flattens it to
274
+ the active locale.
275
+ - Fix: a `block` layout node whose width is measured from its content — `fit-content`, or an
276
+ unset/`auto` width as a flex-row item, or anything but a fixed length inside such a node — no
277
+ longer collapses to 0px. A block's own `@container` root applies inline-size containment, under
278
+ which it has no intrinsic inline size; the generated CSS now turns containment off on that
279
+ block's root (`.<node>>*{container-type:normal}`) and makes every determinately sized container
280
+ node, the document root included, a query container (`container-type:inline-size`), so the
281
+ block measures its content and its container queries resolve against the width of the region
282
+ it sits in. `fit-content`, `fill`, `100%` and fixed lengths all keep their literal meaning; a
283
+ determinate block keeps its own root as the query container exactly as before.
284
+ - Fix: a route template's `template-block` node whose `bindings`/`templates` keys were written
285
+ against a field's pre-migration name (before a block bumped its version and renamed that field)
286
+ no longer fails closed with `INVALID_VALUE`. `createTemplateLayoutRenderModel` now resolves such
287
+ a key through the block's declared `renames` — a new, optional `TemplateBlockDefinition.renames`
288
+ map, and the exported `buildTemplateBlockRenames` helper that flattens a block's `migrations`
289
+ array into it — before validating the node, so an un-migrated stored template keeps rendering.
290
+ Core still rewrites the stored bindings on deploy; this is the theme's own tolerance for the
291
+ window before that happens.
292
+ - **`buildRichTextTree` takes a `minHeadingLevel` render option**: a floor for every `heading`
293
+ node's rendered tag (`h{max(minHeadingLevel, level)}`, still capped at 6; default `1`, i.e. the
294
+ document's own levels). A page owns its heading outline and a rich-text field does not, so one
295
+ stored document has to be able to render as an h2-and-down section in one block and an h3-and-down
296
+ one in another. Applying it at render time leaves the document untouched — the position stamps and
297
+ every other attribute are identical with and without it. `@eldrajs/theme-vue`'s `EldraRichText`
298
+ exposes it as a prop.
299
+ - First release under the `@eldrajs` scope, moved from the private `@eldra/theme-core` package.
300
+ - `@eldra/bridge` is now the `@eldrajs/theme-core/bridge` subpath.
301
+ - Fix: a `select` field's value from the public/preview read path now arrives as its plain
302
+ string (e.g. `"subtle"`), top-level and nested inside a `list`'s composite item. Previously
303
+ the gateway's resolved `{ value, label }` object leaked into templates unwrapped, and was
304
+ stega-encoded (breaking `===` comparisons) while live-editing. The unwrap only fires for a
305
+ field the theme's manifest registers as `type: "select"` — an ordinary composite field with
306
+ `value`/`label` sub-fields is left untouched. A theme that renders a select field's resolved
307
+ value as visible text (a tone badge, a size label) loses overlay click-to-edit mapping for
308
+ that text, because it is deliberately no longer stega-encoded.
309
+ - `EldraClient.encodeEntryDataStega` gained an optional fourth `apiId` parameter, used to skip
310
+ stega-encoding a registered `select` field's resolved value — backwards compatible for any
311
+ existing caller/implementer.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eldra Tech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,70 @@
1
1
  # @eldrajs/theme-core
2
2
 
3
- Placeholder that reserved the name for trusted publishing. Install a real version.
3
+ Framework-free core of the Eldra theme SDK: the client that talks to the Studio gateway, stega
4
+ encoding/decoding for the visual editor, the overlay runtime that drives in-place editing, layout
5
+ CSS, rich-text position mapping, design tokens and image framing. It imports no framework — no
6
+ Vue, no Nuxt, no DOM library — so any framework binding (`@eldrajs/theme-vue`, a future React
7
+ binding, …) can be built on top of it. The Studio &lt;-&gt; theme postMessage protocol lives at
8
+ the `./bridge` subpath, alongside `./stega`, `./overlay`, `./preview-router`, `./layout`,
9
+ `./dynamic-route`, `./template-layout`, `./reusable`, `./design-tokens` and `./image-framing`.
10
+
11
+ ```bash
12
+ pnpm add @eldrajs/theme-core
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { createEldraClient, stripStega } from '@eldrajs/theme-core';
19
+
20
+ const client = createEldraClient({ gatewayUrl: 'https://api.example.com', orgId: 'org_123' });
21
+ const page = await client.getEntry('page', 'home');
22
+ const title = stripStega(page.data.title);
23
+ ```
24
+
25
+ ## Locale fallback inside a `link` field
26
+
27
+ A `link` field's value is a per-locale record, projected client-side to the active locale's node
28
+ (exact locale, then language, then the first key). Pass `defaultLocale` — the organisation's
29
+ default content locale — to fill, per field, anything the chosen node leaves untranslated (missing,
30
+ empty, or whitespace-only) from the default locale's node instead, recursively:
31
+
32
+ ```ts
33
+ const client = createEldraClient({
34
+ gatewayUrl: 'https://api.example.com',
35
+ orgId: 'org_123',
36
+ defaultLocale: 'en-US',
37
+ });
38
+ ```
39
+
40
+ `null` or omitted disables the fallback: the chosen node is used whole, as before.
41
+
42
+ ## Retrying what the gateway refused for now
43
+
44
+ The gateway rate-limits a client by requests per minute, so a static build of a real site — a
45
+ `nuxi generate` is thousands of reads from one address in a few minutes — meets that limit
46
+ routinely. A `429` is not an answer, and neither is a `503` while the gateway restarts or a
47
+ connection the network drops, so the client asks again: **idempotent requests only**
48
+ (`GET`/`HEAD`/`OPTIONS` — a `POST` that timed out may well have been applied), at most five attempts
49
+ including the first, honouring `Retry-After` (seconds or HTTP-date, up to a minute) and otherwise
50
+ waiting 250 ms doubled per attempt, capped at 5 s, with jitter. Every other status — a `404`, a
51
+ `401` — is reported on the first answer, as before, so the preview's own token recovery is
52
+ unaffected. A dropped connection is told apart from a **malformed** request — an
53
+ unparseable URL, an invalid header name, a `GET` with a body — which fails on the first attempt,
54
+ because repeating it can only fail the same way.
55
+
56
+ ```ts
57
+ const client = createEldraClient({
58
+ gatewayUrl: 'https://api.example.com',
59
+ orgId: 'org_123',
60
+ retry: { attempts: 5, baseDelayMs: 250, maxDelayMs: 5000 }, // the defaults
61
+ });
62
+
63
+ // One request, no waiting:
64
+ createEldraClient({ gatewayUrl: '…', orgId: '…', retry: { attempts: 0 } });
65
+ ```
66
+
67
+ A Nuxt theme sets this once, as `eldra.retry` in `nuxt.config.ts` — see
68
+ [@eldrajs/theme-nuxt](../theme-nuxt/README.md).
69
+
70
+ See [docs/themes.md](../../docs/themes.md) for the full theme integration guide.