@shopify/hydrogen 0.13.2 → 0.16.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 (174) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/dist/esnext/client.d.ts +4 -0
  3. package/dist/esnext/client.js +4 -0
  4. package/dist/esnext/components/CartProvider/CartProvider.client.js +23 -0
  5. package/dist/esnext/components/DevTools.d.ts +1 -0
  6. package/dist/esnext/components/DevTools.js +128 -0
  7. package/dist/esnext/components/Link/Link.client.d.ts +6 -0
  8. package/dist/esnext/components/Link/Link.client.js +85 -3
  9. package/dist/esnext/components/LocalizationProvider/LocalizationContext.client.d.ts +1 -1
  10. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +16 -0
  11. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +7 -2
  12. package/dist/esnext/components/Seo/DefaultPageSeo.client.js +1 -2
  13. package/dist/esnext/constants.d.ts +6 -0
  14. package/dist/esnext/constants.js +6 -0
  15. package/dist/esnext/entry-client.js +20 -4
  16. package/dist/esnext/entry-server.d.ts +1 -1
  17. package/dist/esnext/entry-server.js +42 -23
  18. package/dist/esnext/foundation/Analytics/Analytics.client.d.ts +3 -0
  19. package/dist/esnext/foundation/Analytics/Analytics.client.js +28 -0
  20. package/dist/esnext/foundation/Analytics/Analytics.server.d.ts +1 -0
  21. package/dist/esnext/foundation/Analytics/Analytics.server.js +38 -0
  22. package/dist/esnext/foundation/Analytics/ClientAnalytics.d.ts +24 -0
  23. package/dist/esnext/foundation/Analytics/ClientAnalytics.js +91 -0
  24. package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +2 -0
  25. package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.js +33 -0
  26. package/dist/esnext/foundation/Analytics/const.d.ts +8 -0
  27. package/dist/esnext/foundation/Analytics/const.js +8 -0
  28. package/dist/esnext/foundation/Analytics/hook.d.ts +1 -0
  29. package/dist/esnext/foundation/Analytics/hook.js +7 -0
  30. package/dist/esnext/foundation/Analytics/index.d.ts +2 -0
  31. package/dist/esnext/foundation/Analytics/index.js +2 -0
  32. package/dist/esnext/foundation/Analytics/types.d.ts +5 -0
  33. package/dist/esnext/{components/LocalizationProvider/LocalizationQuery.js → foundation/Analytics/types.js} +0 -0
  34. package/dist/esnext/foundation/Analytics/utils.d.ts +1 -0
  35. package/dist/esnext/foundation/Analytics/utils.js +8 -0
  36. package/dist/esnext/foundation/Boomerang/Boomerang.client.js +3 -1
  37. package/dist/esnext/foundation/Route/Route.server.js +4 -0
  38. package/dist/esnext/foundation/Router/BrowserRouter.client.js +68 -15
  39. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +1 -1
  40. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.d.ts +6 -1
  41. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.js +27 -22
  42. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +4 -1
  43. package/dist/esnext/foundation/ShopifyProvider/types.d.ts +5 -6
  44. package/dist/esnext/foundation/constants.d.ts +1 -1
  45. package/dist/esnext/foundation/constants.js +1 -1
  46. package/dist/esnext/foundation/fetchSync/client/fetchSync.d.ts +10 -0
  47. package/dist/esnext/foundation/fetchSync/client/fetchSync.js +27 -0
  48. package/dist/esnext/foundation/fetchSync/server/fetchSync.d.ts +8 -0
  49. package/dist/esnext/foundation/fetchSync/server/fetchSync.js +27 -0
  50. package/dist/esnext/foundation/fetchSync/types.d.ts +5 -0
  51. package/dist/esnext/foundation/fetchSync/types.js +1 -0
  52. package/dist/esnext/foundation/useQuery/hooks.d.ts +4 -2
  53. package/dist/esnext/foundation/useQuery/hooks.js +10 -6
  54. package/dist/esnext/foundation/useUrl/useUrl.js +8 -1
  55. package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +1 -0
  56. package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +14 -7
  57. package/dist/esnext/framework/cache/in-memory.js +5 -5
  58. package/dist/esnext/framework/cache.d.ts +1 -10
  59. package/dist/esnext/framework/cache.js +67 -30
  60. package/dist/esnext/framework/plugin.js +10 -0
  61. package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +1 -1
  62. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +9 -2
  63. package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +1 -1
  64. package/dist/esnext/hooks/useShopQuery/hooks.d.ts +1 -1
  65. package/dist/esnext/hooks/useShopQuery/hooks.js +37 -22
  66. package/dist/esnext/index.d.ts +2 -0
  67. package/dist/esnext/index.js +2 -0
  68. package/dist/esnext/storefront-api-types.d.ts +150 -3
  69. package/dist/esnext/storefront-api-types.js +16 -0
  70. package/dist/esnext/types.d.ts +6 -1
  71. package/dist/esnext/utilities/apiRoutes.d.ts +2 -3
  72. package/dist/esnext/utilities/apiRoutes.js +14 -9
  73. package/dist/esnext/utilities/hash.d.ts +2 -0
  74. package/dist/esnext/utilities/hash.js +7 -0
  75. package/dist/esnext/utilities/log/log-cache-api-status.js +1 -1
  76. package/dist/esnext/utilities/log/log-cache-header.js +1 -1
  77. package/dist/esnext/utilities/log/log-query-timeline.js +1 -1
  78. package/dist/esnext/utilities/storefrontApi.d.ts +4 -0
  79. package/dist/esnext/utilities/storefrontApi.js +21 -0
  80. package/dist/esnext/utilities/suspense.d.ts +5 -0
  81. package/dist/esnext/utilities/suspense.js +32 -0
  82. package/dist/esnext/utilities/template.js +1 -1
  83. package/dist/esnext/version.d.ts +1 -1
  84. package/dist/esnext/version.js +1 -1
  85. package/dist/node/constants.d.ts +6 -0
  86. package/dist/node/constants.js +7 -1
  87. package/dist/node/entry-server.d.ts +1 -1
  88. package/dist/node/entry-server.js +41 -25
  89. package/dist/node/foundation/Analytics/Analytics.client.d.ts +3 -0
  90. package/dist/node/foundation/Analytics/Analytics.client.js +32 -0
  91. package/dist/node/foundation/Analytics/Analytics.server.d.ts +1 -0
  92. package/dist/node/foundation/Analytics/Analytics.server.js +45 -0
  93. package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +24 -0
  94. package/dist/node/foundation/Analytics/ClientAnalytics.js +94 -0
  95. package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +2 -0
  96. package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.js +37 -0
  97. package/dist/node/foundation/Analytics/const.d.ts +8 -0
  98. package/dist/node/foundation/Analytics/const.js +11 -0
  99. package/dist/node/foundation/Analytics/hook.d.ts +1 -0
  100. package/dist/node/foundation/Analytics/hook.js +11 -0
  101. package/dist/node/foundation/Analytics/index.d.ts +2 -0
  102. package/dist/node/foundation/Analytics/index.js +7 -0
  103. package/dist/node/foundation/Analytics/types.d.ts +5 -0
  104. package/dist/node/foundation/Analytics/types.js +2 -0
  105. package/dist/node/foundation/Analytics/utils.d.ts +1 -0
  106. package/dist/node/foundation/Analytics/utils.js +12 -0
  107. package/dist/node/foundation/Router/BrowserRouter.client.js +67 -14
  108. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +2 -2
  109. package/dist/node/foundation/ServerStateProvider/ServerStateProvider.d.ts +6 -1
  110. package/dist/node/foundation/ServerStateProvider/ServerStateProvider.js +27 -22
  111. package/dist/node/foundation/ShopifyProvider/types.d.ts +5 -6
  112. package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +1 -0
  113. package/dist/node/framework/Hydration/ServerComponentRequest.server.js +16 -9
  114. package/dist/node/framework/cache/in-memory.js +5 -5
  115. package/dist/node/framework/cache.d.ts +1 -10
  116. package/dist/node/framework/cache.js +71 -36
  117. package/dist/node/framework/plugin.js +10 -0
  118. package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +1 -1
  119. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +9 -2
  120. package/dist/node/storefront-api-types.d.ts +150 -3
  121. package/dist/node/storefront-api-types.js +17 -1
  122. package/dist/node/types.d.ts +6 -1
  123. package/dist/node/utilities/apiRoutes.d.ts +2 -3
  124. package/dist/node/utilities/apiRoutes.js +14 -9
  125. package/dist/node/utilities/flattenConnection/flattenConnection.d.ts +6 -0
  126. package/dist/node/utilities/flattenConnection/flattenConnection.js +15 -0
  127. package/dist/node/utilities/flattenConnection/index.d.ts +1 -0
  128. package/dist/node/utilities/flattenConnection/index.js +5 -0
  129. package/dist/node/utilities/hash.d.ts +2 -0
  130. package/dist/node/utilities/hash.js +11 -0
  131. package/dist/node/utilities/image_size.d.ts +30 -0
  132. package/dist/node/utilities/image_size.js +110 -0
  133. package/dist/node/utilities/index.d.ts +11 -0
  134. package/dist/node/utilities/index.js +32 -0
  135. package/dist/node/utilities/isClient/index.d.ts +1 -0
  136. package/dist/node/utilities/isClient/index.js +5 -0
  137. package/dist/node/utilities/isClient/isClient.d.ts +4 -0
  138. package/dist/node/utilities/isClient/isClient.js +10 -0
  139. package/dist/node/utilities/isServer/index.d.ts +1 -0
  140. package/dist/node/utilities/isServer/index.js +5 -0
  141. package/dist/node/utilities/isServer/isServer.d.ts +4 -0
  142. package/dist/node/utilities/isServer/isServer.js +11 -0
  143. package/dist/node/utilities/load_script.d.ts +3 -0
  144. package/dist/node/utilities/load_script.js +27 -0
  145. package/dist/node/utilities/log/log-cache-api-status.js +1 -1
  146. package/dist/node/utilities/log/log-cache-header.js +2 -2
  147. package/dist/node/utilities/log/log-query-timeline.js +2 -2
  148. package/dist/node/utilities/measurement.d.ts +3 -0
  149. package/dist/node/utilities/measurement.js +103 -0
  150. package/dist/node/utilities/parseMetafieldValue/index.d.ts +1 -0
  151. package/dist/node/utilities/parseMetafieldValue/index.js +5 -0
  152. package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +6 -0
  153. package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +39 -0
  154. package/dist/node/utilities/storefrontApi.d.ts +4 -0
  155. package/dist/node/utilities/storefrontApi.js +25 -0
  156. package/dist/node/utilities/suspense.d.ts +12 -0
  157. package/dist/node/utilities/suspense.js +64 -0
  158. package/dist/node/utilities/template.js +1 -1
  159. package/dist/node/utilities/video_parameters.d.ts +47 -0
  160. package/dist/node/utilities/video_parameters.js +27 -0
  161. package/dist/node/version.d.ts +1 -1
  162. package/dist/node/version.js +1 -1
  163. package/package.json +3 -3
  164. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +9 -21
  165. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +51 -47
  166. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +30 -29
  167. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +51 -47
  168. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +17 -17
  169. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +55 -45
  170. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +9 -21
  171. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +51 -47
  172. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +51 -47
  173. package/vendor/react-server-dom-vite/package.json +3 -3
  174. package/dist/esnext/components/LocalizationProvider/LocalizationQuery.d.ts +0 -23
@@ -8,18 +8,38 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
 
11
- import { createElement } from 'react';
11
+ import { useState } from 'react';
12
12
 
13
- // eslint-disable-next-line no-unused-vars
13
+ // Store of components discovered during RSC to load
14
+ // them later when consuming the response in SSR.
15
+ globalThis.__COMPONENT_INDEX = {}; // Store to get module references for long strings
16
+ // when rendering in RSC (strings cannot be wrapped Proxy).
14
17
 
15
- /*global globalThis*/
16
- // This is a store of components discovered during RSC
17
- // to load them later when consuming the response in SSR.
18
- globalThis.__COMPONENT_INDEX = {};
18
+ globalThis.__STRING_REFERENCE_INDEX = {};
19
+ var MODULE_TAG = Symbol.for('react.module.reference');
20
+ var STRING_SIZE_LIMIT = 64;
21
+ var FN_RSC_ERROR = 'Functions exported from client components cannot be called or used as constructors from a server component.'; // TODO what's a better way to detect Flight runtime?
19
22
 
20
- function isReactComponent(component, name, isNamed) {
21
- if (!component) return false;
22
- return typeof component === 'function' && (!isNamed || /^[A-Z]/.test(name)) || typeof component.render === 'function' || component.$$typeof === Symbol.for('react.element');
23
+ function isRsc() {
24
+ try {
25
+ useState();
26
+ return false;
27
+ } catch (error) {
28
+ return error.message.endsWith('Server Components.');
29
+ }
30
+ }
31
+
32
+ function createModuleReference(id, value, name, isDefault) {
33
+ var moduleRef = Object.create(null);
34
+ moduleRef.$$typeof = MODULE_TAG;
35
+ moduleRef.filepath = id;
36
+ moduleRef.name = isDefault ? 'default' : name; // Store component in a global index during RSC to use it later in SSR
37
+
38
+ globalThis.__COMPONENT_INDEX[id] = Object.defineProperty(globalThis.__COMPONENT_INDEX[id] || Object.create(null), moduleRef.name, {
39
+ value: value,
40
+ writable: true
41
+ });
42
+ return moduleRef;
23
43
  } // A ClientProxy behaves as a module reference for the Flight
24
44
  // runtime (RSC) and as a real component for the Fizz runtime (SSR).
25
45
  // Note that this is not used in browser environments.
@@ -28,49 +48,39 @@ function isReactComponent(component, name, isNamed) {
28
48
  function wrapInClientProxy(_ref) {
29
49
  var id = _ref.id,
30
50
  name = _ref.name,
31
- named = _ref.named,
32
- component = _ref.component;
33
-
34
- if (!isReactComponent(component, name, named)) {
35
- // This is not a React component, do not wrap it.
36
- return component;
37
- }
51
+ isDefault = _ref.isDefault,
52
+ value = _ref.value;
53
+ var type = typeof value;
38
54
 
39
- var render = function (props) {
40
- return createElement(component, props);
41
- };
42
-
43
- Object.defineProperty(render, 'name', {
44
- value: name
45
- });
55
+ if (value === null || type !== 'object' && type !== 'function') {
56
+ if (type === 'string' && value.length >= STRING_SIZE_LIMIT) {
57
+ var _moduleRef = createModuleReference(id, value, name, isDefault);
46
58
 
47
- {
48
- render.displayName = name;
49
- } // Fizz runtime accesses the `render` method directly when encountering a forward_ref
59
+ globalThis.__STRING_REFERENCE_INDEX[value] = _moduleRef;
60
+ }
50
61
 
62
+ return value;
63
+ }
51
64
 
52
- var componentRef = Object.create(null);
53
- componentRef.$$typeof = Symbol.for('react.forward_ref');
54
- componentRef.render = render; // Flight runtime will check this custom typeof to decide wether this is a module ref
65
+ var moduleRef = createModuleReference(id, value, name, isDefault);
55
66
 
56
- var moduleRef = Object.create(null);
57
- moduleRef.$$typeof_rsc = Symbol.for('react.module.reference');
58
- moduleRef.filepath = id;
59
- moduleRef.name = named ? name : 'default'; // Store component in a global index during RSC to use them later in SSR
67
+ var get = function (target, prop, receiver) {
68
+ return Reflect.get(isRsc() ? moduleRef : target, prop, receiver);
69
+ };
60
70
 
61
- globalThis.__COMPONENT_INDEX[id] = Object.defineProperty(globalThis.__COMPONENT_INDEX[id] || Object.create(null), moduleRef.name, {
62
- value: component,
63
- writable: true
64
- });
65
- return new Proxy(componentRef, {
66
- get: function (target, prop) {
67
- return (// 1. Let React access the element/ref and type in SSR
68
- target[prop] || // 2. Check module properties for RSC requests
69
- moduleRef[prop] || // 3. Fallback to custom component properties such as `ImageComponent.Fragment`
70
- component[prop]
71
- );
71
+ return new Proxy(value, type === 'object' ? {
72
+ get: get
73
+ } : {
74
+ get: get,
75
+ apply: function () {
76
+ if (isRsc()) throw new Error(FN_RSC_ERROR + (" Calling \"" + name + "\"."));
77
+ return Reflect.apply.apply(Reflect, arguments);
78
+ },
79
+ construct: function () {
80
+ if (isRsc()) throw new Error(FN_RSC_ERROR + (" Instantiating \"" + name + "\"."));
81
+ return Reflect.construct.apply(Reflect, arguments);
72
82
  }
73
83
  });
74
84
  }
75
85
 
76
- export { wrapInClientProxy };
86
+ export { FN_RSC_ERROR, MODULE_TAG, STRING_SIZE_LIMIT, isRsc, wrapInClientProxy };
@@ -78,25 +78,14 @@ function ReactFlightVitePlugin() {
78
78
  var CLIENT_COMPONENT_GLOB = '**/*.client.[jt]s?(x)';
79
79
  var importerPath = path.dirname(id);
80
80
  var importerToRootPath = normalizePath(path.relative(importerPath, config.root));
81
-
82
- var _ref2 = importerToRootPath.match(/(\.\.\/)+(\.\.)?/) || [],
83
- importerToRootNested = _ref2[0];
84
-
85
- var userPrefix = path.normalize(path.join(importerPath, importerToRootNested.replace(/\/?$/, path.sep)));
86
81
  var userGlob = path.join(importerToRootPath, CLIENT_COMPONENT_GLOB);
87
- var importers = [[userGlob, userPrefix]];
82
+ var importers = [userGlob];
88
83
  clientComponentPaths.forEach(function (componentPath) {
89
- var libPrefix = componentPath + path.sep;
90
- var libGlob = path.join(path.relative(importerPath, componentPath), CLIENT_COMPONENT_GLOB);
91
- importers.push([libGlob, libPrefix]);
84
+ importers.push(path.join(path.relative(importerPath, componentPath), CLIENT_COMPONENT_GLOB));
92
85
  });
93
- var injectedGlobs = "Object.assign(Object.create(null), " + importers.map(function (_ref3) {
94
- var glob = _ref3[0],
95
- prefix = _ref3[1];
86
+ var injectedGlobs = "Object.assign(Object.create(null), " + importers.map(function (glob) {
96
87
  return (// Mark the globs to modify the result after Vite resolves them.
97
- // The prefix is used later to turn relative imports
98
- // into absolute imports, and then into hashes.
99
- "/* HASH_BEGIN " + normalizePath(prefix) + " */ " + ("import.meta.glob('" + normalizePath(glob) + "') /* HASH_END */")
88
+ "/* HASH_BEGIN */ " + ("import.meta.glob('" + normalizePath(glob) + "') /* HASH_END */")
100
89
  );
101
90
  }).join(', ') + ");";
102
91
  return code.replace(INJECTING_RE, injectedGlobs);
@@ -153,8 +142,8 @@ async function proxyClientComponent(filepath, src) {
153
142
  exportStatements.forEach(function (key) {
154
143
  var isDefault = key === DEFAULT_EXPORT;
155
144
  var componentName = isDefault ? getComponentFilename(filepath) : key;
156
- proxyCode += "export " + (isDefault ? DEFAULT_EXPORT : "const " + componentName + " =") + " wrapInClientProxy({ name: '" + componentName + "', id: '" + getComponentId(filepath) + "', component: allImports['" + key + "'], named: " + // eslint-disable-next-line react-internal/safe-string-coercion
157
- String(!isDefault) + " });\n";
145
+ proxyCode += "export " + (isDefault ? DEFAULT_EXPORT : "const " + componentName + " =") + " wrapInClientProxy({ name: '" + componentName + "', id: '" + getComponentId(filepath) + "', value: allImports['" + key + "'], isDefault: " + // eslint-disable-next-line react-internal/safe-string-coercion
146
+ String(isDefault) + " });\n";
158
147
  });
159
148
  return proxyCode;
160
149
  }
@@ -164,11 +153,10 @@ var hashImportsPlugin = {
164
153
  transform: function (code, id) {
165
154
  // Turn relative import paths to lossy hashes
166
155
  if (rscViteFileRE.test(id)) {
167
- var nestedRE = /\.\.\//gm;
168
- return code.replace(/\/\*\s*HASH_BEGIN\s*(.+?)\s*\*\/\s*([^]+?)\/\*\s*HASH_END\s*\*\//gm, function (_, prefix, imports) {
156
+ return code.replace(/\/\*\s*HASH_BEGIN\s*\*\/\s*([^]+?)\/\*\s*HASH_END\s*\*\//gm, function (_, imports) {
169
157
  return imports.trim().replace(/"([^"]+?)":/gm, function (__, relativePath) {
170
- var absolutePath = prefix + relativePath.replace(nestedRE, '');
171
- return "\"" + getComponentId(absolutePath) + "\":";
158
+ var absolutePath = path.resolve(path.dirname(id.split('?')[0]), relativePath);
159
+ return "\"" + getComponentId(normalizePath(absolutePath)) + "\":";
172
160
  });
173
161
  });
174
162
  }
@@ -180,8 +180,9 @@ var MODULE_TAG = Symbol.for('react.module.reference');
180
180
  function getModuleKey(reference) {
181
181
  return reference.filepath + '#' + reference.name;
182
182
  }
183
- function isModuleReference(reference) {
184
- return (reference.$$typeof_rsc || reference.$$typeof) === MODULE_TAG;
183
+ function getModuleReference(reference) {
184
+ if (typeof reference === 'string') return globalThis.__STRING_REFERENCE_INDEX[reference];
185
+ return reference && reference.$$typeof === MODULE_TAG ? reference : undefined;
185
186
  }
186
187
  function resolveModuleMetaData(config, moduleReference) {
187
188
  return {
@@ -997,6 +998,11 @@ function attemptResolveElement(type, key, ref, props) {
997
998
  throw new Error('Refs cannot be used in server components, nor passed to client components.');
998
999
  }
999
1000
 
1001
+ if (getModuleReference(type)) {
1002
+ // This is a reference to a client component.
1003
+ return [REACT_ELEMENT_TYPE, type, key, props];
1004
+ }
1005
+
1000
1006
  if (typeof type === 'function') {
1001
1007
  // This is a server-side component.
1002
1008
  return type(props);
@@ -1016,11 +1022,6 @@ function attemptResolveElement(type, key, ref, props) {
1016
1022
 
1017
1023
  return [REACT_ELEMENT_TYPE, type, key, props];
1018
1024
  } else if (type != null && typeof type === 'object') {
1019
- if (isModuleReference(type)) {
1020
- // This is a reference to a client component.
1021
- return [REACT_ELEMENT_TYPE, type, key, props];
1022
- }
1023
-
1024
1025
  switch (type.$$typeof) {
1025
1026
  case REACT_LAZY_TYPE:
1026
1027
  {
@@ -1351,52 +1352,55 @@ function resolveModelToJSON(request, parent, key, value) {
1351
1352
  return null;
1352
1353
  }
1353
1354
 
1354
- if (typeof value === 'object') {
1355
- if (isModuleReference(value)) {
1356
- var moduleReference = value;
1357
- var moduleKey = getModuleKey(moduleReference);
1358
- var writtenModules = request.writtenModules;
1359
- var existingId = writtenModules.get(moduleKey);
1360
-
1361
- if (existingId !== undefined) {
1362
- if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1363
- // If we're encoding the "type" of an element, we can refer
1364
- // to that by a lazy reference instead of directly since React
1365
- // knows how to deal with lazy values. This lets us suspend
1366
- // on this component rather than its parent until the code has
1367
- // loaded.
1368
- return serializeByRefID(existingId);
1369
- }
1355
+ var moduleReference = getModuleReference(value);
1356
+
1357
+ if (moduleReference) {
1358
+ var moduleKey = getModuleKey(moduleReference);
1359
+ var writtenModules = request.writtenModules;
1360
+ var existingId = writtenModules.get(moduleKey);
1361
+
1362
+ if (existingId !== undefined) {
1363
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1364
+ // If we're encoding the "type" of an element, we can refer
1365
+ // to that by a lazy reference instead of directly since React
1366
+ // knows how to deal with lazy values. This lets us suspend
1367
+ // on this component rather than its parent until the code has
1368
+ // loaded.
1369
+ return serializeByRefID(existingId);
1370
+ }
1371
+
1372
+ return serializeByValueID(existingId);
1373
+ }
1370
1374
 
1371
- return serializeByValueID(existingId);
1375
+ try {
1376
+ var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
1377
+ request.pendingChunks++;
1378
+ var moduleId = request.nextChunkId++;
1379
+ emitModuleChunk(request, moduleId, moduleMetaData);
1380
+ writtenModules.set(moduleKey, moduleId);
1381
+
1382
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1383
+ // If we're encoding the "type" of an element, we can refer
1384
+ // to that by a lazy reference instead of directly since React
1385
+ // knows how to deal with lazy values. This lets us suspend
1386
+ // on this component rather than its parent until the code has
1387
+ // loaded.
1388
+ return serializeByRefID(moduleId);
1372
1389
  }
1373
1390
 
1374
- try {
1375
- var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
1376
- request.pendingChunks++;
1377
- var moduleId = request.nextChunkId++;
1378
- emitModuleChunk(request, moduleId, moduleMetaData);
1379
- writtenModules.set(moduleKey, moduleId);
1380
-
1381
- if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1382
- // If we're encoding the "type" of an element, we can refer
1383
- // to that by a lazy reference instead of directly since React
1384
- // knows how to deal with lazy values. This lets us suspend
1385
- // on this component rather than its parent until the code has
1386
- // loaded.
1387
- return serializeByRefID(moduleId);
1388
- }
1391
+ return serializeByValueID(moduleId);
1392
+ } catch (x) {
1393
+ request.pendingChunks++;
1389
1394
 
1390
- return serializeByValueID(moduleId);
1391
- } catch (x) {
1392
- request.pendingChunks++;
1395
+ var _errorId = request.nextChunkId++;
1393
1396
 
1394
- var _errorId = request.nextChunkId++;
1397
+ emitErrorChunk(request, _errorId, x);
1398
+ return serializeByValueID(_errorId);
1399
+ }
1400
+ }
1395
1401
 
1396
- emitErrorChunk(request, _errorId, x);
1397
- return serializeByValueID(_errorId);
1398
- }
1399
- } else if (value.$$typeof === REACT_PROVIDER_TYPE) {
1402
+ if (typeof value === 'object') {
1403
+ if (value.$$typeof === REACT_PROVIDER_TYPE) {
1400
1404
  var providerKey = value._context._globalName;
1401
1405
  var writtenProviders = request.writtenProviders;
1402
1406
  var providerId = writtenProviders.get(key);
@@ -132,8 +132,9 @@ var MODULE_TAG = Symbol.for('react.module.reference');
132
132
  function getModuleKey(reference) {
133
133
  return reference.filepath + '#' + reference.name;
134
134
  }
135
- function isModuleReference(reference) {
136
- return (reference.$$typeof_rsc || reference.$$typeof) === MODULE_TAG;
135
+ function getModuleReference(reference) {
136
+ if (typeof reference === 'string') return globalThis.__STRING_REFERENCE_INDEX[reference];
137
+ return reference && reference.$$typeof === MODULE_TAG ? reference : undefined;
137
138
  }
138
139
  function resolveModuleMetaData(config, moduleReference) {
139
140
  return {
@@ -949,6 +950,11 @@ function attemptResolveElement(type, key, ref, props) {
949
950
  throw new Error('Refs cannot be used in server components, nor passed to client components.');
950
951
  }
951
952
 
953
+ if (getModuleReference(type)) {
954
+ // This is a reference to a client component.
955
+ return [REACT_ELEMENT_TYPE, type, key, props];
956
+ }
957
+
952
958
  if (typeof type === 'function') {
953
959
  // This is a server-side component.
954
960
  return type(props);
@@ -968,11 +974,6 @@ function attemptResolveElement(type, key, ref, props) {
968
974
 
969
975
  return [REACT_ELEMENT_TYPE, type, key, props];
970
976
  } else if (type != null && typeof type === 'object') {
971
- if (isModuleReference(type)) {
972
- // This is a reference to a client component.
973
- return [REACT_ELEMENT_TYPE, type, key, props];
974
- }
975
-
976
977
  switch (type.$$typeof) {
977
978
  case REACT_LAZY_TYPE:
978
979
  {
@@ -1303,52 +1304,55 @@ function resolveModelToJSON(request, parent, key, value) {
1303
1304
  return null;
1304
1305
  }
1305
1306
 
1306
- if (typeof value === 'object') {
1307
- if (isModuleReference(value)) {
1308
- var moduleReference = value;
1309
- var moduleKey = getModuleKey(moduleReference);
1310
- var writtenModules = request.writtenModules;
1311
- var existingId = writtenModules.get(moduleKey);
1312
-
1313
- if (existingId !== undefined) {
1314
- if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1315
- // If we're encoding the "type" of an element, we can refer
1316
- // to that by a lazy reference instead of directly since React
1317
- // knows how to deal with lazy values. This lets us suspend
1318
- // on this component rather than its parent until the code has
1319
- // loaded.
1320
- return serializeByRefID(existingId);
1321
- }
1307
+ var moduleReference = getModuleReference(value);
1308
+
1309
+ if (moduleReference) {
1310
+ var moduleKey = getModuleKey(moduleReference);
1311
+ var writtenModules = request.writtenModules;
1312
+ var existingId = writtenModules.get(moduleKey);
1313
+
1314
+ if (existingId !== undefined) {
1315
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1316
+ // If we're encoding the "type" of an element, we can refer
1317
+ // to that by a lazy reference instead of directly since React
1318
+ // knows how to deal with lazy values. This lets us suspend
1319
+ // on this component rather than its parent until the code has
1320
+ // loaded.
1321
+ return serializeByRefID(existingId);
1322
+ }
1323
+
1324
+ return serializeByValueID(existingId);
1325
+ }
1322
1326
 
1323
- return serializeByValueID(existingId);
1327
+ try {
1328
+ var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
1329
+ request.pendingChunks++;
1330
+ var moduleId = request.nextChunkId++;
1331
+ emitModuleChunk(request, moduleId, moduleMetaData);
1332
+ writtenModules.set(moduleKey, moduleId);
1333
+
1334
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1335
+ // If we're encoding the "type" of an element, we can refer
1336
+ // to that by a lazy reference instead of directly since React
1337
+ // knows how to deal with lazy values. This lets us suspend
1338
+ // on this component rather than its parent until the code has
1339
+ // loaded.
1340
+ return serializeByRefID(moduleId);
1324
1341
  }
1325
1342
 
1326
- try {
1327
- var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
1328
- request.pendingChunks++;
1329
- var moduleId = request.nextChunkId++;
1330
- emitModuleChunk(request, moduleId, moduleMetaData);
1331
- writtenModules.set(moduleKey, moduleId);
1332
-
1333
- if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1334
- // If we're encoding the "type" of an element, we can refer
1335
- // to that by a lazy reference instead of directly since React
1336
- // knows how to deal with lazy values. This lets us suspend
1337
- // on this component rather than its parent until the code has
1338
- // loaded.
1339
- return serializeByRefID(moduleId);
1340
- }
1343
+ return serializeByValueID(moduleId);
1344
+ } catch (x) {
1345
+ request.pendingChunks++;
1341
1346
 
1342
- return serializeByValueID(moduleId);
1343
- } catch (x) {
1344
- request.pendingChunks++;
1347
+ var _errorId = request.nextChunkId++;
1345
1348
 
1346
- var _errorId = request.nextChunkId++;
1349
+ emitErrorChunk(request, _errorId, x);
1350
+ return serializeByValueID(_errorId);
1351
+ }
1352
+ }
1347
1353
 
1348
- emitErrorChunk(request, _errorId, x);
1349
- return serializeByValueID(_errorId);
1350
- }
1351
- } else if (value.$$typeof === REACT_PROVIDER_TYPE) {
1354
+ if (typeof value === 'object') {
1355
+ if (value.$$typeof === REACT_PROVIDER_TYPE) {
1352
1356
  var providerKey = value._context._globalName;
1353
1357
  var writtenProviders = request.writtenProviders;
1354
1358
  var providerId = writtenProviders.get(key);
@@ -37,7 +37,7 @@
37
37
  "require": "./writer.node.server.js",
38
38
  "import": "./esm/react-server-dom-vite-writer.node.server.js"
39
39
  },
40
- "./writer.browser.server": {
40
+ "./writer.browser.server": {
41
41
  "require": "./writer.browser.server.js",
42
42
  "import": "./esm/react-server-dom-vite-writer.browser.server.js"
43
43
  },
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "main": "index.js",
48
48
  "repository": {
49
- "type": "git",
50
- "url": "https://github.com/facebook/react.git",
49
+ "type" : "git",
50
+ "url" : "https://github.com/facebook/react.git",
51
51
  "directory": "packages/react-server-dom-vite"
52
52
  },
53
53
  "engines": {
@@ -1,23 +0,0 @@
1
- /**
2
- * THIS FILE IS AUTO-GENERATED, DO NOT EDIT.
3
- * Instead, you can edit the associated .graphql file to query for additional fields and this file will be updated when you run `yarn graphql-types`
4
- */
5
- import * as Types from '../../storefront-api-types';
6
- export declare type LocalizationQueryVariables = Types.Exact<{
7
- [key: string]: never;
8
- }>;
9
- export declare type LocalizationQuery = {
10
- __typename?: 'QueryRoot';
11
- } & {
12
- localization: {
13
- __typename?: 'Localization';
14
- } & {
15
- country: {
16
- __typename?: 'Country';
17
- } & Pick<Types.Country, 'isoCode' | 'name'> & {
18
- currency: {
19
- __typename?: 'Currency';
20
- } & Pick<Types.Currency, 'isoCode'>;
21
- };
22
- };
23
- };