@eldrajs/vite-plugin-theme 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.
- package/CHANGELOG.md +270 -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-DmmAzjZz.js +2184 -0
- package/dist/scan.d.ts +6 -0
- package/dist/scan.js +2 -0
- package/dist/types-kcnroZCz.d.ts +434 -0
- package/package.json +53 -2
package/dist/scan.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { A as ThemeManifest, C as ScanOptions, b as ManifestTemplateSeed, l as DeclaredTemplateSeed, v as ManifestRoute, w as ScanResult } from "./types-kcnroZCz.js";
|
|
2
|
+
//#region src/scan.d.ts
|
|
3
|
+
export declare function scanTheme(opts: ScanOptions): ScanResult;
|
|
4
|
+
export declare function readPreviousManifest(themeDir: string, errors: string[]): ThemeManifest | undefined;
|
|
5
|
+
//#endregion
|
|
6
|
+
export type { DeclaredTemplateSeed, ManifestRoute, ManifestTemplateSeed, ScanOptions, ScanResult, ThemeManifest };
|
package/dist/scan.js
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { ThemeDesignTokens } from "@eldrajs/theme-core/design-tokens";
|
|
2
|
+
import { LayoutBreakpoints } from "@eldrajs/theme-core/layout";
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
interface ManifestRoute {
|
|
5
|
+
pattern: string;
|
|
6
|
+
kind: 'page' | 'entry';
|
|
7
|
+
schemaApiId?: string;
|
|
8
|
+
field?: string;
|
|
9
|
+
}
|
|
10
|
+
interface DeclaredThemeCodePage {
|
|
11
|
+
path: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
/** The three catalog ids a route template may name instead of a CMS schema,
|
|
16
|
+
* plus the home seed. `catalog:product` / `catalog:collection` /
|
|
17
|
+
* `catalog:category` are reserved ids resolved against the catalog at render
|
|
18
|
+
* time, not CMS schemas. */
|
|
19
|
+
type TemplateSeedSchemaApiId = 'catalog:product' | 'catalog:collection' | 'catalog:category' | 'home';
|
|
20
|
+
/** A seed's other target: a static site **Page** at `/<slug>`, rather than a
|
|
21
|
+
* route template. A seed names one or the other — `schemaApiId`/`routePattern`
|
|
22
|
+
* for a template, `page` for a page — never both. */
|
|
23
|
+
interface PageSeedTarget {
|
|
24
|
+
/** The page's own slug, the whole path it serves (`cart` -> `/cart`). The
|
|
25
|
+
* pattern is the platform's own slug rule, so the scan refuses what the
|
|
26
|
+
* deploy would refuse. */
|
|
27
|
+
slug: string;
|
|
28
|
+
}
|
|
29
|
+
/** A page seed's block as a theme declares it: the block it is an instance of
|
|
30
|
+
* and the data it is seeded with, plus whether the node Core creates for it is
|
|
31
|
+
* locked. A page seed carries no node ids — it declares no layout, so there is
|
|
32
|
+
* nothing for an id to be referenced from, and Core mints the nodes itself. */
|
|
33
|
+
interface DeclaredPageSeedBlock {
|
|
34
|
+
apiId: string;
|
|
35
|
+
data: Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* `true` makes the layout node Core creates **locked**: the author may
|
|
38
|
+
* reorder it and edit its fields, but not delete it or move it out of the
|
|
39
|
+
* page root. It is how a page whose whole purpose is one block — a cart, a
|
|
40
|
+
* search results page — cannot lose that block. Only a page seed's blocks
|
|
41
|
+
* may carry it; a route template's blocks may not.
|
|
42
|
+
*/
|
|
43
|
+
required?: true;
|
|
44
|
+
}
|
|
45
|
+
/** A page seed's placement of one of the site's two shared regions, in the
|
|
46
|
+
* page's block order. It carries no data: the block behind the region is
|
|
47
|
+
* `templateRoles`, and Core resolves the placement to the site's own reusable
|
|
48
|
+
* component, so every seeded page shares one header and one footer. */
|
|
49
|
+
interface DeclaredPageSeedRegion {
|
|
50
|
+
role: 'header' | 'footer';
|
|
51
|
+
}
|
|
52
|
+
/** One entry of a page seed's ordered block list. */
|
|
53
|
+
type DeclaredPageSeedEntry = DeclaredPageSeedBlock | DeclaredPageSeedRegion;
|
|
54
|
+
/** A page seed's block as the manifest carries it. `type` is the block's
|
|
55
|
+
* `apiId`; the key is named for the layout node Core creates from it. */
|
|
56
|
+
interface ManifestPageSeedBlock {
|
|
57
|
+
type: string;
|
|
58
|
+
data: Record<string, unknown>;
|
|
59
|
+
/** Emitted only when the theme declared it, so a seed of ordinary blocks
|
|
60
|
+
* keeps emitting the shape it would have had without this key. */
|
|
61
|
+
required?: true;
|
|
62
|
+
}
|
|
63
|
+
/** A shared region's placement as the manifest carries it: the reserved types
|
|
64
|
+
* `@header` and `@footer`, which cannot collide with a block apiId. */
|
|
65
|
+
interface ManifestPageSeedRegion {
|
|
66
|
+
type: '@header' | '@footer';
|
|
67
|
+
}
|
|
68
|
+
/** One entry of the emitted `blocks` array, which **is** the page in document
|
|
69
|
+
* order: Core synthesises the one-column layout from it. */
|
|
70
|
+
type ManifestPageSeedEntry = ManifestPageSeedBlock | ManifestPageSeedRegion;
|
|
71
|
+
/** A static site page the theme seeds, as the manifest carries it: Core creates
|
|
72
|
+
* the Page (published, at `/<slug>`) on deploy when the organization has no
|
|
73
|
+
* page with that slug, lays its blocks out in one column in this order, and
|
|
74
|
+
* locks every `required` one. */
|
|
75
|
+
interface ManifestPageSeed {
|
|
76
|
+
slug: string;
|
|
77
|
+
title: string;
|
|
78
|
+
blocks: ManifestPageSeedEntry[];
|
|
79
|
+
}
|
|
80
|
+
interface ManifestTemplateSeedBlock {
|
|
81
|
+
id: string;
|
|
82
|
+
apiId: string;
|
|
83
|
+
data: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** A seed block as a theme declares it: the manifest shape plus the optional
|
|
86
|
+
* template bindings that belong to the block's *node* in the seed's layout —
|
|
87
|
+
* how a catalog-backed template fills the block in from the object the route
|
|
88
|
+
* resolved (`{ currentTitle: '{{ title }}' }`), rather than pinning one
|
|
89
|
+
* product or collection into the seed data. Both are keyed by a target path
|
|
90
|
+
* into the block's own fields. */
|
|
91
|
+
interface DeclaredTemplateSeedBlock extends ManifestTemplateSeedBlock {
|
|
92
|
+
/** Text templates: `{{ path }}` tokens resolved against the routed entry. */
|
|
93
|
+
templates?: Record<string, string>;
|
|
94
|
+
/** Whole-value bindings: a path on the routed entry, copied into the field. */
|
|
95
|
+
bindings?: Record<string, string>;
|
|
96
|
+
}
|
|
97
|
+
/** A reusable component named by the role it fills rather than by id: the theme
|
|
98
|
+
* cannot know a site's component ids, so the role is resolved on deploy. */
|
|
99
|
+
interface TemplateSeedReusableNode {
|
|
100
|
+
id: string;
|
|
101
|
+
type: 'reusable';
|
|
102
|
+
role: 'header' | 'footer';
|
|
103
|
+
}
|
|
104
|
+
interface TemplateSeedBlockNode {
|
|
105
|
+
id: string;
|
|
106
|
+
type: 'block';
|
|
107
|
+
/** The id of one of the seed's own `blocks[]`, not a CMS entry id. */
|
|
108
|
+
entryId: string;
|
|
109
|
+
/** Carried over from the seed block that declared them. Emitted only when
|
|
110
|
+
* the block declared any, so a seed without bindings keeps emitting the node
|
|
111
|
+
* an older Core already accepts. */
|
|
112
|
+
templates?: Record<string, string>;
|
|
113
|
+
bindings?: Record<string, string>;
|
|
114
|
+
}
|
|
115
|
+
type TemplateSeedLayoutNode = TemplateSeedReusableNode | TemplateSeedBlockNode;
|
|
116
|
+
/** A single column of role and block nodes — the only layout shape a seed may
|
|
117
|
+
* take, so what ships is exactly what the deploy decodes. */
|
|
118
|
+
interface TemplateSeedLayout {
|
|
119
|
+
version: 1;
|
|
120
|
+
root: {
|
|
121
|
+
id: string;
|
|
122
|
+
type: 'flex';
|
|
123
|
+
layout: {
|
|
124
|
+
direction: {
|
|
125
|
+
normal: 'column';
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
children: TemplateSeedLayoutNode[];
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** A template seed as it is emitted to the manifest: a layout is always
|
|
132
|
+
* present, and the declaration-only `header`/`footer` switches are gone. */
|
|
133
|
+
interface ManifestTemplateSeed {
|
|
134
|
+
routePattern: string;
|
|
135
|
+
schemaApiId: TemplateSeedSchemaApiId;
|
|
136
|
+
title: string;
|
|
137
|
+
blocks: ManifestTemplateSeedBlock[];
|
|
138
|
+
layout: TemplateSeedLayout;
|
|
139
|
+
}
|
|
140
|
+
/** The block data behind the `header`/`footer` roles a template seed's layout
|
|
141
|
+
* may reference: the theme block and the data instance a site's reusable
|
|
142
|
+
* header/footer component is seeded from on first deploy. Required whenever
|
|
143
|
+
* any declared template seed's layout places that role. */
|
|
144
|
+
interface ManifestTemplateRoles {
|
|
145
|
+
header?: {
|
|
146
|
+
apiId: string;
|
|
147
|
+
data: Record<string, unknown>;
|
|
148
|
+
};
|
|
149
|
+
footer?: {
|
|
150
|
+
apiId: string;
|
|
151
|
+
data: Record<string, unknown>;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** A static page seed as a theme declares it: a title, the slug the page is
|
|
155
|
+
* created at, and the page's content in document order — blocks, and the
|
|
156
|
+
* placements of the site's shared header and footer among them. There is no
|
|
157
|
+
* `layout`: the list **is** the page, and Core lays it out in one column. */
|
|
158
|
+
interface DeclaredPageSeed {
|
|
159
|
+
page: PageSeedTarget;
|
|
160
|
+
title: string;
|
|
161
|
+
blocks: DeclaredPageSeedEntry[];
|
|
162
|
+
}
|
|
163
|
+
/** One entry of a theme's `templates` option: a route-template (or home) seed,
|
|
164
|
+
* or a static page seed. The two are told apart by the target they name. */
|
|
165
|
+
type DeclaredSeed = DeclaredTemplateSeed | DeclaredPageSeed;
|
|
166
|
+
/** A template seed as a theme declares it. */
|
|
167
|
+
interface DeclaredTemplateSeed {
|
|
168
|
+
routePattern: string;
|
|
169
|
+
schemaApiId: TemplateSeedSchemaApiId;
|
|
170
|
+
title: string;
|
|
171
|
+
blocks: DeclaredTemplateSeedBlock[];
|
|
172
|
+
/** Omit to get a column of the blocks in order, framed by the roles below. */
|
|
173
|
+
layout?: TemplateSeedLayout;
|
|
174
|
+
/** Place the header role before the blocks (default true). Scanner input
|
|
175
|
+
* only — never emitted to the manifest. */
|
|
176
|
+
header?: boolean;
|
|
177
|
+
/** Place the footer role after the blocks (default true). Scanner input
|
|
178
|
+
* only — never emitted to the manifest. */
|
|
179
|
+
footer?: boolean;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Conditional visibility for a block field: the field is shown to an author
|
|
183
|
+
* only while the named sibling holds one of `in`'s values. `field` names a
|
|
184
|
+
* sibling in the *same* field set — top level, or the same composite / list
|
|
185
|
+
* item — which must be a `select`, `bool` or `string` field carrying no
|
|
186
|
+
* `showWhen` of its own (conditions do not chain).
|
|
187
|
+
*
|
|
188
|
+
* `equals` is sugar for a single-entry `in`; the scanner normalizes it away, so
|
|
189
|
+
* a manifest always carries `in`. Visibility is authoring UX, not storage:
|
|
190
|
+
* adding, changing or removing it is never a breaking field change and never
|
|
191
|
+
* needs a version bump.
|
|
192
|
+
*/
|
|
193
|
+
interface BlockFieldShowWhen {
|
|
194
|
+
field: string;
|
|
195
|
+
in?: string[];
|
|
196
|
+
equals?: string;
|
|
197
|
+
}
|
|
198
|
+
interface BlockField {
|
|
199
|
+
fieldId: string;
|
|
200
|
+
name: string;
|
|
201
|
+
type: string;
|
|
202
|
+
groupId?: string;
|
|
203
|
+
isTitle?: boolean;
|
|
204
|
+
localized?: boolean;
|
|
205
|
+
default?: unknown;
|
|
206
|
+
description?: string;
|
|
207
|
+
helpText?: string;
|
|
208
|
+
validators?: Record<string, unknown>;
|
|
209
|
+
metadata?: Record<string, unknown>;
|
|
210
|
+
/** Show this field only while a sibling holds one of the listed values. */
|
|
211
|
+
showWhen?: BlockFieldShowWhen;
|
|
212
|
+
/** `reference` fields only. A relation must name at least one target
|
|
213
|
+
* (`allowedTagIds`, `allowProducts` or `allowCollections`); `allowedSchemaIds`
|
|
214
|
+
* stays refused, because schema ids are not portable across organizations
|
|
215
|
+
* while products and collections are catalog objects every organization has. */
|
|
216
|
+
relation?: {
|
|
217
|
+
allowedTagIds?: string[];
|
|
218
|
+
allowProducts?: boolean;
|
|
219
|
+
allowCollections?: boolean;
|
|
220
|
+
multiple?: boolean;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
interface BlockSlotDefinition {
|
|
224
|
+
id: string;
|
|
225
|
+
label: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
minItems?: 0;
|
|
228
|
+
maxItems: number;
|
|
229
|
+
allowedBlockApiIds?: string[];
|
|
230
|
+
}
|
|
231
|
+
/** One field's values converted into a `link` field's on deploy. `from` is read
|
|
232
|
+
* and `to` is written; `from` is never deleted, so the engine's ordinary
|
|
233
|
+
* retirement pass stashes it as `<from>__v<previousVersion>` and anything the
|
|
234
|
+
* old shape carried and a link cannot hold stays readable. */
|
|
235
|
+
interface BlockMigrationLinkConversion {
|
|
236
|
+
/** The field read, as the previous local manifest names it. */
|
|
237
|
+
from: string;
|
|
238
|
+
/** The `link` field written — or the `list` of links, for `shape: "list"`. */
|
|
239
|
+
to: string;
|
|
240
|
+
/** What `from` was: a string holding an href, or a list of composites. */
|
|
241
|
+
shape: 'string' | 'list';
|
|
242
|
+
/** The child (or, for `shape: "string"`, the sibling field) holding the label. */
|
|
243
|
+
label?: string;
|
|
244
|
+
/** `shape: "list"` only: the child holding the href. */
|
|
245
|
+
url?: string;
|
|
246
|
+
/** `shape: "list"` only: the child holding the column heading. */
|
|
247
|
+
group?: string;
|
|
248
|
+
/**
|
|
249
|
+
* `shape: "list"` only: the child list holding the nested links, and the key
|
|
250
|
+
* names those nested rows use. They are named separately because the row
|
|
251
|
+
* above rarely uses the same ones — a footer column is `{title, links[]}`
|
|
252
|
+
* while each link under it is `{label, href}`. Each name falls back to the
|
|
253
|
+
* step's own when it is left out.
|
|
254
|
+
*/
|
|
255
|
+
children?: {
|
|
256
|
+
from: string;
|
|
257
|
+
label?: string;
|
|
258
|
+
url?: string;
|
|
259
|
+
group?: string;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
interface BlockMigration {
|
|
263
|
+
version: number;
|
|
264
|
+
/** Optional: a step may carry only conversions. A step must declare at least
|
|
265
|
+
* one of `renames` and `convertToLink`. */
|
|
266
|
+
renames?: Array<{
|
|
267
|
+
from: string;
|
|
268
|
+
to: string;
|
|
269
|
+
}>;
|
|
270
|
+
convertToLink?: BlockMigrationLinkConversion[];
|
|
271
|
+
}
|
|
272
|
+
interface BlockDefinition {
|
|
273
|
+
apiId: string;
|
|
274
|
+
name: string;
|
|
275
|
+
description?: string;
|
|
276
|
+
icon?: string;
|
|
277
|
+
category?: string;
|
|
278
|
+
version: number;
|
|
279
|
+
fields: BlockField[];
|
|
280
|
+
groups?: Array<{
|
|
281
|
+
groupId: string;
|
|
282
|
+
name: string;
|
|
283
|
+
defaultOpen?: boolean;
|
|
284
|
+
}>;
|
|
285
|
+
slots?: BlockSlotDefinition[];
|
|
286
|
+
migrations?: BlockMigration[];
|
|
287
|
+
}
|
|
288
|
+
interface ThemeManifest {
|
|
289
|
+
/** 2: `theme.id` is required. There is no v1 reader. */
|
|
290
|
+
manifestVersion: 2;
|
|
291
|
+
theme: {
|
|
292
|
+
/** The theme's stable id (`package.json` `eldra.themeId`); Core stores the theme's
|
|
293
|
+
* block schemas as `<id>:<blockApiId>`. Block apiIds in this manifest stay bare. */
|
|
294
|
+
id: string;
|
|
295
|
+
name: string;
|
|
296
|
+
version: string;
|
|
297
|
+
framework: string;
|
|
298
|
+
sdk: {
|
|
299
|
+
core: string;
|
|
300
|
+
vitePlugin: string;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
blocks: Array<Record<string, unknown> & {
|
|
304
|
+
mock: Record<string, unknown>;
|
|
305
|
+
previewImage: string | null;
|
|
306
|
+
}>;
|
|
307
|
+
routes: ManifestRoute[];
|
|
308
|
+
customPages: DeclaredThemeCodePage[];
|
|
309
|
+
/** Default templates the site is seeded with on its first deploy. Absent
|
|
310
|
+
* rather than empty when the theme declares none, so a theme that seeds
|
|
311
|
+
* nothing keeps emitting the manifest an older Core already accepts. */
|
|
312
|
+
templates?: ManifestTemplateSeed[];
|
|
313
|
+
/** The block data behind the `header`/`footer` roles a declared template
|
|
314
|
+
* seed's layout references. Absent rather than empty when the theme
|
|
315
|
+
* declares no roles, for the same reason `templates` is absent when empty. */
|
|
316
|
+
templateRoles?: ManifestTemplateRoles;
|
|
317
|
+
/** The static Pages the site is seeded with, `/<slug>` each. The home page
|
|
318
|
+
* is **not** one of them: it keeps being the `templates` entry it has always
|
|
319
|
+
* been, which Core maps to a Page itself, so this manifest's home seed is
|
|
320
|
+
* byte-identical to the one themes have always emitted. Absent rather than
|
|
321
|
+
* empty when the theme seeds no pages, for the same reason `templates` is. */
|
|
322
|
+
pageSeeds?: ManifestPageSeed[];
|
|
323
|
+
tokens: ThemeDesignTokens | LegacyThemeTokens;
|
|
324
|
+
/** The theme's own message catalogue, read from `i18n/<tag>.json` and
|
|
325
|
+
* flattened to dotted keys. Absent rather than empty when the theme ships
|
|
326
|
+
* no `i18n/` directory, so a theme that declares no texts keeps emitting
|
|
327
|
+
* the manifest shape an older Core already accepts. */
|
|
328
|
+
messages?: ThemeMessages;
|
|
329
|
+
}
|
|
330
|
+
interface LegacyThemeTokens {
|
|
331
|
+
colors: Record<string, string>;
|
|
332
|
+
fonts: Record<string, string>;
|
|
333
|
+
spacing: Record<string, string>;
|
|
334
|
+
}
|
|
335
|
+
/** The theme's own message catalogue — `i18n/<tag>.json`, flattened to dotted
|
|
336
|
+
* keys. `defaultLocale` is the locale whose key set every other locale's keys
|
|
337
|
+
* must be a subset of; see `ThemeManifest['messages']` for why it is absent
|
|
338
|
+
* rather than present-but-empty when the theme ships none. */
|
|
339
|
+
interface ThemeMessages {
|
|
340
|
+
defaultLocale: string;
|
|
341
|
+
locales: Record<string, Record<string, string>>;
|
|
342
|
+
}
|
|
343
|
+
interface ScanResult {
|
|
344
|
+
manifest: ThemeManifest | null;
|
|
345
|
+
blockDirs: Record<string, string>;
|
|
346
|
+
errors: string[];
|
|
347
|
+
/** The theme's own tablet/normal layout breakpoints — resolved and
|
|
348
|
+
* validated (defaults, 768/1024, when the theme configured none or
|
|
349
|
+
* something invalid; see @eldrajs/theme-core's resolveLayoutBreakpoints).
|
|
350
|
+
* Deliberately outside `ThemeManifest`: build-time-only, carried to the
|
|
351
|
+
* runtime through `virtual:eldra/breakpoints`, never written to
|
|
352
|
+
* `.eldra/manifest.json`. Always resolved, independent of `errors`. */
|
|
353
|
+
breakpoints: LayoutBreakpoints;
|
|
354
|
+
}
|
|
355
|
+
interface ScanOptions {
|
|
356
|
+
/** Last validated local manifest, advisory only; Core owns installed history. */
|
|
357
|
+
previousManifest?: ThemeManifest;
|
|
358
|
+
themeDir: string;
|
|
359
|
+
framework?: string;
|
|
360
|
+
routes?: ManifestRoute[];
|
|
361
|
+
customPages?: DeclaredThemeCodePage[];
|
|
362
|
+
/** The seeds a site is created with: route templates (at most 8) and static
|
|
363
|
+
* pages (at most 8). */
|
|
364
|
+
templates?: DeclaredSeed[];
|
|
365
|
+
/** The block data behind the `header`/`footer` roles the declared
|
|
366
|
+
* `templates` layouts may reference. Required for a role once any template
|
|
367
|
+
* seed's layout places it. */
|
|
368
|
+
templateRoles?: ManifestTemplateRoles;
|
|
369
|
+
/** The theme's raw, as-configured breakpoints — validated and defaulted
|
|
370
|
+
* into the manifest's `breakpoints` by resolveLayoutBreakpoints (Core),
|
|
371
|
+
* not here. */
|
|
372
|
+
breakpoints?: LayoutBreakpoints;
|
|
373
|
+
}
|
|
374
|
+
interface EldraThemeOptions {
|
|
375
|
+
framework?: string;
|
|
376
|
+
routes?: ManifestRoute[];
|
|
377
|
+
customPages?: DeclaredThemeCodePage[];
|
|
378
|
+
/** The seeds a site is created with on its first deploy: the route templates
|
|
379
|
+
* a merchant gets without building anything (the product and collection
|
|
380
|
+
* pages, the home page), at most 8, and the static **page** seeds beside them
|
|
381
|
+
* (`{ page: { slug }, title, blocks }`), also at most 8 — a page at
|
|
382
|
+
* `/<slug>` whose `required` blocks the author cannot delete. A seed is
|
|
383
|
+
* ignored once the site has a template for its pattern, or a page with its
|
|
384
|
+
* slug, so a merchant's edits are never overwritten. */
|
|
385
|
+
templates?: DeclaredSeed[];
|
|
386
|
+
/** The block data behind the `header`/`footer` roles the declared
|
|
387
|
+
* `templates` layouts may reference. Required for a role once any template
|
|
388
|
+
* seed's layout places it. */
|
|
389
|
+
templateRoles?: ManifestTemplateRoles;
|
|
390
|
+
/** Theme source root. Nuxt 4 sets Vite's root to app/, so adapters pass rootDir explicitly. */
|
|
391
|
+
themeDir?: string;
|
|
392
|
+
/** Opt in to the Tailwind v4 virtual theme module; false keeps Tailwind entirely optional. */
|
|
393
|
+
tailwind?: boolean;
|
|
394
|
+
/** The theme's own tablet/normal layout breakpoints (min-width px).
|
|
395
|
+
* Validated and defaulted (768/1024) into the manifest by Core's
|
|
396
|
+
* resolveLayoutBreakpoints; an invalid pair here falls back with a console
|
|
397
|
+
* warning rather than failing the build. */
|
|
398
|
+
breakpoints?: LayoutBreakpoints;
|
|
399
|
+
/**
|
|
400
|
+
* Transforms `virtual:eldra/messages`'s content before it is served — called with the
|
|
401
|
+
* manifest's own `messages` block (or the fallback catalogue, `{ defaultLocale: 'en-US',
|
|
402
|
+
* locales: {} }`, when the theme ships no `i18n/` directory) and returning what the virtual
|
|
403
|
+
* module actually exports. Absent, the module keeps serving that input unchanged.
|
|
404
|
+
*
|
|
405
|
+
* The one caller today is `@eldrajs/theme-nuxt`: it reads the public platform route once per
|
|
406
|
+
* build (a read this package knows nothing about) and, once that read settles, sets this to a
|
|
407
|
+
* closure merging the platform's response over whatever manifest messages it is handed
|
|
408
|
+
* (`@eldrajs/theme-core/i18n`'s `mergeMessageCatalogues`/`resolveMessageCatalogue`) — set on the
|
|
409
|
+
* same options object this function closed over, after `eldraTheme(options)` was already called,
|
|
410
|
+
* which works because `load()` (like every other hook here) reads `options` through the closure,
|
|
411
|
+
* not a snapshot taken at construction time, and Nuxt's own module `setup()` always finishes —
|
|
412
|
+
* platform read included — before Vite's build hooks run.
|
|
413
|
+
*/
|
|
414
|
+
resolveMessages?: (themeMessages: ThemeMessages) => ThemeMessages;
|
|
415
|
+
/**
|
|
416
|
+
* Transforms `virtual:eldra/tokens.css`'s content before it is served — called with the
|
|
417
|
+
* manifest's own `tokens` block (the theme's raw, as-authored `tokens.json`) and returning the
|
|
418
|
+
* `ThemeDesignTokens` the virtual module renders into generic `--eldra-color-*`/
|
|
419
|
+
* `--eldra-container-*` CSS. Absent, the module keeps rendering
|
|
420
|
+
* `normalizeThemeDesignTokens(manifest.tokens)` unchanged.
|
|
421
|
+
*
|
|
422
|
+
* The one caller today is `@eldrajs/theme-nuxt`: it reads the public platform route once per
|
|
423
|
+
* build (a read this package knows nothing about) and, once that read settles, sets this to a
|
|
424
|
+
* closure answering the platform's resolved catalog when the read succeeded, falling back to
|
|
425
|
+
* `normalizeThemeDesignTokens(manifestTokens)` otherwise — set on the same options object this
|
|
426
|
+
* function closed over, after `eldraTheme(options)` was already called, which works because
|
|
427
|
+
* `load()` (like every other hook here) reads `options` through the closure, not a snapshot taken
|
|
428
|
+
* at construction time, and Nuxt's own module `setup()` always finishes — platform read included
|
|
429
|
+
* — before Vite's build hooks run.
|
|
430
|
+
*/
|
|
431
|
+
resolveTokens?: (manifestTokens: ThemeDesignTokens | LegacyThemeTokens) => ThemeDesignTokens;
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
export { ThemeManifest as A, ScanOptions as C, TemplateSeedLayoutNode as D, TemplateSeedLayout as E, TemplateSeedReusableNode as O, PageSeedTarget as S, TemplateSeedBlockNode as T, ManifestPageSeedRegion as _, DeclaredPageSeedBlock as a, ManifestTemplateSeed as b, DeclaredSeed as c, DeclaredThemeCodePage as d, EldraThemeOptions as f, ManifestPageSeedEntry as g, ManifestPageSeedBlock as h, DeclaredPageSeed as i, ThemeMessages as j, TemplateSeedSchemaApiId as k, DeclaredTemplateSeed as l, ManifestPageSeed as m, BlockField as n, DeclaredPageSeedEntry as o, LegacyThemeTokens as p, BlockMigration as r, DeclaredPageSeedRegion as s, BlockDefinition as t, DeclaredTemplateSeedBlock as u, ManifestRoute as v, ScanResult as w, ManifestTemplateSeedBlock as x, ManifestTemplateRoles as y };
|
package/package.json
CHANGED
|
@@ -1,11 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eldrajs/vite-plugin-theme",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Vite plugin for Eldra themes: scans blocks/*/block.json, validates them, emits the theme manifest and the virtual modules the runtime reads (blocks, manifest, block fields, breakpoints, tokens CSS).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cms",
|
|
7
|
+
"eldra",
|
|
8
|
+
"theme",
|
|
9
|
+
"vite",
|
|
10
|
+
"vite-plugin"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/eldra-is/headless-kit/tree/main/packages/vite-plugin-theme#readme",
|
|
13
|
+
"bugs": "https://github.com/eldra-is/headless-kit/issues",
|
|
5
14
|
"license": "MIT",
|
|
6
15
|
"repository": {
|
|
7
16
|
"type": "git",
|
|
8
17
|
"url": "git+https://github.com/eldra-is/headless-kit.git",
|
|
9
18
|
"directory": "packages/vite-plugin-theme"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"CHANGELOG.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./scan": {
|
|
33
|
+
"types": "./dist/scan.d.ts",
|
|
34
|
+
"import": "./dist/scan.js"
|
|
35
|
+
},
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"provenance": true
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"ajv": "^8.17.1",
|
|
44
|
+
"@eldrajs/theme-core": "^0.2.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@tailwindcss/vite": "^4.1.14",
|
|
48
|
+
"tailwindcss": "^4.1.14",
|
|
49
|
+
"vite": "^8.0.8"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"vite": ">=5"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=20"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsdown",
|
|
59
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
60
|
+
"test": "vitest run"
|
|
10
61
|
}
|
|
11
62
|
}
|