@weaverse/next 0.1.0-alpha.13 → 0.1.0-alpha.15

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.
Files changed (106) hide show
  1. package/README.md +125 -23
  2. package/dist/{chunk-MQ6N5ODA.mjs → chunk-NL22OVD7.mjs} +93 -4
  3. package/dist/chunk-NL22OVD7.mjs.map +1 -0
  4. package/dist/index.js +86 -5
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +20 -27
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/server.js +158 -2
  9. package/dist/server.js.map +1 -1
  10. package/dist/server.mjs +126 -5
  11. package/dist/server.mjs.map +1 -1
  12. package/dist/types/client.d.ts +16 -0
  13. package/dist/types/client.d.ts.map +1 -0
  14. package/dist/types/hooks.d.ts +20 -0
  15. package/dist/types/hooks.d.ts.map +1 -0
  16. package/dist/types/index.d.ts +34 -0
  17. package/dist/types/index.d.ts.map +1 -0
  18. package/dist/types/item.d.ts +54 -0
  19. package/dist/types/item.d.ts.map +1 -0
  20. package/dist/types/loader.d.ts +25 -0
  21. package/dist/types/loader.d.ts.map +1 -0
  22. package/dist/types/main.d.ts +11 -0
  23. package/dist/types/main.d.ts.map +1 -0
  24. package/dist/types/provider.d.ts +82 -0
  25. package/dist/types/provider.d.ts.map +1 -0
  26. package/dist/types/registry.d.ts +15 -0
  27. package/dist/types/registry.d.ts.map +1 -0
  28. package/dist/types/renderer.d.ts +20 -0
  29. package/dist/types/renderer.d.ts.map +1 -0
  30. package/dist/types/request-info.d.ts +8 -0
  31. package/dist/types/request-info.d.ts.map +1 -0
  32. package/dist/types/revalidate-item.d.ts +81 -0
  33. package/dist/types/revalidate-item.d.ts.map +1 -0
  34. package/dist/types/root-provider.d.ts +61 -0
  35. package/dist/types/root-provider.d.ts.map +1 -0
  36. package/dist/types/runtime.d.ts +113 -0
  37. package/dist/types/runtime.d.ts.map +1 -0
  38. package/dist/types/seo.d.ts +55 -0
  39. package/dist/types/seo.d.ts.map +1 -0
  40. package/dist/types/server/configs.d.ts +27 -0
  41. package/dist/types/server/configs.d.ts.map +1 -0
  42. package/dist/types/server/normalize-page-url.d.ts +19 -0
  43. package/dist/types/server/normalize-page-url.d.ts.map +1 -0
  44. package/dist/types/server/revalidate-handler.d.ts +55 -0
  45. package/dist/types/server/revalidate-handler.d.ts.map +1 -0
  46. package/dist/types/server/server-client.d.ts +21 -0
  47. package/dist/types/server/server-client.d.ts.map +1 -0
  48. package/dist/types/server.d.ts +19 -0
  49. package/dist/types/server.d.ts.map +1 -0
  50. package/dist/types/studio-bridge.d.ts +16 -0
  51. package/dist/types/studio-bridge.d.ts.map +1 -0
  52. package/dist/types/studio-connect.d.ts +27 -0
  53. package/dist/types/studio-connect.d.ts.map +1 -0
  54. package/dist/types/studio-router.d.ts +50 -0
  55. package/dist/types/studio-router.d.ts.map +1 -0
  56. package/dist/types/studio-script-src.d.ts +12 -0
  57. package/dist/types/studio-script-src.d.ts.map +1 -0
  58. package/dist/types/theme-settings-store.d.ts +17 -0
  59. package/dist/types/theme-settings-store.d.ts.map +1 -0
  60. package/dist/types/translation-context.d.ts +156 -0
  61. package/dist/types/translation-context.d.ts.map +1 -0
  62. package/dist/types/translation-store.d.ts +44 -0
  63. package/dist/types/translation-store.d.ts.map +1 -0
  64. package/dist/types/types.d.ts +661 -0
  65. package/dist/types/types.d.ts.map +1 -0
  66. package/dist/types/use-weaverse-next-studio.d.ts +34 -0
  67. package/dist/types/use-weaverse-next-studio.d.ts.map +1 -0
  68. package/dist/types/utils.d.ts +12 -0
  69. package/dist/types/utils.d.ts.map +1 -0
  70. package/package.json +7 -6
  71. package/src/client.ts +101 -0
  72. package/src/hooks.ts +50 -0
  73. package/src/index.ts +153 -0
  74. package/src/item.ts +151 -0
  75. package/src/loader.ts +135 -0
  76. package/src/main.tsx +45 -0
  77. package/src/provider.tsx +225 -0
  78. package/src/registry.ts +63 -0
  79. package/src/renderer.tsx +99 -0
  80. package/src/request-info.ts +95 -0
  81. package/src/revalidate-item.ts +210 -0
  82. package/src/root-provider.tsx +181 -0
  83. package/src/runtime.ts +521 -0
  84. package/src/seo.ts +157 -0
  85. package/src/server/configs.ts +182 -0
  86. package/src/server/normalize-page-url.ts +65 -0
  87. package/src/server/revalidate-handler.ts +357 -0
  88. package/src/server/server-client.ts +727 -0
  89. package/src/server.ts +67 -0
  90. package/src/studio-bridge.tsx +82 -0
  91. package/src/studio-connect.tsx +88 -0
  92. package/src/studio-router.ts +85 -0
  93. package/src/studio-script-src.ts +128 -0
  94. package/src/theme-settings-store.ts +46 -0
  95. package/src/translation-context.tsx +299 -0
  96. package/src/translation-store.ts +69 -0
  97. package/src/types.ts +748 -0
  98. package/src/use-weaverse-next-studio.tsx +106 -0
  99. package/src/utils.ts +37 -0
  100. package/dist/chunk-MQ6N5ODA.mjs.map +0 -1
  101. package/dist/index.d.mts +0 -592
  102. package/dist/index.d.ts +0 -592
  103. package/dist/seo-CrEFl_Up.d.mts +0 -516
  104. package/dist/seo-CrEFl_Up.d.ts +0 -516
  105. package/dist/server.d.mts +0 -100
  106. package/dist/server.d.ts +0 -100
@@ -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,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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,20 @@
1
+ import type { WeaverseNextClient, WeaverseNextLoaderData } from './types';
2
+ /** Page payload, client, and connector data accepted by the Next renderer. */
3
+ export interface WeaverseNextRendererProps {
4
+ /** Client to render from. Defaults to the provider's client. */
5
+ client?: WeaverseNextClient;
6
+ /** Page payload to render. Defaults to `client.data`. */
7
+ data?: WeaverseNextLoaderData | null;
8
+ /** Data-connector context for `{{...}}` template replacement. */
9
+ dataContext?: Record<string, unknown>;
10
+ }
11
+ /**
12
+ * Render a serialized Weaverse page tree through `@weaverse/react` primitives.
13
+ *
14
+ * Reads the client/page data supplied by {@link WeaverseNextProvider} when no
15
+ * props are passed, or accepts an explicit `client` + `data` for standalone use. Builds a
16
+ * framework-neutral `Weaverse` core instance (no React Router hooks) and hands
17
+ * it to the shared `WeaverseRoot`.
18
+ */
19
+ export declare const WeaverseNextRenderer: import("react").MemoExoticComponent<(props: WeaverseNextRendererProps) => import("react/jsx-runtime").JSX.Element | null>;
20
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/renderer.tsx"],"names":[],"mappings":"AAMA,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,oDA+ChC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { WeaverseNextRequestContext, WeaverseNextRequestInfo } from './types';
2
+ /**
3
+ * Build the Hydrogen-like request info shape consumed by the Studio bridge.
4
+ * Duplicate query keys keep the last value, matching `URLSearchParams` iteration
5
+ * assignment and Hydrogen's practical query-object behavior.
6
+ */
7
+ export declare function buildWeaverseNextRequestInfo(context?: WeaverseNextRequestContext): WeaverseNextRequestInfo;
8
+ //# 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;AAwEhB;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,CAAC,EAAE,0BAA0B,GACnC,uBAAuB,CAYzB"}
@@ -0,0 +1,81 @@
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=`/`?weaverseApiKey=`
12
+ * must never influence server config resolution (see `getWeaverseNextConfigs`).
13
+ * - Transient: draft-item and RSC transport params never describe route identity.
14
+ */
15
+ export declare const DENIED_ROUTE_CONTEXT_PARAMS: string[];
16
+ /** i18n fields allowed to cross the browser boundary. */
17
+ export declare const ROUTE_CONTEXT_I18N_KEYS: readonly ["country", "label", "language", "locale", "pathPrefix"];
18
+ /**
19
+ * JSON-safe route subset that may cross the browser boundary alongside the
20
+ * draft item. Never carries headers, cookies, auth, env, project ID, Studio
21
+ * host, API keys/bases, commerce clients, the request context, runtime, or
22
+ * client. `search` is canonical (preserves duplicate keys); the derived
23
+ * `queries` record is intentionally omitted.
24
+ */
25
+ export interface WeaverseNextRevalidateRouteContext {
26
+ /** Route handle used for page assignment. */
27
+ handle?: string;
28
+ /** Public locale and market identity allowed across the browser boundary. */
29
+ i18n?: Pick<WeaverseNextI18n, 'country' | 'label' | 'language' | 'locale' | 'pathPrefix'>;
30
+ /** Weaverse page type resolved by the active route. */
31
+ pageType?: PageType;
32
+ /** Canonical same-origin route pathname. */
33
+ pathname: string;
34
+ /** Sanitized serialized query string, including the leading `?` when set. */
35
+ search: string;
36
+ }
37
+ /**
38
+ * Minimal runtime surface the in-place apply needs. Structural (not the
39
+ * concrete `WeaverseNextRuntime` class) so unit tests can drive it with a
40
+ * plain mock. `requestInfo` stays optional: a real `WeaverseNextRuntime`
41
+ * always supplies it, but when absent the client omits `routeContext` and the
42
+ * legacy `{ draftItem }` request is preserved.
43
+ */
44
+ export interface RevalidateItemRuntimeLike {
45
+ /** Live item stores keyed by Weaverse item ID. */
46
+ itemInstances: Map<string, {
47
+ /** Merge refreshed loader data into the live item store. */
48
+ setData: (update: Record<string, unknown>) => unknown;
49
+ }>;
50
+ /** Active route identity used to construct the optional revalidation payload. */
51
+ requestInfo?: WeaverseNextRequestInfo;
52
+ }
53
+ /**
54
+ * Strip denied (server-owned/transient) controls from a `search` string and
55
+ * re-serialize it. Preserves ordinary application queries, duplicate keys,
56
+ * encoded Unicode, and mode controls (`isDesignMode`, `isPreviewMode`,
57
+ * `__revisionId`, `sectionType`). Returns `''` or a `?`-prefixed string.
58
+ */
59
+ export declare function sanitizeRouteContextSearch(search: string): string;
60
+ /**
61
+ * Build the sanitized {@link WeaverseNextRevalidateRouteContext} from the
62
+ * active runtime's request info. Returns `undefined` without a usable pathname
63
+ * so the caller omits `routeContext` and keeps the legacy request. This is not
64
+ * the security boundary — the route handler re-validates and re-sanitizes.
65
+ */
66
+ export declare function buildWeaverseNextRevalidateRouteContext(requestInfo?: WeaverseNextRequestInfo): WeaverseNextRevalidateRouteContext | undefined;
67
+ /**
68
+ * Studio per-item loader revalidation: POST the unsaved draft item (and, when
69
+ * the runtime exposes route context, a sanitized `routeContext`) to the app's
70
+ * revalidate route (see `createWeaverseNextRevalidateHandler`) and apply the
71
+ * returned `loaderData` to the live item instance in place.
72
+ *
73
+ * No `router.refresh()` is involved, so the RSC tree is never re-applied — no
74
+ * page remount, no scroll reset, and the draft payload never touches the URL.
75
+ *
76
+ * Throws on any failure (missing route, non-OK response, unknown item) so the
77
+ * Builder Studio bridge can detect the miss and fall back to its legacy
78
+ * refresh-based revalidation for this window.
79
+ */
80
+ export declare function revalidateWeaverseNextItem(runtime: RevalidateItemRuntimeLike, draftItem: WeaverseNextComponentData, endpoint?: string): Promise<void>;
81
+ //# 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,K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,CAAC,CAgCf"}
@@ -0,0 +1,61 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type TranslateFunction } from './translation-context';
3
+ import { TranslationStore } from './translation-store';
4
+ import type { WeaverseNextThemeSchema, WeaverseNextThemeSettingsStore } from './types';
5
+ /** Root-scoped theme and translation stores adopted by route providers. */
6
+ export interface WeaverseNextRootContextValue {
7
+ /** Active-locale static-text overrides shared with route-level providers. */
8
+ merchantOverrides?: Record<string, unknown>;
9
+ /** Theme default locale JSON shared with route-level providers. */
10
+ staticContent: Record<string, unknown>;
11
+ /** Root-scoped external store shared with route-level providers. */
12
+ themeSettingsStore: WeaverseNextThemeSettingsStore;
13
+ /** Single live design-mode static-text override store for the whole session. */
14
+ translationStore: TranslationStore;
15
+ }
16
+ /**
17
+ * Ambient root-scoped context. Route-level `WeaverseNextProvider` reads this to
18
+ * adopt the shared theme settings store instead of creating its own.
19
+ */
20
+ export declare const WeaverseNextRootContext: import("react").Context<WeaverseNextRootContextValue | null>;
21
+ /** Root theme and translation data shared across the App Router tree. */
22
+ export interface WeaverseNextRootProviderProps {
23
+ /** Application subtree, including global and route-level components. */
24
+ children: ReactNode;
25
+ /** Root-loaded theme settings (published-mode fetch, no design-mode context). */
26
+ initialThemeSettings?: Record<string, unknown>;
27
+ /** Active-locale static-text overrides from `loadThemeSettings().merchantOverrides`. */
28
+ merchantOverrides?: Record<string, unknown>;
29
+ /** Public environment values exposed to the theme-settings store. */
30
+ publicEnv?: Record<string, string | undefined>;
31
+ /**
32
+ * Theme default locale JSON (`loadThemeSettings().staticContent`). Falls back
33
+ * to `themeSchema.i18n.staticContent` when omitted.
34
+ */
35
+ staticContent?: Record<string, unknown>;
36
+ /** Optional external translation function (host i18n); highest priority in `t()`. */
37
+ t?: TranslateFunction;
38
+ /** Theme schema associated with the initial settings. */
39
+ themeSchema?: WeaverseNextThemeSchema;
40
+ }
41
+ /**
42
+ * Root-scoped client boundary that owns the single `WeaverseNextThemeSettingsStore`
43
+ * for the whole app session, matching Hydrogen's `withWeaverse()` root store.
44
+ * Mount once in `app/layout.tsx`, above `Header`/`Footer`/global modules and any
45
+ * route-level `WeaverseNextProvider`.
46
+ *
47
+ * Also renders `WeaverseNextContext` with a minimal value so `useThemeSettings()`
48
+ * works for components mounted directly under this provider, even without a
49
+ * route-level `WeaverseNextProvider` above them.
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * <WeaverseNextRootProvider initialThemeSettings={theme.theme} themeSchema={theme.schema}>
54
+ * <Header />
55
+ * {children}
56
+ * <Footer />
57
+ * </WeaverseNextRootProvider>
58
+ * ```
59
+ */
60
+ export declare function WeaverseNextRootProvider(props: WeaverseNextRootProviderProps): import("react/jsx-runtime").JSX.Element;
61
+ //# 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,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,uBAAuB,CAAA;CACtC;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,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM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iBAAiB,GACf,QAAQ,MAAM,EACd,KAAK,MAAM,EACX,eAAe,MAAM,EACrB,iBAAiB,MAAM,UAcxB;IAED;;;;OAIG;IACH,qBAAqB,QAAO,8BAA8B,GAAG,SAAS,CAsBrE;IAED;;;;;OAKG;IACH,cAAc,GAAI,MAAM,0BAA0B,UAIjD;IAED;;;;;;OAMG;IACH,uBAAuB,aActB;CACF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,yBAAyB,GAChC,mBAAmB,CA2FrB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,mBAAmB,WAwCzE"}
@@ -0,0 +1,55 @@
1
+ import type { PageSEOData } from '@weaverse/schema';
2
+ import type { Metadata } from 'next';
3
+ import type { WeaverseNextLoaderData, WeaverseNextPageData } from './types';
4
+ /** Object containing an optional Weaverse page for SEO extraction. */
5
+ export interface WeaverseNextSeoPageContainer {
6
+ /** Page whose published SEO fields should be formatted. */
7
+ page?: WeaverseNextPageData | null;
8
+ }
9
+ /** Input accepted by {@link getWeaverseNextSeoMetadata}. */
10
+ export type WeaverseNextSeoInput = WeaverseNextLoaderData | WeaverseNextPageData | WeaverseNextSeoPageContainer | null | undefined;
11
+ /** Open Graph metadata accepted by Next.js's `Metadata` API. */
12
+ export type NextOpenGraph = NonNullable<Metadata['openGraph']>;
13
+ /** Twitter card metadata accepted by Next.js's `Metadata` API. */
14
+ export type NextTwitter = NonNullable<Metadata['twitter']>;
15
+ /**
16
+ * Weaverse page SEO expressed as a subset of Next's `Metadata`. Assignable to
17
+ * `Metadata` as-is: `const metadata: Metadata = getWeaverseNextSeoMetadata(data)`.
18
+ */
19
+ export interface WeaverseNextSeoMetadata {
20
+ /** Canonical URL settings for Next's metadata API. */
21
+ alternates?: {
22
+ /** Preferred URL for search indexing. */
23
+ canonical?: string;
24
+ };
25
+ /** Page meta description. */
26
+ description?: string;
27
+ /** Page meta keywords. */
28
+ keywords?: string;
29
+ /** Open Graph metadata normalized to Next's supported union. */
30
+ openGraph?: NextOpenGraph;
31
+ /** Search crawler indexing and link-following directives. */
32
+ robots: {
33
+ /** Whether crawlers may follow links on the page. */
34
+ follow: boolean;
35
+ /** Whether crawlers may index the page. */
36
+ index: boolean;
37
+ };
38
+ /** Page title. */
39
+ title?: string;
40
+ /** Twitter card metadata normalized for Next's metadata API. */
41
+ twitter?: NextTwitter;
42
+ }
43
+ /**
44
+ * Convert Builder SEO fields into metadata accepted by Next.js.
45
+ *
46
+ * Unsupported Open Graph product types and incomplete Twitter app/player
47
+ * cards are safely downgraded to renderable Next.js variants.
48
+ */
49
+ export declare function formatWeaverseNextSeoMetadata(seo: PageSEOData | null | undefined): WeaverseNextSeoMetadata;
50
+ /**
51
+ * Read page SEO from loader data or a page payload and format it for Next.js
52
+ * `generateMetadata`. Missing data returns indexable/followable robot defaults.
53
+ */
54
+ export declare function getWeaverseNextSeoMetadata(data: WeaverseNextSeoInput): WeaverseNextSeoMetadata;
55
+ //# sourceMappingURL=seo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seo.d.ts","sourceRoot":"","sources":["../../src/seo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAE3E,sEAAsE;AACtE,MAAM,WAAW,4BAA4B;IAC3C,2DAA2D;IAC3D,IAAI,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAA;CACnC;AAED,4DAA4D;AAC5D,MAAM,MAAM,oBAAoB,GAC5B,sBAAsB,GACtB,oBAAoB,GACpB,4BAA4B,GAC5B,IAAI,GACJ,SAAS,CAAA;AAEb,gEAAgE;AAChE,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAA;AAE9D,kEAAkE;AAClE,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAA;AAE1D;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,sDAAsD;IACtD,UAAU,CAAC,EAAE;QACX,yCAAyC;QACzC,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,6BAA6B;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,6DAA6D;IAC7D,MAAM,EAAE;QACN,qDAAqD;QACrD,MAAM,EAAE,OAAO,CAAA;QACf,2CAA2C;QAC3C,KAAK,EAAE,OAAO,CAAA;KACf,CAAA;IACD,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gEAAgE;IAChE,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB;AA+BD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAClC,uBAAuB,CAiDzB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,oBAAoB,GACzB,uBAAuB,CASzB"}
@@ -0,0 +1,27 @@
1
+ import type { WeaverseNextBaseConfigs, WeaverseNextRequestContext } from '../types';
2
+ /**
3
+ * Extract the request search params from the explicit Next request context.
4
+ * Prefers `searchParams`, falls back to parsing `url`.
5
+ */
6
+ export declare function getContextSearchParams(context?: WeaverseNextRequestContext): URLSearchParams;
7
+ /** Overrides used while resolving request-scoped Weaverse configuration. */
8
+ export interface ResolveConfigsOptions {
9
+ /** Environment values; missing keys fall back to `process.env`. */
10
+ env?: Record<string, string | undefined>;
11
+ /** Public data API base override. */
12
+ weaverseApiBase?: string;
13
+ /** Studio origin override. */
14
+ weaverseHost?: string;
15
+ /** Studio asset version override. */
16
+ weaverseVersion?: string;
17
+ }
18
+ /**
19
+ * Derive Weaverse configs from the request context and env, close to Hydrogen's
20
+ * `getWeaverseConfigs`. Resolves the trusted host, public API base, design /
21
+ * preview / revision flags, and public env — but never resolves the final
22
+ * `projectId` (that priority chain, which may call an async resolver, lives in
23
+ * the server client). Query/env projectId candidates are returned for the
24
+ * client to combine with function/string inputs.
25
+ */
26
+ export declare function getWeaverseNextConfigs(context?: WeaverseNextRequestContext, options?: ResolveConfigsOptions): WeaverseNextBaseConfigs;
27
+ //# sourceMappingURL=configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../src/server/configs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,UAAU,CAAA;AA6CjB;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,CAAC,EAAE,0BAA0B,GACnC,eAAe,CAWjB;AAkCD,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,mEAAmE;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACxC,qCAAqC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,qCAAqC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,CAAC,EAAE,0BAA0B,EACpC,OAAO,GAAE,qBAA0B,GAClC,uBAAuB,CA2DzB"}
@@ -0,0 +1,19 @@
1
+ import type { WeaverseNextRequestContext } from '../types';
2
+ /**
3
+ * Normalize the storefront URL sent in the Builder page API request body.
4
+ *
5
+ * The Builder reads only the pathname (locale/type/handle fallback) and the
6
+ * Weaverse/Studio control params from this URL, so keep exactly those and drop
7
+ * tracking params. Params are sorted for a stable, cache-friendly string.
8
+ *
9
+ * Ported from `@weaverse/hydrogen`'s `normalizePageUrl`, but tolerant of a
10
+ * relative URL (Next route handlers may only know the pathname).
11
+ */
12
+ export declare function normalizeNextPageUrl(url: string): string;
13
+ /**
14
+ * Build an absolute-ish request URL string from the explicit request context,
15
+ * preferring `url`, then `pathname` + `searchParams`. Used as the input to
16
+ * {@link normalizeNextPageUrl}.
17
+ */
18
+ export declare function resolveRequestUrl(context?: WeaverseNextRequestContext): string;
19
+ //# sourceMappingURL=normalize-page-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-page-url.d.ts","sourceRoot":"","sources":["../../../src/server/normalize-page-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AAa1D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAqBxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,0BAA0B,GACnC,MAAM,CAWR"}
@@ -0,0 +1,55 @@
1
+ import { type WeaverseNextRevalidateRouteContext } from '../revalidate-item';
2
+ import type { WeaverseNextComponentData, WeaverseNextRequestContext, WeaverseNextServerClient } from '../types';
3
+ /** Configuration for the App Router item-revalidation handler. */
4
+ export interface WeaverseNextRevalidateHandlerConfig {
5
+ /**
6
+ * Reuse the app's server-client factory so the loader runs with the same
7
+ * component registry and commerce (storefront) context as page loads.
8
+ *
9
+ * The optional second argument is the validated, same-origin route context
10
+ * reconstructed from the request body. It is `undefined` for legacy bodies
11
+ * that carry no `routeContext`, so a one-argument `(request) => client`
12
+ * callback remains valid. Consumers must still source project ID, Studio
13
+ * host, API bases/keys, and env from server config — never from this
14
+ * browser-provided context.
15
+ */
16
+ getClient: (request: Request, requestContext?: WeaverseNextRequestContext) => Promise<WeaverseNextServerClient> | WeaverseNextServerClient;
17
+ }
18
+ /** POST body accepted by the revalidate route. */
19
+ export interface WeaverseNextRevalidateRequestBody {
20
+ /** Unsaved Studio item settings to pass to the registered component loader. */
21
+ draftItem: WeaverseNextComponentData;
22
+ /** Public route identity used to reconstruct the loader request context. */
23
+ routeContext?: WeaverseNextRevalidateRouteContext;
24
+ }
25
+ /** App Router handler returned for Studio item revalidation requests. */
26
+ export interface WeaverseNextRevalidateHandler {
27
+ /** Handle a Studio request to rerun one registered component loader. */
28
+ POST: (request: Request) => Promise<Response>;
29
+ }
30
+ /**
31
+ * Create the Studio per-item revalidation route handler.
32
+ *
33
+ * Studio design-mode edits to loader-backed inputs (e.g. resource pickers) need
34
+ * fresh server loader data for a single item. Re-running it through
35
+ * `router.refresh()` re-applies the whole RSC tree — and the draft-item query
36
+ * rewrite changes the App Router page segment key, remounting the page and
37
+ * resetting scroll. This handler runs just the edited component's `loader`
38
+ * with the unsaved draft settings and returns the payload for an in-place
39
+ * client update (see the `2026-07-02--next-item-revalidation` spec).
40
+ *
41
+ * Security: only registered component types are executable, the handler never
42
+ * persists anything, and responses are `no-store`. Exposure is equivalent to
43
+ * the existing `weaverseDraftItem` URL param, which already lets any visitor
44
+ * run design-mode loaders with arbitrary draft settings.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * // app/api/weaverse/revalidate/route.ts
49
+ * export const { POST } = createWeaverseNextRevalidateHandler({
50
+ * getClient: () => getWeaverseServerClient(Promise.resolve({})),
51
+ * })
52
+ * ```
53
+ */
54
+ export declare function createWeaverseNextRevalidateHandler(config: WeaverseNextRevalidateHandlerConfig): WeaverseNextRevalidateHandler;
55
+ //# sourceMappingURL=revalidate-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revalidate-handler.d.ts","sourceRoot":"","sources":["../../../src/server/revalidate-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,kCAAkC,EACxC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EACV,yBAAyB,EAEzB,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,UAAU,CAAA;AAsBjB,kEAAkE;AAClE,MAAM,WAAW,mCAAmC;IAClD;;;;;;;;;;OAUG;IACH,SAAS,EAAE,CACT,OAAO,EAAE,OAAO,EAChB,cAAc,CAAC,EAAE,0BAA0B,KACxC,OAAO,CAAC,wBAAwB,CAAC,GAAG,wBAAwB,CAAA;CAClE;AAED,kDAAkD;AAClD,MAAM,WAAW,iCAAiC;IAChD,+EAA+E;IAC/E,SAAS,EAAE,yBAAyB,CAAA;IACpC,4EAA4E;IAC5E,YAAY,CAAC,EAAE,kCAAkC,CAAA;CAClD;AAoMD,yEAAyE;AACzE,MAAM,WAAW,6BAA6B;IAC5C,wEAAwE;IACxE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,mCAAmC,GAC1C,6BAA6B,CAqE/B"}
@@ -0,0 +1,21 @@
1
+ import type { WeaverseNextServerClient, WeaverseNextServerClientConfig } from '../types';
2
+ /**
3
+ * Create a server-side {@link WeaverseNextServerClient} for Next.js App Router
4
+ * routes / server components.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * let weaverse = createWeaverseNextServerClient({
9
+ * projectId: process.env.WEAVERSE_PROJECT_ID,
10
+ * components,
11
+ * commerce: { storefront },
12
+ * requestContext: { url, headers, searchParams, i18n },
13
+ * cache: { revalidate: 60, tags: ['weaverse'] },
14
+ * })
15
+ * let data = await weaverse.loadPage({ type: 'INDEX' })
16
+ * let theme = await weaverse.loadThemeSettings()
17
+ * ```
18
+ */
19
+ export declare function createWeaverseNextServerClient(config: WeaverseNextServerClientConfig): WeaverseNextServerClient;
20
+ export { getContextSearchParams } from './configs';
21
+ //# sourceMappingURL=server-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-client.d.ts","sourceRoot":"","sources":["../../../src/server/server-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAgBV,wBAAwB,EACxB,8BAA8B,EAM/B,MAAM,UAAU,CAAA;AAsqBjB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,8BAA8B,GACrC,wBAAwB,CAE1B;AAED,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Server-only Weaverse APIs for Next.js App Router server components and route
3
+ * handlers.
4
+ *
5
+ * When migrating from Hydrogen's `context.weaverse`, create a request-scoped
6
+ * client with {@link createWeaverseNextServerClient}, then call `loadPage()` or
7
+ * `loadThemeSettings()`. Keep rendering providers and components imported from
8
+ * the root `@weaverse/next` entrypoint.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ export type { WeaverseNextRevalidateRouteContext } from './revalidate-item';
13
+ export { formatWeaverseNextSeoMetadata, getWeaverseNextSeoMetadata, type NextOpenGraph, type NextTwitter, type WeaverseNextSeoInput, type WeaverseNextSeoMetadata, type WeaverseNextSeoPageContainer, } from './seo';
14
+ export { getWeaverseNextConfigs, type ResolveConfigsOptions, } from './server/configs';
15
+ export { normalizeNextPageUrl, resolveRequestUrl, } from './server/normalize-page-url';
16
+ export { createWeaverseNextRevalidateHandler, type WeaverseNextRevalidateHandler, type WeaverseNextRevalidateHandlerConfig, type WeaverseNextRevalidateRequestBody, } from './server/revalidate-handler';
17
+ export { createWeaverseNextServerClient } from './server/server-client';
18
+ export type { WeaverseNextBaseConfigs, WeaverseNextCacheConfig, WeaverseNextClient, WeaverseNextCommerceContext, WeaverseNextComponent, WeaverseNextComponentData, WeaverseNextComponentLoaderArgs, WeaverseNextComponentProps, WeaverseNextConfigs, WeaverseNextCustomPageEntry, WeaverseNextFetchCustomPagesOptions, WeaverseNextFetchOptions, WeaverseNextI18n, WeaverseNextLoaderData, WeaverseNextLoadPageInput, WeaverseNextPageAssignment, WeaverseNextPageData, WeaverseNextProjectId, WeaverseNextRequestContext, WeaverseNextServerClient, WeaverseNextServerClientConfig, WeaverseNextServerLoadPageInput, WeaverseNextStorefront, WeaverseNextThemeSchema, WeaverseNextThemeSchemaGroup, WeaverseNextThemeSchemaInput, WeaverseNextThemeSettingsOptions, WeaverseNextThemeSettingsResponse, } from './types';
19
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EAAE,kCAAkC,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,GAClC,MAAM,OAAO,CAAA;AACd,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,mCAAmC,EACnC,KAAK,6BAA6B,EAClC,KAAK,mCAAmC,EACxC,KAAK,iCAAiC,GACvC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAA;AACvE,YAAY,EACV,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,yBAAyB,EACzB,+BAA+B,EAC/B,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAC3B,mCAAmC,EACnC,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,sBAAsB,EACtB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,iCAAiC,GAClC,MAAM,SAAS,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { type WeaverseNextRuntime } from './runtime';
2
+ import type { WeaverseNextRuntimeInternal } from './types';
3
+ /** Runtime and host callbacks attached to the Builder Studio bridge. */
4
+ export interface WeaverseNextStudioBridgeProps {
5
+ /** Preview navigation callback. */
6
+ navigate?: WeaverseNextRuntimeInternal['navigate'];
7
+ /** Whole-route refresh callback used as a legacy fallback. */
8
+ revalidate?: WeaverseNextRuntimeInternal['revalidate'];
9
+ /** Preferred per-item loader revalidation callback. */
10
+ revalidateItem?: WeaverseNextRuntimeInternal['revalidateItem'];
11
+ /** Browser runtime to initialize or refresh in Studio. */
12
+ runtime: WeaverseNextRuntime;
13
+ }
14
+ /** Page-level Studio runtime binder. */
15
+ export declare function WeaverseNextStudioBridge(props: WeaverseNextStudioBridgeProps): null;
16
+ //# sourceMappingURL=studio-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio-bridge.d.ts","sourceRoot":"","sources":["../../src/studio-bridge.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAA;AAClB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAK1D,wEAAwE;AACxE,MAAM,WAAW,6BAA6B;IAC5C,mCAAmC;IACnC,QAAQ,CAAC,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAA;IAClD,8DAA8D;IAC9D,UAAU,CAAC,EAAE,2BAA2B,CAAC,YAAY,CAAC,CAAA;IACtD,uDAAuD;IACvD,cAAc,CAAC,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,CAAA;IAC9D,0DAA0D;IAC1D,OAAO,EAAE,mBAAmB,CAAA;CAC7B;AAED,wCAAwC;AACxC,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,QAwD5E"}
@@ -0,0 +1,27 @@
1
+ import type { WeaverseNextRequestContext } from './types';
2
+ /** Trust context used while loading the Studio bridge script. */
3
+ export interface LoadWeaverseNextStudioScriptOptions {
4
+ /** Storefront hostname; required to permit loopback Studio origins. */
5
+ storefrontHostname?: string;
6
+ }
7
+ /**
8
+ * Resolve and append the Next Studio bridge script for the given request
9
+ * context, deduping by src. SSR-safe (no-op without `document`) so it can run
10
+ * unconditionally from a root layout/error boundary before any page tree or
11
+ * runtime exists — e.g. App Router `not-found.tsx` / `error.tsx` routes.
12
+ */
13
+ export declare function loadWeaverseNextStudioScript(context?: WeaverseNextRequestContext, options?: LoadWeaverseNextStudioScriptOptions): void;
14
+ /** Props for the root-level Studio script connector. */
15
+ export interface WeaverseNextStudioConnectProps {
16
+ /** Explicit request context used to resolve Studio mode and host. */
17
+ context?: WeaverseNextRequestContext;
18
+ /** Storefront hostname; required to permit loopback Studio origins. */
19
+ storefrontHostname?: string;
20
+ }
21
+ /**
22
+ * Root-level Studio script connector for Next client boundaries. Mount once
23
+ * near the app root (e.g. root layout) so it also covers routes that never
24
+ * render `WeaverseNextRenderer`, such as `not-found.tsx` / `error.tsx`.
25
+ */
26
+ export declare function WeaverseNextStudioConnect(props: WeaverseNextStudioConnectProps): null;
27
+ //# sourceMappingURL=studio-connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio-connect.d.ts","sourceRoot":"","sources":["../../src/studio-connect.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AA0BzD,iEAAiE;AACjE,MAAM,WAAW,mCAAmC;IAClD,uEAAuE;IACvE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,CAAC,EAAE,0BAA0B,EACpC,OAAO,GAAE,mCAAwC,QAkBlD;AAED,wDAAwD;AACxD,MAAM,WAAW,8BAA8B;IAC7C,qEAAqE;IACrE,OAAO,CAAC,EAAE,0BAA0B,CAAA;IACpC,uEAAuE;IACvE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,8BAA8B,QAStC"}