@weaverse/next 0.1.0-alpha.0 → 0.1.0-alpha.10

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.
@@ -0,0 +1,517 @@
1
+ import { PageType, InspectorGroup, PageSEOData, SchemaType } from '@weaverse/schema';
2
+ import { WeaverseElement, WeaverseResourcePickerData } from '@weaverse/react';
3
+ import { ReactNode, ComponentType, ForwardRefExoticComponent } from 'react';
4
+
5
+ /**
6
+ * Minimal mutable store for design-mode static text overrides.
7
+ *
8
+ * `useSyncExternalStore`-compatible. Passed into {@link TranslationProvider}
9
+ * (from `./translation-context`) which subscribes internally and layers
10
+ * overrides on top of `merchantOverrides`/`staticContent`. The Studio bridge
11
+ * calls `updateOverrides()` via `runtime.internal.translationStore` (also
12
+ * exposed as the deprecated `runtime.internal.themeTextStore` alias) so live
13
+ * static-text edits reach the runtime — identical surface to Hydrogen's store,
14
+ * so Builder's existing static-text RPC works with `@weaverse/next` unchanged.
15
+ *
16
+ * Shape: flat `Record<string, string>` — dot-notation keys map to values
17
+ * (e.g. "cart.title" → "Shopping Cart").
18
+ */
19
+ declare class TranslationStore {
20
+ overrides: Record<string, string>;
21
+ private readonly listeners;
22
+ setOverrides: (overrides: Record<string, string>) => void;
23
+ updateOverrides: (newOverrides: Record<string, string>) => void;
24
+ getSnapshot: () => Record<string, string>;
25
+ getServerSnapshot: () => Record<string, string>;
26
+ subscribe: (callback: () => void) => () => void;
27
+ private readonly emit;
28
+ }
29
+ /**
30
+ * @deprecated Use {@link TranslationStore} instead. Kept as a backward-compatible
31
+ * alias and will remain exported for existing integrations.
32
+ */
33
+ declare const ThemeTextStore: typeof TranslationStore;
34
+ /**
35
+ * @deprecated Use {@link TranslationStore} instead. Kept as a backward-compatible
36
+ * alias and will remain exported for existing integrations.
37
+ */
38
+ type ThemeTextStore = TranslationStore;
39
+
40
+ interface WeaverseNextRequestInfo {
41
+ i18n?: WeaverseNextI18n;
42
+ pathname: string;
43
+ queries: Record<string, string | boolean>;
44
+ search: string;
45
+ }
46
+ interface WeaverseNextThemeSettingsStore {
47
+ getServerSnapshot: () => Record<string, unknown>;
48
+ getSnapshot: () => Record<string, unknown>;
49
+ publicEnv?: Record<string, string | undefined>;
50
+ schema?: WeaverseNextThemeSchema;
51
+ settings: Record<string, unknown>;
52
+ subscribe: (listener: () => void) => () => void;
53
+ updateThemeSettings: (next: Record<string, unknown>) => void;
54
+ }
55
+ /**
56
+ * Page assignment payload returned by `/api/public/project` and preserved on
57
+ * loader data so the Builder Studio save pipeline receives the same shape it
58
+ * gets from Hydrogen (`{ projectId, type, locale, handle }`, plus optional
59
+ * inherited/fallback `meta`). Kept framework-neutral: `type` accepts a known
60
+ * {@link PageType} or any string, and `meta` preserves inherited/fallback
61
+ * metadata (unknown fields included) without asserting a strict shape.
62
+ */
63
+ interface WeaverseNextPageAssignment {
64
+ handle: string;
65
+ locale: string;
66
+ /** Inherited/fallback page metadata; unknown fields preserved as-is. */
67
+ meta?: {
68
+ depth?: number;
69
+ inherited?: boolean;
70
+ sourceProjectId?: string;
71
+ [key: string]: unknown;
72
+ };
73
+ projectId: string;
74
+ type: PageType | string;
75
+ }
76
+ interface WeaverseNextRuntimeInternal {
77
+ /** Active-locale static-text overrides fetched from the API (nested). */
78
+ merchantOverrides?: Record<string, unknown>;
79
+ navigate?: (to: string, options?: {
80
+ preventScrollReset?: boolean;
81
+ } | Record<string, unknown>) => void;
82
+ pageAssignment?: WeaverseNextPageAssignment;
83
+ project?: unknown;
84
+ revalidate?: (options?: unknown) => Promise<void> | void;
85
+ /**
86
+ * Studio per-item loader revalidation. Builder feature-detects this and
87
+ * prefers it over the legacy `revalidate()` (`router.refresh()`) flow; it
88
+ * must reject on failure so Builder can fall back.
89
+ */
90
+ revalidateItem?: (draftItem: WeaverseNextComponentData) => Promise<void>;
91
+ themeSettingsStore?: WeaverseNextThemeSettingsStore;
92
+ /**
93
+ * @deprecated Use {@link WeaverseNextRuntimeInternal.translationStore}
94
+ * instead. Same instance, kept so Builder's existing `updateStaticText()`
95
+ * RPC (which reads `internal.themeTextStore`) works with Next unchanged.
96
+ */
97
+ themeTextStore?: TranslationStore;
98
+ /**
99
+ * Live design-mode static-text override store. Builder's `updateStaticText()`
100
+ * RPC mutates it via `updateOverrides()`; the `TranslationProvider` observing
101
+ * the same instance re-renders `useTranslation()` consumers.
102
+ */
103
+ translationStore?: TranslationStore;
104
+ }
105
+ interface WeaverseNextRuntimeConfig {
106
+ client?: WeaverseNextClient;
107
+ data: WeaverseNextLoaderData;
108
+ dataContext?: Record<string, unknown>;
109
+ /** Active-locale static-text overrides threaded onto `internal`. */
110
+ merchantOverrides?: Record<string, unknown>;
111
+ navigate?: WeaverseNextRuntimeInternal['navigate'];
112
+ revalidate?: WeaverseNextRuntimeInternal['revalidate'];
113
+ themeSettingsStore?: WeaverseNextThemeSettingsStore;
114
+ /** Root/route-owned translation store to attach to `internal`. */
115
+ translationStore?: TranslationStore;
116
+ }
117
+ /** A single translated field for one item. */
118
+ interface WeaverseNextTranslationMapEntry {
119
+ originalValue: string;
120
+ translatedValue: string;
121
+ }
122
+ /** Per-item translation fields, keyed by field name. */
123
+ interface WeaverseNextTranslationItemEntry {
124
+ [key: string]: WeaverseNextTranslationMapEntry;
125
+ }
126
+ /**
127
+ * Translation map sent from Builder alongside page data in design mode.
128
+ * Keyed by item ID, each value maps field names to translation entries.
129
+ */
130
+ interface WeaverseNextTranslationMap {
131
+ [itemId: string]: WeaverseNextTranslationItemEntry;
132
+ }
133
+ /** A single translation entry for save payloads. */
134
+ interface WeaverseNextTranslationEntry {
135
+ deleted?: boolean;
136
+ itemId: string;
137
+ key: string;
138
+ originalValue: string;
139
+ translatedValue: string;
140
+ }
141
+ /** Result of collecting translation changes for the save flow. */
142
+ interface WeaverseNextTranslationChanges {
143
+ entries: WeaverseNextTranslationEntry[];
144
+ languageId: string;
145
+ }
146
+ /**
147
+ * Locale/market info passed through to component loaders and the Storefront
148
+ * client. Kept structurally close to Hydrogen's `WeaverseI18n` but without the
149
+ * `@shopify/hydrogen` `I18nBase` dependency so the adapter stays framework
150
+ * neutral.
151
+ */
152
+ interface WeaverseNextI18n {
153
+ country?: string;
154
+ label?: string;
155
+ language?: string;
156
+ locale?: string;
157
+ pathPrefix?: string;
158
+ [key: string]: unknown;
159
+ }
160
+ /**
161
+ * Theme schema shape accepted by the Next adapter. Mirrors Hydrogen's
162
+ * `HydrogenThemeSchema` but keeps locale data framework-neutral via
163
+ * {@link WeaverseNextI18n} instead of Shopify Hydrogen's `I18nBase`.
164
+ */
165
+ interface WeaverseNextThemeSchemaInput {
166
+ condition?: unknown;
167
+ defaultValue?: unknown;
168
+ name?: string;
169
+ [key: string]: unknown;
170
+ }
171
+ interface WeaverseNextThemeSchemaGroup {
172
+ group?: string;
173
+ inputs?: WeaverseNextThemeSchemaInput[];
174
+ [key: string]: unknown;
175
+ }
176
+ interface WeaverseNextThemeSchema {
177
+ i18n?: {
178
+ defaultLocale?: WeaverseNextI18n;
179
+ shopLocales?: WeaverseNextI18n[];
180
+ staticContent?: Record<string, unknown>;
181
+ /** Enable the translation UI in Builder. */
182
+ translation?: boolean;
183
+ urlStructure?: 'url-path' | 'subdomain' | 'top-level-domain';
184
+ [key: string]: unknown;
185
+ };
186
+ info?: {
187
+ author?: string;
188
+ authorProfilePhoto?: string;
189
+ documentationUrl?: string;
190
+ name?: string;
191
+ supportUrl?: string;
192
+ version?: string;
193
+ [key: string]: unknown;
194
+ };
195
+ /** @deprecated Use settings instead. */
196
+ inspector?: (InspectorGroup | WeaverseNextThemeSchemaGroup)[];
197
+ settings?: (InspectorGroup | WeaverseNextThemeSchemaGroup)[];
198
+ [key: string]: unknown;
199
+ }
200
+ /**
201
+ * Minimal Storefront client shape required by component loaders. The host app
202
+ * provides this (public or private token mode); Weaverse never owns it.
203
+ */
204
+ interface WeaverseNextStorefront {
205
+ i18n?: WeaverseNextI18n;
206
+ query: (query: string, options?: unknown) => Promise<unknown>;
207
+ [key: string]: unknown;
208
+ }
209
+ /**
210
+ * App-provided commerce context. `storefront` is the only v0 must-have; cart
211
+ * and customer-account stay app-owned and are passed through untouched.
212
+ */
213
+ interface WeaverseNextCommerceContext {
214
+ cart?: unknown;
215
+ customerAccount?: unknown;
216
+ storefront?: WeaverseNextStorefront;
217
+ [key: string]: unknown;
218
+ }
219
+ /**
220
+ * Explicit, framework-neutral replacement for React Router's
221
+ * `LoaderFunctionArgs`. Built by the Next route/page from params + headers +
222
+ * searchParams instead of an implicit loader context.
223
+ */
224
+ interface WeaverseNextRequestContext {
225
+ handle?: string;
226
+ headers?: Headers;
227
+ i18n?: WeaverseNextI18n;
228
+ isDesignMode?: boolean;
229
+ isPreviewMode?: boolean;
230
+ isRevisionPreview?: boolean;
231
+ pageType?: PageType;
232
+ pathname?: string;
233
+ searchParams?: URLSearchParams;
234
+ sectionType?: string;
235
+ url?: URL | string;
236
+ [key: string]: unknown;
237
+ }
238
+ /** A single serialized item in a Weaverse page tree. */
239
+ interface WeaverseNextComponentData {
240
+ children?: WeaverseNextComponentData[] | {
241
+ id: string;
242
+ }[];
243
+ data?: Record<string, unknown>;
244
+ id: string;
245
+ /** Attached by {@link runWeaverseComponentLoaders} after a loader runs. */
246
+ loaderData?: unknown;
247
+ type: string;
248
+ [key: string]: unknown;
249
+ }
250
+ /** Serialized page tree fetched from Weaverse. */
251
+ interface WeaverseNextPageData {
252
+ id: string;
253
+ items: WeaverseNextComponentData[];
254
+ name?: string;
255
+ rootId?: string;
256
+ /** Page-level SEO metadata published by Weaverse Builder. */
257
+ seo?: PageSEOData | null;
258
+ [key: string]: unknown;
259
+ }
260
+ /**
261
+ * Top-level payload returned by `client.loadPage`. Kept close to Hydrogen's
262
+ * `WeaverseLoaderData` so registered components stay portable.
263
+ */
264
+ interface WeaverseNextLoaderData {
265
+ configs?: Record<string, unknown>;
266
+ page: WeaverseNextPageData;
267
+ pageAssignment?: WeaverseNextPageAssignment;
268
+ project?: Record<string, unknown>;
269
+ [key: string]: unknown;
270
+ }
271
+ /** Props injected into every registered Weaverse component. */
272
+ interface WeaverseNextComponentProps<L = unknown> extends Partial<WeaverseElement> {
273
+ children?: ReactNode;
274
+ className?: string;
275
+ loaderData?: L;
276
+ [key: string]: unknown;
277
+ }
278
+ /**
279
+ * Arguments passed to a component `loader`. `commerce.storefront` is the
280
+ * explicit contract; `weaverse.storefront` exists as a compatibility alias for
281
+ * Pilot-style loaders that call `weaverse.storefront.query(...)`.
282
+ */
283
+ interface WeaverseNextComponentLoaderArgs<TData = unknown> {
284
+ commerce?: WeaverseNextCommerceContext;
285
+ context?: WeaverseNextRequestContext;
286
+ data: TData;
287
+ weaverse: WeaverseNextClient;
288
+ }
289
+ /** Registered component module shape: `default` + `schema` + optional `loader`. */
290
+ interface WeaverseNextComponent<TProps extends WeaverseNextComponentProps = WeaverseNextComponentProps> {
291
+ default: ComponentType<TProps> | ForwardRefExoticComponent<TProps>;
292
+ loader?: (args: WeaverseNextComponentLoaderArgs) => Promise<unknown>;
293
+ schema: SchemaType;
294
+ }
295
+ /** Input for `client.loadPage`. The Next route maps `params` → `type/handle`. */
296
+ interface WeaverseNextLoadPageInput {
297
+ handle?: string;
298
+ locale?: string;
299
+ type?: PageType;
300
+ [key: string]: unknown;
301
+ }
302
+ interface WeaverseNextClientConfig {
303
+ commerce?: WeaverseNextCommerceContext;
304
+ components: WeaverseNextComponent[];
305
+ /**
306
+ * Injected page fetcher. v0 delegates network I/O to the host app so the
307
+ * adapter can be tested without real Weaverse API calls.
308
+ */
309
+ fetchPage?: (input: WeaverseNextLoadPageInput) => Promise<WeaverseNextLoaderData | null>;
310
+ /** Injected theme-settings fetcher. */
311
+ fetchThemeSettings?: (context?: WeaverseNextRequestContext) => Promise<unknown>;
312
+ projectId: string;
313
+ requestContext?: WeaverseNextRequestContext;
314
+ themeSchema?: WeaverseNextThemeSchema;
315
+ themeSettings?: Record<string, unknown>;
316
+ }
317
+ /**
318
+ * Request-safe client returned by {@link createWeaverseNextClient}. Holds the
319
+ * registry/config plus the currently loaded page data, and is the object passed
320
+ * to component loaders as `weaverse`.
321
+ */
322
+ interface WeaverseNextClient {
323
+ commerce?: WeaverseNextCommerceContext;
324
+ components: WeaverseNextComponent[];
325
+ /** Currently loaded page payload (set by `loadPage`). */
326
+ data: WeaverseNextLoaderData | null;
327
+ /** Data-connector context handed to the React renderer. */
328
+ dataContext: Record<string, unknown>;
329
+ loadPage: (input?: WeaverseNextLoadPageInput) => Promise<WeaverseNextLoaderData | null>;
330
+ loadThemeSettings: (context?: WeaverseNextRequestContext) => Promise<unknown>;
331
+ projectId: string;
332
+ requestContext?: WeaverseNextRequestContext;
333
+ /** Compatibility alias for `commerce.storefront`. */
334
+ storefront?: WeaverseNextStorefront;
335
+ themeSchema?: WeaverseNextThemeSchema;
336
+ themeSettings: Record<string, unknown>;
337
+ }
338
+ type WeaverseProduct = WeaverseResourcePickerData;
339
+ type WeaverseCollection = WeaverseResourcePickerData;
340
+ type WeaverseBlog = WeaverseResourcePickerData;
341
+ type WeaverseArticle = WeaverseResourcePickerData;
342
+ type WeaverseMetaObject = WeaverseResourcePickerData;
343
+ /**
344
+ * Project identifier accepted by {@link WeaverseNextServerClientConfig}. Either
345
+ * a static string or a (possibly async) resolver that reads the request
346
+ * context — matching Hydrogen's static/dynamic projectId support.
347
+ */
348
+ type WeaverseNextProjectId = string | ((context?: WeaverseNextRequestContext) => string | Promise<string> | undefined);
349
+ /** Simple Next.js fetch cache options used for published-mode requests. */
350
+ interface WeaverseNextCacheConfig {
351
+ /** Maps to Next's `fetch(..., { next: { revalidate } })`. */
352
+ revalidate?: number | false;
353
+ /** Maps to Next's `fetch(..., { next: { tags } })`. */
354
+ tags?: string[];
355
+ }
356
+ /**
357
+ * Per-request fetch options for {@link WeaverseNextServerClient.fetchWithCache}.
358
+ * Plain `RequestInit` plus the same simple Next cache knobs as
359
+ * {@link WeaverseNextCacheConfig}, so callers never need to import `next/*`.
360
+ */
361
+ interface WeaverseNextFetchOptions extends RequestInit {
362
+ revalidate?: number | false;
363
+ tags?: string[];
364
+ }
365
+ /**
366
+ * Public, client-safe Weaverse config bundle. Mirrors Hydrogen's
367
+ * `WeaverseProjectConfigs` minus server secrets — `weaverseApiKey` is never
368
+ * included so it cannot leak into serialized loader data.
369
+ */
370
+ interface WeaverseNextConfigs {
371
+ isDesignMode: boolean;
372
+ isPreviewMode: boolean;
373
+ isRevisionPreview: boolean;
374
+ projectId: string;
375
+ publicEnv: Record<string, string | undefined>;
376
+ sectionType: string;
377
+ weaverseApiBase: string;
378
+ weaverseHost: string;
379
+ weaversePublicApiBase: string;
380
+ weaverseVersion: string;
381
+ }
382
+ /**
383
+ * Resolved base configs derived from request context + env. Includes the
384
+ * server-only `weaverseApiKey`, so this stays internal to the server client and
385
+ * is never serialized into loader data.
386
+ */
387
+ interface WeaverseNextBaseConfigs {
388
+ envProjectId: string;
389
+ isDesignMode: boolean;
390
+ isPreviewMode: boolean;
391
+ isRevisionPreview: boolean;
392
+ publicEnv: Record<string, string | undefined>;
393
+ queryProjectId: string;
394
+ sectionType: string;
395
+ weaverseApiBase: string;
396
+ weaverseApiKey: string;
397
+ weaverseHost: string;
398
+ weaverseVersion: string;
399
+ }
400
+ /** Theme settings payload returned by {@link WeaverseNextServerClient.loadThemeSettings}. */
401
+ interface WeaverseNextThemeSettingsResponse {
402
+ _error?: string;
403
+ _loadFailed?: boolean;
404
+ merchantOverrides?: Record<string, unknown>;
405
+ publicEnv?: Record<string, string | undefined>;
406
+ schema?: WeaverseNextThemeSchema;
407
+ staticContent?: Record<string, unknown>;
408
+ theme?: Record<string, unknown>;
409
+ [key: string]: unknown;
410
+ }
411
+ /**
412
+ * Options for {@link WeaverseNextServerClient.loadThemeSettings}. Cache knobs
413
+ * only — the server client always reads the request context it was created
414
+ * with, so there is no per-call context override.
415
+ */
416
+ interface WeaverseNextThemeSettingsOptions extends WeaverseNextCacheConfig {
417
+ }
418
+ interface WeaverseNextCustomPageEntry {
419
+ changeFrequency?: 'daily' | 'weekly' | 'monthly';
420
+ handle: string;
421
+ lastModified: string;
422
+ locale: string | null;
423
+ path: string;
424
+ priority?: number;
425
+ }
426
+ interface WeaverseNextFetchCustomPagesOptions extends WeaverseNextCacheConfig {
427
+ limit?: number;
428
+ locale?: string;
429
+ }
430
+ /**
431
+ * Config for {@link createWeaverseNextServerClient}. Unlike
432
+ * {@link WeaverseNextClientConfig} (which delegates network I/O to injected
433
+ * fetchers), the server client performs the real Weaverse API fetch itself, so
434
+ * it accepts request context, env, and cache options instead.
435
+ */
436
+ interface WeaverseNextServerClientConfig {
437
+ cache?: WeaverseNextCacheConfig;
438
+ commerce?: WeaverseNextCommerceContext;
439
+ components: WeaverseNextComponent[];
440
+ /** Plain env map; falls back to `process.env` for any missing key. */
441
+ env?: Record<string, string | undefined>;
442
+ /** Custom `fetch` (mainly for tests); defaults to the global `fetch`. */
443
+ fetch?: typeof fetch;
444
+ /** Per-request network timeout in ms. Defaults to 10s. */
445
+ fetchTimeoutMs?: number;
446
+ projectId?: WeaverseNextProjectId;
447
+ requestContext?: WeaverseNextRequestContext;
448
+ themeSchema?: WeaverseNextThemeSchema;
449
+ themeSettings?: Record<string, unknown>;
450
+ /** Optional override for the resolved Weaverse public API base. */
451
+ weaverseApiBase?: string;
452
+ /** Optional override for the resolved Weaverse host. */
453
+ weaverseHost?: string;
454
+ weaverseVersion?: string;
455
+ }
456
+ /**
457
+ * Server-side Weaverse client returned by {@link createWeaverseNextServerClient}.
458
+ * Closes the gap with Hydrogen's `context.weaverse.loadPage(...)` by performing
459
+ * the real Weaverse API fetch in Next server components/route handlers. It is
460
+ * also assignable to {@link WeaverseNextClient} so it can be passed straight to
461
+ * `runWeaverseComponentLoaders` and the renderer/runtime.
462
+ */
463
+ interface WeaverseNextServerClient extends WeaverseNextClient {
464
+ /** Public, client-safe resolved configs (no server secrets). */
465
+ configs: WeaverseNextConfigs;
466
+ fetchCustomPages: (options?: WeaverseNextFetchCustomPagesOptions) => Promise<WeaverseNextCustomPageEntry[]>;
467
+ fetchWithCache: <T = unknown>(url: string, options?: WeaverseNextFetchOptions) => Promise<T>;
468
+ loadPage: (input?: WeaverseNextLoadPageInput) => Promise<WeaverseNextLoaderData | null>;
469
+ /**
470
+ * Load theme settings. Pass cache options (`revalidate` / `tags`) only — the
471
+ * request context is the one the client was created with, so there is no
472
+ * per-call context override. The parameter is typed broadly purely to stay
473
+ * assignable to the base {@link WeaverseNextClient.loadThemeSettings}; any
474
+ * non-cache fields are ignored.
475
+ */
476
+ loadThemeSettings: (options?: WeaverseNextThemeSettingsOptions | WeaverseNextRequestContext) => Promise<WeaverseNextThemeSettingsResponse>;
477
+ /** Resolve the effective projectId (query → function → string → env). */
478
+ resolveProjectId: () => Promise<string>;
479
+ }
480
+ /** Input for {@link WeaverseNextServerClient.loadPage}. */
481
+ interface WeaverseNextServerLoadPageInput extends WeaverseNextLoadPageInput {
482
+ /** Per-call cache override merged over the client-level `cache` config. */
483
+ cache?: WeaverseNextCacheConfig;
484
+ /** Route-level project override (multi-project), like Hydrogen. */
485
+ projectId?: string;
486
+ }
487
+
488
+ interface WeaverseNextSeoMetadata {
489
+ alternates?: {
490
+ canonical?: string;
491
+ };
492
+ description?: string;
493
+ keywords?: string;
494
+ openGraph?: {
495
+ description?: string;
496
+ images?: string[];
497
+ title?: string;
498
+ type?: string;
499
+ };
500
+ robots: {
501
+ follow: boolean;
502
+ index: boolean;
503
+ };
504
+ title?: string;
505
+ twitter?: {
506
+ card?: string;
507
+ description?: string;
508
+ images?: string[];
509
+ title?: string;
510
+ };
511
+ }
512
+ declare function formatWeaverseNextSeoMetadata(seo: PageSEOData | null | undefined): WeaverseNextSeoMetadata;
513
+ declare function getWeaverseNextSeoMetadata(data: WeaverseNextLoaderData | WeaverseNextPageData | {
514
+ page?: WeaverseNextPageData | null;
515
+ } | null | undefined): WeaverseNextSeoMetadata;
516
+
517
+ export { type WeaverseNextRuntimeInternal as A, type WeaverseNextSeoMetadata as B, type WeaverseNextServerClient as C, type WeaverseNextServerClientConfig as D, type WeaverseNextServerLoadPageInput as E, type WeaverseNextStorefront as F, type WeaverseNextThemeSchema as G, type WeaverseNextThemeSettingsOptions as H, type WeaverseNextThemeSettingsResponse as I, type WeaverseNextThemeSettingsStore as J, type WeaverseNextTranslationChanges as K, type WeaverseNextTranslationEntry as L, type WeaverseNextTranslationItemEntry as M, type WeaverseNextTranslationMap as N, type WeaverseNextTranslationMapEntry as O, type WeaverseProduct as P, formatWeaverseNextSeoMetadata as Q, getWeaverseNextSeoMetadata as R, ThemeTextStore as T, type WeaverseArticle as W, TranslationStore as a, type WeaverseBlog as b, type WeaverseCollection as c, type WeaverseMetaObject as d, type WeaverseNextBaseConfigs as e, type WeaverseNextCacheConfig as f, type WeaverseNextClient as g, type WeaverseNextClientConfig as h, type WeaverseNextCommerceContext as i, type WeaverseNextComponent as j, type WeaverseNextComponentData as k, type WeaverseNextComponentLoaderArgs as l, type WeaverseNextComponentProps as m, type WeaverseNextConfigs as n, type WeaverseNextCustomPageEntry as o, type WeaverseNextFetchCustomPagesOptions as p, type WeaverseNextFetchOptions as q, type WeaverseNextI18n as r, type WeaverseNextLoadPageInput as s, type WeaverseNextLoaderData as t, type WeaverseNextPageAssignment as u, type WeaverseNextPageData as v, type WeaverseNextProjectId as w, type WeaverseNextRequestContext as x, type WeaverseNextRequestInfo as y, type WeaverseNextRuntimeConfig as z };
@@ -0,0 +1,99 @@
1
+ import { x as WeaverseNextRequestContext, e as WeaverseNextBaseConfigs, C as WeaverseNextServerClient, k as WeaverseNextComponentData, D as WeaverseNextServerClientConfig } from './seo-CgO21rLg.mjs';
2
+ export { f as WeaverseNextCacheConfig, n as WeaverseNextConfigs, o as WeaverseNextCustomPageEntry, p as WeaverseNextFetchCustomPagesOptions, q as WeaverseNextFetchOptions, w as WeaverseNextProjectId, B as WeaverseNextSeoMetadata, E as WeaverseNextServerLoadPageInput, H as WeaverseNextThemeSettingsOptions, I as WeaverseNextThemeSettingsResponse, Q as formatWeaverseNextSeoMetadata, R as getWeaverseNextSeoMetadata } from './seo-CgO21rLg.mjs';
3
+ import '@weaverse/schema';
4
+ import '@weaverse/react';
5
+ import 'react';
6
+
7
+ interface ResolveConfigsOptions {
8
+ env?: Record<string, string | undefined>;
9
+ weaverseApiBase?: string;
10
+ weaverseHost?: string;
11
+ weaverseVersion?: string;
12
+ }
13
+ /**
14
+ * Derive Weaverse configs from the request context and env, close to Hydrogen's
15
+ * `getWeaverseConfigs`. Resolves the trusted host, public API base, design /
16
+ * preview / revision flags, and public env — but never resolves the final
17
+ * `projectId` (that priority chain, which may call an async resolver, lives in
18
+ * the server client). Query/env projectId candidates are returned for the
19
+ * client to combine with function/string inputs.
20
+ */
21
+ declare function getWeaverseNextConfigs(context?: WeaverseNextRequestContext, options?: ResolveConfigsOptions): WeaverseNextBaseConfigs;
22
+
23
+ /**
24
+ * Normalize the storefront URL sent in the Builder page API request body.
25
+ *
26
+ * The Builder reads only the pathname (locale/type/handle fallback) and the
27
+ * Weaverse/Studio control params from this URL, so keep exactly those and drop
28
+ * tracking params. Params are sorted for a stable, cache-friendly string.
29
+ *
30
+ * Ported from `@weaverse/hydrogen`'s `normalizePageUrl`, but tolerant of a
31
+ * relative URL (Next route handlers may only know the pathname).
32
+ */
33
+ declare function normalizeNextPageUrl(url: string): string;
34
+ /**
35
+ * Build an absolute-ish request URL string from the explicit request context,
36
+ * preferring `url`, then `pathname` + `searchParams`. Used as the input to
37
+ * {@link normalizeNextPageUrl}.
38
+ */
39
+ declare function resolveRequestUrl(context?: WeaverseNextRequestContext): string;
40
+
41
+ interface WeaverseNextRevalidateHandlerConfig {
42
+ /**
43
+ * Reuse the app's server-client factory so the loader runs with the same
44
+ * component registry and commerce (storefront) context as page loads.
45
+ */
46
+ getClient: (request: Request) => Promise<WeaverseNextServerClient> | WeaverseNextServerClient;
47
+ }
48
+ /** POST body accepted by the revalidate route. */
49
+ interface WeaverseNextRevalidateRequestBody {
50
+ draftItem: WeaverseNextComponentData;
51
+ }
52
+ /**
53
+ * Create the Studio per-item revalidation route handler.
54
+ *
55
+ * Studio design-mode edits to loader-backed inputs (e.g. resource pickers) need
56
+ * fresh server loader data for a single item. Re-running it through
57
+ * `router.refresh()` re-applies the whole RSC tree — and the draft-item query
58
+ * rewrite changes the App Router page segment key, remounting the page and
59
+ * resetting scroll. This handler runs just the edited component's `loader`
60
+ * with the unsaved draft settings and returns the payload for an in-place
61
+ * client update (see the `2026-07-02--next-item-revalidation` spec).
62
+ *
63
+ * Security: only registered component types are executable, the handler never
64
+ * persists anything, and responses are `no-store`. Exposure is equivalent to
65
+ * the existing `weaverseDraftItem` URL param, which already lets any visitor
66
+ * run design-mode loaders with arbitrary draft settings.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * // app/api/weaverse/revalidate/route.ts
71
+ * export const { POST } = createWeaverseNextRevalidateHandler({
72
+ * getClient: () => getWeaverseServerClient(Promise.resolve({})),
73
+ * })
74
+ * ```
75
+ */
76
+ declare function createWeaverseNextRevalidateHandler(config: WeaverseNextRevalidateHandlerConfig): {
77
+ POST: (request: Request) => Promise<Response>;
78
+ };
79
+
80
+ /**
81
+ * Create a server-side {@link WeaverseNextServerClient} for Next.js App Router
82
+ * routes / server components.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * let weaverse = createWeaverseNextServerClient({
87
+ * projectId: process.env.WEAVERSE_PROJECT_ID,
88
+ * components,
89
+ * commerce: { storefront },
90
+ * requestContext: { url, headers, searchParams, i18n },
91
+ * cache: { revalidate: 60, tags: ['weaverse'] },
92
+ * })
93
+ * let data = await weaverse.loadPage({ type: 'INDEX' })
94
+ * let theme = await weaverse.loadThemeSettings()
95
+ * ```
96
+ */
97
+ declare function createWeaverseNextServerClient(config: WeaverseNextServerClientConfig): WeaverseNextServerClient;
98
+
99
+ export { WeaverseNextBaseConfigs, type WeaverseNextRevalidateHandlerConfig, type WeaverseNextRevalidateRequestBody, WeaverseNextServerClient, WeaverseNextServerClientConfig, createWeaverseNextRevalidateHandler, createWeaverseNextServerClient, getWeaverseNextConfigs, normalizeNextPageUrl, resolveRequestUrl };