@usethrottle/builder-react 0.4.2 → 0.5.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/CLAUDE.md +23 -2
- package/dist/{chunk-SYXZO5H2.js → chunk-G6I4RIXU.js} +2109 -332
- package/dist/{chunk-XHTZWZPN.cjs → chunk-UNL4JWZS.cjs} +2003 -226
- package/dist/index.cjs +2301 -605
- package/dist/index.d.cts +245 -62
- package/dist/index.d.ts +245 -62
- package/dist/index.js +2264 -567
- package/dist/next.cjs +383 -13
- package/dist/next.d.cts +92 -3
- package/dist/next.d.ts +92 -3
- package/dist/next.js +385 -15
- package/dist/{seo-CNZ9DrlU.d.cts → seo-iX2POfOp.d.cts} +87 -2
- package/dist/{seo-CNZ9DrlU.d.ts → seo-iX2POfOp.d.ts} +87 -2
- package/dist/server.cjs +191 -24
- package/dist/server.d.cts +172 -8
- package/dist/server.d.ts +172 -8
- package/dist/server.js +174 -7
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TemplateAst, WidgetNode, SettingValue, WidgetDefinition, DataSourceDescriptor, PageDocument, FrozenAsset, SavedSectionsAnswer, CodeRuntimeAnswer, WidgetRegistry, CustomWidgetSnapshot, CodeWidgetSnapshotLive, AnyCustomWidgetSnapshot, SettingField, DataBinding, SavedSectionRefNode } from '@usethrottle/builder-schema';
|
|
1
|
+
import { ComponentType, ReactNode, CSSProperties, Context } from 'react';
|
|
2
|
+
import { TemplateAst, TemplateName, RootNode, StoreRoutes, WidgetNode, SettingValue, WidgetDefinition, DataSourceDescriptor, PageDocument, FrozenAsset, SavedSectionsAnswer, CodeRuntimeAnswer, WidgetRegistry, CustomWidgetSnapshot, CodeWidgetSnapshotLive, AnyCustomWidgetSnapshot, SettingField, DataBinding, SavedSectionRefNode } from '@usethrottle/builder-schema';
|
|
3
3
|
import { BuilderClient } from '@usethrottle/builder';
|
|
4
4
|
export { BuilderNotFoundError, BuilderUnavailableError } from '@usethrottle/builder';
|
|
5
5
|
|
|
@@ -29,6 +29,74 @@ type Budget = Pick<RenderBudget, 'limit' | 'used' | 'exhausted' | 'take'>;
|
|
|
29
29
|
/** True when a template's worst case fits the budget; the interpreter refuses the template otherwise. */
|
|
30
30
|
declare const fitsBudget: (ast: TemplateAst, limit?: number) => boolean;
|
|
31
31
|
|
|
32
|
+
/** The route a template loader serves: the matched path, its dynamic params and the query string. */
|
|
33
|
+
type TemplateRoute = {
|
|
34
|
+
path: string;
|
|
35
|
+
params: Record<string, string>;
|
|
36
|
+
query: Record<string, string | string[]>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* What a template's widgets read (spec §5.1): the loaded catalog or shopper data of the route. Each field
|
|
40
|
+
* is plain data a loader resolved on the server; the owning stream (T-P, T-L, T-A) narrows its own field.
|
|
41
|
+
*/
|
|
42
|
+
type TemplateContext = {
|
|
43
|
+
product?: unknown;
|
|
44
|
+
listing?: unknown;
|
|
45
|
+
cart?: unknown;
|
|
46
|
+
customer?: unknown;
|
|
47
|
+
route: TemplateRoute;
|
|
48
|
+
};
|
|
49
|
+
/** The answer of a template loader. */
|
|
50
|
+
type TemplateLoadResult = {
|
|
51
|
+
status: 'ok';
|
|
52
|
+
context: TemplateContext;
|
|
53
|
+
} | {
|
|
54
|
+
status: 'not-found';
|
|
55
|
+
} | {
|
|
56
|
+
status: 'redirect';
|
|
57
|
+
to: string;
|
|
58
|
+
} | {
|
|
59
|
+
status: 'unavailable';
|
|
60
|
+
};
|
|
61
|
+
/** Reads what one template needs for one request. */
|
|
62
|
+
type TemplateLoader = (args: {
|
|
63
|
+
params: Record<string, string | string[] | undefined>;
|
|
64
|
+
searchParams: Record<string, string | string[] | undefined>;
|
|
65
|
+
route: TemplateRoute;
|
|
66
|
+
}) => Promise<TemplateLoadResult>;
|
|
67
|
+
/** The sections of a document: what `PageDocument.sections` holds. */
|
|
68
|
+
type DocumentNodes = RootNode[];
|
|
69
|
+
/** What a widget pack contributes for one template: its loader and its default composition. */
|
|
70
|
+
type PackTemplateContribution = {
|
|
71
|
+
name: TemplateName;
|
|
72
|
+
loader: TemplateLoader;
|
|
73
|
+
/** The pack's default composition of the template, optionally one of its `variants`. */
|
|
74
|
+
defaultComposition: (variant?: string) => DocumentNodes;
|
|
75
|
+
variants?: string[];
|
|
76
|
+
/**
|
|
77
|
+
* A component the template body is rendered inside, once, for state its widgets share (the product page's selected
|
|
78
|
+
* variant, a listing's filters): `createBuilderRoute` and `BuilderTemplate` draw
|
|
79
|
+
* `<Root context document>{template body}</Root>`, on the server, for the loaded template, its unavailable state
|
|
80
|
+
* and the pack's default composition. `document` is the template's `PageDocument`. A client component reference
|
|
81
|
+
* is fine; it receives plain data only. Without it the body is drawn as it is.
|
|
82
|
+
*/
|
|
83
|
+
Root?: ComponentType<{
|
|
84
|
+
context: TemplateContext;
|
|
85
|
+
document: unknown;
|
|
86
|
+
children: ReactNode;
|
|
87
|
+
}>;
|
|
88
|
+
};
|
|
89
|
+
/** What the store hands the template route (spec §5.1). */
|
|
90
|
+
type BuilderRouteConfig = {
|
|
91
|
+
site: LoadedSite;
|
|
92
|
+
packs: readonly WidgetPack[];
|
|
93
|
+
/** Catalog route prefixes the store serves (`shop`, `collection`, ...), by template name. */
|
|
94
|
+
catalogRoutes?: Partial<Record<TemplateName, string>>;
|
|
95
|
+
/** Paths of the store templates the merchant renamed (`routes.store`). */
|
|
96
|
+
storeRoutes?: Partial<StoreRoutes>;
|
|
97
|
+
loaders: Partial<Record<TemplateName, TemplateLoader>>;
|
|
98
|
+
};
|
|
99
|
+
|
|
32
100
|
/** Resolved data by binding key (`bindingKey`), plus `context.*` entries a slot supplies. */
|
|
33
101
|
type DataMap = Record<string, unknown>;
|
|
34
102
|
type WidgetRenderProps = {
|
|
@@ -101,6 +169,8 @@ type WidgetPack = {
|
|
|
101
169
|
dataSources: PackDataSource[];
|
|
102
170
|
linkTargets?: LinkTargetProvider;
|
|
103
171
|
slots?: SlotPoint[];
|
|
172
|
+
/** The templates the pack contributes: loaders and default compositions (spec §5.1). */
|
|
173
|
+
templates?: PackTemplateContribution[];
|
|
104
174
|
};
|
|
105
175
|
/** A page document as the store reads it (a published snapshot). */
|
|
106
176
|
type PageAssets = Record<string, FrozenAsset>;
|
|
@@ -145,10 +215,19 @@ type LoadedSite = {
|
|
|
145
215
|
locale: string;
|
|
146
216
|
generation: number;
|
|
147
217
|
siteVersion: number;
|
|
218
|
+
/**
|
|
219
|
+
* The instant `loadSite` read the site (ISO 8601, stamped on the server). Time rules (announcement schedules)
|
|
220
|
+
* are evaluated at this instant while rendering, so server HTML and the first client render agree.
|
|
221
|
+
*/
|
|
222
|
+
loadedAt?: string;
|
|
148
223
|
/** The origin media files must be on (https). Images from anywhere else are refused. */
|
|
149
224
|
mediaOrigin: string;
|
|
150
225
|
/** Site settings resolved for the locale (localized values are strings). */
|
|
151
226
|
settings: Record<string, unknown>;
|
|
227
|
+
/** The site answer's `theme` (beside `settings`): `customCssHref` is the Builder's stylesheet for CSS over 4 KB. */
|
|
228
|
+
theme?: {
|
|
229
|
+
customCssHref?: string;
|
|
230
|
+
};
|
|
152
231
|
header: LoadedPart;
|
|
153
232
|
footer: LoadedPart;
|
|
154
233
|
slots: Record<string, LoadedPart>;
|
|
@@ -176,6 +255,8 @@ type NodeWrapperProps = {
|
|
|
176
255
|
type?: string;
|
|
177
256
|
as?: 'div' | 'section';
|
|
178
257
|
className: string;
|
|
258
|
+
/** The node's own class tokens (`cssClass`, spec §11.1): put on the root next to `className`, after being checked again. */
|
|
259
|
+
cssClass?: readonly string[] | undefined;
|
|
179
260
|
anchor?: string | undefined;
|
|
180
261
|
/** The anchor name of a per-device copy: `data-b-anchor`, which the runtime scrolls to when `#name` points at a hidden copy. */
|
|
181
262
|
copyAnchor?: string | undefined;
|
|
@@ -223,6 +304,41 @@ type RendererRegistryOptions = {
|
|
|
223
304
|
/** Builds the registry the renderer reads. The built-in packs come first; a pack cannot replace a built-in type. */
|
|
224
305
|
declare function createRendererRegistry(packs: readonly WidgetPack[], options?: RendererRegistryOptions): RendererRegistry;
|
|
225
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Where a code widget may run (v2 spec, code widgets). The allow-list lives here, in the renderer, and is not a
|
|
309
|
+
* merchant setting: no switch in the dashboard can put a script on a checkout, cart-payment, account or sign-in page.
|
|
310
|
+
*/
|
|
311
|
+
/**
|
|
312
|
+
* 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`
|
|
313
|
+
* tests every segment of the path with it, and the deny wins over every allow rule.
|
|
314
|
+
*/
|
|
315
|
+
declare const CODE_ROUTE_DENY: RegExp;
|
|
316
|
+
/** The catalog templates a store has unless it passes its own (`{name}` is one path segment). */
|
|
317
|
+
declare const DEFAULT_CATALOG_ROUTES: readonly string[];
|
|
318
|
+
/** The path (or path template, `{name}` is one segment) of each template the store serves, by template name. */
|
|
319
|
+
type RouteTable = Partial<Record<TemplateName, string>>;
|
|
320
|
+
/**
|
|
321
|
+
* The route table of a store: its `routes.store` (cart, account, sign-in, ... as the merchant renamed them) over the
|
|
322
|
+
* catalog templates it serves (`product` -> `/p/{handle}` and so on). Entries of `store` win.
|
|
323
|
+
*/
|
|
324
|
+
declare function buildRouteTable(store: Partial<Record<TemplateName, string>> | undefined, catalog?: RouteTable): RouteTable;
|
|
325
|
+
type Routes = {
|
|
326
|
+
page: string;
|
|
327
|
+
catalog?: readonly string[] | undefined;
|
|
328
|
+
routeTable?: RouteTable | undefined;
|
|
329
|
+
/** Paths (or `{handle}` templates) of pages the route resolver serves at their own path (`/about`); the deny rules still win. */
|
|
330
|
+
allow?: readonly string[] | undefined;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Whether code widgets may run on this path. False when the path is unknown; false on the deny list; false when the
|
|
334
|
+
* page's template (`templateName`) is one of `CODE_TEMPLATE_DENY`, or the route table maps the path to one (a renamed
|
|
335
|
+
* `/bag` cart); otherwise true only on `/`, the site's page template and the catalog templates. A segment of the deny
|
|
336
|
+
* list anywhere in the path refuses it (`/fr/checkout`, `/de/account/orders`), whatever the page template is.
|
|
337
|
+
*/
|
|
338
|
+
declare function isCodeRoute(pathname: string | undefined, routes: Routes & {
|
|
339
|
+
templateName?: TemplateName | undefined;
|
|
340
|
+
}): boolean;
|
|
341
|
+
|
|
226
342
|
/** What a render needs to decide whether a code widget runs: the store's code switch and the page it is on. */
|
|
227
343
|
type CodeRender = {
|
|
228
344
|
/** The store's code runtime (`code` of the read answer). Absent: no code. */
|
|
@@ -232,7 +348,10 @@ type CodeRender = {
|
|
|
232
348
|
routes: {
|
|
233
349
|
page: string;
|
|
234
350
|
catalog?: readonly string[] | undefined;
|
|
351
|
+
routeTable?: RouteTable | undefined;
|
|
235
352
|
};
|
|
353
|
+
/** The template this page renders (`product`, `cart`, ...). A name in `CODE_TEMPLATE_DENY` emits no script. Absent: decided by the path alone. */
|
|
354
|
+
templateName?: TemplateName | undefined;
|
|
236
355
|
/** A preview page (`mode: 'preview'` provider): the widget is drawn, never run. */
|
|
237
356
|
preview?: boolean | undefined;
|
|
238
357
|
};
|
|
@@ -374,6 +493,78 @@ declare function WidgetStyle({ css }: {
|
|
|
374
493
|
*/
|
|
375
494
|
declare const BASE_CSS = "@layer throttle{\n:root{--tb-scale:1;--tb-space-xs:calc(.25rem*var(--tb-scale));--tb-space-s:calc(.5rem*var(--tb-scale));--tb-space-m:calc(1rem*var(--tb-scale));--tb-space-l:calc(1.5rem*var(--tb-scale));--tb-space-xl:calc(2.5rem*var(--tb-scale));--tb-space-2xl:calc(4rem*var(--tb-scale));\n--tb-text-xs:.75rem;--tb-text-s:.875rem;--tb-text-m:1rem;--tb-text-l:1.25rem;--tb-text-xl:1.5rem;--tb-text-2xl:2rem;--tb-text-3xl:2.75rem}\n.tb-root{display:block;inline-size:100%}\n.tb-section,.tb-col,.tb-w{--tb-hide:initial}\n.tb-section,.tb-col{--tb-bg:initial;--tb-bgimg:initial;--tb-bgpos:initial;--tb-bgsize:initial;--tb-overlay:initial}\n.tb-section{--tb-valign:initial;--tb-minh:initial;--tb-pady:initial;--tb-padx:initial;--tb-gap:initial;--tb-maxw:initial;--tb-flow:initial}\n.tb-col{--tb-pad:initial;--tb-self:initial}\n.tb-section{box-sizing:border-box;position:relative;display:var(--tb-hide,flex);flex-direction:column;justify-content:var(--tb-valign,flex-start);min-block-size:var(--tb-minh,0px);padding-block:var(--tb-pady,0px);padding-inline:var(--tb-padx,0px);background-color:var(--tb-bg,transparent);background-image:var(--tb-bgimg,none);background-position:var(--tb-bgpos,center);background-size:var(--tb-bgsize,cover);background-repeat:no-repeat}\n.tb-section::before{content:\"\";position:absolute;inset:0;background:var(--tb-overlay,transparent);pointer-events:none}\n.tb-inner{box-sizing:border-box;position:relative;inline-size:100%;max-inline-size:var(--tb-maxw,1200px);margin-inline:auto}\n.tb-row{display:flex;flex-flow:var(--tb-flow,row wrap);gap:var(--tb-gap,0px);align-items:stretch}\n.tb-col{box-sizing:border-box;display:var(--tb-hide,flex);flex-direction:column;flex:0 0 auto;inline-size:calc((100% - var(--tb-cn,0)*var(--tb-gap,0px))*var(--tb-cw,1));min-inline-size:0;align-self:var(--tb-self,stretch);padding:var(--tb-pad,0px);background-color:var(--tb-bg,transparent);background-image:var(--tb-bgimg,none);background-position:var(--tb-bgpos,center);background-size:var(--tb-bgsize,cover);background-repeat:no-repeat}\n.tb-w{display:var(--tb-hide,block);min-inline-size:0;margin-block-start:var(--b-spacingTop,var(--w-spacingTop,0px));margin-block-end:var(--b-spacingBottom,var(--w-spacingBottom,0px))}\n.tb-missing{padding:var(--tb-space-s);border:1px dashed var(--tb-color-border-control,currentColor);font-size:var(--tb-text-s)}\n@media (min-width:1025px){.tb-v:not(.tb-only-desktop){display:none!important}}\n@media (min-width:768px) and (max-width:1024px){.tb-v:not(.tb-only-tablet){display:none!important}}\n@media (max-width:767px){.tb-v:not(.tb-only-phone){display:none!important}}\n}";
|
|
376
495
|
|
|
496
|
+
/**
|
|
497
|
+
* The catalog and page targets of the menus and parts, resolved on the server: `${kind}:${id}` (kind is `page`,
|
|
498
|
+
* `category`, `collection` or `product`) to the href, or `null` for a target that no longer exists (it then renders as
|
|
499
|
+
* text, never a link). The store's layout fills it before render and hands it to `BuilderProvider`, so hydration never
|
|
500
|
+
* looks a handle up and never draws a null link. A key that is absent falls back to the page's own resolver.
|
|
501
|
+
*/
|
|
502
|
+
type LinkTargets = Readonly<Record<string, string | null>>;
|
|
503
|
+
type BuilderContextValue = {
|
|
504
|
+
client: BuilderClient | null;
|
|
505
|
+
packs: readonly WidgetPack[];
|
|
506
|
+
registry: RendererRegistry;
|
|
507
|
+
site: LoadedSite;
|
|
508
|
+
locale: string;
|
|
509
|
+
mediaOrigin: string;
|
|
510
|
+
onError?: ((error: unknown, info: {
|
|
511
|
+
part: string;
|
|
512
|
+
}) => void) | undefined;
|
|
513
|
+
resolveLink: (target: {
|
|
514
|
+
kind: string;
|
|
515
|
+
[key: string]: unknown;
|
|
516
|
+
}) => string | null;
|
|
517
|
+
/** Server-resolved targets (`LinkTargets`), or undefined when the store passes none. */
|
|
518
|
+
linkTargets?: LinkTargets | undefined;
|
|
519
|
+
/** False in the editor's edit mode: every panel expanded, nothing animated or ticking. */
|
|
520
|
+
interactive: boolean;
|
|
521
|
+
/** The site's sanitised custom CSS (scoped under `[data-b-root]`), or ''. */
|
|
522
|
+
customCss: string;
|
|
523
|
+
/** The page being rendered, for announcement page rules (its id, template name, `home`). Absent: only `home` is known, from `pathname`. */
|
|
524
|
+
page?: {
|
|
525
|
+
id?: string | undefined;
|
|
526
|
+
template?: string | undefined;
|
|
527
|
+
home?: boolean | undefined;
|
|
528
|
+
} | undefined;
|
|
529
|
+
/** `preview` is a page the Builder editor draws: code widgets are drawn there, never run. */
|
|
530
|
+
mode: 'live' | 'preview';
|
|
531
|
+
/** The path being rendered (`usePathname()` of the store); without it no code widget runs. */
|
|
532
|
+
pathname: string | undefined;
|
|
533
|
+
/** The site's page template and the catalog templates code may run on (`isCodeRoute`). */
|
|
534
|
+
codeRoutes: {
|
|
535
|
+
page: string;
|
|
536
|
+
catalog?: readonly string[] | undefined;
|
|
537
|
+
routeTable?: RouteTable | undefined;
|
|
538
|
+
allow?: readonly string[] | undefined;
|
|
539
|
+
};
|
|
540
|
+
/** The template the page being rendered is (`product`, `cart`, ...); a denied one emits no code script. */
|
|
541
|
+
templateName?: TemplateName | undefined;
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* `react` has no `createContext` in a React Server Components build, and the server entries share this module's chunk
|
|
545
|
+
* through `PartBoundary`. Nothing reads the context on the server (`useBuilder` runs only in client components), so
|
|
546
|
+
* evaluating this module there must not throw.
|
|
547
|
+
*/
|
|
548
|
+
declare const BuilderContext: Context<BuilderContextValue | null>;
|
|
549
|
+
/** The provider's value, or null outside a `BuilderProvider`. */
|
|
550
|
+
declare const useBuilder: () => BuilderContextValue | null;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* What the store knows about the shopper in the browser, for `showWhen` (spec §5.4). `null` for a facet means the store has
|
|
554
|
+
* not resolved it yet (the customer or the cart is still loading): the node keeps its server branch and its reserved space
|
|
555
|
+
* until it is known. The package cannot read the customer or the cart itself (it sits below the storefront), so the store
|
|
556
|
+
* passes them to `BuilderProvider`'s `viewer` prop.
|
|
557
|
+
*/
|
|
558
|
+
type BuilderViewer = {
|
|
559
|
+
signedIn: boolean | null;
|
|
560
|
+
cartItemCount: number | null;
|
|
561
|
+
};
|
|
562
|
+
/**
|
|
563
|
+
* The provider's viewer: `undefined` when the store wired none (a guest with an empty cart), `null` while the store's
|
|
564
|
+
* customer state is still loading as a whole.
|
|
565
|
+
*/
|
|
566
|
+
declare const useViewer: () => BuilderViewer | null | undefined;
|
|
567
|
+
|
|
377
568
|
type BuilderProviderProps = {
|
|
378
569
|
/** The publishable Builder key (`tb_pk_...`). Only needed for a `BuilderPage` that reads its own page. */
|
|
379
570
|
builderKey?: string;
|
|
@@ -397,8 +588,36 @@ type BuilderProviderProps = {
|
|
|
397
588
|
pathname?: string;
|
|
398
589
|
/** The catalog route templates code widgets may also run on (`{handle}` is one segment). Default: `/p/{handle}`, `/c/{handle}`, `/collections/{handle}`, `/tags/{tag}`, `/search`, `/shop`. */
|
|
399
590
|
catalogRoutes?: string[];
|
|
591
|
+
/**
|
|
592
|
+
* The path (or `{handle}` template) of each template the store serves, by template name. A path it maps to a
|
|
593
|
+
* template in `CODE_TEMPLATE_DENY` (a cart renamed `/bag`) never runs code and is left with a full page load.
|
|
594
|
+
* Default: the site settings' `routes.store`.
|
|
595
|
+
*/
|
|
596
|
+
routeTable?: RouteTable;
|
|
597
|
+
/** The template the page being rendered is. One in `CODE_TEMPLATE_DENY` (cart, account, sign-in, ...) emits no code script, whatever its path. */
|
|
598
|
+
templateName?: TemplateName;
|
|
599
|
+
/**
|
|
600
|
+
* The own paths (`/about`) of the store's pages (`loadOwnPagePaths()` of `@usethrottle/builder-react/server`). Code
|
|
601
|
+
* widgets may run on them, and a client navigation to one does not force a page load. The deny rules still win.
|
|
602
|
+
*/
|
|
603
|
+
ownPagePaths?: readonly string[];
|
|
400
604
|
/** `preview` is the Builder's own preview page: code widgets are drawn there with a badge and never run. */
|
|
401
605
|
mode?: 'live' | 'preview';
|
|
606
|
+
/**
|
|
607
|
+
* What the store knows about the shopper in the browser, for nodes with `showWhen` (spec §5.4) and announcement
|
|
608
|
+
* audiences: whether they are signed in and how many items are in the cart (a facet is `null` while it is still
|
|
609
|
+
* loading). `null` as a whole means the customer state is still loading; absent means a guest with an empty cart.
|
|
610
|
+
* The package cannot read either itself.
|
|
611
|
+
*/
|
|
612
|
+
viewer?: BuilderViewer | null | undefined;
|
|
613
|
+
/** The page being rendered (id, template name, `home`), for the page rules of announcement messages. */
|
|
614
|
+
page?: {
|
|
615
|
+
id?: string;
|
|
616
|
+
template?: string;
|
|
617
|
+
home?: boolean;
|
|
618
|
+
};
|
|
619
|
+
/** The menu and part targets the store resolved on the server (`LinkTargets`): `${kind}:${id}` to the href, or null for a deleted target. */
|
|
620
|
+
linkTargets?: LinkTargets;
|
|
402
621
|
children: ReactNode;
|
|
403
622
|
};
|
|
404
623
|
/**
|
|
@@ -415,44 +634,7 @@ type BuilderProviderProps = {
|
|
|
415
634
|
* With a site the Builder could not answer (`status: 'unavailable'`) it fills
|
|
416
635
|
* nothing, so the catalog's own design shows and every part renders nothing.
|
|
417
636
|
*/
|
|
418
|
-
declare function BuilderProvider({ builderKey, client, packs, site, onError, interactive, pathname, catalogRoutes, mode, children }: BuilderProviderProps): ReactNode;
|
|
419
|
-
|
|
420
|
-
type BuilderContextValue = {
|
|
421
|
-
client: BuilderClient | null;
|
|
422
|
-
packs: readonly WidgetPack[];
|
|
423
|
-
registry: RendererRegistry;
|
|
424
|
-
site: LoadedSite;
|
|
425
|
-
locale: string;
|
|
426
|
-
mediaOrigin: string;
|
|
427
|
-
onError?: ((error: unknown, info: {
|
|
428
|
-
part: string;
|
|
429
|
-
}) => void) | undefined;
|
|
430
|
-
resolveLink: (target: {
|
|
431
|
-
kind: string;
|
|
432
|
-
[key: string]: unknown;
|
|
433
|
-
}) => string | null;
|
|
434
|
-
/** False in the editor's edit mode: every panel expanded, nothing animated or ticking. */
|
|
435
|
-
interactive: boolean;
|
|
436
|
-
/** The site's sanitised custom CSS (scoped under `[data-b-root]`), or ''. */
|
|
437
|
-
customCss: string;
|
|
438
|
-
/** `preview` is a page the Builder editor draws: code widgets are drawn there, never run. */
|
|
439
|
-
mode: 'live' | 'preview';
|
|
440
|
-
/** The path being rendered (`usePathname()` of the store); without it no code widget runs. */
|
|
441
|
-
pathname: string | undefined;
|
|
442
|
-
/** The site's page template and the catalog templates code may run on (`isCodeRoute`). */
|
|
443
|
-
codeRoutes: {
|
|
444
|
-
page: string;
|
|
445
|
-
catalog?: readonly string[] | undefined;
|
|
446
|
-
};
|
|
447
|
-
};
|
|
448
|
-
/**
|
|
449
|
-
* `react` has no `createContext` in a React Server Components build, and the server entries share this module's chunk
|
|
450
|
-
* through `PartBoundary`. Nothing reads the context on the server (`useBuilder` runs only in client components), so
|
|
451
|
-
* evaluating this module there must not throw.
|
|
452
|
-
*/
|
|
453
|
-
declare const BuilderContext: Context<BuilderContextValue | null>;
|
|
454
|
-
/** The provider's value, or null outside a `BuilderProvider`. */
|
|
455
|
-
declare const useBuilder: () => BuilderContextValue | null;
|
|
637
|
+
declare function BuilderProvider({ builderKey, client, packs, site, onError, interactive, pathname, catalogRoutes, routeTable, templateName, ownPagePaths, mode, viewer, page, linkTargets, children }: BuilderProviderProps): ReactNode;
|
|
456
638
|
|
|
457
639
|
/** A loaded page rendered with the provider's registry. Data the server could not resolve fills in after mount. */
|
|
458
640
|
declare function BuilderPageView({ page, resolve }: {
|
|
@@ -488,6 +670,28 @@ declare function BuilderSlot({ name, context }: {
|
|
|
488
670
|
context?: unknown;
|
|
489
671
|
}): ReactNode;
|
|
490
672
|
|
|
673
|
+
/**
|
|
674
|
+
* A template document (`product`, `cart`, `not-found`, ...) rendered with the provider's registry, over the loader's
|
|
675
|
+
* `context` (`context.product`, `context.listing`, `context.route`, ...). The layout's header and footer sit around it.
|
|
676
|
+
*/
|
|
677
|
+
declare function BuilderTemplateView({ name, part, context, }: {
|
|
678
|
+
name: TemplateName;
|
|
679
|
+
part: LoadedPart;
|
|
680
|
+
context?: unknown;
|
|
681
|
+
}): ReactNode;
|
|
682
|
+
/**
|
|
683
|
+
* What the route resolver knows about the page it renders and the provider above it (in the layout) cannot: the
|
|
684
|
+
* template (`cart` never gets a script, whatever its path), the store's route table (a cart renamed `/bag`) and the
|
|
685
|
+
* path of a page served at its own path (`/about`), which code widgets may run on. Code decisions below this point
|
|
686
|
+
* read these; the deny rules still win over `allowPath`.
|
|
687
|
+
*/
|
|
688
|
+
declare function BuilderRouteScope({ templateName, routeTable, allowPath, children, }: {
|
|
689
|
+
templateName?: TemplateName;
|
|
690
|
+
routeTable?: RouteTable;
|
|
691
|
+
allowPath?: string;
|
|
692
|
+
children: ReactNode;
|
|
693
|
+
}): ReactNode;
|
|
694
|
+
|
|
491
695
|
/**
|
|
492
696
|
* The key one binding is stored under. Identical bindings (same source, same
|
|
493
697
|
* params) share it, which is what makes "resolve once" work. A `context.*`
|
|
@@ -509,27 +713,6 @@ declare function resolveBindings(bindings: ReadonlyMap<string, DataBinding>, reg
|
|
|
509
713
|
include: 'static' | 'shopper' | 'all';
|
|
510
714
|
}): Promise<DataMap>;
|
|
511
715
|
|
|
512
|
-
/**
|
|
513
|
-
* Where a code widget may run (v2 spec, code widgets). The allow-list lives here, in the renderer, and is not a
|
|
514
|
-
* merchant setting: no switch in the dashboard can put a script on a checkout, cart-payment, account or sign-in page.
|
|
515
|
-
*/
|
|
516
|
-
/**
|
|
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
|
-
* tests every segment of the path with it, and the deny wins over every allow rule.
|
|
519
|
-
*/
|
|
520
|
-
declare const CODE_ROUTE_DENY: RegExp;
|
|
521
|
-
/** The catalog templates a store has unless it passes its own (`{name}` is one path segment). */
|
|
522
|
-
declare const DEFAULT_CATALOG_ROUTES: readonly string[];
|
|
523
|
-
/**
|
|
524
|
-
* Whether code widgets may run on this path. False when the path is unknown; false on the deny list; otherwise true
|
|
525
|
-
* only on `/`, the site's page template and the catalog templates. A segment of the deny list anywhere in the path refuses it
|
|
526
|
-
* (`/fr/checkout`, `/de/account/orders`), whatever the page template is.
|
|
527
|
-
*/
|
|
528
|
-
declare function isCodeRoute(pathname: string | undefined, routes: {
|
|
529
|
-
page: string;
|
|
530
|
-
catalog?: readonly string[];
|
|
531
|
-
}): boolean;
|
|
532
|
-
|
|
533
716
|
/**
|
|
534
717
|
* Saved sections (agent v2): a `saved-section` root node names a document by id, and the read answer carries the
|
|
535
718
|
* published section of every document the page uses. The renderer draws that section where the reference stands.
|
|
@@ -626,4 +809,4 @@ declare function CompositeWidget(props: CompositeWidgetProps): ReactNode;
|
|
|
626
809
|
*/
|
|
627
810
|
declare const customWidgetFactory: CustomWidgetFactory;
|
|
628
811
|
|
|
629
|
-
export { AssetImage, BASE_CSS, BASIC_COMPONENTS, BuilderContext, type BuilderContextValue, BuilderFooter, BuilderHeader, BuilderPage, BuilderPageView, BuilderProvider, type BuilderProviderProps, BuilderRenderer, type BuilderRendererProps, BuilderSlot, CODE_ROUTE_DENY, CUSTOM_WIDGET_CONTAINMENT, type CodeRender, CodeWidget, type CodeWidgetProps, CompositeWidget, type CompositeWidgetProps, type CustomWidgetFactory, DEFAULT_CATALOG_ROUTES, type DataMap, type DataSourceResolver, type EditModeHooks, type LinkTargetProvider, type LoadedPage, type LoadedPart, type LoadedRedirect, type LoadedSite, MAX_RENDERED_NODES, MissingSavedSection, NodeWrapper, type PackDataSource, type PackWidget, RenderBudget, type RenderWarning, type RendererRegistry, type RendererRegistryOptions, type ResolveContext, RichText, type SlotPoint, TemplateWidget, type TemplateWidgetProps, type WidgetPack, type WidgetRenderProps, WidgetStyle, basicPack, bindingKey, bindingsOf, codeScriptUrl, collectBindings, compileResponsiveCss, createRendererRegistry, cssValue, customWidgetFactory, embedSrc, expandSavedSections, fitsBudget, isCodeRoute, isFrozenAsset, jsonForScript, parseRichText, parseVideoUrl, pickLocale, resolveBindings, useBuilder, validateRender };
|
|
812
|
+
export { AssetImage, BASE_CSS, BASIC_COMPONENTS, BuilderContext, type BuilderContextValue, BuilderFooter, BuilderHeader, BuilderPage, BuilderPageView, BuilderProvider, type BuilderProviderProps, BuilderRenderer, type BuilderRendererProps, type BuilderRouteConfig, BuilderRouteScope, BuilderSlot, BuilderTemplateView, type BuilderViewer, CODE_ROUTE_DENY, CUSTOM_WIDGET_CONTAINMENT, type CodeRender, CodeWidget, type CodeWidgetProps, CompositeWidget, type CompositeWidgetProps, type CustomWidgetFactory, DEFAULT_CATALOG_ROUTES, type DataMap, type DataSourceResolver, type DocumentNodes, type EditModeHooks, type LinkTargetProvider, type LinkTargets, type LoadedPage, type LoadedPart, type LoadedRedirect, type LoadedSite, MAX_RENDERED_NODES, MissingSavedSection, NodeWrapper, type PackDataSource, type PackTemplateContribution, type PackWidget, RenderBudget, type RenderWarning, type RendererRegistry, type RendererRegistryOptions, type ResolveContext, RichText, type RouteTable, type SlotPoint, type TemplateContext, type TemplateLoadResult, type TemplateLoader, type TemplateRoute, TemplateWidget, type TemplateWidgetProps, type WidgetPack, type WidgetRenderProps, WidgetStyle, basicPack, bindingKey, bindingsOf, buildRouteTable, codeScriptUrl, collectBindings, compileResponsiveCss, createRendererRegistry, cssValue, customWidgetFactory, embedSrc, expandSavedSections, fitsBudget, isCodeRoute, isFrozenAsset, jsonForScript, parseRichText, parseVideoUrl, pickLocale, resolveBindings, useBuilder, useViewer, validateRender };
|