@usethrottle/builder-react 0.0.0-stage → 0.2.0

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 ADDED
@@ -0,0 +1,93 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkS2XR224Acjs = require('./chunk-S2XR224A.cjs');
8
+
9
+ // src/next/index.ts
10
+ var _react = require('react');
11
+ var _navigation = require('next/navigation');
12
+ var _builder = require('@usethrottle/builder');
13
+ var _builderreact = require('@usethrottle/builder-react');
14
+
15
+ // src/safe-path.ts
16
+ var _builderschema = require('@usethrottle/builder-schema');
17
+ var UNSAFE = /[\x00-\x20\x7f-\xa0\\\u1680\u2000-\u200f\u2028\u2029\u202f\u205f\u3000\ufeff]/;
18
+ var LEADING = /^\/(?![/\\])/;
19
+ function plainPath(path) {
20
+ return !UNSAFE.test(path) && (path === "/" || LEADING.test(path));
21
+ }
22
+ function sitePath(to) {
23
+ if (typeof to !== "string" || !plainPath(to)) return null;
24
+ let decoded;
25
+ try {
26
+ decoded = decodeURIComponent(to);
27
+ } catch (e) {
28
+ return null;
29
+ }
30
+ if (!plainPath(decoded)) return null;
31
+ return _builderschema.safeUrl.call(void 0, to, "href", { mediaOrigin: "" });
32
+ }
33
+
34
+ // src/next/index.ts
35
+ function slugOf(options, params) {
36
+ if ("slug" in options) return options.slug;
37
+ const value = params[options.fromParams];
38
+ const slug = Array.isArray(value) ? value.join("/") : value;
39
+ if (slug === void 0 || slug === "") _navigation.notFound.call(void 0, );
40
+ return slug;
41
+ }
42
+ async function localeOf(options, params) {
43
+ if (typeof options.locale === "function") return options.locale(params);
44
+ if (options.locale !== void 0) return options.locale;
45
+ const fromRoute = params.locale;
46
+ return typeof fromRoute === "string" ? fromRoute : "en";
47
+ }
48
+ function createBuilderPage(options) {
49
+ async function Page(props) {
50
+ const params = await props.params;
51
+ const slug = slugOf(options, params);
52
+ const loaded = await _chunkS2XR224Acjs.loadBuilderPage.call(void 0, {
53
+ ...options,
54
+ slug,
55
+ locale: await localeOf(options, params)
56
+ }).catch((error) => {
57
+ if (error instanceof _builder.BuilderNotFoundError) _navigation.notFound.call(void 0, );
58
+ throw error;
59
+ });
60
+ if (loaded.kind === "redirect") {
61
+ const path = sitePath(loaded.redirectTo);
62
+ if (path === null) _navigation.notFound.call(void 0, );
63
+ _navigation.permanentRedirect.call(void 0, path);
64
+ }
65
+ return _react.createElement.call(void 0, _builderreact.BuilderPageView, { page: loaded });
66
+ }
67
+ async function generateMetadata(props) {
68
+ const params = await props.params;
69
+ const slug = slugOf(options, params);
70
+ const locale = await localeOf(options, params);
71
+ const client = _chunkS2XR224Acjs.clientOf.call(void 0, options);
72
+ try {
73
+ const bundle = await _chunkS2XR224Acjs.getBundle.call(void 0, { client, locale, page: slug, slots: options.slots });
74
+ const page = bundle.page;
75
+ if (page === void 0 || _chunkS2XR224Acjs.isRedirect.call(void 0, page)) return {};
76
+ return _chunkS2XR224Acjs.metadataOf.call(void 0, page, {
77
+ settings: bundle.site.settings,
78
+ mediaOrigin: _nullishCoalesce(options.mediaOrigin, () => ( "")),
79
+ storeUrl: options.storeUrl,
80
+ pagePath: options.pagePath,
81
+ routeLocale: options.locale === void 0 && typeof params.locale === "string" ? params.locale : void 0
82
+ });
83
+ } catch (error) {
84
+ if (error instanceof _builder.BuilderNotFoundError) return {};
85
+ if (error instanceof _builder.BuilderUnavailableError && client.mode !== "build") return {};
86
+ throw error;
87
+ }
88
+ }
89
+ return { Page, generateMetadata };
90
+ }
91
+
92
+
93
+ exports.createBuilderPage = createBuilderPage;
@@ -0,0 +1,52 @@
1
+ import { ReactNode } from 'react';
2
+ import { Metadata } from 'next';
3
+ import { C as ClientOptions, W as WidgetPack, P as PagePathResolver } from './seo-Dz439Jlk.cjs';
4
+ import '@usethrottle/builder-schema';
5
+ import '@usethrottle/builder';
6
+
7
+ type Params = Record<string, string | string[] | undefined>;
8
+ type CreateBuilderPageOptions = ({
9
+ slug: string;
10
+ } | {
11
+ fromParams: string;
12
+ }) & ClientOptions & {
13
+ packs?: readonly WidgetPack[];
14
+ /** The locale of the page; by default `params.locale` when the route has one, else `en`. */
15
+ locale?: string | ((params: Params) => string | Promise<string>);
16
+ /** The slots the layout reads, so the page read can share the layout's. */
17
+ slots?: readonly string[];
18
+ /** The store's origin (`https://shop.example.com`), for the canonical link. The Builder does not publish it, so without it a page has no canonical. */
19
+ storeUrl?: string;
20
+ /** The origin of the store's media, as for `loadSite({ mediaOrigin })`. A share image on any other origin is left out. */
21
+ mediaOrigin?: string;
22
+ /**
23
+ * Where your store serves a page, for the canonical link. By default the site's page route with the slug
24
+ * (`/pages/home` for the home page). A store that serves its home page at `/` says so:
25
+ * `pagePath: (page) => (page.pageType === 'home' ? '/' : page.path)`. `path` is the default. An invalid
26
+ * answer (not a path on this site) is ignored. Pass the same function to `builderSitemap`.
27
+ */
28
+ pagePath?: PagePathResolver;
29
+ };
30
+ type PageProps = {
31
+ params: Promise<Params> | Params;
32
+ };
33
+ /**
34
+ * The route of a Builder page, for `app/pages/[handle]/page.tsx`:
35
+ *
36
+ * ```ts
37
+ * const { Page, generateMetadata } = createBuilderPage({ fromParams: 'handle', packs, builderKey });
38
+ * export default Page;
39
+ * export { generateMetadata };
40
+ * ```
41
+ *
42
+ * `Page` reads the page, answers `notFound()` for an unpublished one and a
43
+ * permanent redirect for a renamed slug, and lets `BuilderUnavailableError`
44
+ * reach the store's error boundary. It renders through `BuilderProvider`, so the
45
+ * route needs one above it (the layout has it).
46
+ */
47
+ declare function createBuilderPage(options: CreateBuilderPageOptions): {
48
+ Page: (props: PageProps) => Promise<ReactNode>;
49
+ generateMetadata: (props: PageProps) => Promise<Metadata>;
50
+ };
51
+
52
+ export { type CreateBuilderPageOptions, createBuilderPage };
package/dist/next.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ import { ReactNode } from 'react';
2
+ import { Metadata } from 'next';
3
+ import { C as ClientOptions, W as WidgetPack, P as PagePathResolver } from './seo-Dz439Jlk.js';
4
+ import '@usethrottle/builder-schema';
5
+ import '@usethrottle/builder';
6
+
7
+ type Params = Record<string, string | string[] | undefined>;
8
+ type CreateBuilderPageOptions = ({
9
+ slug: string;
10
+ } | {
11
+ fromParams: string;
12
+ }) & ClientOptions & {
13
+ packs?: readonly WidgetPack[];
14
+ /** The locale of the page; by default `params.locale` when the route has one, else `en`. */
15
+ locale?: string | ((params: Params) => string | Promise<string>);
16
+ /** The slots the layout reads, so the page read can share the layout's. */
17
+ slots?: readonly string[];
18
+ /** The store's origin (`https://shop.example.com`), for the canonical link. The Builder does not publish it, so without it a page has no canonical. */
19
+ storeUrl?: string;
20
+ /** The origin of the store's media, as for `loadSite({ mediaOrigin })`. A share image on any other origin is left out. */
21
+ mediaOrigin?: string;
22
+ /**
23
+ * Where your store serves a page, for the canonical link. By default the site's page route with the slug
24
+ * (`/pages/home` for the home page). A store that serves its home page at `/` says so:
25
+ * `pagePath: (page) => (page.pageType === 'home' ? '/' : page.path)`. `path` is the default. An invalid
26
+ * answer (not a path on this site) is ignored. Pass the same function to `builderSitemap`.
27
+ */
28
+ pagePath?: PagePathResolver;
29
+ };
30
+ type PageProps = {
31
+ params: Promise<Params> | Params;
32
+ };
33
+ /**
34
+ * The route of a Builder page, for `app/pages/[handle]/page.tsx`:
35
+ *
36
+ * ```ts
37
+ * const { Page, generateMetadata } = createBuilderPage({ fromParams: 'handle', packs, builderKey });
38
+ * export default Page;
39
+ * export { generateMetadata };
40
+ * ```
41
+ *
42
+ * `Page` reads the page, answers `notFound()` for an unpublished one and a
43
+ * permanent redirect for a renamed slug, and lets `BuilderUnavailableError`
44
+ * reach the store's error boundary. It renders through `BuilderProvider`, so the
45
+ * route needs one above it (the layout has it).
46
+ */
47
+ declare function createBuilderPage(options: CreateBuilderPageOptions): {
48
+ Page: (props: PageProps) => Promise<ReactNode>;
49
+ generateMetadata: (props: PageProps) => Promise<Metadata>;
50
+ };
51
+
52
+ export { type CreateBuilderPageOptions, createBuilderPage };
package/dist/next.js ADDED
@@ -0,0 +1,93 @@
1
+ import {
2
+ clientOf,
3
+ getBundle,
4
+ isRedirect,
5
+ loadBuilderPage,
6
+ metadataOf
7
+ } from "./chunk-NUE2KNT2.js";
8
+
9
+ // src/next/index.ts
10
+ import { createElement } from "react";
11
+ import { notFound, permanentRedirect } from "next/navigation";
12
+ import { BuilderNotFoundError, BuilderUnavailableError } from "@usethrottle/builder";
13
+ import { BuilderPageView } from "@usethrottle/builder-react";
14
+
15
+ // src/safe-path.ts
16
+ import { safeUrl } from "@usethrottle/builder-schema";
17
+ var UNSAFE = /[\x00-\x20\x7f-\xa0\\\u1680\u2000-\u200f\u2028\u2029\u202f\u205f\u3000\ufeff]/;
18
+ var LEADING = /^\/(?![/\\])/;
19
+ function plainPath(path) {
20
+ return !UNSAFE.test(path) && (path === "/" || LEADING.test(path));
21
+ }
22
+ function sitePath(to) {
23
+ if (typeof to !== "string" || !plainPath(to)) return null;
24
+ let decoded;
25
+ try {
26
+ decoded = decodeURIComponent(to);
27
+ } catch {
28
+ return null;
29
+ }
30
+ if (!plainPath(decoded)) return null;
31
+ return safeUrl(to, "href", { mediaOrigin: "" });
32
+ }
33
+
34
+ // src/next/index.ts
35
+ function slugOf(options, params) {
36
+ if ("slug" in options) return options.slug;
37
+ const value = params[options.fromParams];
38
+ const slug = Array.isArray(value) ? value.join("/") : value;
39
+ if (slug === void 0 || slug === "") notFound();
40
+ return slug;
41
+ }
42
+ async function localeOf(options, params) {
43
+ if (typeof options.locale === "function") return options.locale(params);
44
+ if (options.locale !== void 0) return options.locale;
45
+ const fromRoute = params.locale;
46
+ return typeof fromRoute === "string" ? fromRoute : "en";
47
+ }
48
+ function createBuilderPage(options) {
49
+ async function Page(props) {
50
+ const params = await props.params;
51
+ const slug = slugOf(options, params);
52
+ const loaded = await loadBuilderPage({
53
+ ...options,
54
+ slug,
55
+ locale: await localeOf(options, params)
56
+ }).catch((error) => {
57
+ if (error instanceof BuilderNotFoundError) notFound();
58
+ throw error;
59
+ });
60
+ if (loaded.kind === "redirect") {
61
+ const path = sitePath(loaded.redirectTo);
62
+ if (path === null) notFound();
63
+ permanentRedirect(path);
64
+ }
65
+ return createElement(BuilderPageView, { page: loaded });
66
+ }
67
+ async function generateMetadata(props) {
68
+ const params = await props.params;
69
+ const slug = slugOf(options, params);
70
+ const locale = await localeOf(options, params);
71
+ const client = clientOf(options);
72
+ try {
73
+ const bundle = await getBundle({ client, locale, page: slug, slots: options.slots });
74
+ const page = bundle.page;
75
+ if (page === void 0 || isRedirect(page)) return {};
76
+ return metadataOf(page, {
77
+ settings: bundle.site.settings,
78
+ mediaOrigin: options.mediaOrigin ?? "",
79
+ storeUrl: options.storeUrl,
80
+ pagePath: options.pagePath,
81
+ routeLocale: options.locale === void 0 && typeof params.locale === "string" ? params.locale : void 0
82
+ });
83
+ } catch (error) {
84
+ if (error instanceof BuilderNotFoundError) return {};
85
+ if (error instanceof BuilderUnavailableError && client.mode !== "build") return {};
86
+ throw error;
87
+ }
88
+ }
89
+ return { Page, generateMetadata };
90
+ }
91
+ export {
92
+ createBuilderPage
93
+ };
@@ -0,0 +1,149 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { WidgetDefinition, WidgetNode, SettingValue, DataSourceDescriptor, PageDocument, FrozenAsset } from '@usethrottle/builder-schema';
3
+ import { BuilderClient, BuilderBundle } from '@usethrottle/builder';
4
+
5
+ /** A count of rendered nodes with a ceiling. One per custom widget render. */
6
+ declare class RenderBudget {
7
+ readonly limit: number;
8
+ private spent;
9
+ constructor(limit?: number);
10
+ /** Takes `count` nodes. False, and nothing taken, when that would pass the limit. */
11
+ take(count?: number): boolean;
12
+ get used(): number;
13
+ get exhausted(): boolean;
14
+ }
15
+ /**
16
+ * What a renderer needs of a budget: the public members of `RenderBudget`, not the class. The server entries' type
17
+ * files carry their own copy of the class, and its private field would make a pack made against one copy unusable
18
+ * with the other (`loadSite({ packs })`).
19
+ */
20
+ type Budget = Pick<RenderBudget, 'limit' | 'used' | 'exhausted' | 'take'>;
21
+
22
+ /** Resolved data by binding key (`bindingKey`), plus `context.*` entries a slot supplies. */
23
+ type DataMap = Record<string, unknown>;
24
+ type WidgetRenderProps = {
25
+ node: WidgetNode;
26
+ /** The node's settings at this variant, defaults filled, translatable text resolved, image ids replaced by their frozen asset. */
27
+ props: Record<string, SettingValue>;
28
+ /** Resolved data by the widget's named inputs. Absent until a perShopper source has resolved in the browser. */
29
+ data: Record<string, unknown>;
30
+ editMode: boolean;
31
+ locale: string;
32
+ /** The only origin a media `src` may be on; pass it to `AssetImage`. */
33
+ mediaOrigin: string;
34
+ /** In the editor only: the inline editor of one text setting of this node, or null. */
35
+ inlineEdit?: ((key: string) => ReactNode | null) | undefined;
36
+ /** The href of a link target (page, catalog kinds), or null. Callers still check the result with `safeUrl`. */
37
+ resolveLink?: ((target: {
38
+ kind: string;
39
+ [key: string]: unknown;
40
+ }) => string | null) | undefined;
41
+ /** Custom widgets only: the node budget of this render (`MAX_RENDERED_NODES`). */
42
+ budget?: Budget | undefined;
43
+ };
44
+ type ResolveContext = {
45
+ locale: string;
46
+ /** The store's main currency, when the site knows it. Never defaulted here. */
47
+ currency?: string | undefined;
48
+ preview: boolean;
49
+ /** The slot context (`{ product }` or `{ listing }`) for `context.*` bindings. */
50
+ context?: unknown;
51
+ signal: AbortSignal;
52
+ };
53
+ type DataSourceResolver = (params: Record<string, SettingValue>, ctx: ResolveContext) => Promise<unknown>;
54
+ type PackDataSource = DataSourceDescriptor & {
55
+ resolve: DataSourceResolver;
56
+ };
57
+ type PackWidget = WidgetDefinition & {
58
+ Component: ComponentType<WidgetRenderProps>;
59
+ };
60
+ /** The pickers and href resolution of a pack's link targets (catalog: category, collection, product, search). */
61
+ type LinkTargetProvider = {
62
+ /** The href of a menu target the pack owns, or null when it cannot resolve one. */
63
+ resolve(target: {
64
+ kind: string;
65
+ [key: string]: unknown;
66
+ }): string | null;
67
+ };
68
+ type SlotPoint = {
69
+ name: string;
70
+ context: 'product' | 'listing' | 'none';
71
+ };
72
+ /** A set of widgets and data sources (spec §9.4). `basic` ships with this package. */
73
+ type WidgetPack = {
74
+ id: string;
75
+ /** The npm version that ships it. */
76
+ version: string;
77
+ widgets: PackWidget[];
78
+ dataSources: PackDataSource[];
79
+ linkTargets?: LinkTargetProvider;
80
+ slots?: SlotPoint[];
81
+ };
82
+ /** A page document as the store reads it (a published snapshot). */
83
+ type PageAssets = Record<string, FrozenAsset>;
84
+ type LoadedPage = {
85
+ kind: 'page';
86
+ slug: string;
87
+ title: string;
88
+ path: string;
89
+ generation: number;
90
+ document: PageDocument;
91
+ assets: PageAssets;
92
+ /** Data of every non-perShopper binding, resolved on the server. Never holds perShopper data. */
93
+ initialData: DataMap;
94
+ /** The page's other fields as the read API sent them (seo, description, ...). */
95
+ meta: Record<string, unknown>;
96
+ };
97
+ type LoadedRedirect = {
98
+ kind: 'redirect';
99
+ redirectTo: string;
100
+ };
101
+ /** What a site part or a slot holds once the server has read it. */
102
+ type LoadedPart = {
103
+ document: PageDocument;
104
+ assets: PageAssets;
105
+ initialData: DataMap;
106
+ };
107
+ /**
108
+ * The store's site design, read once per request. `unavailable` means the
109
+ * Builder could not answer and there is no last good answer: every part then
110
+ * renders nothing (ruling R8) and the catalog's own design takes over.
111
+ */
112
+ type LoadedSite = {
113
+ status: 'ok';
114
+ locale: string;
115
+ generation: number;
116
+ siteVersion: number;
117
+ /** The origin media files must be on (https). Images from anywhere else are refused. */
118
+ mediaOrigin: string;
119
+ /** Site settings resolved for the locale (localized values are strings). */
120
+ settings: Record<string, unknown>;
121
+ header: LoadedPart;
122
+ footer: LoadedPart;
123
+ slots: Record<string, LoadedPart>;
124
+ } | {
125
+ status: 'unavailable';
126
+ locale: string;
127
+ };
128
+
129
+ type BundleAsk = {
130
+ client: BuilderClient;
131
+ locale: string;
132
+ page?: string | undefined;
133
+ slots?: readonly string[] | undefined;
134
+ };
135
+ /** The bundle for an ask, shared per request. It rejects exactly as `client.bundle` does. */
136
+ declare function getBundle(ask: BundleAsk): Promise<BuilderBundle>;
137
+ type ClientOptions = {
138
+ client?: BuilderClient | undefined;
139
+ builderKey?: string | undefined;
140
+ };
141
+
142
+ /** A store's own answer for where a page lives: it gets the default and returns a site path (or null for the default). */
143
+ type PagePathResolver = (page: {
144
+ slug: string;
145
+ pageType: string;
146
+ path: string;
147
+ }) => string | null | undefined;
148
+
149
+ export { type BundleAsk as B, type ClientOptions as C, type LoadedPage as L, type PagePathResolver as P, type WidgetPack as W, type LoadedRedirect as a, type LoadedSite as b, getBundle as g };
@@ -0,0 +1,149 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { WidgetDefinition, WidgetNode, SettingValue, DataSourceDescriptor, PageDocument, FrozenAsset } from '@usethrottle/builder-schema';
3
+ import { BuilderClient, BuilderBundle } from '@usethrottle/builder';
4
+
5
+ /** A count of rendered nodes with a ceiling. One per custom widget render. */
6
+ declare class RenderBudget {
7
+ readonly limit: number;
8
+ private spent;
9
+ constructor(limit?: number);
10
+ /** Takes `count` nodes. False, and nothing taken, when that would pass the limit. */
11
+ take(count?: number): boolean;
12
+ get used(): number;
13
+ get exhausted(): boolean;
14
+ }
15
+ /**
16
+ * What a renderer needs of a budget: the public members of `RenderBudget`, not the class. The server entries' type
17
+ * files carry their own copy of the class, and its private field would make a pack made against one copy unusable
18
+ * with the other (`loadSite({ packs })`).
19
+ */
20
+ type Budget = Pick<RenderBudget, 'limit' | 'used' | 'exhausted' | 'take'>;
21
+
22
+ /** Resolved data by binding key (`bindingKey`), plus `context.*` entries a slot supplies. */
23
+ type DataMap = Record<string, unknown>;
24
+ type WidgetRenderProps = {
25
+ node: WidgetNode;
26
+ /** The node's settings at this variant, defaults filled, translatable text resolved, image ids replaced by their frozen asset. */
27
+ props: Record<string, SettingValue>;
28
+ /** Resolved data by the widget's named inputs. Absent until a perShopper source has resolved in the browser. */
29
+ data: Record<string, unknown>;
30
+ editMode: boolean;
31
+ locale: string;
32
+ /** The only origin a media `src` may be on; pass it to `AssetImage`. */
33
+ mediaOrigin: string;
34
+ /** In the editor only: the inline editor of one text setting of this node, or null. */
35
+ inlineEdit?: ((key: string) => ReactNode | null) | undefined;
36
+ /** The href of a link target (page, catalog kinds), or null. Callers still check the result with `safeUrl`. */
37
+ resolveLink?: ((target: {
38
+ kind: string;
39
+ [key: string]: unknown;
40
+ }) => string | null) | undefined;
41
+ /** Custom widgets only: the node budget of this render (`MAX_RENDERED_NODES`). */
42
+ budget?: Budget | undefined;
43
+ };
44
+ type ResolveContext = {
45
+ locale: string;
46
+ /** The store's main currency, when the site knows it. Never defaulted here. */
47
+ currency?: string | undefined;
48
+ preview: boolean;
49
+ /** The slot context (`{ product }` or `{ listing }`) for `context.*` bindings. */
50
+ context?: unknown;
51
+ signal: AbortSignal;
52
+ };
53
+ type DataSourceResolver = (params: Record<string, SettingValue>, ctx: ResolveContext) => Promise<unknown>;
54
+ type PackDataSource = DataSourceDescriptor & {
55
+ resolve: DataSourceResolver;
56
+ };
57
+ type PackWidget = WidgetDefinition & {
58
+ Component: ComponentType<WidgetRenderProps>;
59
+ };
60
+ /** The pickers and href resolution of a pack's link targets (catalog: category, collection, product, search). */
61
+ type LinkTargetProvider = {
62
+ /** The href of a menu target the pack owns, or null when it cannot resolve one. */
63
+ resolve(target: {
64
+ kind: string;
65
+ [key: string]: unknown;
66
+ }): string | null;
67
+ };
68
+ type SlotPoint = {
69
+ name: string;
70
+ context: 'product' | 'listing' | 'none';
71
+ };
72
+ /** A set of widgets and data sources (spec §9.4). `basic` ships with this package. */
73
+ type WidgetPack = {
74
+ id: string;
75
+ /** The npm version that ships it. */
76
+ version: string;
77
+ widgets: PackWidget[];
78
+ dataSources: PackDataSource[];
79
+ linkTargets?: LinkTargetProvider;
80
+ slots?: SlotPoint[];
81
+ };
82
+ /** A page document as the store reads it (a published snapshot). */
83
+ type PageAssets = Record<string, FrozenAsset>;
84
+ type LoadedPage = {
85
+ kind: 'page';
86
+ slug: string;
87
+ title: string;
88
+ path: string;
89
+ generation: number;
90
+ document: PageDocument;
91
+ assets: PageAssets;
92
+ /** Data of every non-perShopper binding, resolved on the server. Never holds perShopper data. */
93
+ initialData: DataMap;
94
+ /** The page's other fields as the read API sent them (seo, description, ...). */
95
+ meta: Record<string, unknown>;
96
+ };
97
+ type LoadedRedirect = {
98
+ kind: 'redirect';
99
+ redirectTo: string;
100
+ };
101
+ /** What a site part or a slot holds once the server has read it. */
102
+ type LoadedPart = {
103
+ document: PageDocument;
104
+ assets: PageAssets;
105
+ initialData: DataMap;
106
+ };
107
+ /**
108
+ * The store's site design, read once per request. `unavailable` means the
109
+ * Builder could not answer and there is no last good answer: every part then
110
+ * renders nothing (ruling R8) and the catalog's own design takes over.
111
+ */
112
+ type LoadedSite = {
113
+ status: 'ok';
114
+ locale: string;
115
+ generation: number;
116
+ siteVersion: number;
117
+ /** The origin media files must be on (https). Images from anywhere else are refused. */
118
+ mediaOrigin: string;
119
+ /** Site settings resolved for the locale (localized values are strings). */
120
+ settings: Record<string, unknown>;
121
+ header: LoadedPart;
122
+ footer: LoadedPart;
123
+ slots: Record<string, LoadedPart>;
124
+ } | {
125
+ status: 'unavailable';
126
+ locale: string;
127
+ };
128
+
129
+ type BundleAsk = {
130
+ client: BuilderClient;
131
+ locale: string;
132
+ page?: string | undefined;
133
+ slots?: readonly string[] | undefined;
134
+ };
135
+ /** The bundle for an ask, shared per request. It rejects exactly as `client.bundle` does. */
136
+ declare function getBundle(ask: BundleAsk): Promise<BuilderBundle>;
137
+ type ClientOptions = {
138
+ client?: BuilderClient | undefined;
139
+ builderKey?: string | undefined;
140
+ };
141
+
142
+ /** A store's own answer for where a page lives: it gets the default and returns a site path (or null for the default). */
143
+ type PagePathResolver = (page: {
144
+ slug: string;
145
+ pageType: string;
146
+ path: string;
147
+ }) => string | null | undefined;
148
+
149
+ export { type BundleAsk as B, type ClientOptions as C, type LoadedPage as L, type PagePathResolver as P, type WidgetPack as W, type LoadedRedirect as a, type LoadedSite as b, getBundle as g };