@eldrajs/vite-plugin-theme 0.4.0 → 0.4.1

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 CHANGED
@@ -5,6 +5,7 @@ Release-please writes the generated notes from commit messages and does not repl
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ - A block field may say `"allowPrices": false` (WS-1474): Core allows price tokens in every `string`, `text` and `rich-text` field of a theme block, and this opts one out — a URL, an email, a code. The scan refuses it unless it is a boolean on one of those types, at any depth, and it reaches the manifest. Changing it never needs a version bump.
8
9
  - **A theme can declare its menu as an object: `metadata.tree` takes depth, sections and cards
9
10
  (WS-1312).** `tree` on a `link` field is now `boolean | EldraLinkTree` (new types `EldraLinkTree`,
10
11
  `EldraLinkTreeSections`, `EldraLinkTreeCards`, Core's own JSON keys). The scanner refuses exactly
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as PageSeedTarget, B as ThemeMessages, C as ManifestPageSeedBlock, D as ManifestTemplateRoles, E as ManifestRoute, F as TemplateSeedLayoutNode, I as TemplateSeedReusableNode, L as TemplateSeedSchemaApiId, M as ScanResult, N as TemplateSeedBlockNode, O as ManifestTemplateSeed, P as TemplateSeedLayout, R as ThemeManifest, S as ManifestPageSeed, T as ManifestPageSeedRegion, _ as EldraThemeOptions, a as DeclaredFormSeed, b as ManifestFormSeedField, c as DeclaredPageSeedEntry, d as DeclaredTemplateSeed, f as DeclaredTemplateSeedBlock, g as EldraLinkTreeSections, h as EldraLinkTreeCards, i as BlockMigrationGroupsToSections, j as ScanOptions, k as ManifestTemplateSeedBlock, l as DeclaredPageSeedRegion, m as EldraLinkTree, n as BlockField, o as DeclaredPageSeed, p as DeclaredThemeCodePage, r as BlockMigration, s as DeclaredPageSeedBlock, t as BlockDefinition, u as DeclaredSeed, v as LegacyThemeTokens, w as ManifestPageSeedEntry, x as ManifestFormSeedFieldType, y as ManifestFormSeed, z as ThemeManifestCapabilities } from "./types-Dej7h4ZU.js";
1
+ import { A as PageSeedTarget, B as ThemeMessages, C as ManifestPageSeedBlock, D as ManifestTemplateRoles, E as ManifestRoute, F as TemplateSeedLayoutNode, I as TemplateSeedReusableNode, L as TemplateSeedSchemaApiId, M as ScanResult, N as TemplateSeedBlockNode, O as ManifestTemplateSeed, P as TemplateSeedLayout, R as ThemeManifest, S as ManifestPageSeed, T as ManifestPageSeedRegion, _ as EldraThemeOptions, a as DeclaredFormSeed, b as ManifestFormSeedField, c as DeclaredPageSeedEntry, d as DeclaredTemplateSeed, f as DeclaredTemplateSeedBlock, g as EldraLinkTreeSections, h as EldraLinkTreeCards, i as BlockMigrationGroupsToSections, j as ScanOptions, k as ManifestTemplateSeedBlock, l as DeclaredPageSeedRegion, m as EldraLinkTree, n as BlockField, o as DeclaredPageSeed, p as DeclaredThemeCodePage, r as BlockMigration, s as DeclaredPageSeedBlock, t as BlockDefinition, u as DeclaredSeed, v as LegacyThemeTokens, w as ManifestPageSeedEntry, x as ManifestFormSeedFieldType, y as ManifestFormSeed, z as ThemeManifestCapabilities } from "./types-CVzauCgt.js";
2
2
  import { Plugin } from "vite";
3
3
  export default function eldraTheme(options?: EldraThemeOptions): Plugin;
4
4
  export declare function generateBlockTypes(blocks: BlockDefinition[], messages?: ThemeMessages): string;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as validateTemplateRoles, i as validatePageSeeds, n as scanTheme, o as validateTemplateSeeds, r as seedLayout, s as validateFormSeeds, t as readPreviousManifest } from "./scan-DBOHDmAQ.js";
1
+ import { a as validateTemplateRoles, i as validatePageSeeds, n as scanTheme, o as validateTemplateSeeds, r as seedLayout, s as validateFormSeeds, t as readPreviousManifest } from "./scan-DB3i4ttC.js";
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join, relative } from "node:path";
4
4
  import { generateDesignTokenCss, generateTailwindThemeCss, normalizeThemeDesignTokens } from "@eldrajs/theme-core/design-tokens";
@@ -211,6 +211,7 @@ const blockJsonSchema = {
211
211
  groupId: { type: "string" },
212
212
  isTitle: { type: "boolean" },
213
213
  localized: { type: "boolean" },
214
+ allowPrices: { type: "boolean" },
214
215
  default: {},
215
216
  description: { type: "string" },
216
217
  helpText: { type: "string" },
@@ -326,6 +327,7 @@ const STORED_FIELD_KEYS = [
326
327
  "description",
327
328
  "default",
328
329
  "localized",
330
+ "allowPrices",
329
331
  "helpText",
330
332
  "validators",
331
333
  "metadata",
@@ -575,7 +577,7 @@ function validMigrationFieldShape(value, depth = 1) {
575
577
  function storedMigrationField(raw, depth = 1) {
576
578
  const value = storedObject(raw, STORED_FIELD_KEYS);
577
579
  if (value !== null) for (const key of IGNORED_FIELD_KEYS) delete value[key];
578
- if (value === null || typeof value.fieldId !== "string" || !/^[a-zA-Z0-9_]+$/.test(value.fieldId) || typeof value.name !== "string" || value.name === "" || typeof value.type !== "string" || !STORED_FIELD_TYPES.has(value.type) || value.localized != null && typeof value.localized !== "boolean" || depth > 5) return null;
580
+ if (value === null || typeof value.fieldId !== "string" || !/^[a-zA-Z0-9_]+$/.test(value.fieldId) || typeof value.name !== "string" || value.name === "" || typeof value.type !== "string" || !STORED_FIELD_TYPES.has(value.type) || value.localized != null && typeof value.localized !== "boolean" || value.allowPrices != null && typeof value.allowPrices !== "boolean" || depth > 5) return null;
579
581
  if ([
580
582
  "groupId",
581
583
  "presetId",
@@ -2110,6 +2112,7 @@ function formatAjvError(file, error) {
2110
2112
  }
2111
2113
  function semanticChecks(file, block, errors) {
2112
2114
  const fields = Array.isArray(block.fields) ? block.fields : [];
2115
+ priceFieldChecks(file, fields, "fields", errors);
2113
2116
  const seen = /* @__PURE__ */ new Set();
2114
2117
  let titleCount = 0;
2115
2118
  const groups = Array.isArray(block.groups) ? block.groups : [];
@@ -2399,6 +2402,29 @@ function checkFieldVisibility(file, field, siblings, at, errors) {
2399
2402
  in: values
2400
2403
  };
2401
2404
  }
2405
+ /** The field types that hold price tokens (WS-1474), and so the only ones `allowPrices` may name. */
2406
+ const PRICE_FIELD_TYPES = /* @__PURE__ */ new Set([
2407
+ "string",
2408
+ "text",
2409
+ "rich-text"
2410
+ ]);
2411
+ /**
2412
+ * `allowPrices` is a text field's own setting: Core allows price tokens in every text field of a
2413
+ * theme block, and `false` opts one out. At any depth (a list item's or composite's fields too) it
2414
+ * must be a boolean on `string`, `text` or `rich-text`.
2415
+ */
2416
+ function priceFieldChecks(file, fields, at, errors) {
2417
+ fields.forEach((field, index) => {
2418
+ const where = `${at}[${index}]`;
2419
+ if ("allowPrices" in field) {
2420
+ if (typeof field.allowPrices !== "boolean") errors.push(`${file}: ${where}.allowPrices — must be a boolean`);
2421
+ else if (!PRICE_FIELD_TYPES.has(String(field.type))) errors.push(`${file}: ${where}.allowPrices — only allowed on type "string", "text" or "rich-text" (got "${String(field.type)}")`);
2422
+ }
2423
+ const metadata = isRecord(field.metadata) ? field.metadata : {};
2424
+ if (Array.isArray(metadata.fields)) priceFieldChecks(file, metadata.fields.filter(isRecord), `${where}.metadata.fields`, errors);
2425
+ if (isRecord(metadata.item)) priceFieldChecks(file, [metadata.item], `${where}.metadata.item`, errors);
2426
+ });
2427
+ }
2402
2428
  function compositeDepth(field, depth = 1) {
2403
2429
  const metadata = field.metadata;
2404
2430
  if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata)) return depth;
package/dist/scan.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as ManifestRoute, M as ScanResult, O as ManifestTemplateSeed, R as ThemeManifest, d as DeclaredTemplateSeed, j as ScanOptions } from "./types-Dej7h4ZU.js";
1
+ import { E as ManifestRoute, M as ScanResult, O as ManifestTemplateSeed, R as ThemeManifest, d as DeclaredTemplateSeed, j as ScanOptions } from "./types-CVzauCgt.js";
2
2
  export declare function scanTheme(opts: ScanOptions): ScanResult;
3
3
  export declare function readPreviousManifest(themeDir: string, errors: string[]): ThemeManifest | undefined;
4
4
  export type { DeclaredTemplateSeed, ManifestRoute, ManifestTemplateSeed, ScanOptions, ScanResult, ThemeManifest };
package/dist/scan.js CHANGED
@@ -1 +1 @@
1
- export { t as readPreviousManifest, n as scanTheme } from "./scan-DBOHDmAQ.js";
1
+ export { t as readPreviousManifest, n as scanTheme } from "./scan-DB3i4ttC.js";
@@ -238,6 +238,12 @@ interface BlockField {
238
238
  groupId?: string;
239
239
  isTitle?: boolean;
240
240
  localized?: boolean;
241
+ /**
242
+ * Whether a merchant may insert price tokens here (WS-1474). Core allows them in every
243
+ * `string`/`text`/`rich-text` field of a theme block; `false` opts one out — a URL, a code, an
244
+ * id, anything a written price would break. Only on those three types.
245
+ */
246
+ allowPrices?: boolean;
241
247
  default?: unknown;
242
248
  description?: string;
243
249
  helpText?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrajs/vite-plugin-theme",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
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
5
  "keywords": [
6
6
  "cms",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "ajv": "^8.17.1",
44
- "@eldrajs/theme-core": "^0.4.0"
44
+ "@eldrajs/theme-core": "^0.4.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@tailwindcss/vite": "^4.1.14",