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