@vue-storefront/next 1.0.0 → 1.0.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Change log
2
+
3
+ ## 1.0.2
4
+
5
+ - **[FIXED]** Multi-store URL calculation, now working correctly in the browser.
6
+
7
+ ## 1.0.1
8
+
9
+ - **[CHANGED]** Set `@vue-storefront/sdk` as a dependency instead of a peer dependency
10
+
11
+ ## 1.0.0
12
+
13
+ - Initialized the package
package/dist/index.js CHANGED
@@ -45,18 +45,23 @@ function calculateMiddlewareUrl({
45
45
  options,
46
46
  headers
47
47
  }) {
48
- var _a, _b;
48
+ var _a, _b, _c;
49
49
  const { apiUrl, ssrApiUrl } = options.middleware;
50
50
  if (typeof window !== "undefined") {
51
+ if ((_a = options.multistore) == null ? void 0 : _a.enabled) {
52
+ const url2 = new URL(apiUrl);
53
+ url2.host = window.location.host;
54
+ return url2.href;
55
+ }
51
56
  return apiUrl;
52
57
  }
53
58
  if (ssrApiUrl) {
54
59
  return ssrApiUrl;
55
60
  }
56
- if (!((_a = options.multistore) == null ? void 0 : _a.enabled)) {
61
+ if (!((_b = options.multistore) == null ? void 0 : _b.enabled)) {
57
62
  return apiUrl;
58
63
  }
59
- const forwardedHost = (_b = headers["x-forwarded-host"]) != null ? _b : headers.host;
64
+ const forwardedHost = (_c = headers["x-forwarded-host"]) != null ? _c : headers.host;
60
65
  const resolvedForwardedHost = forwardedHost && Array.isArray(forwardedHost) ? forwardedHost[0] : forwardedHost;
61
66
  const url = new URL(apiUrl);
62
67
  url.host = resolvedForwardedHost || new URL(apiUrl).host;
package/dist/index.mjs CHANGED
@@ -8,18 +8,23 @@ function calculateMiddlewareUrl({
8
8
  options,
9
9
  headers
10
10
  }) {
11
- var _a, _b;
11
+ var _a, _b, _c;
12
12
  const { apiUrl, ssrApiUrl } = options.middleware;
13
13
  if (typeof window !== "undefined") {
14
+ if ((_a = options.multistore) == null ? void 0 : _a.enabled) {
15
+ const url2 = new URL(apiUrl);
16
+ url2.host = window.location.host;
17
+ return url2.href;
18
+ }
14
19
  return apiUrl;
15
20
  }
16
21
  if (ssrApiUrl) {
17
22
  return ssrApiUrl;
18
23
  }
19
- if (!((_a = options.multistore) == null ? void 0 : _a.enabled)) {
24
+ if (!((_b = options.multistore) == null ? void 0 : _b.enabled)) {
20
25
  return apiUrl;
21
26
  }
22
- const forwardedHost = (_b = headers["x-forwarded-host"]) != null ? _b : headers.host;
27
+ const forwardedHost = (_c = headers["x-forwarded-host"]) != null ? _c : headers.host;
23
28
  const resolvedForwardedHost = forwardedHost && Array.isArray(forwardedHost) ? forwardedHost[0] : forwardedHost;
24
29
  const url = new URL(apiUrl);
25
30
  url.host = resolvedForwardedHost || new URL(apiUrl).host;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@vue-storefront/next",
3
3
  "description": "Vue Storefront dedicated features for Next.js",
4
4
  "license": "MIT",
5
- "version": "1.0.0",
5
+ "version": "1.0.2",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./dist/index.mjs",
@@ -42,6 +42,9 @@
42
42
  "test:e2e": "cd ../../shared/ && yarn test:e2e",
43
43
  "test:unit": "vitest run"
44
44
  },
45
+ "dependencies": {
46
+ "@vue-storefront/sdk": "^1.0.0"
47
+ },
45
48
  "devDependencies": {
46
49
  "@types/react": "^18.2.31",
47
50
  "@types/react-dom": "^18.2.14",
@@ -51,7 +54,6 @@
51
54
  "vitest": "^0.34.6"
52
55
  },
53
56
  "peerDependencies": {
54
- "@vue-storefront/sdk": "^1.0.0",
55
57
  "react": "^18.2.0",
56
58
  "next": "^13.4.7 || ^14.0.0"
57
59
  },