@weaverse/hydrogen 5.16.2 → 5.16.4
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/dist/index.d.mts +75 -26
- package/dist/index.d.ts +75 -26
- package/dist/index.js +183 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +181 -85
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -15,14 +15,15 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
15
15
|
/**
|
|
16
16
|
* Minimal mutable store for design-mode static text overrides.
|
|
17
17
|
*
|
|
18
|
-
* useSyncExternalStore-compatible. Passed into
|
|
18
|
+
* useSyncExternalStore-compatible. Passed into TranslationProvider which
|
|
19
19
|
* subscribes internally and merges overrides into merchantOverrides.
|
|
20
|
-
* The studio bridge calls updateOverrides() via weaverse.internal.
|
|
20
|
+
* The studio bridge calls updateOverrides() via weaverse.internal.translationStore
|
|
21
|
+
* (also exposed as the deprecated weaverse.internal.themeTextStore alias).
|
|
21
22
|
*
|
|
22
23
|
* Shape: flat Record<string, string> — dot-notation keys map to values
|
|
23
24
|
* (e.g. "cart.title" → "Shopping Cart").
|
|
24
25
|
*/
|
|
25
|
-
declare class
|
|
26
|
+
declare class TranslationStore {
|
|
26
27
|
overrides: Record<string, string>;
|
|
27
28
|
private listeners;
|
|
28
29
|
setOverrides: (overrides: Record<string, string>) => void;
|
|
@@ -32,6 +33,16 @@ declare class ThemeTextStore {
|
|
|
32
33
|
subscribe: (callback: () => void) => () => void;
|
|
33
34
|
private emit;
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use {@link TranslationStore} instead. Kept as a backward-compatible
|
|
38
|
+
* alias and will remain exported for existing integrations.
|
|
39
|
+
*/
|
|
40
|
+
declare const ThemeTextStore: typeof TranslationStore;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use {@link TranslationStore} instead. Kept as a backward-compatible
|
|
43
|
+
* alias and will remain exported for existing integrations.
|
|
44
|
+
*/
|
|
45
|
+
type ThemeTextStore = TranslationStore;
|
|
35
46
|
|
|
36
47
|
type WeaverseThemeData = {
|
|
37
48
|
theme: HydrogenThemeSettings;
|
|
@@ -74,12 +85,12 @@ declare function interpolate(template: string, variables?: Record<string, string
|
|
|
74
85
|
* Signature for a translation function.
|
|
75
86
|
*/
|
|
76
87
|
type TranslateFunction = (key: string, variables?: Record<string, string | number>) => string;
|
|
77
|
-
type
|
|
88
|
+
type TranslationValue = {
|
|
78
89
|
/**
|
|
79
90
|
* Translate a key with optional variable interpolation.
|
|
80
91
|
*
|
|
81
92
|
* Priority chain (highest wins):
|
|
82
|
-
* 1. External `t` (passed into `withWeaverse` / `
|
|
93
|
+
* 1. External `t` (passed into `withWeaverse` / `TranslationProvider`)
|
|
83
94
|
* 2. `merchantOverrides` (DB overrides for the current locale + design overrides)
|
|
84
95
|
* 3. `staticContent` (theme default JSON)
|
|
85
96
|
* 4. The key itself (fallback)
|
|
@@ -90,11 +101,16 @@ type ThemeTextValue = {
|
|
|
90
101
|
*/
|
|
91
102
|
t: TranslateFunction;
|
|
92
103
|
/** Exposed for useStudio to attach to weaverse.internal. Null in production. */
|
|
93
|
-
|
|
104
|
+
translationStore: TranslationStore | null;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated Use {@link TranslationValue.translationStore} instead. Kept as a
|
|
107
|
+
* backward-compatible alias pointing at the same store instance.
|
|
108
|
+
*/
|
|
109
|
+
themeTextStore: TranslationStore | null;
|
|
94
110
|
/** Active-locale translated keys loaded from the storefront API. */
|
|
95
111
|
merchantOverrides: Record<string, unknown> | null;
|
|
96
112
|
};
|
|
97
|
-
type
|
|
113
|
+
type TranslationProviderProps = {
|
|
98
114
|
staticContent: Record<string, unknown>;
|
|
99
115
|
merchantOverrides?: Record<string, unknown>;
|
|
100
116
|
/**
|
|
@@ -105,7 +121,13 @@ type ThemeTextProviderProps = {
|
|
|
105
121
|
*/
|
|
106
122
|
t?: TranslateFunction;
|
|
107
123
|
/** Optional store for live design-mode text overrides from the builder. */
|
|
108
|
-
|
|
124
|
+
translationStore?: TranslationStore | null;
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated Use {@link TranslationProviderProps.translationStore} instead.
|
|
127
|
+
* Still accepted for backward compatibility; ignored when `translationStore`
|
|
128
|
+
* is also provided.
|
|
129
|
+
*/
|
|
130
|
+
themeTextStore?: TranslationStore | null;
|
|
109
131
|
children: ReactNode;
|
|
110
132
|
};
|
|
111
133
|
/**
|
|
@@ -113,23 +135,40 @@ type ThemeTextProviderProps = {
|
|
|
113
135
|
*
|
|
114
136
|
* - `staticContent` – the theme's default locale JSON (from themeSchema.i18n)
|
|
115
137
|
* - `merchantOverrides` – locale-specific overrides fetched from the API
|
|
116
|
-
* - `
|
|
138
|
+
* - `translationStore` – optional store for live design-mode text overrides
|
|
139
|
+
* (the deprecated `themeTextStore` prop is accepted as a fallback)
|
|
117
140
|
*/
|
|
118
|
-
declare function
|
|
141
|
+
declare function TranslationProvider({ staticContent, merchantOverrides, t: externalT, translationStore, themeTextStore, children, }: TranslationProviderProps): react_jsx_runtime.JSX.Element;
|
|
119
142
|
/**
|
|
120
|
-
* Hook to access the
|
|
143
|
+
* Hook to access the translation `t()` function.
|
|
121
144
|
*
|
|
122
|
-
* Must be used inside a component wrapped by `withWeaverse` or `
|
|
145
|
+
* Must be used inside a component wrapped by `withWeaverse` or `TranslationProvider`.
|
|
123
146
|
*
|
|
124
147
|
* @example
|
|
125
148
|
* ```tsx
|
|
126
149
|
* function CartTitle() {
|
|
127
|
-
* const { t } =
|
|
150
|
+
* const { t } = useTranslation()
|
|
128
151
|
* return <h2>{t('cart.title')}</h2>
|
|
129
152
|
* }
|
|
130
153
|
* ```
|
|
131
154
|
*/
|
|
132
|
-
declare function
|
|
155
|
+
declare function useTranslation(): TranslationValue;
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated Use {@link TranslationProvider} instead.
|
|
158
|
+
*/
|
|
159
|
+
declare const ThemeTextProvider: typeof TranslationProvider;
|
|
160
|
+
/**
|
|
161
|
+
* @deprecated Use {@link useTranslation} instead.
|
|
162
|
+
*/
|
|
163
|
+
declare const useThemeText: typeof useTranslation;
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Use {@link TranslationValue} instead.
|
|
166
|
+
*/
|
|
167
|
+
type ThemeTextValue = TranslationValue;
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated Use {@link TranslationProviderProps} instead.
|
|
170
|
+
*/
|
|
171
|
+
type ThemeTextProviderProps = TranslationProviderProps;
|
|
133
172
|
|
|
134
173
|
type WeaverseDataValue = WeaverseLoaderData | Promise<WeaverseLoaderData> | null;
|
|
135
174
|
|
|
@@ -251,15 +290,23 @@ type WithWeaverseOptions = {
|
|
|
251
290
|
/**
|
|
252
291
|
* Optional external translation function (e.g. from Shopify i18n).
|
|
253
292
|
* When provided it becomes the **highest-priority** source
|
|
254
|
-
* in the `t()` resolution chain exposed by `
|
|
293
|
+
* in the `t()` resolution chain exposed by `useTranslation()`.
|
|
255
294
|
*/
|
|
256
295
|
t?: TranslateFunction;
|
|
257
296
|
};
|
|
258
297
|
/**
|
|
259
|
-
* Higher-order component that wraps your app with Weaverse theme settings
|
|
260
|
-
* and
|
|
298
|
+
* Higher-order component that wraps your app with Weaverse theme settings and
|
|
299
|
+
* translation context, and mounts the Studio connect bridge.
|
|
300
|
+
*
|
|
301
|
+
* Export the result as your root route's **`Layout`** (not the default route
|
|
302
|
+
* `Component`). In React Router the root `Layout` wraps both the matched route
|
|
303
|
+
* and its `ErrorBoundary`, so the Studio bridge keeps rendering on 404s and
|
|
304
|
+
* loader/render errors — exactly the pages where Studio must still answer its
|
|
305
|
+
* handshake instead of reporting a false "Connection lost". A default-component
|
|
306
|
+
* wrapper (`export default withWeaverse(App)`) is replaced by the error
|
|
307
|
+
* boundary on those routes and would drop the bridge.
|
|
261
308
|
*
|
|
262
|
-
* @param Component - The root component to wrap
|
|
309
|
+
* @param Component - The root layout component to wrap
|
|
263
310
|
* @param options - Optional configuration (e.g. an external `t` function)
|
|
264
311
|
* @returns Wrapped component with theme settings + translation providers
|
|
265
312
|
*
|
|
@@ -267,11 +314,11 @@ type WithWeaverseOptions = {
|
|
|
267
314
|
* ```typescript
|
|
268
315
|
* import { withWeaverse } from '@weaverse/hydrogen'
|
|
269
316
|
*
|
|
270
|
-
* // Basic usage
|
|
271
|
-
* export
|
|
317
|
+
* // Basic usage — export as the root route Layout
|
|
318
|
+
* export const Layout = withWeaverse(RootLayout)
|
|
272
319
|
*
|
|
273
|
-
* // With external translation function
|
|
274
|
-
* export
|
|
320
|
+
* // With an external translation function
|
|
321
|
+
* export const Layout = withWeaverse(RootLayout, { t: myI18nFunction })
|
|
275
322
|
* ```
|
|
276
323
|
*/
|
|
277
324
|
declare function withWeaverse(Component: ComponentType<any>, options?: WithWeaverseOptions): (props: JSX.IntrinsicAttributes) => react_jsx_runtime.JSX.Element;
|
|
@@ -460,7 +507,7 @@ declare class WeaverseClient {
|
|
|
460
507
|
* Fetches page content, executes component loaders, and handles empty items fallback.
|
|
461
508
|
*
|
|
462
509
|
* @param params - Optional page loading parameters
|
|
463
|
-
* @param params.type - Page type (
|
|
510
|
+
* @param params.type - Page type (INDEX, PAGE, PRODUCT, COLLECTION, etc.)
|
|
464
511
|
* @param params.handle - Page handle for dynamic routes
|
|
465
512
|
* @param params.locale - Locale override
|
|
466
513
|
* @param params.projectId - Route-level project ID override (for multi-project)
|
|
@@ -473,7 +520,7 @@ declare class WeaverseClient {
|
|
|
473
520
|
* const data = await weaverse.loadPage()
|
|
474
521
|
*
|
|
475
522
|
* // With page type
|
|
476
|
-
* const data = await weaverse.loadPage({ type: '
|
|
523
|
+
* const data = await weaverse.loadPage({ type: 'INDEX' })
|
|
477
524
|
*
|
|
478
525
|
* // Route-level project override
|
|
479
526
|
* const data = await weaverse.loadPage({
|
|
@@ -541,7 +588,9 @@ type WeaverseInternal = {
|
|
|
541
588
|
navigate: NavigateFunction;
|
|
542
589
|
revalidate: () => void;
|
|
543
590
|
themeSettingsStore: ThemeSettingsStore;
|
|
544
|
-
|
|
591
|
+
translationStore?: TranslationStore | null;
|
|
592
|
+
/** @deprecated Use translationStore instead. */
|
|
593
|
+
themeTextStore?: TranslationStore | null;
|
|
545
594
|
merchantOverrides?: Record<string, unknown> | null;
|
|
546
595
|
};
|
|
547
596
|
/**
|
|
@@ -1208,4 +1257,4 @@ declare const IMAGES_PLACEHOLDERS: {
|
|
|
1208
1257
|
product_18: string;
|
|
1209
1258
|
};
|
|
1210
1259
|
|
|
1211
|
-
export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type CustomPageEntry, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, ThemeTextProvider, type ThemeTextProviderProps, ThemeTextStore, type ThemeTextValue, type TranslateFunction, type TranslationChanges, type TranslationEntry, type TranslationItemEntry, type TranslationMap, type TranslationMapEntry, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, type WithWeaverseOptions, createWeaverseDataContext, defaultComponents, formatMetaDescriptors, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, getWeaverseSeoMeta, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
|
|
1260
|
+
export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type CustomPageEntry, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, ThemeTextProvider, type ThemeTextProviderProps, ThemeTextStore, type ThemeTextValue, type TranslateFunction, type TranslationChanges, type TranslationEntry, type TranslationItemEntry, type TranslationMap, type TranslationMapEntry, TranslationProvider, type TranslationProviderProps, TranslationStore, type TranslationValue, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, type WithWeaverseOptions, createWeaverseDataContext, defaultComponents, formatMetaDescriptors, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, getWeaverseSeoMeta, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useTranslation, useWeaverseDataContext, withWeaverse };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,14 +15,15 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
15
15
|
/**
|
|
16
16
|
* Minimal mutable store for design-mode static text overrides.
|
|
17
17
|
*
|
|
18
|
-
* useSyncExternalStore-compatible. Passed into
|
|
18
|
+
* useSyncExternalStore-compatible. Passed into TranslationProvider which
|
|
19
19
|
* subscribes internally and merges overrides into merchantOverrides.
|
|
20
|
-
* The studio bridge calls updateOverrides() via weaverse.internal.
|
|
20
|
+
* The studio bridge calls updateOverrides() via weaverse.internal.translationStore
|
|
21
|
+
* (also exposed as the deprecated weaverse.internal.themeTextStore alias).
|
|
21
22
|
*
|
|
22
23
|
* Shape: flat Record<string, string> — dot-notation keys map to values
|
|
23
24
|
* (e.g. "cart.title" → "Shopping Cart").
|
|
24
25
|
*/
|
|
25
|
-
declare class
|
|
26
|
+
declare class TranslationStore {
|
|
26
27
|
overrides: Record<string, string>;
|
|
27
28
|
private listeners;
|
|
28
29
|
setOverrides: (overrides: Record<string, string>) => void;
|
|
@@ -32,6 +33,16 @@ declare class ThemeTextStore {
|
|
|
32
33
|
subscribe: (callback: () => void) => () => void;
|
|
33
34
|
private emit;
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use {@link TranslationStore} instead. Kept as a backward-compatible
|
|
38
|
+
* alias and will remain exported for existing integrations.
|
|
39
|
+
*/
|
|
40
|
+
declare const ThemeTextStore: typeof TranslationStore;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use {@link TranslationStore} instead. Kept as a backward-compatible
|
|
43
|
+
* alias and will remain exported for existing integrations.
|
|
44
|
+
*/
|
|
45
|
+
type ThemeTextStore = TranslationStore;
|
|
35
46
|
|
|
36
47
|
type WeaverseThemeData = {
|
|
37
48
|
theme: HydrogenThemeSettings;
|
|
@@ -74,12 +85,12 @@ declare function interpolate(template: string, variables?: Record<string, string
|
|
|
74
85
|
* Signature for a translation function.
|
|
75
86
|
*/
|
|
76
87
|
type TranslateFunction = (key: string, variables?: Record<string, string | number>) => string;
|
|
77
|
-
type
|
|
88
|
+
type TranslationValue = {
|
|
78
89
|
/**
|
|
79
90
|
* Translate a key with optional variable interpolation.
|
|
80
91
|
*
|
|
81
92
|
* Priority chain (highest wins):
|
|
82
|
-
* 1. External `t` (passed into `withWeaverse` / `
|
|
93
|
+
* 1. External `t` (passed into `withWeaverse` / `TranslationProvider`)
|
|
83
94
|
* 2. `merchantOverrides` (DB overrides for the current locale + design overrides)
|
|
84
95
|
* 3. `staticContent` (theme default JSON)
|
|
85
96
|
* 4. The key itself (fallback)
|
|
@@ -90,11 +101,16 @@ type ThemeTextValue = {
|
|
|
90
101
|
*/
|
|
91
102
|
t: TranslateFunction;
|
|
92
103
|
/** Exposed for useStudio to attach to weaverse.internal. Null in production. */
|
|
93
|
-
|
|
104
|
+
translationStore: TranslationStore | null;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated Use {@link TranslationValue.translationStore} instead. Kept as a
|
|
107
|
+
* backward-compatible alias pointing at the same store instance.
|
|
108
|
+
*/
|
|
109
|
+
themeTextStore: TranslationStore | null;
|
|
94
110
|
/** Active-locale translated keys loaded from the storefront API. */
|
|
95
111
|
merchantOverrides: Record<string, unknown> | null;
|
|
96
112
|
};
|
|
97
|
-
type
|
|
113
|
+
type TranslationProviderProps = {
|
|
98
114
|
staticContent: Record<string, unknown>;
|
|
99
115
|
merchantOverrides?: Record<string, unknown>;
|
|
100
116
|
/**
|
|
@@ -105,7 +121,13 @@ type ThemeTextProviderProps = {
|
|
|
105
121
|
*/
|
|
106
122
|
t?: TranslateFunction;
|
|
107
123
|
/** Optional store for live design-mode text overrides from the builder. */
|
|
108
|
-
|
|
124
|
+
translationStore?: TranslationStore | null;
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated Use {@link TranslationProviderProps.translationStore} instead.
|
|
127
|
+
* Still accepted for backward compatibility; ignored when `translationStore`
|
|
128
|
+
* is also provided.
|
|
129
|
+
*/
|
|
130
|
+
themeTextStore?: TranslationStore | null;
|
|
109
131
|
children: ReactNode;
|
|
110
132
|
};
|
|
111
133
|
/**
|
|
@@ -113,23 +135,40 @@ type ThemeTextProviderProps = {
|
|
|
113
135
|
*
|
|
114
136
|
* - `staticContent` – the theme's default locale JSON (from themeSchema.i18n)
|
|
115
137
|
* - `merchantOverrides` – locale-specific overrides fetched from the API
|
|
116
|
-
* - `
|
|
138
|
+
* - `translationStore` – optional store for live design-mode text overrides
|
|
139
|
+
* (the deprecated `themeTextStore` prop is accepted as a fallback)
|
|
117
140
|
*/
|
|
118
|
-
declare function
|
|
141
|
+
declare function TranslationProvider({ staticContent, merchantOverrides, t: externalT, translationStore, themeTextStore, children, }: TranslationProviderProps): react_jsx_runtime.JSX.Element;
|
|
119
142
|
/**
|
|
120
|
-
* Hook to access the
|
|
143
|
+
* Hook to access the translation `t()` function.
|
|
121
144
|
*
|
|
122
|
-
* Must be used inside a component wrapped by `withWeaverse` or `
|
|
145
|
+
* Must be used inside a component wrapped by `withWeaverse` or `TranslationProvider`.
|
|
123
146
|
*
|
|
124
147
|
* @example
|
|
125
148
|
* ```tsx
|
|
126
149
|
* function CartTitle() {
|
|
127
|
-
* const { t } =
|
|
150
|
+
* const { t } = useTranslation()
|
|
128
151
|
* return <h2>{t('cart.title')}</h2>
|
|
129
152
|
* }
|
|
130
153
|
* ```
|
|
131
154
|
*/
|
|
132
|
-
declare function
|
|
155
|
+
declare function useTranslation(): TranslationValue;
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated Use {@link TranslationProvider} instead.
|
|
158
|
+
*/
|
|
159
|
+
declare const ThemeTextProvider: typeof TranslationProvider;
|
|
160
|
+
/**
|
|
161
|
+
* @deprecated Use {@link useTranslation} instead.
|
|
162
|
+
*/
|
|
163
|
+
declare const useThemeText: typeof useTranslation;
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Use {@link TranslationValue} instead.
|
|
166
|
+
*/
|
|
167
|
+
type ThemeTextValue = TranslationValue;
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated Use {@link TranslationProviderProps} instead.
|
|
170
|
+
*/
|
|
171
|
+
type ThemeTextProviderProps = TranslationProviderProps;
|
|
133
172
|
|
|
134
173
|
type WeaverseDataValue = WeaverseLoaderData | Promise<WeaverseLoaderData> | null;
|
|
135
174
|
|
|
@@ -251,15 +290,23 @@ type WithWeaverseOptions = {
|
|
|
251
290
|
/**
|
|
252
291
|
* Optional external translation function (e.g. from Shopify i18n).
|
|
253
292
|
* When provided it becomes the **highest-priority** source
|
|
254
|
-
* in the `t()` resolution chain exposed by `
|
|
293
|
+
* in the `t()` resolution chain exposed by `useTranslation()`.
|
|
255
294
|
*/
|
|
256
295
|
t?: TranslateFunction;
|
|
257
296
|
};
|
|
258
297
|
/**
|
|
259
|
-
* Higher-order component that wraps your app with Weaverse theme settings
|
|
260
|
-
* and
|
|
298
|
+
* Higher-order component that wraps your app with Weaverse theme settings and
|
|
299
|
+
* translation context, and mounts the Studio connect bridge.
|
|
300
|
+
*
|
|
301
|
+
* Export the result as your root route's **`Layout`** (not the default route
|
|
302
|
+
* `Component`). In React Router the root `Layout` wraps both the matched route
|
|
303
|
+
* and its `ErrorBoundary`, so the Studio bridge keeps rendering on 404s and
|
|
304
|
+
* loader/render errors — exactly the pages where Studio must still answer its
|
|
305
|
+
* handshake instead of reporting a false "Connection lost". A default-component
|
|
306
|
+
* wrapper (`export default withWeaverse(App)`) is replaced by the error
|
|
307
|
+
* boundary on those routes and would drop the bridge.
|
|
261
308
|
*
|
|
262
|
-
* @param Component - The root component to wrap
|
|
309
|
+
* @param Component - The root layout component to wrap
|
|
263
310
|
* @param options - Optional configuration (e.g. an external `t` function)
|
|
264
311
|
* @returns Wrapped component with theme settings + translation providers
|
|
265
312
|
*
|
|
@@ -267,11 +314,11 @@ type WithWeaverseOptions = {
|
|
|
267
314
|
* ```typescript
|
|
268
315
|
* import { withWeaverse } from '@weaverse/hydrogen'
|
|
269
316
|
*
|
|
270
|
-
* // Basic usage
|
|
271
|
-
* export
|
|
317
|
+
* // Basic usage — export as the root route Layout
|
|
318
|
+
* export const Layout = withWeaverse(RootLayout)
|
|
272
319
|
*
|
|
273
|
-
* // With external translation function
|
|
274
|
-
* export
|
|
320
|
+
* // With an external translation function
|
|
321
|
+
* export const Layout = withWeaverse(RootLayout, { t: myI18nFunction })
|
|
275
322
|
* ```
|
|
276
323
|
*/
|
|
277
324
|
declare function withWeaverse(Component: ComponentType<any>, options?: WithWeaverseOptions): (props: JSX.IntrinsicAttributes) => react_jsx_runtime.JSX.Element;
|
|
@@ -460,7 +507,7 @@ declare class WeaverseClient {
|
|
|
460
507
|
* Fetches page content, executes component loaders, and handles empty items fallback.
|
|
461
508
|
*
|
|
462
509
|
* @param params - Optional page loading parameters
|
|
463
|
-
* @param params.type - Page type (
|
|
510
|
+
* @param params.type - Page type (INDEX, PAGE, PRODUCT, COLLECTION, etc.)
|
|
464
511
|
* @param params.handle - Page handle for dynamic routes
|
|
465
512
|
* @param params.locale - Locale override
|
|
466
513
|
* @param params.projectId - Route-level project ID override (for multi-project)
|
|
@@ -473,7 +520,7 @@ declare class WeaverseClient {
|
|
|
473
520
|
* const data = await weaverse.loadPage()
|
|
474
521
|
*
|
|
475
522
|
* // With page type
|
|
476
|
-
* const data = await weaverse.loadPage({ type: '
|
|
523
|
+
* const data = await weaverse.loadPage({ type: 'INDEX' })
|
|
477
524
|
*
|
|
478
525
|
* // Route-level project override
|
|
479
526
|
* const data = await weaverse.loadPage({
|
|
@@ -541,7 +588,9 @@ type WeaverseInternal = {
|
|
|
541
588
|
navigate: NavigateFunction;
|
|
542
589
|
revalidate: () => void;
|
|
543
590
|
themeSettingsStore: ThemeSettingsStore;
|
|
544
|
-
|
|
591
|
+
translationStore?: TranslationStore | null;
|
|
592
|
+
/** @deprecated Use translationStore instead. */
|
|
593
|
+
themeTextStore?: TranslationStore | null;
|
|
545
594
|
merchantOverrides?: Record<string, unknown> | null;
|
|
546
595
|
};
|
|
547
596
|
/**
|
|
@@ -1208,4 +1257,4 @@ declare const IMAGES_PLACEHOLDERS: {
|
|
|
1208
1257
|
product_18: string;
|
|
1209
1258
|
};
|
|
1210
1259
|
|
|
1211
|
-
export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type CustomPageEntry, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, ThemeTextProvider, type ThemeTextProviderProps, ThemeTextStore, type ThemeTextValue, type TranslateFunction, type TranslationChanges, type TranslationEntry, type TranslationItemEntry, type TranslationMap, type TranslationMapEntry, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, type WithWeaverseOptions, createWeaverseDataContext, defaultComponents, formatMetaDescriptors, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, getWeaverseSeoMeta, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
|
|
1260
|
+
export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type CustomPageEntry, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, ThemeTextProvider, type ThemeTextProviderProps, ThemeTextStore, type ThemeTextValue, type TranslateFunction, type TranslationChanges, type TranslationEntry, type TranslationItemEntry, type TranslationMap, type TranslationMapEntry, TranslationProvider, type TranslationProviderProps, TranslationStore, type TranslationValue, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, type WithWeaverseOptions, createWeaverseDataContext, defaultComponents, formatMetaDescriptors, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, getWeaverseSeoMeta, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useTranslation, useWeaverseDataContext, withWeaverse };
|