@usethrottle/builder-react 0.4.3 → 0.5.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.
- package/CLAUDE.md +23 -2
- package/dist/{chunk-C57AQKJI.js → chunk-G6I4RIXU.js} +2122 -393
- package/dist/{chunk-E7SRVAFV.cjs → chunk-UNL4JWZS.cjs} +1992 -263
- package/dist/index.cjs +2251 -603
- package/dist/index.d.cts +186 -61
- package/dist/index.d.ts +186 -61
- package/dist/index.js +2218 -569
- 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-BYBk3Sya.d.cts → seo-iX2POfOp.d.cts} +39 -2
- package/dist/{seo-BYBk3Sya.d.ts → seo-iX2POfOp.d.ts} +39 -2
- package/dist/server.cjs +193 -24
- package/dist/server.d.cts +187 -8
- package/dist/server.d.ts +187 -8
- package/dist/server.js +176 -7
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentType, ReactNode, CSSProperties, Context } from 'react';
|
|
2
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';
|
|
@@ -73,6 +73,18 @@ type PackTemplateContribution = {
|
|
|
73
73
|
/** The pack's default composition of the template, optionally one of its `variants`. */
|
|
74
74
|
defaultComposition: (variant?: string) => DocumentNodes;
|
|
75
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
|
+
}>;
|
|
76
88
|
};
|
|
77
89
|
/** What the store hands the template route (spec §5.1). */
|
|
78
90
|
type BuilderRouteConfig = {
|
|
@@ -203,10 +215,19 @@ type LoadedSite = {
|
|
|
203
215
|
locale: string;
|
|
204
216
|
generation: number;
|
|
205
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;
|
|
206
223
|
/** The origin media files must be on (https). Images from anywhere else are refused. */
|
|
207
224
|
mediaOrigin: string;
|
|
208
225
|
/** Site settings resolved for the locale (localized values are strings). */
|
|
209
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
|
+
};
|
|
210
231
|
header: LoadedPart;
|
|
211
232
|
footer: LoadedPart;
|
|
212
233
|
slots: Record<string, LoadedPart>;
|
|
@@ -234,6 +255,8 @@ type NodeWrapperProps = {
|
|
|
234
255
|
type?: string;
|
|
235
256
|
as?: 'div' | 'section';
|
|
236
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;
|
|
237
260
|
anchor?: string | undefined;
|
|
238
261
|
/** The anchor name of a per-device copy: `data-b-anchor`, which the runtime scrolls to when `#name` points at a hidden copy. */
|
|
239
262
|
copyAnchor?: string | undefined;
|
|
@@ -281,6 +304,41 @@ type RendererRegistryOptions = {
|
|
|
281
304
|
/** Builds the registry the renderer reads. The built-in packs come first; a pack cannot replace a built-in type. */
|
|
282
305
|
declare function createRendererRegistry(packs: readonly WidgetPack[], options?: RendererRegistryOptions): RendererRegistry;
|
|
283
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
|
+
|
|
284
342
|
/** What a render needs to decide whether a code widget runs: the store's code switch and the page it is on. */
|
|
285
343
|
type CodeRender = {
|
|
286
344
|
/** The store's code runtime (`code` of the read answer). Absent: no code. */
|
|
@@ -290,7 +348,10 @@ type CodeRender = {
|
|
|
290
348
|
routes: {
|
|
291
349
|
page: string;
|
|
292
350
|
catalog?: readonly string[] | undefined;
|
|
351
|
+
routeTable?: RouteTable | undefined;
|
|
293
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;
|
|
294
355
|
/** A preview page (`mode: 'preview'` provider): the widget is drawn, never run. */
|
|
295
356
|
preview?: boolean | undefined;
|
|
296
357
|
};
|
|
@@ -432,6 +493,78 @@ declare function WidgetStyle({ css }: {
|
|
|
432
493
|
*/
|
|
433
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}";
|
|
434
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
|
+
|
|
435
568
|
type BuilderProviderProps = {
|
|
436
569
|
/** The publishable Builder key (`tb_pk_...`). Only needed for a `BuilderPage` that reads its own page. */
|
|
437
570
|
builderKey?: string;
|
|
@@ -455,8 +588,36 @@ type BuilderProviderProps = {
|
|
|
455
588
|
pathname?: string;
|
|
456
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`. */
|
|
457
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[];
|
|
458
604
|
/** `preview` is the Builder's own preview page: code widgets are drawn there with a badge and never run. */
|
|
459
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;
|
|
460
621
|
children: ReactNode;
|
|
461
622
|
};
|
|
462
623
|
/**
|
|
@@ -473,44 +634,7 @@ type BuilderProviderProps = {
|
|
|
473
634
|
* With a site the Builder could not answer (`status: 'unavailable'`) it fills
|
|
474
635
|
* nothing, so the catalog's own design shows and every part renders nothing.
|
|
475
636
|
*/
|
|
476
|
-
declare function BuilderProvider({ builderKey, client, packs, site, onError, interactive, pathname, catalogRoutes, mode, children }: BuilderProviderProps): ReactNode;
|
|
477
|
-
|
|
478
|
-
type BuilderContextValue = {
|
|
479
|
-
client: BuilderClient | null;
|
|
480
|
-
packs: readonly WidgetPack[];
|
|
481
|
-
registry: RendererRegistry;
|
|
482
|
-
site: LoadedSite;
|
|
483
|
-
locale: string;
|
|
484
|
-
mediaOrigin: string;
|
|
485
|
-
onError?: ((error: unknown, info: {
|
|
486
|
-
part: string;
|
|
487
|
-
}) => void) | undefined;
|
|
488
|
-
resolveLink: (target: {
|
|
489
|
-
kind: string;
|
|
490
|
-
[key: string]: unknown;
|
|
491
|
-
}) => string | null;
|
|
492
|
-
/** False in the editor's edit mode: every panel expanded, nothing animated or ticking. */
|
|
493
|
-
interactive: boolean;
|
|
494
|
-
/** The site's sanitised custom CSS (scoped under `[data-b-root]`), or ''. */
|
|
495
|
-
customCss: string;
|
|
496
|
-
/** `preview` is a page the Builder editor draws: code widgets are drawn there, never run. */
|
|
497
|
-
mode: 'live' | 'preview';
|
|
498
|
-
/** The path being rendered (`usePathname()` of the store); without it no code widget runs. */
|
|
499
|
-
pathname: string | undefined;
|
|
500
|
-
/** The site's page template and the catalog templates code may run on (`isCodeRoute`). */
|
|
501
|
-
codeRoutes: {
|
|
502
|
-
page: string;
|
|
503
|
-
catalog?: readonly string[] | undefined;
|
|
504
|
-
};
|
|
505
|
-
};
|
|
506
|
-
/**
|
|
507
|
-
* `react` has no `createContext` in a React Server Components build, and the server entries share this module's chunk
|
|
508
|
-
* through `PartBoundary`. Nothing reads the context on the server (`useBuilder` runs only in client components), so
|
|
509
|
-
* evaluating this module there must not throw.
|
|
510
|
-
*/
|
|
511
|
-
declare const BuilderContext: Context<BuilderContextValue | null>;
|
|
512
|
-
/** The provider's value, or null outside a `BuilderProvider`. */
|
|
513
|
-
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;
|
|
514
638
|
|
|
515
639
|
/** A loaded page rendered with the provider's registry. Data the server could not resolve fills in after mount. */
|
|
516
640
|
declare function BuilderPageView({ page, resolve }: {
|
|
@@ -546,6 +670,28 @@ declare function BuilderSlot({ name, context }: {
|
|
|
546
670
|
context?: unknown;
|
|
547
671
|
}): ReactNode;
|
|
548
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
|
+
|
|
549
695
|
/**
|
|
550
696
|
* The key one binding is stored under. Identical bindings (same source, same
|
|
551
697
|
* params) share it, which is what makes "resolve once" work. A `context.*`
|
|
@@ -567,27 +713,6 @@ declare function resolveBindings(bindings: ReadonlyMap<string, DataBinding>, reg
|
|
|
567
713
|
include: 'static' | 'shopper' | 'all';
|
|
568
714
|
}): Promise<DataMap>;
|
|
569
715
|
|
|
570
|
-
/**
|
|
571
|
-
* Where a code widget may run (v2 spec, code widgets). The allow-list lives here, in the renderer, and is not a
|
|
572
|
-
* merchant setting: no switch in the dashboard can put a script on a checkout, cart-payment, account or sign-in page.
|
|
573
|
-
*/
|
|
574
|
-
/**
|
|
575
|
-
* 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`
|
|
576
|
-
* tests every segment of the path with it, and the deny wins over every allow rule.
|
|
577
|
-
*/
|
|
578
|
-
declare const CODE_ROUTE_DENY: RegExp;
|
|
579
|
-
/** The catalog templates a store has unless it passes its own (`{name}` is one path segment). */
|
|
580
|
-
declare const DEFAULT_CATALOG_ROUTES: readonly string[];
|
|
581
|
-
/**
|
|
582
|
-
* Whether code widgets may run on this path. False when the path is unknown; false on the deny list; otherwise true
|
|
583
|
-
* only on `/`, the site's page template and the catalog templates. A segment of the deny list anywhere in the path refuses it
|
|
584
|
-
* (`/fr/checkout`, `/de/account/orders`), whatever the page template is.
|
|
585
|
-
*/
|
|
586
|
-
declare function isCodeRoute(pathname: string | undefined, routes: {
|
|
587
|
-
page: string;
|
|
588
|
-
catalog?: readonly string[];
|
|
589
|
-
}): boolean;
|
|
590
|
-
|
|
591
716
|
/**
|
|
592
717
|
* Saved sections (agent v2): a `saved-section` root node names a document by id, and the read answer carries the
|
|
593
718
|
* published section of every document the page uses. The renderer draws that section where the reference stands.
|
|
@@ -684,4 +809,4 @@ declare function CompositeWidget(props: CompositeWidgetProps): ReactNode;
|
|
|
684
809
|
*/
|
|
685
810
|
declare const customWidgetFactory: CustomWidgetFactory;
|
|
686
811
|
|
|
687
|
-
export { AssetImage, BASE_CSS, BASIC_COMPONENTS, BuilderContext, type BuilderContextValue, BuilderFooter, BuilderHeader, BuilderPage, BuilderPageView, BuilderProvider, type BuilderProviderProps, BuilderRenderer, type BuilderRendererProps, type BuilderRouteConfig, 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 DocumentNodes, type EditModeHooks, type LinkTargetProvider, 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 SlotPoint, type TemplateContext, type TemplateLoadResult, type TemplateLoader, type TemplateRoute, 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 };
|