@weaverse/hydrogen 5.17.1 → 5.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +83 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/WeaverseHydrogenRoot.d.ts +218 -0
- package/dist/types/WeaverseHydrogenRoot.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/components/main.d.ts +7 -0
- package/dist/types/components/main.d.ts.map +1 -0
- package/dist/types/hooks/theme-text-context.d.ts +2 -0
- package/dist/types/hooks/theme-text-context.d.ts.map +1 -0
- package/dist/types/hooks/translation-context.d.ts +138 -0
- package/dist/types/hooks/translation-context.d.ts.map +1 -0
- package/dist/types/hooks/use-weaverse-data-context.d.ts +29 -0
- package/dist/types/hooks/use-weaverse-data-context.d.ts.map +1 -0
- package/dist/types/index.d.ts +99 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/seo.d.ts +43 -0
- package/dist/types/seo.d.ts.map +1 -0
- package/dist/types/types.d.ts +826 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +44 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/normalize-page-url.d.ts +16 -0
- package/dist/types/utils/normalize-page-url.d.ts.map +1 -0
- package/dist/types/utils/pick-weaverse-data.d.ts +44 -0
- package/dist/types/utils/pick-weaverse-data.d.ts.map +1 -0
- package/dist/types/utils/pixel.d.ts +16 -0
- package/dist/types/utils/pixel.d.ts.map +1 -0
- package/dist/types/utils/studio-request-info.d.ts +17 -0
- package/dist/types/utils/studio-request-info.d.ts.map +1 -0
- package/dist/types/utils/studio-script-src.d.ts +78 -0
- package/dist/types/utils/studio-script-src.d.ts.map +1 -0
- package/dist/types/utils/sync-reused-instance.d.ts +21 -0
- package/dist/types/utils/sync-reused-instance.d.ts.map +1 -0
- package/dist/types/utils/theme-text-store.d.ts +2 -0
- package/dist/types/utils/theme-text-store.d.ts.map +1 -0
- package/dist/types/utils/translation-store.d.ts +40 -0
- package/dist/types/utils/translation-store.d.ts.map +1 -0
- package/dist/types/utils/use-studio.d.ts +33 -0
- package/dist/types/utils/use-studio.d.ts.map +1 -0
- package/dist/types/utils/use-theme-settings-store.d.ts +39 -0
- package/dist/types/utils/use-theme-settings-store.d.ts.map +1 -0
- package/dist/types/weaverse-client.d.ts +227 -0
- package/dist/types/weaverse-client.d.ts.map +1 -0
- package/package.json +7 -6
- package/src/WeaverseHydrogenRoot.tsx +649 -0
- package/src/components/index.ts +10 -0
- package/src/components/main.tsx +28 -0
- package/src/hooks/theme-text-context.tsx +14 -0
- package/src/hooks/translation-context.tsx +275 -0
- package/src/hooks/use-weaverse-data-context.ts +69 -0
- package/src/index.ts +179 -0
- package/src/seo.ts +125 -0
- package/src/types.ts +1020 -0
- package/src/utils/index.ts +351 -0
- package/src/utils/normalize-page-url.ts +44 -0
- package/src/utils/pick-weaverse-data.ts +89 -0
- package/src/utils/pixel.ts +71 -0
- package/src/utils/studio-request-info.ts +66 -0
- package/src/utils/studio-script-src.ts +162 -0
- package/src/utils/sync-reused-instance.ts +57 -0
- package/src/utils/theme-text-store.ts +1 -0
- package/src/utils/translation-store.ts +65 -0
- package/src/utils/use-studio.ts +168 -0
- package/src/utils/use-theme-settings-store.ts +160 -0
- package/src/weaverse-client.ts +1179 -0
- package/dist/index.d.mts +0 -1260
- package/dist/index.d.ts +0 -1260
package/dist/index.d.mts
DELETED
|
@@ -1,1260 +0,0 @@
|
|
|
1
|
-
import { SelectedOptionInput } from '@shopify/hydrogen/storefront-api-types';
|
|
2
|
-
import { Weaverse, WeaverseItemStore, ElementData, WeaverseElement, WeaverseProjectDataType, WeaverseCoreParams, WeaverseResourcePickerData } from '@weaverse/react';
|
|
3
|
-
export { PositionInputValue, WeaverseImage, WeaverseVideo, isBrowser, isIframe, useChildInstances, useItemInstance, useParentInstance, useWeaverse } from '@weaverse/react';
|
|
4
|
-
import { PageType, InspectorGroup, SchemaType, PageSEOData, Resolvable, ComponentAvailabilityContext, ComponentPresets, SchemaValidationResult } from '@weaverse/schema';
|
|
5
|
-
export * from '@weaverse/schema';
|
|
6
|
-
export { BasicInput, ComponentAvailabilityContext, ComponentGroup, HeadingInput, InputType, InspectorGroup, PageType, Resolvable, SchemaValidationIssue, SchemaValidationResult } from '@weaverse/schema';
|
|
7
|
-
import { createWithCache, CachingStrategy, I18nBase, HydrogenContext, HydrogenEnv } from '@shopify/hydrogen';
|
|
8
|
-
export { CachingStrategy } from '@shopify/hydrogen';
|
|
9
|
-
import { LoaderFunctionArgs, AppLoadContext } from '@shopify/remix-oxygen';
|
|
10
|
-
import * as React$1 from 'react';
|
|
11
|
-
import { ReactNode, ComponentType, JSX, ForwardRefExoticComponent } from 'react';
|
|
12
|
-
import { NavigateFunction, UIMatch, MetaDescriptor } from 'react-router';
|
|
13
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Minimal mutable store for design-mode static text overrides.
|
|
17
|
-
*
|
|
18
|
-
* useSyncExternalStore-compatible. Passed into TranslationProvider which
|
|
19
|
-
* subscribes internally and merges overrides into merchantOverrides.
|
|
20
|
-
* The studio bridge calls updateOverrides() via weaverse.internal.translationStore
|
|
21
|
-
* (also exposed as the deprecated weaverse.internal.themeTextStore alias).
|
|
22
|
-
*
|
|
23
|
-
* Shape: flat Record<string, string> — dot-notation keys map to values
|
|
24
|
-
* (e.g. "cart.title" → "Shopping Cart").
|
|
25
|
-
*/
|
|
26
|
-
declare class TranslationStore {
|
|
27
|
-
overrides: Record<string, string>;
|
|
28
|
-
private listeners;
|
|
29
|
-
setOverrides: (overrides: Record<string, string>) => void;
|
|
30
|
-
updateOverrides: (newOverrides: Record<string, string>) => void;
|
|
31
|
-
getSnapshot: () => Record<string, string>;
|
|
32
|
-
getServerSnapshot: () => Record<string, string>;
|
|
33
|
-
subscribe: (callback: () => void) => () => void;
|
|
34
|
-
private emit;
|
|
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;
|
|
46
|
-
|
|
47
|
-
type WeaverseThemeData = {
|
|
48
|
-
theme: HydrogenThemeSettings;
|
|
49
|
-
schema?: HydrogenThemeSchema;
|
|
50
|
-
publicEnv?: PublicEnv;
|
|
51
|
-
};
|
|
52
|
-
declare class ThemeSettingsStore {
|
|
53
|
-
settings: HydrogenThemeSettings;
|
|
54
|
-
schema?: HydrogenThemeSchema;
|
|
55
|
-
publicEnv?: PublicEnv;
|
|
56
|
-
private listeners;
|
|
57
|
-
private hasWarnedListenerCount;
|
|
58
|
-
private isDestroyed;
|
|
59
|
-
constructor(data: WeaverseThemeData);
|
|
60
|
-
updateThemeSettings: (newSettings: HydrogenThemeSettings) => void;
|
|
61
|
-
getSnapshot: () => HydrogenThemeSettings;
|
|
62
|
-
getServerSnapshot: () => HydrogenThemeSettings;
|
|
63
|
-
subscribe: (callback: () => void) => () => void;
|
|
64
|
-
private emit;
|
|
65
|
-
destroy: () => void;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Traverse a nested object by dot-path.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* getNestedKey({ cart: { title: 'Cart' } }, 'cart.title') // => 'Cart'
|
|
73
|
-
* getNestedKey({}, 'cart.title', 'fallback') // => 'fallback'
|
|
74
|
-
*/
|
|
75
|
-
declare function getNestedKey(obj: Record<string, unknown>, path: string, fallback?: string): string | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Replace `{{variable}}` patterns in a string with provided values.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* interpolate('Hello {{name}}!', { name: 'World' }) // => 'Hello World!'
|
|
81
|
-
* interpolate('-{{percentage}}% Off', { percentage: 15 }) // => '-15% Off'
|
|
82
|
-
*/
|
|
83
|
-
declare function interpolate(template: string, variables?: Record<string, string | number>): string;
|
|
84
|
-
/**
|
|
85
|
-
* Signature for a translation function.
|
|
86
|
-
*/
|
|
87
|
-
type TranslateFunction = (key: string, variables?: Record<string, string | number>) => string;
|
|
88
|
-
type TranslationValue = {
|
|
89
|
-
/**
|
|
90
|
-
* Translate a key with optional variable interpolation.
|
|
91
|
-
*
|
|
92
|
-
* Priority chain (highest wins):
|
|
93
|
-
* 1. External `t` (passed into `withWeaverse` / `TranslationProvider`)
|
|
94
|
-
* 2. `merchantOverrides` (DB overrides for the current locale + design overrides)
|
|
95
|
-
* 3. `staticContent` (theme default JSON)
|
|
96
|
-
* 4. The key itself (fallback)
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* t('cart.title') // => "Cart"
|
|
100
|
-
* t('badge.sale', { percentage: 15 }) // => "-15% Off"
|
|
101
|
-
*/
|
|
102
|
-
t: TranslateFunction;
|
|
103
|
-
/** Exposed for useStudio to attach to weaverse.internal. Null in production. */
|
|
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;
|
|
110
|
-
/** Active-locale translated keys loaded from the storefront API. */
|
|
111
|
-
merchantOverrides: Record<string, unknown> | null;
|
|
112
|
-
};
|
|
113
|
-
type TranslationProviderProps = {
|
|
114
|
-
staticContent: Record<string, unknown>;
|
|
115
|
-
merchantOverrides?: Record<string, unknown>;
|
|
116
|
-
/**
|
|
117
|
-
* Optional external translation function.
|
|
118
|
-
* When provided it becomes the **highest-priority** source:
|
|
119
|
-
* if it returns a non-empty string that differs from the raw key,
|
|
120
|
-
* that value is used; otherwise the internal resolution chain continues.
|
|
121
|
-
*/
|
|
122
|
-
t?: TranslateFunction;
|
|
123
|
-
/** Optional store for live design-mode text overrides from the builder. */
|
|
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;
|
|
131
|
-
children: ReactNode;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Provider that wraps the app to expose the `t()` function.
|
|
135
|
-
*
|
|
136
|
-
* - `staticContent` – the theme's default locale JSON (from themeSchema.i18n)
|
|
137
|
-
* - `merchantOverrides` – locale-specific overrides fetched from the API
|
|
138
|
-
* - `translationStore` – optional store for live design-mode text overrides
|
|
139
|
-
* (the deprecated `themeTextStore` prop is accepted as a fallback)
|
|
140
|
-
*/
|
|
141
|
-
declare function TranslationProvider({ staticContent, merchantOverrides, t: externalT, translationStore, themeTextStore, children, }: TranslationProviderProps): react_jsx_runtime.JSX.Element;
|
|
142
|
-
/**
|
|
143
|
-
* Hook to access the translation `t()` function.
|
|
144
|
-
*
|
|
145
|
-
* Must be used inside a component wrapped by `withWeaverse` or `TranslationProvider`.
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```tsx
|
|
149
|
-
* function CartTitle() {
|
|
150
|
-
* const { t } = useTranslation()
|
|
151
|
-
* return <h2>{t('cart.title')}</h2>
|
|
152
|
-
* }
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
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;
|
|
172
|
-
|
|
173
|
-
type WeaverseDataValue = WeaverseLoaderData | Promise<WeaverseLoaderData> | null;
|
|
174
|
-
|
|
175
|
-
declare class WeaverseHydrogenItem extends WeaverseItemStore {
|
|
176
|
-
weaverse: WeaverseHydrogen;
|
|
177
|
-
/**
|
|
178
|
-
* Cached merged snapshot (base + translations).
|
|
179
|
-
* Reset to `null` whenever `_store` or the item's translation entry changes.
|
|
180
|
-
*/
|
|
181
|
-
private _cachedSnapshot;
|
|
182
|
-
private _snapshotStoreRef;
|
|
183
|
-
private _snapshotTranslationRef;
|
|
184
|
-
constructor(initialData: HydrogenComponentData, weaverse: WeaverseHydrogen);
|
|
185
|
-
get Element(): HydrogenElement;
|
|
186
|
-
/**
|
|
187
|
-
* Override getSnapShot to merge translation data when in translation mode.
|
|
188
|
-
* Memoizes the result: returns the same object reference as long as
|
|
189
|
-
* both `_store` and the translation entry haven't changed.
|
|
190
|
-
* This is critical for `useSyncExternalStore` stability.
|
|
191
|
-
*/
|
|
192
|
-
getSnapShot: () => ElementData;
|
|
193
|
-
}
|
|
194
|
-
declare class WeaverseHydrogen extends Weaverse {
|
|
195
|
-
pageId: string;
|
|
196
|
-
internal: Partial<WeaverseInternal>;
|
|
197
|
-
requestInfo: WeaverseLoaderRequestInfo;
|
|
198
|
-
projectId: string;
|
|
199
|
-
weaverseHost: string;
|
|
200
|
-
weaverseApiBase: string;
|
|
201
|
-
weaverseApiKey: string;
|
|
202
|
-
weaverseVersion: string;
|
|
203
|
-
isDesignMode: boolean;
|
|
204
|
-
isPreviewMode: boolean;
|
|
205
|
-
isRevisionPreview: boolean;
|
|
206
|
-
sectionType: string;
|
|
207
|
-
ItemConstructor: typeof WeaverseHydrogenItem;
|
|
208
|
-
data: HydrogenPageData;
|
|
209
|
-
static itemInstances: Map<string, WeaverseHydrogenItem>;
|
|
210
|
-
static elementRegistry: Map<string, HydrogenElement>;
|
|
211
|
-
/**
|
|
212
|
-
* Translation map received from the builder in design mode.
|
|
213
|
-
* Keyed by item ID, each entry maps field names to translated values.
|
|
214
|
-
* `WeaverseHydrogenItem.getSnapShot()` merges these into the data
|
|
215
|
-
* returned to components, so translations render without monkey-patching.
|
|
216
|
-
*/
|
|
217
|
-
translationMap: TranslationMap;
|
|
218
|
-
translationLocale: string;
|
|
219
|
-
translationLanguageId: string;
|
|
220
|
-
constructor(params: WeaverseHydrogenParams);
|
|
221
|
-
/**
|
|
222
|
-
* Extract translation sidecar data from `this.data` (the page data).
|
|
223
|
-
* The builder attaches `translationMap`, `translationLocale`, and
|
|
224
|
-
* `translationLanguageId` to the page data in design mode.
|
|
225
|
-
*/
|
|
226
|
-
extractTranslationSidecar: () => void;
|
|
227
|
-
/**
|
|
228
|
-
* Set the translation sidecar data.
|
|
229
|
-
* Called by the studio bridge when translation data arrives or changes.
|
|
230
|
-
* Triggers a re-render of all items so translated snapshots are recalculated.
|
|
231
|
-
*/
|
|
232
|
-
setTranslationSidecar: (translationMap: TranslationMap, locale: string, languageId: string) => void;
|
|
233
|
-
/**
|
|
234
|
-
* Update a single translation entry for a specific item field.
|
|
235
|
-
* Used by the studio bridge when the user edits a translatable field.
|
|
236
|
-
*/
|
|
237
|
-
updateTranslation: (itemId: string, key: string, originalValue: string, translatedValue: string) => void;
|
|
238
|
-
/**
|
|
239
|
-
* Collect all translation changes across all weaverse instances.
|
|
240
|
-
* Used by the save flow to persist translation edits.
|
|
241
|
-
*/
|
|
242
|
-
getTranslationChanges: () => TranslationChanges | undefined;
|
|
243
|
-
/**
|
|
244
|
-
* Override setProjectData to re-extract translation sidecar from new page data.
|
|
245
|
-
*/
|
|
246
|
-
setProjectData: (data: HydrogenPageData) => void;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Register a Weaverse component with the global element registry.
|
|
250
|
-
* Must be called before rendering components in WeaverseHydrogenRoot.
|
|
251
|
-
*
|
|
252
|
-
* @param element - Component configuration with schema, Component, and optional loader
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```typescript
|
|
256
|
-
* import Hero from './sections/Hero'
|
|
257
|
-
* import { schema } from './sections/Hero'
|
|
258
|
-
*
|
|
259
|
-
* registerComponent({
|
|
260
|
-
* type: 'hero',
|
|
261
|
-
* Component: Hero,
|
|
262
|
-
* schema,
|
|
263
|
-
* loader: async ({ data, weaverse }) => {
|
|
264
|
-
* return { someData: 'value' }
|
|
265
|
-
* }
|
|
266
|
-
* })
|
|
267
|
-
* ```
|
|
268
|
-
*/
|
|
269
|
-
declare function registerComponent(element: HydrogenElement): void;
|
|
270
|
-
declare const WeaverseHydrogenRoot: React$1.MemoExoticComponent<({ components, data: dataProp, errorComponent: ErrorComponent, }: {
|
|
271
|
-
components: HydrogenComponent[];
|
|
272
|
-
/**
|
|
273
|
-
* Optional explicit `weaverseData` payload. When provided, bypasses the
|
|
274
|
-
* automatic route-scoped resolution. Accepts a resolved value, a
|
|
275
|
-
* `Promise` (handled via `<Await>`), or `null` to suppress rendering.
|
|
276
|
-
*
|
|
277
|
-
* Recommended for nested layout + child route compositions where two
|
|
278
|
-
* `<WeaverseHydrogenRoot>` instances need to render different Weaverse
|
|
279
|
-
* pages on the same URL. See issue #451.
|
|
280
|
-
*/
|
|
281
|
-
data?: WeaverseDataValue;
|
|
282
|
-
errorComponent?: React.FC<{
|
|
283
|
-
error: Error | unknown;
|
|
284
|
-
}>;
|
|
285
|
-
}) => react_jsx_runtime.JSX.Element | null>;
|
|
286
|
-
/**
|
|
287
|
-
* Options for the `withWeaverse` HOC.
|
|
288
|
-
*/
|
|
289
|
-
type WithWeaverseOptions = {
|
|
290
|
-
/**
|
|
291
|
-
* Optional external translation function (e.g. from Shopify i18n).
|
|
292
|
-
* When provided it becomes the **highest-priority** source
|
|
293
|
-
* in the `t()` resolution chain exposed by `useTranslation()`.
|
|
294
|
-
*/
|
|
295
|
-
t?: TranslateFunction;
|
|
296
|
-
};
|
|
297
|
-
/**
|
|
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.
|
|
308
|
-
*
|
|
309
|
-
* @param Component - The root layout component to wrap
|
|
310
|
-
* @param options - Optional configuration (e.g. an external `t` function)
|
|
311
|
-
* @returns Wrapped component with theme settings + translation providers
|
|
312
|
-
*
|
|
313
|
-
* @example
|
|
314
|
-
* ```typescript
|
|
315
|
-
* import { withWeaverse } from '@weaverse/hydrogen'
|
|
316
|
-
*
|
|
317
|
-
* // Basic usage — export as the root route Layout
|
|
318
|
-
* export const Layout = withWeaverse(RootLayout)
|
|
319
|
-
*
|
|
320
|
-
* // With an external translation function
|
|
321
|
-
* export const Layout = withWeaverse(RootLayout, { t: myI18nFunction })
|
|
322
|
-
* ```
|
|
323
|
-
*/
|
|
324
|
-
declare function withWeaverse(Component: ComponentType<any>, options?: WithWeaverseOptions): (props: JSX.IntrinsicAttributes) => react_jsx_runtime.JSX.Element;
|
|
325
|
-
/**
|
|
326
|
-
* React hook to access Weaverse theme settings from anywhere in your component tree.
|
|
327
|
-
* Must be used within a component wrapped by `withWeaverse` or inside `WeaverseHydrogenRoot`.
|
|
328
|
-
*
|
|
329
|
-
* @returns Current theme settings object
|
|
330
|
-
*
|
|
331
|
-
* @example
|
|
332
|
-
* ```typescript
|
|
333
|
-
* function MyComponent() {
|
|
334
|
-
* const theme = useThemeSettings()
|
|
335
|
-
* const primaryColor = theme.colors?.primary
|
|
336
|
-
*
|
|
337
|
-
* return <div style={{ color: primaryColor }}>Styled content</div>
|
|
338
|
-
* }
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
declare function useThemeSettings<T = HydrogenThemeSettings>(): T;
|
|
342
|
-
|
|
343
|
-
type BuilderApiCacheTarget = 'custom-pages' | 'merchant-overrides' | 'project' | 'theme-settings';
|
|
344
|
-
declare class WeaverseClient {
|
|
345
|
-
API: "v1";
|
|
346
|
-
basePageConfigs: Omit<WeaverseProjectConfigs, 'requestInfo'>;
|
|
347
|
-
basePageRequestBody: Omit<FetchProjectRequestBody, 'url'>;
|
|
348
|
-
configs: WeaverseProjectConfigs;
|
|
349
|
-
withCache: ReturnType<typeof createWithCache>;
|
|
350
|
-
request: WeaverseClientArgs['request'];
|
|
351
|
-
customerAccount: WeaverseClientArgs['customerAccount'];
|
|
352
|
-
storefront: WeaverseClientArgs['storefront'];
|
|
353
|
-
components: WeaverseClientArgs['components'];
|
|
354
|
-
themeSchema: WeaverseClientArgs['themeSchema'];
|
|
355
|
-
env: WeaverseClientArgs['env'];
|
|
356
|
-
cache: WeaverseClientArgs['cache'];
|
|
357
|
-
waitUntil: WeaverseClientArgs['waitUntil'];
|
|
358
|
-
private readonly parsedUrl;
|
|
359
|
-
private readonly componentsByType;
|
|
360
|
-
private readonly fetchTimeoutMs;
|
|
361
|
-
constructor(args: WeaverseClientArgs);
|
|
362
|
-
/**
|
|
363
|
-
* Initialize Hydrogen cache with proper configuration.
|
|
364
|
-
* Logs warning if waitUntil is missing.
|
|
365
|
-
*/
|
|
366
|
-
private initializeCache;
|
|
367
|
-
/**
|
|
368
|
-
* Initialize configs with projectId resolution and fail-fast validation.
|
|
369
|
-
* Throws WeaverseError if projectId cannot be resolved.
|
|
370
|
-
*/
|
|
371
|
-
private initializeConfigs;
|
|
372
|
-
/**
|
|
373
|
-
* Build component lookup map for O(1) access by type.
|
|
374
|
-
* Significantly improves performance for large component lists.
|
|
375
|
-
*/
|
|
376
|
-
private buildComponentLookupMap;
|
|
377
|
-
/**
|
|
378
|
-
* Extract comprehensive error information from unknown error type.
|
|
379
|
-
* Preserves error context, codes, and stack traces for debugging.
|
|
380
|
-
*
|
|
381
|
-
* @param error - Unknown error to extract information from
|
|
382
|
-
* @returns Structured error information with message, code, stack, and context
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
* ```typescript
|
|
386
|
-
* try {
|
|
387
|
-
* // ... operation
|
|
388
|
-
* } catch (error) {
|
|
389
|
-
* const errorInfo = this.extractErrorInfo(error)
|
|
390
|
-
* console.error('Operation failed:', errorInfo.message, errorInfo.context)
|
|
391
|
-
* }
|
|
392
|
-
* ```
|
|
393
|
-
*/
|
|
394
|
-
private extractErrorInfo;
|
|
395
|
-
/**
|
|
396
|
-
* Extract error message only (for backward compatibility).
|
|
397
|
-
* Use extractErrorInfo() for more detailed error information.
|
|
398
|
-
*
|
|
399
|
-
* @deprecated Use extractErrorInfo() instead to preserve error context
|
|
400
|
-
*/
|
|
401
|
-
private extractErrorMessage;
|
|
402
|
-
/**
|
|
403
|
-
* Validates projectId format (alphanumeric, hyphens, underscores only).
|
|
404
|
-
* Returns detailed validation result with error message.
|
|
405
|
-
*
|
|
406
|
-
* @param projectId - Project identifier to validate
|
|
407
|
-
* @returns Validation result with error message if invalid
|
|
408
|
-
*/
|
|
409
|
-
private validateProjectId;
|
|
410
|
-
/**
|
|
411
|
-
* Resolves projectId with multi-project architecture support.
|
|
412
|
-
* Uses priority chain to determine the correct project ID.
|
|
413
|
-
*
|
|
414
|
-
* @param projectId - Project identifier (string, function, or undefined)
|
|
415
|
-
* @param request - HTTP request for context access
|
|
416
|
-
* @param env - Hydrogen environment with variables
|
|
417
|
-
* @param baseConfigs - Pre-fetched base configs to avoid duplicate calls
|
|
418
|
-
* @returns Resolved project ID string (empty string if none found)
|
|
419
|
-
*/
|
|
420
|
-
private resolveProjectIdSync;
|
|
421
|
-
/**
|
|
422
|
-
* Priority 1: Resolve projectId from URL query parameters.
|
|
423
|
-
* Used for design mode and preview mode overrides.
|
|
424
|
-
*/
|
|
425
|
-
private resolveFromQueryParams;
|
|
426
|
-
/**
|
|
427
|
-
* Priority 2: Resolve projectId from function parameter.
|
|
428
|
-
* Detects and rejects async functions with helpful error.
|
|
429
|
-
*/
|
|
430
|
-
private resolveFromFunction;
|
|
431
|
-
/**
|
|
432
|
-
* Priority 3: Resolve projectId from explicit string parameter.
|
|
433
|
-
*/
|
|
434
|
-
private resolveFromString;
|
|
435
|
-
/**
|
|
436
|
-
* Priority 4: Resolve projectId from environment variables.
|
|
437
|
-
*/
|
|
438
|
-
private resolveFromEnvironment;
|
|
439
|
-
/**
|
|
440
|
-
* Helper method for direct fetching in design mode.
|
|
441
|
-
* Returns same format as withCache.fetch for consistency.
|
|
442
|
-
* Includes 10-second timeout to prevent hanging requests.
|
|
443
|
-
*/
|
|
444
|
-
private readonly fetchOnce;
|
|
445
|
-
private readonly directFetch;
|
|
446
|
-
private getApiUrl;
|
|
447
|
-
private isExternalPublicApiUrl;
|
|
448
|
-
/**
|
|
449
|
-
* Fetch data with caching support for both design mode and production.
|
|
450
|
-
* Uses direct fetch in design mode, Hydrogen's withCache in production.
|
|
451
|
-
* Automatically includes projectId in cache key for multi-project isolation.
|
|
452
|
-
*
|
|
453
|
-
* @param url - The URL to fetch from
|
|
454
|
-
* @param options - Fetch options including optional cache strategy
|
|
455
|
-
* @returns Promise resolving to the fetched data
|
|
456
|
-
*
|
|
457
|
-
* @example
|
|
458
|
-
* ```typescript
|
|
459
|
-
* const data = await weaverse.fetchWithCache<MyData>(
|
|
460
|
-
* 'https://api.example.com/data',
|
|
461
|
-
* { method: 'POST', body: JSON.stringify({ key: 'value' }) }
|
|
462
|
-
* )
|
|
463
|
-
* ```
|
|
464
|
-
*/
|
|
465
|
-
fetchWithCache: <T = unknown>(url: string, options?: RequestInit & {
|
|
466
|
-
cacheTarget?: BuilderApiCacheTarget;
|
|
467
|
-
strategy?: CachingStrategy;
|
|
468
|
-
}) => Promise<T>;
|
|
469
|
-
/**
|
|
470
|
-
* Load theme settings from Weaverse API with fallback to schema defaults.
|
|
471
|
-
* Merges remote settings with local theme schema and handles design mode serialization.
|
|
472
|
-
*
|
|
473
|
-
* @param strategy - Optional cache strategy override
|
|
474
|
-
* @returns Promise resolving to theme settings response
|
|
475
|
-
*
|
|
476
|
-
* @example
|
|
477
|
-
* ```typescript
|
|
478
|
-
* const settings = await weaverse.loadThemeSettings()
|
|
479
|
-
* const primaryColor = settings.theme.colors?.primary
|
|
480
|
-
* ```
|
|
481
|
-
*/
|
|
482
|
-
loadThemeSettings: (strategy?: CachingStrategy) => Promise<ThemeSettingsResponse>;
|
|
483
|
-
/**
|
|
484
|
-
* Fetch locale-specific merchant overrides from the translation API.
|
|
485
|
-
* Returns a nested JSON object with translated values.
|
|
486
|
-
* Falls back to empty object on error to avoid blocking theme rendering.
|
|
487
|
-
*/
|
|
488
|
-
private fetchMerchantOverrides;
|
|
489
|
-
/**
|
|
490
|
-
* Generate fallback page with default structure when page data is unavailable.
|
|
491
|
-
* Used internally when API returns no page or when page needs default content.
|
|
492
|
-
*
|
|
493
|
-
* @param message - Custom message to display in the fallback page
|
|
494
|
-
* @returns HydrogenPageData with single main component containing the message
|
|
495
|
-
*/
|
|
496
|
-
generateFallbackPage: (message: string) => HydrogenPageData;
|
|
497
|
-
/**
|
|
498
|
-
* Fetch all published custom pages for sitemap generation.
|
|
499
|
-
* Paginates automatically, never throws, returns accumulated results on partial failure.
|
|
500
|
-
*/
|
|
501
|
-
fetchCustomPages(opts?: {
|
|
502
|
-
locale?: string;
|
|
503
|
-
limit?: number;
|
|
504
|
-
}): Promise<CustomPageEntry[]>;
|
|
505
|
-
/**
|
|
506
|
-
* Load page data from Weaverse API with optional route-level project override.
|
|
507
|
-
* Fetches page content, executes component loaders, and handles empty items fallback.
|
|
508
|
-
*
|
|
509
|
-
* @param params - Optional page loading parameters
|
|
510
|
-
* @param params.type - Page type (INDEX, PAGE, PRODUCT, COLLECTION, etc.)
|
|
511
|
-
* @param params.handle - Page handle for dynamic routes
|
|
512
|
-
* @param params.locale - Locale override
|
|
513
|
-
* @param params.projectId - Route-level project ID override (for multi-project)
|
|
514
|
-
* @param params.strategy - Custom cache strategy override
|
|
515
|
-
* @returns Promise resolving to page data or null on error
|
|
516
|
-
*
|
|
517
|
-
* @example
|
|
518
|
-
* ```typescript
|
|
519
|
-
* // Basic usage
|
|
520
|
-
* const data = await weaverse.loadPage()
|
|
521
|
-
*
|
|
522
|
-
* // With page type
|
|
523
|
-
* const data = await weaverse.loadPage({ type: 'INDEX' })
|
|
524
|
-
*
|
|
525
|
-
* // Route-level project override
|
|
526
|
-
* const data = await weaverse.loadPage({
|
|
527
|
-
* type: 'PAGE',
|
|
528
|
-
* handle: 'about',
|
|
529
|
-
* projectId: 'campaign-project-123'
|
|
530
|
-
* })
|
|
531
|
-
* ```
|
|
532
|
-
*/
|
|
533
|
-
loadPage: (params?: LoadPageParams) => Promise<WeaverseLoaderData | null>;
|
|
534
|
-
execComponentLoader: (item: HydrogenComponentData) => Promise<HydrogenComponentData>;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
type ComponentLoaderArgs<T = any, _E = any> = {
|
|
538
|
-
data: T;
|
|
539
|
-
weaverse: WeaverseClient;
|
|
540
|
-
};
|
|
541
|
-
interface RouteLoaderArgs extends LoaderFunctionArgs {
|
|
542
|
-
context: AppLoadContext & {
|
|
543
|
-
weaverse: WeaverseClient;
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
type ComponentDataValue = string | number | boolean | undefined | null;
|
|
547
|
-
interface HydrogenComponentData extends ElementData {
|
|
548
|
-
children?: {
|
|
549
|
-
id: string;
|
|
550
|
-
}[];
|
|
551
|
-
createdAt?: string;
|
|
552
|
-
data?: Record<string, ComponentDataValue | Record<string, unknown>>;
|
|
553
|
-
deletedAt?: string;
|
|
554
|
-
id: string;
|
|
555
|
-
type: string;
|
|
556
|
-
updatedAt?: string;
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* Optimized: Use Zod-inferred SchemaType directly instead of extending
|
|
560
|
-
* This ensures perfect type consistency with the schema validation
|
|
561
|
-
*/
|
|
562
|
-
type HydrogenComponentSchema = SchemaType;
|
|
563
|
-
interface HydrogenComponentProps<L = any> extends WeaverseElement {
|
|
564
|
-
children?: React$1.JSX.Element[];
|
|
565
|
-
className?: string;
|
|
566
|
-
loaderData?: L;
|
|
567
|
-
}
|
|
568
|
-
type WeaverseLoaderRequestInfo = {
|
|
569
|
-
search: string;
|
|
570
|
-
pathname: string;
|
|
571
|
-
queries: {
|
|
572
|
-
[key: string]: string | boolean;
|
|
573
|
-
};
|
|
574
|
-
i18n: WeaverseI18n;
|
|
575
|
-
};
|
|
576
|
-
type HydrogenThemeSettings = {
|
|
577
|
-
[key: string]: any;
|
|
578
|
-
};
|
|
579
|
-
type HydrogenProjectType = {
|
|
580
|
-
id: string;
|
|
581
|
-
weaverseShopId: string;
|
|
582
|
-
name: string;
|
|
583
|
-
[key: string]: any;
|
|
584
|
-
};
|
|
585
|
-
type WeaverseInternal = {
|
|
586
|
-
pageAssignment: HydrogenPageAssignment;
|
|
587
|
-
project: HydrogenProjectType;
|
|
588
|
-
navigate: NavigateFunction;
|
|
589
|
-
revalidate: () => void;
|
|
590
|
-
themeSettingsStore: ThemeSettingsStore;
|
|
591
|
-
translationStore?: TranslationStore | null;
|
|
592
|
-
/** @deprecated Use translationStore instead. */
|
|
593
|
-
themeTextStore?: TranslationStore | null;
|
|
594
|
-
merchantOverrides?: Record<string, unknown> | null;
|
|
595
|
-
};
|
|
596
|
-
/**
|
|
597
|
-
* Optimized: Use direct type alias to maintain consistency
|
|
598
|
-
*/
|
|
599
|
-
type HydrogenComponentPresets = ComponentPresets;
|
|
600
|
-
type HydrogenElement = {
|
|
601
|
-
Component: ForwardRefExoticComponent<HydrogenComponentProps> | ((props: HydrogenComponentProps) => React$1.JSX.Element);
|
|
602
|
-
type: string;
|
|
603
|
-
schema?: HydrogenComponentSchema;
|
|
604
|
-
/** Optional data loader function for server-side data fetching */
|
|
605
|
-
loader?: (args: ComponentLoaderArgs) => Promise<unknown>;
|
|
606
|
-
};
|
|
607
|
-
interface WeaverseHydrogenParams extends Omit<WeaverseCoreParams, 'ItemConstructor'> {
|
|
608
|
-
data: HydrogenPageData;
|
|
609
|
-
dataContext?: Record<string, unknown> | null;
|
|
610
|
-
internal: Partial<WeaverseInternal>;
|
|
611
|
-
isDesignMode?: boolean;
|
|
612
|
-
isPreviewMode?: boolean;
|
|
613
|
-
isRevisionPreview?: boolean;
|
|
614
|
-
pageId: string;
|
|
615
|
-
projectId: string;
|
|
616
|
-
requestInfo: WeaverseLoaderRequestInfo;
|
|
617
|
-
sectionType?: string;
|
|
618
|
-
weaverseApiBase: string;
|
|
619
|
-
weaverseApiKey: string;
|
|
620
|
-
weaverseHost: string;
|
|
621
|
-
/**
|
|
622
|
-
* Public data API origin. Keep `weaverseHost` for Studio scripts/editor
|
|
623
|
-
* assets; point this at the Cloudflare proxy (`https://api.weaverse.io`)
|
|
624
|
-
* when edge caching is enabled.
|
|
625
|
-
*/
|
|
626
|
-
weaversePublicApiBase?: string;
|
|
627
|
-
weaverseVersion?: string;
|
|
628
|
-
}
|
|
629
|
-
type HydrogenComponent<T extends HydrogenComponentProps = any> = {
|
|
630
|
-
default: ForwardRefExoticComponent<T> | ((props: T) => React$1.JSX.Element);
|
|
631
|
-
schema: HydrogenComponentSchema;
|
|
632
|
-
/** Optional data loader function for server-side data fetching */
|
|
633
|
-
loader?: (args: ComponentLoaderArgs) => Promise<unknown>;
|
|
634
|
-
};
|
|
635
|
-
type WeaverseStudioQueries = {
|
|
636
|
-
weaverseProjectId: string;
|
|
637
|
-
weaverseApiKey: string;
|
|
638
|
-
weaverseHost: string;
|
|
639
|
-
weaverseVersion: string;
|
|
640
|
-
isDesignMode: boolean;
|
|
641
|
-
isPreviewMode?: boolean;
|
|
642
|
-
sectionType?: string;
|
|
643
|
-
};
|
|
644
|
-
type PublicEnv = {
|
|
645
|
-
PUBLIC_STORE_DOMAIN: string;
|
|
646
|
-
PUBLIC_STOREFRONT_API_TOKEN: string;
|
|
647
|
-
};
|
|
648
|
-
type WeaverseProjectConfigs = {
|
|
649
|
-
projectId: string;
|
|
650
|
-
weaverseHost: string;
|
|
651
|
-
weaverseApiBase: string;
|
|
652
|
-
weaversePublicApiBase?: string;
|
|
653
|
-
weaverseApiKey: string;
|
|
654
|
-
weaverseVersion?: string;
|
|
655
|
-
isDesignMode?: boolean;
|
|
656
|
-
isPreviewMode?: boolean;
|
|
657
|
-
isRevisionPreview?: boolean;
|
|
658
|
-
sectionType?: string;
|
|
659
|
-
publicEnv?: PublicEnv;
|
|
660
|
-
};
|
|
661
|
-
type HydrogenPageAssignment = {
|
|
662
|
-
projectId: string;
|
|
663
|
-
type: PageType;
|
|
664
|
-
handle: string;
|
|
665
|
-
locale: string;
|
|
666
|
-
meta?: {
|
|
667
|
-
inherited: boolean;
|
|
668
|
-
sourceProjectId: string;
|
|
669
|
-
depth: number;
|
|
670
|
-
};
|
|
671
|
-
};
|
|
672
|
-
type WeaverseLoaderData = {
|
|
673
|
-
configs: Omit<WeaverseProjectConfigs, 'publicEnv'> & {
|
|
674
|
-
requestInfo: WeaverseLoaderRequestInfo;
|
|
675
|
-
};
|
|
676
|
-
page: HydrogenPageData;
|
|
677
|
-
project: HydrogenProjectType;
|
|
678
|
-
pageAssignment?: HydrogenPageAssignment;
|
|
679
|
-
};
|
|
680
|
-
interface HydrogenPageData extends WeaverseProjectDataType {
|
|
681
|
-
__cacheId?: string;
|
|
682
|
-
id: string;
|
|
683
|
-
items: HydrogenComponentData[];
|
|
684
|
-
name: string;
|
|
685
|
-
/**
|
|
686
|
-
* Page-level SEO metadata published by Weaverse Builder. `null` when
|
|
687
|
-
* the page has no `PageSeo` row; absent on revision snapshots that
|
|
688
|
-
* predate the SEO feature. Themes should treat both as "no Weaverse
|
|
689
|
-
* override".
|
|
690
|
-
*/
|
|
691
|
-
seo?: PageSEOData | null;
|
|
692
|
-
[key: string]: any;
|
|
693
|
-
}
|
|
694
|
-
type WeaverseI18n = I18nBase & {
|
|
695
|
-
label?: string;
|
|
696
|
-
pathPrefix?: string;
|
|
697
|
-
[key: string]: any;
|
|
698
|
-
};
|
|
699
|
-
type HydrogenThemeSchema = {
|
|
700
|
-
info: {
|
|
701
|
-
name: string;
|
|
702
|
-
version: string;
|
|
703
|
-
author: string;
|
|
704
|
-
authorProfilePhoto: string;
|
|
705
|
-
documentationUrl: string;
|
|
706
|
-
supportUrl: string;
|
|
707
|
-
};
|
|
708
|
-
/** @deprecated Use settings instead */
|
|
709
|
-
inspector?: InspectorGroup[];
|
|
710
|
-
settings?: InspectorGroup[];
|
|
711
|
-
i18n?: {
|
|
712
|
-
urlStructure: 'url-path' | 'subdomain' | 'top-level-domain';
|
|
713
|
-
defaultLocale: WeaverseI18n;
|
|
714
|
-
shopLocales: WeaverseI18n[];
|
|
715
|
-
staticContent?: Record<string, unknown>;
|
|
716
|
-
/** Enable the translation UI in the builder. */
|
|
717
|
-
translation?: boolean;
|
|
718
|
-
};
|
|
719
|
-
};
|
|
720
|
-
type FetchProjectRequestBody = {
|
|
721
|
-
projectId: string;
|
|
722
|
-
url: string;
|
|
723
|
-
i18n?: WeaverseI18n;
|
|
724
|
-
params?: {
|
|
725
|
-
type?: PageType;
|
|
726
|
-
locale?: string;
|
|
727
|
-
handle?: string;
|
|
728
|
-
};
|
|
729
|
-
isDesignMode?: boolean;
|
|
730
|
-
};
|
|
731
|
-
type FetchProjectPayload = {
|
|
732
|
-
page?: HydrogenPageData;
|
|
733
|
-
project?: HydrogenProjectType;
|
|
734
|
-
pageAssignment?: HydrogenPageAssignment;
|
|
735
|
-
error?: string;
|
|
736
|
-
[key: string]: any;
|
|
737
|
-
};
|
|
738
|
-
/**
|
|
739
|
-
* Project identifier value - can be static string or dynamic function.
|
|
740
|
-
*
|
|
741
|
-
* **Static String**: Direct project ID reference
|
|
742
|
-
* ```ts
|
|
743
|
-
* 'project-abc-123'
|
|
744
|
-
* ```
|
|
745
|
-
*
|
|
746
|
-
* **Synchronous Function**: Returns project ID based on request context
|
|
747
|
-
* ```ts
|
|
748
|
-
* () => {
|
|
749
|
-
* const host = new URL(request.url).hostname
|
|
750
|
-
* return PROJECT_MAP[host] || 'default-project'
|
|
751
|
-
* }
|
|
752
|
-
* ```
|
|
753
|
-
*
|
|
754
|
-
* **Asynchronous Function**: Async project resolution (must be awaited before passing)
|
|
755
|
-
* ```ts
|
|
756
|
-
* async () => {
|
|
757
|
-
* return await database.getProjectId(userId)
|
|
758
|
-
* }
|
|
759
|
-
* ```
|
|
760
|
-
*/
|
|
761
|
-
type ProjectIdValue = string | (() => string) | (() => Promise<string>);
|
|
762
|
-
/**
|
|
763
|
-
* Type guard for detecting function-based projectId.
|
|
764
|
-
*
|
|
765
|
-
* Used internally by WeaverseClient constructor to determine
|
|
766
|
-
* if projectId needs evaluation or can be used directly.
|
|
767
|
-
*/
|
|
768
|
-
declare function isProjectIdFunction(projectId: ProjectIdValue | undefined): projectId is (() => string) | (() => Promise<string>);
|
|
769
|
-
/**
|
|
770
|
-
* Extended WeaverseClient constructor arguments supporting multi-project architecture.
|
|
771
|
-
*
|
|
772
|
-
* @example Static project (existing pattern - backward compatible)
|
|
773
|
-
* ```ts
|
|
774
|
-
* const weaverse = new WeaverseClient({
|
|
775
|
-
* ...hydrogenContext,
|
|
776
|
-
* projectId: 'project-default-123'
|
|
777
|
-
* })
|
|
778
|
-
* ```
|
|
779
|
-
*
|
|
780
|
-
* @example Dynamic project selection (new capability)
|
|
781
|
-
* ```ts
|
|
782
|
-
* const weaverse = new WeaverseClient({
|
|
783
|
-
* ...hydrogenContext,
|
|
784
|
-
* projectId: () => {
|
|
785
|
-
* const origin = new URL(request.url).origin
|
|
786
|
-
* if (origin === 'https://mystore.se') return process.env.WEAVERSE_PROJECT_SWEDEN!
|
|
787
|
-
* if (origin === 'https://mystore.fr') return process.env.WEAVERSE_PROJECT_FRANCE!
|
|
788
|
-
* return process.env.WEAVERSE_PROJECT_ID!
|
|
789
|
-
* }
|
|
790
|
-
* })
|
|
791
|
-
* ```
|
|
792
|
-
*
|
|
793
|
-
* **Priority Chain** (highest to lowest):
|
|
794
|
-
* 1. URL query parameter: `?weaverseProjectId=...` (design mode, preview mode)
|
|
795
|
-
* 2. Function result (if function provided)
|
|
796
|
-
* 3. Explicit string value (if string provided)
|
|
797
|
-
* 4. Environment variable: `WEAVERSE_PROJECT_ID` (Hydrogen env or process.env)
|
|
798
|
-
* 5. Empty string (triggers validation error in methods)
|
|
799
|
-
*
|
|
800
|
-
* **Function Requirements**:
|
|
801
|
-
* - Must return non-empty string
|
|
802
|
-
* - Can access request via closure for routing decisions
|
|
803
|
-
* - Evaluated once per WeaverseClient instance (request-scoped)
|
|
804
|
-
* - Async functions must be awaited before passing to constructor
|
|
805
|
-
* - Should handle edge cases (missing headers, invalid domains, etc.)
|
|
806
|
-
*
|
|
807
|
-
* **Request Context Access**:
|
|
808
|
-
* Functions access request via closure from constructor arguments.
|
|
809
|
-
*/
|
|
810
|
-
type WeaverseClientArgs = HydrogenContext & {
|
|
811
|
-
/**
|
|
812
|
-
* React components registered with Weaverse CMS.
|
|
813
|
-
* Each component must have a schema defining its properties and settings.
|
|
814
|
-
*/
|
|
815
|
-
components: HydrogenComponent[];
|
|
816
|
-
/**
|
|
817
|
-
* Theme schema defining global theme settings (colors, fonts, layouts).
|
|
818
|
-
* Used to generate default theme configuration and validate theme data.
|
|
819
|
-
*/
|
|
820
|
-
themeSchema: HydrogenThemeSchema;
|
|
821
|
-
/**
|
|
822
|
-
* Incoming HTTP request object from React Router loader.
|
|
823
|
-
* Provides access to URL, headers, cookies for dynamic routing decisions.
|
|
824
|
-
*/
|
|
825
|
-
request: Request;
|
|
826
|
-
/**
|
|
827
|
-
* Hydrogen cache instance for content caching.
|
|
828
|
-
*Supports multi-tenant caching with project-specific cache keys.
|
|
829
|
-
*/
|
|
830
|
-
cache: Cache;
|
|
831
|
-
/**
|
|
832
|
-
* Project identifier for loading content from Weaverse CMS.
|
|
833
|
-
*
|
|
834
|
-
* **Value Types**:
|
|
835
|
-
* - Static string: 'project-123' (existing usage)
|
|
836
|
-
* - Synchronous function: () => determineProject(request)
|
|
837
|
-
* - Asynchronous function: async () => await getProject(request) (must be awaited)
|
|
838
|
-
*
|
|
839
|
-
* **Backward Compatibility**:
|
|
840
|
-
* - Optional parameter (defaults to environment variable)
|
|
841
|
-
* - Existing code without projectId continues to work unchanged
|
|
842
|
-
*
|
|
843
|
-
* **Cache Isolation**:
|
|
844
|
-
* ProjectId is included in cache keys to prevent cross-project content pollution.
|
|
845
|
-
* Each project's content is cached separately, ensuring multi-tenant isolation.
|
|
846
|
-
*/
|
|
847
|
-
projectId?: ProjectIdValue;
|
|
848
|
-
/**
|
|
849
|
-
* Fetch timeout in milliseconds for API requests.
|
|
850
|
-
* Defaults to 10000ms (10 seconds) if not specified.
|
|
851
|
-
* Useful for adjusting based on network conditions or deployment environment.
|
|
852
|
-
*
|
|
853
|
-
* @default 10000
|
|
854
|
-
* @example
|
|
855
|
-
* ```typescript
|
|
856
|
-
* new WeaverseClient({
|
|
857
|
-
* // ... other args
|
|
858
|
-
* fetchTimeoutMs: 5000 // 5 second timeout
|
|
859
|
-
* })
|
|
860
|
-
* ```
|
|
861
|
-
*/
|
|
862
|
-
fetchTimeoutMs?: number;
|
|
863
|
-
};
|
|
864
|
-
type WeaverseProduct = WeaverseResourcePickerData;
|
|
865
|
-
type WeaverseCollection = WeaverseResourcePickerData;
|
|
866
|
-
type WeaverseBlog = WeaverseResourcePickerData;
|
|
867
|
-
type WeaverseArticle = WeaverseResourcePickerData;
|
|
868
|
-
type WeaverseMetaObject = WeaverseResourcePickerData;
|
|
869
|
-
/**
|
|
870
|
-
* Response types for improved type safety
|
|
871
|
-
*/
|
|
872
|
-
type WithCacheFetchResponse<T> = {
|
|
873
|
-
data: T;
|
|
874
|
-
response: Response;
|
|
875
|
-
};
|
|
876
|
-
type ThemeSettingsResponse = {
|
|
877
|
-
theme?: HydrogenThemeSettings;
|
|
878
|
-
schema?: HydrogenThemeSchema;
|
|
879
|
-
publicEnv?: PublicEnv;
|
|
880
|
-
/** Theme's default locale JSON from themeSchema.i18n.staticContent */
|
|
881
|
-
staticContent?: Record<string, unknown>;
|
|
882
|
-
/** Locale-specific merchant overrides from the API */
|
|
883
|
-
merchantOverrides?: Record<string, unknown>;
|
|
884
|
-
_error?: string;
|
|
885
|
-
_loadFailed?: boolean;
|
|
886
|
-
};
|
|
887
|
-
type DirectFetchResponse<T = unknown> = {
|
|
888
|
-
data?: T;
|
|
889
|
-
error?: string;
|
|
890
|
-
};
|
|
891
|
-
type CacheResponseValidator<T = unknown> = (response: WithCacheFetchResponse<T> | T) => boolean;
|
|
892
|
-
declare class WeaverseError extends Error {
|
|
893
|
-
readonly code: string;
|
|
894
|
-
readonly statusCode?: number;
|
|
895
|
-
readonly context?: Record<string, unknown>;
|
|
896
|
-
constructor(message: string, code?: string, statusCode?: number, context?: Record<string, unknown>);
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Validation result type for project ID validation.
|
|
900
|
-
* Returns validation status with optional error message.
|
|
901
|
-
*/
|
|
902
|
-
type ProjectIdValidationResult = {
|
|
903
|
-
valid: boolean;
|
|
904
|
-
error?: string;
|
|
905
|
-
};
|
|
906
|
-
interface CustomPageEntry {
|
|
907
|
-
changeFrequency?: 'daily' | 'weekly' | 'monthly';
|
|
908
|
-
handle: string;
|
|
909
|
-
lastModified: string;
|
|
910
|
-
locale: string | null;
|
|
911
|
-
path: string;
|
|
912
|
-
priority?: number;
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* Type guards for response validation
|
|
916
|
-
*/
|
|
917
|
-
declare function isWithCacheFetchResponse<T>(response: unknown): response is WithCacheFetchResponse<T>;
|
|
918
|
-
declare function isFetchProjectPayload(payload: unknown): payload is FetchProjectPayload;
|
|
919
|
-
declare function hasError(response: unknown): response is {
|
|
920
|
-
error: string;
|
|
921
|
-
};
|
|
922
|
-
declare function isThemeSettingsResponse(data: unknown): data is ThemeSettingsResponse;
|
|
923
|
-
/**
|
|
924
|
-
* Enhanced type utilities for better development experience
|
|
925
|
-
*/
|
|
926
|
-
type HydrogenSchemaValidationResult = SchemaValidationResult<HydrogenComponentSchema>;
|
|
927
|
-
/**
|
|
928
|
-
* Type guard to check if a schema is valid.
|
|
929
|
-
* Leverages validation from @weaverse/schema package which provides
|
|
930
|
-
* comprehensive Zod-based validation with the ElementSchema.
|
|
931
|
-
*
|
|
932
|
-
* @param schema - Unknown value to validate
|
|
933
|
-
* @returns True if schema is a valid HydrogenComponentSchema
|
|
934
|
-
*
|
|
935
|
-
* @example
|
|
936
|
-
* ```typescript
|
|
937
|
-
* if (isValidHydrogenSchema(userInput)) {
|
|
938
|
-
* // userInput is now typed as HydrogenComponentSchema
|
|
939
|
-
* console.log(userInput.type)
|
|
940
|
-
* }
|
|
941
|
-
* ```
|
|
942
|
-
*/
|
|
943
|
-
declare function isValidHydrogenSchema(schema: unknown): schema is HydrogenComponentSchema;
|
|
944
|
-
/** Type-safe component schema authoring options. */
|
|
945
|
-
type CreateHydrogenSchemaOptions = {
|
|
946
|
-
title: string;
|
|
947
|
-
type: string;
|
|
948
|
-
limit?: number;
|
|
949
|
-
settings?: InspectorGroup[];
|
|
950
|
-
childTypes?: string[];
|
|
951
|
-
/** @deprecated Use `enabled` instead. */
|
|
952
|
-
enabledOn?: {
|
|
953
|
-
pages?: PageType[];
|
|
954
|
-
groups?: ('*' | 'header' | 'footer' | 'body')[];
|
|
955
|
-
};
|
|
956
|
-
enabled?: Resolvable<boolean, ComponentAvailabilityContext>;
|
|
957
|
-
presets?: {
|
|
958
|
-
children?: ComponentPresets[];
|
|
959
|
-
[key: string]: any;
|
|
960
|
-
};
|
|
961
|
-
};
|
|
962
|
-
declare global {
|
|
963
|
-
interface Window {
|
|
964
|
-
__weaverse?: WeaverseHydrogen;
|
|
965
|
-
__weaverses?: Record<string, WeaverseHydrogen>;
|
|
966
|
-
__weaverseThemeSettingsStore?: ThemeSettingsStore;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
interface WeaverseStudio {
|
|
970
|
-
init: (weaverse: WeaverseHydrogen) => void;
|
|
971
|
-
refreshStudio: (params: WeaverseHydrogenParams) => void;
|
|
972
|
-
}
|
|
973
|
-
declare function hasWeaverseStudio(window: Window): window is Window & {
|
|
974
|
-
weaverseStudio: WeaverseStudio;
|
|
975
|
-
};
|
|
976
|
-
declare module '@shopify/remix-oxygen' {
|
|
977
|
-
interface AppLoadContext {
|
|
978
|
-
weaverse: WeaverseClient;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
declare module '@shopify/hydrogen' {
|
|
982
|
-
interface HydrogenEnv {
|
|
983
|
-
CUSTOM_COLLECTION_BANNER_METAFIELD: string;
|
|
984
|
-
JUDGEME_PRIVATE_API_TOKEN: string;
|
|
985
|
-
KLAVIYO_PRIVATE_API_TOKEN: string;
|
|
986
|
-
METAOBJECT_COLOR_NAME_KEY: string;
|
|
987
|
-
METAOBJECT_COLOR_VALUE_KEY: string;
|
|
988
|
-
METAOBJECT_COLORS_TYPE: string;
|
|
989
|
-
PUBLIC_GOOGLE_GTM_ID: string;
|
|
990
|
-
PUBLIC_SHOPIFY_INBOX_SHOP_ID: string;
|
|
991
|
-
PUBLIC_STORE_DOMAIN: string;
|
|
992
|
-
PUBLIC_STOREFRONT_API_TOKEN: string;
|
|
993
|
-
WEAVERSE_API_KEY: string;
|
|
994
|
-
WEAVERSE_HOST?: string;
|
|
995
|
-
WEAVERSE_PROJECT_ID: string;
|
|
996
|
-
WEAVERSE_PUBLIC_API_BASE?: string;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
/**
|
|
1000
|
-
* Parameters for loadPage method supporting route-level project override.
|
|
1001
|
-
*
|
|
1002
|
-
* @example Basic usage (uses client-level project)
|
|
1003
|
-
* ```ts
|
|
1004
|
-
* const weaverseData = await weaverse.loadPage({
|
|
1005
|
-
* type: 'PRODUCT',
|
|
1006
|
-
* handle: params.productHandle
|
|
1007
|
-
* })
|
|
1008
|
-
* ```
|
|
1009
|
-
*
|
|
1010
|
-
* @example Route-level project override
|
|
1011
|
-
* ```ts
|
|
1012
|
-
* export async function loader({ params, context }: LoaderFunctionArgs) {
|
|
1013
|
-
* const { weaverse } = context
|
|
1014
|
-
*
|
|
1015
|
-
* // Use special campaign project for this route only
|
|
1016
|
-
* const weaverseData = await weaverse.loadPage({
|
|
1017
|
-
* type: 'PRODUCT',
|
|
1018
|
-
* handle: params.productHandle,
|
|
1019
|
-
* projectId: process.env.WEAVERSE_PROJECT_CAMPAIGN // Override
|
|
1020
|
-
* })
|
|
1021
|
-
*
|
|
1022
|
-
* return { weaverseData }
|
|
1023
|
-
* }
|
|
1024
|
-
* ```
|
|
1025
|
-
*/
|
|
1026
|
-
type LoadPageParams = {
|
|
1027
|
-
/**
|
|
1028
|
-
* Page type to load from Weaverse CMS.
|
|
1029
|
-
*
|
|
1030
|
-
* Determines which template to use for rendering the page.
|
|
1031
|
-
* Falls back to 'INDEX' if not specified or if page type doesn't exist.
|
|
1032
|
-
*
|
|
1033
|
-
* @default 'INDEX'
|
|
1034
|
-
*/
|
|
1035
|
-
type?: PageType;
|
|
1036
|
-
/**
|
|
1037
|
-
* Locale for internationalization.
|
|
1038
|
-
*
|
|
1039
|
-
* Format: IETF BCP 47 language tag (e.g., 'en-US', 'fr-FR', 'de-DE')
|
|
1040
|
-
* Used to load locale-specific content and translations.
|
|
1041
|
-
*/
|
|
1042
|
-
locale?: string;
|
|
1043
|
-
/**
|
|
1044
|
-
* Page handle for dynamic pages.
|
|
1045
|
-
*
|
|
1046
|
-
* Identifies specific resource within page type:
|
|
1047
|
-
* - Product handle: 'red-sneakers'
|
|
1048
|
-
* - Collection handle: 'summer-sale'
|
|
1049
|
-
* - Page handle: 'about-us'
|
|
1050
|
-
* - Article handle: 'how-to-style-sneakers'
|
|
1051
|
-
*/
|
|
1052
|
-
handle?: string;
|
|
1053
|
-
/**
|
|
1054
|
-
* Cache strategy override for this specific page load.
|
|
1055
|
-
*
|
|
1056
|
-
* Overrides default cache strategy for special use cases:
|
|
1057
|
-
* - Fresh content for checkout pages (no cache)
|
|
1058
|
-
* - Long-lived cache for static pages (1 hour+)
|
|
1059
|
-
* - Short-lived cache for frequently updated content (5 minutes)
|
|
1060
|
-
*/
|
|
1061
|
-
strategy?: CachingStrategy;
|
|
1062
|
-
/**
|
|
1063
|
-
* Optional project override for this specific page load.
|
|
1064
|
-
*
|
|
1065
|
-
* **Precedence**: Route-level projectId takes precedence over client-level projectId.
|
|
1066
|
-
*
|
|
1067
|
-
* **Use Cases**:
|
|
1068
|
-
* - Campaign landing pages with custom content
|
|
1069
|
-
* - VIP customer experiences with dedicated projects
|
|
1070
|
-
* - A/B testing specific pages without changing global config
|
|
1071
|
-
* - Seasonal promotions with limited-time content
|
|
1072
|
-
*
|
|
1073
|
-
* **Validation**:
|
|
1074
|
-
* - Must be non-empty string
|
|
1075
|
-
* - Validated before API call
|
|
1076
|
-
* - Falls back to client-level projectId if undefined
|
|
1077
|
-
* - Does NOT support function (string only)
|
|
1078
|
-
*
|
|
1079
|
-
* **Cache Isolation**:
|
|
1080
|
-
* Override projectId is included in cache key, ensuring separate caches
|
|
1081
|
-
* for different projects even on the same route.
|
|
1082
|
-
*
|
|
1083
|
-
* @example Campaign page override
|
|
1084
|
-
* ```ts
|
|
1085
|
-
* const campaignData = await weaverse.loadPage({
|
|
1086
|
-
* type: 'PAGE',
|
|
1087
|
-
* handle: 'summer-sale',
|
|
1088
|
-
* projectId: process.env.WEAVERSE_PROJECT_CAMPAIGN
|
|
1089
|
-
* })
|
|
1090
|
-
* ```
|
|
1091
|
-
*/
|
|
1092
|
-
projectId?: string;
|
|
1093
|
-
};
|
|
1094
|
-
/** A single translated field for one item */
|
|
1095
|
-
interface TranslationMapEntry {
|
|
1096
|
-
originalValue: string;
|
|
1097
|
-
translatedValue: string;
|
|
1098
|
-
}
|
|
1099
|
-
/** Per-item translation fields, keyed by field name */
|
|
1100
|
-
type TranslationItemEntry = {
|
|
1101
|
-
[key: string]: TranslationMapEntry;
|
|
1102
|
-
};
|
|
1103
|
-
/**
|
|
1104
|
-
* Translation map sent from the builder alongside page data in design mode.
|
|
1105
|
-
* Keyed by item ID, each value maps field names to translation entries.
|
|
1106
|
-
*/
|
|
1107
|
-
type TranslationMap = {
|
|
1108
|
-
[itemId: string]: TranslationItemEntry;
|
|
1109
|
-
};
|
|
1110
|
-
/** A single translation entry for save payloads */
|
|
1111
|
-
interface TranslationEntry {
|
|
1112
|
-
deleted?: boolean;
|
|
1113
|
-
itemId: string;
|
|
1114
|
-
key: string;
|
|
1115
|
-
originalValue: string;
|
|
1116
|
-
translatedValue: string;
|
|
1117
|
-
}
|
|
1118
|
-
/** Result of collecting translation changes for the save flow */
|
|
1119
|
-
type TranslationChanges = {
|
|
1120
|
-
languageId: string;
|
|
1121
|
-
entries: TranslationEntry[];
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
|
-
declare let defaultComponents: HydrogenComponent[];
|
|
1125
|
-
|
|
1126
|
-
interface RouteKeyedDataContext {
|
|
1127
|
-
root?: Record<string, unknown>;
|
|
1128
|
-
[routeKey: `routes/${string}`]: Record<string, unknown>;
|
|
1129
|
-
}
|
|
1130
|
-
type WeaverseDataContext = RouteKeyedDataContext & Record<string, unknown>;
|
|
1131
|
-
/**
|
|
1132
|
-
* Hook to get flat route-keyed data context from matches
|
|
1133
|
-
* Returns: {root: {...}, "routes/xxx": {...}}
|
|
1134
|
-
* No more useLoaderData dependency - everything comes from matches
|
|
1135
|
-
*/
|
|
1136
|
-
declare function useWeaverseDataContext(): WeaverseDataContext;
|
|
1137
|
-
/**
|
|
1138
|
-
* Helper function to create flat route-keyed data context from useMatches() result
|
|
1139
|
-
* Returns: {root: {...}, "routes/xxx": {...}}
|
|
1140
|
-
*/
|
|
1141
|
-
declare function createWeaverseDataContext(matches: UIMatch<unknown, unknown>[]): WeaverseDataContext;
|
|
1142
|
-
|
|
1143
|
-
/**
|
|
1144
|
-
* Convert a Weaverse page-level SEO payload into React Router
|
|
1145
|
-
* `MetaDescriptor[]`. Pure, synchronous, tree-shakeable — does not fetch.
|
|
1146
|
-
*
|
|
1147
|
-
* Behavior:
|
|
1148
|
-
* - `title` → top-level `{ title }` descriptor.
|
|
1149
|
-
* - `description` / `keywords` → `<meta name="...">`.
|
|
1150
|
-
* - `canonicalUrl` → `<link rel="canonical">`.
|
|
1151
|
-
* - `openGraph.*` → `<meta property="og:*">`. `og:type` defaults to
|
|
1152
|
-
* `'website'` when any other OG field is present.
|
|
1153
|
-
* - `twitter.*` → `<meta name="twitter:*">`. `twitter:card` defaults to
|
|
1154
|
-
* `'summary'` when any other Twitter field is present.
|
|
1155
|
-
* - `robots` is always emitted (defaults to `'index,follow'`) so themes
|
|
1156
|
-
* stacking multiple SEO sources have a deterministic last word on
|
|
1157
|
-
* indexing for Weaverse-managed pages.
|
|
1158
|
-
* - Empty strings / missing fields are filtered before return so empty
|
|
1159
|
-
* descriptors don't override earlier sources (e.g. Hydrogen
|
|
1160
|
-
* `getSeoMeta`).
|
|
1161
|
-
*/
|
|
1162
|
-
declare function formatMetaDescriptors(seo: PageSEOData | null | undefined): MetaDescriptor[];
|
|
1163
|
-
/**
|
|
1164
|
-
* Convenience accessor: pull `page.seo` out of a `WeaverseLoaderData`
|
|
1165
|
-
* (or `HydrogenPageData`) and emit `MetaDescriptor[]`. Null-safe.
|
|
1166
|
-
*
|
|
1167
|
-
* @example
|
|
1168
|
-
* ```ts
|
|
1169
|
-
* export const meta: MetaFunction<typeof loader> = ({ data }) => {
|
|
1170
|
-
* return getWeaverseSeoMeta(data?.weaverseData)
|
|
1171
|
-
* }
|
|
1172
|
-
* ```
|
|
1173
|
-
*/
|
|
1174
|
-
declare function getWeaverseSeoMeta(data: WeaverseLoaderData | HydrogenPageData | {
|
|
1175
|
-
page?: HydrogenPageData | null;
|
|
1176
|
-
} | null | undefined): MetaDescriptor[];
|
|
1177
|
-
|
|
1178
|
-
/**
|
|
1179
|
-
* Extract and parse query parameters from a request URL.
|
|
1180
|
-
* Supports optional allowlist for security-sensitive applications.
|
|
1181
|
-
*
|
|
1182
|
-
* @param request - The incoming request
|
|
1183
|
-
* @param options - Optional configuration
|
|
1184
|
-
* @param options.allowedKeys - If provided, only these keys will be extracted
|
|
1185
|
-
* @returns Parsed query parameters with type coercion for booleans
|
|
1186
|
-
*
|
|
1187
|
-
* @example
|
|
1188
|
-
* ```typescript
|
|
1189
|
-
* // Extract all params
|
|
1190
|
-
* const queries = getRequestQueries(request)
|
|
1191
|
-
*
|
|
1192
|
-
* // Extract only allowed params (security-sensitive)
|
|
1193
|
-
* const queries = getRequestQueries(request, {
|
|
1194
|
-
* allowedKeys: ['weaverseProjectId', 'weaverseHost']
|
|
1195
|
-
* })
|
|
1196
|
-
* ```
|
|
1197
|
-
*/
|
|
1198
|
-
declare function getRequestQueries<T = Record<string, string | boolean>>(request: Request, options?: {
|
|
1199
|
-
allowedKeys?: string[];
|
|
1200
|
-
}): T;
|
|
1201
|
-
declare function getWeaverseConfigs(request: Request, env: HydrogenEnv): WeaverseProjectConfigs;
|
|
1202
|
-
/**
|
|
1203
|
-
* Generate default data from component or theme schema.
|
|
1204
|
-
* Results are memoized using WeakMap for performance.
|
|
1205
|
-
*
|
|
1206
|
-
* @param schema - Component or theme schema
|
|
1207
|
-
* @returns Default data object extracted from schema inputs
|
|
1208
|
-
*/
|
|
1209
|
-
declare function generateDataFromSchema(schema: HydrogenComponentSchema | HydrogenThemeSchema): Record<string, any>;
|
|
1210
|
-
declare function getPreviewData(type: string, components: HydrogenComponent[], weaverseHost: string): WeaverseLoaderData;
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
* Filter out Weaverse-specific query parameters from product options.
|
|
1214
|
-
* Removes `isDesignMode` and any parameters starting with `weaverse` prefix.
|
|
1215
|
-
*
|
|
1216
|
-
* @param request - The incoming HTTP request
|
|
1217
|
-
* @returns Filtered product options for Shopify Hydrogen
|
|
1218
|
-
*
|
|
1219
|
-
* @example
|
|
1220
|
-
* ```typescript
|
|
1221
|
-
* export async function loader({ request }: LoaderFunctionArgs) {
|
|
1222
|
-
* const selectedOptions = getSelectedProductOptions(request)
|
|
1223
|
-
* // Use selectedOptions for product queries without Weaverse params
|
|
1224
|
-
* }
|
|
1225
|
-
* ```
|
|
1226
|
-
*/
|
|
1227
|
-
declare function getSelectedProductOptions(request: Request): SelectedOptionInput[];
|
|
1228
|
-
declare const IMAGES_PLACEHOLDERS: {
|
|
1229
|
-
logo_white: string;
|
|
1230
|
-
logo_black: string;
|
|
1231
|
-
image: string;
|
|
1232
|
-
banner_1: string;
|
|
1233
|
-
banner_2: string;
|
|
1234
|
-
collection_1: string;
|
|
1235
|
-
collection_2: string;
|
|
1236
|
-
collection_3: string;
|
|
1237
|
-
collection_4: string;
|
|
1238
|
-
collection_5: string;
|
|
1239
|
-
collection_6: string;
|
|
1240
|
-
product_1: string;
|
|
1241
|
-
product_2: string;
|
|
1242
|
-
product_3: string;
|
|
1243
|
-
product_4: string;
|
|
1244
|
-
product_5: string;
|
|
1245
|
-
product_6: string;
|
|
1246
|
-
product_7: string;
|
|
1247
|
-
product_8: string;
|
|
1248
|
-
product_9: string;
|
|
1249
|
-
product_10: string;
|
|
1250
|
-
product_11: string;
|
|
1251
|
-
product_12: string;
|
|
1252
|
-
product_13: string;
|
|
1253
|
-
product_14: string;
|
|
1254
|
-
product_15: string;
|
|
1255
|
-
product_16: string;
|
|
1256
|
-
product_17: string;
|
|
1257
|
-
product_18: string;
|
|
1258
|
-
};
|
|
1259
|
-
|
|
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 };
|