@eldrajs/vite-plugin-theme 0.0.0 → 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.
- package/CHANGELOG.md +259 -0
- package/LICENSE +21 -0
- package/README.md +30 -1
- package/dist/index.d.ts +74 -0
- package/dist/index.js +452 -0
- package/dist/scan-DjW4f_E8.js +2162 -0
- package/dist/scan.d.ts +6 -0
- package/dist/scan.js +2 -0
- package/dist/types-BRNXfpXW.d.ts +430 -0
- package/package.json +53 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# @eldrajs/vite-plugin-theme 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
|
+
- The scanner now reads a theme's own message catalogue: `i18n/<tag>.json`, siblings of
|
|
9
|
+
`tokens.json`, one file per locale, each a nested JSON object of strings that gets flattened to
|
|
10
|
+
dotted keys (`header.menu`, `cart.empty.title`). It validates key grammar/length, value
|
|
11
|
+
type/length, the 2000-key and 20-locale bounds, that every file name is a canonical `ll-RR` BCP-47
|
|
12
|
+
tag, and that every non-default locale's keys are a subset of the default locale's (naming the
|
|
13
|
+
locale and the first offending key otherwise). The default locale is declared under
|
|
14
|
+
`package.json`'s own `eldra.defaultLocale` key, beside the `name`/`version` the scanner already
|
|
15
|
+
reads from the same file; when undeclared it falls back to `en-US` when shipped, else the
|
|
16
|
+
alphabetically first locale file. `manifest.messages = { defaultLocale, locales }` is **absent**
|
|
17
|
+
— not an empty object — when the theme has no `i18n/` directory, so a theme shipping no texts
|
|
18
|
+
never changes its manifest shape. A new virtual module, `virtual:eldra/messages`
|
|
19
|
+
(`{ defaultLocale: string; locales: Record<string, Record<string, string>> }`), serves the
|
|
20
|
+
manifest's own block today, or `{ defaultLocale: 'en-US', locales: {} }` when the theme declares
|
|
21
|
+
none; the Nuxt wrapper will later merge a live organization read over it. `generateBlockTypes`
|
|
22
|
+
(and therefore every `.eldra/block-types.d.ts` write, from the plugin on every scan and from
|
|
23
|
+
`eldra-theme types --blocks`) now also emits a `type MessageKey = '…' | '…';` union from the
|
|
24
|
+
default locale's keys when the theme ships any, so a theme's own code gets typed message keys
|
|
25
|
+
without a hand-written `Messages` interface. See `docs/theme-design-tokens.md`'s new "Messages"
|
|
26
|
+
section.
|
|
27
|
+
|
|
28
|
+
- `eldraTheme()` takes a new option, `resolveMessages?: (themeMessages) => themeMessages` — when
|
|
29
|
+
set, `virtual:eldra/messages` serves its return value instead of the manifest's own `messages`
|
|
30
|
+
block unchanged. `@eldrajs/theme-nuxt`'s module is the one caller: it sets this once its own
|
|
31
|
+
build-time read of the public platform route has settled, merging that response over the
|
|
32
|
+
manifest defaults and resolving the result over the organisation's locales
|
|
33
|
+
(`@eldrajs/theme-core/i18n`). Absent, nothing changes from today's behaviour.
|
|
34
|
+
|
|
35
|
+
- `eldraTheme()` takes a matching option for design tokens, `resolveTokens?: (manifestTokens) =>
|
|
36
|
+
ThemeDesignTokens` — when set, `virtual:eldra/tokens.css` generates its CSS from its return value
|
|
37
|
+
instead of `normalizeThemeDesignTokens(manifest.tokens)`. `@eldrajs/theme-nuxt`'s module is the one
|
|
38
|
+
caller: it sets this once its own build-time read of the organisation's resolved design-token
|
|
39
|
+
catalog has settled, answering that catalog outright — there is nothing to merge per key, unlike
|
|
40
|
+
messages — and falling back to the manifest's own tokens, normalized, when the read found nothing.
|
|
41
|
+
Absent, nothing changes from today's behaviour. See `docs/theme-design-tokens.md`'s new
|
|
42
|
+
"The build-time merge" section.
|
|
43
|
+
|
|
44
|
+
- A route template seed may now target `catalog:category`, and its pattern's trailing parameter is
|
|
45
|
+
the **catch-all** `:path*` (`/categories/:path*`) rather than `:slug`: a category is addressed by
|
|
46
|
+
its canonical path — the slugs of its ancestors, root first, then its own. The pairing is checked
|
|
47
|
+
both ways, so a category seed carrying `:slug` and a product or collection seed carrying a
|
|
48
|
+
catch-all are each refused by name, with the parameter the target actually takes. Core enforces
|
|
49
|
+
the same pairing on the route-template entry and on the manifest's seed target, so a pattern the
|
|
50
|
+
scan accepted and the deploy refused would be a scan that lied.
|
|
51
|
+
|
|
52
|
+
- `eldra.templates` now also declares **static page seeds**: an entry naming `page: { slug }`
|
|
53
|
+
instead of `schemaApiId`/`routePattern` seeds a Page at `/<slug>` (at most 16 of them, counted
|
|
54
|
+
separately from the 8 route templates). A seed names one target or the other, never both. Its
|
|
55
|
+
`blocks` array **is** the page in document order — there is no `layout` and there are no node
|
|
56
|
+
ids; Core lays the entries out in one column — and an entry is either a block
|
|
57
|
+
(`{ apiId, data, required? }`, emitted as `{ type: apiId, data, required? }`) or a placement of
|
|
58
|
+
one of the site's shared regions (`{ role: 'header' | 'footer' }`, emitted as the reserved
|
|
59
|
+
`{ type: '@header' }` / `{ type: '@footer' }`, at most once each and only where the theme declares
|
|
60
|
+
that `templateRoles` role). A region may sit anywhere in the order, so an announcement bar can
|
|
61
|
+
precede the header. `required: true` makes the node Core creates locked: the author reorders it
|
|
62
|
+
and edits its fields, but cannot delete it or move it out of the page root; it is refused on a
|
|
63
|
+
route template's blocks. Block `data` goes through exactly the walk a template seed's data does.
|
|
64
|
+
The home page is **not** a page seed — it stays the `templates` entry it has always been, which
|
|
65
|
+
Core maps to the site's root Page itself, so the home seed on the wire is unchanged, and a page
|
|
66
|
+
seed may not claim the slug `home` while that template seed exists. `pageSeeds` is absent rather
|
|
67
|
+
than empty when a theme seeds no pages. Every key a page seed cannot take is refused by name
|
|
68
|
+
rather than dropped — `layout`, `header` and `footer` on the seed, `templates`, `bindings` and
|
|
69
|
+
`id` on one of its block entries, and anything else at either level — because the manifest is
|
|
70
|
+
decoded with unknown fields disallowed, so a key swallowed by the scan would fail the entire
|
|
71
|
+
deploy later with a message about a file the author never wrote.
|
|
72
|
+
|
|
73
|
+
- A seed's `link` value with `kind: "url"` is checked against the platform's href allowlist rather
|
|
74
|
+
than only for being a non-blank string, so a scan refuses what a deploy refuses. A `mock.json` or
|
|
75
|
+
`preview.json` carrying `javascript:…`, a `data:` url, a protocol-relative `//host`, a bare `#`,
|
|
76
|
+
a backslash, a control character, a value over 2048 bytes or a scheme with the wrong number of
|
|
77
|
+
slashes (`https:example.com`) now fails `eldra-theme validate` and `pnpm dev`/`build` with a line
|
|
78
|
+
naming the path that carries it, instead of failing at the deploy — the one place a theme author
|
|
79
|
+
cannot fix it offline.
|
|
80
|
+
|
|
81
|
+
- A block migration step may now carry `convertToLink`, which turns an existing field's values into
|
|
82
|
+
a `link` field's on deploy — where a handle can still be resolved against the catalog — rather
|
|
83
|
+
than letting a composite-to-link change land as a retirement that leaves the new field empty:
|
|
84
|
+
|
|
85
|
+
```jsonc
|
|
86
|
+
"migrations": [{
|
|
87
|
+
"version": 3,
|
|
88
|
+
"renames": [],
|
|
89
|
+
"convertToLink": [
|
|
90
|
+
{ "from": "links", "to": "links", "shape": "list",
|
|
91
|
+
"label": "label", "url": "href",
|
|
92
|
+
"children": { "from": "menuLinks", "group": "group" } },
|
|
93
|
+
{ "from": "ctaHref", "to": "cta", "shape": "string", "label": "ctaLabel" }
|
|
94
|
+
]
|
|
95
|
+
}]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`label`, `url` and `group` name the fields of the **row** being converted; `children` names the
|
|
99
|
+
nested list and the key names those nested rows use, each falling back to the step's own when it
|
|
100
|
+
is left out. They are separate because the row above rarely uses the same names — a footer column
|
|
101
|
+
is `{title, links[]}` while each link under it is `{label, href}`, which one set of keys could not
|
|
102
|
+
carry.
|
|
103
|
+
|
|
104
|
+
`shape` says what the old field was: a `string` holding an href, or a `list` of composites whose
|
|
105
|
+
named children carry the label, href, group and nested links. **The conversion copies; it never
|
|
106
|
+
deletes.** `from` is left alone, so the ordinary retirement pass then stashes it as
|
|
107
|
+
`<from>__v<previousVersion>` and anything the old shape carried and a link cannot hold stays
|
|
108
|
+
readable — and a step that converts still has to bump the block's version for that reason. It is
|
|
109
|
+
idempotent for free: on the next deploy `from` no longer exists under its old id.
|
|
110
|
+
|
|
111
|
+
The scanner checks that `to` exists in the incoming fields and is a `link` (or, for
|
|
112
|
+
`shape: "list"`, a list whose item is one), that no two conversions in a step write the same
|
|
113
|
+
field, that a `shape: "string"` conversion declares no `url`, `group` or `children` (it reads one
|
|
114
|
+
field and writes one link, so there are no rows to name), that a `children` mapping has an href
|
|
115
|
+
key at one level or the other (without one every child converts blank and is dropped), that
|
|
116
|
+
`from` exists in the previous local manifest — for as long as that manifest still describes the
|
|
117
|
+
old shape; a step stops being source-checked once `from` is gone or has itself become the link
|
|
118
|
+
the step writes, which is what redeploying an applied step produces — and
|
|
119
|
+
that every named key exists at the level it names: `label`/`url`/`group` on the previous item's
|
|
120
|
+
composite, `children.from` as a list of composites under it, and `children`'s own key names on
|
|
121
|
+
that nested composite. For `shape: "string"`, that `label` names another string field of the
|
|
122
|
+
previous block.
|
|
123
|
+
|
|
124
|
+
- `renames` is now optional on a migration step, so a step may carry only conversions. A step must
|
|
125
|
+
still declare at least one of `renames` and `convertToLink`.
|
|
126
|
+
|
|
127
|
+
- Seed data (a block's `mock.json`, a template seed's block data and a template role's data) may
|
|
128
|
+
name a `link` field's destination. A product or a collection may be named by handle —
|
|
129
|
+
`{ "kind": "collection", "target": { "_type": "collection", "slug": "the-winter-edit" } }` — and
|
|
130
|
+
Core resolves it against the organisation's own catalog at seed time, leaving that one link out
|
|
131
|
+
when nothing matches rather than emptying the field. The other kinds address
|
|
132
|
+
organisation-owned objects a theme has no portable name for, so a seed leaves their `target` out
|
|
133
|
+
and an author fills it in. The scanner refuses anything else: an unknown `kind`, a `url` on a
|
|
134
|
+
kind that is not `url` (or a missing one on a kind that is), a `target` on `kind: "url"`, an id
|
|
135
|
+
that is not a uuid, a target whose `_type` does not mirror its `kind` (the rule Core's own
|
|
136
|
+
validator refuses a mismatch on at deploy), a handle for a kind Core cannot resolve one for, and a
|
|
137
|
+
child carrying children of its own. Children are walked with the same rules, and a `link` inside a list or a
|
|
138
|
+
composite is walked as well.
|
|
139
|
+
|
|
140
|
+
- A `link` value may be `kind: "none"` — a heading that groups the links under it and goes nowhere
|
|
141
|
+
itself, which is the only shape a footer column heading or a mega-menu parent without its own page
|
|
142
|
+
has. It carries a `label` and non-empty `children`, never a `target` or a `url`, and is refused
|
|
143
|
+
anywhere it cannot head anything (as a child, or with no children of its own). `metadata.kinds`
|
|
144
|
+
accepts it alongside the six destinations.
|
|
145
|
+
|
|
146
|
+
- A block field may now declare `"type": "link"` — one destination the platform understands rather
|
|
147
|
+
than a typed-out URL. Its value is
|
|
148
|
+
`{ kind, target?: { _type, id }, url?, label?, openInNewTab?, group?, children? }` with `kind` one
|
|
149
|
+
of `product`, `collection`, `category`, `entry`, `page` or `url`; `url` is set only for
|
|
150
|
+
`kind: "url"` and `target` only for the other five, and `children` is one level deep and never
|
|
151
|
+
more. Three metadata keys belong to the type and to nothing else: `kinds` (the kinds an author may
|
|
152
|
+
pick from — every kind when absent), `allowedEntrySchemaApiIds` (restricts `kind: "entry"` to the
|
|
153
|
+
named schemas, and requires `kinds` to include `entry`), and `tree` (author the field as a tree of
|
|
154
|
+
one level of children — allowed only on a `link` that is a `list`'s `metadata.item`, because a
|
|
155
|
+
`list` may declare only `allowedSchemas` and `item` itself). A `link` field may not declare
|
|
156
|
+
`relation`. Each refusal names the field's own path
|
|
157
|
+
(`blocks/navigation/block.json: fields[3].metadata.item.metadata.kinds — unknown kind "blog"`).
|
|
158
|
+
|
|
159
|
+
- `.eldra/block-types.d.ts` types a `link` field as the new global `EldraLink` interface — a list of
|
|
160
|
+
links as `Array<EldraLink>`, a link inside a composite inline with the rest — and declares the
|
|
161
|
+
interface only when some block actually uses the type, the way `RichTextNode` is only imported
|
|
162
|
+
when one declares rich text.
|
|
163
|
+
|
|
164
|
+
- Seed data (a block's `mock.json`, a template seed's block data and a template role's data) may
|
|
165
|
+
now name a catalog collection by slug in a `reference` field:
|
|
166
|
+
`{ "_type": "collection", "slug": "the-winter-edit" }`. A theme cannot know an organisation's
|
|
167
|
+
collection ids, so this is the only form it can ship; Core resolves it against the
|
|
168
|
+
organisation's own catalog at seed time and leaves the field empty when nothing matches, so the
|
|
169
|
+
deploy still succeeds. The scanner now validates every seed reference value: absent,
|
|
170
|
+
`{ _type, id: <uuid> }`, or the slug form on a relation whose `allowCollections` is true.
|
|
171
|
+
Anything else — a bare handle string, a resolved read's whole object, a slug on a relation that
|
|
172
|
+
allows no collection — is a validation error naming the path that carries it
|
|
173
|
+
(`blocks/collection-grid/mock.json: collection: reference values must be absent, …`), the same
|
|
174
|
+
way a media value that is not `{assetId: uuid}` already was.
|
|
175
|
+
|
|
176
|
+
- A block field may now declare `showWhen: { "field": "<sibling>", "in": ["<value>", …] }` — the
|
|
177
|
+
field is offered to an author only while that sibling holds one of the listed values.
|
|
178
|
+
`equals: "x"` is sugar for `in: ["x"]` and is normalized away while scanning, so the manifest
|
|
179
|
+
always carries `in`. `field` names a sibling in the *same* field set (top level, or the same
|
|
180
|
+
composite / list item) which must be a `select`, `bool` or `string` field carrying no `showWhen`
|
|
181
|
+
of its own — conditions do not chain — and, for a `select` sibling, every listed value must be
|
|
182
|
+
one of its `metadata.options`. Each rule is a validation error naming the field
|
|
183
|
+
(`blocks/product-carousel/block.json: fields[2].showWhen.field — references unknown sibling
|
|
184
|
+
"variation"`), and Core's manifest ingest refuses the same shapes the same way. Visibility is
|
|
185
|
+
authoring UX, not storage: adding, changing or removing `showWhen` is **not** a breaking field
|
|
186
|
+
change, so it never demands a `version` bump, and the generated `.eldra/block-types.d.ts` is
|
|
187
|
+
unchanged by it.
|
|
188
|
+
|
|
189
|
+
- A declared template seed block may now carry `templates` and `bindings`
|
|
190
|
+
(`Record<string, string>` each), and they are emitted on that block's node in the generated —
|
|
191
|
+
or declared — seed layout rather than on `templates[].blocks[]`, which still carries only the
|
|
192
|
+
three keys Core decodes. Both are keyed by a target path into the block's own fields, the same
|
|
193
|
+
grammar the theme's template layout reads (identifier segments with list indices allowed:
|
|
194
|
+
`heading`, `items.0.label`, first segment a field the block declares), and each value must be a
|
|
195
|
+
non-empty string — a text template (`{{ title }}`) for `templates`, a path on the routed entry
|
|
196
|
+
for `bindings`. A key that is not such a path, or a value that is not a non-empty string, is a
|
|
197
|
+
validation error naming it (`templates[0].blocks[0].templates.subheading — must be a path into
|
|
198
|
+
hero's fields (expected …)`). This is what lets a catalog-backed seed fill a block in from the
|
|
199
|
+
object its route resolved instead of pinning one product or collection into the seed data.
|
|
200
|
+
|
|
201
|
+
- Themes can declare `templates`: up to 8 default page templates a site is seeded with on its
|
|
202
|
+
first deploy, so a merchant gets working product and collection pages without building
|
|
203
|
+
anything. A seed is `{ routePattern, schemaApiId, title, blocks: [{ id, apiId, data }],
|
|
204
|
+
layout? }`, where `schemaApiId` is `catalog:product`, `catalog:collection` or `home`, and each
|
|
205
|
+
block's `data` is the same kind of seed as a block's `mock.json` — validated the same way, so a
|
|
206
|
+
media value must be `{assetId: uuid}` or absent (`templates[0].blocks[1].data — image: media
|
|
207
|
+
values must be {assetId: uuid} — use preview.json for demo imagery`). Every block `apiId` must
|
|
208
|
+
be one the theme ships, ids are unique and shaped `^[a-z][a-z0-9-]{0,47}$`, and route patterns
|
|
209
|
+
do not repeat. The pattern has to agree with what the seed is a template for: `home` owns `/`,
|
|
210
|
+
and a catalog seed needs a static prefix plus the one `:slug` parameter it is resolved by. A seed without a `layout` gets one column of its blocks in order, framed by a
|
|
211
|
+
header and a footer node that name a *role* rather than a component id (the site's own reusable
|
|
212
|
+
components are resolved on deploy); `header: false` / `footer: false` leave the role out. Those
|
|
213
|
+
two switches steer the generated layout and are never written to the manifest. The key is
|
|
214
|
+
emitted only when a theme declares at least one seed.
|
|
215
|
+
|
|
216
|
+
A theme can also declare `templateRoles`: the block data behind the `header`/`footer` roles its
|
|
217
|
+
template seed layouts reference — `{ header?: { apiId, data }, footer?: { apiId, data } }`,
|
|
218
|
+
validated the same way as a seed block (`templateRoles.header.apiId — unknown block "…"`,
|
|
219
|
+
`templateRoles.header.data — …`). A role is required once any declared seed's layout places it
|
|
220
|
+
(generated or declared), whether or not that seed also carries the switch that puts it there:
|
|
221
|
+
`templateRoles.header — required: templates[0] places the header role`. Emitted only when the
|
|
222
|
+
theme declares at least one role, same as `templates`.
|
|
223
|
+
|
|
224
|
+
- A `reference` field's `relation` now names its targets as any combination of `allowedTagIds`
|
|
225
|
+
(semantic tag names), `allowProducts` and `allowCollections`, with at least one of them —
|
|
226
|
+
`allowedTagIds` is no longer required, and `allowProducts` is no longer refused. A relation that
|
|
227
|
+
names none — one carrying only `multiple` included — fails with `blocks/<id>/block.json:
|
|
228
|
+
fields[<i>] — relation requires one of allowedTagIds, allowProducts or allowCollections`, the
|
|
229
|
+
same rule and wording Core's manifest ingest applies. `allowedSchemaIds` stays refused (`themes
|
|
230
|
+
may use only relation.allowedTagIds, relation.allowProducts and relation.allowCollections`):
|
|
231
|
+
schema ids are not portable across organizations, while products and collections are catalog
|
|
232
|
+
objects every organization has.
|
|
233
|
+
- `generateBlockTypes` now declares `EldraCollectionReference`
|
|
234
|
+
(`{ id; _type: 'collection'; slug?; status?; type?; productCount?; translations? }` — only
|
|
235
|
+
`id`/`_type` are guaranteed, since the public read returns the stub at depth 0, for an archived
|
|
236
|
+
collection, and for a page builder draft overlay) and types a `reference` field whose relation targets
|
|
237
|
+
catalog collections *and nothing else* as `EldraCollectionReference | null`, or
|
|
238
|
+
`EldraCollectionReference[]` when the relation is `multiple`. A relation mixing targets keeps
|
|
239
|
+
`Record<string, unknown>`.
|
|
240
|
+
- The advisory local-history check now requires a block `version` bump for a storage-incompatible
|
|
241
|
+
field change (type or `localized` flip, or a nested composite/list child change) under the same
|
|
242
|
+
`fieldId`, and for a field removed without a declared rename — mirroring Core's field retirement,
|
|
243
|
+
which archives the previous content into a read-only `<fieldId>__v<n>` field on a bump instead of
|
|
244
|
+
refusing the deploy. Without the bump, `migrationChecks` fails with `blocks/<id>/block.json: field
|
|
245
|
+
<fieldId> changed type (<old> → <new>); bump "version" to <n+1> so Core retires the previous
|
|
246
|
+
content` (or `changed localization` / `was removed`). See `docs/theme-field-migrations.md` → "Type
|
|
247
|
+
changes and removed fields".
|
|
248
|
+
- First release under the `@eldrajs` scope, moved from the private `@eldra/vite-plugin-theme` package.
|
|
249
|
+
- Adds `generateBlockTypes(blocks)`, a framework-free generator that turns every scanned block's
|
|
250
|
+
`block.json` into a global ambient `.eldra/block-types.d.ts` (`interface EldraBlockData`,
|
|
251
|
+
`EldraBlockEntry<K>`, `EldraMedia`) so a theme's `Block.vue` components get typed `entry.data`.
|
|
252
|
+
The plugin now writes that file next to `.eldra/manifest.json` on `buildStart` and on block file
|
|
253
|
+
changes in dev, skipping the write when the content is unchanged.
|
|
254
|
+
- `scanTheme` now validates every media field value in a block's `mock.json` against Core's
|
|
255
|
+
write-side shape (`{ assetId: <uuid>, framing? }`), so a fixture-shaped value (or any other shape)
|
|
256
|
+
fails with `mock.json: <field>: media values must be {assetId: uuid} — use preview.json for demo
|
|
257
|
+
imagery` instead of only surfacing as a 400 when Studio later seeds a freshly-inserted block's CMS
|
|
258
|
+
entry from it. The check walks `list`/`composite` nesting and `multiple: true` media fields too. A
|
|
259
|
+
media field may still be entirely absent — that's the expected shape.
|
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,32 @@
|
|
|
1
1
|
# @eldrajs/vite-plugin-theme
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vite plugin for Eldra themes. Scans `blocks/*/block.json`, validates them against the manifest
|
|
4
|
+
schema, and emits the theme manifest plus the virtual modules a theme's runtime reads: block
|
|
5
|
+
components, the block manifest, per-block field projections, layout breakpoints, and generated
|
|
6
|
+
design-token CSS (including an optional Tailwind v4 theme layer). `./scan` exposes the scanner
|
|
7
|
+
standalone, used by `@eldrajs/theme-cli`'s `validate`/`types` commands.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add -D @eldrajs/vite-plugin-theme
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// vite.config.ts
|
|
17
|
+
import { defineConfig } from 'vite';
|
|
18
|
+
import eldraTheme from '@eldrajs/vite-plugin-theme';
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
plugins: [eldraTheme({ tailwind: true })],
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
// scan a theme directory directly
|
|
27
|
+
import { scanTheme } from '@eldrajs/vite-plugin-theme/scan';
|
|
28
|
+
|
|
29
|
+
const { manifest, errors } = scanTheme({ themeDir: '.', framework: 'nuxt' });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
See [docs/themes.md](../../docs/themes.md) for the full theme integration guide.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { A as ThemeManifest, C as ScanOptions, D as TemplateSeedLayoutNode, E as TemplateSeedLayout, O as TemplateSeedReusableNode, S as PageSeedTarget, T as TemplateSeedBlockNode, _ as ManifestPageSeedRegion, a as DeclaredPageSeedBlock, b as ManifestTemplateSeed, c as DeclaredSeed, d as DeclaredThemeCodePage, f as EldraThemeOptions, g as ManifestPageSeedEntry, h as ManifestPageSeedBlock, i as DeclaredPageSeed, j as ThemeMessages, k as TemplateSeedSchemaApiId, l as DeclaredTemplateSeed, m as ManifestPageSeed, n as BlockField, o as DeclaredPageSeedEntry, p as LegacyThemeTokens, r as BlockMigration, s as DeclaredPageSeedRegion, t as BlockDefinition, u as DeclaredTemplateSeedBlock, v as ManifestRoute, w as ScanResult, x as ManifestTemplateSeedBlock, y as ManifestTemplateRoles } from "./types-BRNXfpXW.js";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
//#region src/plugin.d.ts
|
|
4
|
+
export default function eldraTheme(options?: EldraThemeOptions): Plugin;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/blockTypes.d.ts
|
|
7
|
+
export declare function generateBlockTypes(blocks: BlockDefinition[], messages?: ThemeMessages): string;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/templates.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* The layout a seed gets when it declares none: one column of its blocks in
|
|
12
|
+
* order, framed by the header and footer roles unless the seed opts out. The
|
|
13
|
+
* roles are resolved to the site's own reusable components on deploy, which is
|
|
14
|
+
* why they travel as a role rather than an id.
|
|
15
|
+
*/
|
|
16
|
+
export declare function seedLayout(seed: DeclaredTemplateSeed): TemplateSeedLayout;
|
|
17
|
+
/**
|
|
18
|
+
* Validates the theme's declared template seeds against the blocks it ships and
|
|
19
|
+
* returns them in manifest shape: every seed with a layout, and without the
|
|
20
|
+
* `header`/`footer` switches, which steer the generated layout and are never
|
|
21
|
+
* emitted.
|
|
22
|
+
*
|
|
23
|
+
* The declared list also carries static **page** seeds (`page: { slug }`);
|
|
24
|
+
* those are skipped here and validated by `validatePageSeeds`, which reads the
|
|
25
|
+
* same list. Only the template seeds count against the template cap.
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateTemplateSeeds(seeds: ReadonlyArray<DeclaredSeed>, blocks: ReadonlyArray<Record<string, unknown>>, errors: string[]): ManifestTemplateSeed[];
|
|
28
|
+
/**
|
|
29
|
+
* Validates the theme's declared **page** seeds — the entries of the same
|
|
30
|
+
* `templates` list that name `page: { slug }` instead of a template target —
|
|
31
|
+
* and returns them in manifest shape.
|
|
32
|
+
*
|
|
33
|
+
* A page seed is the simplest seed there is: a slug, a title and the page's
|
|
34
|
+
* content in document order. There is no `layout` and there are no node ids:
|
|
35
|
+
* the `blocks` array **is** the page, and Core synthesises the one-column
|
|
36
|
+
* layout from it. An entry is either
|
|
37
|
+
*
|
|
38
|
+
* - a **block** — `{ apiId, data, required? }`, emitted as
|
|
39
|
+
* `{ type: apiId, data, required? }`. `required: true` makes the node Core
|
|
40
|
+
* creates locked: the author reorders it and edits its fields but cannot
|
|
41
|
+
* delete it or move it out of the page root, so a cart page cannot lose its
|
|
42
|
+
* cart.
|
|
43
|
+
* - a **region placement** — `{ role: 'header' | 'footer' }`, emitted as the
|
|
44
|
+
* reserved `{ type: '@header' }` / `{ type: '@footer' }`. It carries no data:
|
|
45
|
+
* the block behind the region is `templateRoles`, and Core resolves the
|
|
46
|
+
* placement to the site's own reusable component, so every seeded page shares
|
|
47
|
+
* one header and one footer. A region may sit anywhere in the order — which
|
|
48
|
+
* is what lets an announcement bar precede the header — at most once each, and
|
|
49
|
+
* only when the theme declares that role.
|
|
50
|
+
*
|
|
51
|
+
* The **home** page is not a page seed. It keeps being the `templates` entry it
|
|
52
|
+
* has always been, which Core maps to the site's root Page itself, so the home
|
|
53
|
+
* seed on the wire is byte-identical to the one every theme has emitted; a page
|
|
54
|
+
* seed may therefore not claim the slug `home` while that template seed exists.
|
|
55
|
+
*
|
|
56
|
+
* Every rule a seed's data obeys is the one `validateTemplateSeeds` applies —
|
|
57
|
+
* the same `checkSeedData` walk, because a page seed is the same kind of write
|
|
58
|
+
* Core makes on deploy.
|
|
59
|
+
*/
|
|
60
|
+
export declare function validatePageSeeds(seeds: ReadonlyArray<DeclaredSeed>, blocks: ReadonlyArray<Record<string, unknown>>, templates: ReadonlyArray<ManifestTemplateSeed>, roles: ManifestTemplateRoles | undefined, errors: string[]): ManifestPageSeed[];
|
|
61
|
+
/**
|
|
62
|
+
* Validates the block data a theme declares behind the `header`/`footer`
|
|
63
|
+
* roles its template seed layouts may reference, and returns it in manifest
|
|
64
|
+
* shape. A role's `apiId` must be a block the theme ships and its `data` is
|
|
65
|
+
* validated exactly like a seed block's data (the same media walk `mock.json`
|
|
66
|
+
* and `templates[].blocks[].data` go through) — the manifest write it becomes
|
|
67
|
+
* is the same kind of write. Cross-checked against the already-validated
|
|
68
|
+
* `templates`: a role a seed's layout places (whether generated or declared)
|
|
69
|
+
* and that the theme did not declare is an error naming the seed that needs
|
|
70
|
+
* it, so Core is never handed a template it cannot seed a site with.
|
|
71
|
+
*/
|
|
72
|
+
export declare function validateTemplateRoles(roles: ManifestTemplateRoles | undefined, blocks: ReadonlyArray<Record<string, unknown>>, templates: ReadonlyArray<ManifestTemplateSeed>, errors: string[]): ManifestTemplateRoles | undefined;
|
|
73
|
+
//#endregion
|
|
74
|
+
export type { BlockDefinition, BlockField, BlockMigration, DeclaredPageSeed, DeclaredPageSeedBlock, DeclaredPageSeedEntry, DeclaredPageSeedRegion, DeclaredSeed, DeclaredTemplateSeed, DeclaredTemplateSeedBlock, DeclaredThemeCodePage, EldraThemeOptions, LegacyThemeTokens, ManifestPageSeed, ManifestPageSeedBlock, ManifestPageSeedEntry, ManifestPageSeedRegion, ManifestRoute, ManifestTemplateRoles, ManifestTemplateSeed, ManifestTemplateSeedBlock, PageSeedTarget, ScanOptions, ScanResult, TemplateSeedBlockNode, TemplateSeedLayout, TemplateSeedLayoutNode, TemplateSeedReusableNode, TemplateSeedSchemaApiId, ThemeManifest, ThemeMessages };
|