@usethrottle/builder-react 0.5.2 → 0.5.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/dist/next.cjs CHANGED
@@ -12,7 +12,9 @@
12
12
 
13
13
 
14
14
 
15
- var _chunkWGBNEYOFcjs = require('./chunk-WGBNEYOF.cjs');
15
+
16
+
17
+ var _chunkJ2IHOBDXcjs = require('./chunk-J2IHOBDX.cjs');
16
18
 
17
19
  // src/next/index.ts
18
20
  var _react = require('react'); var React = _interopRequireWildcard(_react);
@@ -70,7 +72,7 @@ var BuilderUnavailablePageError = class extends Error {
70
72
  constructor(template) {
71
73
  super(`The ${template} template cannot be served: its data source is unavailable`);
72
74
  this.template = template;
73
- _chunkWGBNEYOFcjs.__publicField.call(void 0, this, "name", "BuilderUnavailablePageError");
75
+ _chunkJ2IHOBDXcjs.__publicField.call(void 0, this, "name", "BuilderUnavailablePageError");
74
76
  }
75
77
  };
76
78
  var isRec = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -148,8 +150,8 @@ function createBuilderRoute(options) {
148
150
  return typeof params.locale === "string" ? params.locale : "en";
149
151
  }
150
152
  async function resolve(path, locale, currency) {
151
- const client = _chunkWGBNEYOFcjs.clientOf.call(void 0, options);
152
- const bundle = await _chunkWGBNEYOFcjs.getBundle.call(void 0, { client, locale, slots: options.slots });
153
+ const client = _chunkJ2IHOBDXcjs.clientOf.call(void 0, options);
154
+ const bundle = await _chunkJ2IHOBDXcjs.getBundle.call(void 0, { client, locale, slots: options.slots });
153
155
  const settings = bundle.site.settings;
154
156
  const read = {
155
157
  client: options.client,
@@ -172,10 +174,10 @@ function createBuilderRoute(options) {
172
174
  const params = matchTemplate(template, path);
173
175
  return params === null ? [] : [{ name, params }];
174
176
  })[0];
175
- const routeTable = _chunkWGBNEYOFcjs.buildRouteTable.call(void 0, store, catalog);
177
+ const routeTable = _chunkJ2IHOBDXcjs.buildRouteTable.call(void 0, store, catalog);
176
178
  if (path === "/") {
177
179
  try {
178
- const home = await _chunkWGBNEYOFcjs.loadBuilderPage.call(void 0, { ...read, slug: "home" });
180
+ const home = await _chunkJ2IHOBDXcjs.loadBuilderPage.call(void 0, { ...read, slug: "home" });
179
181
  if (home.kind === "redirect") return pageRedirectTo(home.redirectTo);
180
182
  return { kind: "page", slug: "home", page: home, path, own: false };
181
183
  } catch (error) {
@@ -186,7 +188,7 @@ function createBuilderRoute(options) {
186
188
  const handle = _optionalChain([matchTemplate, 'call', _6 => _6(pageRoute, path), 'optionalAccess', _7 => _7.handle]);
187
189
  if (matched === void 0 && handle === void 0 && path !== "/" && _builderschema.PAGE_PATH_RE.test(path)) {
188
190
  try {
189
- const found = await _chunkWGBNEYOFcjs.loadBuilderPageByPath.call(void 0, { ...read, path });
191
+ const found = await _chunkJ2IHOBDXcjs.loadBuilderPageByPath.call(void 0, { ...read, path });
190
192
  if (found.kind === "redirect") return pageRedirectTo(found.redirectTo);
191
193
  return { kind: "page", slug: found.slug, page: found, path, own: true };
192
194
  } catch (error) {
@@ -195,9 +197,9 @@ function createBuilderRoute(options) {
195
197
  }
196
198
  if (handle !== void 0) {
197
199
  try {
198
- const found = await _chunkWGBNEYOFcjs.loadBuilderPage.call(void 0, { ...read, slug: handle });
200
+ const found = await _chunkJ2IHOBDXcjs.loadBuilderPage.call(void 0, { ...read, slug: handle });
199
201
  if (found.kind === "redirect") return pageRedirectTo(found.redirectTo);
200
- if (_chunkWGBNEYOFcjs.isOwnPath.call(void 0, found.path)) return { kind: "redirect", to: found.path, permanent: true };
202
+ if (_chunkJ2IHOBDXcjs.isOwnPath.call(void 0, found.path)) return { kind: "redirect", to: found.path, permanent: true };
201
203
  return { kind: "page", slug: handle, page: found, path, own: false };
202
204
  } catch (error) {
203
205
  if (!isNotFound(error)) throw error;
@@ -209,7 +211,7 @@ function createBuilderRoute(options) {
209
211
  async function finish(matched, queryJson, locale, currency) {
210
212
  const { name, path, routeTable } = matched;
211
213
  const query = JSON.parse(queryJson);
212
- const bundle = await _chunkWGBNEYOFcjs.getBundle.call(void 0, { client: _chunkWGBNEYOFcjs.clientOf.call(void 0, options), locale, slots: options.slots });
214
+ const bundle = await _chunkJ2IHOBDXcjs.getBundle.call(void 0, { client: _chunkJ2IHOBDXcjs.clientOf.call(void 0, options), locale, slots: options.slots });
213
215
  const read = {
214
216
  client: options.client,
215
217
  builderKey: options.builderKey,
@@ -232,7 +234,7 @@ function createBuilderRoute(options) {
232
234
  ...bundle.code === void 0 ? {} : { code: bundle.code }
233
235
  };
234
236
  try {
235
- const { part, meta } = await _chunkWGBNEYOFcjs.loadBuilderTemplate.call(void 0, { ...read, name, shared });
237
+ const { part, meta } = await _chunkJ2IHOBDXcjs.loadBuilderTemplate.call(void 0, { ...read, name, shared });
236
238
  return { kind: "template", name, part, context, meta, routeTable, path, unavailable };
237
239
  } catch (error) {
238
240
  const contribution = packs.flatMap((pack) => _nullishCoalesce(pack.templates, () => ( []))).find((entry) => entry.name === name);
@@ -297,24 +299,47 @@ function createBuilderRoute(options) {
297
299
  return { resolved, params, locale, search: search === "" ? "" : `?${search}` };
298
300
  }
299
301
  function templateBody(resolved) {
300
- const view = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _builderreact.BuilderTemplateView, { name: resolved.name, part: resolved.part, context: resolved.context });
301
- const Root = _chunkWGBNEYOFcjs.templateRootOf.call(void 0, packs, resolved.name);
302
+ const view = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
303
+ _builderreact.BuilderTemplateView,
304
+ {
305
+ name: resolved.name,
306
+ part: resolved.part,
307
+ context: resolved.context,
308
+ frame: _optionalChain([resolved, 'access', _8 => _8.meta, 'optionalAccess', _9 => _9.frame])
309
+ }
310
+ );
311
+ const Root = _chunkJ2IHOBDXcjs.templateRootOf.call(void 0, packs, resolved.name);
302
312
  if (Root === void 0) return view;
303
313
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { context: resolved.context, document: resolved.part.document, children: view });
304
314
  }
305
315
  async function Page(props) {
306
- const { resolved } = await request(props);
316
+ const { resolved, locale } = await request(props);
307
317
  switch (resolved.kind) {
308
318
  case "redirect":
309
319
  return resolved.permanent ? _navigation.permanentRedirect.call(void 0, resolved.to) : _navigation.redirect.call(void 0, resolved.to);
310
320
  case "notFound":
311
321
  return _navigation.notFound.call(void 0, );
312
- case "page":
313
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _builderreact.BuilderRouteScope, { ...resolved.own ? { allowPath: resolved.path } : {}, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _builderreact.BuilderPageView, { page: resolved.page }) });
322
+ case "page": {
323
+ const view = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _builderreact.BuilderRouteScope, { ...resolved.own ? { allowPath: resolved.path } : {}, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _builderreact.BuilderPageView, { page: resolved.page }) });
324
+ if (options.siteJsonLd === false || resolved.path !== "/") return view;
325
+ const bundle = await _chunkJ2IHOBDXcjs.getBundle.call(void 0, { client: _chunkJ2IHOBDXcjs.clientOf.call(void 0, options), locale, slots: options.slots });
326
+ const catalogOn = bundle.site.catalogInstalled !== false;
327
+ const search = { ...DEFAULT_CATALOG_TEMPLATE_PATHS, ...options.catalogRoutes }.search;
328
+ const entries = _chunkJ2IHOBDXcjs.siteJsonLdOf.call(void 0, bundle.site.settings, {
329
+ storeUrl: options.storeUrl,
330
+ mediaOrigin: _nullishCoalesce(options.mediaOrigin, () => ( "")),
331
+ searchPath: catalogOn && search !== void 0 && !search.includes("{") ? search : null
332
+ });
333
+ if (entries.length === 0) return view;
334
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
335
+ entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "script", { type: "application/ld+json", children: _chunkJ2IHOBDXcjs.jsonLdString.call(void 0, entry) }, String(entry["@id"]))),
336
+ view
337
+ ] });
338
+ }
314
339
  case "template":
315
340
  if (resolved.unavailable) {
316
341
  if (options.unavailable === "error") throw new BuilderUnavailablePageError(resolved.name);
317
- _optionalChain([options, 'access', _8 => _8.onUnavailable, 'optionalCall', _9 => _9({
342
+ _optionalChain([options, 'access', _10 => _10.onUnavailable, 'optionalCall', _11 => _11({
318
343
  status: 503,
319
344
  headers: { "Retry-After": String(_nullishCoalesce(options.retryAfterSeconds, () => ( 30))) }
320
345
  })]);
@@ -327,14 +352,14 @@ function createBuilderRoute(options) {
327
352
  }
328
353
  }
329
354
  async function generateMetadata(props) {
330
- const client = _chunkWGBNEYOFcjs.clientOf.call(void 0, options);
355
+ const client = _chunkJ2IHOBDXcjs.clientOf.call(void 0, options);
331
356
  try {
332
357
  const { resolved, params, locale, search } = await request(props);
333
358
  if (resolved.kind === "redirect" || resolved.kind === "notFound") return {};
334
- const bundle = await _chunkWGBNEYOFcjs.getBundle.call(void 0, { client, locale, slots: options.slots });
359
+ const bundle = await _chunkJ2IHOBDXcjs.getBundle.call(void 0, { client, locale, slots: options.slots });
335
360
  const settings = bundle.site.settings;
336
361
  if (resolved.kind === "page") {
337
- const shared = await _chunkWGBNEYOFcjs.getBundle.call(void 0, {
362
+ const shared = await _chunkJ2IHOBDXcjs.getBundle.call(void 0, {
338
363
  client,
339
364
  locale,
340
365
  page: resolved.slug,
@@ -342,7 +367,7 @@ function createBuilderRoute(options) {
342
367
  });
343
368
  const page = shared.page;
344
369
  if (page === void 0 || "redirectTo" in page) return {};
345
- return _chunkWGBNEYOFcjs.metadataOf.call(void 0, page, {
370
+ return _chunkJ2IHOBDXcjs.metadataOf.call(void 0, page, {
346
371
  settings: shared.site.settings,
347
372
  mediaOrigin: _nullishCoalesce(options.mediaOrigin, () => ( "")),
348
373
  storeUrl: options.storeUrl,
@@ -350,7 +375,7 @@ function createBuilderRoute(options) {
350
375
  routeLocale: options.locale === void 0 && typeof params.locale === "string" ? params.locale : void 0
351
376
  });
352
377
  }
353
- return _chunkWGBNEYOFcjs.templateMetadataOf.call(void 0, resolved.name, {
378
+ return _chunkJ2IHOBDXcjs.templateMetadataOf.call(void 0, resolved.name, {
354
379
  settings,
355
380
  storeUrl: options.storeUrl,
356
381
  mediaOrigin: _nullishCoalesce(options.mediaOrigin, () => ( "")),
@@ -382,18 +407,23 @@ async function BuilderTemplate({
382
407
  ...client
383
408
  }) {
384
409
  try {
385
- const { part } = await _chunkWGBNEYOFcjs.loadBuilderTemplate.call(void 0, {
410
+ const { part, meta } = await _chunkJ2IHOBDXcjs.loadBuilderTemplate.call(void 0, {
386
411
  ...client,
387
412
  name,
388
413
  locale,
389
414
  ...packs === void 0 ? {} : { packs }
390
415
  });
391
416
  const templateContext = _nullishCoalesce(context, () => ( { route: { path: "", params: {}, query: {} } }));
392
- const view = _react.createElement.call(void 0, _builderreact.BuilderTemplateView, { name, part, context: templateContext });
393
- const Root = _chunkWGBNEYOFcjs.templateRootOf.call(void 0, packs, name);
417
+ const view = _react.createElement.call(void 0, _builderreact.BuilderTemplateView, {
418
+ name,
419
+ part,
420
+ context: templateContext,
421
+ frame: _optionalChain([meta, 'optionalAccess', _12 => _12.frame])
422
+ });
423
+ const Root = _chunkJ2IHOBDXcjs.templateRootOf.call(void 0, packs, name);
394
424
  return Root === void 0 ? view : _react.createElement.call(void 0, Root, { context: templateContext, document: part.document, children: view });
395
425
  } catch (error) {
396
- if (error instanceof _builder.BuilderUnavailableError || _optionalChain([error, 'optionalAccess', _10 => _10.name]) === "BuilderUnavailableError")
426
+ if (error instanceof _builder.BuilderUnavailableError || _optionalChain([error, 'optionalAccess', _13 => _13.name]) === "BuilderUnavailableError")
397
427
  return null;
398
428
  throw error;
399
429
  }
@@ -423,7 +453,7 @@ function createBuilderPage(options) {
423
453
  const slug = slugOf(options, params);
424
454
  const currency = await currencyOf(options, params);
425
455
  const { currency: _currency, ...rest } = options;
426
- const loaded = await _chunkWGBNEYOFcjs.loadBuilderPage.call(void 0, {
456
+ const loaded = await _chunkJ2IHOBDXcjs.loadBuilderPage.call(void 0, {
427
457
  ...rest,
428
458
  slug,
429
459
  locale: await localeOf(options, params),
@@ -443,12 +473,12 @@ function createBuilderPage(options) {
443
473
  const params = await props.params;
444
474
  const slug = slugOf(options, params);
445
475
  const locale = await localeOf(options, params);
446
- const client = _chunkWGBNEYOFcjs.clientOf.call(void 0, options);
476
+ const client = _chunkJ2IHOBDXcjs.clientOf.call(void 0, options);
447
477
  try {
448
- const bundle = await _chunkWGBNEYOFcjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
478
+ const bundle = await _chunkJ2IHOBDXcjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
449
479
  const page = bundle.page;
450
- if (page === void 0 || _chunkWGBNEYOFcjs.isRedirect.call(void 0, page)) return {};
451
- return _chunkWGBNEYOFcjs.metadataOf.call(void 0, page, {
480
+ if (page === void 0 || _chunkJ2IHOBDXcjs.isRedirect.call(void 0, page)) return {};
481
+ return _chunkJ2IHOBDXcjs.metadataOf.call(void 0, page, {
452
482
  settings: bundle.site.settings,
453
483
  mediaOrigin: _nullishCoalesce(options.mediaOrigin, () => ( "")),
454
484
  storeUrl: options.storeUrl,
@@ -471,4 +501,4 @@ function createBuilderPage(options) {
471
501
 
472
502
 
473
503
 
474
- exports.BuilderTemplate = BuilderTemplate; exports.BuilderUnavailablePageError = BuilderUnavailablePageError; exports.DEFAULT_CATALOG_TEMPLATE_PATHS = DEFAULT_CATALOG_TEMPLATE_PATHS; exports.DEFAULT_STORE_TEMPLATE_PATHS = DEFAULT_STORE_TEMPLATE_PATHS; exports.canonicalFor = _chunkWGBNEYOFcjs.canonicalFor; exports.createBuilderPage = createBuilderPage; exports.createBuilderRoute = createBuilderRoute;
504
+ exports.BuilderTemplate = BuilderTemplate; exports.BuilderUnavailablePageError = BuilderUnavailablePageError; exports.DEFAULT_CATALOG_TEMPLATE_PATHS = DEFAULT_CATALOG_TEMPLATE_PATHS; exports.DEFAULT_STORE_TEMPLATE_PATHS = DEFAULT_STORE_TEMPLATE_PATHS; exports.canonicalFor = _chunkJ2IHOBDXcjs.canonicalFor; exports.createBuilderPage = createBuilderPage; exports.createBuilderRoute = createBuilderRoute;
package/dist/next.d.cts CHANGED
@@ -39,6 +39,11 @@ type CreateBuilderRouteOptions = Omit<BuilderRouteConfig, 'site' | 'loaders'> &
39
39
  storeUrl?: string;
40
40
  mediaOrigin?: string;
41
41
  pagePath?: PagePathResolver;
42
+ /**
43
+ * Emit the site-level JSON-LD (Organization, WebSite, LocalBusiness; each only when its `seo.structuredData` switch
44
+ * is on) on the home page. Default true; pass `false` when the store already emits its own.
45
+ */
46
+ siteJsonLd?: boolean;
42
47
  /** Seconds in the `Retry-After` of an unavailable template. Default 30. */
43
48
  retryAfterSeconds?: number;
44
49
  /**
@@ -89,7 +94,8 @@ type BuilderTemplateProps = ClientOptions & {
89
94
  /**
90
95
  * A published template drawn on its own: `app/(store)/not-found.tsx` is `<BuilderTemplate name="not-found" ... />`, which
91
96
  * Next renders inside the layout, so the header and footer stay around it. A template that cannot be read draws
92
- * nothing rather than failing the 404 (the layout's parts still render).
97
+ * nothing rather than failing the 404 (the layout's parts still render). A template whose meta has `frame: 'none'`
98
+ * hides those parts with CSS (the layout draws them, so they stay in the HTML).
93
99
  */
94
100
  declare function BuilderTemplate({ name, packs, locale, context, ...client }: BuilderTemplateProps): Promise<ReactNode>;
95
101
 
package/dist/next.d.ts CHANGED
@@ -39,6 +39,11 @@ type CreateBuilderRouteOptions = Omit<BuilderRouteConfig, 'site' | 'loaders'> &
39
39
  storeUrl?: string;
40
40
  mediaOrigin?: string;
41
41
  pagePath?: PagePathResolver;
42
+ /**
43
+ * Emit the site-level JSON-LD (Organization, WebSite, LocalBusiness; each only when its `seo.structuredData` switch
44
+ * is on) on the home page. Default true; pass `false` when the store already emits its own.
45
+ */
46
+ siteJsonLd?: boolean;
42
47
  /** Seconds in the `Retry-After` of an unavailable template. Default 30. */
43
48
  retryAfterSeconds?: number;
44
49
  /**
@@ -89,7 +94,8 @@ type BuilderTemplateProps = ClientOptions & {
89
94
  /**
90
95
  * A published template drawn on its own: `app/(store)/not-found.tsx` is `<BuilderTemplate name="not-found" ... />`, which
91
96
  * Next renders inside the layout, so the header and footer stay around it. A template that cannot be read draws
92
- * nothing rather than failing the 404 (the layout's parts still render).
97
+ * nothing rather than failing the 404 (the layout's parts still render). A template whose meta has `frame: 'none'`
98
+ * hides those parts with CSS (the layout draws them, so they stay in the HTML).
93
99
  */
94
100
  declare function BuilderTemplate({ name, packs, locale, context, ...client }: BuilderTemplateProps): Promise<ReactNode>;
95
101
 
package/dist/next.js CHANGED
@@ -6,13 +6,15 @@ import {
6
6
  getBundle,
7
7
  isOwnPath,
8
8
  isRedirect,
9
+ jsonLdString,
9
10
  loadBuilderPage,
10
11
  loadBuilderPageByPath,
11
12
  loadBuilderTemplate,
12
13
  metadataOf,
14
+ siteJsonLdOf,
13
15
  templateMetadataOf,
14
16
  templateRootOf
15
- } from "./chunk-ULAFEYQV.js";
17
+ } from "./chunk-HE6MD2RZ.js";
16
18
 
17
19
  // src/next/index.ts
18
20
  import { createElement as createElement2 } from "react";
@@ -49,7 +51,7 @@ import {
49
51
  BuilderRouteScope,
50
52
  BuilderTemplateView
51
53
  } from "@usethrottle/builder-react";
52
- import { jsx, jsxs } from "react/jsx-runtime";
54
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
53
55
  var DEFAULT_CATALOG_TEMPLATE_PATHS = {
54
56
  shop: "/shop",
55
57
  collection: "/collections/{handle}",
@@ -297,20 +299,43 @@ function createBuilderRoute(options) {
297
299
  return { resolved, params, locale, search: search === "" ? "" : `?${search}` };
298
300
  }
299
301
  function templateBody(resolved) {
300
- const view = /* @__PURE__ */ jsx(BuilderTemplateView, { name: resolved.name, part: resolved.part, context: resolved.context });
302
+ const view = /* @__PURE__ */ jsx(
303
+ BuilderTemplateView,
304
+ {
305
+ name: resolved.name,
306
+ part: resolved.part,
307
+ context: resolved.context,
308
+ frame: resolved.meta?.frame
309
+ }
310
+ );
301
311
  const Root = templateRootOf(packs, resolved.name);
302
312
  if (Root === void 0) return view;
303
313
  return /* @__PURE__ */ jsx(Root, { context: resolved.context, document: resolved.part.document, children: view });
304
314
  }
305
315
  async function Page(props) {
306
- const { resolved } = await request(props);
316
+ const { resolved, locale } = await request(props);
307
317
  switch (resolved.kind) {
308
318
  case "redirect":
309
319
  return resolved.permanent ? permanentRedirect(resolved.to) : redirect(resolved.to);
310
320
  case "notFound":
311
321
  return notFound();
312
- case "page":
313
- return /* @__PURE__ */ jsx(BuilderRouteScope, { ...resolved.own ? { allowPath: resolved.path } : {}, children: /* @__PURE__ */ jsx(BuilderPageView, { page: resolved.page }) });
322
+ case "page": {
323
+ const view = /* @__PURE__ */ jsx(BuilderRouteScope, { ...resolved.own ? { allowPath: resolved.path } : {}, children: /* @__PURE__ */ jsx(BuilderPageView, { page: resolved.page }) });
324
+ if (options.siteJsonLd === false || resolved.path !== "/") return view;
325
+ const bundle = await getBundle({ client: clientOf(options), locale, slots: options.slots });
326
+ const catalogOn = bundle.site.catalogInstalled !== false;
327
+ const search = { ...DEFAULT_CATALOG_TEMPLATE_PATHS, ...options.catalogRoutes }.search;
328
+ const entries = siteJsonLdOf(bundle.site.settings, {
329
+ storeUrl: options.storeUrl,
330
+ mediaOrigin: options.mediaOrigin ?? "",
331
+ searchPath: catalogOn && search !== void 0 && !search.includes("{") ? search : null
332
+ });
333
+ if (entries.length === 0) return view;
334
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
335
+ entries.map((entry) => /* @__PURE__ */ jsx("script", { type: "application/ld+json", children: jsonLdString(entry) }, String(entry["@id"]))),
336
+ view
337
+ ] });
338
+ }
314
339
  case "template":
315
340
  if (resolved.unavailable) {
316
341
  if (options.unavailable === "error") throw new BuilderUnavailablePageError(resolved.name);
@@ -382,14 +407,19 @@ async function BuilderTemplate({
382
407
  ...client
383
408
  }) {
384
409
  try {
385
- const { part } = await loadBuilderTemplate({
410
+ const { part, meta } = await loadBuilderTemplate({
386
411
  ...client,
387
412
  name,
388
413
  locale,
389
414
  ...packs === void 0 ? {} : { packs }
390
415
  });
391
416
  const templateContext = context ?? { route: { path: "", params: {}, query: {} } };
392
- const view = createElement(BuilderTemplateView2, { name, part, context: templateContext });
417
+ const view = createElement(BuilderTemplateView2, {
418
+ name,
419
+ part,
420
+ context: templateContext,
421
+ frame: meta?.frame
422
+ });
393
423
  const Root = templateRootOf(packs, name);
394
424
  return Root === void 0 ? view : createElement(Root, { context: templateContext, document: part.document, children: view });
395
425
  } catch (error) {
package/dist/server.cjs CHANGED
@@ -22,7 +22,8 @@
22
22
 
23
23
 
24
24
 
25
- var _chunkWGBNEYOFcjs = require('./chunk-WGBNEYOF.cjs');
25
+
26
+ var _chunkJ2IHOBDXcjs = require('./chunk-J2IHOBDX.cjs');
26
27
 
27
28
  // src/server/load-site.ts
28
29
  var _builder = require('@usethrottle/builder');
@@ -32,23 +33,23 @@ function siteThemeOf(site) {
32
33
  }
33
34
  async function loadSite(options) {
34
35
  const { locale, slots = [], packs = [], page, mediaOrigin = "", currency } = options;
35
- const client = _chunkWGBNEYOFcjs.clientOf.call(void 0, options);
36
+ const client = _chunkJ2IHOBDXcjs.clientOf.call(void 0, options);
36
37
  let bundle;
37
38
  try {
38
- bundle = await _chunkWGBNEYOFcjs.getBundle.call(void 0, { client, locale, slots, page });
39
+ bundle = await _chunkJ2IHOBDXcjs.getBundle.call(void 0, { client, locale, slots, page });
39
40
  } catch (error) {
40
41
  if (!(error instanceof _builder.BuilderUnavailableError) || client.mode === "build") throw error;
41
- _chunkWGBNEYOFcjs.warnOnce.call(void 0, "site-unavailable", `The Builder could not be read (${error.reason}); the store renders without its Builder header, footer and slots`);
42
+ _chunkJ2IHOBDXcjs.warnOnce.call(void 0, "site-unavailable", `The Builder could not be read (${error.reason}); the store renders without its Builder header, footer and slots`);
42
43
  return { status: "unavailable", locale };
43
44
  }
44
- const registry = _chunkWGBNEYOFcjs.createRendererRegistry.call(void 0, packs);
45
+ const registry = _chunkJ2IHOBDXcjs.createRendererRegistry.call(void 0, packs);
45
46
  const names = Object.keys(bundle.slots);
46
47
  const withShared = (loaded) => ({
47
48
  ...loaded,
48
49
  ...(_nullishCoalesce(loaded.savedSections, () => ( bundle.savedSections))) === void 0 ? {} : { savedSections: _nullishCoalesce(loaded.savedSections, () => ( bundle.savedSections)) }
49
50
  });
50
51
  const documents = [bundle.header, bundle.footer, ...names.map((n) => bundle.slots[n])].map(withShared);
51
- const data = await _chunkWGBNEYOFcjs.staticDataFor.call(void 0, documents, registry, locale, currency);
52
+ const data = await _chunkJ2IHOBDXcjs.staticDataFor.call(void 0, documents, registry, locale, currency);
52
53
  return {
53
54
  status: "ok",
54
55
  locale,
@@ -58,9 +59,9 @@ async function loadSite(options) {
58
59
  mediaOrigin,
59
60
  settings: bundle.site.settings,
60
61
  ...siteThemeOf(bundle.site),
61
- header: _chunkWGBNEYOFcjs.partOf.call(void 0, bundle.header, data, bundle),
62
- footer: _chunkWGBNEYOFcjs.partOf.call(void 0, bundle.footer, data, bundle),
63
- slots: Object.fromEntries(names.map((name) => [name, _chunkWGBNEYOFcjs.partOf.call(void 0, bundle.slots[name], data, bundle)]))
62
+ header: _chunkJ2IHOBDXcjs.partOf.call(void 0, bundle.header, data, bundle),
63
+ footer: _chunkJ2IHOBDXcjs.partOf.call(void 0, bundle.footer, data, bundle),
64
+ slots: Object.fromEntries(names.map((name) => [name, _chunkJ2IHOBDXcjs.partOf.call(void 0, bundle.slots[name], data, bundle)]))
64
65
  };
65
66
  }
66
67
 
@@ -98,7 +99,7 @@ var pathnameOf = (url) => {
98
99
  }
99
100
  };
100
101
  async function builderSitemapParts(options, extras = {}) {
101
- const origin = _chunkWGBNEYOFcjs.originOf.call(void 0, options.storeUrl);
102
+ const origin = _chunkJ2IHOBDXcjs.originOf.call(void 0, options.storeUrl);
102
103
  const entries = await pageEntries(options, origin);
103
104
  if (origin === void 0) return { parts: [] };
104
105
  const rules = sitemapRulesOf(await settingsOf(options));
@@ -114,7 +115,7 @@ async function builderSitemapParts(options, extras = {}) {
114
115
  entries.push({ url: loc, ...when === void 0 || Number.isNaN(when.getTime()) ? {} : { lastModified: when } });
115
116
  }
116
117
  } catch (error) {
117
- _chunkWGBNEYOFcjs.warnOnce.call(void 0, "sitemap-contributor", `A sitemap contributor failed (${error instanceof Error ? error.message : "unknown error"}); the sitemap leaves out its URLs`);
118
+ _chunkJ2IHOBDXcjs.warnOnce.call(void 0, "sitemap-contributor", `A sitemap contributor failed (${error instanceof Error ? error.message : "unknown error"}); the sitemap leaves out its URLs`);
118
119
  }
119
120
  }
120
121
  const parts = [];
@@ -128,19 +129,19 @@ async function builderSitemap(options, extras = {}) {
128
129
  }
129
130
  async function settingsOf(options) {
130
131
  try {
131
- return (await _chunkWGBNEYOFcjs.clientOf.call(void 0, options).site({ locale: _nullishCoalesce(options.locale, () => ( "en")) })).settings;
132
+ return (await _chunkJ2IHOBDXcjs.clientOf.call(void 0, options).site({ locale: _nullishCoalesce(options.locale, () => ( "en")) })).settings;
132
133
  } catch (e3) {
133
134
  return {};
134
135
  }
135
136
  }
136
137
  async function pageEntries(options, origin) {
137
138
  if (options.client === void 0 && (options.builderKey === void 0 || options.builderKey === "")) {
138
- _chunkWGBNEYOFcjs.warnOnce.call(void 0, "sitemap-no-key", "builderSitemap has no builderKey (is THROTTLE_BUILDER_KEY set?); the sitemap leaves out the Builder pages");
139
+ _chunkJ2IHOBDXcjs.warnOnce.call(void 0, "sitemap-no-key", "builderSitemap has no builderKey (is THROTTLE_BUILDER_KEY set?); the sitemap leaves out the Builder pages");
139
140
  return [];
140
141
  }
141
- const client = _chunkWGBNEYOFcjs.clientOf.call(void 0, options);
142
+ const client = _chunkJ2IHOBDXcjs.clientOf.call(void 0, options);
142
143
  if (origin === void 0) {
143
- _chunkWGBNEYOFcjs.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.");
144
+ _chunkJ2IHOBDXcjs.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.");
144
145
  return [];
145
146
  }
146
147
  const locale = _nullishCoalesce(options.locale, () => ( "en"));
@@ -150,19 +151,19 @@ async function pageEntries(options, origin) {
150
151
  const rules = sitemapRulesOf(settings);
151
152
  if (!rules.pages) return [];
152
153
  const indexable = await withoutNoindex(client, pages, locale);
153
- const { list } = _chunkWGBNEYOFcjs.siteLocales.call(void 0, settings);
154
+ const { list } = _chunkJ2IHOBDXcjs.siteLocales.call(void 0, settings);
154
155
  const prefixes = options.localeRoute !== true ? [void 0] : list.length > 0 ? list : [locale];
155
156
  return indexable.flatMap((page) => {
156
- const path = _chunkWGBNEYOFcjs.pagePathOf.call(void 0, settings, page, options.pagePath);
157
+ const path = _chunkJ2IHOBDXcjs.pagePathOf.call(void 0, settings, page, options.pagePath);
157
158
  if (path === null || excluded(rules.exclude, path, page.slug)) return [];
158
159
  return prefixes.flatMap((prefix) => {
159
- const url = safeLoc(`${origin}${_chunkWGBNEYOFcjs.localized.call(void 0, path, prefix)}`, origin);
160
+ const url = safeLoc(`${origin}${_chunkJ2IHOBDXcjs.localized.call(void 0, path, prefix)}`, origin);
160
161
  return url === null ? [] : [{ url, lastModified: new Date(page.updatedAt) }];
161
162
  });
162
163
  });
163
164
  } catch (error) {
164
165
  if (!(error instanceof _builder.BuilderUnavailableError) || client.mode === "build") throw error;
165
- _chunkWGBNEYOFcjs.warnOnce.call(void 0, "sitemap-unavailable", `The Builder could not be read (${error.reason}); the sitemap leaves out its pages`);
166
+ _chunkJ2IHOBDXcjs.warnOnce.call(void 0, "sitemap-unavailable", `The Builder could not be read (${error.reason}); the sitemap leaves out its pages`);
166
167
  return [];
167
168
  }
168
169
  }
@@ -176,14 +177,14 @@ async function withoutNoindex(client, pages, locale) {
176
177
  slice.map(
177
178
  (page) => client.pages.get(page.slug, { locale }).catch((error) => {
178
179
  if (error instanceof _builder.BuilderNotFoundError) return "gone";
179
- _chunkWGBNEYOFcjs.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`);
180
+ _chunkJ2IHOBDXcjs.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`);
180
181
  return void 0;
181
182
  })
182
183
  )
183
184
  );
184
185
  slice.forEach((page, index) => {
185
186
  const answer = answers[index];
186
- if (answer === "gone" || answer !== void 0 && (_chunkWGBNEYOFcjs.isRedirect.call(void 0, answer) || _chunkWGBNEYOFcjs.pageSeoOf.call(void 0, answer).noindex)) skip.add(page.slug);
187
+ if (answer === "gone" || answer !== void 0 && (_chunkJ2IHOBDXcjs.isRedirect.call(void 0, answer) || _chunkJ2IHOBDXcjs.pageSeoOf.call(void 0, answer).noindex)) skip.add(page.slug);
187
188
  });
188
189
  }
189
190
  return pages.filter((page) => !skip.has(page.slug));
@@ -232,7 +233,7 @@ var validDisallow = (value) => validLine(value) && value.trim() !== "/";
232
233
  function siteOriginOf(site, options = {}) {
233
234
  const settings = _nullishCoalesce(site.settings, () => ( {}));
234
235
  const seo = isRec2(settings.seo) ? settings.seo : {};
235
- return _nullishCoalesce(_nullishCoalesce(_chunkWGBNEYOFcjs.originOf.call(void 0, typeof seo.canonicalBase === "string" ? seo.canonicalBase : void 0), () => ( _chunkWGBNEYOFcjs.originOf.call(void 0, options.storeUrl))), () => ( _chunkWGBNEYOFcjs.originOf.call(void 0, typeof settings.storeUrl === "string" ? settings.storeUrl : void 0)));
236
+ return _nullishCoalesce(_nullishCoalesce(_chunkJ2IHOBDXcjs.originOf.call(void 0, typeof seo.canonicalBase === "string" ? seo.canonicalBase : void 0), () => ( _chunkJ2IHOBDXcjs.originOf.call(void 0, options.storeUrl))), () => ( _chunkJ2IHOBDXcjs.originOf.call(void 0, typeof settings.storeUrl === "string" ? settings.storeUrl : void 0)));
236
237
  }
237
238
  function builderRobots(site, options = {}) {
238
239
  const settings = _nullishCoalesce(site.settings, () => ( {}));
@@ -257,7 +258,7 @@ function builderRobotsResponse(site, options = {}) {
257
258
 
258
259
  // src/server/static-params.ts
259
260
  async function builderStaticParams(options) {
260
- const client = _chunkWGBNEYOFcjs.clientOf.call(void 0, options);
261
+ const client = _chunkJ2IHOBDXcjs.clientOf.call(void 0, options);
261
262
  if (client.mode !== "build")
262
263
  throw new TypeError(
263
264
  'builderStaticParams generates every page of a frozen release: give it a client made with createBuilderClient({ mode: "build" }). A live store keeps its pages dynamic.'
@@ -292,4 +293,5 @@ async function builderStaticParams(options) {
292
293
 
293
294
 
294
295
 
295
- exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.DEFAULT_ROBOTS_DISALLOW = DEFAULT_ROBOTS_DISALLOW; exports.SITEMAP_MAX_URLS = SITEMAP_MAX_URLS; exports.breadcrumbJsonLd = _chunkWGBNEYOFcjs.breadcrumbJsonLd; exports.builderRobots = builderRobots; exports.builderRobotsResponse = builderRobotsResponse; exports.builderSitemap = builderSitemap; exports.builderSitemapParts = builderSitemapParts; exports.builderStaticParams = builderStaticParams; exports.faqJsonLd = _chunkWGBNEYOFcjs.faqJsonLd; exports.getBundle = _chunkWGBNEYOFcjs.getBundle; exports.isOwnPath = _chunkWGBNEYOFcjs.isOwnPath; exports.jsonLdString = _chunkWGBNEYOFcjs.jsonLdString; exports.loadBuilderPage = _chunkWGBNEYOFcjs.loadBuilderPage; exports.loadBuilderPageByPath = _chunkWGBNEYOFcjs.loadBuilderPageByPath; exports.loadBuilderTemplate = _chunkWGBNEYOFcjs.loadBuilderTemplate; exports.loadOwnPagePaths = _chunkWGBNEYOFcjs.loadOwnPagePaths; exports.loadSite = loadSite; exports.localBusinessJsonLd = _chunkWGBNEYOFcjs.localBusinessJsonLd; exports.organizationJsonLd = _chunkWGBNEYOFcjs.organizationJsonLd; exports.siteOriginOf = siteOriginOf; exports.webSiteJsonLd = _chunkWGBNEYOFcjs.webSiteJsonLd;
296
+
297
+ exports.BuilderNotFoundError = _builder.BuilderNotFoundError; exports.BuilderUnavailableError = _builder.BuilderUnavailableError; exports.DEFAULT_ROBOTS_DISALLOW = DEFAULT_ROBOTS_DISALLOW; exports.SITEMAP_MAX_URLS = SITEMAP_MAX_URLS; exports.breadcrumbJsonLd = _chunkJ2IHOBDXcjs.breadcrumbJsonLd; exports.builderRobots = builderRobots; exports.builderRobotsResponse = builderRobotsResponse; exports.builderSitemap = builderSitemap; exports.builderSitemapParts = builderSitemapParts; exports.builderStaticParams = builderStaticParams; exports.faqJsonLd = _chunkJ2IHOBDXcjs.faqJsonLd; exports.getBundle = _chunkJ2IHOBDXcjs.getBundle; exports.isOwnPath = _chunkJ2IHOBDXcjs.isOwnPath; exports.jsonLdString = _chunkJ2IHOBDXcjs.jsonLdString; exports.loadBuilderPage = _chunkJ2IHOBDXcjs.loadBuilderPage; exports.loadBuilderPageByPath = _chunkJ2IHOBDXcjs.loadBuilderPageByPath; exports.loadBuilderTemplate = _chunkJ2IHOBDXcjs.loadBuilderTemplate; exports.loadOwnPagePaths = _chunkJ2IHOBDXcjs.loadOwnPagePaths; exports.loadSite = loadSite; exports.localBusinessJsonLd = _chunkJ2IHOBDXcjs.localBusinessJsonLd; exports.organizationJsonLd = _chunkJ2IHOBDXcjs.organizationJsonLd; exports.siteOriginOf = siteOriginOf; exports.videoJsonLd = _chunkJ2IHOBDXcjs.videoJsonLd; exports.webSiteJsonLd = _chunkJ2IHOBDXcjs.webSiteJsonLd;