@eldrajs/theme-core 0.1.0 → 0.3.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 CHANGED
@@ -5,6 +5,44 @@ Release-please writes the generated notes from commit messages and does not repl
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ - **`createAnalytics`, `normalizeAnalyticsProps`, `truncateUtf8`.** Framework-free custom-event layer
9
+ over the Eldra tracker's `window.eldra('event', ...)`: props stringified and cut to the platform's
10
+ limits, events queued (50) until the script loads, a no-op when disabled, `pageview` rejected.
11
+ Behind `useEldraAnalytics` in `@eldrajs/theme-nuxt`.
12
+
13
+ - New framework-free schema.org JSON-LD builders: `buildProductLd` (`Offer`, or `AggregateOffer` for
14
+ variants at different prices; price rounded to the currency's own fraction digits, list price from
15
+ `compareAt`, GTIN only when valid), `buildBreadcrumbLd`, `buildItemListLd`, `buildOrganizationLd`,
16
+ `buildWebSiteLd` (with a `SearchAction` when given a search path) and `serializeLd` (escapes `<`
17
+ and the two line separators so a value cannot close the script tag), plus `validGtin`, `ldPrice`,
18
+ `ldPlainText` and `applyStructuredDataPolicy` (the opt-out and extender `@eldrajs/theme-nuxt`
19
+ applies). Empty values are omitted, never written. Documented in `docs/theme-seo.md`.
20
+ - New framework-free `buildSitemap` (a `urlset`, or a `sitemapindex` with children past the
21
+ sitemaps.org limits; hreflang `xhtml:link` alternates and `x-default`; noindex pages excluded; a
22
+ same-origin canonical as `loc`), `buildRobots` (preview: `Disallow: /`; production: `Allow: /`,
23
+ merchant lines, `Sitemap:`), `buildAlternates` (the head's hreflang set) and their helpers
24
+ (`siteOrigin`, `sitemapLastmod`, `escapeXml`). `@eldrajs/theme-nuxt` feeds them the prerendered
25
+ routes. Documented in `docs/theme-seo.md`.
26
+
27
+ - New framework-free SEO resolver, `resolveSeo` (and `substituteSeoPattern`, `tidySeoTitle`,
28
+ `renderSeoTitle`, `pickSeoLocale`, the `SeoSetting`/`SeoEntryValue`/`ResolvedSeo` types):
29
+ title, description, share image, canonical, `noindex`, `og:type` and Twitter handle for one route
30
+ from the entry's own `seo` value, the route template's pattern, the site's pattern and the page's
31
+ own title, in that order. `{{dot.path}}` substitution is a single pass, an unknown or empty
32
+ variable becomes empty (never literal braces), and a separator left dangling by an empty variable
33
+ is dropped. Studio's previews run the same function; `src/__tests__/fixtures/seo-vectors.json`
34
+ is the vector file shared with Core and Studio. Documented in `docs/theme-seo.md`.
35
+
36
+ - New `themeId` helpers, framework-free: `blockApiIdOf(schemaApiId, themeId)` (the wire spelling
37
+ `<themeId>:<apiId>` to the bare block id, stripping only the given theme's own prefix, so
38
+ `catalog:product` and another theme's `starter:hero` pass through) and
39
+ `themeSchemaApiId(blockApiId, themeId)` (the reverse, idempotent), plus `THEME_ID_PATTERN`,
40
+ `RESERVED_THEME_IDS`, `registerThemeId`/`getRegisteredThemeId`. **Breaking:** `registerBlockFields(fields,
41
+ themeId)` now requires the theme's own id and registers it, so `isBlockFieldLocalized`,
42
+ `isBlockFieldSelect` (and the select unwrap and stega skip that use it) and a template block's
43
+ entry/placement match resolve a block entry whose `schemaApiId` is `<themeId>:<apiId>`. Bare ids
44
+ keep working. The bridge's `theme:ready` reports `manifestVersion: 2`.
45
+
8
46
  - New subpath, `@eldrajs/theme-core/i18n`, framework-free: `flattenMessages`/`unflattenMessages`
9
47
  (nested vue-i18n JSON ↔ the manifest's own flat dotted keys), `mergeMessageCatalogues(themeDefaults,
10
48
  platform)` (the platform's theme-message overrides win per key; a locale the theme never shipped
@@ -250,7 +250,7 @@ function createThemeBridge(opts) {
250
250
  }
251
251
  function sendReady() {
252
252
  deliver(makeEnvelope("theme:ready", {
253
- manifestVersion: 1,
253
+ manifestVersion: 2,
254
254
  themeVersion: readMeta("eldra-theme-version"),
255
255
  sdkVersion: readMeta("eldra-sdk-version"),
256
256
  path: window.location.pathname,
package/dist/bridge.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as BRIDGE_PROTOCOL, c as KNOWN_MESSAGE_TYPES, i as parseEnvelope, l as RICH_TEXT_COMMAND_NAMES, n as createEditorBridge, o as BRIDGE_VERSION, r as makeEnvelope, s as EDITOR_CAPABILITIES, t as createThemeBridge, u as THEME_CAPABILITIES } from "./bridge-DfNINXLL.js";
1
+ import { a as BRIDGE_PROTOCOL, c as KNOWN_MESSAGE_TYPES, i as parseEnvelope, l as RICH_TEXT_COMMAND_NAMES, n as createEditorBridge, o as BRIDGE_VERSION, r as makeEnvelope, s as EDITOR_CAPABILITIES, t as createThemeBridge, u as THEME_CAPABILITIES } from "./bridge-CLi2P6Wh.js";
2
2
  export { BRIDGE_PROTOCOL, BRIDGE_VERSION, EDITOR_CAPABILITIES, KNOWN_MESSAGE_TYPES, RICH_TEXT_COMMAND_NAMES, THEME_CAPABILITIES, createEditorBridge, createThemeBridge, makeEnvelope, parseEnvelope };
package/dist/index.d.ts CHANGED
@@ -10,6 +10,58 @@ import { PageLayoutDocument, PageLayoutNode, ReusableComponentSnapshotCache, Reu
10
10
  //#region src/client.d.ts
11
11
  export declare function createEldraClient(opts: EldraClientOptions): EldraClient;
12
12
  //#endregion
13
+ //#region src/analytics.d.ts
14
+ /**
15
+ * Framework-free custom-event tracking for the Eldra analytics tracker script
16
+ * (`<gateway>/js/script.js`, see `analyticsTrackerScript` in `@eldrajs/sdk`).
17
+ *
18
+ * The script owns pageviews (including SPA navigations, by patching `history`) and exposes
19
+ * `window.eldra('event', name, { props })` for everything else. This module is the thin, testable
20
+ * layer a theme calls instead of reaching for that global: it coerces props to the string-only
21
+ * shape Core accepts, stays inside Core's limits, holds events until the script has loaded, and is
22
+ * a no-op wherever tracking is off (disabled, a Studio preview frame, the server).
23
+ *
24
+ * Nothing here reads or writes a cookie or storage: the visitor is a salted daily hash computed by
25
+ * the platform, never an identifier kept in the browser.
26
+ */
27
+ /** A prop value a theme may pass; stringified (and `null`/`undefined` dropped) before sending. */
28
+ export type AnalyticsPropValue = string | number | boolean | null | undefined;
29
+ export type AnalyticsProps = Record<string, AnalyticsPropValue>;
30
+ /** Core's ingest limits (`SanitizeProps`): 30 entries, keys up to 60 bytes, values 300 bytes. */
31
+ export declare const ANALYTICS_MAX_PROPS = 30;
32
+ export declare const ANALYTICS_MAX_KEY_BYTES = 60;
33
+ export declare const ANALYTICS_MAX_VALUE_BYTES = 300;
34
+ /** Core cuts an event name at 120 bytes. */
35
+ export declare const ANALYTICS_MAX_NAME_BYTES = 120;
36
+ /** Events held back before the tracker script has loaded; the oldest are dropped past this. */
37
+ export declare const ANALYTICS_QUEUE_LIMIT = 50;
38
+ /** The tracker script's global, as `script.js` installs it. */
39
+ export type AnalyticsSender = (command: 'event', name: string, options?: {
40
+ props?: Record<string, string>;
41
+ }) => void;
42
+ export interface Analytics {
43
+ /** Whether events are sent at all. `false` makes `track` a no-op. */
44
+ readonly enabled: boolean;
45
+ /** Records a named event. Never throws; a failed send is dropped. */
46
+ track(name: string, props?: AnalyticsProps): void;
47
+ /** Sends everything queued while the script was loading. Call once the script has loaded. */
48
+ flush(): void;
49
+ }
50
+ export interface CreateAnalyticsOptions {
51
+ /** `false` for the server, a preview frame, a dev server or a site that opted out. */
52
+ enabled: boolean;
53
+ /** Resolves the tracker's global; `undefined` until the script has loaded. */
54
+ sender: () => AnalyticsSender | undefined;
55
+ }
56
+ /** Cuts a string to at most `maxBytes` of UTF-8 without splitting a character. */
57
+ export declare function truncateUtf8(value: string, maxBytes: number): string;
58
+ /**
59
+ * Coerces a theme's props to what Core stores: strings only, `null`/`undefined`/non-finite numbers
60
+ * dropped, keys and values cut to the ingest limits, at most 30 entries.
61
+ */
62
+ export declare function normalizeAnalyticsProps(props: AnalyticsProps | undefined): Record<string, string>;
63
+ export declare function createAnalytics(options: CreateAnalyticsOptions): Analytics;
64
+ //#endregion
13
65
  //#region src/stegaWalk.d.ts
14
66
  /**
15
67
  * Projects a complete localized CMS draft into the active-locale shape used
@@ -388,8 +440,12 @@ type BlockFieldsMap = Record<string, BlockFieldDefinition[]>;
388
440
  * equivalent entry for another adapter) imports `virtual:eldra/block-fields`
389
441
  * and calls this once at startup with the resolved map; call it again (e.g.
390
442
  * on the plugin's HMR rescan) to replace the registered map.
443
+ *
444
+ * `themeId` is the theme's own id (the manifest's `theme.id`). Core spells a
445
+ * block entry's schema `<themeId>:<apiId>` on the wire while this map is keyed
446
+ * by the bare `apiId`, so the lookups below strip that one prefix.
391
447
  */
392
- export declare function registerBlockFields(fields: BlockFieldsMap): void;
448
+ export declare function registerBlockFields(fields: BlockFieldsMap, themeId: string): void;
393
449
  /**
394
450
  * Whether the manifest marks this block field `localized`. A rich-text
395
451
  * renderer uses it to default an omitted `locale` to the preview's active
@@ -404,4 +460,385 @@ export declare function registerBlockFields(fields: BlockFieldsMap): void;
404
460
  */
405
461
  export declare function isBlockFieldLocalized(apiId: string | undefined, fieldId: string): boolean;
406
462
  //#endregion
463
+ //#region src/themeId.d.ts
464
+ /**
465
+ * Theme ownership of block schemas, as the kit sees it.
466
+ *
467
+ * Core stores a theme's block schemas under `<themeId>:<blockApiId>`
468
+ * (`soley:hero`), so two themes in one organisation never clash and a
469
+ * merchant's own schemas can never shadow a theme's. Everything the theme
470
+ * itself authors stays **bare**: `block.json`, the manifest's block ids, a
471
+ * layout node's `apiId`, a slot allowlist, `data-eldra-schema` and the
472
+ * overlay's `theme:block-clicked`. Only the wire spelling of an entry's
473
+ * `schemaApiId` carries the prefix, so these two helpers are the whole
474
+ * boundary.
475
+ *
476
+ * The prefix stripped is the one of the theme *this build is for* (injected at
477
+ * build from the manifest's `theme.id`), never "any prefix": `catalog:product`
478
+ * and another theme's `starter:hero` are not this theme's blocks and pass
479
+ * through untouched.
480
+ */
481
+ /** The grammar of a theme id (and of a block apiId): lower-case, 2 to 49 characters. */
482
+ export declare const THEME_ID_PATTERN: RegExp;
483
+ /**
484
+ * Ids a theme may not use. Core reserves `catalog:` for catalog route targets,
485
+ * so a theme called `catalog` would claim that namespace for its block schemas.
486
+ */
487
+ export declare const RESERVED_THEME_IDS: readonly string[];
488
+ /** Wire to bare: `soley:hero` to `hero` for theme `soley`; anything else is returned as given. */
489
+ export declare function blockApiIdOf(schemaApiId: string, themeId: string | undefined | null): string;
490
+ /**
491
+ * Bare to wire: `hero` to `soley:hero` for theme `soley`. A value that already
492
+ * carries a colon (the wire spelling, or `catalog:product`) is returned as
493
+ * given, so the call is idempotent.
494
+ */
495
+ export declare function themeSchemaApiId(blockApiId: string, themeId: string | undefined | null): string;
496
+ /** Registers the theme's own id for the lookups inside theme-core. See `registerBlockFields`. */
497
+ export declare function registerThemeId(themeId: string | undefined): void;
498
+ /** The registered theme id, if the app registered one. */
499
+ export declare function getRegisteredThemeId(): string | undefined;
500
+ //#endregion
501
+ //#region src/seo.d.ts
502
+ /**
503
+ * The page-title and SEO-metadata resolver. Framework-free: the theme's `useEldraSeo`
504
+ * (`@eldrajs/theme-nuxt`) feeds it, and Studio's search-result and share-card previews run the
505
+ * very same function, so what the merchant sees is what the build writes.
506
+ *
507
+ * The rules are the platform's contract (`__tests__/fixtures/seo-vectors.json` is shared with
508
+ * Core and Studio):
509
+ *
510
+ * - Precedence, per field: the entry's own `seo` value, then the route template's pattern for this
511
+ * context, then the site's pattern, then the page's own title.
512
+ * - A pattern is `{{dot.path}}` over scalars (`"syntax": 1`). Substitution is **one pass** over the
513
+ * pattern: a substituted value is never scanned again, so a product called `{{site.name}}` shows
514
+ * those characters. An unknown or empty variable becomes `''`, never literal braces (unlike the
515
+ * email renderer, which keeps unknown paths and swallows nearby whitespace and punctuation).
516
+ * - Titles are tidied afterwards: whitespace collapsed, and a separator (`· | – — -`, standing
517
+ * alone between spaces) left leading, trailing or doubled by an empty variable is dropped.
518
+ */
519
+ /** The contexts a pattern can be written for; they decide which variables exist. */
520
+ export type SeoContext = 'page' | 'home' | 'catalog:product' | 'catalog:collection' | 'catalog:category';
521
+ /** The only pattern syntax version this resolver understands. */
522
+ export declare const SEO_SYNTAX = 1;
523
+ /** A string per locale, keyed by the site's locale tags. */
524
+ export type SeoLocaleMap = Record<string, string>;
525
+ /** `GET /site/v1/seo` exactly as the platform answers it. */
526
+ export interface SeoSetting {
527
+ revision: number;
528
+ syntax: number;
529
+ site: {
530
+ /** `null`: use the site's own name (the theme's). */
531
+ name: string | null;
532
+ titlePattern: SeoLocaleMap;
533
+ description: SeoLocaleMap;
534
+ imageAssetId: string | null;
535
+ /** The media worker's 1200x630 rendering, absolute, or `null`. */
536
+ imageUrl: string | null;
537
+ twitterHandle: string | null;
538
+ };
539
+ /** Per-context patterns (`catalog:product`, ...). A context with none inherits the site's. */
540
+ templates: Record<string, {
541
+ titlePattern?: SeoLocaleMap;
542
+ descriptionPattern?: SeoLocaleMap;
543
+ }>;
544
+ }
545
+ /** A page's or template's own `seo` field value. Each string may also be a per-locale map. */
546
+ export interface SeoEntryValue {
547
+ title?: string | SeoLocaleMap | null;
548
+ description?: string | SeoLocaleMap | null;
549
+ canonicalUrl?: string | SeoLocaleMap | null;
550
+ /** Open Graph title and description overrides; each falls back to the page's title and description. */
551
+ ogTitle?: string | SeoLocaleMap | null;
552
+ ogDescription?: string | SeoLocaleMap | null;
553
+ /** The share image's asset id; Core resolves it to `imageUrl` in the public entry read. */
554
+ imageAssetId?: string | null;
555
+ /**
556
+ * The share image's media URL: the resolved rendering of `imageAssetId` (as Core serves for the
557
+ * site's own image). The resolver reads only the URL.
558
+ */
559
+ imageUrl?: string | null;
560
+ noindex?: boolean | null;
561
+ }
562
+ /** Variables by path: nested (`{ page: { title } }`) or flat (`{ 'page.title': ... }`). */
563
+ export type SeoData = Record<string, unknown>;
564
+ export interface ResolveSeoInput {
565
+ /** The locale being rendered (`en-US`). */
566
+ locale: string | null;
567
+ /** The locale served at `/`; the last fallback when a map has no entry for `locale`. */
568
+ defaultLocale?: string | null;
569
+ context: SeoContext;
570
+ /** The platform's setting, or `null` (unset, or the read failed). */
571
+ site: SeoSetting | null;
572
+ /** The site's own name, used when the setting names none. */
573
+ siteName?: string | null;
574
+ /** The site's origin (`https://shop.example`); without it no canonical or absolute image exists. */
575
+ siteUrl?: string | null;
576
+ /** The route's path, with its locale prefix, as it is served. */
577
+ path?: string | null;
578
+ /** The page's or template's own `seo` field value. */
579
+ entry?: SeoEntryValue | null;
580
+ /** The route template's `seo` field value, when the route renders through one. */
581
+ template?: SeoEntryValue | null;
582
+ /**
583
+ * The context's variables (`page.title`, `product.name`, ...). `site.*` is filled in here and
584
+ * wins over anything supplied under that name.
585
+ */
586
+ data?: SeoData;
587
+ /** The image the content itself offers (a product's first image); used after the entry's own. */
588
+ contentImage?: string | null;
589
+ /** A preview build: robots is `noindex` whatever the content says. */
590
+ isPreview?: boolean;
591
+ }
592
+ export interface ResolvedSeo {
593
+ title: string;
594
+ description: string;
595
+ /** The Open Graph title: the entry's or template's `ogTitle`, else `title`. */
596
+ ogTitle: string;
597
+ /** The Open Graph description: the entry's or template's `ogDescription`, else `description`. */
598
+ ogDescription: string;
599
+ /** Absolute image URL, or `null`. */
600
+ image: string | null;
601
+ /** Absolute canonical URL, or `null` when no site origin is known. */
602
+ canonical: string | null;
603
+ noindex: boolean;
604
+ ogType: 'website' | 'product';
605
+ /** `@handle` form, or `null`. */
606
+ twitterSite: string | null;
607
+ }
608
+ /** The title pattern used when neither the context nor the site sets one. */
609
+ export declare const DEFAULT_TITLE_PATTERN = "{{page.title}} · {{site.name}}";
610
+ /** The home page's default: the site's name alone. */
611
+ export declare const DEFAULT_HOME_TITLE_PATTERN = "{{site.name}}";
612
+ /** One pass of `{{path}}` substitution; unknown and empty values become `''`. No tidying. */
613
+ export declare function substituteSeoPattern(pattern: string, data: SeoData): string;
614
+ /** Collapses whitespace and drops leading, trailing and doubled separators. */
615
+ export declare function tidySeoTitle(value: string): string;
616
+ /** Substitutes, then tidies: the title rule the shared vectors pin down. */
617
+ export declare function renderSeoTitle(pattern: string, data: SeoData): string;
618
+ /**
619
+ * One locale's string out of a string or a locale map: the exact tag, the same language, the
620
+ * default locale, then `''`.
621
+ */
622
+ export declare function pickSeoLocale(value: string | SeoLocaleMap | null | undefined, locale: string | null, defaultLocale?: string | null): string;
623
+ /** Resolves every SEO value one route needs. Pure; never throws on malformed content. */
624
+ export declare function resolveSeo(input: ResolveSeoInput): ResolvedSeo;
625
+ //#endregion
626
+ //#region src/sitemap.d.ts
627
+ /**
628
+ * `sitemap.xml` and `robots.txt` for a static build. Framework-free and pure: the theme-nuxt
629
+ * module feeds it the prerendered route list, a test reads every byte without a Nuxt app.
630
+ *
631
+ * Why the input is already fanned out per locale: which paths exist under which locale prefix is
632
+ * the module's routing (`localePathFor`), not this file's. A page is one entry holding one
633
+ * `variant` per locale it is served in, and every variant lists its siblings as
634
+ * `xhtml:link rel="alternate" hreflang` (plus `x-default`), which is what tells a search engine
635
+ * the URLs are one page in several languages.
636
+ */
637
+ /** One URL of a page: the page as it is spelled under one locale. */
638
+ export interface SitemapVariant {
639
+ /** The locale tag written as `hreflang`; `null` on a site with no locales. */
640
+ locale: string | null;
641
+ /** The served path, with its locale prefix (`/en-US/about`). */
642
+ path: string;
643
+ /** The page's own canonical URL for this variant, when it has one. */
644
+ canonical?: string | null;
645
+ /** The variant served at `/`: what `x-default` points at. */
646
+ isDefault?: boolean;
647
+ }
648
+ export interface SitemapPage {
649
+ variants: readonly SitemapVariant[];
650
+ /** When the content last changed: an ISO string or a `Date`. Anything unparsable is omitted. */
651
+ lastmod?: string | Date | null;
652
+ /** A `noindex` page is left out of the sitemap altogether. */
653
+ noindex?: boolean;
654
+ }
655
+ export interface SitemapLimits {
656
+ /** sitemaps.org: 50,000 URLs per file. */
657
+ maxUrls?: number;
658
+ /** sitemaps.org: 50 MiB uncompressed per file. */
659
+ maxBytes?: number;
660
+ }
661
+ export interface SitemapFile {
662
+ /** The file name inside the site root: `sitemap.xml`, `sitemap-1.xml`, ... */
663
+ name: string;
664
+ xml: string;
665
+ }
666
+ export declare const SITEMAP_MAX_URLS = 50000;
667
+ export declare const SITEMAP_MAX_BYTES = 52428800;
668
+ /** The absolute origin of `siteUrl` (`https://shop.example`, no trailing slash), or `null`. */
669
+ export declare function siteOrigin(siteUrl: string | null | undefined): string | null;
670
+ export declare function escapeXml(value: string): string;
671
+ /** A W3C datetime (`2026-01-02T03:04:05.000Z`), or `null` for anything that is not a date. */
672
+ export declare function sitemapLastmod(value: string | Date | null | undefined): string | null;
673
+ /**
674
+ * The sitemap files for `pages`: one `sitemap.xml` (a `urlset`), or, when the URLs do not fit the
675
+ * limits, a `sitemap.xml` that is a `sitemapindex` over `sitemap-1.xml`, `sitemap-2.xml`, ...
676
+ *
677
+ * Empty when `siteUrl` is not an absolute http(s) URL (a sitemap of relative URLs is invalid) and
678
+ * when no page is indexable.
679
+ */
680
+ export declare function buildSitemap(input: {
681
+ pages: readonly SitemapPage[];
682
+ siteUrl: string | null | undefined;
683
+ limits?: SitemapLimits;
684
+ }): SitemapFile[];
685
+ /**
686
+ * The `robots.txt` body.
687
+ *
688
+ * A **preview** build disallows everything and names no sitemap. A production build allows
689
+ * everything, adds the merchant's own lines (`extra`), and names the sitemap when there is one.
690
+ * `extra` is untrusted text: control characters are dropped, every line is trimmed, and a line
691
+ * that opens a second `User-agent` group is kept as the merchant wrote it (that is the point of
692
+ * the field), after the platform's group.
693
+ */
694
+ export declare function buildRobots(input: {
695
+ target: 'production' | 'preview';
696
+ siteUrl?: string | null;
697
+ extra?: string | null;
698
+ /** Name `<origin>/sitemap.xml`; only honoured in production with an absolute `siteUrl`. */
699
+ sitemap?: boolean;
700
+ }): string;
701
+ /**
702
+ * The `<link rel="alternate" hreflang>` set for one page, for the head: one per locale plus
703
+ * `x-default`. `pathFor(locale)` spells the page under that locale (`undefined`: the one
704
+ * served at `/`, for `x-default`). Absolute when `siteUrl` is known, otherwise the paths as given. Empty for fewer
705
+ * than two locales: a single-locale site has no alternates.
706
+ */
707
+ export declare function buildAlternates(input: {
708
+ locales: readonly string[];
709
+ pathFor: (locale: string | undefined) => string;
710
+ siteUrl?: string | null;
711
+ }): Array<{
712
+ rel: 'alternate';
713
+ hreflang: string;
714
+ href: string;
715
+ }>;
716
+ //#endregion
717
+ //#region src/structuredData.d.ts
718
+ /**
719
+ * schema.org JSON-LD builders, framework-free. A theme's page feeds them plain data it already
720
+ * renders from (the same price, currency and stock the visible `<Price>` and stock line read), and
721
+ * `@eldrajs/theme-nuxt`'s `useStructuredData` writes the result into the head. Nothing here reads
722
+ * a gateway, a route or the DOM.
723
+ *
724
+ * Rules every builder follows, so a theme never has to:
725
+ *
726
+ * - An `undefined`, `null`, empty string, empty array or empty object is **omitted**, never
727
+ * emitted: a half-empty node is worse than none for a crawler, and Google penalises made-up
728
+ * values (so there is no rating unless the caller has real ones).
729
+ * - Prices are the amount rounded to the **store currency's own fraction digits** (`ISK` has none,
730
+ * `USD` two), the same rounding the rendered price uses.
731
+ * - `availability` is a full schema.org URL.
732
+ * - `serializeLd` escapes `<` (and the two line separators) so a product named `</script>` cannot
733
+ * break out of the tag.
734
+ */
735
+ /** One JSON-LD node. */
736
+ export type JsonLd = Record<string, unknown>;
737
+ /** The kinds of node a theme writes; the opt-out and the extender are keyed by these. */
738
+ export type StructuredDataType = 'product' | 'breadcrumb' | 'itemList' | 'organization' | 'website';
739
+ export declare const STRUCTURED_DATA_TYPES: readonly StructuredDataType[];
740
+ export type LdAvailability = 'InStock' | 'OutOfStock' | 'PreOrder' | 'LimitedAvailability';
741
+ export interface ProductLdVariant {
742
+ sku?: string | null;
743
+ /** Free text in the catalog; emitted as `gtin` only when it is a valid GTIN-8/12/13/14. */
744
+ gtin?: string | null;
745
+ /** Major units. */
746
+ price: number;
747
+ /** The pre-sale price in major units; written as the offer's list price when above `price`. */
748
+ compareAt?: number | null;
749
+ availability: LdAvailability;
750
+ url?: string | null;
751
+ /** ISO 8601 date; the end of the sale price. */
752
+ priceValidUntil?: string | null;
753
+ }
754
+ export interface ProductLdInput {
755
+ url: string;
756
+ name: string;
757
+ description?: string | null;
758
+ images?: readonly string[];
759
+ brand?: string | null;
760
+ variants: readonly ProductLdVariant[];
761
+ /** ISO 4217. Without one no offer is written: a price with no currency is not a price. */
762
+ currency?: string | null;
763
+ /** Only real review data; `undefined` writes nothing. */
764
+ ratings?: {
765
+ value: number;
766
+ count: number;
767
+ } | null;
768
+ }
769
+ /** The amount as the number written in an offer: rounded to the currency's own digits. */
770
+ export declare function ldPrice(amount: number, currency: string): number;
771
+ /**
772
+ * The GTIN if `value` is a valid GTIN-8/12/13/14 (digits only, GS1 check digit correct), else
773
+ * `null`. A barcode field is free text, so anything else (an internal code, a mistyped digit) is
774
+ * left out rather than sent to a crawler as an identifier.
775
+ */
776
+ export declare function validGtin(value: string | null | undefined): string | null;
777
+ /**
778
+ * A `Product`. One variant, or several at one price, is an `Offer`; variants at different prices
779
+ * are an `AggregateOffer` (`lowPrice`, `highPrice`, `offerCount`, one `Offer` each). With no
780
+ * currency or no variants the node carries no offers at all.
781
+ */
782
+ export declare function buildProductLd(input: ProductLdInput): JsonLd;
783
+ /** A `BreadcrumbList`, root first. Every level carries its URL, the last one included. */
784
+ export declare function buildBreadcrumbLd(items: readonly {
785
+ name: string;
786
+ url: string;
787
+ }[]): JsonLd;
788
+ /** An `ItemList` of the things a listing page shows, in the order shown. */
789
+ export declare function buildItemListLd(items: readonly {
790
+ url: string;
791
+ name: string;
792
+ }[]): JsonLd;
793
+ export interface OrganizationLdInput {
794
+ name: string;
795
+ url: string;
796
+ logo?: string | null;
797
+ sameAs?: readonly string[];
798
+ contact?: {
799
+ email?: string | null;
800
+ telephone?: string | null;
801
+ } | null;
802
+ }
803
+ export declare function buildOrganizationLd(input: OrganizationLdInput): JsonLd;
804
+ export interface WebSiteLdInput {
805
+ name: string;
806
+ url: string;
807
+ /** The site's search page path (`/search`), or `null`/absent when there is none. A SearchAction
808
+ * pointing at a page that does not exist is worse than none. It is queried with `?q=`. */
809
+ searchPath?: string | null;
810
+ }
811
+ export declare function buildWebSiteLd(input: WebSiteLdInput): JsonLd;
812
+ /**
813
+ * The text of `<script type="application/ld+json">`. One node is written as itself, several as an
814
+ * array. `<` is written as its JSON escape (so `</script>` and `<!--` cannot occur) and U+2028/U+2029 are
815
+ * escaped; the result is still plain JSON.
816
+ */
817
+ export declare function serializeLd(nodes: readonly JsonLd[]): string;
818
+ export declare const LD_DESCRIPTION_MAX = 5000;
819
+ /**
820
+ * A description as plain text for `description`: a string with its HTML tags dropped, or a rich-text
821
+ * document (nodes with `text`/`content`) flattened, whitespace collapsed, cut at `max` characters
822
+ * on a word boundary.
823
+ */
824
+ export declare function ldPlainText(value: unknown, max?: number): string;
825
+ /** A built node and what kind it is. */
826
+ export interface StructuredDataEntry {
827
+ type: StructuredDataType;
828
+ node: JsonLd;
829
+ }
830
+ /** What a theme can say about the nodes it writes. */
831
+ export interface StructuredDataPolicy {
832
+ /** `true` writes none; a list switches those node kinds off. */
833
+ disable?: readonly StructuredDataType[] | boolean;
834
+ /** Edit a node (return the new one) or drop it (return `null`). Runs after `disable`. */
835
+ extend?: (type: StructuredDataType, node: JsonLd, context: StructuredDataContext) => JsonLd | null;
836
+ }
837
+ export interface StructuredDataContext {
838
+ path: string;
839
+ locale: string | null;
840
+ }
841
+ /** Applies the theme's opt-out and extender to the nodes a page built. Pure. */
842
+ export declare function applyStructuredDataPolicy(entries: readonly StructuredDataEntry[], policy: StructuredDataPolicy, context: StructuredDataContext): JsonLd[];
843
+ //#endregion
407
844
  export { type BeforeInputClassification, type BlockFieldDefinition, type BlockFieldsMap, BlockSlotDefinition, type BuildRichTextTreeOptions, CatalogDoc, CatalogList, CatalogQuery, ColorLiteral, ColorSelection, ContainerOverride, ContainerPreset, CssLength, CssTokenLength, DEFAULT_IMAGE_FRAMING, DEFAULT_LAYOUT_BREAKPOINTS, DesignTokenCatalog, DesignTokenId, DesignTokenValidationCode, DesignTokenValidationError, DynamicRouteResolution, EDIT_MODE_HIDDEN_OPACITY, EldraCatalogReader, EldraClient, EldraClientError, EldraClientOptions, EldraRetryOptions, EntryDoc, EntryList, EntryQuery, FrameRect, IMAGE_FRAMING_MAX_ZOOM, IMAGE_FRAMING_MIN_ZOOM, ImageFraming, LAYOUT_BREAKPOINTS, LayoutBlockNode, LayoutBreakpoint, LayoutBreakpoints, LayoutContainerNode, LayoutDocument, LayoutNode, LayoutRenderBlockNode, LayoutRenderModel, LayoutRenderNode, LayoutStyle, LayoutValidationCode, LayoutValidationError, LayoutValidationIssue, MAX_DYNAMIC_ROUTE_PATTERN_BYTES, type NegotiatedEditorCapabilities, NormalizedLayoutResult, type OverlayRuntime, type OverlayRuntimeOptions, PREVIEW_ROUTER_MESSAGE_TYPES, PageLayoutDocument, PageLayoutNode, type PageLike, PageMeta, ParsedDynamicRoutePattern, type PreviewMessageRouter, type PreviewRouterMessageType, ResolveEntryListBody, ResolvedLayoutDocument, ResolvedLayoutNode, ResolvedLayoutStyle, Responsive, ResponsiveTokenValue, type ReusableComponentBinding, type ReusableComponentPlacement, type ReusableComponentProjection, type ReusableComponentResolver, type ReusableComponentRevision, ReusableComponentSnapshotCache, ReusableLayoutOptions, ReusableLayoutRenderModel, ReusableLayoutRenderNode, ReusablePerspective, type ReusableRenderIdentity, type RichTextDomPoint, type RichTextFieldIdentity, type RichTextMark, type RichTextNode, type RichTextPositionNode, type RichTextPositions, type RichTextRenderChild, type RichTextRenderNode, type RichTextRenderStateChange, type RichTextSelectionContext, type RichTextToolbarControl, RouteTemplateLike, SiteDesignTokenOverrides, SizingLength, SlotValidationContext, Spacing, type StegaMeta, TemplateBlockDefinition, TemplateBlockFieldDefinition, TemplateBlockNode, TemplateLayoutContext, TemplateLayoutDocument, TemplateLayoutNode, TemplateLayoutRenderModel, TemplateLayoutRenderNode, ThemeColorToken, ThemeDesignTokens, WidthLength, activeLayoutBreakpoint, applyDesignTokenOverrides, buildDynamicRoutePath, buildTemplateBlockRenames, catalogRouteTarget, clampFocal, clampImageFraming, classifyBeforeInput, createLayoutRenderModel, createOverlayRuntime, createPreviewMessageRouter, createProjectionResolver, createReusableLayoutRenderModel, createTemplateLayoutRenderModel, decodeStega, designTokenRevisionHash, encodeStega, focalBand, framingDrag, framingZoom, generateDesignTokenCss, generateLayoutCss, generateTailwindThemeCss, hiddenLayoutBreakpoints, imageFramingAttrs, imageFramingStyle, layoutNodeClass, layoutRenderNodeId, matchDynamicRoutePattern, normalizeColorSelection, normalizeImageFraming, normalizeLayoutDocument, normalizeSiteDesignTokenOverrides, normalizeThemeDesignTokens, parseDynamicRoutePattern, parseImageFramingValueAttr, resolveColorSelection, resolveDesignTokenCatalog, resolveLayoutBreakpoints, resolveLayoutDocument, resolvePagePath, resolveRoute, responsiveValue, stripStega, unscaledFrameRect, validateLayoutDocument };