@usethrottle/builder-react 0.4.0 → 0.4.2
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/dist/{chunk-4EGFSBVT.js → chunk-SYXZO5H2.js} +6 -4
- package/dist/{chunk-54BG5PPM.cjs → chunk-XHTZWZPN.cjs} +6 -4
- package/dist/index.cjs +10 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -7
- package/dist/next.cjs +6 -6
- package/dist/next.js +1 -1
- package/dist/server.cjs +21 -21
- package/dist/server.js +1 -1
- package/package.json +3 -3
|
@@ -352,11 +352,11 @@ import { BASIC_WIDGET_DEFINITIONS, resolveResponsive, safeUrl } from "@usethrott
|
|
|
352
352
|
|
|
353
353
|
// src/basics/styles.ts
|
|
354
354
|
var BASICS_CSS = `@layer throttle{
|
|
355
|
-
.tb-b-heading{margin:0;text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l));line-height:1.2;overflow-wrap:anywhere}
|
|
355
|
+
.tb-b-heading{margin:0;font-family:var(--throttle-font-family-heading,inherit);text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l));line-height:1.2;overflow-wrap:anywhere}
|
|
356
356
|
.tb-b-text{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.6;overflow-wrap:anywhere}
|
|
357
357
|
.tb-b-text>:first-child{margin-block-start:0}
|
|
358
358
|
.tb-b-text>:last-child{margin-block-end:0}
|
|
359
|
-
.tb-b-text h2,.tb-b-text h3,.tb-b-text h4{line-height:1.25}
|
|
359
|
+
.tb-b-text h2,.tb-b-text h3,.tb-b-text h4{font-family:var(--throttle-font-family-heading,inherit);line-height:1.25}
|
|
360
360
|
.tb-b-text blockquote{margin-inline:0;padding-inline-start:var(--tb-space-m);border-inline-start:3px solid var(--tb-color-border,currentColor)}
|
|
361
361
|
.tb-b-text code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}
|
|
362
362
|
.tb-b-link{color:var(--tb-color-primary,currentColor);text-decoration:underline}
|
|
@@ -1643,7 +1643,7 @@ function TemplateWidget(props) {
|
|
|
1643
1643
|
import { useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
1644
1644
|
|
|
1645
1645
|
// src/code/routes.ts
|
|
1646
|
-
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)
|
|
1646
|
+
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)?$|^(confirm|thank|receipt|invoice|quote).*$|^order[-_].*$/i;
|
|
1647
1647
|
var DEFAULT_CATALOG_ROUTES = [
|
|
1648
1648
|
"/p/{handle}",
|
|
1649
1649
|
"/c/{handle}",
|
|
@@ -1703,7 +1703,9 @@ function isCodeRoute(pathname, routes) {
|
|
|
1703
1703
|
if (path === null) return false;
|
|
1704
1704
|
if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
|
|
1705
1705
|
if (path === "/") return true;
|
|
1706
|
-
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some(
|
|
1706
|
+
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some(
|
|
1707
|
+
(template) => matchesTemplate(path, template)
|
|
1708
|
+
);
|
|
1707
1709
|
}
|
|
1708
1710
|
|
|
1709
1711
|
// src/code/leave.ts
|
|
@@ -352,11 +352,11 @@ var _ui = require('@usethrottle/ui');
|
|
|
352
352
|
|
|
353
353
|
// src/basics/styles.ts
|
|
354
354
|
var BASICS_CSS = `@layer throttle{
|
|
355
|
-
.tb-b-heading{margin:0;text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l));line-height:1.2;overflow-wrap:anywhere}
|
|
355
|
+
.tb-b-heading{margin:0;font-family:var(--throttle-font-family-heading,inherit);text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l));line-height:1.2;overflow-wrap:anywhere}
|
|
356
356
|
.tb-b-text{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.6;overflow-wrap:anywhere}
|
|
357
357
|
.tb-b-text>:first-child{margin-block-start:0}
|
|
358
358
|
.tb-b-text>:last-child{margin-block-end:0}
|
|
359
|
-
.tb-b-text h2,.tb-b-text h3,.tb-b-text h4{line-height:1.25}
|
|
359
|
+
.tb-b-text h2,.tb-b-text h3,.tb-b-text h4{font-family:var(--throttle-font-family-heading,inherit);line-height:1.25}
|
|
360
360
|
.tb-b-text blockquote{margin-inline:0;padding-inline-start:var(--tb-space-m);border-inline-start:3px solid var(--tb-color-border,currentColor)}
|
|
361
361
|
.tb-b-text code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}
|
|
362
362
|
.tb-b-link{color:var(--tb-color-primary,currentColor);text-decoration:underline}
|
|
@@ -1643,7 +1643,7 @@ function TemplateWidget(props) {
|
|
|
1643
1643
|
|
|
1644
1644
|
|
|
1645
1645
|
// src/code/routes.ts
|
|
1646
|
-
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)
|
|
1646
|
+
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)?$|^(confirm|thank|receipt|invoice|quote).*$|^order[-_].*$/i;
|
|
1647
1647
|
var DEFAULT_CATALOG_ROUTES = [
|
|
1648
1648
|
"/p/{handle}",
|
|
1649
1649
|
"/c/{handle}",
|
|
@@ -1703,7 +1703,9 @@ function isCodeRoute(pathname, routes) {
|
|
|
1703
1703
|
if (path === null) return false;
|
|
1704
1704
|
if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
|
|
1705
1705
|
if (path === "/") return true;
|
|
1706
|
-
return [routes.page, ..._nullishCoalesce(routes.catalog, () => ( DEFAULT_CATALOG_ROUTES))].some(
|
|
1706
|
+
return [routes.page, ..._nullishCoalesce(routes.catalog, () => ( DEFAULT_CATALOG_ROUTES))].some(
|
|
1707
|
+
(template) => matchesTemplate(path, template)
|
|
1708
|
+
);
|
|
1707
1709
|
}
|
|
1708
1710
|
|
|
1709
1711
|
// src/code/leave.ts
|
package/dist/index.cjs
CHANGED
|
@@ -710,7 +710,7 @@ function reloadHere() {
|
|
|
710
710
|
}
|
|
711
711
|
|
|
712
712
|
// src/code/routes.ts
|
|
713
|
-
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)
|
|
713
|
+
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)?$|^(confirm|thank|receipt|invoice|quote).*$|^order[-_].*$/i;
|
|
714
714
|
var DEFAULT_CATALOG_ROUTES = [
|
|
715
715
|
"/p/{handle}",
|
|
716
716
|
"/c/{handle}",
|
|
@@ -770,7 +770,9 @@ function isCodeRoute(pathname, routes) {
|
|
|
770
770
|
if (path === null) return false;
|
|
771
771
|
if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
|
|
772
772
|
if (path === "/") return true;
|
|
773
|
-
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some(
|
|
773
|
+
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some(
|
|
774
|
+
(template) => matchesTemplate(path, template)
|
|
775
|
+
);
|
|
774
776
|
}
|
|
775
777
|
|
|
776
778
|
// src/code/leave.ts
|
|
@@ -2026,11 +2028,11 @@ var import_builder_schema14 = require("@usethrottle/builder-schema");
|
|
|
2026
2028
|
|
|
2027
2029
|
// src/basics/styles.ts
|
|
2028
2030
|
var BASICS_CSS = `@layer throttle{
|
|
2029
|
-
.tb-b-heading{margin:0;text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l));line-height:1.2;overflow-wrap:anywhere}
|
|
2031
|
+
.tb-b-heading{margin:0;font-family:var(--throttle-font-family-heading,inherit);text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l));line-height:1.2;overflow-wrap:anywhere}
|
|
2030
2032
|
.tb-b-text{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.6;overflow-wrap:anywhere}
|
|
2031
2033
|
.tb-b-text>:first-child{margin-block-start:0}
|
|
2032
2034
|
.tb-b-text>:last-child{margin-block-end:0}
|
|
2033
|
-
.tb-b-text h2,.tb-b-text h3,.tb-b-text h4{line-height:1.25}
|
|
2035
|
+
.tb-b-text h2,.tb-b-text h3,.tb-b-text h4{font-family:var(--throttle-font-family-heading,inherit);line-height:1.25}
|
|
2034
2036
|
.tb-b-text blockquote{margin-inline:0;padding-inline-start:var(--tb-space-m);border-inline-start:3px solid var(--tb-color-border,currentColor)}
|
|
2035
2037
|
.tb-b-text code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}
|
|
2036
2038
|
.tb-b-link{color:var(--tb-color-primary,currentColor);text-decoration:underline}
|
|
@@ -3116,9 +3118,10 @@ var kebab = (key) => key.replace(/^color/, "").replace(/([a-z])([A-Z])/g, "$1-$2
|
|
|
3116
3118
|
function colourDecls(p) {
|
|
3117
3119
|
return PALETTE_KEYS.map((key) => `--tb-color-${kebab(key)}:${p[key]}`).join(";");
|
|
3118
3120
|
}
|
|
3119
|
-
function themeCss(settings) {
|
|
3121
|
+
function themeCss(settings, options = {}) {
|
|
3120
3122
|
const { tokens, colorScheme } = themeTokens(settings);
|
|
3121
|
-
const
|
|
3123
|
+
const heading = options.hostFont === true ? "" : `--throttle-font-family-heading:${fontStack(tokens.fonts.heading)};`;
|
|
3124
|
+
const light = `:root{--tb-scale:${String(SCALE[tokens.spacingScale])};${heading}${colourDecls(tokens.light)}}`;
|
|
3122
3125
|
const dark = colourDecls(tokens.dark);
|
|
3123
3126
|
if (colorScheme === "light") return light;
|
|
3124
3127
|
if (colorScheme === "dark") return `${light}:root{${dark}}`;
|
|
@@ -3294,7 +3297,7 @@ function BuilderProvider({ builderKey, client, packs, site, onError, interactive
|
|
|
3294
3297
|
return parentFont === void 0 ? merged : { ...merged, variables: { ...merged.variables, fontFamily: parentFont } };
|
|
3295
3298
|
}, [own, merged, parentFont]);
|
|
3296
3299
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(BuilderContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_ui6.ThrottleUIProvider, { ...appearance === void 0 ? {} : { appearance }, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_ui6.SiteDesignProvider, { value: design, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_ui6.SlotOutletProvider, { resolve: resolveSlot, children: [
|
|
3297
|
-
site.status === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("style", { children: themeCss(site.settings) }) : null,
|
|
3300
|
+
site.status === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("style", { children: themeCss(site.settings, { hostFont: parentFont !== void 0 }) }) : null,
|
|
3298
3301
|
customCss === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("style", { children: customCssSheet(customCss) }),
|
|
3299
3302
|
leaving ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { "data-b-leaving": "", hidden: true }) : children
|
|
3300
3303
|
] }) }) }) });
|
package/dist/index.d.cts
CHANGED
|
@@ -514,7 +514,7 @@ declare function resolveBindings(bindings: ReadonlyMap<string, DataBinding>, reg
|
|
|
514
514
|
* merchant setting: no switch in the dashboard can put a script on a checkout, cart-payment, account or sign-in page.
|
|
515
515
|
*/
|
|
516
516
|
/**
|
|
517
|
-
* A path segment that never runs code (checkout, cart, account, sign-in and their common synonyms). `isCodeRoute`
|
|
517
|
+
* A path segment that never runs code (checkout, cart, account, sign-in and their common synonyms, and the pages after a purchase or a quote: `confirm*`, `thank*`, `receipt*`, `invoice*`, `quote*`, `order-*`). `isCodeRoute`
|
|
518
518
|
* tests every segment of the path with it, and the deny wins over every allow rule.
|
|
519
519
|
*/
|
|
520
520
|
declare const CODE_ROUTE_DENY: RegExp;
|
package/dist/index.d.ts
CHANGED
|
@@ -514,7 +514,7 @@ declare function resolveBindings(bindings: ReadonlyMap<string, DataBinding>, reg
|
|
|
514
514
|
* merchant setting: no switch in the dashboard can put a script on a checkout, cart-payment, account or sign-in page.
|
|
515
515
|
*/
|
|
516
516
|
/**
|
|
517
|
-
* A path segment that never runs code (checkout, cart, account, sign-in and their common synonyms). `isCodeRoute`
|
|
517
|
+
* A path segment that never runs code (checkout, cart, account, sign-in and their common synonyms, and the pages after a purchase or a quote: `confirm*`, `thank*`, `receipt*`, `invoice*`, `quote*`, `order-*`). `isCodeRoute`
|
|
518
518
|
* tests every segment of the path with it, and the deny wins over every allow rule.
|
|
519
519
|
*/
|
|
520
520
|
declare const CODE_ROUTE_DENY: RegExp;
|
package/dist/index.js
CHANGED
|
@@ -663,7 +663,7 @@ function reloadHere() {
|
|
|
663
663
|
}
|
|
664
664
|
|
|
665
665
|
// src/code/routes.ts
|
|
666
|
-
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)
|
|
666
|
+
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)?$|^(confirm|thank|receipt|invoice|quote).*$|^order[-_].*$/i;
|
|
667
667
|
var DEFAULT_CATALOG_ROUTES = [
|
|
668
668
|
"/p/{handle}",
|
|
669
669
|
"/c/{handle}",
|
|
@@ -723,7 +723,9 @@ function isCodeRoute(pathname, routes) {
|
|
|
723
723
|
if (path === null) return false;
|
|
724
724
|
if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
|
|
725
725
|
if (path === "/") return true;
|
|
726
|
-
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some(
|
|
726
|
+
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some(
|
|
727
|
+
(template) => matchesTemplate(path, template)
|
|
728
|
+
);
|
|
727
729
|
}
|
|
728
730
|
|
|
729
731
|
// src/code/leave.ts
|
|
@@ -1987,11 +1989,11 @@ import { BASIC_WIDGET_DEFINITIONS, resolveResponsive as resolveResponsive3, safe
|
|
|
1987
1989
|
|
|
1988
1990
|
// src/basics/styles.ts
|
|
1989
1991
|
var BASICS_CSS = `@layer throttle{
|
|
1990
|
-
.tb-b-heading{margin:0;text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l));line-height:1.2;overflow-wrap:anywhere}
|
|
1992
|
+
.tb-b-heading{margin:0;font-family:var(--throttle-font-family-heading,inherit);text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l));line-height:1.2;overflow-wrap:anywhere}
|
|
1991
1993
|
.tb-b-text{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.6;overflow-wrap:anywhere}
|
|
1992
1994
|
.tb-b-text>:first-child{margin-block-start:0}
|
|
1993
1995
|
.tb-b-text>:last-child{margin-block-end:0}
|
|
1994
|
-
.tb-b-text h2,.tb-b-text h3,.tb-b-text h4{line-height:1.25}
|
|
1996
|
+
.tb-b-text h2,.tb-b-text h3,.tb-b-text h4{font-family:var(--throttle-font-family-heading,inherit);line-height:1.25}
|
|
1995
1997
|
.tb-b-text blockquote{margin-inline:0;padding-inline-start:var(--tb-space-m);border-inline-start:3px solid var(--tb-color-border,currentColor)}
|
|
1996
1998
|
.tb-b-text code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}
|
|
1997
1999
|
.tb-b-link{color:var(--tb-color-primary,currentColor);text-decoration:underline}
|
|
@@ -3077,9 +3079,10 @@ var kebab = (key) => key.replace(/^color/, "").replace(/([a-z])([A-Z])/g, "$1-$2
|
|
|
3077
3079
|
function colourDecls(p) {
|
|
3078
3080
|
return PALETTE_KEYS.map((key) => `--tb-color-${kebab(key)}:${p[key]}`).join(";");
|
|
3079
3081
|
}
|
|
3080
|
-
function themeCss(settings) {
|
|
3082
|
+
function themeCss(settings, options = {}) {
|
|
3081
3083
|
const { tokens, colorScheme } = themeTokens(settings);
|
|
3082
|
-
const
|
|
3084
|
+
const heading = options.hostFont === true ? "" : `--throttle-font-family-heading:${fontStack(tokens.fonts.heading)};`;
|
|
3085
|
+
const light = `:root{--tb-scale:${String(SCALE[tokens.spacingScale])};${heading}${colourDecls(tokens.light)}}`;
|
|
3083
3086
|
const dark = colourDecls(tokens.dark);
|
|
3084
3087
|
if (colorScheme === "light") return light;
|
|
3085
3088
|
if (colorScheme === "dark") return `${light}:root{${dark}}`;
|
|
@@ -3255,7 +3258,7 @@ function BuilderProvider({ builderKey, client, packs, site, onError, interactive
|
|
|
3255
3258
|
return parentFont === void 0 ? merged : { ...merged, variables: { ...merged.variables, fontFamily: parentFont } };
|
|
3256
3259
|
}, [own, merged, parentFont]);
|
|
3257
3260
|
return /* @__PURE__ */ jsx33(BuilderContext.Provider, { value, children: /* @__PURE__ */ jsx33(ThrottleUIProvider, { ...appearance === void 0 ? {} : { appearance }, children: /* @__PURE__ */ jsx33(SiteDesignProvider, { value: design, children: /* @__PURE__ */ jsxs21(SlotOutletProvider, { resolve: resolveSlot, children: [
|
|
3258
|
-
site.status === "ok" ? /* @__PURE__ */ jsx33("style", { children: themeCss(site.settings) }) : null,
|
|
3261
|
+
site.status === "ok" ? /* @__PURE__ */ jsx33("style", { children: themeCss(site.settings, { hostFont: parentFont !== void 0 }) }) : null,
|
|
3259
3262
|
customCss === "" ? null : /* @__PURE__ */ jsx33("style", { children: customCssSheet(customCss) }),
|
|
3260
3263
|
leaving ? /* @__PURE__ */ jsx33("div", { "data-b-leaving": "", hidden: true }) : children
|
|
3261
3264
|
] }) }) }) });
|
package/dist/next.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkXHTZWZPNcjs = require('./chunk-XHTZWZPN.cjs');
|
|
8
8
|
|
|
9
9
|
// src/next/index.ts
|
|
10
10
|
var _react = require('react');
|
|
@@ -55,7 +55,7 @@ function createBuilderPage(options) {
|
|
|
55
55
|
const slug = slugOf(options, params);
|
|
56
56
|
const currency = await currencyOf(options, params);
|
|
57
57
|
const { currency: _currency, ...rest } = options;
|
|
58
|
-
const loaded = await
|
|
58
|
+
const loaded = await _chunkXHTZWZPNcjs.loadBuilderPage.call(void 0, {
|
|
59
59
|
...rest,
|
|
60
60
|
slug,
|
|
61
61
|
locale: await localeOf(options, params),
|
|
@@ -75,12 +75,12 @@ function createBuilderPage(options) {
|
|
|
75
75
|
const params = await props.params;
|
|
76
76
|
const slug = slugOf(options, params);
|
|
77
77
|
const locale = await localeOf(options, params);
|
|
78
|
-
const client =
|
|
78
|
+
const client = _chunkXHTZWZPNcjs.clientOf.call(void 0, options);
|
|
79
79
|
try {
|
|
80
|
-
const bundle = await
|
|
80
|
+
const bundle = await _chunkXHTZWZPNcjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
|
|
81
81
|
const page = bundle.page;
|
|
82
|
-
if (page === void 0 ||
|
|
83
|
-
return
|
|
82
|
+
if (page === void 0 || _chunkXHTZWZPNcjs.isRedirect.call(void 0, page)) return {};
|
|
83
|
+
return _chunkXHTZWZPNcjs.metadataOf.call(void 0, page, {
|
|
84
84
|
settings: bundle.site.settings,
|
|
85
85
|
mediaOrigin: _nullishCoalesce(options.mediaOrigin, () => ( "")),
|
|
86
86
|
storeUrl: options.storeUrl,
|
package/dist/next.js
CHANGED
package/dist/server.cjs
CHANGED
|
@@ -12,29 +12,29 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkXHTZWZPNcjs = require('./chunk-XHTZWZPN.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 = "", currency } = options;
|
|
21
|
-
const client =
|
|
21
|
+
const client = _chunkXHTZWZPNcjs.clientOf.call(void 0, options);
|
|
22
22
|
let bundle;
|
|
23
23
|
try {
|
|
24
|
-
bundle = await
|
|
24
|
+
bundle = await _chunkXHTZWZPNcjs.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
|
+
_chunkXHTZWZPNcjs.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 = _chunkXHTZWZPNcjs.createRendererRegistry.call(void 0, packs);
|
|
31
31
|
const names = Object.keys(bundle.slots);
|
|
32
32
|
const withShared = (loaded) => ({
|
|
33
33
|
...loaded,
|
|
34
34
|
...(_nullishCoalesce(loaded.savedSections, () => ( bundle.savedSections))) === void 0 ? {} : { savedSections: _nullishCoalesce(loaded.savedSections, () => ( bundle.savedSections)) }
|
|
35
35
|
});
|
|
36
36
|
const documents = [bundle.header, bundle.footer, ...names.map((n) => bundle.slots[n])].map(withShared);
|
|
37
|
-
const data = await
|
|
37
|
+
const data = await _chunkXHTZWZPNcjs.staticDataFor.call(void 0, documents, registry, locale, currency);
|
|
38
38
|
return {
|
|
39
39
|
status: "ok",
|
|
40
40
|
locale,
|
|
@@ -42,9 +42,9 @@ async function loadSite(options) {
|
|
|
42
42
|
siteVersion: bundle.site.siteVersion,
|
|
43
43
|
mediaOrigin,
|
|
44
44
|
settings: bundle.site.settings,
|
|
45
|
-
header:
|
|
46
|
-
footer:
|
|
47
|
-
slots: Object.fromEntries(names.map((name) => [name,
|
|
45
|
+
header: _chunkXHTZWZPNcjs.partOf.call(void 0, bundle.header, data, bundle),
|
|
46
|
+
footer: _chunkXHTZWZPNcjs.partOf.call(void 0, bundle.footer, data, bundle),
|
|
47
|
+
slots: Object.fromEntries(names.map((name) => [name, _chunkXHTZWZPNcjs.partOf.call(void 0, bundle.slots[name], data, bundle)]))
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -52,13 +52,13 @@ async function loadSite(options) {
|
|
|
52
52
|
|
|
53
53
|
async function builderSitemap(options) {
|
|
54
54
|
if (options.client === void 0 && (options.builderKey === void 0 || options.builderKey === "")) {
|
|
55
|
-
|
|
55
|
+
_chunkXHTZWZPNcjs.warnOnce.call(void 0, "sitemap-no-key", "builderSitemap has no builderKey (is THROTTLE_BUILDER_KEY set?); the sitemap leaves out the Builder pages");
|
|
56
56
|
return [];
|
|
57
57
|
}
|
|
58
|
-
const client =
|
|
59
|
-
const origin =
|
|
58
|
+
const client = _chunkXHTZWZPNcjs.clientOf.call(void 0, options);
|
|
59
|
+
const origin = _chunkXHTZWZPNcjs.originOf.call(void 0, options.storeUrl);
|
|
60
60
|
if (origin === void 0) {
|
|
61
|
-
|
|
61
|
+
_chunkXHTZWZPNcjs.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.");
|
|
62
62
|
return [];
|
|
63
63
|
}
|
|
64
64
|
const locale = _nullishCoalesce(options.locale, () => ( "en"));
|
|
@@ -66,16 +66,16 @@ async function builderSitemap(options) {
|
|
|
66
66
|
const pages = await client.pages.list();
|
|
67
67
|
const { settings } = await client.site({ locale });
|
|
68
68
|
const indexable = await withoutNoindex(client, pages, locale);
|
|
69
|
-
const { list } =
|
|
69
|
+
const { list } = _chunkXHTZWZPNcjs.siteLocales.call(void 0, settings);
|
|
70
70
|
const prefixes = options.localeRoute !== true ? [void 0] : list.length > 0 ? list : [locale];
|
|
71
71
|
return indexable.flatMap((page) => {
|
|
72
|
-
const path =
|
|
72
|
+
const path = _chunkXHTZWZPNcjs.pagePathOf.call(void 0, settings, page, options.pagePath);
|
|
73
73
|
if (path === null) return [];
|
|
74
|
-
return prefixes.map((prefix) => ({ url: `${origin}${
|
|
74
|
+
return prefixes.map((prefix) => ({ url: `${origin}${_chunkXHTZWZPNcjs.localized.call(void 0, path, prefix)}`, lastModified: new Date(page.updatedAt) }));
|
|
75
75
|
});
|
|
76
76
|
} catch (error) {
|
|
77
77
|
if (!(error instanceof _builder.BuilderUnavailableError) || client.mode === "build") throw error;
|
|
78
|
-
|
|
78
|
+
_chunkXHTZWZPNcjs.warnOnce.call(void 0, "sitemap-unavailable", `The Builder could not be read (${error.reason}); the sitemap leaves out its pages`);
|
|
79
79
|
return [];
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -89,14 +89,14 @@ async function withoutNoindex(client, pages, locale) {
|
|
|
89
89
|
slice.map(
|
|
90
90
|
(page) => client.pages.get(page.slug, { locale }).catch((error) => {
|
|
91
91
|
if (error instanceof _builder.BuilderNotFoundError) return "gone";
|
|
92
|
-
|
|
92
|
+
_chunkXHTZWZPNcjs.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`);
|
|
93
93
|
return void 0;
|
|
94
94
|
})
|
|
95
95
|
)
|
|
96
96
|
);
|
|
97
97
|
slice.forEach((page, index) => {
|
|
98
98
|
const answer = answers[index];
|
|
99
|
-
if (answer === "gone" || answer !== void 0 && (
|
|
99
|
+
if (answer === "gone" || answer !== void 0 && (_chunkXHTZWZPNcjs.isRedirect.call(void 0, answer) || _chunkXHTZWZPNcjs.pageSeoOf.call(void 0, answer).noindex)) skip.add(page.slug);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
return pages.filter((page) => !skip.has(page.slug));
|
|
@@ -104,7 +104,7 @@ async function withoutNoindex(client, pages, locale) {
|
|
|
104
104
|
|
|
105
105
|
// src/server/static-params.ts
|
|
106
106
|
async function builderStaticParams(options) {
|
|
107
|
-
const client =
|
|
107
|
+
const client = _chunkXHTZWZPNcjs.clientOf.call(void 0, options);
|
|
108
108
|
if (client.mode !== "build")
|
|
109
109
|
throw new TypeError(
|
|
110
110
|
'builderStaticParams generates every page of a frozen release: give it a client made with createBuilderClient({ mode: "build" }). A live store keeps its pages dynamic.'
|
|
@@ -123,4 +123,4 @@ async function builderStaticParams(options) {
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.builderSitemap = builderSitemap; exports.builderStaticParams = builderStaticParams; exports.getBundle =
|
|
126
|
+
exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.builderSitemap = builderSitemap; exports.builderStaticParams = builderStaticParams; exports.getBundle = _chunkXHTZWZPNcjs.getBundle; exports.loadBuilderPage = _chunkXHTZWZPNcjs.loadBuilderPage; exports.loadSite = loadSite;
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usethrottle/builder-react",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
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-schema": "^0.2.1",
|
|
61
60
|
"@usethrottle/ui": "^0.1.2",
|
|
62
|
-
"@usethrottle/builder": "^0.5.0"
|
|
61
|
+
"@usethrottle/builder": "^0.5.0",
|
|
62
|
+
"@usethrottle/builder-schema": "^0.2.1"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"next": ">=15",
|