@weaverse/hydrogen 6.0.0-beta.0 → 6.1.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/internal.js +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/react-router.js +1 -1
- package/dist/react-router.mjs +1 -1
- package/dist/translation-store-BpPWqZ0B.js.map +1 -1
- package/dist/translation-store-C42QdI0e.mjs.map +1 -1
- package/dist/types/types.d.ts +19 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/weaverse-client.d.ts +1 -0
- package/dist/types/weaverse-client.d.ts.map +1 -1
- package/dist/{weaverse-client-yC4TYuVV.js → weaverse-client-BDMvJ0Dp.js} +7 -5
- package/dist/{weaverse-client-yC4TYuVV.js.map → weaverse-client-BDMvJ0Dp.js.map} +1 -1
- package/dist/{weaverse-client-Clu3u7md.mjs → weaverse-client-D1n6tucX.mjs} +7 -5
- package/dist/{weaverse-client-Clu3u7md.mjs.map → weaverse-client-D1n6tucX.mjs.map} +1 -1
- package/package.json +4 -4
- package/readme.md +11 -0
- package/src/types.ts +20 -1
- package/src/weaverse-client.ts +7 -5
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@weaverse/hydrogen",
|
|
3
3
|
"author": "Weaverse Team",
|
|
4
4
|
"description": "Components, hooks, and utilities for building Shopify Hydrogen websites with Weaverse",
|
|
5
|
-
"version": "6.
|
|
5
|
+
"version": "6.1.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"typings": "dist/types/index.d.ts",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"@shopify/hydrogen": "^2026.10.2"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@weaverse/next": "1.1.
|
|
73
|
-
"@weaverse/react": "
|
|
74
|
-
"@weaverse/schema": "0.
|
|
72
|
+
"@weaverse/next": "1.1.1",
|
|
73
|
+
"@weaverse/react": "6.1.0",
|
|
74
|
+
"@weaverse/schema": "0.20.0",
|
|
75
75
|
"react": ">=19",
|
|
76
76
|
"react-dom": ">=19",
|
|
77
77
|
"react-error-boundary": "^6",
|
package/readme.md
CHANGED
|
@@ -140,6 +140,17 @@ export const middleware: Route.MiddlewareFunction[] = [
|
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
`storefront.i18n` selects the content locale, including its `pathPrefix`.
|
|
143
|
+
When a market's Shopify `LanguageCode` differs from the locale Weaverse keys
|
|
144
|
+
its translations by (for example `ZH_TW` for a Traditional Chinese Hong Kong
|
|
145
|
+
market), pass the market as `locale` instead of relabeling the storefront
|
|
146
|
+
client. It sets the Translation Manager locale, the locale sent with page
|
|
147
|
+
requests and the `requestInfo.i18n` Studio reads, while the Storefront API keeps
|
|
148
|
+
its own `i18n`:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
new WeaverseClient({ ...args, locale: { language: 'ZH', country: 'HK', pathPrefix: '/zh-hk' } })
|
|
152
|
+
```
|
|
153
|
+
|
|
143
154
|
Section loaders receive the same client as `weaverse`, so they query the
|
|
144
155
|
Storefront API with `weaverse.storefront.graphql(QUERY, { variables, cache })`.
|
|
145
156
|
|
package/src/types.ts
CHANGED
|
@@ -29,6 +29,7 @@ import type {
|
|
|
29
29
|
SchemaType,
|
|
30
30
|
SchemaValidationIssue,
|
|
31
31
|
SchemaValidationResult,
|
|
32
|
+
ThemeOutline,
|
|
32
33
|
ThemeRoutes,
|
|
33
34
|
} from '@weaverse/schema'
|
|
34
35
|
import { isValidSchema } from '@weaverse/schema'
|
|
@@ -419,6 +420,11 @@ export type WeaverseThemeSchema = {
|
|
|
419
420
|
* `{ COLLECTION: '/shop/:handle' }`. See `ThemeRoutes`.
|
|
420
421
|
*/
|
|
421
422
|
routes?: ThemeRoutes
|
|
423
|
+
/**
|
|
424
|
+
* Settings groups listed in the Studio Page Outline, keyed by area. See
|
|
425
|
+
* `ThemeOutline`.
|
|
426
|
+
*/
|
|
427
|
+
outline?: ThemeOutline
|
|
422
428
|
/** Theme localization configuration. */
|
|
423
429
|
i18n?: {
|
|
424
430
|
/** Strategy used to encode the locale in storefront URLs. */
|
|
@@ -550,10 +556,23 @@ export function isProjectIdFunction(
|
|
|
550
556
|
export type WeaverseClientArgs = {
|
|
551
557
|
/**
|
|
552
558
|
* Request-scoped Hydrogen Storefront API client. Section loaders reach it
|
|
553
|
-
* as `weaverse.storefront`; its `i18n` selects the content locale
|
|
559
|
+
* as `weaverse.storefront`; its `i18n` selects the content locale unless
|
|
560
|
+
* {@link WeaverseClientArgs.locale} is given.
|
|
554
561
|
*/
|
|
555
562
|
storefront: WeaverseStorefront
|
|
556
563
|
|
|
564
|
+
/**
|
|
565
|
+
* The market this request serves, as Weaverse identifies it. It selects the
|
|
566
|
+
* Translation Manager overrides (`${language}-${country}`, lowercased), the
|
|
567
|
+
* locale sent with page requests and the `requestInfo.i18n` Studio reads,
|
|
568
|
+
* so include `pathPrefix`. Pass it when the storefront's `i18n.language` is
|
|
569
|
+
* a Shopify `LanguageCode` that differs from the market's public language,
|
|
570
|
+
* such as `ZH_TW` for a Traditional Chinese Hong Kong market.
|
|
571
|
+
*
|
|
572
|
+
* @defaultValue `storefront.i18n`
|
|
573
|
+
*/
|
|
574
|
+
locale?: WeaverseI18n
|
|
575
|
+
|
|
557
576
|
/** Runtime environment variables, such as the Oxygen worker `env`. */
|
|
558
577
|
env: WeaverseEnv
|
|
559
578
|
|
package/src/weaverse-client.ts
CHANGED
|
@@ -316,6 +316,7 @@ export class WeaverseClient {
|
|
|
316
316
|
private readonly componentsByType: Map<string, WeaverseComponent>
|
|
317
317
|
|
|
318
318
|
// Configuration
|
|
319
|
+
private readonly locale: WeaverseI18n
|
|
319
320
|
private readonly fetchTimeoutMs: number
|
|
320
321
|
private readonly throwPageLoadFailures: boolean
|
|
321
322
|
|
|
@@ -336,6 +337,7 @@ export class WeaverseClient {
|
|
|
336
337
|
this.componentsByType = this.buildComponentLookupMap(args.components)
|
|
337
338
|
|
|
338
339
|
// Configuration
|
|
340
|
+
this.locale = args.locale ?? args.storefront.i18n
|
|
339
341
|
this.fetchTimeoutMs = args.fetchTimeoutMs || DEFAULT_FETCH_TIMEOUT_MS
|
|
340
342
|
this.throwPageLoadFailures = args.throwPageLoadFailures === true
|
|
341
343
|
|
|
@@ -406,7 +408,7 @@ export class WeaverseClient {
|
|
|
406
408
|
|
|
407
409
|
this.basePageRequestBody = {
|
|
408
410
|
isDesignMode: this.configs.isDesignMode,
|
|
409
|
-
i18n:
|
|
411
|
+
i18n: this.locale,
|
|
410
412
|
projectId: this.configs.projectId,
|
|
411
413
|
}
|
|
412
414
|
|
|
@@ -1038,7 +1040,7 @@ export class WeaverseClient {
|
|
|
1038
1040
|
): Promise<Record<string, unknown> | undefined> => {
|
|
1039
1041
|
try {
|
|
1040
1042
|
const { projectId, weaverseHost } = this.configs
|
|
1041
|
-
const i18n = this.
|
|
1043
|
+
const i18n = this.locale
|
|
1042
1044
|
|
|
1043
1045
|
// Skip entirely when the theme hasn't opted into i18n. Merchant overrides
|
|
1044
1046
|
// are locale-specific translations; a theme with no `i18n` schema has no
|
|
@@ -1053,7 +1055,7 @@ export class WeaverseClient {
|
|
|
1053
1055
|
return
|
|
1054
1056
|
}
|
|
1055
1057
|
|
|
1056
|
-
// Build locale code from
|
|
1058
|
+
// Build locale code from the market's locale (e.g. "en-us")
|
|
1057
1059
|
const language = (i18n?.language || 'en').toLowerCase()
|
|
1058
1060
|
const country = (i18n?.country || 'us').toLowerCase()
|
|
1059
1061
|
const locale = `${language}-${country}`
|
|
@@ -1225,7 +1227,7 @@ export class WeaverseClient {
|
|
|
1225
1227
|
}
|
|
1226
1228
|
|
|
1227
1229
|
try {
|
|
1228
|
-
const { request,
|
|
1230
|
+
const { request, basePageRequestBody, basePageConfigs } = this
|
|
1229
1231
|
const {
|
|
1230
1232
|
projectId: clientProjectId,
|
|
1231
1233
|
weaverseHost,
|
|
@@ -1352,7 +1354,7 @@ export class WeaverseClient {
|
|
|
1352
1354
|
configs: {
|
|
1353
1355
|
...basePageConfigs,
|
|
1354
1356
|
requestInfo: {
|
|
1355
|
-
i18n:
|
|
1357
|
+
i18n: this.locale,
|
|
1356
1358
|
queries: getRequestQueries<WeaverseStudioQueries>(request),
|
|
1357
1359
|
pathname: this.parsedUrl.pathname,
|
|
1358
1360
|
search: this.parsedUrl.search,
|