@weaverse/hydrogen 5.11.1 → 5.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +113 -6
- package/dist/index.d.ts +113 -6
- package/dist/index.js +199 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +199 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -12,6 +12,27 @@ import { ReactNode, ComponentType, JSX, ForwardRefExoticComponent } from 'react'
|
|
|
12
12
|
import { NavigateFunction, UIMatch } from 'react-router';
|
|
13
13
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Minimal mutable store for design-mode static text overrides.
|
|
17
|
+
*
|
|
18
|
+
* useSyncExternalStore-compatible. Passed into ThemeTextProvider which
|
|
19
|
+
* subscribes internally and merges overrides into merchantOverrides.
|
|
20
|
+
* The studio bridge calls updateOverrides() via weaverse.internal.themeTextStore.
|
|
21
|
+
*
|
|
22
|
+
* Shape: flat Record<string, string> — dot-notation keys map to values
|
|
23
|
+
* (e.g. "cart.title" → "Shopping Cart").
|
|
24
|
+
*/
|
|
25
|
+
declare class ThemeTextStore {
|
|
26
|
+
overrides: Record<string, string>;
|
|
27
|
+
private listeners;
|
|
28
|
+
setOverrides: (overrides: Record<string, string>) => void;
|
|
29
|
+
updateOverrides: (newOverrides: Record<string, string>) => void;
|
|
30
|
+
getSnapshot: () => Record<string, string>;
|
|
31
|
+
getServerSnapshot: () => Record<string, string>;
|
|
32
|
+
subscribe: (callback: () => void) => () => void;
|
|
33
|
+
private emit;
|
|
34
|
+
}
|
|
35
|
+
|
|
15
36
|
type WeaverseThemeData = {
|
|
16
37
|
theme: HydrogenThemeSettings;
|
|
17
38
|
schema?: HydrogenThemeSchema;
|
|
@@ -59,7 +80,7 @@ type ThemeTextValue = {
|
|
|
59
80
|
*
|
|
60
81
|
* Priority chain (highest wins):
|
|
61
82
|
* 1. External `t` (passed into `withWeaverse` / `ThemeTextProvider`)
|
|
62
|
-
* 2. `merchantOverrides` (DB overrides for the current locale)
|
|
83
|
+
* 2. `merchantOverrides` (DB overrides for the current locale + design overrides)
|
|
63
84
|
* 3. `staticContent` (theme default JSON)
|
|
64
85
|
* 4. The key itself (fallback)
|
|
65
86
|
*
|
|
@@ -68,6 +89,10 @@ type ThemeTextValue = {
|
|
|
68
89
|
* t('badge.sale', { percentage: 15 }) // => "-15% Off"
|
|
69
90
|
*/
|
|
70
91
|
t: TranslateFunction;
|
|
92
|
+
/** Exposed for useStudio to attach to weaverse.internal. Null in production. */
|
|
93
|
+
themeTextStore: ThemeTextStore | null;
|
|
94
|
+
/** Active-locale translated keys loaded from the storefront API. */
|
|
95
|
+
merchantOverrides: Record<string, unknown> | null;
|
|
71
96
|
};
|
|
72
97
|
type ThemeTextProviderProps = {
|
|
73
98
|
staticContent: Record<string, unknown>;
|
|
@@ -79,6 +104,8 @@ type ThemeTextProviderProps = {
|
|
|
79
104
|
* that value is used; otherwise the internal resolution chain continues.
|
|
80
105
|
*/
|
|
81
106
|
t?: TranslateFunction;
|
|
107
|
+
/** Optional store for live design-mode text overrides from the builder. */
|
|
108
|
+
themeTextStore?: ThemeTextStore | null;
|
|
82
109
|
children: ReactNode;
|
|
83
110
|
};
|
|
84
111
|
/**
|
|
@@ -86,8 +113,9 @@ type ThemeTextProviderProps = {
|
|
|
86
113
|
*
|
|
87
114
|
* - `staticContent` – the theme's default locale JSON (from themeSchema.i18n)
|
|
88
115
|
* - `merchantOverrides` – locale-specific overrides fetched from the API
|
|
116
|
+
* - `themeTextStore` – optional store for live design-mode text overrides
|
|
89
117
|
*/
|
|
90
|
-
declare function ThemeTextProvider({ staticContent, merchantOverrides, t: externalT, children, }: ThemeTextProviderProps): react_jsx_runtime.JSX.Element;
|
|
118
|
+
declare function ThemeTextProvider({ staticContent, merchantOverrides, t: externalT, themeTextStore, children, }: ThemeTextProviderProps): react_jsx_runtime.JSX.Element;
|
|
91
119
|
/**
|
|
92
120
|
* Hook to access the theme text `t()` function.
|
|
93
121
|
*
|
|
@@ -105,8 +133,22 @@ declare function useThemeText(): ThemeTextValue;
|
|
|
105
133
|
|
|
106
134
|
declare class WeaverseHydrogenItem extends WeaverseItemStore {
|
|
107
135
|
weaverse: WeaverseHydrogen;
|
|
136
|
+
/**
|
|
137
|
+
* Cached merged snapshot (base + translations).
|
|
138
|
+
* Reset to `null` whenever `_store` or the item's translation entry changes.
|
|
139
|
+
*/
|
|
140
|
+
private _cachedSnapshot;
|
|
141
|
+
private _snapshotStoreRef;
|
|
142
|
+
private _snapshotTranslationRef;
|
|
108
143
|
constructor(initialData: HydrogenComponentData, weaverse: WeaverseHydrogen);
|
|
109
144
|
get Element(): HydrogenElement;
|
|
145
|
+
/**
|
|
146
|
+
* Override getSnapShot to merge translation data when in translation mode.
|
|
147
|
+
* Memoizes the result: returns the same object reference as long as
|
|
148
|
+
* both `_store` and the translation entry haven't changed.
|
|
149
|
+
* This is critical for `useSyncExternalStore` stability.
|
|
150
|
+
*/
|
|
151
|
+
getSnapShot: () => ElementData;
|
|
110
152
|
}
|
|
111
153
|
declare class WeaverseHydrogen extends Weaverse {
|
|
112
154
|
pageId: string;
|
|
@@ -125,7 +167,42 @@ declare class WeaverseHydrogen extends Weaverse {
|
|
|
125
167
|
data: HydrogenPageData;
|
|
126
168
|
static itemInstances: Map<string, WeaverseHydrogenItem>;
|
|
127
169
|
static elementRegistry: Map<string, HydrogenElement>;
|
|
170
|
+
/**
|
|
171
|
+
* Translation map received from the builder in design mode.
|
|
172
|
+
* Keyed by item ID, each entry maps field names to translated values.
|
|
173
|
+
* `WeaverseHydrogenItem.getSnapShot()` merges these into the data
|
|
174
|
+
* returned to components, so translations render without monkey-patching.
|
|
175
|
+
*/
|
|
176
|
+
translationMap: TranslationMap;
|
|
177
|
+
translationLocale: string;
|
|
178
|
+
translationLanguageId: string;
|
|
128
179
|
constructor(params: WeaverseHydrogenParams);
|
|
180
|
+
/**
|
|
181
|
+
* Extract translation sidecar data from `this.data` (the page data).
|
|
182
|
+
* The builder attaches `translationMap`, `translationLocale`, and
|
|
183
|
+
* `translationLanguageId` to the page data in design mode.
|
|
184
|
+
*/
|
|
185
|
+
extractTranslationSidecar: () => void;
|
|
186
|
+
/**
|
|
187
|
+
* Set the translation sidecar data.
|
|
188
|
+
* Called by the studio bridge when translation data arrives or changes.
|
|
189
|
+
* Triggers a re-render of all items so translated snapshots are recalculated.
|
|
190
|
+
*/
|
|
191
|
+
setTranslationSidecar: (translationMap: TranslationMap, locale: string, languageId: string) => void;
|
|
192
|
+
/**
|
|
193
|
+
* Update a single translation entry for a specific item field.
|
|
194
|
+
* Used by the studio bridge when the user edits a translatable field.
|
|
195
|
+
*/
|
|
196
|
+
updateTranslation: (itemId: string, key: string, originalValue: string, translatedValue: string) => void;
|
|
197
|
+
/**
|
|
198
|
+
* Collect all translation changes across all weaverse instances.
|
|
199
|
+
* Used by the save flow to persist translation edits.
|
|
200
|
+
*/
|
|
201
|
+
getTranslationChanges: () => TranslationChanges | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Override setProjectData to re-extract translation sidecar from new page data.
|
|
204
|
+
*/
|
|
205
|
+
setProjectData: (data: HydrogenPageData) => void;
|
|
129
206
|
}
|
|
130
207
|
/**
|
|
131
208
|
* Register a Weaverse component with the global element registry.
|
|
@@ -440,6 +517,8 @@ type WeaverseInternal = {
|
|
|
440
517
|
navigate: NavigateFunction;
|
|
441
518
|
revalidate: () => void;
|
|
442
519
|
themeSettingsStore: ThemeSettingsStore;
|
|
520
|
+
themeTextStore?: ThemeTextStore | null;
|
|
521
|
+
merchantOverrides?: Record<string, unknown> | null;
|
|
443
522
|
};
|
|
444
523
|
/**
|
|
445
524
|
* Optimized: Use direct type alias to maintain consistency
|
|
@@ -531,9 +610,6 @@ type WeaverseI18n = I18nBase & {
|
|
|
531
610
|
[key: string]: any;
|
|
532
611
|
};
|
|
533
612
|
type HydrogenThemeSchema = {
|
|
534
|
-
betaFlags?: {
|
|
535
|
-
contentManager?: boolean;
|
|
536
|
-
};
|
|
537
613
|
info: {
|
|
538
614
|
name: string;
|
|
539
615
|
version: string;
|
|
@@ -550,6 +626,8 @@ type HydrogenThemeSchema = {
|
|
|
550
626
|
defaultLocale: WeaverseI18n;
|
|
551
627
|
shopLocales: WeaverseI18n[];
|
|
552
628
|
staticContent?: Record<string, unknown>;
|
|
629
|
+
/** Enable the translation UI in the builder. */
|
|
630
|
+
translation?: boolean;
|
|
553
631
|
};
|
|
554
632
|
};
|
|
555
633
|
type FetchProjectRequestBody = {
|
|
@@ -918,6 +996,35 @@ type LoadPageParams = {
|
|
|
918
996
|
*/
|
|
919
997
|
projectId?: string;
|
|
920
998
|
};
|
|
999
|
+
/** A single translated field for one item */
|
|
1000
|
+
interface TranslationMapEntry {
|
|
1001
|
+
originalValue: string;
|
|
1002
|
+
translatedValue: string;
|
|
1003
|
+
}
|
|
1004
|
+
/** Per-item translation fields, keyed by field name */
|
|
1005
|
+
type TranslationItemEntry = {
|
|
1006
|
+
[key: string]: TranslationMapEntry;
|
|
1007
|
+
};
|
|
1008
|
+
/**
|
|
1009
|
+
* Translation map sent from the builder alongside page data in design mode.
|
|
1010
|
+
* Keyed by item ID, each value maps field names to translation entries.
|
|
1011
|
+
*/
|
|
1012
|
+
type TranslationMap = {
|
|
1013
|
+
[itemId: string]: TranslationItemEntry;
|
|
1014
|
+
};
|
|
1015
|
+
/** A single translation entry for save payloads */
|
|
1016
|
+
interface TranslationEntry {
|
|
1017
|
+
deleted?: boolean;
|
|
1018
|
+
itemId: string;
|
|
1019
|
+
key: string;
|
|
1020
|
+
originalValue: string;
|
|
1021
|
+
translatedValue: string;
|
|
1022
|
+
}
|
|
1023
|
+
/** Result of collecting translation changes for the save flow */
|
|
1024
|
+
type TranslationChanges = {
|
|
1025
|
+
languageId: string;
|
|
1026
|
+
entries: TranslationEntry[];
|
|
1027
|
+
};
|
|
921
1028
|
|
|
922
1029
|
declare let defaultComponents: HydrogenComponent[];
|
|
923
1030
|
|
|
@@ -1020,4 +1127,4 @@ declare const IMAGES_PLACEHOLDERS: {
|
|
|
1020
1127
|
product_18: string;
|
|
1021
1128
|
};
|
|
1022
1129
|
|
|
1023
|
-
export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, 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, type ThemeTextValue, type TranslateFunction, 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, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
|
|
1130
|
+
export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, 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, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,27 @@ import { ReactNode, ComponentType, JSX, ForwardRefExoticComponent } from 'react'
|
|
|
12
12
|
import { NavigateFunction, UIMatch } from 'react-router';
|
|
13
13
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Minimal mutable store for design-mode static text overrides.
|
|
17
|
+
*
|
|
18
|
+
* useSyncExternalStore-compatible. Passed into ThemeTextProvider which
|
|
19
|
+
* subscribes internally and merges overrides into merchantOverrides.
|
|
20
|
+
* The studio bridge calls updateOverrides() via weaverse.internal.themeTextStore.
|
|
21
|
+
*
|
|
22
|
+
* Shape: flat Record<string, string> — dot-notation keys map to values
|
|
23
|
+
* (e.g. "cart.title" → "Shopping Cart").
|
|
24
|
+
*/
|
|
25
|
+
declare class ThemeTextStore {
|
|
26
|
+
overrides: Record<string, string>;
|
|
27
|
+
private listeners;
|
|
28
|
+
setOverrides: (overrides: Record<string, string>) => void;
|
|
29
|
+
updateOverrides: (newOverrides: Record<string, string>) => void;
|
|
30
|
+
getSnapshot: () => Record<string, string>;
|
|
31
|
+
getServerSnapshot: () => Record<string, string>;
|
|
32
|
+
subscribe: (callback: () => void) => () => void;
|
|
33
|
+
private emit;
|
|
34
|
+
}
|
|
35
|
+
|
|
15
36
|
type WeaverseThemeData = {
|
|
16
37
|
theme: HydrogenThemeSettings;
|
|
17
38
|
schema?: HydrogenThemeSchema;
|
|
@@ -59,7 +80,7 @@ type ThemeTextValue = {
|
|
|
59
80
|
*
|
|
60
81
|
* Priority chain (highest wins):
|
|
61
82
|
* 1. External `t` (passed into `withWeaverse` / `ThemeTextProvider`)
|
|
62
|
-
* 2. `merchantOverrides` (DB overrides for the current locale)
|
|
83
|
+
* 2. `merchantOverrides` (DB overrides for the current locale + design overrides)
|
|
63
84
|
* 3. `staticContent` (theme default JSON)
|
|
64
85
|
* 4. The key itself (fallback)
|
|
65
86
|
*
|
|
@@ -68,6 +89,10 @@ type ThemeTextValue = {
|
|
|
68
89
|
* t('badge.sale', { percentage: 15 }) // => "-15% Off"
|
|
69
90
|
*/
|
|
70
91
|
t: TranslateFunction;
|
|
92
|
+
/** Exposed for useStudio to attach to weaverse.internal. Null in production. */
|
|
93
|
+
themeTextStore: ThemeTextStore | null;
|
|
94
|
+
/** Active-locale translated keys loaded from the storefront API. */
|
|
95
|
+
merchantOverrides: Record<string, unknown> | null;
|
|
71
96
|
};
|
|
72
97
|
type ThemeTextProviderProps = {
|
|
73
98
|
staticContent: Record<string, unknown>;
|
|
@@ -79,6 +104,8 @@ type ThemeTextProviderProps = {
|
|
|
79
104
|
* that value is used; otherwise the internal resolution chain continues.
|
|
80
105
|
*/
|
|
81
106
|
t?: TranslateFunction;
|
|
107
|
+
/** Optional store for live design-mode text overrides from the builder. */
|
|
108
|
+
themeTextStore?: ThemeTextStore | null;
|
|
82
109
|
children: ReactNode;
|
|
83
110
|
};
|
|
84
111
|
/**
|
|
@@ -86,8 +113,9 @@ type ThemeTextProviderProps = {
|
|
|
86
113
|
*
|
|
87
114
|
* - `staticContent` – the theme's default locale JSON (from themeSchema.i18n)
|
|
88
115
|
* - `merchantOverrides` – locale-specific overrides fetched from the API
|
|
116
|
+
* - `themeTextStore` – optional store for live design-mode text overrides
|
|
89
117
|
*/
|
|
90
|
-
declare function ThemeTextProvider({ staticContent, merchantOverrides, t: externalT, children, }: ThemeTextProviderProps): react_jsx_runtime.JSX.Element;
|
|
118
|
+
declare function ThemeTextProvider({ staticContent, merchantOverrides, t: externalT, themeTextStore, children, }: ThemeTextProviderProps): react_jsx_runtime.JSX.Element;
|
|
91
119
|
/**
|
|
92
120
|
* Hook to access the theme text `t()` function.
|
|
93
121
|
*
|
|
@@ -105,8 +133,22 @@ declare function useThemeText(): ThemeTextValue;
|
|
|
105
133
|
|
|
106
134
|
declare class WeaverseHydrogenItem extends WeaverseItemStore {
|
|
107
135
|
weaverse: WeaverseHydrogen;
|
|
136
|
+
/**
|
|
137
|
+
* Cached merged snapshot (base + translations).
|
|
138
|
+
* Reset to `null` whenever `_store` or the item's translation entry changes.
|
|
139
|
+
*/
|
|
140
|
+
private _cachedSnapshot;
|
|
141
|
+
private _snapshotStoreRef;
|
|
142
|
+
private _snapshotTranslationRef;
|
|
108
143
|
constructor(initialData: HydrogenComponentData, weaverse: WeaverseHydrogen);
|
|
109
144
|
get Element(): HydrogenElement;
|
|
145
|
+
/**
|
|
146
|
+
* Override getSnapShot to merge translation data when in translation mode.
|
|
147
|
+
* Memoizes the result: returns the same object reference as long as
|
|
148
|
+
* both `_store` and the translation entry haven't changed.
|
|
149
|
+
* This is critical for `useSyncExternalStore` stability.
|
|
150
|
+
*/
|
|
151
|
+
getSnapShot: () => ElementData;
|
|
110
152
|
}
|
|
111
153
|
declare class WeaverseHydrogen extends Weaverse {
|
|
112
154
|
pageId: string;
|
|
@@ -125,7 +167,42 @@ declare class WeaverseHydrogen extends Weaverse {
|
|
|
125
167
|
data: HydrogenPageData;
|
|
126
168
|
static itemInstances: Map<string, WeaverseHydrogenItem>;
|
|
127
169
|
static elementRegistry: Map<string, HydrogenElement>;
|
|
170
|
+
/**
|
|
171
|
+
* Translation map received from the builder in design mode.
|
|
172
|
+
* Keyed by item ID, each entry maps field names to translated values.
|
|
173
|
+
* `WeaverseHydrogenItem.getSnapShot()` merges these into the data
|
|
174
|
+
* returned to components, so translations render without monkey-patching.
|
|
175
|
+
*/
|
|
176
|
+
translationMap: TranslationMap;
|
|
177
|
+
translationLocale: string;
|
|
178
|
+
translationLanguageId: string;
|
|
128
179
|
constructor(params: WeaverseHydrogenParams);
|
|
180
|
+
/**
|
|
181
|
+
* Extract translation sidecar data from `this.data` (the page data).
|
|
182
|
+
* The builder attaches `translationMap`, `translationLocale`, and
|
|
183
|
+
* `translationLanguageId` to the page data in design mode.
|
|
184
|
+
*/
|
|
185
|
+
extractTranslationSidecar: () => void;
|
|
186
|
+
/**
|
|
187
|
+
* Set the translation sidecar data.
|
|
188
|
+
* Called by the studio bridge when translation data arrives or changes.
|
|
189
|
+
* Triggers a re-render of all items so translated snapshots are recalculated.
|
|
190
|
+
*/
|
|
191
|
+
setTranslationSidecar: (translationMap: TranslationMap, locale: string, languageId: string) => void;
|
|
192
|
+
/**
|
|
193
|
+
* Update a single translation entry for a specific item field.
|
|
194
|
+
* Used by the studio bridge when the user edits a translatable field.
|
|
195
|
+
*/
|
|
196
|
+
updateTranslation: (itemId: string, key: string, originalValue: string, translatedValue: string) => void;
|
|
197
|
+
/**
|
|
198
|
+
* Collect all translation changes across all weaverse instances.
|
|
199
|
+
* Used by the save flow to persist translation edits.
|
|
200
|
+
*/
|
|
201
|
+
getTranslationChanges: () => TranslationChanges | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Override setProjectData to re-extract translation sidecar from new page data.
|
|
204
|
+
*/
|
|
205
|
+
setProjectData: (data: HydrogenPageData) => void;
|
|
129
206
|
}
|
|
130
207
|
/**
|
|
131
208
|
* Register a Weaverse component with the global element registry.
|
|
@@ -440,6 +517,8 @@ type WeaverseInternal = {
|
|
|
440
517
|
navigate: NavigateFunction;
|
|
441
518
|
revalidate: () => void;
|
|
442
519
|
themeSettingsStore: ThemeSettingsStore;
|
|
520
|
+
themeTextStore?: ThemeTextStore | null;
|
|
521
|
+
merchantOverrides?: Record<string, unknown> | null;
|
|
443
522
|
};
|
|
444
523
|
/**
|
|
445
524
|
* Optimized: Use direct type alias to maintain consistency
|
|
@@ -531,9 +610,6 @@ type WeaverseI18n = I18nBase & {
|
|
|
531
610
|
[key: string]: any;
|
|
532
611
|
};
|
|
533
612
|
type HydrogenThemeSchema = {
|
|
534
|
-
betaFlags?: {
|
|
535
|
-
contentManager?: boolean;
|
|
536
|
-
};
|
|
537
613
|
info: {
|
|
538
614
|
name: string;
|
|
539
615
|
version: string;
|
|
@@ -550,6 +626,8 @@ type HydrogenThemeSchema = {
|
|
|
550
626
|
defaultLocale: WeaverseI18n;
|
|
551
627
|
shopLocales: WeaverseI18n[];
|
|
552
628
|
staticContent?: Record<string, unknown>;
|
|
629
|
+
/** Enable the translation UI in the builder. */
|
|
630
|
+
translation?: boolean;
|
|
553
631
|
};
|
|
554
632
|
};
|
|
555
633
|
type FetchProjectRequestBody = {
|
|
@@ -918,6 +996,35 @@ type LoadPageParams = {
|
|
|
918
996
|
*/
|
|
919
997
|
projectId?: string;
|
|
920
998
|
};
|
|
999
|
+
/** A single translated field for one item */
|
|
1000
|
+
interface TranslationMapEntry {
|
|
1001
|
+
originalValue: string;
|
|
1002
|
+
translatedValue: string;
|
|
1003
|
+
}
|
|
1004
|
+
/** Per-item translation fields, keyed by field name */
|
|
1005
|
+
type TranslationItemEntry = {
|
|
1006
|
+
[key: string]: TranslationMapEntry;
|
|
1007
|
+
};
|
|
1008
|
+
/**
|
|
1009
|
+
* Translation map sent from the builder alongside page data in design mode.
|
|
1010
|
+
* Keyed by item ID, each value maps field names to translation entries.
|
|
1011
|
+
*/
|
|
1012
|
+
type TranslationMap = {
|
|
1013
|
+
[itemId: string]: TranslationItemEntry;
|
|
1014
|
+
};
|
|
1015
|
+
/** A single translation entry for save payloads */
|
|
1016
|
+
interface TranslationEntry {
|
|
1017
|
+
deleted?: boolean;
|
|
1018
|
+
itemId: string;
|
|
1019
|
+
key: string;
|
|
1020
|
+
originalValue: string;
|
|
1021
|
+
translatedValue: string;
|
|
1022
|
+
}
|
|
1023
|
+
/** Result of collecting translation changes for the save flow */
|
|
1024
|
+
type TranslationChanges = {
|
|
1025
|
+
languageId: string;
|
|
1026
|
+
entries: TranslationEntry[];
|
|
1027
|
+
};
|
|
921
1028
|
|
|
922
1029
|
declare let defaultComponents: HydrogenComponent[];
|
|
923
1030
|
|
|
@@ -1020,4 +1127,4 @@ declare const IMAGES_PLACEHOLDERS: {
|
|
|
1020
1127
|
product_18: string;
|
|
1021
1128
|
};
|
|
1022
1129
|
|
|
1023
|
-
export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, 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, type ThemeTextValue, type TranslateFunction, 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, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
|
|
1130
|
+
export { type CacheResponseValidator, type ComponentDataValue, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, 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, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
|