@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.
- package/CHANGELOG.md +144 -0
- package/dist/esnext/client.d.ts +4 -0
- package/dist/esnext/client.js +4 -0
- package/dist/esnext/components/CartProvider/CartProvider.client.js +23 -0
- package/dist/esnext/components/DevTools.d.ts +1 -0
- package/dist/esnext/components/DevTools.js +128 -0
- package/dist/esnext/components/Link/Link.client.d.ts +6 -0
- package/dist/esnext/components/Link/Link.client.js +85 -3
- package/dist/esnext/components/LocalizationProvider/LocalizationContext.client.d.ts +1 -1
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +16 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +7 -2
- package/dist/esnext/components/Seo/DefaultPageSeo.client.js +1 -2
- package/dist/esnext/constants.d.ts +6 -0
- package/dist/esnext/constants.js +6 -0
- package/dist/esnext/entry-client.js +20 -4
- package/dist/esnext/entry-server.d.ts +1 -1
- package/dist/esnext/entry-server.js +42 -23
- package/dist/esnext/foundation/Analytics/Analytics.client.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/Analytics.client.js +28 -0
- package/dist/esnext/foundation/Analytics/Analytics.server.d.ts +1 -0
- package/dist/esnext/foundation/Analytics/Analytics.server.js +38 -0
- package/dist/esnext/foundation/Analytics/ClientAnalytics.d.ts +24 -0
- package/dist/esnext/foundation/Analytics/ClientAnalytics.js +91 -0
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +2 -0
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.js +33 -0
- package/dist/esnext/foundation/Analytics/const.d.ts +8 -0
- package/dist/esnext/foundation/Analytics/const.js +8 -0
- package/dist/esnext/foundation/Analytics/hook.d.ts +1 -0
- package/dist/esnext/foundation/Analytics/hook.js +7 -0
- package/dist/esnext/foundation/Analytics/index.d.ts +2 -0
- package/dist/esnext/foundation/Analytics/index.js +2 -0
- package/dist/esnext/foundation/Analytics/types.d.ts +5 -0
- package/dist/esnext/{components/LocalizationProvider/LocalizationQuery.js → foundation/Analytics/types.js} +0 -0
- package/dist/esnext/foundation/Analytics/utils.d.ts +1 -0
- package/dist/esnext/foundation/Analytics/utils.js +8 -0
- package/dist/esnext/foundation/Boomerang/Boomerang.client.js +3 -1
- package/dist/esnext/foundation/Route/Route.server.js +4 -0
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +68 -15
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +1 -1
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.d.ts +6 -1
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.js +27 -22
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +4 -1
- package/dist/esnext/foundation/ShopifyProvider/types.d.ts +5 -6
- package/dist/esnext/foundation/constants.d.ts +1 -1
- package/dist/esnext/foundation/constants.js +1 -1
- package/dist/esnext/foundation/fetchSync/client/fetchSync.d.ts +10 -0
- package/dist/esnext/foundation/fetchSync/client/fetchSync.js +27 -0
- package/dist/esnext/foundation/fetchSync/server/fetchSync.d.ts +8 -0
- package/dist/esnext/foundation/fetchSync/server/fetchSync.js +27 -0
- package/dist/esnext/foundation/fetchSync/types.d.ts +5 -0
- package/dist/esnext/foundation/fetchSync/types.js +1 -0
- package/dist/esnext/foundation/useQuery/hooks.d.ts +4 -2
- package/dist/esnext/foundation/useQuery/hooks.js +10 -6
- package/dist/esnext/foundation/useUrl/useUrl.js +8 -1
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +1 -0
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +14 -7
- package/dist/esnext/framework/cache/in-memory.js +5 -5
- package/dist/esnext/framework/cache.d.ts +1 -10
- package/dist/esnext/framework/cache.js +67 -30
- package/dist/esnext/framework/plugin.js +10 -0
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +9 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +1 -1
- package/dist/esnext/hooks/useShopQuery/hooks.d.ts +1 -1
- package/dist/esnext/hooks/useShopQuery/hooks.js +37 -22
- package/dist/esnext/index.d.ts +2 -0
- package/dist/esnext/index.js +2 -0
- package/dist/esnext/storefront-api-types.d.ts +150 -3
- package/dist/esnext/storefront-api-types.js +16 -0
- package/dist/esnext/types.d.ts +6 -1
- package/dist/esnext/utilities/apiRoutes.d.ts +2 -3
- package/dist/esnext/utilities/apiRoutes.js +14 -9
- package/dist/esnext/utilities/hash.d.ts +2 -0
- package/dist/esnext/utilities/hash.js +7 -0
- package/dist/esnext/utilities/log/log-cache-api-status.js +1 -1
- package/dist/esnext/utilities/log/log-cache-header.js +1 -1
- package/dist/esnext/utilities/log/log-query-timeline.js +1 -1
- package/dist/esnext/utilities/storefrontApi.d.ts +4 -0
- package/dist/esnext/utilities/storefrontApi.js +21 -0
- package/dist/esnext/utilities/suspense.d.ts +5 -0
- package/dist/esnext/utilities/suspense.js +32 -0
- package/dist/esnext/utilities/template.js +1 -1
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/constants.d.ts +6 -0
- package/dist/node/constants.js +7 -1
- package/dist/node/entry-server.d.ts +1 -1
- package/dist/node/entry-server.js +41 -25
- package/dist/node/foundation/Analytics/Analytics.client.d.ts +3 -0
- package/dist/node/foundation/Analytics/Analytics.client.js +32 -0
- package/dist/node/foundation/Analytics/Analytics.server.d.ts +1 -0
- package/dist/node/foundation/Analytics/Analytics.server.js +45 -0
- package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +24 -0
- package/dist/node/foundation/Analytics/ClientAnalytics.js +94 -0
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +2 -0
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.js +37 -0
- package/dist/node/foundation/Analytics/const.d.ts +8 -0
- package/dist/node/foundation/Analytics/const.js +11 -0
- package/dist/node/foundation/Analytics/hook.d.ts +1 -0
- package/dist/node/foundation/Analytics/hook.js +11 -0
- package/dist/node/foundation/Analytics/index.d.ts +2 -0
- package/dist/node/foundation/Analytics/index.js +7 -0
- package/dist/node/foundation/Analytics/types.d.ts +5 -0
- package/dist/node/foundation/Analytics/types.js +2 -0
- package/dist/node/foundation/Analytics/utils.d.ts +1 -0
- package/dist/node/foundation/Analytics/utils.js +12 -0
- package/dist/node/foundation/Router/BrowserRouter.client.js +67 -14
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +2 -2
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.d.ts +6 -1
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.js +27 -22
- package/dist/node/foundation/ShopifyProvider/types.d.ts +5 -6
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +1 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.js +16 -9
- package/dist/node/framework/cache/in-memory.js +5 -5
- package/dist/node/framework/cache.d.ts +1 -10
- package/dist/node/framework/cache.js +71 -36
- package/dist/node/framework/plugin.js +10 -0
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +9 -2
- package/dist/node/storefront-api-types.d.ts +150 -3
- package/dist/node/storefront-api-types.js +17 -1
- package/dist/node/types.d.ts +6 -1
- package/dist/node/utilities/apiRoutes.d.ts +2 -3
- package/dist/node/utilities/apiRoutes.js +14 -9
- package/dist/node/utilities/flattenConnection/flattenConnection.d.ts +6 -0
- package/dist/node/utilities/flattenConnection/flattenConnection.js +15 -0
- package/dist/node/utilities/flattenConnection/index.d.ts +1 -0
- package/dist/node/utilities/flattenConnection/index.js +5 -0
- package/dist/node/utilities/hash.d.ts +2 -0
- package/dist/node/utilities/hash.js +11 -0
- package/dist/node/utilities/image_size.d.ts +30 -0
- package/dist/node/utilities/image_size.js +110 -0
- package/dist/node/utilities/index.d.ts +11 -0
- package/dist/node/utilities/index.js +32 -0
- package/dist/node/utilities/isClient/index.d.ts +1 -0
- package/dist/node/utilities/isClient/index.js +5 -0
- package/dist/node/utilities/isClient/isClient.d.ts +4 -0
- package/dist/node/utilities/isClient/isClient.js +10 -0
- package/dist/node/utilities/isServer/index.d.ts +1 -0
- package/dist/node/utilities/isServer/index.js +5 -0
- package/dist/node/utilities/isServer/isServer.d.ts +4 -0
- package/dist/node/utilities/isServer/isServer.js +11 -0
- package/dist/node/utilities/load_script.d.ts +3 -0
- package/dist/node/utilities/load_script.js +27 -0
- package/dist/node/utilities/log/log-cache-api-status.js +1 -1
- package/dist/node/utilities/log/log-cache-header.js +2 -2
- package/dist/node/utilities/log/log-query-timeline.js +2 -2
- package/dist/node/utilities/measurement.d.ts +3 -0
- package/dist/node/utilities/measurement.js +103 -0
- package/dist/node/utilities/parseMetafieldValue/index.d.ts +1 -0
- package/dist/node/utilities/parseMetafieldValue/index.js +5 -0
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +6 -0
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +39 -0
- package/dist/node/utilities/storefrontApi.d.ts +4 -0
- package/dist/node/utilities/storefrontApi.js +25 -0
- package/dist/node/utilities/suspense.d.ts +12 -0
- package/dist/node/utilities/suspense.js +64 -0
- package/dist/node/utilities/template.js +1 -1
- package/dist/node/utilities/video_parameters.d.ts +47 -0
- package/dist/node/utilities/video_parameters.js +27 -0
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/package.json +3 -3
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +9 -21
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +51 -47
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +30 -29
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +51 -47
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +17 -17
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +55 -45
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +9 -21
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +51 -47
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +51 -47
- package/vendor/react-server-dom-vite/package.json +3 -3
- 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 {
|
|
11
|
+
import { useState } from 'react';
|
|
12
12
|
|
|
13
|
-
//
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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 = [
|
|
82
|
+
var importers = [userGlob];
|
|
88
83
|
clientComponentPaths.forEach(function (componentPath) {
|
|
89
|
-
|
|
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 (
|
|
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
|
-
|
|
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) + "',
|
|
157
|
-
String(
|
|
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
|
-
|
|
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 =
|
|
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
|
|
184
|
-
|
|
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
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
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
|
-
|
|
1391
|
-
} catch (x) {
|
|
1392
|
-
request.pendingChunks++;
|
|
1395
|
+
var _errorId = request.nextChunkId++;
|
|
1393
1396
|
|
|
1394
|
-
|
|
1397
|
+
emitErrorChunk(request, _errorId, x);
|
|
1398
|
+
return serializeByValueID(_errorId);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1395
1401
|
|
|
1396
|
-
|
|
1397
|
-
|
|
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
|
|
136
|
-
|
|
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
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
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
|
-
|
|
1343
|
-
} catch (x) {
|
|
1344
|
-
request.pendingChunks++;
|
|
1347
|
+
var _errorId = request.nextChunkId++;
|
|
1345
1348
|
|
|
1346
|
-
|
|
1349
|
+
emitErrorChunk(request, _errorId, x);
|
|
1350
|
+
return serializeByValueID(_errorId);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1347
1353
|
|
|
1348
|
-
|
|
1349
|
-
|
|
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
|
-
};
|