@usethrottle/builder-react 0.2.1 → 0.2.3
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/CLAUDE.md +6 -0
- package/dist/{chunk-NUE2KNT2.js → chunk-GZN4SYTE.js} +14 -6
- package/dist/{chunk-S2XR224A.cjs → chunk-L7COZ3SN.cjs} +28 -20
- package/dist/index.cjs +19 -4
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +26 -9
- package/dist/next.cjs +6 -6
- package/dist/next.js +1 -1
- package/dist/server.cjs +24 -20
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +5 -1
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -42,6 +42,12 @@ export { generateMetadata };
|
|
|
42
42
|
which a server component cannot pass down, so the store creates its packs in a
|
|
43
43
|
client module. `site` is plain data (what `loadSite` returned).
|
|
44
44
|
|
|
45
|
+
**Nesting.** `BuilderProvider` lays the site theme over an enclosing `@usethrottle/ui` appearance (it merges
|
|
46
|
+
`variables`, `darkVariables`, `elements`, `parts`, `components`; the Builder's values win except `fontFamily`,
|
|
47
|
+
which stays the host's when it set one), so it can sit inside a store's ui provider without dropping its part
|
|
48
|
+
classes. Put it OUTSIDE `StorefrontNextProvider` anyway: that provider reads the site design, which only exists
|
|
49
|
+
below `BuilderProvider`, and it builds its own appearance from that design.
|
|
50
|
+
|
|
45
51
|
## Rules (do not break)
|
|
46
52
|
|
|
47
53
|
- **No time-based revalidation, ever.** Every read goes through the
|
|
@@ -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
|
|
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
|
}
|
|
@@ -1233,7 +1236,12 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
1233
1236
|
for (const field of fields.values()) base[field.key] = field.default;
|
|
1234
1237
|
const resolved = resolveResponsive3({ ...base, ...node.props }, node.responsive, device);
|
|
1235
1238
|
const out = {};
|
|
1236
|
-
for (const [key, value] of Object.entries(resolved))
|
|
1239
|
+
for (const [key, value] of Object.entries(resolved)) {
|
|
1240
|
+
const field = fields.get(key);
|
|
1241
|
+
const freeText = field?.control === "text" || field?.control === "richtext";
|
|
1242
|
+
const usable = field === void 0 || (freeText ? value !== null : validateSettingValue2(field, value) === null) ? value : field.default;
|
|
1243
|
+
out[key] = prepare(field, usable, ctx);
|
|
1244
|
+
}
|
|
1237
1245
|
return out;
|
|
1238
1246
|
}
|
|
1239
1247
|
function variantsOf(node, def, fields, ctx) {
|
|
@@ -1768,14 +1776,14 @@ function build(input) {
|
|
|
1768
1776
|
const innerField = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v)?.settings.find((f) => f.key === target.prop);
|
|
1769
1777
|
if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
|
|
1770
1778
|
const converted = convert(field, value);
|
|
1771
|
-
if (
|
|
1779
|
+
if (validateSettingValue3(innerField, converted) !== null) continue;
|
|
1772
1780
|
inner.props[target.prop] = converted;
|
|
1773
1781
|
const responsive = inner.responsive;
|
|
1774
1782
|
for (const device of DEVICES3) {
|
|
1775
1783
|
if (responsive?.[device] !== void 0) delete responsive[device][target.prop];
|
|
1776
1784
|
const raw = outer.responsive?.[device];
|
|
1777
1785
|
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) &&
|
|
1786
|
+
if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && validateSettingValue3(innerField, raw[binding.setting]) === null) {
|
|
1779
1787
|
const target$ = inner.responsive ?? (inner.responsive = {});
|
|
1780
1788
|
(target$[device] ?? (target$[device] = {}))[target.prop] = raw[binding.setting];
|
|
1781
1789
|
}
|
|
@@ -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
|
|
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
|
}
|
|
@@ -1233,7 +1236,12 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
1233
1236
|
for (const field of fields.values()) base[field.key] = field.default;
|
|
1234
1237
|
const resolved = _builderschema.resolveResponsive.call(void 0, { ...base, ...node.props }, node.responsive, device);
|
|
1235
1238
|
const out = {};
|
|
1236
|
-
for (const [key, value] of Object.entries(resolved))
|
|
1239
|
+
for (const [key, value] of Object.entries(resolved)) {
|
|
1240
|
+
const field = fields.get(key);
|
|
1241
|
+
const freeText = _optionalChain([field, 'optionalAccess', _44 => _44.control]) === "text" || _optionalChain([field, 'optionalAccess', _45 => _45.control]) === "richtext";
|
|
1242
|
+
const usable = field === void 0 || (freeText ? value !== null : _builderschema.validateSettingValue.call(void 0, field, value) === null) ? value : field.default;
|
|
1243
|
+
out[key] = prepare(field, usable, ctx);
|
|
1244
|
+
}
|
|
1237
1245
|
return out;
|
|
1238
1246
|
}
|
|
1239
1247
|
function variantsOf(node, def, fields, ctx) {
|
|
@@ -1483,7 +1491,7 @@ var ROLES = new Set(_builderschema.ALLOWED_ROLES);
|
|
|
1483
1491
|
function attrAllowed(tag, name) {
|
|
1484
1492
|
if (_builderschema.DATA_ATTR_RE.test(name)) return !name.startsWith(_builderschema.RESERVED_DATA_PREFIX);
|
|
1485
1493
|
const own = Object.hasOwn(_builderschema.ALLOWED_ATTRS, tag) ? _builderschema.ALLOWED_ATTRS[tag] : void 0;
|
|
1486
|
-
return (_nullishCoalesce(_optionalChain([_builderschema.ALLOWED_ATTRS, 'access',
|
|
1494
|
+
return (_nullishCoalesce(_optionalChain([_builderschema.ALLOWED_ATTRS, 'access', _46 => _46["*"], 'optionalAccess', _47 => _47.includes, 'call', _48 => _48(name)]), () => ( false))) || (_nullishCoalesce(_optionalChain([own, 'optionalAccess', _49 => _49.includes, 'call', _50 => _50(name)]), () => ( false)));
|
|
1487
1495
|
}
|
|
1488
1496
|
function attrText(attr, env, scope) {
|
|
1489
1497
|
return attr.value.map((part) => part.type === "text" ? part.value : filtered(lookup(part.path, env, scope), part.filters)).join("");
|
|
@@ -1606,14 +1614,14 @@ function compile(snapshot, registry) {
|
|
|
1606
1614
|
const source = snapshot.template;
|
|
1607
1615
|
if (typeof source !== "string") return refuse("no template source");
|
|
1608
1616
|
const parsed = _builderschema.parseTemplate.call(void 0, source);
|
|
1609
|
-
if (!parsed.ok) return refuse(`template does not parse: ${_nullishCoalesce(_optionalChain([parsed, 'access',
|
|
1617
|
+
if (!parsed.ok) return refuse(`template does not parse: ${_nullishCoalesce(_optionalChain([parsed, 'access', _51 => _51.issues, 'access', _52 => _52[0], 'optionalAccess', _53 => _53.message]), () => ( "invalid"))}`);
|
|
1610
1618
|
const data = snapshot.data;
|
|
1611
1619
|
const issues = _builderschema.validateTemplate.call(void 0, parsed.ast, {
|
|
1612
1620
|
settings: snapshot.settings,
|
|
1613
1621
|
data: typeof data === "object" && data !== null ? data : {},
|
|
1614
1622
|
sources: registry.sources()
|
|
1615
1623
|
});
|
|
1616
|
-
if (issues.length > 0) return refuse(`template does not validate: ${_nullishCoalesce(_optionalChain([issues, 'access',
|
|
1624
|
+
if (issues.length > 0) return refuse(`template does not validate: ${_nullishCoalesce(_optionalChain([issues, 'access', _54 => _54[0], 'optionalAccess', _55 => _55.message]), () => ( "invalid"))}`);
|
|
1617
1625
|
if (!fitsBudget(parsed.ast)) return refuse(`it can render more than ${String(_builderschema.MAX_TEMPLATE_WEIGHT)} nodes`);
|
|
1618
1626
|
const css = scopedCss(snapshot.css, snapshot.type);
|
|
1619
1627
|
if (css === null) return refuse("its css does not pass the sanitiser");
|
|
@@ -1645,16 +1653,16 @@ function parseBody(raw) {
|
|
|
1645
1653
|
const stack = Array.isArray(raw.stack) ? raw.stack : void 0;
|
|
1646
1654
|
if (columns === void 0 === (stack === void 0)) return null;
|
|
1647
1655
|
const children = columns !== void 0 ? [{ id: WRAP.inner, type: "inner-section", props: {}, columns }] : _nullishCoalesce(stack, () => ( []));
|
|
1648
|
-
if (_optionalChain([stack, 'optionalAccess',
|
|
1656
|
+
if (_optionalChain([stack, 'optionalAccess', _56 => _56.some, 'call', _57 => _57((node) => isRecord3(node) && node.type === "inner-section")])) return null;
|
|
1649
1657
|
const parsed = _builderschema.pageDocumentSchema.safeParse({
|
|
1650
1658
|
schemaVersion: 1,
|
|
1651
1659
|
sections: [{ id: WRAP.section, type: "section", props: {}, columns: [{ id: WRAP.column, type: "column", props: { width: 100 }, children }] }]
|
|
1652
1660
|
});
|
|
1653
1661
|
if (!parsed.success) return null;
|
|
1654
|
-
const first = _nullishCoalesce(_optionalChain([parsed, 'access',
|
|
1662
|
+
const first = _nullishCoalesce(_optionalChain([parsed, 'access', _58 => _58.data, 'access', _59 => _59.sections, 'access', _60 => _60[0], 'optionalAccess', _61 => _61.columns, 'access', _62 => _62[0], 'optionalAccess', _63 => _63.children]), () => ( []));
|
|
1655
1663
|
if (columns !== void 0) {
|
|
1656
1664
|
const inner = first[0];
|
|
1657
|
-
return _optionalChain([inner, 'optionalAccess',
|
|
1665
|
+
return _optionalChain([inner, 'optionalAccess', _64 => _64.type]) === "inner-section" ? { columns: inner.columns } : null;
|
|
1658
1666
|
}
|
|
1659
1667
|
return { stack: first.filter((node) => node.type !== "inner-section") };
|
|
1660
1668
|
}
|
|
@@ -1708,7 +1716,7 @@ var DEVICES3 = ["tablet", "phone"];
|
|
|
1708
1716
|
function withoutAnchor(node) {
|
|
1709
1717
|
delete node.props.anchor;
|
|
1710
1718
|
const responsive = node.responsive;
|
|
1711
|
-
for (const device of DEVICES3) if (_optionalChain([responsive, 'optionalAccess',
|
|
1719
|
+
for (const device of DEVICES3) if (_optionalChain([responsive, 'optionalAccess', _65 => _65[device]]) !== void 0) delete responsive[device].anchor;
|
|
1712
1720
|
}
|
|
1713
1721
|
function instanceId(outer, inner) {
|
|
1714
1722
|
let a = 3735928559;
|
|
@@ -1728,9 +1736,9 @@ function build(input) {
|
|
|
1728
1736
|
const assets = {};
|
|
1729
1737
|
const hrefs = /* @__PURE__ */ new Map();
|
|
1730
1738
|
const innerData = {};
|
|
1731
|
-
const keep = (child) => _optionalChain([registry, 'access',
|
|
1732
|
-
const columns = _optionalChain([body, 'access',
|
|
1733
|
-
const stack = _optionalChain([body, 'access',
|
|
1739
|
+
const keep = (child) => _optionalChain([registry, 'access', _66 => _66.widget, 'call', _67 => _67(child.type, child.v), 'optionalAccess', _68 => _68.kind]) !== "composite";
|
|
1740
|
+
const columns = _optionalChain([body, 'access', _69 => _69.columns, 'optionalAccess', _70 => _70.map, 'call', _71 => _71((column2) => ({ ...column2, children: column2.children.filter(keep) }))]);
|
|
1741
|
+
const stack = _optionalChain([body, 'access', _72 => _72.stack, 'optionalAccess', _73 => _73.filter, 'call', _74 => _74(keep)]);
|
|
1734
1742
|
const widgets2 = columns !== void 0 ? columns.flatMap((column2) => column2.children) : _nullishCoalesce(stack, () => ( []));
|
|
1735
1743
|
for (const widget of widgets2) {
|
|
1736
1744
|
withoutAnchor(widget);
|
|
@@ -1765,15 +1773,15 @@ function build(input) {
|
|
|
1765
1773
|
const value = props[binding.setting];
|
|
1766
1774
|
for (const target of binding.targets) {
|
|
1767
1775
|
const inner = byId.get(target.node);
|
|
1768
|
-
const innerField = inner === void 0 ? void 0 : _optionalChain([registry, 'access',
|
|
1776
|
+
const innerField = inner === void 0 ? void 0 : _optionalChain([registry, 'access', _75 => _75.widget, 'call', _76 => _76(inner.type, inner.v), 'optionalAccess', _77 => _77.settings, 'access', _78 => _78.find, 'call', _79 => _79((f) => f.key === target.prop)]);
|
|
1769
1777
|
if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
|
|
1770
1778
|
const converted = convert(field, value);
|
|
1771
1779
|
if (_builderschema.validateSettingValue.call(void 0, innerField, converted) !== null) continue;
|
|
1772
1780
|
inner.props[target.prop] = converted;
|
|
1773
1781
|
const responsive = inner.responsive;
|
|
1774
1782
|
for (const device of DEVICES3) {
|
|
1775
|
-
if (_optionalChain([responsive, 'optionalAccess',
|
|
1776
|
-
const raw = _optionalChain([outer, 'access',
|
|
1783
|
+
if (_optionalChain([responsive, 'optionalAccess', _80 => _80[device]]) !== void 0) delete responsive[device][target.prop];
|
|
1784
|
+
const raw = _optionalChain([outer, 'access', _81 => _81.responsive, 'optionalAccess', _82 => _82[device]]);
|
|
1777
1785
|
const plain = field.output === "css" && field.translatable !== true && field.control !== "image" && field.control !== "link";
|
|
1778
1786
|
if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && _builderschema.validateSettingValue.call(void 0, innerField, raw[binding.setting]) === null) {
|
|
1779
1787
|
const target$ = _nullishCoalesce(inner.responsive, () => ( (inner.responsive = {})));
|
|
@@ -1788,7 +1796,7 @@ function build(input) {
|
|
|
1788
1796
|
for (const target of input$.targets) {
|
|
1789
1797
|
const inner = byId.get(target.node);
|
|
1790
1798
|
const def = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v);
|
|
1791
|
-
if (inner === void 0 || _optionalChain([def, 'optionalAccess',
|
|
1799
|
+
if (inner === void 0 || _optionalChain([def, 'optionalAccess', _83 => _83.data]) === void 0 || !Object.hasOwn(def.data, target.input)) continue;
|
|
1792
1800
|
inner.data = { ..._nullishCoalesce(inner.data, () => ( {})), [target.input]: { source: key } };
|
|
1793
1801
|
innerData[key] = data[name];
|
|
1794
1802
|
}
|
|
@@ -1806,7 +1814,7 @@ function build(input) {
|
|
|
1806
1814
|
schemaVersion: 1,
|
|
1807
1815
|
sections: [{ id: ids.section, type: "section", props: { width: "full" }, columns: [column] }]
|
|
1808
1816
|
};
|
|
1809
|
-
let weight = 2 + (_nullishCoalesce(_optionalChain([columns, 'optionalAccess',
|
|
1817
|
+
let weight = 2 + (_nullishCoalesce(_optionalChain([columns, 'optionalAccess', _84 => _84.length]), () => ( 0))) + (columns === void 0 ? 0 : 1);
|
|
1810
1818
|
for (const widget of widgets2) {
|
|
1811
1819
|
const component = registry.component(widget);
|
|
1812
1820
|
weight += 1 + (component === void 0 ? 0 : _nullishCoalesce(componentWeights.get(component), () => ( 0)));
|
|
@@ -1831,7 +1839,7 @@ function CompositeBody(props) {
|
|
|
1831
1839
|
locale,
|
|
1832
1840
|
assets: built.assets,
|
|
1833
1841
|
mediaOrigin,
|
|
1834
|
-
resolveLink: (target) => _nullishCoalesce(_nullishCoalesce(built.hrefs.get(JSON.stringify(target)), () => ( _optionalChain([resolveLink, 'optionalCall',
|
|
1842
|
+
resolveLink: (target) => _nullishCoalesce(_nullishCoalesce(built.hrefs.get(JSON.stringify(target)), () => ( _optionalChain([resolveLink, 'optionalCall', _85 => _85(target)]))), () => ( null))
|
|
1835
1843
|
}
|
|
1836
1844
|
);
|
|
1837
1845
|
}
|
|
@@ -1956,7 +1964,7 @@ function pagePathOf(settings, page, resolve) {
|
|
|
1956
1964
|
return _nullishCoalesce(_builderschema.safeUrl.call(void 0, resolve({ ...page, path }), "href", { mediaOrigin: "" }), () => ( path));
|
|
1957
1965
|
}
|
|
1958
1966
|
function originOf(storeUrl) {
|
|
1959
|
-
const origin = _optionalChain([storeUrl, 'optionalAccess',
|
|
1967
|
+
const origin = _optionalChain([storeUrl, 'optionalAccess', _86 => _86.replace, 'call', _87 => _87(/\/+$/u, "")]);
|
|
1960
1968
|
return origin !== void 0 && ORIGIN_RE.test(origin) ? origin : void 0;
|
|
1961
1969
|
}
|
|
1962
1970
|
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
|
|
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
|
}
|
|
@@ -496,7 +497,12 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
496
497
|
for (const field of fields.values()) base[field.key] = field.default;
|
|
497
498
|
const resolved = (0, import_builder_schema5.resolveResponsive)({ ...base, ...node.props }, node.responsive, device);
|
|
498
499
|
const out = {};
|
|
499
|
-
for (const [key, value] of Object.entries(resolved))
|
|
500
|
+
for (const [key, value] of Object.entries(resolved)) {
|
|
501
|
+
const field = fields.get(key);
|
|
502
|
+
const freeText = field?.control === "text" || field?.control === "richtext";
|
|
503
|
+
const usable = field === void 0 || (freeText ? value !== null : (0, import_builder_schema5.validateSettingValue)(field, value) === null) ? value : field.default;
|
|
504
|
+
out[key] = prepare(field, usable, ctx);
|
|
505
|
+
}
|
|
500
506
|
return out;
|
|
501
507
|
}
|
|
502
508
|
function variantsOf(node, def, fields, ctx) {
|
|
@@ -2239,6 +2245,9 @@ function siteDesignOf(settings, resolve, pageOutlet, mediaOrigin) {
|
|
|
2239
2245
|
// src/provider.tsx
|
|
2240
2246
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2241
2247
|
var EMPTY = {};
|
|
2248
|
+
function useParentFont() {
|
|
2249
|
+
return (0, import_react15.useContext)(import_ui6.AppearanceContext)?.variables?.fontFamily;
|
|
2250
|
+
}
|
|
2242
2251
|
function BuilderProvider({ builderKey, client, packs, site, children }) {
|
|
2243
2252
|
const packsKey = packs.map((pack) => `${pack.id}@${pack.version}`).join("|");
|
|
2244
2253
|
const registryRef = (0, import_react15.useRef)(null);
|
|
@@ -2288,7 +2297,13 @@ function BuilderProvider({ builderKey, client, packs, site, children }) {
|
|
|
2288
2297
|
() => site.status === "ok" ? siteDesignOf(site.settings, resolveLink, pageOutlet, mediaOrigin) : null,
|
|
2289
2298
|
[site, resolveLink, pageOutlet, mediaOrigin]
|
|
2290
2299
|
);
|
|
2291
|
-
const
|
|
2300
|
+
const own = (0, import_react15.useMemo)(() => site.status === "ok" ? appearanceOf(site.settings) : void 0, [site]);
|
|
2301
|
+
const merged = (0, import_ui6.useAppearanceProviderValue)(own);
|
|
2302
|
+
const parentFont = useParentFont();
|
|
2303
|
+
const appearance = (0, import_react15.useMemo)(() => {
|
|
2304
|
+
if (own === void 0) return void 0;
|
|
2305
|
+
return parentFont === void 0 ? merged : { ...merged, variables: { ...merged.variables, fontFamily: parentFont } };
|
|
2306
|
+
}, [own, merged, parentFont]);
|
|
2292
2307
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BuilderContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_ui6.ThrottleUIProvider, { ...appearance === void 0 ? {} : { appearance }, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_ui6.SiteDesignProvider, { value: design, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_ui6.SlotOutletProvider, { resolve: resolveSlot, children: [
|
|
2293
2308
|
site.status === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("style", { children: themeCss(site.settings) }) : null,
|
|
2294
2309
|
children
|
package/dist/index.d.cts
CHANGED
|
@@ -308,6 +308,10 @@ type BuilderProviderProps = {
|
|
|
308
308
|
* the theme and a renderer for a Builder page by slug) and `SlotOutletContext`
|
|
309
309
|
* from a loaded site, and gives the Builder components their registry.
|
|
310
310
|
*
|
|
311
|
+
* It lays the site theme over an enclosing `@usethrottle/ui` appearance (for example `StorefrontNextProvider`'s
|
|
312
|
+
* `parts`) instead of replacing it, so it can sit inside or outside that provider. Outside is better: a
|
|
313
|
+
* storefront provider reads the site design, which only exists below this one.
|
|
314
|
+
*
|
|
311
315
|
* Put it in a client module of the store, where the packs are created: a pack
|
|
312
316
|
* holds components and functions, which a server component cannot pass down.
|
|
313
317
|
* With a site the Builder could not answer (`status: 'unavailable'`) it fills
|
package/dist/index.d.ts
CHANGED
|
@@ -308,6 +308,10 @@ type BuilderProviderProps = {
|
|
|
308
308
|
* the theme and a renderer for a Builder page by slug) and `SlotOutletContext`
|
|
309
309
|
* from a loaded site, and gives the Builder components their registry.
|
|
310
310
|
*
|
|
311
|
+
* It lays the site theme over an enclosing `@usethrottle/ui` appearance (for example `StorefrontNextProvider`'s
|
|
312
|
+
* `parts`) instead of replacing it, so it can sit inside or outside that provider. Outside is better: a
|
|
313
|
+
* storefront provider reads the site design, which only exists below this one.
|
|
314
|
+
*
|
|
311
315
|
* Put it in a client module of the store, where the packs are created: a pack
|
|
312
316
|
* holds components and functions, which a server component cannot pass down.
|
|
313
317
|
* With a site the Builder could not answer (`status: 'unavailable'`) it fills
|
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
|
|
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
|
}
|
|
@@ -448,7 +451,12 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
448
451
|
for (const field of fields.values()) base[field.key] = field.default;
|
|
449
452
|
const resolved = resolveResponsive2({ ...base, ...node.props }, node.responsive, device);
|
|
450
453
|
const out = {};
|
|
451
|
-
for (const [key, value] of Object.entries(resolved))
|
|
454
|
+
for (const [key, value] of Object.entries(resolved)) {
|
|
455
|
+
const field = fields.get(key);
|
|
456
|
+
const freeText = field?.control === "text" || field?.control === "richtext";
|
|
457
|
+
const usable = field === void 0 || (freeText ? value !== null : validateSettingValue2(field, value) === null) ? value : field.default;
|
|
458
|
+
out[key] = prepare(field, usable, ctx);
|
|
459
|
+
}
|
|
452
460
|
return out;
|
|
453
461
|
}
|
|
454
462
|
function variantsOf(node, def, fields, ctx) {
|
|
@@ -616,9 +624,9 @@ function WidgetStyle({ css }) {
|
|
|
616
624
|
}
|
|
617
625
|
|
|
618
626
|
// src/provider.tsx
|
|
619
|
-
import { Suspense as Suspense4, useCallback, useMemo, useRef as useRef2 } from "react";
|
|
627
|
+
import { Suspense as Suspense4, useCallback, useContext as useContext2, useMemo, useRef as useRef2 } from "react";
|
|
620
628
|
import { createBuilderClient } from "@usethrottle/builder";
|
|
621
|
-
import { SiteDesignProvider, SlotOutletProvider, ThrottleUIProvider } from "@usethrottle/ui";
|
|
629
|
+
import { AppearanceContext, SiteDesignProvider, SlotOutletProvider, ThrottleUIProvider, useAppearanceProviderValue } from "@usethrottle/ui";
|
|
622
630
|
|
|
623
631
|
// src/context.ts
|
|
624
632
|
import { createContext, useContext } from "react";
|
|
@@ -1468,7 +1476,7 @@ import { createElement as createElement3 } from "react";
|
|
|
1468
1476
|
|
|
1469
1477
|
// src/custom/composite-widget.tsx
|
|
1470
1478
|
import { Suspense as Suspense2 } from "react";
|
|
1471
|
-
import { pageDocumentSchema, validateSettingValue } from "@usethrottle/builder-schema";
|
|
1479
|
+
import { pageDocumentSchema, validateSettingValue as validateSettingValue3 } from "@usethrottle/builder-schema";
|
|
1472
1480
|
|
|
1473
1481
|
// src/custom/template-widget.tsx
|
|
1474
1482
|
import { Suspense } from "react";
|
|
@@ -1866,14 +1874,14 @@ function build(input) {
|
|
|
1866
1874
|
const innerField = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v)?.settings.find((f) => f.key === target.prop);
|
|
1867
1875
|
if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
|
|
1868
1876
|
const converted = convert(field, value);
|
|
1869
|
-
if (
|
|
1877
|
+
if (validateSettingValue3(innerField, converted) !== null) continue;
|
|
1870
1878
|
inner.props[target.prop] = converted;
|
|
1871
1879
|
const responsive = inner.responsive;
|
|
1872
1880
|
for (const device of DEVICES3) {
|
|
1873
1881
|
if (responsive?.[device] !== void 0) delete responsive[device][target.prop];
|
|
1874
1882
|
const raw = outer.responsive?.[device];
|
|
1875
1883
|
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) &&
|
|
1884
|
+
if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && validateSettingValue3(innerField, raw[binding.setting]) === null) {
|
|
1877
1885
|
const target$ = inner.responsive ?? (inner.responsive = {});
|
|
1878
1886
|
(target$[device] ?? (target$[device] = {}))[target.prop] = raw[binding.setting];
|
|
1879
1887
|
}
|
|
@@ -2202,6 +2210,9 @@ function siteDesignOf(settings, resolve, pageOutlet, mediaOrigin) {
|
|
|
2202
2210
|
// src/provider.tsx
|
|
2203
2211
|
import { jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2204
2212
|
var EMPTY = {};
|
|
2213
|
+
function useParentFont() {
|
|
2214
|
+
return useContext2(AppearanceContext)?.variables?.fontFamily;
|
|
2215
|
+
}
|
|
2205
2216
|
function BuilderProvider({ builderKey, client, packs, site, children }) {
|
|
2206
2217
|
const packsKey = packs.map((pack) => `${pack.id}@${pack.version}`).join("|");
|
|
2207
2218
|
const registryRef = useRef2(null);
|
|
@@ -2251,7 +2262,13 @@ function BuilderProvider({ builderKey, client, packs, site, children }) {
|
|
|
2251
2262
|
() => site.status === "ok" ? siteDesignOf(site.settings, resolveLink, pageOutlet, mediaOrigin) : null,
|
|
2252
2263
|
[site, resolveLink, pageOutlet, mediaOrigin]
|
|
2253
2264
|
);
|
|
2254
|
-
const
|
|
2265
|
+
const own = useMemo(() => site.status === "ok" ? appearanceOf(site.settings) : void 0, [site]);
|
|
2266
|
+
const merged = useAppearanceProviderValue(own);
|
|
2267
|
+
const parentFont = useParentFont();
|
|
2268
|
+
const appearance = useMemo(() => {
|
|
2269
|
+
if (own === void 0) return void 0;
|
|
2270
|
+
return parentFont === void 0 ? merged : { ...merged, variables: { ...merged.variables, fontFamily: parentFont } };
|
|
2271
|
+
}, [own, merged, parentFont]);
|
|
2255
2272
|
return /* @__PURE__ */ jsx25(BuilderContext.Provider, { value, children: /* @__PURE__ */ jsx25(ThrottleUIProvider, { ...appearance === void 0 ? {} : { appearance }, children: /* @__PURE__ */ jsx25(SiteDesignProvider, { value: design, children: /* @__PURE__ */ jsxs15(SlotOutletProvider, { resolve: resolveSlot, children: [
|
|
2256
2273
|
site.status === "ok" ? /* @__PURE__ */ jsx25("style", { children: themeCss(site.settings) }) : null,
|
|
2257
2274
|
children
|
package/dist/next.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkL7COZ3SNcjs = require('./chunk-L7COZ3SN.cjs');
|
|
8
8
|
|
|
9
9
|
// src/next/index.ts
|
|
10
10
|
var _react = require('react');
|
|
@@ -49,7 +49,7 @@ function createBuilderPage(options) {
|
|
|
49
49
|
async function Page(props) {
|
|
50
50
|
const params = await props.params;
|
|
51
51
|
const slug = slugOf(options, params);
|
|
52
|
-
const loaded = await
|
|
52
|
+
const loaded = await _chunkL7COZ3SNcjs.loadBuilderPage.call(void 0, {
|
|
53
53
|
...options,
|
|
54
54
|
slug,
|
|
55
55
|
locale: await localeOf(options, params)
|
|
@@ -68,12 +68,12 @@ function createBuilderPage(options) {
|
|
|
68
68
|
const params = await props.params;
|
|
69
69
|
const slug = slugOf(options, params);
|
|
70
70
|
const locale = await localeOf(options, params);
|
|
71
|
-
const client =
|
|
71
|
+
const client = _chunkL7COZ3SNcjs.clientOf.call(void 0, options);
|
|
72
72
|
try {
|
|
73
|
-
const bundle = await
|
|
73
|
+
const bundle = await _chunkL7COZ3SNcjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
|
|
74
74
|
const page = bundle.page;
|
|
75
|
-
if (page === void 0 ||
|
|
76
|
-
return
|
|
75
|
+
if (page === void 0 || _chunkL7COZ3SNcjs.isRedirect.call(void 0, page)) return {};
|
|
76
|
+
return _chunkL7COZ3SNcjs.metadataOf.call(void 0, page, {
|
|
77
77
|
settings: bundle.site.settings,
|
|
78
78
|
mediaOrigin: _nullishCoalesce(options.mediaOrigin, () => ( "")),
|
|
79
79
|
storeUrl: options.storeUrl,
|
package/dist/next.js
CHANGED
package/dist/server.cjs
CHANGED
|
@@ -12,25 +12,25 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkL7COZ3SNcjs = require('./chunk-L7COZ3SN.cjs');
|
|
16
16
|
|
|
17
17
|
// src/server/load-site.ts
|
|
18
18
|
var _builder = require('@usethrottle/builder');
|
|
19
19
|
async function loadSite(options) {
|
|
20
20
|
const { locale, slots = [], packs = [], page, mediaOrigin = "" } = options;
|
|
21
|
-
const client =
|
|
21
|
+
const client = _chunkL7COZ3SNcjs.clientOf.call(void 0, options);
|
|
22
22
|
let bundle;
|
|
23
23
|
try {
|
|
24
|
-
bundle = await
|
|
24
|
+
bundle = await _chunkL7COZ3SNcjs.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
|
-
|
|
27
|
+
_chunkL7COZ3SNcjs.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 =
|
|
30
|
+
const registry = _chunkL7COZ3SNcjs.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
|
|
33
|
+
const data = await _chunkL7COZ3SNcjs.staticDataFor.call(void 0, documents, registry, locale);
|
|
34
34
|
return {
|
|
35
35
|
status: "ok",
|
|
36
36
|
locale,
|
|
@@ -38,19 +38,23 @@ async function loadSite(options) {
|
|
|
38
38
|
siteVersion: bundle.site.siteVersion,
|
|
39
39
|
mediaOrigin,
|
|
40
40
|
settings: bundle.site.settings,
|
|
41
|
-
header:
|
|
42
|
-
footer:
|
|
43
|
-
slots: Object.fromEntries(names.map((name) => [name,
|
|
41
|
+
header: _chunkL7COZ3SNcjs.partOf.call(void 0, bundle.header, data),
|
|
42
|
+
footer: _chunkL7COZ3SNcjs.partOf.call(void 0, bundle.footer, data),
|
|
43
|
+
slots: Object.fromEntries(names.map((name) => [name, _chunkL7COZ3SNcjs.partOf.call(void 0, bundle.slots[name], data)]))
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// src/server/sitemap.ts
|
|
48
48
|
|
|
49
49
|
async function builderSitemap(options) {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (options.client === void 0 && (options.builderKey === void 0 || options.builderKey === "")) {
|
|
51
|
+
_chunkL7COZ3SNcjs.warnOnce.call(void 0, "sitemap-no-key", "builderSitemap has no builderKey (is THROTTLE_BUILDER_KEY set?); the sitemap leaves out the Builder pages");
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const client = _chunkL7COZ3SNcjs.clientOf.call(void 0, options);
|
|
55
|
+
const origin = _chunkL7COZ3SNcjs.originOf.call(void 0, options.storeUrl);
|
|
52
56
|
if (origin === void 0) {
|
|
53
|
-
|
|
57
|
+
_chunkL7COZ3SNcjs.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.");
|
|
54
58
|
return [];
|
|
55
59
|
}
|
|
56
60
|
const locale = _nullishCoalesce(options.locale, () => ( "en"));
|
|
@@ -58,16 +62,16 @@ async function builderSitemap(options) {
|
|
|
58
62
|
const pages = await client.pages.list();
|
|
59
63
|
const { settings } = await client.site({ locale });
|
|
60
64
|
const indexable = await withoutNoindex(client, pages, locale);
|
|
61
|
-
const { list } =
|
|
65
|
+
const { list } = _chunkL7COZ3SNcjs.siteLocales.call(void 0, settings);
|
|
62
66
|
const prefixes = options.localeRoute !== true ? [void 0] : list.length > 0 ? list : [locale];
|
|
63
67
|
return indexable.flatMap((page) => {
|
|
64
|
-
const path =
|
|
68
|
+
const path = _chunkL7COZ3SNcjs.pagePathOf.call(void 0, settings, page, options.pagePath);
|
|
65
69
|
if (path === null) return [];
|
|
66
|
-
return prefixes.map((prefix) => ({ url: `${origin}${
|
|
70
|
+
return prefixes.map((prefix) => ({ url: `${origin}${_chunkL7COZ3SNcjs.localized.call(void 0, path, prefix)}`, lastModified: new Date(page.updatedAt) }));
|
|
67
71
|
});
|
|
68
72
|
} catch (error) {
|
|
69
73
|
if (!(error instanceof _builder.BuilderUnavailableError) || client.mode === "build") throw error;
|
|
70
|
-
|
|
74
|
+
_chunkL7COZ3SNcjs.warnOnce.call(void 0, "sitemap-unavailable", `The Builder could not be read (${error.reason}); the sitemap leaves out its pages`);
|
|
71
75
|
return [];
|
|
72
76
|
}
|
|
73
77
|
}
|
|
@@ -81,14 +85,14 @@ async function withoutNoindex(client, pages, locale) {
|
|
|
81
85
|
slice.map(
|
|
82
86
|
(page) => client.pages.get(page.slug, { locale }).catch((error) => {
|
|
83
87
|
if (error instanceof _builder.BuilderNotFoundError) return "gone";
|
|
84
|
-
|
|
88
|
+
_chunkL7COZ3SNcjs.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`);
|
|
85
89
|
return void 0;
|
|
86
90
|
})
|
|
87
91
|
)
|
|
88
92
|
);
|
|
89
93
|
slice.forEach((page, index) => {
|
|
90
94
|
const answer = answers[index];
|
|
91
|
-
if (answer === "gone" || answer !== void 0 && (
|
|
95
|
+
if (answer === "gone" || answer !== void 0 && (_chunkL7COZ3SNcjs.isRedirect.call(void 0, answer) || _chunkL7COZ3SNcjs.pageSeoOf.call(void 0, answer).noindex)) skip.add(page.slug);
|
|
92
96
|
});
|
|
93
97
|
}
|
|
94
98
|
return pages.filter((page) => !skip.has(page.slug));
|
|
@@ -96,7 +100,7 @@ async function withoutNoindex(client, pages, locale) {
|
|
|
96
100
|
|
|
97
101
|
// src/server/static-params.ts
|
|
98
102
|
async function builderStaticParams(options) {
|
|
99
|
-
const client =
|
|
103
|
+
const client = _chunkL7COZ3SNcjs.clientOf.call(void 0, options);
|
|
100
104
|
if (client.mode !== "build")
|
|
101
105
|
throw new TypeError(
|
|
102
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.'
|
|
@@ -115,4 +119,4 @@ async function builderStaticParams(options) {
|
|
|
115
119
|
|
|
116
120
|
|
|
117
121
|
|
|
118
|
-
exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.builderSitemap = builderSitemap; exports.builderStaticParams = builderStaticParams; exports.getBundle =
|
|
122
|
+
exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.builderSitemap = builderSitemap; exports.builderStaticParams = builderStaticParams; exports.getBundle = _chunkL7COZ3SNcjs.getBundle; exports.loadBuilderPage = _chunkL7COZ3SNcjs.loadBuilderPage; exports.loadSite = loadSite;
|
package/dist/server.d.cts
CHANGED
|
@@ -60,7 +60,7 @@ type BuilderSitemapOptions = ClientOptions & {
|
|
|
60
60
|
/** Where your store serves a page, as for `createBuilderPage`. Pass the same function. */
|
|
61
61
|
pagePath?: PagePathResolver;
|
|
62
62
|
};
|
|
63
|
-
/** The published pages as sitemap entries. An unavailable Builder gives an empty list, never a failed sitemap (a build-mode client fails the build instead). */
|
|
63
|
+
/** The published pages as sitemap entries. An unavailable Builder, or no key at all, gives an empty list and a warning, never a failed sitemap (a build-mode client fails the build instead). */
|
|
64
64
|
declare function builderSitemap(options: BuilderSitemapOptions): Promise<{
|
|
65
65
|
url: string;
|
|
66
66
|
lastModified: Date;
|
package/dist/server.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ type BuilderSitemapOptions = ClientOptions & {
|
|
|
60
60
|
/** Where your store serves a page, as for `createBuilderPage`. Pass the same function. */
|
|
61
61
|
pagePath?: PagePathResolver;
|
|
62
62
|
};
|
|
63
|
-
/** The published pages as sitemap entries. An unavailable Builder gives an empty list, never a failed sitemap (a build-mode client fails the build instead). */
|
|
63
|
+
/** The published pages as sitemap entries. An unavailable Builder, or no key at all, gives an empty list and a warning, never a failed sitemap (a build-mode client fails the build instead). */
|
|
64
64
|
declare function builderSitemap(options: BuilderSitemapOptions): Promise<{
|
|
65
65
|
url: string;
|
|
66
66
|
lastModified: Date;
|
package/dist/server.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
siteLocales,
|
|
13
13
|
staticDataFor,
|
|
14
14
|
warnOnce
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GZN4SYTE.js";
|
|
16
16
|
|
|
17
17
|
// src/server/load-site.ts
|
|
18
18
|
import { BuilderUnavailableError } from "@usethrottle/builder";
|
|
@@ -47,6 +47,10 @@ async function loadSite(options) {
|
|
|
47
47
|
// src/server/sitemap.ts
|
|
48
48
|
import { BuilderNotFoundError, BuilderUnavailableError as BuilderUnavailableError2 } from "@usethrottle/builder";
|
|
49
49
|
async function builderSitemap(options) {
|
|
50
|
+
if (options.client === void 0 && (options.builderKey === void 0 || options.builderKey === "")) {
|
|
51
|
+
warnOnce("sitemap-no-key", "builderSitemap has no builderKey (is THROTTLE_BUILDER_KEY set?); the sitemap leaves out the Builder pages");
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
50
54
|
const client = clientOf(options);
|
|
51
55
|
const origin = originOf(options.storeUrl);
|
|
52
56
|
if (origin === void 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usethrottle/builder-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
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",
|