@eldrajs/theme-core 0.3.3 → 0.3.5
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,12 @@ Release-please writes the generated notes from commit messages and does not repl
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
+
- **Currencies (WS-1391).** `SELLING_CURRENCIES`, `currencyForCountry(country)` (one table, country code to selling currency), `countryFromHeader(value)`, `VISITOR_COUNTRY_PATH`, `resolveVisitorCurrency({ base, offered, remembered, country })` (the remembered choice, then the visitor's country, then the store's own currency, each only when offered) and `offeredCurrencies(base, listed)`.
|
|
9
|
+
- **`getTypeScriptDefinitions({ sdkAugmentation })` (WS-434, contract 6.1.0).** `true` sends
|
|
10
|
+
`sdkAugmentation=true`, asking the gateway to append the `declare module '@eldrajs/sdk'` block that
|
|
11
|
+
fills `EldraProductExtensions`, so product extensions are typed. Off by default: without it the
|
|
12
|
+
definitions are plain interfaces with no module declaration.
|
|
13
|
+
|
|
8
14
|
- **Company facts in `Organization`, alternate names in `WebSite`.** `buildOrganizationLd` takes
|
|
9
15
|
optional `legalName`, `taxID` (the kennitala in Iceland) and `address` (written as a
|
|
10
16
|
`PostalAddress`, left out when every part is empty); `buildWebSiteLd` takes an optional
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StegaMeta, decodeStega, encodeStega, stripStega } from "./stega.js";
|
|
2
|
-
import { C as ResolveEntryListBody, S as PageMeta, _ as EldraClientOptions, a as TemplateLayoutDocument, b as EntryList, c as TemplateLayoutRenderNode, d as CatalogDoc, f as CatalogList, g as EldraClientError, h as EldraClient, i as TemplateLayoutContext, l as buildTemplateBlockRenames, m as EldraCatalogReader, n as TemplateBlockFieldDefinition, o as TemplateLayoutNode, p as CatalogQuery, r as TemplateBlockNode, s as TemplateLayoutRenderModel, t as TemplateBlockDefinition, u as createTemplateLayoutRenderModel, v as EldraRetryOptions, x as EntryQuery, y as EntryDoc } from "./templateLayout-
|
|
2
|
+
import { C as ResolveEntryListBody, S as PageMeta, _ as EldraClientOptions, a as TemplateLayoutDocument, b as EntryList, c as TemplateLayoutRenderNode, d as CatalogDoc, f as CatalogList, g as EldraClientError, h as EldraClient, i as TemplateLayoutContext, l as buildTemplateBlockRenames, m as EldraCatalogReader, n as TemplateBlockFieldDefinition, o as TemplateLayoutNode, p as CatalogQuery, r as TemplateBlockNode, s as TemplateLayoutRenderModel, t as TemplateBlockDefinition, u as createTemplateLayoutRenderModel, v as EldraRetryOptions, x as EntryQuery, y as EntryDoc } from "./templateLayout-Dp3KYV2b.js";
|
|
3
3
|
import { a as buildDynamicRoutePath, c as parseDynamicRoutePattern, d as resolvePagePath, i as RouteTemplateLike, l as resolveRoute, n as MAX_DYNAMIC_ROUTE_PATTERN_BYTES, o as catalogRouteTarget, r as ParsedDynamicRoutePattern, s as matchDynamicRoutePattern, t as DynamicRouteResolution, u as PageLike } from "./dynamicRoute-DzSNn4tV.js";
|
|
4
4
|
import { a as RichTextRenderStateChange, c as NegotiatedEditorCapabilities, d as PreviewRouterMessageType, f as createPreviewMessageRouter, i as RichTextFieldIdentity, l as PREVIEW_ROUTER_MESSAGE_TYPES, n as OverlayRuntime, o as classifyBeforeInput, r as OverlayRuntimeOptions, s as createOverlayRuntime, t as BeforeInputClassification, u as PreviewMessageRouter } from "./overlay-mKeZLljc.js";
|
|
5
5
|
import { A as generateLayoutCss, C as Responsive, D as WidthLength, E as Spacing, F as resolveLayoutBreakpoints, I as resolveLayoutDocument, L as validateLayoutDocument, M as layoutNodeClass, N as layoutRenderNodeId, O as activeLayoutBreakpoint, P as normalizeLayoutDocument, S as ResolvedLayoutStyle, T as SlotValidationContext, _ as LayoutValidationError, a as LAYOUT_BREAKPOINTS, b as ResolvedLayoutDocument, c as LayoutBreakpoints, d as LayoutNode, f as LayoutRenderBlockNode, g as LayoutValidationCode, h as LayoutStyle, i as EDIT_MODE_HIDDEN_OPACITY, j as hiddenLayoutBreakpoints, k as createLayoutRenderModel, l as LayoutContainerNode, m as LayoutRenderNode, n as CssLength, o as LayoutBlockNode, p as LayoutRenderModel, r as DEFAULT_LAYOUT_BREAKPOINTS, s as LayoutBreakpoint, t as BlockSlotDefinition, u as LayoutDocument, v as LayoutValidationIssue, w as SizingLength, x as ResolvedLayoutNode, y as NormalizedLayoutResult } from "./layout-CkPOfiOM.js";
|
|
@@ -831,4 +831,27 @@ export interface StructuredDataContext {
|
|
|
831
831
|
}
|
|
832
832
|
/** Applies the theme's opt-out and extender to the nodes a page built. Pure. */
|
|
833
833
|
export declare function applyStructuredDataPolicy(entries: readonly StructuredDataEntry[], policy: StructuredDataPolicy, context: StructuredDataContext): JsonLd[];
|
|
834
|
+
/** The currencies a shop can sell in, in the platform's own order (WS-1383). */
|
|
835
|
+
export declare const SELLING_CURRENCIES: readonly ["ISK", "EUR", "USD", "GBP", "CAD", "DKK", "NOK", "SEK"];
|
|
836
|
+
type SellingCurrency = (typeof SELLING_CURRENCIES)[number];
|
|
837
|
+
/** The selling currency a country pays in (ISO 3166-1 alpha-2, as `countryFromHeader` answers it), or `null`. */
|
|
838
|
+
export declare function currencyForCountry(country: string | null | undefined): SellingCurrency | null;
|
|
839
|
+
export interface VisitorCurrencyInput {
|
|
840
|
+
/** The shop's own currency, what every page is built in. */
|
|
841
|
+
base: string;
|
|
842
|
+
/** The currencies the shop shows, `base` first. */
|
|
843
|
+
offered: readonly string[];
|
|
844
|
+
/** The visitor's earlier choice, if any. */
|
|
845
|
+
remembered?: string | null;
|
|
846
|
+
/** The visitor's country, as the edge reports it. */
|
|
847
|
+
country?: string | null;
|
|
848
|
+
}
|
|
849
|
+
/** Remembered choice, then the visitor's country, then the shop's own currency: each only if offered. */
|
|
850
|
+
export declare function resolveVisitorCurrency(input: VisitorCurrencyInput): string;
|
|
851
|
+
/** Selling currencies only, no repeats, `base` first; a list without `base` is not trusted and answers `[base]`. */
|
|
852
|
+
export declare function offeredCurrencies(base: string, listed: readonly unknown[] | null | undefined): string[];
|
|
853
|
+
/** The site's own route that answers `{ country }` from the edge's `CF-IPCountry` header. */
|
|
854
|
+
export declare const VISITOR_COUNTRY_PATH = "/_eldra/visitor";
|
|
855
|
+
/** A two-letter country from `CF-IPCountry`, or `null` for none, unknown (`XX`) or Tor (`T1`). */
|
|
856
|
+
export declare function countryFromHeader(value: string | null | undefined): string | null;
|
|
834
857
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -607,6 +607,7 @@ function createEldraClient(opts) {
|
|
|
607
607
|
if (tsOpts?.schemas?.length) url.searchParams.set("schemas", tsOpts.schemas.join(","));
|
|
608
608
|
if (tsOpts?.maxDepth !== void 0) url.searchParams.set("maxDepth", String(tsOpts.maxDepth));
|
|
609
609
|
if (tsOpts?.moduleName !== void 0) url.searchParams.set("moduleName", tsOpts.moduleName);
|
|
610
|
+
if (tsOpts?.sdkAugmentation) url.searchParams.set("sdkAugmentation", "true");
|
|
610
611
|
return await (await request(url)).text();
|
|
611
612
|
},
|
|
612
613
|
enablePreview(token) {
|
|
@@ -1760,4 +1761,99 @@ function applyStructuredDataPolicy(entries, policy, context) {
|
|
|
1760
1761
|
}
|
|
1761
1762
|
return out;
|
|
1762
1763
|
}
|
|
1763
|
-
|
|
1764
|
+
// src/currency.ts
|
|
1765
|
+
/** The currencies a shop can sell in, in the platform's own order (WS-1383). */
|
|
1766
|
+
const SELLING_CURRENCIES = [
|
|
1767
|
+
"ISK",
|
|
1768
|
+
"EUR",
|
|
1769
|
+
"USD",
|
|
1770
|
+
"GBP",
|
|
1771
|
+
"CAD",
|
|
1772
|
+
"DKK",
|
|
1773
|
+
"NOK",
|
|
1774
|
+
"SEK"
|
|
1775
|
+
];
|
|
1776
|
+
const COUNTRY_CURRENCY = {
|
|
1777
|
+
...Object.fromEntries([
|
|
1778
|
+
"AD",
|
|
1779
|
+
"AT",
|
|
1780
|
+
"AX",
|
|
1781
|
+
"BE",
|
|
1782
|
+
"BG",
|
|
1783
|
+
"BL",
|
|
1784
|
+
"CY",
|
|
1785
|
+
"DE",
|
|
1786
|
+
"EE",
|
|
1787
|
+
"ES",
|
|
1788
|
+
"FI",
|
|
1789
|
+
"FR",
|
|
1790
|
+
"GF",
|
|
1791
|
+
"GP",
|
|
1792
|
+
"GR",
|
|
1793
|
+
"HR",
|
|
1794
|
+
"IE",
|
|
1795
|
+
"IT",
|
|
1796
|
+
"LT",
|
|
1797
|
+
"LU",
|
|
1798
|
+
"LV",
|
|
1799
|
+
"MC",
|
|
1800
|
+
"ME",
|
|
1801
|
+
"MF",
|
|
1802
|
+
"MQ",
|
|
1803
|
+
"MT",
|
|
1804
|
+
"NL",
|
|
1805
|
+
"PM",
|
|
1806
|
+
"PT",
|
|
1807
|
+
"RE",
|
|
1808
|
+
"SI",
|
|
1809
|
+
"SK",
|
|
1810
|
+
"SM",
|
|
1811
|
+
"VA",
|
|
1812
|
+
"XK",
|
|
1813
|
+
"YT"
|
|
1814
|
+
].map((country) => [country, "EUR"])),
|
|
1815
|
+
IS: "ISK",
|
|
1816
|
+
US: "USD",
|
|
1817
|
+
AS: "USD",
|
|
1818
|
+
GU: "USD",
|
|
1819
|
+
MP: "USD",
|
|
1820
|
+
PR: "USD",
|
|
1821
|
+
UM: "USD",
|
|
1822
|
+
VI: "USD",
|
|
1823
|
+
GB: "GBP",
|
|
1824
|
+
GG: "GBP",
|
|
1825
|
+
IM: "GBP",
|
|
1826
|
+
JE: "GBP",
|
|
1827
|
+
CA: "CAD",
|
|
1828
|
+
DK: "DKK",
|
|
1829
|
+
FO: "DKK",
|
|
1830
|
+
GL: "DKK",
|
|
1831
|
+
NO: "NOK",
|
|
1832
|
+
SJ: "NOK",
|
|
1833
|
+
SE: "SEK"
|
|
1834
|
+
};
|
|
1835
|
+
/** The selling currency a country pays in (ISO 3166-1 alpha-2, as `countryFromHeader` answers it), or `null`. */
|
|
1836
|
+
function currencyForCountry(country) {
|
|
1837
|
+
return country ? COUNTRY_CURRENCY[country] ?? null : null;
|
|
1838
|
+
}
|
|
1839
|
+
/** Remembered choice, then the visitor's country, then the shop's own currency: each only if offered. */
|
|
1840
|
+
function resolveVisitorCurrency(input) {
|
|
1841
|
+
const offered = new Set(input.offered);
|
|
1842
|
+
if (input.remembered && offered.has(input.remembered)) return input.remembered;
|
|
1843
|
+
const fromCountry = currencyForCountry(input.country);
|
|
1844
|
+
if (fromCountry !== null && offered.has(fromCountry)) return fromCountry;
|
|
1845
|
+
return input.base;
|
|
1846
|
+
}
|
|
1847
|
+
/** Selling currencies only, no repeats, `base` first; a list without `base` is not trusted and answers `[base]`. */
|
|
1848
|
+
function offeredCurrencies(base, listed) {
|
|
1849
|
+
if (!Array.isArray(listed) || !listed.includes(base)) return [base];
|
|
1850
|
+
return [base, ...SELLING_CURRENCIES.filter((code) => code !== base && listed.includes(code))];
|
|
1851
|
+
}
|
|
1852
|
+
/** The site's own route that answers `{ country }` from the edge's `CF-IPCountry` header. */
|
|
1853
|
+
const VISITOR_COUNTRY_PATH = "/_eldra/visitor";
|
|
1854
|
+
/** A two-letter country from `CF-IPCountry`, or `null` for none, unknown (`XX`) or Tor (`T1`). */
|
|
1855
|
+
function countryFromHeader(value) {
|
|
1856
|
+
const code = (value ?? "").trim().toUpperCase();
|
|
1857
|
+
return /^[A-Z]{2}$/.test(code) && code !== "XX" ? code : null;
|
|
1858
|
+
}
|
|
1859
|
+
export { ANALYTICS_MAX_KEY_BYTES, ANALYTICS_MAX_NAME_BYTES, ANALYTICS_MAX_PROPS, ANALYTICS_MAX_VALUE_BYTES, ANALYTICS_QUEUE_LIMIT, DEFAULT_HOME_TITLE_PATTERN, DEFAULT_IMAGE_FRAMING, DEFAULT_LAYOUT_BREAKPOINTS, DEFAULT_TITLE_PATTERN, DesignTokenValidationError, EDIT_MODE_HIDDEN_OPACITY, EldraClientError, IMAGE_FRAMING_MAX_ZOOM, IMAGE_FRAMING_MIN_ZOOM, LAYOUT_BREAKPOINTS, LD_DESCRIPTION_MAX, LayoutValidationError, MAX_DYNAMIC_ROUTE_PATTERN_BYTES, PREVIEW_ROUTER_MESSAGE_TYPES, RESERVED_THEME_IDS, RICH_TEXT_LEAF_TYPES, RICH_TEXT_MARK_ELEMENTS, RICH_TEXT_PAD_ATTR, RICH_TEXT_TOOLBAR_CONTROLS, ReusableComponentSnapshotCache, SELLING_CURRENCIES, SEO_SYNTAX, SITEMAP_MAX_BYTES, SITEMAP_MAX_URLS, STRUCTURED_DATA_TYPES, THEME_ID_PATTERN, VISITOR_COUNTRY_PATH, activeLayoutBreakpoint, applyDesignTokenOverrides, applyStructuredDataPolicy, blockApiIdOf, buildAlternates, buildBreadcrumbLd, buildDynamicRoutePath, buildItemListLd, buildOrganizationLd, buildProductLd, buildRichTextTree, buildRobots, buildSitemap, buildTemplateBlockRenames, buildWebSiteLd, catalogRouteTarget, clampFocal, clampImageFraming, classifyBeforeInput, computeRichTextPositions, countryFromHeader, createAnalytics, createEldraClient, createLayoutRenderModel, createOverlayRuntime, createPreviewMessageRouter, createProjectionResolver, createReusableLayoutRenderModel, createTemplateLayoutRenderModel, currencyForCountry, decodeStega, describeSelectionContext, designTokenRevisionHash, domRangeToPositions, encodeEntryDataStega, encodeStega, escapeXml, focalBand, framingDrag, framingZoom, generateDesignTokenCss, generateLayoutCss, generateTailwindThemeCss, getRegisteredThemeId, hiddenLayoutBreakpoints, imageFramingAttrs, imageFramingStyle, isBlockFieldLocalized, layoutIdentityOf, layoutNodeClass, layoutRenderNodeId, ldPlainText, ldPrice, matchDynamicRoutePattern, normalizeAnalyticsProps, normalizeColorSelection, normalizeImageFraming, normalizeLayoutDocument, normalizeSiteDesignTokenOverrides, normalizeThemeDesignTokens, offeredCurrencies, parseDynamicRoutePattern, parseImageFramingValueAttr, pickSeoLocale, projectEntryDataLocale, registerBlockFields, registerThemeId, renderSeoTitle, resolveColorSelection, resolveDesignTokenCatalog, resolveDomPoint, resolveDomPosition, resolveLayoutBreakpoints, resolveLayoutDocument, resolvePagePath, resolveRoute, resolveSeo, resolveVisitorCurrency, responsiveValue, restampRichTextPositions, richTextMarkNameOf, richTextNodeSize, richTextText, safeHref, serializeLd, siteOrigin, sitemapLastmod, stripStega, substituteSeoPattern, themeSchemaApiId, tidySeoTitle, truncateUtf8, unscaledFrameRect, validGtin, validateLayoutDocument };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as TemplateLayoutDocument, c as TemplateLayoutRenderNode, i as TemplateLayoutContext, l as buildTemplateBlockRenames, n as TemplateBlockFieldDefinition, o as TemplateLayoutNode, r as TemplateBlockNode, s as TemplateLayoutRenderModel, t as TemplateBlockDefinition, u as createTemplateLayoutRenderModel } from "./templateLayout-
|
|
1
|
+
import { a as TemplateLayoutDocument, c as TemplateLayoutRenderNode, i as TemplateLayoutContext, l as buildTemplateBlockRenames, n as TemplateBlockFieldDefinition, o as TemplateLayoutNode, r as TemplateBlockNode, s as TemplateLayoutRenderModel, t as TemplateBlockDefinition, u as createTemplateLayoutRenderModel } from "./templateLayout-Dp3KYV2b.js";
|
|
2
2
|
import { n as ReusableComponentPlacement, o as ReusableRenderIdentity, r as ReusableComponentProjection } from "./reusableExpansion-CqrqpK4A.js";
|
|
3
3
|
export { type ReusableComponentPlacement, type ReusableComponentProjection, type ReusableRenderIdentity, TemplateBlockDefinition, TemplateBlockFieldDefinition, TemplateBlockNode, TemplateLayoutContext, TemplateLayoutDocument, TemplateLayoutNode, TemplateLayoutRenderModel, TemplateLayoutRenderNode, buildTemplateBlockRenames, createTemplateLayoutRenderModel };
|
|
@@ -137,6 +137,8 @@ interface EldraClient {
|
|
|
137
137
|
schemas?: string[];
|
|
138
138
|
maxDepth?: number;
|
|
139
139
|
moduleName?: string;
|
|
140
|
+
/** Ask for the `declare module '@eldrajs/sdk'` block that fills `EldraProductExtensions`; off by default. */
|
|
141
|
+
sdkAugmentation?: boolean;
|
|
140
142
|
}): Promise<string>;
|
|
141
143
|
enablePreview(token: string): void;
|
|
142
144
|
disablePreview(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eldrajs/theme-core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Framework-free core of the Eldra theme SDK: the Studio preview bridge, stega encoding, the overlay runtime, layout CSS, rich-text positions, design tokens and image framing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|