@weaverse/next 0.1.0-alpha.8 → 1.0.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/README.md +155 -73
- package/dist/{chunk-6PMZ77RA.mjs → chunk-LH6AAEIK.mjs} +115 -8
- package/dist/chunk-LH6AAEIK.mjs.map +1 -0
- package/dist/index.js +260 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +167 -46
- package/dist/index.mjs.map +1 -1
- package/dist/server.js +321 -91
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +205 -28
- package/dist/server.mjs.map +1 -1
- package/dist/types/client.d.ts +16 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +20 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/item.d.ts +60 -0
- package/dist/types/item.d.ts.map +1 -0
- package/dist/types/loader.d.ts +25 -0
- package/dist/types/loader.d.ts.map +1 -0
- package/dist/types/main.d.ts +11 -0
- package/dist/types/main.d.ts.map +1 -0
- package/dist/types/provider.d.ts +82 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/registry.d.ts +15 -0
- package/dist/types/registry.d.ts.map +1 -0
- package/dist/types/renderer.d.ts +21 -0
- package/dist/types/renderer.d.ts.map +1 -0
- package/dist/types/request-info.d.ts +19 -0
- package/dist/types/request-info.d.ts.map +1 -0
- package/dist/types/revalidate-item.d.ts +82 -0
- package/dist/types/revalidate-item.d.ts.map +1 -0
- package/dist/types/root-provider.d.ts +62 -0
- package/dist/types/root-provider.d.ts.map +1 -0
- package/dist/types/runtime.d.ts +113 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/seo.d.ts +55 -0
- package/dist/types/seo.d.ts.map +1 -0
- package/dist/types/server/configs.d.ts +27 -0
- package/dist/types/server/configs.d.ts.map +1 -0
- package/dist/types/server/normalize-page-url.d.ts +19 -0
- package/dist/types/server/normalize-page-url.d.ts.map +1 -0
- package/dist/types/server/revalidate-handler.d.ts +55 -0
- package/dist/types/server/revalidate-handler.d.ts.map +1 -0
- package/dist/types/server/server-client.d.ts +21 -0
- package/dist/types/server/server-client.d.ts.map +1 -0
- package/dist/types/server.d.ts +19 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/studio-bridge.d.ts +16 -0
- package/dist/types/studio-bridge.d.ts.map +1 -0
- package/dist/types/studio-connect.d.ts +27 -0
- package/dist/types/studio-connect.d.ts.map +1 -0
- package/dist/types/studio-router.d.ts +50 -0
- package/dist/types/studio-router.d.ts.map +1 -0
- package/dist/types/studio-script-src.d.ts +12 -0
- package/dist/types/studio-script-src.d.ts.map +1 -0
- package/dist/types/theme-settings-store.d.ts +18 -0
- package/dist/types/theme-settings-store.d.ts.map +1 -0
- package/dist/types/translation-context.d.ts +156 -0
- package/dist/types/translation-context.d.ts.map +1 -0
- package/dist/types/translation-store.d.ts +44 -0
- package/dist/types/translation-store.d.ts.map +1 -0
- package/dist/types/types.d.ts +665 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/use-weaverse-next-studio.d.ts +34 -0
- package/dist/types/use-weaverse-next-studio.d.ts.map +1 -0
- package/dist/types/utils.d.ts +12 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +12 -8
- package/src/client.ts +102 -0
- package/src/hooks.ts +50 -0
- package/src/index.ts +153 -0
- package/src/item.ts +167 -0
- package/src/loader.ts +135 -0
- package/src/main.tsx +45 -0
- package/src/provider.tsx +225 -0
- package/src/registry.ts +63 -0
- package/src/renderer.tsx +100 -0
- package/src/request-info.ts +124 -0
- package/src/revalidate-item.ts +211 -0
- package/src/root-provider.tsx +182 -0
- package/src/runtime.ts +555 -0
- package/src/seo.ts +157 -0
- package/src/server/configs.ts +178 -0
- package/src/server/normalize-page-url.ts +73 -0
- package/src/server/revalidate-handler.ts +357 -0
- package/src/server/server-client.ts +728 -0
- package/src/server.ts +67 -0
- package/src/studio-bridge.tsx +82 -0
- package/src/studio-connect.tsx +88 -0
- package/src/studio-router.ts +85 -0
- package/src/studio-script-src.ts +128 -0
- package/src/theme-settings-store.ts +47 -0
- package/src/translation-context.tsx +299 -0
- package/src/translation-store.ts +69 -0
- package/src/types.ts +753 -0
- package/src/use-weaverse-next-studio.tsx +106 -0
- package/src/utils.ts +37 -0
- package/dist/chunk-6PMZ77RA.mjs.map +0 -1
- package/dist/index.d.mts +0 -517
- package/dist/index.d.ts +0 -517
- package/dist/seo-CpN6tC36.d.mts +0 -477
- package/dist/seo-CpN6tC36.d.ts +0 -477
- package/dist/server.d.mts +0 -99
- package/dist/server.d.ts +0 -99
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { WeaverseNextCommerceContext } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Read explicit root/global data passed to the provider. Next-native
|
|
4
|
+
* replacement for `useRouteLoaderData('root')`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useWeaverseRootData<T = unknown>(): T;
|
|
7
|
+
/**
|
|
8
|
+
* Read explicit page/route commerce data passed to the provider. Next-native
|
|
9
|
+
* replacement for section-level `useLoaderData()`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useWeaversePageData<T = unknown>(): T;
|
|
12
|
+
/** Read the app-provided commerce context (storefront/cart/customer). */
|
|
13
|
+
export declare function useWeaverseCommerce<T = WeaverseNextCommerceContext>(): T;
|
|
14
|
+
/**
|
|
15
|
+
* Read live Weaverse theme settings. The Studio bridge updates the provider's
|
|
16
|
+
* external store via `updateThemeSettings`, so components re-render during live
|
|
17
|
+
* design-mode edits.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useThemeSettings<T = Record<string, unknown>>(): T;
|
|
20
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAY1D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAEpD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAEpD;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,2BAA2B,KAAK,CAAC,CAExE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAOjE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js App Router rendering, provider, Studio, translation, and schema APIs.
|
|
3
|
+
*
|
|
4
|
+
* When migrating from `@weaverse/hydrogen`, replace route-loader context with
|
|
5
|
+
* {@link WeaverseNextProvider} props and render page data with
|
|
6
|
+
* {@link WeaverseNextRenderer}. Import server-only fetching and route-handler
|
|
7
|
+
* helpers from `@weaverse/next/server`.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export { isBrowser, isIframe, useChildInstances, useItemInstance, useParentInstance, useWeaverse, } from '@weaverse/react';
|
|
12
|
+
export * from '@weaverse/schema';
|
|
13
|
+
export { createWeaverseNextClient } from './client';
|
|
14
|
+
export { useThemeSettings, useWeaverseCommerce, useWeaversePageData, useWeaverseRootData, } from './hooks';
|
|
15
|
+
export type { WeaverseNextItem } from './item';
|
|
16
|
+
export { type RunComponentLoadersArgs, runWeaverseComponentLoaders, } from './loader';
|
|
17
|
+
export { WeaverseNextProvider, type WeaverseNextProviderProps, } from './provider';
|
|
18
|
+
export { WeaverseNextRenderer, type WeaverseNextRendererProps, } from './renderer';
|
|
19
|
+
export { buildWeaverseNextRequestInfo } from './request-info';
|
|
20
|
+
export { buildWeaverseNextRevalidateRouteContext, DEFAULT_REVALIDATE_ENDPOINT, type RevalidateItemRuntimeLike, revalidateWeaverseNextItem, type WeaverseNextRevalidateRouteContext, } from './revalidate-item';
|
|
21
|
+
export { type WeaverseNextRootContextValue, WeaverseNextRootProvider, type WeaverseNextRootProviderProps, } from './root-provider';
|
|
22
|
+
export { bindWeaverseNextStudioRuntime, createWeaverseNextRuntime, type WeaverseNextRenderablePage, WeaverseNextRuntime, } from './runtime';
|
|
23
|
+
export { formatWeaverseNextSeoMetadata, getWeaverseNextSeoMetadata, type NextOpenGraph, type NextTwitter, type WeaverseNextSeoInput, type WeaverseNextSeoMetadata, type WeaverseNextSeoPageContainer, } from './seo';
|
|
24
|
+
export { WeaverseNextStudioBridge, type WeaverseNextStudioBridgeProps, } from './studio-bridge';
|
|
25
|
+
export { type LoadWeaverseNextStudioScriptOptions, loadWeaverseNextStudioScript, WeaverseNextStudioConnect, type WeaverseNextStudioConnectProps, } from './studio-connect';
|
|
26
|
+
export { type CreateWeaverseNextStudioInternalsOptions, createWeaverseNextStudioInternals, type WeaverseNextRouterLike, type WeaverseNextStudioInternals, } from './studio-router';
|
|
27
|
+
export { type ResolveWeaverseNextStudioScriptSrcOptions, resolveWeaverseNextStudioScriptSrc, } from './studio-script-src';
|
|
28
|
+
export { type CreateWeaverseNextThemeSettingsStoreOptions, createWeaverseNextThemeSettingsStore, } from './theme-settings-store';
|
|
29
|
+
export { type CreateTranslateSources, createTranslate, getNestedKey, interpolate, ThemeTextProvider, type ThemeTextProviderProps, type ThemeTextValue, type TranslateFunction, TranslationProvider, type TranslationProviderProps, type TranslationValue, useThemeText, useTranslation, } from './translation-context';
|
|
30
|
+
export { ThemeTextStore, TranslationStore } from './translation-store';
|
|
31
|
+
export type { WeaverseArticle, WeaverseBlog, WeaverseCollection, WeaverseMetaObject, WeaverseNextCacheConfig, WeaverseNextClient, WeaverseNextClientConfig, WeaverseNextCommerceContext, WeaverseNextComponent, WeaverseNextComponentData, WeaverseNextComponentLoaderArgs, WeaverseNextComponentProps, WeaverseNextCustomPageEntry, WeaverseNextFetchCustomPagesOptions, WeaverseNextI18n, WeaverseNextLoaderData, WeaverseNextLoadPageInput, WeaverseNextPageAssignment, WeaverseNextPageData, WeaverseNextRequestContext, WeaverseNextRequestInfo, WeaverseNextRuntimeConfig, WeaverseNextRuntimeInternal, WeaverseNextStorefront, WeaverseNextThemeSchema, WeaverseNextThemeSchemaGroup, WeaverseNextThemeSchemaInput, WeaverseNextThemeSettingsStore, WeaverseNextTranslationChanges, WeaverseNextTranslationEntry, WeaverseNextTranslationItemEntry, WeaverseNextTranslationMap, WeaverseNextTranslationMapEntry, WeaverseProduct, } from './types';
|
|
32
|
+
export { useWeaverseNextStudioInternals, WeaverseNextStudio, type WeaverseNextStudioProps, } from './use-weaverse-next-studio';
|
|
33
|
+
export { generateDataFromSchema } from './utils';
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EACL,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,WAAW,GACZ,MAAM,iBAAiB,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAC9C,OAAO,EACL,KAAK,uBAAuB,EAC5B,2BAA2B,GAC5B,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,4BAA4B,EAAE,MAAM,g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E,MAAM,qBAAqB,CAAA;AACtE,YAAY,EACV,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,2BAA2B,EAC3B,qBAAqB,EACrB,yBAAyB,EACzB,+BAA+B,EAC/B,0BAA0B,EAC1B,2BAA2B,EAC3B,mCAAmC,EACnC,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EACtB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,EAC5B,gCAAgC,EAChC,0BAA0B,EAC1B,+BAA+B,EAC/B,eAAe,GAChB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ElementData } from '@weaverse/react';
|
|
2
|
+
import { Weaverse, WeaverseItemStore } from '@weaverse/react';
|
|
3
|
+
import type { WeaverseNextRuntime } from './runtime';
|
|
4
|
+
import type { WeaverseNextComponentData } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Run `create` with item update emissions deferred, returning its result and
|
|
7
|
+
* the items whose `setData()` fired meanwhile. The caller is responsible for
|
|
8
|
+
* calling `triggerUpdate()` on them once React has committed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function collectDeferredItemUpdates<T>(create: () => T): [T, WeaverseNextItem[]];
|
|
11
|
+
/**
|
|
12
|
+
* Item store that flattens the serialized item's nested `data` field onto the
|
|
13
|
+
* store and seeds schema defaults — same shape Hydrogen produces, so the
|
|
14
|
+
* shared `@weaverse/react` renderer can spread props at the top level.
|
|
15
|
+
*/
|
|
16
|
+
export declare class WeaverseNextItem extends WeaverseItemStore {
|
|
17
|
+
/** Browser runtime that owns this item store. */
|
|
18
|
+
weaverse: WeaverseNextRuntime;
|
|
19
|
+
/**
|
|
20
|
+
* Cached merged snapshot (base `_store` + translations). Reset whenever the
|
|
21
|
+
* `_store` ref or the item's translation entry ref changes, so
|
|
22
|
+
* `useSyncExternalStore` sees a stable object between unrelated re-renders.
|
|
23
|
+
*/
|
|
24
|
+
private _cachedSnapshot;
|
|
25
|
+
private _snapshotStoreRef;
|
|
26
|
+
private _snapshotTranslationRef;
|
|
27
|
+
/** Create an item store from serialized component data and its runtime. */
|
|
28
|
+
constructor(initialData: WeaverseNextComponentData, weaverse: Weaverse);
|
|
29
|
+
/**
|
|
30
|
+
* Flatten nested `data` on updates exactly like the constructor does. Core's
|
|
31
|
+
* `initProject()` calls `setData(item)` when a new runtime serves a page
|
|
32
|
+
* whose item instances already exist (e.g. locale/client navigation).
|
|
33
|
+
*
|
|
34
|
+
* A complete serialized item (it carries `id` and `type`; core's
|
|
35
|
+
* `initProject()` always passes one) replaces the store the way the
|
|
36
|
+
* constructor builds it: the schema defaults of the item's own `type` — the
|
|
37
|
+
* Builder can replace a section in place, keeping its id — then the item's
|
|
38
|
+
* settings. A payload omits a setting — or the whole optional `data` — when
|
|
39
|
+
* its value equals the schema default, so merging into the previous store
|
|
40
|
+
* would keep the previous locale's value visible. Partial updates still
|
|
41
|
+
* merge. Either way the `_store` ref changes, which invalidates the memoized
|
|
42
|
+
* snapshot below. The subscriber emit is queued instead of fired when a
|
|
43
|
+
* render-phase deferral is active (see `collectDeferredItemUpdates`).
|
|
44
|
+
*/
|
|
45
|
+
setData: (update: Omit<ElementData, "id" | "type">) => ElementData;
|
|
46
|
+
/**
|
|
47
|
+
* Overlay item-level translations onto the base store when the runtime is in
|
|
48
|
+
* translation mode. Mirrors Hydrogen's `WeaverseHydrogenItem.getSnapShot()`:
|
|
49
|
+
* memoized by `_store` ref + translation entry ref so the returned object is
|
|
50
|
+
* referentially stable, and a fast path that returns the base store untouched
|
|
51
|
+
* when the item has no translations.
|
|
52
|
+
*/
|
|
53
|
+
getSnapShot: () => ElementData;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Register the Next item constructor globally. Idempotent: calling it more than
|
|
57
|
+
* once is safe. Invoked by the renderer before it builds a Weaverse instance.
|
|
58
|
+
*/
|
|
59
|
+
export declare function ensureNextItemConstructor(): void;
|
|
60
|
+
//# sourceMappingURL=item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,SAAS,CAAA;AA6BhB;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,MAAM,EAAE,MAAM,CAAC,GACd,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CASzB;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB;IACrD,iDAAiD;IACzC,QAAQ,EAAE,mBAAmB,CAAA;IAErC;;;;OAIG;IACH,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,uBAAuB,CACzB;IAEN,2EAA2E;gBAC/D,WAAW,EAAE,yBAAyB,EAAE,QAAQ,EAAE,QAAQ;IAMtE;;;;;;;;;;;;;;;OAeG;IACH,OAAO,GAAI,QAAQ,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,MAAM,CAAC,iBAkBlD;IAED;;;;;;OAMG;IACH,WAAW,QAAO,WAAW,CA6B5B;CACF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,SAQxC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WeaverseNextClient, WeaverseNextCommerceContext, WeaverseNextLoaderData, WeaverseNextRequestContext } from './types';
|
|
2
|
+
/** Inputs for running registered component loaders over a page tree. */
|
|
3
|
+
export interface RunComponentLoadersArgs {
|
|
4
|
+
/** Weaverse client containing the component registry. */
|
|
5
|
+
client: WeaverseNextClient;
|
|
6
|
+
/** Request-scoped commerce override; defaults to `client.commerce`. */
|
|
7
|
+
commerce?: WeaverseNextCommerceContext;
|
|
8
|
+
/** Request-context override; defaults to `client.requestContext`. */
|
|
9
|
+
context?: WeaverseNextRequestContext;
|
|
10
|
+
/** Page payload to walk; defaults to `client.data`. */
|
|
11
|
+
data?: WeaverseNextLoaderData | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Walk a serialized page tree and run each registered component's `loader`,
|
|
15
|
+
* attaching the result to the item as `loaderData`.
|
|
16
|
+
*
|
|
17
|
+
* Loaders receive explicit `commerce.storefront` (and `weaverse.storefront` as
|
|
18
|
+
* a compatibility alias via the client). Children are walked recursively when
|
|
19
|
+
* they are inline item objects; flat `items` arrays are covered by the
|
|
20
|
+
* top-level walk.
|
|
21
|
+
*
|
|
22
|
+
* @returns a cloned `data` object with `loaderData` attached to cloned items.
|
|
23
|
+
*/
|
|
24
|
+
export declare function runWeaverseComponentLoaders(args: RunComponentLoadersArgs): Promise<WeaverseNextLoaderData | null>;
|
|
25
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,2BAA2B,EAG3B,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAGhB,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC,yDAAyD;IACzD,MAAM,EAAE,kBAAkB,CAAA;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,2BAA2B,CAAA;IACtC,qEAAqE;IACrE,OAAO,CAAC,EAAE,0BAA0B,CAAA;IACpC,uDAAuD;IACvD,IAAI,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;CACrC;AAqBD;;;;;;;;;;GAUG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAgFxC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SchemaType } from '@weaverse/schema';
|
|
2
|
+
import type { WeaverseNextComponent } from './types';
|
|
3
|
+
/** Schema for the default {@link Main} root component. Type is exactly `main`. */
|
|
4
|
+
export declare const mainSchema: SchemaType;
|
|
5
|
+
/**
|
|
6
|
+
* Default `main` component module, registered ahead of user components by
|
|
7
|
+
* {@link registerWeaverseNextComponents}. Kept package-internal — consumers
|
|
8
|
+
* override it simply by registering their own component with `type: 'main'`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const defaultMainComponent: WeaverseNextComponent;
|
|
11
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,KAAK,EAAE,qBAAqB,EAA8B,MAAM,SAAS,CAAA;AA4BhF,kFAAkF;AAClF,eAAO,MAAM,UAAU,EAAE,UAGvB,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,qBAGlC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type TranslateFunction } from './translation-context';
|
|
3
|
+
import { TranslationStore } from './translation-store';
|
|
4
|
+
import type { WeaverseNextClient, WeaverseNextCommerceContext, WeaverseNextThemeSettingsStore } from './types';
|
|
5
|
+
/** Read `themeSchema.i18n.staticContent` for the fallback (no-root) provider. */
|
|
6
|
+
export declare function getSchemaStaticContent(schema: unknown): Record<string, unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Value carried by {@link WeaverseNextContext}. Holds the explicit data
|
|
9
|
+
* boundaries that replace React Router's `useLoaderData` /
|
|
10
|
+
* `useRouteLoaderData` inside sections.
|
|
11
|
+
*/
|
|
12
|
+
export interface WeaverseNextContextValue {
|
|
13
|
+
/** Client used by the renderer and component-loader compatibility hooks. */
|
|
14
|
+
client?: WeaverseNextClient;
|
|
15
|
+
/** App-provided commerce context for rendered components. */
|
|
16
|
+
commerce?: WeaverseNextCommerceContext;
|
|
17
|
+
/** Active-locale static-text overrides, threaded into the runtime. */
|
|
18
|
+
merchantOverrides?: Record<string, unknown>;
|
|
19
|
+
/** Page-scoped data exposed to rendered components. */
|
|
20
|
+
pageData?: unknown;
|
|
21
|
+
/** Root-scoped data exposed to rendered components. */
|
|
22
|
+
rootData?: unknown;
|
|
23
|
+
/** Current merged theme-setting values. */
|
|
24
|
+
themeSettings: Record<string, unknown>;
|
|
25
|
+
/** External store that publishes live theme-setting updates. */
|
|
26
|
+
themeSettingsStore: WeaverseNextThemeSettingsStore;
|
|
27
|
+
/** Live design-mode static-text override store, threaded into the runtime. */
|
|
28
|
+
translationStore: TranslationStore;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Null sentinel default lets hooks detect usage outside the provider and throw
|
|
32
|
+
* a clear error instead of silently returning empty data.
|
|
33
|
+
*/
|
|
34
|
+
export declare const WeaverseNextContext: import("react").Context<WeaverseNextContextValue | null>;
|
|
35
|
+
/** Explicit page, commerce, theme, and translation data for Next components. */
|
|
36
|
+
export interface WeaverseNextProviderProps {
|
|
37
|
+
/** React subtree that consumes the Weaverse Next contexts. */
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
/** Client used by the renderer and component-loader compatibility hooks. */
|
|
40
|
+
client?: WeaverseNextClient;
|
|
41
|
+
/** App-provided commerce context (storefront/cart/customer). */
|
|
42
|
+
commerce?: WeaverseNextCommerceContext;
|
|
43
|
+
/**
|
|
44
|
+
* Active-locale static-text overrides (nested, from `loadThemeSettings()`).
|
|
45
|
+
* Adopts the root provider's `merchantOverrides` when omitted.
|
|
46
|
+
*/
|
|
47
|
+
merchantOverrides?: Record<string, unknown>;
|
|
48
|
+
/** Explicit page/route commerce data (replaces section-level `useLoaderData`). */
|
|
49
|
+
pageData?: unknown;
|
|
50
|
+
/** Explicit root/global data (replaces `useRouteLoaderData('root')`). */
|
|
51
|
+
rootData?: unknown;
|
|
52
|
+
/**
|
|
53
|
+
* Theme default locale JSON (`loadThemeSettings().staticContent`). Adopts the
|
|
54
|
+
* root provider's `staticContent` when omitted, then falls back to
|
|
55
|
+
* `client.themeSchema.i18n.staticContent`.
|
|
56
|
+
*/
|
|
57
|
+
staticContent?: Record<string, unknown>;
|
|
58
|
+
/** Optional external translation function (host i18n); highest priority in `t()`. */
|
|
59
|
+
t?: TranslateFunction;
|
|
60
|
+
/** Theme settings override; falls back to `client.themeSettings`. */
|
|
61
|
+
themeSettings?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Client boundary that supplies explicit root/page/commerce data to Weaverse
|
|
65
|
+
* sections. Next-native replacement for `withWeaverse` + route loader data —
|
|
66
|
+
* no React Router route matches are emulated.
|
|
67
|
+
*
|
|
68
|
+
* In App Router, create/pass `client` only from a client component wrapper. A
|
|
69
|
+
* `WeaverseNextClient` contains functions and component references, so it is
|
|
70
|
+
* not serializable across a Server Component → Client Component boundary.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* 'use client'
|
|
75
|
+
*
|
|
76
|
+
* <WeaverseNextProvider client={client} rootData={rootData} pageData={pageData} commerce={commerce}>
|
|
77
|
+
* <WeaverseNextRenderer />
|
|
78
|
+
* </WeaverseNextProvider>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function WeaverseNextProvider(props: WeaverseNextProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAA;AAGd,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EACV,kBAAkB,EAClB,2BAA2B,EAC3B,8BAA8B,EAC/B,MAAM,SAAS,CAAA;AAKhB,iFAAiF;AACjF,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,GACd,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,4EAA4E;IAC5E,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,2BAA2B,CAAA;IACtC,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3C,uDAAuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,2CAA2C;IAC3C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC,gEAAgE;IAChE,kBAAkB,EAAE,8BAA8B,CAAA;IAClD,8EAA8E;IAC9E,gBAAgB,EAAE,gBAAgB,CAAA;CACnC;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,0DACsB,CAAA;AAEtD,gFAAgF;AAChF,MAAM,WAAW,yBAAyB;IACxC,8DAA8D;IAC9D,QAAQ,EAAE,SAAS,CAAA;IACnB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,2BAA2B,CAAA;IACtC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3C,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvC,qFAAqF;IACrF,CAAC,CAAC,EAAE,iBAAiB,CAAA;IACrB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACxC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,2CA+GpE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WeaverseNextComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Register Next adapter components with the shared Weaverse element registry.
|
|
4
|
+
*
|
|
5
|
+
* This mutates global Weaverse runtime state, so callers should run it while
|
|
6
|
+
* creating their app/client wiring, not from a React render body.
|
|
7
|
+
*
|
|
8
|
+
* A default `main` root component is always registered first so consumers don't
|
|
9
|
+
* have to register one for basic page-tree rendering. If the consumer registers
|
|
10
|
+
* their own `main`, that one is preferred: we only prepend the default when the
|
|
11
|
+
* provided components don't already include a `main`, so a user-provided `main`
|
|
12
|
+
* never collides with (or is shadowed by) the default.
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerWeaverseNextComponents(components: WeaverseNextComponent[]): void;
|
|
15
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAWpD;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,qBAAqB,EAAE,QAmCpC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JSX } from 'react/jsx-runtime';
|
|
2
|
+
import type { WeaverseNextClient, WeaverseNextLoaderData } from './types';
|
|
3
|
+
/** Page payload, client, and connector data accepted by the Next renderer. */
|
|
4
|
+
export interface WeaverseNextRendererProps {
|
|
5
|
+
/** Client to render from. Defaults to the provider's client. */
|
|
6
|
+
client?: WeaverseNextClient;
|
|
7
|
+
/** Page payload to render. Defaults to `client.data`. */
|
|
8
|
+
data?: WeaverseNextLoaderData | null;
|
|
9
|
+
/** Data-connector context for `{{...}}` template replacement. */
|
|
10
|
+
dataContext?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Render a serialized Weaverse page tree through `@weaverse/react` primitives.
|
|
14
|
+
*
|
|
15
|
+
* Reads the client/page data supplied by {@link WeaverseNextProvider} when no
|
|
16
|
+
* props are passed, or accepts an explicit `client` + `data` for standalone use. Builds a
|
|
17
|
+
* framework-neutral `Weaverse` core instance (no React Router hooks) and hands
|
|
18
|
+
* it to the shared `WeaverseRoot`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const WeaverseNextRenderer: import("react").MemoExoticComponent<(props: WeaverseNextRendererProps) => JSX.Element | null>;
|
|
21
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/renderer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAG5C,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EAEvB,MAAM,SAAS,CAAA;AAsBhB,8EAA8E;AAC9E,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B,yDAAyD;IACzD,IAAI,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;IACpC,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACtC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,8CACxB,yBAAyB,KAC/B,GAAG,CAAC,OAAO,GAAG,IAAI,CA8CnB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WeaverseNextRequestContext, WeaverseNextRequestInfo } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Put the request's market prefix (`i18n.pathPrefix`, e.g. `/de-de`) on a
|
|
4
|
+
* pathname that does not carry it yet.
|
|
5
|
+
*
|
|
6
|
+
* A Next app builds its request context from the route path, and with
|
|
7
|
+
* locale-segmented routes that path is usually unprefixed. Studio's address
|
|
8
|
+
* bar follows `requestInfo.pathname`, so without the prefix it snaps back to
|
|
9
|
+
* the default market after every navigation. A path that already carries the
|
|
10
|
+
* prefix, and the default market's empty prefix, pass through unchanged.
|
|
11
|
+
*/
|
|
12
|
+
export declare function withPathPrefix(pathname: string, i18n?: WeaverseNextRequestContext['i18n']): string;
|
|
13
|
+
/**
|
|
14
|
+
* Build the Hydrogen-like request info shape consumed by the Studio bridge.
|
|
15
|
+
* Duplicate query keys keep the last value, matching `URLSearchParams` iteration
|
|
16
|
+
* assignment and Hydrogen's practical query-object behavior.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildWeaverseNextRequestInfo(context?: WeaverseNextRequestContext): WeaverseNextRequestInfo;
|
|
19
|
+
//# sourceMappingURL=request-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-info.d.ts","sourceRoot":"","sources":["../../src/request-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAqBhB;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,0BAA0B,CAAC,MAAM,CAAC,GACxC,MAAM,CAcR;AAqDD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,CAAC,EAAE,0BAA0B,GACnC,uBAAuB,CAYzB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { PageType } from '@weaverse/schema';
|
|
2
|
+
import type { WeaverseNextComponentData, WeaverseNextI18n, WeaverseNextRequestInfo } from './types';
|
|
3
|
+
/** Default App Router endpoint used for Studio item-loader revalidation. */
|
|
4
|
+
export declare const DEFAULT_REVALIDATE_ENDPOINT = "/api/weaverse/revalidate";
|
|
5
|
+
/**
|
|
6
|
+
* Server-owned and transient controls stripped from the revalidation route
|
|
7
|
+
* context on both sides of the trust boundary. Compared case-insensitively, so
|
|
8
|
+
* every entry is stored lowercased. Client sanitization keeps normal traffic
|
|
9
|
+
* clean; the route handler repeats this deny-list as the security boundary.
|
|
10
|
+
*
|
|
11
|
+
* - Server-owned: a crafted `?weaverseProjectId=`/`?weaverseHost=` must never
|
|
12
|
+
* influence server config resolution (see `getWeaverseNextConfigs`), and
|
|
13
|
+
* credential-shaped params never ride along in route context.
|
|
14
|
+
* - Transient: draft-item and RSC transport params never describe route identity.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DENIED_ROUTE_CONTEXT_PARAMS: string[];
|
|
17
|
+
/** i18n fields allowed to cross the browser boundary. */
|
|
18
|
+
export declare const ROUTE_CONTEXT_I18N_KEYS: readonly ["country", "label", "language", "locale", "pathPrefix"];
|
|
19
|
+
/**
|
|
20
|
+
* JSON-safe route subset that may cross the browser boundary alongside the
|
|
21
|
+
* draft item. Never carries headers, cookies, auth, env, project ID, Studio
|
|
22
|
+
* host, API keys/bases, commerce clients, the request context, runtime, or
|
|
23
|
+
* client. `search` is canonical (preserves duplicate keys); the derived
|
|
24
|
+
* `queries` record is intentionally omitted.
|
|
25
|
+
*/
|
|
26
|
+
export interface WeaverseNextRevalidateRouteContext {
|
|
27
|
+
/** Route handle used for page assignment. */
|
|
28
|
+
handle?: string;
|
|
29
|
+
/** Public locale and market identity allowed across the browser boundary. */
|
|
30
|
+
i18n?: Pick<WeaverseNextI18n, 'country' | 'label' | 'language' | 'locale' | 'pathPrefix'>;
|
|
31
|
+
/** Weaverse page type resolved by the active route. */
|
|
32
|
+
pageType?: PageType;
|
|
33
|
+
/** Canonical same-origin route pathname. */
|
|
34
|
+
pathname: string;
|
|
35
|
+
/** Sanitized serialized query string, including the leading `?` when set. */
|
|
36
|
+
search: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Minimal runtime surface the in-place apply needs. Structural (not the
|
|
40
|
+
* concrete `WeaverseNextRuntime` class) so unit tests can drive it with a
|
|
41
|
+
* plain mock. `requestInfo` stays optional: a real `WeaverseNextRuntime`
|
|
42
|
+
* always supplies it, but when absent the client omits `routeContext` and the
|
|
43
|
+
* legacy `{ draftItem }` request is preserved.
|
|
44
|
+
*/
|
|
45
|
+
export interface RevalidateItemRuntimeLike {
|
|
46
|
+
/** Live item stores keyed by Weaverse item ID. */
|
|
47
|
+
itemInstances: Map<string, {
|
|
48
|
+
/** Merge refreshed loader data into the live item store. */
|
|
49
|
+
setData: (update: Record<string, unknown>) => unknown;
|
|
50
|
+
}>;
|
|
51
|
+
/** Active route identity used to construct the optional revalidation payload. */
|
|
52
|
+
requestInfo?: WeaverseNextRequestInfo;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Strip denied (server-owned/transient) controls from a `search` string and
|
|
56
|
+
* re-serialize it. Preserves ordinary application queries, duplicate keys,
|
|
57
|
+
* encoded Unicode, and mode controls (`isDesignMode`, `isPreviewMode`,
|
|
58
|
+
* `__revisionId`, `sectionType`). Returns `''` or a `?`-prefixed string.
|
|
59
|
+
*/
|
|
60
|
+
export declare function sanitizeRouteContextSearch(search: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Build the sanitized {@link WeaverseNextRevalidateRouteContext} from the
|
|
63
|
+
* active runtime's request info. Returns `undefined` without a usable pathname
|
|
64
|
+
* so the caller omits `routeContext` and keeps the legacy request. This is not
|
|
65
|
+
* the security boundary — the route handler re-validates and re-sanitizes.
|
|
66
|
+
*/
|
|
67
|
+
export declare function buildWeaverseNextRevalidateRouteContext(requestInfo?: WeaverseNextRequestInfo): WeaverseNextRevalidateRouteContext | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Studio per-item loader revalidation: POST the unsaved draft item (and, when
|
|
70
|
+
* the runtime exposes route context, a sanitized `routeContext`) to the app's
|
|
71
|
+
* revalidate route (see `createWeaverseNextRevalidateHandler`) and apply the
|
|
72
|
+
* returned `loaderData` to the live item instance in place.
|
|
73
|
+
*
|
|
74
|
+
* No `router.refresh()` is involved, so the RSC tree is never re-applied — no
|
|
75
|
+
* page remount, no scroll reset, and the draft payload never touches the URL.
|
|
76
|
+
*
|
|
77
|
+
* Throws on any failure (missing route, non-OK response, unknown item) so the
|
|
78
|
+
* Builder Studio bridge can detect the miss and fall back to its legacy
|
|
79
|
+
* refresh-based revalidation for this window.
|
|
80
|
+
*/
|
|
81
|
+
export declare function revalidateWeaverseNextItem(runtime: RevalidateItemRuntimeLike, draftItem: WeaverseNextComponentData, endpoint?: string): Promise<void>;
|
|
82
|
+
//# sourceMappingURL=revalidate-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidate-item.d.ts","sourceRoot":"","sources":["../../src/revalidate-item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,OAAO,KAAK,EACV,yBAAyB,EACzB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAE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verse/schema';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { type TranslateFunction } from './translation-context';
|
|
4
|
+
import { TranslationStore } from './translation-store';
|
|
5
|
+
import type { WeaverseNextThemeSchema, WeaverseNextThemeSettingsStore } from './types';
|
|
6
|
+
/** Root-scoped theme and translation stores adopted by route providers. */
|
|
7
|
+
export interface WeaverseNextRootContextValue {
|
|
8
|
+
/** Active-locale static-text overrides shared with route-level providers. */
|
|
9
|
+
merchantOverrides?: Record<string, unknown>;
|
|
10
|
+
/** Theme default locale JSON shared with route-level providers. */
|
|
11
|
+
staticContent: Record<string, unknown>;
|
|
12
|
+
/** Root-scoped external store shared with route-level providers. */
|
|
13
|
+
themeSettingsStore: WeaverseNextThemeSettingsStore;
|
|
14
|
+
/** Single live design-mode static-text override store for the whole session. */
|
|
15
|
+
translationStore: TranslationStore;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Ambient root-scoped context. Route-level `WeaverseNextProvider` reads this to
|
|
19
|
+
* adopt the shared theme settings store instead of creating its own.
|
|
20
|
+
*/
|
|
21
|
+
export declare const WeaverseNextRootContext: import("react").Context<WeaverseNextRootContextValue | null>;
|
|
22
|
+
/** Root theme and translation data shared across the App Router tree. */
|
|
23
|
+
export interface WeaverseNextRootProviderProps {
|
|
24
|
+
/** Application subtree, including global and route-level components. */
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
/** Root-loaded theme settings (published-mode fetch, no design-mode context). */
|
|
27
|
+
initialThemeSettings?: Record<string, unknown>;
|
|
28
|
+
/** Active-locale static-text overrides from `loadThemeSettings().merchantOverrides`. */
|
|
29
|
+
merchantOverrides?: Record<string, unknown>;
|
|
30
|
+
/** Public environment values exposed to the theme-settings store. */
|
|
31
|
+
publicEnv?: Record<string, string | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Theme default locale JSON (`loadThemeSettings().staticContent`). Falls back
|
|
34
|
+
* to `themeSchema.i18n.staticContent` when omitted.
|
|
35
|
+
*/
|
|
36
|
+
staticContent?: Record<string, unknown>;
|
|
37
|
+
/** Optional external translation function (host i18n); highest priority in `t()`. */
|
|
38
|
+
t?: TranslateFunction;
|
|
39
|
+
/** Theme schema associated with the initial settings. */
|
|
40
|
+
themeSchema?: SchemaType | WeaverseNextThemeSchema;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Root-scoped client boundary that owns the single `WeaverseNextThemeSettingsStore`
|
|
44
|
+
* for the whole app session, matching Hydrogen's `withWeaverse()` root store.
|
|
45
|
+
* Mount once in `app/layout.tsx`, above `Header`/`Footer`/global modules and any
|
|
46
|
+
* route-level `WeaverseNextProvider`.
|
|
47
|
+
*
|
|
48
|
+
* Also renders `WeaverseNextContext` with a minimal value so `useThemeSettings()`
|
|
49
|
+
* works for components mounted directly under this provider, even without a
|
|
50
|
+
* route-level `WeaverseNextProvider` above them.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <WeaverseNextRootProvider initialThemeSettings={theme.theme} themeSchema={theme.schema}>
|
|
55
|
+
* <Header />
|
|
56
|
+
* {children}
|
|
57
|
+
* <Footer />
|
|
58
|
+
* </WeaverseNextRootProvider>
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function WeaverseNextRootProvider(props: WeaverseNextRootProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
//# sourceMappingURL=root-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-provider.d.ts","sourceRoot":"","sources":["../../src/root-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAA;AAOd,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC/B,MAAM,SAAS,CAAA;AAEhB,2EAA2E;AAC3E,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3C,mEAAmE;IACnE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC,oEAAoE;IACpE,kBAAkB,EAAE,8BAA8B,CAAA;IAClD,gFAAgF;IAChF,gBAAgB,EAAE,gBAAgB,CAAA;CACnC;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,8DACsB,CAAA;AAE1D,yEAAyE;AACzE,MAAM,WAAW,6BAA6B;IAC5C,wEAAwE;IACxE,QAAQ,EAAE,SAAS,CAAA;IACnB,iFAAiF;IACjF,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9C,wFAAwF;IACxF,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3C,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IAC9C;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvC,qFAAqF;IACrF,CAAC,CAAC,EAAE,iBAAiB,CAAA;IACrB,yDAAyD;IACzD,WAAW,CAAC,EAAE,UAAU,GAAG,uBAAuB,CAAA;CACnD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,2CAgG5E"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Weaverse } from '@weaverse/react';
|
|
2
|
+
import { type WeaverseNextItem } from './item';
|
|
3
|
+
import type { WeaverseNextPageData, WeaverseNextRequestInfo, WeaverseNextRuntimeConfig, WeaverseNextRuntimeInternal, WeaverseNextTranslationChanges, WeaverseNextTranslationMap } from './types';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
__weaverse?: WeaverseNextRuntime;
|
|
7
|
+
__weaverses?: Record<string, WeaverseNextRuntime>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Weaverse page data with the root component resolved for rendering. */
|
|
11
|
+
export interface WeaverseNextRenderablePage extends WeaverseNextPageData {
|
|
12
|
+
/** Component item ID used as the root of the rendered page tree. */
|
|
13
|
+
rootId: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Browser runtime that adapts a Next.js loader payload to `@weaverse/react`
|
|
17
|
+
* and exposes the navigation, settings, and translation state used by Studio.
|
|
18
|
+
*/
|
|
19
|
+
export declare class WeaverseNextRuntime extends Weaverse {
|
|
20
|
+
/** Stable ID of the page owned by this runtime. */
|
|
21
|
+
pageId: string;
|
|
22
|
+
/** Mutable callbacks and stores consumed by the Studio bridge. */
|
|
23
|
+
internal: WeaverseNextRuntimeInternal;
|
|
24
|
+
/** Path, query, and locale metadata for Studio navigation. */
|
|
25
|
+
requestInfo: WeaverseNextRequestInfo;
|
|
26
|
+
/** Whether this runtime renders a component preview. */
|
|
27
|
+
isPreviewMode: boolean;
|
|
28
|
+
/** Whether this runtime renders a saved revision. */
|
|
29
|
+
isRevisionPreview: boolean;
|
|
30
|
+
/** Component type rendered in section preview mode. */
|
|
31
|
+
sectionType?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Translation map received from Builder in design mode, keyed by item ID.
|
|
34
|
+
* `WeaverseNextItem.getSnapShot()` overlays these onto the data handed to
|
|
35
|
+
* components, so translations render without mutating the base `_store`.
|
|
36
|
+
*/
|
|
37
|
+
translationMap: WeaverseNextTranslationMap;
|
|
38
|
+
/** Locale associated with the item-level translation sidecar. */
|
|
39
|
+
translationLocale: string;
|
|
40
|
+
/** Weaverse language ID used when saving translation changes. */
|
|
41
|
+
translationLanguageId: string;
|
|
42
|
+
/**
|
|
43
|
+
* Fresh page data captured while React was rendering. Runtime reuse happens
|
|
44
|
+
* inside the renderer's render phase (`useMemo`), where applying it through
|
|
45
|
+
* `setProjectData()` would emit item updates to `useSyncExternalStore`
|
|
46
|
+
* subscribers mid-render. The renderer applies it post-commit via
|
|
47
|
+
* `flushRenderPhaseUpdates()`. Never set on design-mode runtimes — the live
|
|
48
|
+
* Studio tree owns the page data there.
|
|
49
|
+
*/
|
|
50
|
+
pendingProjectData?: WeaverseNextRenderablePage;
|
|
51
|
+
/**
|
|
52
|
+
* Reused item instances whose data was refreshed while this runtime was
|
|
53
|
+
* constructed during render (core `initProject()` calls `setData()` on
|
|
54
|
+
* them). Their data is already fresh; only the subscriber notification was
|
|
55
|
+
* deferred to `flushRenderPhaseUpdates()`.
|
|
56
|
+
*/
|
|
57
|
+
pendingItemUpdates: WeaverseNextItem[];
|
|
58
|
+
/** Create a browser runtime from a loaded page and its request context. */
|
|
59
|
+
constructor(config: WeaverseNextRuntimeConfig);
|
|
60
|
+
/**
|
|
61
|
+
* Pull `translationMap` / `translationLocale` / `translationLanguageId` off
|
|
62
|
+
* the current page data (Builder attaches them in design mode). Unlike
|
|
63
|
+
* Hydrogen, this also clears the sidecar to defaults when the new page data
|
|
64
|
+
* carries none, so a reused runtime / project-data swap can't leave a stale
|
|
65
|
+
* map overlaying the fresh tree.
|
|
66
|
+
*/
|
|
67
|
+
extractTranslationSidecar: () => void;
|
|
68
|
+
/**
|
|
69
|
+
* Replace the translation sidecar (Builder pushes this when translation data
|
|
70
|
+
* arrives or the active language changes) and refresh every item so their
|
|
71
|
+
* merged snapshots recompute.
|
|
72
|
+
*/
|
|
73
|
+
setTranslationSidecar: (map?: WeaverseNextTranslationMap, locale?: string, languageId?: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Update a single translatable field for one item. Assigns a new per-item
|
|
76
|
+
* entry object so `WeaverseNextItem.getSnapShot()`'s translation-ref cache
|
|
77
|
+
* invalidates, then triggers only that item's subscribers.
|
|
78
|
+
*/
|
|
79
|
+
updateTranslation: (itemId: string, key: string, originalValue: string, translatedValue: string) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Collect translation changes for the save flow. Returns `undefined` unless
|
|
82
|
+
* both the locale and language ID are set and at least one entry exists;
|
|
83
|
+
* each entry key is namespaced as `data.<field>` to match Builder.
|
|
84
|
+
*/
|
|
85
|
+
getTranslationChanges: () => WeaverseNextTranslationChanges | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Re-extract the translation sidecar whenever project data is replaced (route
|
|
88
|
+
* change / non-design reuse), before rebuilding item stores. Takes the
|
|
89
|
+
* renderable page shape (`rootId` resolved) that `getRenderablePage()` and
|
|
90
|
+
* the reuse branch pass in.
|
|
91
|
+
*/
|
|
92
|
+
setProjectData: (data: WeaverseNextRenderablePage) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Apply updates deferred off the render phase: swap in any pending page data
|
|
95
|
+
* captured on runtime reuse, then notify items whose data was refreshed
|
|
96
|
+
* during construction. The renderer calls this from a layout effect right
|
|
97
|
+
* after commit, so subscribers re-render before paint (no content flash) and
|
|
98
|
+
* without React's setState-in-render warning.
|
|
99
|
+
*/
|
|
100
|
+
flushRenderPhaseUpdates: () => void;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a browser runtime or reuse the runtime already registered for the
|
|
104
|
+
* same page and request. Reuse preserves unsaved Studio state in design mode.
|
|
105
|
+
*/
|
|
106
|
+
export declare function createWeaverseNextRuntime(config: WeaverseNextRuntimeConfig): WeaverseNextRuntime;
|
|
107
|
+
/**
|
|
108
|
+
* Bind a design-mode runtime to the global Builder Studio bridge.
|
|
109
|
+
*
|
|
110
|
+
* @returns `true` when Studio was initialized or refreshed, otherwise `false`.
|
|
111
|
+
*/
|
|
112
|
+
export declare function bindWeaverseNextStudioRuntime(runtime: WeaverseNextRuntime): boolean;
|
|
113
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,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