@shopify/hydrogen 0.17.1 → 0.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.
Files changed (150) hide show
  1. package/CHANGELOG.md +136 -1
  2. package/config.js +1 -0
  3. package/dist/esnext/client.d.ts +2 -0
  4. package/dist/esnext/client.js +2 -0
  5. package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +2 -2
  6. package/dist/esnext/components/CartProvider/CartProvider.client.js +15 -14
  7. package/dist/esnext/components/CartProvider/{hooks.d.ts → hooks.client.d.ts} +0 -0
  8. package/dist/esnext/components/CartProvider/{hooks.js → hooks.client.js} +0 -0
  9. package/dist/esnext/components/CartProvider/index.d.ts +1 -1
  10. package/dist/esnext/components/CartProvider/index.js +1 -1
  11. package/dist/esnext/components/{DevTools.d.ts → DevTools.client.d.ts} +0 -0
  12. package/dist/esnext/components/{DevTools.js → DevTools.client.js} +3 -2
  13. package/dist/esnext/components/Image/Image.js +2 -0
  14. package/dist/esnext/components/Link/Link.client.js +11 -2
  15. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +1 -1
  16. package/dist/esnext/components/Metafield/Metafield.client.js +4 -5
  17. package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +1 -1
  18. package/dist/esnext/components/ModelViewer/ModelViewer.client.js +2 -2
  19. package/dist/esnext/components/Money/Money.client.d.ts +5 -1
  20. package/dist/esnext/components/Money/Money.client.js +16 -3
  21. package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +1 -1
  22. package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.js +1 -1
  23. package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +7 -3
  24. package/dist/esnext/components/ProductProvider/ProductProvider.client.js +1 -1
  25. package/dist/esnext/components/ShopPayButton/ShopPayButton.client.js +6 -2
  26. package/dist/esnext/components/Video/Video.js +3 -1
  27. package/dist/esnext/config.d.ts +3 -0
  28. package/dist/esnext/config.js +1 -0
  29. package/dist/esnext/constants.js +1 -1
  30. package/dist/esnext/entry-client.js +3 -1
  31. package/dist/esnext/entry-server.d.ts +2 -2
  32. package/dist/esnext/entry-server.js +59 -56
  33. package/dist/esnext/foundation/Analytics/ClientAnalytics.d.ts +1 -0
  34. package/dist/esnext/foundation/Analytics/ClientAnalytics.js +7 -1
  35. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.d.ts +7 -0
  36. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +64 -0
  37. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.server.d.ts +1 -0
  38. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.server.js +24 -0
  39. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.d.ts +1 -0
  40. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.js +23 -0
  41. package/dist/esnext/foundation/Analytics/const.d.ts +1 -0
  42. package/dist/esnext/foundation/Analytics/const.js +1 -0
  43. package/dist/esnext/foundation/Cookie/Cookie.js +2 -1
  44. package/dist/esnext/foundation/FileRoutes/FileRoutes.server.d.ts +4 -4
  45. package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +18 -21
  46. package/dist/esnext/foundation/FileSessionStorage/FileSessionStorage.js +2 -1
  47. package/dist/esnext/foundation/Redirect/Redirect.client.js +1 -0
  48. package/dist/esnext/foundation/Route/Route.server.js +1 -10
  49. package/dist/esnext/foundation/Router/BrowserRouter.client.js +34 -5
  50. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +5 -3
  51. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +2 -2
  52. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +7 -2
  53. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.js +6 -1
  54. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.d.ts +8 -1
  55. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +31 -5
  56. package/dist/esnext/foundation/ShopifyProvider/types.d.ts +3 -4
  57. package/dist/esnext/foundation/fetchSync/client/fetchSync.js +2 -1
  58. package/dist/esnext/foundation/fetchSync/server/fetchSync.js +4 -2
  59. package/dist/esnext/foundation/ssr-interop.js +1 -1
  60. package/dist/esnext/foundation/useQuery/hooks.d.ts +1 -1
  61. package/dist/esnext/foundation/useQuery/hooks.js +2 -2
  62. package/dist/esnext/foundation/useShop/use-shop.d.ts +3 -1
  63. package/dist/esnext/foundation/useShop/use-shop.js +3 -1
  64. package/dist/esnext/foundation/useUrl/useUrl.js +7 -4
  65. package/dist/esnext/framework/Hydration/Html.js +1 -1
  66. package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +3 -2
  67. package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +16 -7
  68. package/dist/esnext/framework/middleware.d.ts +3 -4
  69. package/dist/esnext/framework/middleware.js +4 -4
  70. package/dist/esnext/framework/plugin.d.ts +2 -2
  71. package/dist/esnext/framework/plugin.js +3 -3
  72. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +1 -1
  73. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +2 -2
  74. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +59 -4
  75. package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +2 -2
  76. package/dist/esnext/hooks/useLoadScript/index.d.ts +1 -1
  77. package/dist/esnext/hooks/useLoadScript/index.js +1 -1
  78. package/dist/esnext/hooks/useLoadScript/{useLoadScript.d.ts → useLoadScript.client.d.ts} +0 -0
  79. package/dist/esnext/hooks/useLoadScript/{useLoadScript.js → useLoadScript.client.js} +2 -1
  80. package/dist/esnext/hooks/useMoney/hooks.d.ts +13 -1
  81. package/dist/esnext/hooks/useMoney/hooks.js +25 -1
  82. package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +0 -2
  83. package/dist/esnext/hooks/useProduct/useProduct.js +1 -1
  84. package/dist/esnext/hooks/useProductOptions/index.d.ts +1 -1
  85. package/dist/esnext/hooks/useProductOptions/index.js +1 -1
  86. package/dist/esnext/hooks/useProductOptions/{useProductOptions.d.ts → useProductOptions.client.d.ts} +0 -0
  87. package/dist/esnext/hooks/useProductOptions/{useProductOptions.js → useProductOptions.client.js} +6 -23
  88. package/dist/esnext/hooks/useShopQuery/hooks.js +15 -4
  89. package/dist/esnext/index.d.ts +1 -0
  90. package/dist/esnext/index.js +1 -0
  91. package/dist/esnext/storefront-api-types.d.ts +60 -6
  92. package/dist/esnext/storefront-api-types.js +6 -2
  93. package/dist/esnext/types.d.ts +11 -4
  94. package/dist/esnext/utilities/apiRoutes.d.ts +4 -3
  95. package/dist/esnext/utilities/apiRoutes.js +51 -33
  96. package/dist/esnext/utilities/bot-ua.js +3 -0
  97. package/dist/esnext/utilities/empty-hydrogen-config.d.ts +2 -0
  98. package/dist/esnext/utilities/empty-hydrogen-config.js +2 -0
  99. package/dist/esnext/utilities/findRoutePrefix.d.ts +1 -0
  100. package/dist/esnext/utilities/findRoutePrefix.js +17 -0
  101. package/dist/esnext/utilities/log/utils.js +1 -1
  102. package/dist/esnext/utilities/parse.d.ts +1 -0
  103. package/dist/esnext/utilities/parse.js +9 -0
  104. package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.js +2 -1
  105. package/dist/esnext/utilities/storefrontApi.js +1 -0
  106. package/dist/esnext/version.d.ts +1 -1
  107. package/dist/esnext/version.js +1 -1
  108. package/dist/node/constants.js +1 -1
  109. package/dist/node/entry-server.d.ts +2 -2
  110. package/dist/node/entry-server.js +59 -56
  111. package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +1 -0
  112. package/dist/node/foundation/Analytics/ClientAnalytics.js +7 -1
  113. package/dist/node/foundation/Analytics/const.d.ts +1 -0
  114. package/dist/node/foundation/Analytics/const.js +1 -0
  115. package/dist/node/foundation/Redirect/Redirect.client.js +1 -0
  116. package/dist/node/foundation/Router/BrowserRouter.client.js +34 -5
  117. package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +5 -3
  118. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +2 -2
  119. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +7 -2
  120. package/dist/node/foundation/ShopifyProvider/types.d.ts +3 -4
  121. package/dist/node/foundation/ssr-interop.js +1 -1
  122. package/dist/node/framework/Hydration/Html.js +1 -1
  123. package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +3 -2
  124. package/dist/node/framework/Hydration/ServerComponentRequest.server.js +16 -7
  125. package/dist/node/framework/middleware.d.ts +3 -4
  126. package/dist/node/framework/middleware.js +4 -4
  127. package/dist/node/framework/plugin.d.ts +2 -2
  128. package/dist/node/framework/plugin.js +3 -3
  129. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +1 -1
  130. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +2 -2
  131. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +58 -3
  132. package/dist/node/framework/plugins/vite-plugin-platform-entry.js +2 -2
  133. package/dist/node/storefront-api-types.d.ts +60 -6
  134. package/dist/node/storefront-api-types.js +6 -2
  135. package/dist/node/types.d.ts +11 -4
  136. package/dist/node/utilities/apiRoutes.d.ts +4 -3
  137. package/dist/node/utilities/apiRoutes.js +53 -34
  138. package/dist/node/utilities/bot-ua.js +3 -0
  139. package/dist/node/utilities/findRoutePrefix.d.ts +1 -0
  140. package/dist/node/utilities/findRoutePrefix.js +21 -0
  141. package/dist/node/utilities/log/utils.js +1 -1
  142. package/dist/node/utilities/parse.d.ts +1 -0
  143. package/dist/node/utilities/parse.js +13 -0
  144. package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +2 -1
  145. package/dist/node/utilities/storefrontApi.js +1 -0
  146. package/dist/node/version.d.ts +1 -1
  147. package/dist/node/version.js +1 -1
  148. package/package.json +9 -7
  149. package/dist/esnext/foundation/Boomerang/Boomerang.client.d.ts +0 -9
  150. package/dist/esnext/foundation/Boomerang/Boomerang.client.js +0 -66
@@ -1,4 +1,4 @@
1
- import { ImportGlobEagerOutput, ShopifyConfig } from '../types';
1
+ import { HydrogenConfig, HydrogenConfigRoutes } from '../types';
2
2
  import type { ServerComponentRequest } from '../framework/Hydration/ServerComponentRequest.server';
3
3
  import type { ASTNode } from 'graphql';
4
4
  import { SessionApi, SessionStorageAdapter } from '../foundation/session/session';
@@ -19,7 +19,8 @@ export declare type ApiRouteMatch = {
19
19
  hasServerComponent: boolean;
20
20
  params: RouteParams;
21
21
  };
22
- export declare function getApiRoutes(pages: ImportGlobEagerOutput | undefined, topLevelPath?: string): Array<HydrogenApiRoute>;
22
+ export declare function extractPathFromRoutesKey(routesKey: string, dirPrefix: string | RegExp): string;
23
+ export declare function getApiRoutes(rawRoutes: HydrogenConfigRoutes): Array<HydrogenApiRoute>;
23
24
  export declare function getApiRouteFromURL(url: URL, routes: Array<HydrogenApiRoute>): ApiRouteMatch | null;
24
25
  /** The `queryShop` utility is a function that helps you query the Storefront API.
25
26
  * It's similar to the `useShopQuery` hook, which is available in server components.
@@ -33,5 +34,5 @@ interface QueryShopArgs {
33
34
  /** An object of the variables for the GraphQL query. */
34
35
  variables?: Record<string, any>;
35
36
  }
36
- export declare function renderApiRoute(request: ServerComponentRequest, route: ApiRouteMatch, shopifyConfig: ShopifyConfig, session?: SessionStorageAdapter): Promise<Response | Request>;
37
+ export declare function renderApiRoute(request: ServerComponentRequest, route: ApiRouteMatch, shopifyConfig: HydrogenConfig['shopify'], session?: SessionStorageAdapter): Promise<Response | Request>;
37
38
  export {};
@@ -1,38 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderApiRoute = exports.getApiRouteFromURL = exports.getApiRoutes = void 0;
3
+ exports.renderApiRoute = exports.getApiRouteFromURL = exports.getApiRoutes = exports.extractPathFromRoutesKey = void 0;
4
4
  const matchPath_1 = require("./matchPath");
5
5
  const log_1 = require("../utilities/log/");
6
6
  const fetch_1 = require("./fetch");
7
+ const findRoutePrefix_1 = require("./findRoutePrefix");
7
8
  const storefrontApi_1 = require("./storefrontApi");
8
9
  const session_1 = require("../foundation/session/session");
9
- let memoizedRoutes = [];
10
- let memoizedPages = {};
11
- function getApiRoutes(pages, topLevelPath = '*') {
12
- if (!pages || memoizedPages === pages)
13
- return memoizedRoutes;
10
+ let memoizedApiRoutes = [];
11
+ let memoizedRawRoutes = {};
12
+ function extractPathFromRoutesKey(routesKey, dirPrefix) {
13
+ let path = routesKey
14
+ .replace(dirPrefix, '')
15
+ .replace(/\.server\.(t|j)sx?$/, '')
16
+ /**
17
+ * Replace /index with /
18
+ */
19
+ .replace(/\/index$/i, '/')
20
+ /**
21
+ * Only lowercase the first letter. This allows the developer to use camelCase
22
+ * dynamic paths while ensuring their standard routes are normalized to lowercase.
23
+ */
24
+ .replace(/\b[A-Z]/, (firstLetter) => firstLetter.toLowerCase())
25
+ /**
26
+ * Convert /[handle].jsx and /[...handle].jsx to /:handle.jsx for react-router-dom
27
+ */
28
+ .replace(/\[(?:[.]{3})?(\w+?)\]/g, (_match, param) => `:${param}`);
29
+ if (path.endsWith('/') && path !== '/') {
30
+ path = path.substring(0, path.length - 1);
31
+ }
32
+ return path;
33
+ }
34
+ exports.extractPathFromRoutesKey = extractPathFromRoutesKey;
35
+ function getApiRoutes(rawRoutes) {
36
+ var _a, _b;
37
+ const routes = ((_a = rawRoutes.files) !== null && _a !== void 0 ? _a : rawRoutes);
38
+ const topLevelPath = ((_b = rawRoutes.basePath) !== null && _b !== void 0 ? _b : '*');
39
+ const dirPrefix = rawRoutes.dirPrefix;
40
+ if (!routes || memoizedRawRoutes === routes)
41
+ return memoizedApiRoutes;
14
42
  const topLevelPrefix = topLevelPath.replace('*', '').replace(/\/$/, '');
15
- const routes = Object.keys(pages)
16
- .filter((key) => pages[key].api)
43
+ const keys = Object.keys(routes);
44
+ const commonRoutePrefix = dirPrefix !== null && dirPrefix !== void 0 ? dirPrefix : (0, findRoutePrefix_1.findRoutePrefix)(keys);
45
+ const apiRoutes = keys
46
+ .filter((key) => routes[key].api)
17
47
  .map((key) => {
18
- let path = key
19
- .replace('./routes', '')
20
- .replace(/\.server\.(t|j)sx?$/, '')
21
- /**
22
- * Replace /index with /
23
- */
24
- .replace(/\/index$/i, '/')
25
- /**
26
- * Only lowercase the first letter. This allows the developer to use camelCase
27
- * dynamic paths while ensuring their standard routes are normalized to lowercase.
28
- */
29
- .replace(/\b[A-Z]/, (firstLetter) => firstLetter.toLowerCase())
30
- /**
31
- * Convert /[handle].jsx and /[...handle].jsx to /:handle.jsx for react-router-dom
32
- */
33
- .replace(/\[(?:[.]{3})?(\w+?)\]/g, (_match, param) => `:${param}`);
34
- if (path.endsWith('/') && path !== '/')
35
- path = path.substring(0, path.length - 1);
48
+ const path = extractPathFromRoutesKey(key, commonRoutePrefix);
36
49
  /**
37
50
  * Catch-all routes [...handle].jsx don't need an exact match
38
51
  * https://reactrouter.com/core/api/Route/exact-bool
@@ -40,17 +53,17 @@ function getApiRoutes(pages, topLevelPath = '*') {
40
53
  const exact = !/\[(?:[.]{3})(\w+?)\]/.test(key);
41
54
  return {
42
55
  path: topLevelPrefix + path,
43
- resource: pages[key].api,
44
- hasServerComponent: !!pages[key].default,
56
+ resource: routes[key].api,
57
+ hasServerComponent: !!routes[key].default,
45
58
  exact,
46
59
  };
47
60
  });
48
- memoizedRoutes = [
49
- ...routes.filter((route) => !route.path.includes(':')),
50
- ...routes.filter((route) => route.path.includes(':')),
61
+ memoizedApiRoutes = [
62
+ ...apiRoutes.filter((route) => !route.path.includes(':')),
63
+ ...apiRoutes.filter((route) => route.path.includes(':')),
51
64
  ];
52
- memoizedPages = pages;
53
- return memoizedRoutes;
65
+ memoizedRawRoutes = routes;
66
+ return memoizedApiRoutes;
54
67
  }
55
68
  exports.getApiRoutes = getApiRoutes;
56
69
  function getApiRouteFromURL(url, routes) {
@@ -71,8 +84,14 @@ function getApiRouteFromURL(url, routes) {
71
84
  };
72
85
  }
73
86
  exports.getApiRouteFromURL = getApiRouteFromURL;
74
- function queryShopBuilder(shopifyConfig, request) {
87
+ function queryShopBuilder(shopifyConfigGetter, request) {
75
88
  return async function queryShop({ query, variables, }) {
89
+ const shopifyConfig = typeof shopifyConfigGetter === 'function'
90
+ ? await shopifyConfigGetter(request)
91
+ : shopifyConfigGetter;
92
+ if (!shopifyConfig) {
93
+ throw new Error('Shopify connection info was not found in Hydrogen config');
94
+ }
76
95
  const { storeDomain, storefrontApiVersion, storefrontToken } = shopifyConfig;
77
96
  const buyerIp = request.getBuyerIp();
78
97
  const extraHeaders = (0, storefrontApi_1.getStorefrontApiRequestHeaders)({
@@ -44,6 +44,9 @@ const botUserAgents = [
44
44
  'W3C_Validator',
45
45
  'WhatsApp',
46
46
  'yandex',
47
+ // SEO Tools
48
+ 'Seoradar',
49
+ 'W3C html2txt',
47
50
  ];
48
51
  /**
49
52
  * Creates a regex based on the botUserAgents array
@@ -0,0 +1 @@
1
+ export declare function findRoutePrefix([first, ...rest]: string[]): string | RegExp;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findRoutePrefix = void 0;
4
+ const DEFAULT_ROUTE_PREFIX = /^\.(\/src)?\/routes/;
5
+ function findRoutePrefix([first, ...rest]) {
6
+ if (!(first === null || first === void 0 ? void 0 : first.startsWith('./')))
7
+ return '';
8
+ let commonPrefix = '.';
9
+ if (rest.length > 0) {
10
+ const parts = first.split('/');
11
+ parts.pop(); // Last part is always different and has extension
12
+ for (const string of rest) {
13
+ const tmp = string.split('/');
14
+ const diffIndex = parts.findIndex((part, index) => part !== tmp[index]);
15
+ diffIndex >= 0 && parts.splice(diffIndex);
16
+ }
17
+ commonPrefix = parts.join('/');
18
+ }
19
+ return commonPrefix === '.' ? DEFAULT_ROUTE_PREFIX : commonPrefix;
20
+ }
21
+ exports.findRoutePrefix = findRoutePrefix;
@@ -6,7 +6,7 @@ function findQueryName(key) {
6
6
  if (key.length < 100) {
7
7
  return key.replace('"__QUERY_CACHE_ID__"', '').replace(/"/g, '');
8
8
  }
9
- const match = decodeKey.match(/query ([^\s\()]*)\s?(|\(\{)/);
9
+ const match = decodeKey.match(/query ([^\s()]*)\s?(|\(\{)/);
10
10
  if (match && match.length > 1) {
11
11
  return match[1];
12
12
  }
@@ -0,0 +1 @@
1
+ export declare function parseJSON(json: any): any;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseJSON = void 0;
4
+ function parseJSON(json) {
5
+ if (String(json).includes('__proto__'))
6
+ return JSON.parse(json, noproto);
7
+ return JSON.parse(json);
8
+ }
9
+ exports.parseJSON = parseJSON;
10
+ function noproto(k, v) {
11
+ if (k !== '__proto__')
12
+ return v;
13
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseMetafieldValue = void 0;
4
+ const parse_1 = require("../parse");
4
5
  /**
5
6
  * The `parseMetafieldValue` function parses a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `type`.
6
7
  */
@@ -23,7 +24,7 @@ function parseMetafieldValue(metafield) {
23
24
  case 'dimension':
24
25
  case 'volume':
25
26
  case 'rating':
26
- return JSON.parse(metafield.value);
27
+ return (0, parse_1.parseJSON)(metafield.value);
27
28
  case 'color':
28
29
  case 'single_line_text_field':
29
30
  case 'multi_line_text_field':
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getStorefrontApiRequestHeaders = void 0;
4
+ /* global Oxygen */
4
5
  const constants_1 = require("../constants");
5
6
  function getStorefrontApiRequestHeaders({ buyerIp, storefrontToken, }) {
6
7
  var _a;
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "0.17.1";
1
+ export declare const LIB_VERSION = "0.18.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LIB_VERSION = void 0;
4
- exports.LIB_VERSION = '0.17.1';
4
+ exports.LIB_VERSION = '0.18.0';
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "engines": {
8
8
  "node": ">=14"
9
9
  },
10
- "version": "0.17.1",
10
+ "version": "0.18.0",
11
11
  "description": "Modern custom Shopify storefronts",
12
12
  "license": "MIT",
13
13
  "main": "dist/esnext/index.js",
@@ -21,6 +21,8 @@
21
21
  "entry-server.d.ts",
22
22
  "client.js",
23
23
  "client.d.ts",
24
+ "config.js",
25
+ "config.d.ts",
24
26
  "entry-client.js",
25
27
  "entry-client.d.ts",
26
28
  "marker.js",
@@ -70,8 +72,8 @@
70
72
  "@types/node-fetch": "^2.5.9",
71
73
  "@types/react": "^17.0.3",
72
74
  "@types/react-dom": "^17.0.3",
73
- "@types/ws": "^8.2.0",
74
75
  "@types/uuid": "^8.3.4",
76
+ "@types/ws": "^8.2.0",
75
77
  "babel-loader": "^8.2.2",
76
78
  "cpy-cli": "3.1.1",
77
79
  "mkdirp": "^1.0.4",
@@ -81,7 +83,7 @@
81
83
  "rimraf": "^3.0.2"
82
84
  },
83
85
  "peerDependencies": {
84
- "body-parser": "^1.19.1",
86
+ "body-parser": "^1.20.0",
85
87
  "compression": "^1.7.4",
86
88
  "react": "0.0.0-experimental-2bf7c02f0-20220314",
87
89
  "react-dom": "0.0.0-experimental-2bf7c02f0-20220314",
@@ -102,9 +104,7 @@
102
104
  "dependencies": {
103
105
  "@vitejs/plugin-react": "^1.3.0",
104
106
  "abort-controller": "^3.0.0",
105
- "worktop": "^0.7.3",
106
- "uuid": "^8.3.2",
107
- "body-parser": "^1.19.2",
107
+ "body-parser": "^1.20.0",
108
108
  "connect": "^3.7.0",
109
109
  "es-module-lexer": "^0.10.0",
110
110
  "fast-glob": "^3.2.11",
@@ -116,7 +116,9 @@
116
116
  "path-to-regexp": "^6.2.0",
117
117
  "react-error-boundary": "^3.1.3",
118
118
  "react-helmet-async": "^1.2.3",
119
+ "uuid": "^8.3.2",
119
120
  "vite-plugin-inspect": "^0.3.6",
120
- "web-streams-polyfill": "^3.2.0"
121
+ "web-streams-polyfill": "^3.2.0",
122
+ "worktop": "^0.7.3"
121
123
  }
122
124
  }
@@ -1,9 +0,0 @@
1
- declare global {
2
- interface Window {
3
- BOOMR: any;
4
- BOOMR_onload: any;
5
- }
6
- }
7
- export declare function Boomerang({ pageTemplate }: {
8
- pageTemplate: string | null;
9
- }): null;
@@ -1,66 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { loadScript } from '../../utilities';
3
- import { useShop } from '../useShop';
4
- const URL = 'https://cdn.shopify.com/shopifycloud/boomerang/shopify-boomerang-hydrogen.min.js';
5
- export function Boomerang({ pageTemplate }) {
6
- const { storeDomain } = useShop();
7
- const templateName = pageTemplate && pageTemplate !== null
8
- ? pageTemplate.toLowerCase()
9
- : 'not-set';
10
- useEffect(() => {
11
- (function () {
12
- function boomerangAddVar() {
13
- if (window.BOOMR && window.BOOMR.addVar) {
14
- window.BOOMR.addVar('page_template', templateName);
15
- }
16
- }
17
- // Executes on every mount
18
- boomerangAddVar();
19
- if (window.BOOMR &&
20
- (window.BOOMR.version || window.BOOMR.snippetExecuted)) {
21
- return;
22
- }
23
- // Executes only on first mount
24
- window.BOOMR = window.BOOMR || {};
25
- window.BOOMR.storeDomain = storeDomain;
26
- window.BOOMR.pageTemplate = templateName;
27
- function boomerangSaveLoadTime(e) {
28
- window.BOOMR_onload = (e && e.timeStamp) || Date.now();
29
- }
30
- // @ts-ignore
31
- function boomerangInit(e) {
32
- e.detail.BOOMR.init({
33
- producer_url: 'https://monorail-edge.shopifysvc.com/v1/produce',
34
- });
35
- e.detail.BOOMR.t_end = Date.now();
36
- boomerangAddVar();
37
- }
38
- if (window.addEventListener) {
39
- window.addEventListener('load', boomerangSaveLoadTime, false);
40
- // @ts-ignore
41
- }
42
- else if (window.attachEvent) {
43
- // @ts-ignore
44
- window.attachEvent('onload', boomerangSaveLoadTime);
45
- }
46
- if (document.addEventListener) {
47
- document.addEventListener('onBoomerangLoaded', boomerangInit);
48
- // @ts-ignore
49
- }
50
- else if (document.attachEvent) {
51
- // @ts-ignore
52
- document.attachEvent('onpropertychange', function (e) {
53
- if (!e)
54
- e = event;
55
- if (e.propertyName === 'onBoomerangLoaded')
56
- boomerangInit(e);
57
- });
58
- }
59
- })();
60
- loadScript(URL).catch(() => {
61
- // ignore if boomerang doesn't load
62
- // most likely because of a ad blocker
63
- });
64
- }, [storeDomain, pageTemplate]);
65
- return null;
66
- }