@usethrottle/builder-react 0.2.2 → 0.2.4

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.
@@ -84,7 +84,7 @@ function pageOf(raw, initialData) {
84
84
  meta
85
85
  };
86
86
  }
87
- async function staticDataFor(documents, registry, locale) {
87
+ async function staticDataFor(documents, registry, locale, currency) {
88
88
  const bindings = /* @__PURE__ */ new Map();
89
89
  for (const document of documents) {
90
90
  for (const [key, binding] of collectBindings(document, registry)) bindings.set(key, binding);
@@ -93,7 +93,7 @@ async function staticDataFor(documents, registry, locale) {
93
93
  return resolveBindings(
94
94
  bindings,
95
95
  registry,
96
- { locale, preview: false, signal: new AbortController().signal },
96
+ { locale, ...currency === void 0 ? {} : { currency }, preview: false, signal: new AbortController().signal },
97
97
  { include: "static" }
98
98
  );
99
99
  }
@@ -850,7 +850,7 @@ import { createElement as createElement3 } from "react";
850
850
 
851
851
  // src/custom/composite-widget.tsx
852
852
  import { Suspense as Suspense2 } from "react";
853
- import { pageDocumentSchema, validateSettingValue } from "@usethrottle/builder-schema";
853
+ import { pageDocumentSchema, validateSettingValue as validateSettingValue3 } from "@usethrottle/builder-schema";
854
854
 
855
855
  // src/budget.ts
856
856
  import { MAX_TEMPLATE_WEIGHT, templateWeight } from "@usethrottle/builder-schema";
@@ -885,6 +885,7 @@ import {
885
885
  resolveResponsive as resolveResponsive3,
886
886
  safeUrl as safeUrl9,
887
887
  upgradeNodes,
888
+ validateSettingValue as validateSettingValue2,
888
889
  walkNodes as walkNodes2
889
890
  } from "@usethrottle/builder-schema";
890
891
 
@@ -895,6 +896,7 @@ import {
895
896
  resolveColumnWidths,
896
897
  resolveResponsive as resolveResponsive2,
897
898
  safeUrl as safeUrl8,
899
+ validateSettingValue,
898
900
  wrapColumnRows
899
901
  } from "@usethrottle/builder-schema";
900
902
  var TABLET_QUERY = "(max-width:1024px)";
@@ -981,13 +983,14 @@ function widgetDecls(node, device, registry) {
981
983
  const prefix = node.type.startsWith("custom.") ? "--w-" : "--b-";
982
984
  for (const field of fields.values()) {
983
985
  if (field.output !== "css") continue;
984
- const value = resolved[field.key];
986
+ const raw = resolved[field.key];
987
+ const value = raw === void 0 || validateSettingValue(field, raw) === null ? raw : field.default;
985
988
  if (value === null || value === void 0) continue;
986
989
  if (field.key === "hidden") {
987
990
  if (value === true) put(out, "--tb-hide", "none");
988
991
  continue;
989
992
  }
990
- put(out, `${prefix}${field.key}`, cssValue(field.control, value));
993
+ put(out, `${prefix}${field.key}`, cssValue(field.control, value) ?? (field.default === null ? null : cssValue(field.control, field.default)));
991
994
  }
992
995
  return out;
993
996
  }
@@ -1228,12 +1231,25 @@ function prepare(field, value, ctx) {
1228
1231
  }
1229
1232
  return value;
1230
1233
  }
1234
+ function storedLinkPart(value) {
1235
+ if (!isRecord2(value) || value.kind !== "page") return value;
1236
+ const { slug: _slug, href: _href, ...stored } = value;
1237
+ void _slug;
1238
+ void _href;
1239
+ return stored;
1240
+ }
1231
1241
  function settingsAt(node, fields, device, ctx) {
1232
1242
  const base = {};
1233
1243
  for (const field of fields.values()) base[field.key] = field.default;
1234
1244
  const resolved = resolveResponsive3({ ...base, ...node.props }, node.responsive, device);
1235
1245
  const out = {};
1236
- for (const [key, value] of Object.entries(resolved)) out[key] = prepare(fields.get(key), value, ctx);
1246
+ for (const [key, value] of Object.entries(resolved)) {
1247
+ const field = fields.get(key);
1248
+ const freeText = field?.control === "text" || field?.control === "richtext";
1249
+ const checked = field?.control === "link" ? storedLinkPart(value) : value;
1250
+ const usable = field === void 0 || (freeText ? value !== null : validateSettingValue2(field, checked) === null) ? value : field.default;
1251
+ out[key] = prepare(field, usable, ctx);
1252
+ }
1237
1253
  return out;
1238
1254
  }
1239
1255
  function variantsOf(node, def, fields, ctx) {
@@ -1768,14 +1784,14 @@ function build(input) {
1768
1784
  const innerField = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v)?.settings.find((f) => f.key === target.prop);
1769
1785
  if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
1770
1786
  const converted = convert(field, value);
1771
- if (validateSettingValue(innerField, converted) !== null) continue;
1787
+ if (validateSettingValue3(innerField, converted) !== null) continue;
1772
1788
  inner.props[target.prop] = converted;
1773
1789
  const responsive = inner.responsive;
1774
1790
  for (const device of DEVICES3) {
1775
1791
  if (responsive?.[device] !== void 0) delete responsive[device][target.prop];
1776
1792
  const raw = outer.responsive?.[device];
1777
1793
  const plain = field.output === "css" && field.translatable !== true && field.control !== "image" && field.control !== "link";
1778
- if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && validateSettingValue(innerField, raw[binding.setting]) === null) {
1794
+ if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && validateSettingValue3(innerField, raw[binding.setting]) === null) {
1779
1795
  const target$ = inner.responsive ?? (inner.responsive = {});
1780
1796
  (target$[device] ?? (target$[device] = {}))[target.prop] = raw[binding.setting];
1781
1797
  }
@@ -1910,12 +1926,12 @@ function createRendererRegistry(packs, options = {}) {
1910
1926
  // src/server/load-page.ts
1911
1927
  import { BuilderNotFoundError } from "@usethrottle/builder";
1912
1928
  async function loadBuilderPage(options) {
1913
- const { slug, locale, packs = [], slots } = options;
1929
+ const { slug, locale, packs = [], slots, currency } = options;
1914
1930
  const bundle = await getBundle({ client: clientOf(options), locale, page: slug, slots });
1915
1931
  const found = bundle.page;
1916
1932
  if (found === void 0) throw new BuilderNotFoundError(slug);
1917
1933
  if (isRedirect(found)) return { kind: "redirect", redirectTo: found.redirectTo };
1918
- const data = await staticDataFor([found.document], createRendererRegistry(packs), locale);
1934
+ const data = await staticDataFor([found.document], createRendererRegistry(packs), locale, currency);
1919
1935
  return pageOf(found, data);
1920
1936
  }
1921
1937
 
@@ -84,7 +84,7 @@ function pageOf(raw, initialData) {
84
84
  meta
85
85
  };
86
86
  }
87
- async function staticDataFor(documents, registry, locale) {
87
+ async function staticDataFor(documents, registry, locale, currency) {
88
88
  const bindings = /* @__PURE__ */ new Map();
89
89
  for (const document of documents) {
90
90
  for (const [key, binding] of collectBindings(document, registry)) bindings.set(key, binding);
@@ -93,7 +93,7 @@ async function staticDataFor(documents, registry, locale) {
93
93
  return resolveBindings(
94
94
  bindings,
95
95
  registry,
96
- { locale, preview: false, signal: new AbortController().signal },
96
+ { locale, ...currency === void 0 ? {} : { currency }, preview: false, signal: new AbortController().signal },
97
97
  { include: "static" }
98
98
  );
99
99
  }
@@ -888,6 +888,7 @@ var fitsBudget = (ast, limit = MAX_RENDERED_NODES) => _builderschema.templateWei
888
888
 
889
889
 
890
890
 
891
+
891
892
  // src/css-compiler.ts
892
893
 
893
894
 
@@ -897,6 +898,7 @@ var fitsBudget = (ast, limit = MAX_RENDERED_NODES) => _builderschema.templateWei
897
898
 
898
899
 
899
900
 
901
+
900
902
  var TABLET_QUERY = "(max-width:1024px)";
901
903
  var PHONE_QUERY = "(max-width:767px)";
902
904
  var SAFE_VALUE = /^[A-Za-z0-9#%.,()\-+*/_: ]{1,200}$/;
@@ -981,13 +983,14 @@ function widgetDecls(node, device, registry) {
981
983
  const prefix = node.type.startsWith("custom.") ? "--w-" : "--b-";
982
984
  for (const field of fields.values()) {
983
985
  if (field.output !== "css") continue;
984
- const value = resolved[field.key];
986
+ const raw = resolved[field.key];
987
+ const value = raw === void 0 || _builderschema.validateSettingValue.call(void 0, field, raw) === null ? raw : field.default;
985
988
  if (value === null || value === void 0) continue;
986
989
  if (field.key === "hidden") {
987
990
  if (value === true) put(out, "--tb-hide", "none");
988
991
  continue;
989
992
  }
990
- put(out, `${prefix}${field.key}`, cssValue(field.control, value));
993
+ put(out, `${prefix}${field.key}`, _nullishCoalesce(cssValue(field.control, value), () => ( (field.default === null ? null : cssValue(field.control, field.default)))));
991
994
  }
992
995
  return out;
993
996
  }
@@ -1228,12 +1231,25 @@ function prepare(field, value, ctx) {
1228
1231
  }
1229
1232
  return value;
1230
1233
  }
1234
+ function storedLinkPart(value) {
1235
+ if (!isRecord2(value) || value.kind !== "page") return value;
1236
+ const { slug: _slug, href: _href, ...stored } = value;
1237
+ void _slug;
1238
+ void _href;
1239
+ return stored;
1240
+ }
1231
1241
  function settingsAt(node, fields, device, ctx) {
1232
1242
  const base = {};
1233
1243
  for (const field of fields.values()) base[field.key] = field.default;
1234
1244
  const resolved = _builderschema.resolveResponsive.call(void 0, { ...base, ...node.props }, node.responsive, device);
1235
1245
  const out = {};
1236
- for (const [key, value] of Object.entries(resolved)) out[key] = prepare(fields.get(key), value, ctx);
1246
+ for (const [key, value] of Object.entries(resolved)) {
1247
+ const field = fields.get(key);
1248
+ const freeText = _optionalChain([field, 'optionalAccess', _44 => _44.control]) === "text" || _optionalChain([field, 'optionalAccess', _45 => _45.control]) === "richtext";
1249
+ const checked = _optionalChain([field, 'optionalAccess', _46 => _46.control]) === "link" ? storedLinkPart(value) : value;
1250
+ const usable = field === void 0 || (freeText ? value !== null : _builderschema.validateSettingValue.call(void 0, field, checked) === null) ? value : field.default;
1251
+ out[key] = prepare(field, usable, ctx);
1252
+ }
1237
1253
  return out;
1238
1254
  }
1239
1255
  function variantsOf(node, def, fields, ctx) {
@@ -1483,7 +1499,7 @@ var ROLES = new Set(_builderschema.ALLOWED_ROLES);
1483
1499
  function attrAllowed(tag, name) {
1484
1500
  if (_builderschema.DATA_ATTR_RE.test(name)) return !name.startsWith(_builderschema.RESERVED_DATA_PREFIX);
1485
1501
  const own = Object.hasOwn(_builderschema.ALLOWED_ATTRS, tag) ? _builderschema.ALLOWED_ATTRS[tag] : void 0;
1486
- return (_nullishCoalesce(_optionalChain([_builderschema.ALLOWED_ATTRS, 'access', _44 => _44["*"], 'optionalAccess', _45 => _45.includes, 'call', _46 => _46(name)]), () => ( false))) || (_nullishCoalesce(_optionalChain([own, 'optionalAccess', _47 => _47.includes, 'call', _48 => _48(name)]), () => ( false)));
1502
+ return (_nullishCoalesce(_optionalChain([_builderschema.ALLOWED_ATTRS, 'access', _47 => _47["*"], 'optionalAccess', _48 => _48.includes, 'call', _49 => _49(name)]), () => ( false))) || (_nullishCoalesce(_optionalChain([own, 'optionalAccess', _50 => _50.includes, 'call', _51 => _51(name)]), () => ( false)));
1487
1503
  }
1488
1504
  function attrText(attr, env, scope) {
1489
1505
  return attr.value.map((part) => part.type === "text" ? part.value : filtered(lookup(part.path, env, scope), part.filters)).join("");
@@ -1606,14 +1622,14 @@ function compile(snapshot, registry) {
1606
1622
  const source = snapshot.template;
1607
1623
  if (typeof source !== "string") return refuse("no template source");
1608
1624
  const parsed = _builderschema.parseTemplate.call(void 0, source);
1609
- if (!parsed.ok) return refuse(`template does not parse: ${_nullishCoalesce(_optionalChain([parsed, 'access', _49 => _49.issues, 'access', _50 => _50[0], 'optionalAccess', _51 => _51.message]), () => ( "invalid"))}`);
1625
+ if (!parsed.ok) return refuse(`template does not parse: ${_nullishCoalesce(_optionalChain([parsed, 'access', _52 => _52.issues, 'access', _53 => _53[0], 'optionalAccess', _54 => _54.message]), () => ( "invalid"))}`);
1610
1626
  const data = snapshot.data;
1611
1627
  const issues = _builderschema.validateTemplate.call(void 0, parsed.ast, {
1612
1628
  settings: snapshot.settings,
1613
1629
  data: typeof data === "object" && data !== null ? data : {},
1614
1630
  sources: registry.sources()
1615
1631
  });
1616
- if (issues.length > 0) return refuse(`template does not validate: ${_nullishCoalesce(_optionalChain([issues, 'access', _52 => _52[0], 'optionalAccess', _53 => _53.message]), () => ( "invalid"))}`);
1632
+ if (issues.length > 0) return refuse(`template does not validate: ${_nullishCoalesce(_optionalChain([issues, 'access', _55 => _55[0], 'optionalAccess', _56 => _56.message]), () => ( "invalid"))}`);
1617
1633
  if (!fitsBudget(parsed.ast)) return refuse(`it can render more than ${String(_builderschema.MAX_TEMPLATE_WEIGHT)} nodes`);
1618
1634
  const css = scopedCss(snapshot.css, snapshot.type);
1619
1635
  if (css === null) return refuse("its css does not pass the sanitiser");
@@ -1645,16 +1661,16 @@ function parseBody(raw) {
1645
1661
  const stack = Array.isArray(raw.stack) ? raw.stack : void 0;
1646
1662
  if (columns === void 0 === (stack === void 0)) return null;
1647
1663
  const children = columns !== void 0 ? [{ id: WRAP.inner, type: "inner-section", props: {}, columns }] : _nullishCoalesce(stack, () => ( []));
1648
- if (_optionalChain([stack, 'optionalAccess', _54 => _54.some, 'call', _55 => _55((node) => isRecord3(node) && node.type === "inner-section")])) return null;
1664
+ if (_optionalChain([stack, 'optionalAccess', _57 => _57.some, 'call', _58 => _58((node) => isRecord3(node) && node.type === "inner-section")])) return null;
1649
1665
  const parsed = _builderschema.pageDocumentSchema.safeParse({
1650
1666
  schemaVersion: 1,
1651
1667
  sections: [{ id: WRAP.section, type: "section", props: {}, columns: [{ id: WRAP.column, type: "column", props: { width: 100 }, children }] }]
1652
1668
  });
1653
1669
  if (!parsed.success) return null;
1654
- const first = _nullishCoalesce(_optionalChain([parsed, 'access', _56 => _56.data, 'access', _57 => _57.sections, 'access', _58 => _58[0], 'optionalAccess', _59 => _59.columns, 'access', _60 => _60[0], 'optionalAccess', _61 => _61.children]), () => ( []));
1670
+ const first = _nullishCoalesce(_optionalChain([parsed, 'access', _59 => _59.data, 'access', _60 => _60.sections, 'access', _61 => _61[0], 'optionalAccess', _62 => _62.columns, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.children]), () => ( []));
1655
1671
  if (columns !== void 0) {
1656
1672
  const inner = first[0];
1657
- return _optionalChain([inner, 'optionalAccess', _62 => _62.type]) === "inner-section" ? { columns: inner.columns } : null;
1673
+ return _optionalChain([inner, 'optionalAccess', _65 => _65.type]) === "inner-section" ? { columns: inner.columns } : null;
1658
1674
  }
1659
1675
  return { stack: first.filter((node) => node.type !== "inner-section") };
1660
1676
  }
@@ -1708,7 +1724,7 @@ var DEVICES3 = ["tablet", "phone"];
1708
1724
  function withoutAnchor(node) {
1709
1725
  delete node.props.anchor;
1710
1726
  const responsive = node.responsive;
1711
- for (const device of DEVICES3) if (_optionalChain([responsive, 'optionalAccess', _63 => _63[device]]) !== void 0) delete responsive[device].anchor;
1727
+ for (const device of DEVICES3) if (_optionalChain([responsive, 'optionalAccess', _66 => _66[device]]) !== void 0) delete responsive[device].anchor;
1712
1728
  }
1713
1729
  function instanceId(outer, inner) {
1714
1730
  let a = 3735928559;
@@ -1728,9 +1744,9 @@ function build(input) {
1728
1744
  const assets = {};
1729
1745
  const hrefs = /* @__PURE__ */ new Map();
1730
1746
  const innerData = {};
1731
- const keep = (child) => _optionalChain([registry, 'access', _64 => _64.widget, 'call', _65 => _65(child.type, child.v), 'optionalAccess', _66 => _66.kind]) !== "composite";
1732
- const columns = _optionalChain([body, 'access', _67 => _67.columns, 'optionalAccess', _68 => _68.map, 'call', _69 => _69((column2) => ({ ...column2, children: column2.children.filter(keep) }))]);
1733
- const stack = _optionalChain([body, 'access', _70 => _70.stack, 'optionalAccess', _71 => _71.filter, 'call', _72 => _72(keep)]);
1747
+ const keep = (child) => _optionalChain([registry, 'access', _67 => _67.widget, 'call', _68 => _68(child.type, child.v), 'optionalAccess', _69 => _69.kind]) !== "composite";
1748
+ const columns = _optionalChain([body, 'access', _70 => _70.columns, 'optionalAccess', _71 => _71.map, 'call', _72 => _72((column2) => ({ ...column2, children: column2.children.filter(keep) }))]);
1749
+ const stack = _optionalChain([body, 'access', _73 => _73.stack, 'optionalAccess', _74 => _74.filter, 'call', _75 => _75(keep)]);
1734
1750
  const widgets2 = columns !== void 0 ? columns.flatMap((column2) => column2.children) : _nullishCoalesce(stack, () => ( []));
1735
1751
  for (const widget of widgets2) {
1736
1752
  withoutAnchor(widget);
@@ -1765,15 +1781,15 @@ function build(input) {
1765
1781
  const value = props[binding.setting];
1766
1782
  for (const target of binding.targets) {
1767
1783
  const inner = byId.get(target.node);
1768
- const innerField = inner === void 0 ? void 0 : _optionalChain([registry, 'access', _73 => _73.widget, 'call', _74 => _74(inner.type, inner.v), 'optionalAccess', _75 => _75.settings, 'access', _76 => _76.find, 'call', _77 => _77((f) => f.key === target.prop)]);
1784
+ const innerField = inner === void 0 ? void 0 : _optionalChain([registry, 'access', _76 => _76.widget, 'call', _77 => _77(inner.type, inner.v), 'optionalAccess', _78 => _78.settings, 'access', _79 => _79.find, 'call', _80 => _80((f) => f.key === target.prop)]);
1769
1785
  if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
1770
1786
  const converted = convert(field, value);
1771
1787
  if (_builderschema.validateSettingValue.call(void 0, innerField, converted) !== null) continue;
1772
1788
  inner.props[target.prop] = converted;
1773
1789
  const responsive = inner.responsive;
1774
1790
  for (const device of DEVICES3) {
1775
- if (_optionalChain([responsive, 'optionalAccess', _78 => _78[device]]) !== void 0) delete responsive[device][target.prop];
1776
- const raw = _optionalChain([outer, 'access', _79 => _79.responsive, 'optionalAccess', _80 => _80[device]]);
1791
+ if (_optionalChain([responsive, 'optionalAccess', _81 => _81[device]]) !== void 0) delete responsive[device][target.prop];
1792
+ const raw = _optionalChain([outer, 'access', _82 => _82.responsive, 'optionalAccess', _83 => _83[device]]);
1777
1793
  const plain = field.output === "css" && field.translatable !== true && field.control !== "image" && field.control !== "link";
1778
1794
  if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && _builderschema.validateSettingValue.call(void 0, innerField, raw[binding.setting]) === null) {
1779
1795
  const target$ = _nullishCoalesce(inner.responsive, () => ( (inner.responsive = {})));
@@ -1788,7 +1804,7 @@ function build(input) {
1788
1804
  for (const target of input$.targets) {
1789
1805
  const inner = byId.get(target.node);
1790
1806
  const def = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v);
1791
- if (inner === void 0 || _optionalChain([def, 'optionalAccess', _81 => _81.data]) === void 0 || !Object.hasOwn(def.data, target.input)) continue;
1807
+ if (inner === void 0 || _optionalChain([def, 'optionalAccess', _84 => _84.data]) === void 0 || !Object.hasOwn(def.data, target.input)) continue;
1792
1808
  inner.data = { ..._nullishCoalesce(inner.data, () => ( {})), [target.input]: { source: key } };
1793
1809
  innerData[key] = data[name];
1794
1810
  }
@@ -1806,7 +1822,7 @@ function build(input) {
1806
1822
  schemaVersion: 1,
1807
1823
  sections: [{ id: ids.section, type: "section", props: { width: "full" }, columns: [column] }]
1808
1824
  };
1809
- let weight = 2 + (_nullishCoalesce(_optionalChain([columns, 'optionalAccess', _82 => _82.length]), () => ( 0))) + (columns === void 0 ? 0 : 1);
1825
+ let weight = 2 + (_nullishCoalesce(_optionalChain([columns, 'optionalAccess', _85 => _85.length]), () => ( 0))) + (columns === void 0 ? 0 : 1);
1810
1826
  for (const widget of widgets2) {
1811
1827
  const component = registry.component(widget);
1812
1828
  weight += 1 + (component === void 0 ? 0 : _nullishCoalesce(componentWeights.get(component), () => ( 0)));
@@ -1831,7 +1847,7 @@ function CompositeBody(props) {
1831
1847
  locale,
1832
1848
  assets: built.assets,
1833
1849
  mediaOrigin,
1834
- resolveLink: (target) => _nullishCoalesce(_nullishCoalesce(built.hrefs.get(JSON.stringify(target)), () => ( _optionalChain([resolveLink, 'optionalCall', _83 => _83(target)]))), () => ( null))
1850
+ resolveLink: (target) => _nullishCoalesce(_nullishCoalesce(built.hrefs.get(JSON.stringify(target)), () => ( _optionalChain([resolveLink, 'optionalCall', _86 => _86(target)]))), () => ( null))
1835
1851
  }
1836
1852
  );
1837
1853
  }
@@ -1910,12 +1926,12 @@ function createRendererRegistry(packs, options = {}) {
1910
1926
  // src/server/load-page.ts
1911
1927
 
1912
1928
  async function loadBuilderPage(options) {
1913
- const { slug, locale, packs = [], slots } = options;
1929
+ const { slug, locale, packs = [], slots, currency } = options;
1914
1930
  const bundle = await getBundle({ client: clientOf(options), locale, page: slug, slots });
1915
1931
  const found = bundle.page;
1916
1932
  if (found === void 0) throw new (0, _builder.BuilderNotFoundError)(slug);
1917
1933
  if (isRedirect(found)) return { kind: "redirect", redirectTo: found.redirectTo };
1918
- const data = await staticDataFor([found.document], createRendererRegistry(packs), locale);
1934
+ const data = await staticDataFor([found.document], createRendererRegistry(packs), locale, currency);
1919
1935
  return pageOf(found, data);
1920
1936
  }
1921
1937
 
@@ -1956,7 +1972,7 @@ function pagePathOf(settings, page, resolve) {
1956
1972
  return _nullishCoalesce(_builderschema.safeUrl.call(void 0, resolve({ ...page, path }), "href", { mediaOrigin: "" }), () => ( path));
1957
1973
  }
1958
1974
  function originOf(storeUrl) {
1959
- const origin = _optionalChain([storeUrl, 'optionalAccess', _84 => _84.replace, 'call', _85 => _85(/\/+$/u, "")]);
1975
+ const origin = _optionalChain([storeUrl, 'optionalAccess', _87 => _87.replace, 'call', _88 => _88(/\/+$/u, "")]);
1960
1976
  return origin !== void 0 && ORIGIN_RE.test(origin) ? origin : void 0;
1961
1977
  }
1962
1978
  function siteLocales(settings) {
package/dist/index.cjs CHANGED
@@ -188,13 +188,14 @@ function widgetDecls(node, device, registry) {
188
188
  const prefix = node.type.startsWith("custom.") ? "--w-" : "--b-";
189
189
  for (const field of fields.values()) {
190
190
  if (field.output !== "css") continue;
191
- const value = resolved[field.key];
191
+ const raw = resolved[field.key];
192
+ const value = raw === void 0 || (0, import_builder_schema2.validateSettingValue)(field, raw) === null ? raw : field.default;
192
193
  if (value === null || value === void 0) continue;
193
194
  if (field.key === "hidden") {
194
195
  if (value === true) put(out, "--tb-hide", "none");
195
196
  continue;
196
197
  }
197
- put(out, `${prefix}${field.key}`, cssValue(field.control, value));
198
+ put(out, `${prefix}${field.key}`, cssValue(field.control, value) ?? (field.default === null ? null : cssValue(field.control, field.default)));
198
199
  }
199
200
  return out;
200
201
  }
@@ -491,12 +492,25 @@ function prepare(field, value, ctx) {
491
492
  }
492
493
  return value;
493
494
  }
495
+ function storedLinkPart(value) {
496
+ if (!isRecord(value) || value.kind !== "page") return value;
497
+ const { slug: _slug, href: _href, ...stored } = value;
498
+ void _slug;
499
+ void _href;
500
+ return stored;
501
+ }
494
502
  function settingsAt(node, fields, device, ctx) {
495
503
  const base = {};
496
504
  for (const field of fields.values()) base[field.key] = field.default;
497
505
  const resolved = (0, import_builder_schema5.resolveResponsive)({ ...base, ...node.props }, node.responsive, device);
498
506
  const out = {};
499
- for (const [key, value] of Object.entries(resolved)) out[key] = prepare(fields.get(key), value, ctx);
507
+ for (const [key, value] of Object.entries(resolved)) {
508
+ const field = fields.get(key);
509
+ const freeText = field?.control === "text" || field?.control === "richtext";
510
+ const checked = field?.control === "link" ? storedLinkPart(value) : value;
511
+ const usable = field === void 0 || (freeText ? value !== null : (0, import_builder_schema5.validateSettingValue)(field, checked) === null) ? value : field.default;
512
+ out[key] = prepare(field, usable, ctx);
513
+ }
500
514
  return out;
501
515
  }
502
516
  function variantsOf(node, def, fields, ctx) {
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  resolveResponsive as resolveResponsive2,
11
11
  safeUrl as safeUrl2,
12
12
  upgradeNodes,
13
+ validateSettingValue as validateSettingValue2,
13
14
  walkNodes as walkNodes2
14
15
  } from "@usethrottle/builder-schema";
15
16
 
@@ -43,6 +44,7 @@ import {
43
44
  resolveColumnWidths,
44
45
  resolveResponsive,
45
46
  safeUrl,
47
+ validateSettingValue,
46
48
  wrapColumnRows
47
49
  } from "@usethrottle/builder-schema";
48
50
 
@@ -140,13 +142,14 @@ function widgetDecls(node, device, registry) {
140
142
  const prefix = node.type.startsWith("custom.") ? "--w-" : "--b-";
141
143
  for (const field of fields.values()) {
142
144
  if (field.output !== "css") continue;
143
- const value = resolved[field.key];
145
+ const raw = resolved[field.key];
146
+ const value = raw === void 0 || validateSettingValue(field, raw) === null ? raw : field.default;
144
147
  if (value === null || value === void 0) continue;
145
148
  if (field.key === "hidden") {
146
149
  if (value === true) put(out, "--tb-hide", "none");
147
150
  continue;
148
151
  }
149
- put(out, `${prefix}${field.key}`, cssValue(field.control, value));
152
+ put(out, `${prefix}${field.key}`, cssValue(field.control, value) ?? (field.default === null ? null : cssValue(field.control, field.default)));
150
153
  }
151
154
  return out;
152
155
  }
@@ -443,12 +446,25 @@ function prepare(field, value, ctx) {
443
446
  }
444
447
  return value;
445
448
  }
449
+ function storedLinkPart(value) {
450
+ if (!isRecord(value) || value.kind !== "page") return value;
451
+ const { slug: _slug, href: _href, ...stored } = value;
452
+ void _slug;
453
+ void _href;
454
+ return stored;
455
+ }
446
456
  function settingsAt(node, fields, device, ctx) {
447
457
  const base = {};
448
458
  for (const field of fields.values()) base[field.key] = field.default;
449
459
  const resolved = resolveResponsive2({ ...base, ...node.props }, node.responsive, device);
450
460
  const out = {};
451
- for (const [key, value] of Object.entries(resolved)) out[key] = prepare(fields.get(key), value, ctx);
461
+ for (const [key, value] of Object.entries(resolved)) {
462
+ const field = fields.get(key);
463
+ const freeText = field?.control === "text" || field?.control === "richtext";
464
+ const checked = field?.control === "link" ? storedLinkPart(value) : value;
465
+ const usable = field === void 0 || (freeText ? value !== null : validateSettingValue2(field, checked) === null) ? value : field.default;
466
+ out[key] = prepare(field, usable, ctx);
467
+ }
452
468
  return out;
453
469
  }
454
470
  function variantsOf(node, def, fields, ctx) {
@@ -1468,7 +1484,7 @@ import { createElement as createElement3 } from "react";
1468
1484
 
1469
1485
  // src/custom/composite-widget.tsx
1470
1486
  import { Suspense as Suspense2 } from "react";
1471
- import { pageDocumentSchema, validateSettingValue } from "@usethrottle/builder-schema";
1487
+ import { pageDocumentSchema, validateSettingValue as validateSettingValue3 } from "@usethrottle/builder-schema";
1472
1488
 
1473
1489
  // src/custom/template-widget.tsx
1474
1490
  import { Suspense } from "react";
@@ -1866,14 +1882,14 @@ function build(input) {
1866
1882
  const innerField = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v)?.settings.find((f) => f.key === target.prop);
1867
1883
  if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
1868
1884
  const converted = convert(field, value);
1869
- if (validateSettingValue(innerField, converted) !== null) continue;
1885
+ if (validateSettingValue3(innerField, converted) !== null) continue;
1870
1886
  inner.props[target.prop] = converted;
1871
1887
  const responsive = inner.responsive;
1872
1888
  for (const device of DEVICES3) {
1873
1889
  if (responsive?.[device] !== void 0) delete responsive[device][target.prop];
1874
1890
  const raw = outer.responsive?.[device];
1875
1891
  const plain = field.output === "css" && field.translatable !== true && field.control !== "image" && field.control !== "link";
1876
- if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && validateSettingValue(innerField, raw[binding.setting]) === null) {
1892
+ if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && validateSettingValue3(innerField, raw[binding.setting]) === null) {
1877
1893
  const target$ = inner.responsive ?? (inner.responsive = {});
1878
1894
  (target$[device] ?? (target$[device] = {}))[target.prop] = raw[binding.setting];
1879
1895
  }
package/dist/next.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkS2XR224Acjs = require('./chunk-S2XR224A.cjs');
7
+ var _chunkWZOWM2I7cjs = require('./chunk-WZOWM2I7.cjs');
8
8
 
9
9
  // src/next/index.ts
10
10
  var _react = require('react');
@@ -39,6 +39,10 @@ function slugOf(options, params) {
39
39
  if (slug === void 0 || slug === "") _navigation.notFound.call(void 0, );
40
40
  return slug;
41
41
  }
42
+ async function currencyOf(options, params) {
43
+ return typeof options.currency === "function" ? options.currency(params) : options.currency;
44
+ }
45
+ var isNamed = (error, name) => typeof error === "object" && error !== null && error.name === name;
42
46
  async function localeOf(options, params) {
43
47
  if (typeof options.locale === "function") return options.locale(params);
44
48
  if (options.locale !== void 0) return options.locale;
@@ -49,12 +53,15 @@ function createBuilderPage(options) {
49
53
  async function Page(props) {
50
54
  const params = await props.params;
51
55
  const slug = slugOf(options, params);
52
- const loaded = await _chunkS2XR224Acjs.loadBuilderPage.call(void 0, {
53
- ...options,
56
+ const currency = await currencyOf(options, params);
57
+ const { currency: _currency, ...rest } = options;
58
+ const loaded = await _chunkWZOWM2I7cjs.loadBuilderPage.call(void 0, {
59
+ ...rest,
54
60
  slug,
55
- locale: await localeOf(options, params)
61
+ locale: await localeOf(options, params),
62
+ ...currency === void 0 ? {} : { currency }
56
63
  }).catch((error) => {
57
- if (error instanceof _builder.BuilderNotFoundError) _navigation.notFound.call(void 0, );
64
+ if (error instanceof _builder.BuilderNotFoundError || isNamed(error, "BuilderNotFoundError")) _navigation.notFound.call(void 0, );
58
65
  throw error;
59
66
  });
60
67
  if (loaded.kind === "redirect") {
@@ -68,12 +75,12 @@ function createBuilderPage(options) {
68
75
  const params = await props.params;
69
76
  const slug = slugOf(options, params);
70
77
  const locale = await localeOf(options, params);
71
- const client = _chunkS2XR224Acjs.clientOf.call(void 0, options);
78
+ const client = _chunkWZOWM2I7cjs.clientOf.call(void 0, options);
72
79
  try {
73
- const bundle = await _chunkS2XR224Acjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
80
+ const bundle = await _chunkWZOWM2I7cjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
74
81
  const page = bundle.page;
75
- if (page === void 0 || _chunkS2XR224Acjs.isRedirect.call(void 0, page)) return {};
76
- return _chunkS2XR224Acjs.metadataOf.call(void 0, page, {
82
+ if (page === void 0 || _chunkWZOWM2I7cjs.isRedirect.call(void 0, page)) return {};
83
+ return _chunkWZOWM2I7cjs.metadataOf.call(void 0, page, {
77
84
  settings: bundle.site.settings,
78
85
  mediaOrigin: _nullishCoalesce(options.mediaOrigin, () => ( "")),
79
86
  storeUrl: options.storeUrl,
@@ -81,8 +88,8 @@ function createBuilderPage(options) {
81
88
  routeLocale: options.locale === void 0 && typeof params.locale === "string" ? params.locale : void 0
82
89
  });
83
90
  } catch (error) {
84
- if (error instanceof _builder.BuilderNotFoundError) return {};
85
- if (error instanceof _builder.BuilderUnavailableError && client.mode !== "build") return {};
91
+ if (error instanceof _builder.BuilderNotFoundError || isNamed(error, "BuilderNotFoundError")) return {};
92
+ if ((error instanceof _builder.BuilderUnavailableError || isNamed(error, "BuilderUnavailableError")) && client.mode !== "build") return {};
86
93
  throw error;
87
94
  }
88
95
  }
package/dist/next.d.cts CHANGED
@@ -13,6 +13,8 @@ type CreateBuilderPageOptions = ({
13
13
  packs?: readonly WidgetPack[];
14
14
  /** The locale of the page; by default `params.locale` when the route has one, else `en`. */
15
15
  locale?: string | ((params: Params) => string | Promise<string>);
16
+ /** The shopper's currency (a value, or read from the route's params, e.g. from a cookie), as for `loadSite({ currency })`. */
17
+ currency?: string | ((params: Params) => string | undefined | Promise<string | undefined>);
16
18
  /** The slots the layout reads, so the page read can share the layout's. */
17
19
  slots?: readonly string[];
18
20
  /** The store's origin (`https://shop.example.com`), for the canonical link. The Builder does not publish it, so without it a page has no canonical. */
package/dist/next.d.ts CHANGED
@@ -13,6 +13,8 @@ type CreateBuilderPageOptions = ({
13
13
  packs?: readonly WidgetPack[];
14
14
  /** The locale of the page; by default `params.locale` when the route has one, else `en`. */
15
15
  locale?: string | ((params: Params) => string | Promise<string>);
16
+ /** The shopper's currency (a value, or read from the route's params, e.g. from a cookie), as for `loadSite({ currency })`. */
17
+ currency?: string | ((params: Params) => string | undefined | Promise<string | undefined>);
16
18
  /** The slots the layout reads, so the page read can share the layout's. */
17
19
  slots?: readonly string[];
18
20
  /** The store's origin (`https://shop.example.com`), for the canonical link. The Builder does not publish it, so without it a page has no canonical. */
package/dist/next.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  isRedirect,
5
5
  loadBuilderPage,
6
6
  metadataOf
7
- } from "./chunk-NUE2KNT2.js";
7
+ } from "./chunk-IBRAMTUT.js";
8
8
 
9
9
  // src/next/index.ts
10
10
  import { createElement } from "react";
@@ -39,6 +39,10 @@ function slugOf(options, params) {
39
39
  if (slug === void 0 || slug === "") notFound();
40
40
  return slug;
41
41
  }
42
+ async function currencyOf(options, params) {
43
+ return typeof options.currency === "function" ? options.currency(params) : options.currency;
44
+ }
45
+ var isNamed = (error, name) => typeof error === "object" && error !== null && error.name === name;
42
46
  async function localeOf(options, params) {
43
47
  if (typeof options.locale === "function") return options.locale(params);
44
48
  if (options.locale !== void 0) return options.locale;
@@ -49,12 +53,15 @@ function createBuilderPage(options) {
49
53
  async function Page(props) {
50
54
  const params = await props.params;
51
55
  const slug = slugOf(options, params);
56
+ const currency = await currencyOf(options, params);
57
+ const { currency: _currency, ...rest } = options;
52
58
  const loaded = await loadBuilderPage({
53
- ...options,
59
+ ...rest,
54
60
  slug,
55
- locale: await localeOf(options, params)
61
+ locale: await localeOf(options, params),
62
+ ...currency === void 0 ? {} : { currency }
56
63
  }).catch((error) => {
57
- if (error instanceof BuilderNotFoundError) notFound();
64
+ if (error instanceof BuilderNotFoundError || isNamed(error, "BuilderNotFoundError")) notFound();
58
65
  throw error;
59
66
  });
60
67
  if (loaded.kind === "redirect") {
@@ -81,8 +88,8 @@ function createBuilderPage(options) {
81
88
  routeLocale: options.locale === void 0 && typeof params.locale === "string" ? params.locale : void 0
82
89
  });
83
90
  } catch (error) {
84
- if (error instanceof BuilderNotFoundError) return {};
85
- if (error instanceof BuilderUnavailableError && client.mode !== "build") return {};
91
+ if (error instanceof BuilderNotFoundError || isNamed(error, "BuilderNotFoundError")) return {};
92
+ if ((error instanceof BuilderUnavailableError || isNamed(error, "BuilderUnavailableError")) && client.mode !== "build") return {};
86
93
  throw error;
87
94
  }
88
95
  }
package/dist/server.cjs CHANGED
@@ -12,25 +12,25 @@
12
12
 
13
13
 
14
14
 
15
- var _chunkS2XR224Acjs = require('./chunk-S2XR224A.cjs');
15
+ var _chunkWZOWM2I7cjs = require('./chunk-WZOWM2I7.cjs');
16
16
 
17
17
  // src/server/load-site.ts
18
18
  var _builder = require('@usethrottle/builder');
19
19
  async function loadSite(options) {
20
- const { locale, slots = [], packs = [], page, mediaOrigin = "" } = options;
21
- const client = _chunkS2XR224Acjs.clientOf.call(void 0, options);
20
+ const { locale, slots = [], packs = [], page, mediaOrigin = "", currency } = options;
21
+ const client = _chunkWZOWM2I7cjs.clientOf.call(void 0, options);
22
22
  let bundle;
23
23
  try {
24
- bundle = await _chunkS2XR224Acjs.getBundle.call(void 0, { client, locale, slots, page });
24
+ bundle = await _chunkWZOWM2I7cjs.getBundle.call(void 0, { client, locale, slots, page });
25
25
  } catch (error) {
26
26
  if (!(error instanceof _builder.BuilderUnavailableError) || client.mode === "build") throw error;
27
- _chunkS2XR224Acjs.warnOnce.call(void 0, "site-unavailable", `The Builder could not be read (${error.reason}); the store renders without its Builder header, footer and slots`);
27
+ _chunkWZOWM2I7cjs.warnOnce.call(void 0, "site-unavailable", `The Builder could not be read (${error.reason}); the store renders without its Builder header, footer and slots`);
28
28
  return { status: "unavailable", locale };
29
29
  }
30
- const registry = _chunkS2XR224Acjs.createRendererRegistry.call(void 0, packs);
30
+ const registry = _chunkWZOWM2I7cjs.createRendererRegistry.call(void 0, packs);
31
31
  const names = Object.keys(bundle.slots);
32
32
  const documents = [bundle.header.document, bundle.footer.document, ...names.map((n) => bundle.slots[n].document)];
33
- const data = await _chunkS2XR224Acjs.staticDataFor.call(void 0, documents, registry, locale);
33
+ const data = await _chunkWZOWM2I7cjs.staticDataFor.call(void 0, documents, registry, locale, currency);
34
34
  return {
35
35
  status: "ok",
36
36
  locale,
@@ -38,9 +38,9 @@ async function loadSite(options) {
38
38
  siteVersion: bundle.site.siteVersion,
39
39
  mediaOrigin,
40
40
  settings: bundle.site.settings,
41
- header: _chunkS2XR224Acjs.partOf.call(void 0, bundle.header, data),
42
- footer: _chunkS2XR224Acjs.partOf.call(void 0, bundle.footer, data),
43
- slots: Object.fromEntries(names.map((name) => [name, _chunkS2XR224Acjs.partOf.call(void 0, bundle.slots[name], data)]))
41
+ header: _chunkWZOWM2I7cjs.partOf.call(void 0, bundle.header, data),
42
+ footer: _chunkWZOWM2I7cjs.partOf.call(void 0, bundle.footer, data),
43
+ slots: Object.fromEntries(names.map((name) => [name, _chunkWZOWM2I7cjs.partOf.call(void 0, bundle.slots[name], data)]))
44
44
  };
45
45
  }
46
46
 
@@ -48,13 +48,13 @@ async function loadSite(options) {
48
48
 
49
49
  async function builderSitemap(options) {
50
50
  if (options.client === void 0 && (options.builderKey === void 0 || options.builderKey === "")) {
51
- _chunkS2XR224Acjs.warnOnce.call(void 0, "sitemap-no-key", "builderSitemap has no builderKey (is THROTTLE_BUILDER_KEY set?); the sitemap leaves out the Builder pages");
51
+ _chunkWZOWM2I7cjs.warnOnce.call(void 0, "sitemap-no-key", "builderSitemap has no builderKey (is THROTTLE_BUILDER_KEY set?); the sitemap leaves out the Builder pages");
52
52
  return [];
53
53
  }
54
- const client = _chunkS2XR224Acjs.clientOf.call(void 0, options);
55
- const origin = _chunkS2XR224Acjs.originOf.call(void 0, options.storeUrl);
54
+ const client = _chunkWZOWM2I7cjs.clientOf.call(void 0, options);
55
+ const origin = _chunkWZOWM2I7cjs.originOf.call(void 0, options.storeUrl);
56
56
  if (origin === void 0) {
57
- _chunkS2XR224Acjs.warnOnce.call(void 0, "sitemap-origin", "builderSitemap needs a storeUrl (https://shop.example.com) that is an http(s) origin. The Builder does not publish the store URL.");
57
+ _chunkWZOWM2I7cjs.warnOnce.call(void 0, "sitemap-origin", "builderSitemap needs a storeUrl (https://shop.example.com) that is an http(s) origin. The Builder does not publish the store URL.");
58
58
  return [];
59
59
  }
60
60
  const locale = _nullishCoalesce(options.locale, () => ( "en"));
@@ -62,16 +62,16 @@ async function builderSitemap(options) {
62
62
  const pages = await client.pages.list();
63
63
  const { settings } = await client.site({ locale });
64
64
  const indexable = await withoutNoindex(client, pages, locale);
65
- const { list } = _chunkS2XR224Acjs.siteLocales.call(void 0, settings);
65
+ const { list } = _chunkWZOWM2I7cjs.siteLocales.call(void 0, settings);
66
66
  const prefixes = options.localeRoute !== true ? [void 0] : list.length > 0 ? list : [locale];
67
67
  return indexable.flatMap((page) => {
68
- const path = _chunkS2XR224Acjs.pagePathOf.call(void 0, settings, page, options.pagePath);
68
+ const path = _chunkWZOWM2I7cjs.pagePathOf.call(void 0, settings, page, options.pagePath);
69
69
  if (path === null) return [];
70
- return prefixes.map((prefix) => ({ url: `${origin}${_chunkS2XR224Acjs.localized.call(void 0, path, prefix)}`, lastModified: new Date(page.updatedAt) }));
70
+ return prefixes.map((prefix) => ({ url: `${origin}${_chunkWZOWM2I7cjs.localized.call(void 0, path, prefix)}`, lastModified: new Date(page.updatedAt) }));
71
71
  });
72
72
  } catch (error) {
73
73
  if (!(error instanceof _builder.BuilderUnavailableError) || client.mode === "build") throw error;
74
- _chunkS2XR224Acjs.warnOnce.call(void 0, "sitemap-unavailable", `The Builder could not be read (${error.reason}); the sitemap leaves out its pages`);
74
+ _chunkWZOWM2I7cjs.warnOnce.call(void 0, "sitemap-unavailable", `The Builder could not be read (${error.reason}); the sitemap leaves out its pages`);
75
75
  return [];
76
76
  }
77
77
  }
@@ -85,14 +85,14 @@ async function withoutNoindex(client, pages, locale) {
85
85
  slice.map(
86
86
  (page) => client.pages.get(page.slug, { locale }).catch((error) => {
87
87
  if (error instanceof _builder.BuilderNotFoundError) return "gone";
88
- _chunkS2XR224Acjs.warnOnce.call(void 0, "sitemap-page-read", `A page could not be read for the sitemap (${error instanceof Error ? error.message : "unknown error"}); it stays listed`);
88
+ _chunkWZOWM2I7cjs.warnOnce.call(void 0, "sitemap-page-read", `A page could not be read for the sitemap (${error instanceof Error ? error.message : "unknown error"}); it stays listed`);
89
89
  return void 0;
90
90
  })
91
91
  )
92
92
  );
93
93
  slice.forEach((page, index) => {
94
94
  const answer = answers[index];
95
- if (answer === "gone" || answer !== void 0 && (_chunkS2XR224Acjs.isRedirect.call(void 0, answer) || _chunkS2XR224Acjs.pageSeoOf.call(void 0, answer).noindex)) skip.add(page.slug);
95
+ if (answer === "gone" || answer !== void 0 && (_chunkWZOWM2I7cjs.isRedirect.call(void 0, answer) || _chunkWZOWM2I7cjs.pageSeoOf.call(void 0, answer).noindex)) skip.add(page.slug);
96
96
  });
97
97
  }
98
98
  return pages.filter((page) => !skip.has(page.slug));
@@ -100,7 +100,7 @@ async function withoutNoindex(client, pages, locale) {
100
100
 
101
101
  // src/server/static-params.ts
102
102
  async function builderStaticParams(options) {
103
- const client = _chunkS2XR224Acjs.clientOf.call(void 0, options);
103
+ const client = _chunkWZOWM2I7cjs.clientOf.call(void 0, options);
104
104
  if (client.mode !== "build")
105
105
  throw new TypeError(
106
106
  'builderStaticParams generates every page of a frozen release: give it a client made with createBuilderClient({ mode: "build" }). A live store keeps its pages dynamic.'
@@ -119,4 +119,4 @@ async function builderStaticParams(options) {
119
119
 
120
120
 
121
121
 
122
- exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.builderSitemap = builderSitemap; exports.builderStaticParams = builderStaticParams; exports.getBundle = _chunkS2XR224Acjs.getBundle; exports.loadBuilderPage = _chunkS2XR224Acjs.loadBuilderPage; exports.loadSite = loadSite;
122
+ exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.builderSitemap = builderSitemap; exports.builderStaticParams = builderStaticParams; exports.getBundle = _chunkWZOWM2I7cjs.getBundle; exports.loadBuilderPage = _chunkWZOWM2I7cjs.loadBuilderPage; exports.loadSite = loadSite;
package/dist/server.d.cts CHANGED
@@ -16,6 +16,11 @@ type LoadSiteOptions = ClientOptions & {
16
16
  */
17
17
  mediaOrigin?: string;
18
18
  packs?: readonly WidgetPack[];
19
+ /**
20
+ * The shopper's currency, when the store keeps one (a cookie): data sources that price things answer in it
21
+ * (`ctx.currency`). Without it they answer in the store's own currency.
22
+ */
23
+ currency?: string;
19
24
  };
20
25
  /**
21
26
  * Reads the site design once for a request: settings, header, footer and the
@@ -35,6 +40,8 @@ type LoadBuilderPageOptions = ClientOptions & {
35
40
  packs?: readonly WidgetPack[];
36
41
  /** The slots the layout reads, so this read can share the layout's. */
37
42
  slots?: readonly string[];
43
+ /** The shopper's currency, as for `loadSite({ currency })`. */
44
+ currency?: string;
38
45
  };
39
46
  /**
40
47
  * Reads one published page for a request. Data of the page's non-perShopper
package/dist/server.d.ts CHANGED
@@ -16,6 +16,11 @@ type LoadSiteOptions = ClientOptions & {
16
16
  */
17
17
  mediaOrigin?: string;
18
18
  packs?: readonly WidgetPack[];
19
+ /**
20
+ * The shopper's currency, when the store keeps one (a cookie): data sources that price things answer in it
21
+ * (`ctx.currency`). Without it they answer in the store's own currency.
22
+ */
23
+ currency?: string;
19
24
  };
20
25
  /**
21
26
  * Reads the site design once for a request: settings, header, footer and the
@@ -35,6 +40,8 @@ type LoadBuilderPageOptions = ClientOptions & {
35
40
  packs?: readonly WidgetPack[];
36
41
  /** The slots the layout reads, so this read can share the layout's. */
37
42
  slots?: readonly string[];
43
+ /** The shopper's currency, as for `loadSite({ currency })`. */
44
+ currency?: string;
38
45
  };
39
46
  /**
40
47
  * Reads one published page for a request. Data of the page's non-perShopper
package/dist/server.js CHANGED
@@ -12,12 +12,12 @@ import {
12
12
  siteLocales,
13
13
  staticDataFor,
14
14
  warnOnce
15
- } from "./chunk-NUE2KNT2.js";
15
+ } from "./chunk-IBRAMTUT.js";
16
16
 
17
17
  // src/server/load-site.ts
18
18
  import { BuilderUnavailableError } from "@usethrottle/builder";
19
19
  async function loadSite(options) {
20
- const { locale, slots = [], packs = [], page, mediaOrigin = "" } = options;
20
+ const { locale, slots = [], packs = [], page, mediaOrigin = "", currency } = options;
21
21
  const client = clientOf(options);
22
22
  let bundle;
23
23
  try {
@@ -30,7 +30,7 @@ async function loadSite(options) {
30
30
  const registry = createRendererRegistry(packs);
31
31
  const names = Object.keys(bundle.slots);
32
32
  const documents = [bundle.header.document, bundle.footer.document, ...names.map((n) => bundle.slots[n].document)];
33
- const data = await staticDataFor(documents, registry, locale);
33
+ const data = await staticDataFor(documents, registry, locale, currency);
34
34
  return {
35
35
  status: "ok",
36
36
  locale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/builder-react",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Renders a published Throttle Builder page document as React in a merchant's store: responsive CSS, header, footer, slots and the site design provider.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,9 +57,9 @@
57
57
  "nextjs"
58
58
  ],
59
59
  "dependencies": {
60
- "@usethrottle/builder": "^0.3.0",
61
60
  "@usethrottle/builder-schema": "^0.1.2",
62
- "@usethrottle/ui": "^0.1.2"
61
+ "@usethrottle/ui": "^0.1.2",
62
+ "@usethrottle/builder": "^0.3.0"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "next": ">=15",