@usethrottle/builder-react 0.4.0 → 0.4.1

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.
@@ -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].*)?$/i;
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((template) => matchesTemplate(path, template));
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
@@ -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].*)?$/i;
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((template) => matchesTemplate(path, template));
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
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].*)?$/i;
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((template) => matchesTemplate(path, template));
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
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].*)?$/i;
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((template) => matchesTemplate(path, template));
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
package/dist/next.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunk54BG5PPMcjs = require('./chunk-54BG5PPM.cjs');
7
+ var _chunk3HSHGY7Mcjs = require('./chunk-3HSHGY7M.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 _chunk54BG5PPMcjs.loadBuilderPage.call(void 0, {
58
+ const loaded = await _chunk3HSHGY7Mcjs.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 = _chunk54BG5PPMcjs.clientOf.call(void 0, options);
78
+ const client = _chunk3HSHGY7Mcjs.clientOf.call(void 0, options);
79
79
  try {
80
- const bundle = await _chunk54BG5PPMcjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
80
+ const bundle = await _chunk3HSHGY7Mcjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
81
81
  const page = bundle.page;
82
- if (page === void 0 || _chunk54BG5PPMcjs.isRedirect.call(void 0, page)) return {};
83
- return _chunk54BG5PPMcjs.metadataOf.call(void 0, page, {
82
+ if (page === void 0 || _chunk3HSHGY7Mcjs.isRedirect.call(void 0, page)) return {};
83
+ return _chunk3HSHGY7Mcjs.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
@@ -4,7 +4,7 @@ import {
4
4
  isRedirect,
5
5
  loadBuilderPage,
6
6
  metadataOf
7
- } from "./chunk-4EGFSBVT.js";
7
+ } from "./chunk-TS2WCTZ3.js";
8
8
 
9
9
  // src/next/index.ts
10
10
  import { createElement } from "react";
package/dist/server.cjs CHANGED
@@ -12,29 +12,29 @@
12
12
 
13
13
 
14
14
 
15
- var _chunk54BG5PPMcjs = require('./chunk-54BG5PPM.cjs');
15
+ var _chunk3HSHGY7Mcjs = require('./chunk-3HSHGY7M.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 = _chunk54BG5PPMcjs.clientOf.call(void 0, options);
21
+ const client = _chunk3HSHGY7Mcjs.clientOf.call(void 0, options);
22
22
  let bundle;
23
23
  try {
24
- bundle = await _chunk54BG5PPMcjs.getBundle.call(void 0, { client, locale, slots, page });
24
+ bundle = await _chunk3HSHGY7Mcjs.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
- _chunk54BG5PPMcjs.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
+ _chunk3HSHGY7Mcjs.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 = _chunk54BG5PPMcjs.createRendererRegistry.call(void 0, packs);
30
+ const registry = _chunk3HSHGY7Mcjs.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 _chunk54BG5PPMcjs.staticDataFor.call(void 0, documents, registry, locale, currency);
37
+ const data = await _chunk3HSHGY7Mcjs.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: _chunk54BG5PPMcjs.partOf.call(void 0, bundle.header, data, bundle),
46
- footer: _chunk54BG5PPMcjs.partOf.call(void 0, bundle.footer, data, bundle),
47
- slots: Object.fromEntries(names.map((name) => [name, _chunk54BG5PPMcjs.partOf.call(void 0, bundle.slots[name], data, bundle)]))
45
+ header: _chunk3HSHGY7Mcjs.partOf.call(void 0, bundle.header, data, bundle),
46
+ footer: _chunk3HSHGY7Mcjs.partOf.call(void 0, bundle.footer, data, bundle),
47
+ slots: Object.fromEntries(names.map((name) => [name, _chunk3HSHGY7Mcjs.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
- _chunk54BG5PPMcjs.warnOnce.call(void 0, "sitemap-no-key", "builderSitemap has no builderKey (is THROTTLE_BUILDER_KEY set?); the sitemap leaves out the Builder pages");
55
+ _chunk3HSHGY7Mcjs.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 = _chunk54BG5PPMcjs.clientOf.call(void 0, options);
59
- const origin = _chunk54BG5PPMcjs.originOf.call(void 0, options.storeUrl);
58
+ const client = _chunk3HSHGY7Mcjs.clientOf.call(void 0, options);
59
+ const origin = _chunk3HSHGY7Mcjs.originOf.call(void 0, options.storeUrl);
60
60
  if (origin === void 0) {
61
- _chunk54BG5PPMcjs.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.");
61
+ _chunk3HSHGY7Mcjs.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 } = _chunk54BG5PPMcjs.siteLocales.call(void 0, settings);
69
+ const { list } = _chunk3HSHGY7Mcjs.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 = _chunk54BG5PPMcjs.pagePathOf.call(void 0, settings, page, options.pagePath);
72
+ const path = _chunk3HSHGY7Mcjs.pagePathOf.call(void 0, settings, page, options.pagePath);
73
73
  if (path === null) return [];
74
- return prefixes.map((prefix) => ({ url: `${origin}${_chunk54BG5PPMcjs.localized.call(void 0, path, prefix)}`, lastModified: new Date(page.updatedAt) }));
74
+ return prefixes.map((prefix) => ({ url: `${origin}${_chunk3HSHGY7Mcjs.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
- _chunk54BG5PPMcjs.warnOnce.call(void 0, "sitemap-unavailable", `The Builder could not be read (${error.reason}); the sitemap leaves out its pages`);
78
+ _chunk3HSHGY7Mcjs.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
- _chunk54BG5PPMcjs.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`);
92
+ _chunk3HSHGY7Mcjs.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 && (_chunk54BG5PPMcjs.isRedirect.call(void 0, answer) || _chunk54BG5PPMcjs.pageSeoOf.call(void 0, answer).noindex)) skip.add(page.slug);
99
+ if (answer === "gone" || answer !== void 0 && (_chunk3HSHGY7Mcjs.isRedirect.call(void 0, answer) || _chunk3HSHGY7Mcjs.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 = _chunk54BG5PPMcjs.clientOf.call(void 0, options);
107
+ const client = _chunk3HSHGY7Mcjs.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 = _chunk54BG5PPMcjs.getBundle; exports.loadBuilderPage = _chunk54BG5PPMcjs.loadBuilderPage; exports.loadSite = loadSite;
126
+ exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.builderSitemap = builderSitemap; exports.builderStaticParams = builderStaticParams; exports.getBundle = _chunk3HSHGY7Mcjs.getBundle; exports.loadBuilderPage = _chunk3HSHGY7Mcjs.loadBuilderPage; exports.loadSite = loadSite;
package/dist/server.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  siteLocales,
13
13
  staticDataFor,
14
14
  warnOnce
15
- } from "./chunk-4EGFSBVT.js";
15
+ } from "./chunk-TS2WCTZ3.js";
16
16
 
17
17
  // src/server/load-site.ts
18
18
  import { BuilderUnavailableError } from "@usethrottle/builder";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/builder-react",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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",