@weaverse/hydrogen 5.17.1 → 5.19.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
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type { ElementData } from '@weaverse/react';
|
|
2
|
+
import { Weaverse, WeaverseItemStore } from '@weaverse/react';
|
|
3
|
+
import { type ComponentType, type JSX } from 'react';
|
|
4
|
+
import { type TranslateFunction } from './hooks/translation-context';
|
|
5
|
+
import type { HydrogenComponentData, HydrogenElement, HydrogenPageData, HydrogenThemeSettings, TranslationChanges, TranslationMap, WeaverseInternal, WeaverseLoaderRequestInfo } from './index';
|
|
6
|
+
import type { HydrogenComponent, WeaverseHydrogenParams } from './types';
|
|
7
|
+
import { type WeaverseDataValue } from './utils/pick-weaverse-data';
|
|
8
|
+
/** Runtime store for one rendered Hydrogen component instance. */
|
|
9
|
+
export declare class WeaverseHydrogenItem extends WeaverseItemStore {
|
|
10
|
+
/** Owning Hydrogen runtime instance. */
|
|
11
|
+
weaverse: WeaverseHydrogen;
|
|
12
|
+
/**
|
|
13
|
+
* Cached merged snapshot (base + translations).
|
|
14
|
+
* Reset to `null` whenever `_store` or the item's translation entry changes.
|
|
15
|
+
*/
|
|
16
|
+
private _cachedSnapshot;
|
|
17
|
+
private _snapshotStoreRef;
|
|
18
|
+
private _snapshotTranslationRef;
|
|
19
|
+
/** Creates an item store from serialized component data and its owner. */
|
|
20
|
+
constructor(initialData: HydrogenComponentData, weaverse: WeaverseHydrogen);
|
|
21
|
+
/** Registered component definition for this item's type. */
|
|
22
|
+
get Element(): HydrogenElement;
|
|
23
|
+
/**
|
|
24
|
+
* Override getSnapShot to merge translation data when in translation mode.
|
|
25
|
+
* Memoizes the result: returns the same object reference as long as
|
|
26
|
+
* both `_store` and the translation entry haven't changed.
|
|
27
|
+
* This is critical for `useSyncExternalStore` stability.
|
|
28
|
+
*/
|
|
29
|
+
getSnapShot: () => ElementData;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hydrogen-specific Weaverse runtime that owns page data, component stores,
|
|
33
|
+
* Studio state, and translation sidecars for one rendered page.
|
|
34
|
+
*/
|
|
35
|
+
export declare class WeaverseHydrogen extends Weaverse {
|
|
36
|
+
/** Identifier of the rendered page. */
|
|
37
|
+
pageId: string;
|
|
38
|
+
/** Runtime services and project metadata exposed to integrations. */
|
|
39
|
+
internal: Partial<WeaverseInternal>;
|
|
40
|
+
/** Normalized URL and locale information for the current request. */
|
|
41
|
+
requestInfo: WeaverseLoaderRequestInfo;
|
|
42
|
+
/** Identifier of the project supplying the page. */
|
|
43
|
+
projectId: string;
|
|
44
|
+
/** Origin used for Studio assets and editor communication. */
|
|
45
|
+
weaverseHost: string;
|
|
46
|
+
/** Base URL used for public content API requests. */
|
|
47
|
+
weaverseApiBase: string;
|
|
48
|
+
/**
|
|
49
|
+
* API key read from environment/configuration for storefront requests or
|
|
50
|
+
* supplied by Studio requests while editing and previewing.
|
|
51
|
+
*/
|
|
52
|
+
weaverseApiKey: string;
|
|
53
|
+
/** Studio asset version supplied by the preview request. */
|
|
54
|
+
weaverseVersion: string;
|
|
55
|
+
/** Whether the page is running inside the visual editor. */
|
|
56
|
+
isDesignMode: boolean;
|
|
57
|
+
/** Whether a single component preview is being rendered. */
|
|
58
|
+
isPreviewMode: boolean;
|
|
59
|
+
/** Whether a saved page revision is being previewed. */
|
|
60
|
+
isRevisionPreview: boolean;
|
|
61
|
+
/** Component type requested by section preview mode. */
|
|
62
|
+
sectionType: string;
|
|
63
|
+
/** Component item store constructor used by the core runtime. */
|
|
64
|
+
ItemConstructor: typeof WeaverseHydrogenItem;
|
|
65
|
+
/** Current page content owned by the runtime. */
|
|
66
|
+
data: HydrogenPageData;
|
|
67
|
+
/** Component item stores indexed by instance ID. */
|
|
68
|
+
static itemInstances: Map<string, WeaverseHydrogenItem>;
|
|
69
|
+
/** Registered component definitions indexed by component type. */
|
|
70
|
+
static elementRegistry: Map<string, HydrogenElement>;
|
|
71
|
+
/**
|
|
72
|
+
* Translation map received from the builder in design mode.
|
|
73
|
+
* Keyed by item ID, each entry maps field names to translated values.
|
|
74
|
+
* `WeaverseHydrogenItem.getSnapShot()` merges these into the data
|
|
75
|
+
* returned to components, so translations render without monkey-patching.
|
|
76
|
+
*/
|
|
77
|
+
translationMap: TranslationMap;
|
|
78
|
+
/** Locale code for the active translation sidecar. */
|
|
79
|
+
translationLocale: string;
|
|
80
|
+
/** Builder language identifier for the active translation sidecar. */
|
|
81
|
+
translationLanguageId: string;
|
|
82
|
+
/** Creates a page runtime from resolved loader data and request settings. */
|
|
83
|
+
constructor(params: WeaverseHydrogenParams);
|
|
84
|
+
/**
|
|
85
|
+
* Extract translation sidecar data from `this.data` (the page data).
|
|
86
|
+
* The builder attaches `translationMap`, `translationLocale`, and
|
|
87
|
+
* `translationLanguageId` to the page data in design mode.
|
|
88
|
+
*/
|
|
89
|
+
extractTranslationSidecar: () => void;
|
|
90
|
+
/**
|
|
91
|
+
* Set the translation sidecar data.
|
|
92
|
+
* Called by the studio bridge when translation data arrives or changes.
|
|
93
|
+
* Triggers a re-render of all items so translated snapshots are recalculated.
|
|
94
|
+
*/
|
|
95
|
+
setTranslationSidecar: (translationMap: TranslationMap, locale: string, languageId: string) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Update a single translation entry for a specific item field.
|
|
98
|
+
* Used by the studio bridge when the user edits a translatable field.
|
|
99
|
+
*/
|
|
100
|
+
updateTranslation: (itemId: string, key: string, originalValue: string, translatedValue: string) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Collect all translation changes across all weaverse instances.
|
|
103
|
+
* Used by the save flow to persist translation edits.
|
|
104
|
+
*/
|
|
105
|
+
getTranslationChanges: () => TranslationChanges | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Override setProjectData to re-extract translation sidecar from new page data.
|
|
108
|
+
*/
|
|
109
|
+
setProjectData: (data: HydrogenPageData) => void;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Register a Weaverse component with the global element registry.
|
|
113
|
+
* Must be called before rendering components in WeaverseHydrogenRoot.
|
|
114
|
+
*
|
|
115
|
+
* @param element - Component configuration with schema, Component, and optional loader
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* import Hero from './sections/Hero'
|
|
120
|
+
* import { schema } from './sections/Hero'
|
|
121
|
+
*
|
|
122
|
+
* registerComponent({
|
|
123
|
+
* type: 'hero',
|
|
124
|
+
* Component: Hero,
|
|
125
|
+
* schema,
|
|
126
|
+
* loader: async ({ data, weaverse }) => {
|
|
127
|
+
* return { someData: 'value' }
|
|
128
|
+
* }
|
|
129
|
+
* })
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare function registerComponent(element: HydrogenElement): void;
|
|
133
|
+
/** Props passed to a custom Weaverse page error component. */
|
|
134
|
+
export interface WeaverseHydrogenRootErrorProps {
|
|
135
|
+
/** Error raised while resolving or rendering the Weaverse page. */
|
|
136
|
+
error: Error | unknown;
|
|
137
|
+
}
|
|
138
|
+
/** Props accepted by {@link WeaverseHydrogenRoot}. */
|
|
139
|
+
export interface WeaverseHydrogenRootProps {
|
|
140
|
+
/** Theme components available to the page renderer. */
|
|
141
|
+
components: HydrogenComponent[];
|
|
142
|
+
/**
|
|
143
|
+
* Optional explicit `weaverseData` payload. When provided, bypasses the
|
|
144
|
+
* automatic route-scoped resolution. Accepts a resolved value, a
|
|
145
|
+
* `Promise` (handled via `<Await>`), or `null` to suppress rendering.
|
|
146
|
+
*
|
|
147
|
+
* Recommended for nested layout + child route compositions where two
|
|
148
|
+
* `<WeaverseHydrogenRoot>` instances need to render different Weaverse
|
|
149
|
+
* pages on the same URL. See issue #451.
|
|
150
|
+
*/
|
|
151
|
+
data?: WeaverseDataValue;
|
|
152
|
+
/** Component rendered when page data cannot be resolved or awaited. */
|
|
153
|
+
errorComponent?: React.FC<WeaverseHydrogenRootErrorProps>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Renders the Weaverse page for the current React Router route.
|
|
157
|
+
*
|
|
158
|
+
* Pass `data` to override automatic route-loader resolution. A promise is
|
|
159
|
+
* handled with React Router's `Await`, while explicit `null` suppresses output.
|
|
160
|
+
*/
|
|
161
|
+
export declare const WeaverseHydrogenRoot: import("react").MemoExoticComponent<({ components, data: dataProp, errorComponent: ErrorComponent, }: WeaverseHydrogenRootProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
162
|
+
/**
|
|
163
|
+
* Options for the `withWeaverse` HOC.
|
|
164
|
+
*/
|
|
165
|
+
export type WithWeaverseOptions = {
|
|
166
|
+
/**
|
|
167
|
+
* Optional external translation function (e.g. from Shopify i18n).
|
|
168
|
+
* When provided it becomes the **highest-priority** source
|
|
169
|
+
* in the `t()` resolution chain exposed by `useTranslation()`.
|
|
170
|
+
*/
|
|
171
|
+
t?: TranslateFunction;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Higher-order component that wraps your app with Weaverse theme settings and
|
|
175
|
+
* translation context, and mounts the Studio connect bridge.
|
|
176
|
+
*
|
|
177
|
+
* Export the result as your root route's **`Layout`** (not the default route
|
|
178
|
+
* `Component`). In React Router the root `Layout` wraps both the matched route
|
|
179
|
+
* and its `ErrorBoundary`, so the Studio bridge keeps rendering on 404s and
|
|
180
|
+
* loader/render errors — exactly the pages where Studio must still answer its
|
|
181
|
+
* handshake instead of reporting a false "Connection lost". A default-component
|
|
182
|
+
* wrapper (`export default withWeaverse(App)`) is replaced by the error
|
|
183
|
+
* boundary on those routes and would drop the bridge.
|
|
184
|
+
*
|
|
185
|
+
* @param Component - The root layout component to wrap
|
|
186
|
+
* @param options - Optional configuration (e.g. an external `t` function)
|
|
187
|
+
* @returns Wrapped component with theme settings + translation providers
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* import { withWeaverse } from '@weaverse/hydrogen'
|
|
192
|
+
*
|
|
193
|
+
* // Basic usage — export as the root route Layout
|
|
194
|
+
* export const Layout = withWeaverse(RootLayout)
|
|
195
|
+
*
|
|
196
|
+
* // With an external translation function
|
|
197
|
+
* export const Layout = withWeaverse(RootLayout, { t: myI18nFunction })
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export declare function withWeaverse(Component: ComponentType<any>, options?: WithWeaverseOptions): (props: JSX.IntrinsicAttributes) => import("react/jsx-runtime").JSX.Element;
|
|
201
|
+
/**
|
|
202
|
+
* React hook to access Weaverse theme settings from anywhere in your component tree.
|
|
203
|
+
* Must be used within a component wrapped by `withWeaverse` or inside `WeaverseHydrogenRoot`.
|
|
204
|
+
*
|
|
205
|
+
* @returns Current theme settings object
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* function MyComponent() {
|
|
210
|
+
* const theme = useThemeSettings()
|
|
211
|
+
* const primaryColor = theme.colors?.primary
|
|
212
|
+
*
|
|
213
|
+
* return <div style={{ color: primaryColor }}>Styled content</div>
|
|
214
|
+
* }
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export declare function useThemeSettings<T = HydrogenThemeSettings>(): T;
|
|
218
|
+
//# sourceMappingURL=WeaverseHydrogenRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WeaverseHydrogenRoot.d.ts","sourceRoot":"","sources":["../../src/WeaverseHydrogenRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAGL,QAAQ,EACR,iBAAiB,EAElB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,GAAG,EAKT,MAAM,OAAO,CAAA;AASd,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAGlB,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EAEvB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAA;AA4BnC,kEAAkE;AAClE,qBAAa,oBAAqB,SAAQ,iBAAiB;IACzD,wCAAwC;IAChC,QAAQ,EAAE,gBAAgB,CAAA;IAElC;;;OAGG;IACH,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,iB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gB,CAAC,CAAC,GAAG,qBAAqB,KAOrC,CAAC,CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAGjD,8EAA8E;AAC9E,eAAO,IAAI,iBAAiB,EAAE,iBAAiB,EAK9C,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SchemaType } from '@weaverse/schema';
|
|
2
|
+
import type { HTMLAttributes } from 'react';
|
|
3
|
+
import type { HydrogenComponentProps } from '../types';
|
|
4
|
+
declare function Main(props: HydrogenComponentProps & HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export default Main;
|
|
6
|
+
export declare let schema: SchemaType;
|
|
7
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/components/main.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAMtD,iBAAS,IAAI,CAAC,KAAK,EAAE,sBAAsB,GAAG,cAAc,CAAC,cAAc,CAAC,2CAY3E;AAED,eAAe,IAAI,CAAA;AAEnB,eAAO,IAAI,MAAM,EAAE,UAGjB,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createTranslate, getNestedKey, interpolate, ThemeTextProvider, type ThemeTextProviderProps, type ThemeTextValue, type TranslateFunction, TranslationProvider, type TranslationProviderProps, type TranslationValue, useThemeText, useTranslation, } from './translation-context';
|
|
2
|
+
//# sourceMappingURL=theme-text-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-text-context.d.ts","sourceRoot":"","sources":["../../../src/hooks/theme-text-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { TranslationStore } from '../utils/translation-store';
|
|
3
|
+
/**
|
|
4
|
+
* Traverse a nested object by dot-path.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* getNestedKey({ cart: { title: 'Cart' } }, 'cart.title') // => 'Cart'
|
|
8
|
+
* getNestedKey({}, 'cart.title', 'fallback') // => 'fallback'
|
|
9
|
+
*/
|
|
10
|
+
export declare function getNestedKey(obj: Record<string, unknown>, path: string, fallback?: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Replace `{{variable}}` patterns in a string with provided values.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* interpolate('Hello {{name}}!', { name: 'World' }) // => 'Hello World!'
|
|
16
|
+
* interpolate('-{{percentage}}% Off', { percentage: 15 }) // => '-15% Off'
|
|
17
|
+
*/
|
|
18
|
+
export declare function interpolate(template: string, variables?: Record<string, string | number>): string;
|
|
19
|
+
/**
|
|
20
|
+
* Signature for a translation function.
|
|
21
|
+
*/
|
|
22
|
+
export type TranslateFunction = (key: string, variables?: Record<string, string | number>) => string;
|
|
23
|
+
/** Translation function, stores, and locale overrides exposed by the provider. */
|
|
24
|
+
export type TranslationValue = {
|
|
25
|
+
/**
|
|
26
|
+
* Translate a key with optional variable interpolation.
|
|
27
|
+
*
|
|
28
|
+
* Priority chain (highest wins):
|
|
29
|
+
* 1. External `t` (passed into `withWeaverse` / `TranslationProvider`)
|
|
30
|
+
* 2. `merchantOverrides` (DB overrides for the current locale + design overrides)
|
|
31
|
+
* 3. `staticContent` (theme default JSON)
|
|
32
|
+
* 4. The key itself (fallback)
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* t('cart.title') // => "Cart"
|
|
36
|
+
* t('badge.sale', { percentage: 15 }) // => "-15% Off"
|
|
37
|
+
*/
|
|
38
|
+
t: TranslateFunction;
|
|
39
|
+
/** Exposed for useStudio to attach to weaverse.internal. Null in production. */
|
|
40
|
+
translationStore: TranslationStore | null;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use {@link TranslationValue.translationStore} instead. Kept as a
|
|
43
|
+
* backward-compatible alias pointing at the same store instance.
|
|
44
|
+
*/
|
|
45
|
+
themeTextStore: TranslationStore | null;
|
|
46
|
+
/** Active-locale translated keys loaded from the storefront API. */
|
|
47
|
+
merchantOverrides: Record<string, unknown> | null;
|
|
48
|
+
};
|
|
49
|
+
/** Inputs accepted by {@link TranslationProvider}. */
|
|
50
|
+
export type TranslationProviderProps = {
|
|
51
|
+
/** Theme-provided default-locale translation content. */
|
|
52
|
+
staticContent: Record<string, unknown>;
|
|
53
|
+
/** Active-locale translations published by the merchant. */
|
|
54
|
+
merchantOverrides?: Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Optional external translation function.
|
|
57
|
+
* When provided it becomes the **highest-priority** source:
|
|
58
|
+
* if it returns a non-empty string that differs from the raw key,
|
|
59
|
+
* that value is used; otherwise the internal resolution chain continues.
|
|
60
|
+
*/
|
|
61
|
+
t?: TranslateFunction;
|
|
62
|
+
/** Optional store for live design-mode text overrides from the builder. */
|
|
63
|
+
translationStore?: TranslationStore | null;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated Use {@link TranslationProviderProps.translationStore} instead.
|
|
66
|
+
* Still accepted for backward compatibility; ignored when `translationStore`
|
|
67
|
+
* is also provided.
|
|
68
|
+
*/
|
|
69
|
+
themeTextStore?: TranslationStore | null;
|
|
70
|
+
/** React content that can consume the translation context. */
|
|
71
|
+
children: ReactNode;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Build the `t()` translation function over a fixed set of sources.
|
|
75
|
+
*
|
|
76
|
+
* Resolution order, highest priority first:
|
|
77
|
+
* 1. `externalT` – host i18n (e.g. Shopify), unless it echoes the key
|
|
78
|
+
* 2. `designOverrides` – live design-mode edits, flat dot-path keys
|
|
79
|
+
* 3. `merchantOverrides` – locale overrides from the API, nested
|
|
80
|
+
* 4. `staticContent` – the theme's default locale JSON
|
|
81
|
+
* 5. the key itself
|
|
82
|
+
*
|
|
83
|
+
* Design overrides are looked up per-key (own properties only) rather than
|
|
84
|
+
* merged into `merchantOverrides`: a flat key like `cart.title` must override
|
|
85
|
+
* exactly that leaf without wiping sibling keys (`cart.subtitle`), and a
|
|
86
|
+
* per-key own-property lookup never builds nested objects from
|
|
87
|
+
* merchant-controlled keys, so it cannot pollute `Object.prototype`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function createTranslate(sources: {
|
|
90
|
+
staticContent: Record<string, unknown>;
|
|
91
|
+
merchantOverrides?: Record<string, unknown>;
|
|
92
|
+
designOverrides?: Record<string, string>;
|
|
93
|
+
externalT?: TranslateFunction;
|
|
94
|
+
}): TranslateFunction;
|
|
95
|
+
/**
|
|
96
|
+
* Provider that wraps the app to expose the `t()` function.
|
|
97
|
+
*
|
|
98
|
+
* - `staticContent` – the theme's default locale JSON (from themeSchema.i18n)
|
|
99
|
+
* - `merchantOverrides` – locale-specific overrides fetched from the API
|
|
100
|
+
* - `translationStore` – optional store for live design-mode text overrides
|
|
101
|
+
* (the deprecated `themeTextStore` prop is accepted as a fallback)
|
|
102
|
+
*/
|
|
103
|
+
export declare function TranslationProvider({ staticContent, merchantOverrides, t: externalT, translationStore, themeTextStore, children, }: TranslationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
104
|
+
/**
|
|
105
|
+
* Hook to access the translation `t()` function.
|
|
106
|
+
*
|
|
107
|
+
* Must be used inside a component wrapped by `withWeaverse` or `TranslationProvider`.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```tsx
|
|
111
|
+
* function CartTitle() {
|
|
112
|
+
* const { t } = useTranslation()
|
|
113
|
+
* return <h2>{t('cart.title')}</h2>
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function useTranslation(): TranslationValue;
|
|
118
|
+
/**
|
|
119
|
+
* Legacy name for {@link TranslationProvider}.
|
|
120
|
+
* @deprecated Use {@link TranslationProvider} instead.
|
|
121
|
+
*/
|
|
122
|
+
export declare const ThemeTextProvider: typeof TranslationProvider;
|
|
123
|
+
/**
|
|
124
|
+
* Legacy name for {@link useTranslation}.
|
|
125
|
+
* @deprecated Use {@link useTranslation} instead.
|
|
126
|
+
*/
|
|
127
|
+
export declare const useThemeText: typeof useTranslation;
|
|
128
|
+
/**
|
|
129
|
+
* Legacy name for {@link TranslationValue}.
|
|
130
|
+
* @deprecated Use {@link TranslationValue} instead.
|
|
131
|
+
*/
|
|
132
|
+
export type ThemeTextValue = TranslationValue;
|
|
133
|
+
/**
|
|
134
|
+
* Legacy name for {@link TranslationProviderProps}.
|
|
135
|
+
* @deprecated Use {@link TranslationProviderProps} instead.
|
|
136
|
+
*/
|
|
137
|
+
export type ThemeTextProviderProps = TranslationProviderProps;
|
|
138
|
+
//# sourceMappingURL=translation-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation-context.d.ts","sourceRoot":"","sources":["../../../src/hooks/translation-context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAA;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAElE;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,CAAC,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ACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,SAAS,CAAC,EAAE,iBAAiB,CAAA;CAC9B,GAAG,iBAAiB,CA6BpB;AAQD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,aAAa,EACb,iBAAiB,EACjB,CAAC,EAAE,SAAS,EACZ,gBAAgB,EAChB,cAAc,EACd,QAAQ,GACT,EAAE,wBAAwB,2CAgC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAQjD;AAMD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,4BAAsB,CAAA;AACpD;;;GAGG;AACH,eAAO,MAAM,YAAY,uBAAiB,CAAA;AAC1C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAC7C;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type UIMatch } from 'react-router';
|
|
2
|
+
/** Loader data indexed by React Router's conventional route identifiers. */
|
|
3
|
+
export interface RouteKeyedDataContext {
|
|
4
|
+
/** Root route loader data, when the root loader returned an object. */
|
|
5
|
+
root?: Record<string, unknown>;
|
|
6
|
+
/** Loader data for a non-root route keyed by its route identifier. */
|
|
7
|
+
[routeKey: `routes/${string}`]: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Flat loader-data map keyed by React Router route ID.
|
|
11
|
+
* Use route IDs such as `root` or `routes/products.$handle` in data bindings.
|
|
12
|
+
*/
|
|
13
|
+
export type WeaverseDataContext = RouteKeyedDataContext & Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Hook to get flat route-keyed data context from matches
|
|
16
|
+
* Returns: {root: {...}, "routes/xxx": {...}}
|
|
17
|
+
* No more useLoaderData dependency - everything comes from matches
|
|
18
|
+
*/
|
|
19
|
+
export declare function useWeaverseDataContext(): WeaverseDataContext;
|
|
20
|
+
/**
|
|
21
|
+
* Helper function to create flat route-keyed data context from useMatches() result
|
|
22
|
+
* Returns: {root: {...}, "routes/xxx": {...}}
|
|
23
|
+
*/
|
|
24
|
+
export declare function createWeaverseDataContext(matches: UIMatch<unknown, unknown>[]): WeaverseDataContext;
|
|
25
|
+
/**
|
|
26
|
+
* Type guard to check if data is WeaverseDataContext (simplified)
|
|
27
|
+
*/
|
|
28
|
+
export declare function isWeaverseDataContext(data: unknown): data is WeaverseDataContext;
|
|
29
|
+
//# sourceMappingURL=use-weaverse-data-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-weaverse-data-context.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-weaverse-data-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,cAAc,CAAA;AAEvD,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,sEAAsE;IACtE,CAAC,QAAQ,EAAE,UAAU,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACxD;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GACrD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAuBzB;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAK5D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GACnC,mBAAmB,CAGrB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,mBAAmB,CAE7B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React and React Router integrations for rendering Weaverse content in
|
|
3
|
+
* Shopify Hydrogen storefronts.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import type { SelectedOptionInput } from '@shopify/hydrogen/storefront-api-types';
|
|
8
|
+
import { isBrowser, isIframe, useChildInstances, useItemInstance, useParentInstance, useWeaverse } from '@weaverse/react';
|
|
9
|
+
/**
|
|
10
|
+
* Filter out Weaverse-specific query parameters from product options.
|
|
11
|
+
* Removes `isDesignMode` and any parameters starting with `weaverse` prefix.
|
|
12
|
+
*
|
|
13
|
+
* @param request - The incoming HTTP request
|
|
14
|
+
* @returns Filtered product options for Shopify Hydrogen
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* export async function loader({ request }: LoaderFunctionArgs) {
|
|
19
|
+
* const selectedOptions = getSelectedProductOptions(request)
|
|
20
|
+
* // Use selectedOptions for product queries without Weaverse params
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSelectedProductOptions(request: Request): SelectedOptionInput[];
|
|
25
|
+
/** Placeholder asset URLs for component schema defaults and theme previews. */
|
|
26
|
+
export declare const IMAGES_PLACEHOLDERS: {
|
|
27
|
+
/** White Weaverse logo placeholder. */
|
|
28
|
+
logo_white: string;
|
|
29
|
+
/** Black Weaverse logo placeholder. */
|
|
30
|
+
logo_black: string;
|
|
31
|
+
/** Generic square image placeholder. */
|
|
32
|
+
image: string;
|
|
33
|
+
/** First landscape banner placeholder. */
|
|
34
|
+
banner_1: string;
|
|
35
|
+
/** Second landscape banner placeholder. */
|
|
36
|
+
banner_2: string;
|
|
37
|
+
/** Hats collection placeholder. */
|
|
38
|
+
collection_1: string;
|
|
39
|
+
/** Shoes collection placeholder. */
|
|
40
|
+
collection_2: string;
|
|
41
|
+
/** Glasses collection placeholder. */
|
|
42
|
+
collection_3: string;
|
|
43
|
+
/** Lamps collection placeholder. */
|
|
44
|
+
collection_4: string;
|
|
45
|
+
/** Bags collection placeholder. */
|
|
46
|
+
collection_5: string;
|
|
47
|
+
/** Watches collection placeholder. */
|
|
48
|
+
collection_6: string;
|
|
49
|
+
/** Third watch product placeholder. */
|
|
50
|
+
product_1: string;
|
|
51
|
+
/** Second bag product placeholder. */
|
|
52
|
+
product_2: string;
|
|
53
|
+
/** First shoe product placeholder. */
|
|
54
|
+
product_3: string;
|
|
55
|
+
/** Second lamp product placeholder. */
|
|
56
|
+
product_4: string;
|
|
57
|
+
/** First glasses product placeholder. */
|
|
58
|
+
product_5: string;
|
|
59
|
+
/** First lamp product placeholder. */
|
|
60
|
+
product_6: string;
|
|
61
|
+
/** Second glasses product placeholder. */
|
|
62
|
+
product_7: string;
|
|
63
|
+
/** Third hat product placeholder. */
|
|
64
|
+
product_8: string;
|
|
65
|
+
/** First bag product placeholder. */
|
|
66
|
+
product_9: string;
|
|
67
|
+
/** Second shoe product placeholder. */
|
|
68
|
+
product_10: string;
|
|
69
|
+
/** Second hat product placeholder. */
|
|
70
|
+
product_11: string;
|
|
71
|
+
/** Third glasses product placeholder. */
|
|
72
|
+
product_12: string;
|
|
73
|
+
/** Third shoe product placeholder. */
|
|
74
|
+
product_13: string;
|
|
75
|
+
/** Third bag product placeholder. */
|
|
76
|
+
product_14: string;
|
|
77
|
+
/** First hat product placeholder. */
|
|
78
|
+
product_15: string;
|
|
79
|
+
/** Third lamp product placeholder. */
|
|
80
|
+
product_16: string;
|
|
81
|
+
/** First watch product placeholder. */
|
|
82
|
+
product_17: string;
|
|
83
|
+
/** Second watch product placeholder. */
|
|
84
|
+
product_18: string;
|
|
85
|
+
};
|
|
86
|
+
export * from '@weaverse/schema';
|
|
87
|
+
export * from './components';
|
|
88
|
+
export { getNestedKey, interpolate, ThemeTextProvider, type ThemeTextProviderProps, type ThemeTextValue, type TranslateFunction, TranslationProvider, type TranslationProviderProps, type TranslationValue, useThemeText, useTranslation, } from './hooks/translation-context';
|
|
89
|
+
export { createWeaverseDataContext, type RouteKeyedDataContext, useWeaverseDataContext, type WeaverseDataContext, } from './hooks/use-weaverse-data-context';
|
|
90
|
+
export * from './seo';
|
|
91
|
+
export * from './types';
|
|
92
|
+
export * from './utils';
|
|
93
|
+
export type { WeaverseDataValue } from './utils/pick-weaverse-data';
|
|
94
|
+
export { ThemeTextStore, TranslationStore } from './utils/translation-store';
|
|
95
|
+
export type { ThemeSettingsStore, WeaverseThemeData, } from './utils/use-theme-settings-store';
|
|
96
|
+
export * from './WeaverseHydrogenRoot';
|
|
97
|
+
export * from './weaverse-client';
|
|
98
|
+
export { isBrowser, isIframe, useChildInstances, useItemInstance, useParentInstance, useWeaverse, };
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AACjF,OAAO,EACL,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACZ,MAAM,iBAAiB,CAAA;AAExB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,GACf,mBAAmB,EAAE,CAKvB;AAED,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB;IAC9B,uCAAuC;;IAGvC,uCAAuC;;IAGvC,wCAAwC;;IAGxC,0CAA0C;;IAG1C,2CAA2C;;IAG3C,mCAAmC;;IAGnC,oCAAoC;;IAGpC,sCAAsC;;IAGtC,oCAAoC;;IAGpC,mCAAmC;;IAGnC,sCAAsC;;IAGtC,uCAAuC;;IAGvC,sCAAsC;;IAGtC,sCAAsC;;IAGtC,uCAAuC;;IAGvC,yCAAyC;;IAGzC,sCAAsC;;IAGtC,0CAA0C;;IAG1C,qCAAqC;;IAGrC,qCAAqC;;IAGrC,uCAAuC;;IAGvC,sCAAsC;;IAGtC,yCAAyC;;IAGzC,sCAAsC;;IAGtC,qCAAqC;;IAGrC,qCAAqC;;IAGrC,sCAAsC;;IAGtC,uCAAuC;;IAGvC,wCAAwC;;CAGzC,CAAA;AAGD,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAEtB,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,yBAAyB,EACzB,KAAK,qBAAqB,EAC1B,sBAAsB,EACtB,KAAK,mBAAmB,GACzB,MAAM,mCAAmC,CAAA;AAE1C,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5E,YAAY,EACV,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,kCAAkC,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,WAAW,GACZ,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PageSEOData } from '@weaverse/schema';
|
|
2
|
+
import type { MetaDescriptor } from 'react-router';
|
|
3
|
+
import type { HydrogenPageData, WeaverseLoaderData } from './types';
|
|
4
|
+
/** Object containing an optional Weaverse page for SEO extraction. */
|
|
5
|
+
export interface WeaverseSeoPageContainer {
|
|
6
|
+
/** Page whose published SEO fields should be formatted. */
|
|
7
|
+
page?: HydrogenPageData | null;
|
|
8
|
+
}
|
|
9
|
+
/** Input accepted by {@link getWeaverseSeoMeta}. */
|
|
10
|
+
export type WeaverseSeoInput = WeaverseLoaderData | HydrogenPageData | WeaverseSeoPageContainer | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a Weaverse page-level SEO payload into React Router
|
|
13
|
+
* `MetaDescriptor[]`. Pure, synchronous, tree-shakeable — does not fetch.
|
|
14
|
+
*
|
|
15
|
+
* Behavior:
|
|
16
|
+
* - `title` → top-level `{ title }` descriptor.
|
|
17
|
+
* - `description` / `keywords` → `<meta name="...">`.
|
|
18
|
+
* - `canonicalUrl` → `<link rel="canonical">`.
|
|
19
|
+
* - `openGraph.*` → `<meta property="og:*">`. `og:type` defaults to
|
|
20
|
+
* `'website'` when any other OG field is present.
|
|
21
|
+
* - `twitter.*` → `<meta name="twitter:*">`. `twitter:card` defaults to
|
|
22
|
+
* `'summary'` when any other Twitter field is present.
|
|
23
|
+
* - `robots` is always emitted (defaults to `'index,follow'`) so themes
|
|
24
|
+
* stacking multiple SEO sources have a deterministic last word on
|
|
25
|
+
* indexing for Weaverse-managed pages.
|
|
26
|
+
* - Empty strings / missing fields are filtered before return so empty
|
|
27
|
+
* descriptors don't override earlier sources (e.g. Hydrogen
|
|
28
|
+
* `getSeoMeta`).
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatMetaDescriptors(seo: PageSEOData | null | undefined): MetaDescriptor[];
|
|
31
|
+
/**
|
|
32
|
+
* Convenience accessor: pull `page.seo` out of a `WeaverseLoaderData`
|
|
33
|
+
* (or `HydrogenPageData`) and emit `MetaDescriptor[]`. Null-safe.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* export const meta: MetaFunction<typeof loader> = ({ data }) => {
|
|
38
|
+
* return getWeaverseSeoMeta(data?.weaverseData)
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function getWeaverseSeoMeta(data: WeaverseSeoInput): MetaDescriptor[];
|
|
43
|
+
//# sourceMappingURL=seo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seo.d.ts","sourceRoot":"","sources":["../../src/seo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEnE,sEAAsE;AACtE,MAAM,WAAW,wBAAwB;IACvC,2DAA2D;IAC3D,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC/B;AAED,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,gBAAgB,GAChB,wBAAwB,GACxB,IAAI,GACJ,SAAS,CAAA;AAEb;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAClC,cAAc,EAAE,CA+DlB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,cAAc,EAAE,CAS3E"}
|