@shopware/nuxt-module 1.3.0 → 1.4.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.
Files changed (3) hide show
  1. package/README.md +5 -9
  2. package/package.json +8 -8
  3. package/plugin.ts +16 -5
package/README.md CHANGED
@@ -125,18 +125,14 @@ More about Nuxt configuration can be found [HERE](https://nuxt.com/docs/getting-
125
125
 
126
126
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/nuxt-module/CHANGELOG.md)
127
127
 
128
- ### Latest changes: 1.3.0
128
+ ### Latest changes: 1.4.0
129
129
 
130
130
  ### Minor Changes
131
131
 
132
- - [#1602](https://github.com/shopware/frontends/pull/1602) [`bb7d1cb`](https://github.com/shopware/frontends/commit/bb7d1cbc4204ff1d48f77416f94f550bc235e5ed) Thanks [@patzick](https://github.com/patzick)! - Package `@shopware-pwa/nuxt3-module` is deprecated. Use [@shopware/nuxt-module](https://www.npmjs.com/package/@shopware/nuxt-module) instead.
133
-
134
- - [#1602](https://github.com/shopware/frontends/pull/1602) [`bb7d1cb`](https://github.com/shopware/frontends/commit/bb7d1cbc4204ff1d48f77416f94f550bc235e5ed) Thanks [@patzick](https://github.com/patzick)! - Switch from `@shopware-pwa/helpers-next` to `@shopware/helpers` package.
135
-
136
- - [#1602](https://github.com/shopware/frontends/pull/1602) [`bb7d1cb`](https://github.com/shopware/frontends/commit/bb7d1cbc4204ff1d48f77416f94f550bc235e5ed) Thanks [@patzick](https://github.com/patzick)! - Switch from `@shopware-pwa/cms-base` to `@shopware/cms-base-layer` package.
132
+ - [#1812](https://github.com/shopware/frontends/pull/1812) [`c28810d`](https://github.com/shopware/frontends/commit/c28810d0ca503b97c232438e200bbf5ba5dab403) Thanks [@patzick](https://github.com/patzick)! - `useShopwareContext` - added `browserLocale` field. With nuxt-module it's automatically injected into context. Should be used for proper date formatting.
137
133
 
138
134
  ### Patch Changes
139
135
 
140
- - Updated dependencies [[`bb7d1cb`](https://github.com/shopware/frontends/commit/bb7d1cbc4204ff1d48f77416f94f550bc235e5ed), [`bb7d1cb`](https://github.com/shopware/frontends/commit/bb7d1cbc4204ff1d48f77416f94f550bc235e5ed)]:
141
- - @shopware/composables@1.8.0
142
- - @shopware/helpers@1.4.0
136
+ - Updated dependencies [[`d016d6b`](https://github.com/shopware/frontends/commit/d016d6b845bff9a148405a74dae88d7fc81ec99c), [`c28810d`](https://github.com/shopware/frontends/commit/c28810d0ca503b97c232438e200bbf5ba5dab403), [`a7ff606`](https://github.com/shopware/frontends/commit/a7ff60681d1a164d5c9f2020c506262e96fad5dc), [`d016d6b`](https://github.com/shopware/frontends/commit/d016d6b845bff9a148405a74dae88d7fc81ec99c), [`bd70905`](https://github.com/shopware/frontends/commit/bd70905b8443fd57d8d8cb3cfc6501a9117dea49)]:
137
+ - @shopware/api-client@1.3.0
138
+ - @shopware/composables@1.9.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware/nuxt-module",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Nuxt 3 module for Shopware Frontends",
5
5
  "author": "Shopware",
6
6
  "repository": {
@@ -34,18 +34,18 @@
34
34
  "index.cjs"
35
35
  ],
36
36
  "dependencies": {
37
- "@nuxt/kit": "3.14.1592",
37
+ "@nuxt/kit": "3.16.2",
38
38
  "defu": "6.1.4",
39
39
  "js-cookie": "3.0.5",
40
- "@shopware/composables": "1.8.0",
41
- "@shopware/api-client": "1.2.0",
42
- "@shopware/helpers": "1.4.0"
40
+ "@shopware/composables": "1.9.0",
41
+ "@shopware/helpers": "1.4.0",
42
+ "@shopware/api-client": "1.3.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@biomejs/biome": "1.8.3",
46
- "@nuxt/schema": "3.14.1592",
47
- "nuxt": "3.14.1592",
48
- "typescript": "5.6.3",
46
+ "@nuxt/schema": "3.16.2",
47
+ "nuxt": "3.16.2",
48
+ "typescript": "5.8.3",
49
49
  "unbuild": "2.0.0",
50
50
  "tsconfig": "0.0.0"
51
51
  },
package/plugin.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { createAPIClient } from "@shopware/api-client";
2
2
  import { isMaintenanceMode } from "@shopware/helpers";
3
- import { defu } from "defu";
4
3
  import { getCookie } from "h3";
5
4
  import Cookies from "js-cookie";
6
5
  import { ref } from "vue";
@@ -8,6 +7,7 @@ import {
8
7
  createShopwareContext,
9
8
  defineNuxtPlugin,
10
9
  showError,
10
+ useRequestHeaders,
11
11
  useRuntimeConfig,
12
12
  useState,
13
13
  } from "#imports";
@@ -32,7 +32,8 @@ export default defineNuxtPlugin((NuxtApp) => {
32
32
  runtimeConfig.public?.shopware?.shopwareEndpoint;
33
33
 
34
34
  const shopwareEndpointSSR =
35
- runtimeConfig.shopware?.endpoint ?? shopwareEndpointCSR;
35
+ (NuxtApp.ssrContext && runtimeConfig.shopware?.endpoint) ||
36
+ shopwareEndpointCSR;
36
37
 
37
38
  const shopwareEndpoint = import.meta.server
38
39
  ? shopwareEndpointSSR
@@ -63,10 +64,9 @@ export default defineNuxtPlugin((NuxtApp) => {
63
64
  contextToken: shouldUseSessionContextInServerRender
64
65
  ? contextTokenFromCookie
65
66
  : "",
66
- defaultHeaders: defu(
67
- runtimeConfig.apiClientConfig?.headers,
67
+ defaultHeaders:
68
+ (NuxtApp.ssrContext && runtimeConfig.apiClientConfig?.headers) ||
68
69
  runtimeConfig.public?.apiClientConfig?.headers,
69
- ),
70
70
  });
71
71
 
72
72
  apiClient.hook("onContextChanged", (newContextToken) => {
@@ -89,11 +89,22 @@ export default defineNuxtPlugin((NuxtApp) => {
89
89
  }
90
90
  });
91
91
 
92
+ // Get browser locale in CSR and SSR
93
+ let browserLocale = "en-US";
94
+ if (import.meta.client) {
95
+ browserLocale = navigator.language;
96
+ } else {
97
+ browserLocale =
98
+ useRequestHeaders()["accept-language"]?.split(",")[0]?.split(";")[0] ??
99
+ "en-US";
100
+ }
101
+
92
102
  NuxtApp.vueApp.provide("apiClient", apiClient);
93
103
  // Shopware context
94
104
  const shopwareContext = createShopwareContext(NuxtApp.vueApp, {
95
105
  enableDevtools: true,
96
106
  devStorefrontUrl: runtimeConfig.public.shopware?.devStorefrontUrl || null,
107
+ browserLocale,
97
108
  });
98
109
  NuxtApp.vueApp.provide("shopware", shopwareContext);
99
110