@shopify/hydrogen 0.12.0 → 0.13.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 +310 -26
- package/dist/esnext/client.d.ts +2 -0
- package/dist/esnext/client.js +2 -0
- package/dist/esnext/components/CartLineProvider/context.d.ts +10 -10
- package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +2 -1
- package/dist/esnext/components/CartProvider/cart-queries.d.ts +9 -0
- package/dist/esnext/components/CartProvider/cart-queries.js +876 -0
- package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +1 -1
- package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +1 -1
- package/dist/esnext/components/CartProvider/hooks.d.ts +1 -1
- package/dist/esnext/components/CartProvider/hooks.js +4 -1
- package/dist/esnext/components/CartProvider/types.d.ts +1 -1
- package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +6 -5
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +5 -2
- package/dist/esnext/components/Image/Image.d.ts +14 -12
- package/dist/esnext/components/Image/Image.js +17 -14
- package/dist/esnext/components/Link/Link.client.d.ts +4 -5
- package/dist/esnext/components/Link/Link.client.js +5 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.js +1 -3
- package/dist/esnext/components/LocalizationProvider/LocalizationContext.client.d.ts +0 -1
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +2 -2
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +15 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationQuery.d.ts +1 -8
- package/dist/esnext/components/LocalizationProvider/index.d.ts +0 -1
- package/dist/esnext/components/LocalizationProvider/index.js +0 -1
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +4 -3
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +2 -2
- package/dist/esnext/components/Metafield/Metafield.client.js +8 -5
- package/dist/esnext/components/Metafield/types.d.ts +1 -1
- package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +57 -56
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +10 -4
- package/dist/esnext/components/Money/Money.client.d.ts +5 -4
- package/dist/esnext/components/Money/Money.client.js +1 -1
- package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +9 -4
- package/dist/esnext/components/ProductDescription/ProductDescription.client.js +4 -3
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +3 -3
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +2 -2
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +3 -2
- package/dist/esnext/components/ProductProvider/ProductProvider.client.js +1 -0
- package/dist/esnext/components/ProductProvider/context.d.ts +23 -14
- package/dist/esnext/components/Seo/CollectionSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/CollectionSeo.client.js +2 -2
- package/dist/esnext/components/Seo/DefaultPageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/DescriptionSeo.client.d.ts +2 -2
- package/dist/esnext/components/Seo/HomePageSeo.client.d.ts +1 -1
- package/dist/esnext/components/Seo/ImageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/ImageSeo.client.js +1 -1
- package/dist/esnext/components/Seo/PageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/ProductSeo.client.d.ts +3 -3
- package/dist/esnext/components/Seo/ProductSeo.client.js +10 -5
- package/dist/esnext/components/Seo/Seo.client.d.ts +10 -7
- package/dist/esnext/components/Seo/TitleSeo.client.d.ts +3 -4
- package/dist/esnext/components/Seo/TwitterSeo.client.d.ts +1 -1
- package/dist/esnext/components/Seo/seo-types.d.ts +17 -0
- package/dist/esnext/components/{ExternalVideo/ExternalVideoFragment.js → Seo/seo-types.js} +0 -0
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +7 -6
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +1 -1
- package/dist/esnext/components/Video/Video.d.ts +5 -4
- package/dist/esnext/components/Video/Video.js +10 -2
- package/dist/esnext/components/index.d.ts +0 -3
- package/dist/esnext/components/index.js +0 -3
- package/dist/esnext/entry-client.js +9 -4
- package/dist/esnext/entry-server.js +99 -87
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.d.ts +22 -0
- package/dist/esnext/foundation/{Router/FileRoutes.js → FileRoutes/FileRoutes.server.js} +20 -10
- package/dist/esnext/foundation/Redirect/Redirect.client.d.ts +5 -0
- package/dist/esnext/foundation/Redirect/Redirect.client.js +14 -0
- package/dist/esnext/foundation/Route/Route.server.d.ts +12 -0
- package/dist/esnext/foundation/Route/Route.server.js +33 -0
- package/dist/esnext/foundation/Router/{Router.d.ts → BrowserRouter.client.d.ts} +3 -2
- package/dist/esnext/foundation/Router/{Router.js → BrowserRouter.client.js} +7 -5
- package/dist/esnext/foundation/Router/Router.server.d.ts +5 -3
- package/dist/esnext/foundation/Router/Router.server.js +7 -22
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +19 -24
- package/dist/esnext/foundation/ShopifyProvider/index.d.ts +0 -1
- package/dist/esnext/foundation/ShopifyProvider/index.js +0 -1
- package/dist/esnext/foundation/index.d.ts +0 -1
- package/dist/esnext/foundation/index.js +0 -1
- package/dist/esnext/{hooks → foundation}/useNavigate/useNavigate.d.ts +6 -3
- package/dist/esnext/{hooks → foundation}/useNavigate/useNavigate.js +4 -1
- package/dist/esnext/foundation/useQuery/hooks.d.ts +2 -4
- package/dist/esnext/foundation/useQuery/hooks.js +5 -2
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.d.ts +9 -0
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.js +7 -0
- package/dist/esnext/foundation/useRouteParams/useRouteParams.d.ts +4 -0
- package/dist/esnext/foundation/useRouteParams/useRouteParams.js +9 -0
- package/dist/esnext/foundation/useUrl/useUrl.js +1 -1
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +6 -0
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +5 -0
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +4 -1
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +5 -0
- package/dist/esnext/framework/middleware.js +25 -3
- package/dist/esnext/framework/plugin.js +6 -1
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.d.ts +2 -0
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +28 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +61 -75
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +1 -1
- package/dist/esnext/hooks/index.d.ts +0 -1
- package/dist/esnext/hooks/index.js +0 -1
- package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +10 -10
- package/dist/esnext/hooks/useCountry/useCountry.d.ts +4 -4
- package/dist/esnext/hooks/useMoney/hooks.d.ts +3 -3
- package/dist/esnext/hooks/useMoney/hooks.js +2 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +17 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +7 -3
- package/dist/esnext/hooks/useProduct/useProduct.d.ts +34 -96
- package/dist/esnext/hooks/useProductOptions/helpers.d.ts +6 -4
- package/dist/esnext/hooks/useProductOptions/helpers.js +13 -6
- package/dist/esnext/hooks/useProductOptions/types.d.ts +15 -35
- package/dist/esnext/hooks/useProductOptions/useProductOptions.d.ts +6 -5
- package/dist/esnext/hooks/useProductOptions/useProductOptions.js +13 -3
- package/dist/esnext/hooks/useShopQuery/hooks.js +47 -7
- package/dist/esnext/index.d.ts +7 -5
- package/dist/esnext/index.js +7 -5
- package/dist/esnext/platforms/worker-event.d.ts +0 -8
- package/dist/esnext/platforms/worker-event.js +2 -23
- package/dist/esnext/platforms/worker.d.ts +14 -0
- package/dist/esnext/platforms/worker.js +24 -0
- package/dist/esnext/{graphql/types/types.d.ts → storefront-api-types.d.ts} +389 -32
- package/dist/esnext/{graphql/types/types.js → storefront-api-types.js} +326 -30
- package/dist/esnext/streaming.server.d.ts +9 -5
- package/dist/esnext/streaming.server.js +2 -18
- package/dist/esnext/types.d.ts +1 -16
- package/dist/esnext/utilities/apiRoutes.d.ts +5 -1
- package/dist/esnext/utilities/apiRoutes.js +2 -3
- package/dist/esnext/utilities/devtools.d.ts +11 -0
- package/dist/esnext/utilities/devtools.js +11 -0
- package/dist/esnext/utilities/fetch.d.ts +7 -1
- package/dist/esnext/utilities/fetch.js +9 -10
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +3 -2
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +9 -2
- package/dist/esnext/utilities/graphql-tracker.d.ts +17 -0
- package/dist/esnext/utilities/graphql-tracker.js +119 -0
- package/dist/esnext/utilities/image_size.d.ts +5 -4
- package/dist/esnext/utilities/log/log-query-timeline.d.ts +1 -1
- package/dist/esnext/utilities/log/log-query-timeline.js +1 -2
- package/dist/esnext/utilities/log/log.d.ts +1 -0
- package/dist/esnext/utilities/log/utils.js +3 -0
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +3 -2
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/entry-server.js +104 -88
- package/dist/node/foundation/Redirect/Redirect.client.d.ts +5 -0
- package/dist/node/foundation/Redirect/Redirect.client.js +17 -0
- package/dist/node/foundation/Router/BrowserRouter.client.d.ts +13 -0
- package/dist/node/foundation/Router/BrowserRouter.client.js +77 -0
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +24 -25
- package/dist/node/foundation/ServerRequestProvider/index.js +5 -1
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.js +5 -1
- package/dist/node/foundation/ssr-interop.d.ts +29 -0
- package/dist/node/foundation/ssr-interop.js +39 -0
- package/dist/node/foundation/useNavigate/useNavigate.d.ts +13 -0
- package/dist/node/foundation/useNavigate/useNavigate.js +18 -0
- package/dist/node/foundation/useServerState/index.d.ts +1 -0
- package/dist/node/foundation/useServerState/index.js +5 -0
- package/dist/node/foundation/useServerState/use-server-state.d.ts +16 -0
- package/dist/node/foundation/useServerState/use-server-state.js +24 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +6 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.js +5 -0
- package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +4 -1
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +8 -0
- package/dist/node/framework/middleware.js +30 -4
- package/dist/node/framework/plugin.js +11 -2
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.d.ts +2 -0
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +31 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +61 -75
- package/dist/node/framework/plugins/vite-plugin-platform-entry.js +1 -1
- package/dist/node/{graphql/types/types.d.ts → storefront-api-types.d.ts} +389 -32
- package/dist/node/{graphql/types/types.js → storefront-api-types.js} +327 -31
- package/dist/node/streaming.server.d.ts +9 -5
- package/dist/node/streaming.server.js +2 -18
- package/dist/node/types.d.ts +1 -16
- package/dist/node/utilities/apiRoutes.d.ts +5 -1
- package/dist/node/utilities/apiRoutes.js +2 -3
- package/dist/node/utilities/fetch.d.ts +7 -1
- package/dist/node/utilities/fetch.js +9 -10
- package/dist/node/utilities/log/log-query-timeline.d.ts +1 -1
- package/dist/node/utilities/log/log-query-timeline.js +1 -2
- package/dist/node/utilities/log/log.d.ts +1 -0
- package/dist/node/utilities/log/utils.js +3 -0
- package/dist/node/utilities/web-api-polyfill.js +5 -1
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/package.json +9 -12
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +43 -104
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +1566 -848
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +36 -421
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +1523 -864
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +35 -437
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +507 -517
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +10 -246
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +16 -23
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +47 -108
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +1033 -306
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +965 -293
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +98 -108
- package/vendor/react-server-dom-vite/package.json +0 -2
- package/dist/esnext/components/ExternalVideo/ExternalVideoFragment.d.ts +0 -8
- package/dist/esnext/components/Image/ImageFragment.d.ts +0 -8
- package/dist/esnext/components/Image/ImageFragment.js +0 -1
- package/dist/esnext/components/MediaFile/MediaFileFragment.d.ts +0 -36
- package/dist/esnext/components/MediaFile/MediaFileFragment.js +0 -1
- package/dist/esnext/components/Metafield/MetafieldFragment.d.ts +0 -22
- package/dist/esnext/components/Metafield/MetafieldFragment.js +0 -1
- package/dist/esnext/components/ModelViewer/Model3DFragment.d.ts +0 -15
- package/dist/esnext/components/ModelViewer/Model3DFragment.js +0 -1
- package/dist/esnext/components/Money/MoneyFragment.d.ts +0 -8
- package/dist/esnext/components/Money/MoneyFragment.js +0 -1
- package/dist/esnext/components/ProductProvider/ProductProviderFragment.d.ts +0 -247
- package/dist/esnext/components/ProductProvider/ProductProviderFragment.js +0 -1
- package/dist/esnext/components/ProductProvider/types.d.ts +0 -19
- package/dist/esnext/components/ProductProvider/types.js +0 -1
- package/dist/esnext/components/RawHtml/RawHtml.d.ts +0 -17
- package/dist/esnext/components/RawHtml/RawHtml.js +0 -21
- package/dist/esnext/components/RawHtml/index.d.ts +0 -1
- package/dist/esnext/components/RawHtml/index.js +0 -1
- package/dist/esnext/components/Seo/SeoFragment.d.ts +0 -66
- package/dist/esnext/components/Seo/SeoFragment.js +0 -1
- package/dist/esnext/components/Seo/types.d.ts +0 -15
- package/dist/esnext/components/Seo/types.js +0 -1
- package/dist/esnext/components/UnitPrice/UnitPriceFragment.d.ts +0 -15
- package/dist/esnext/components/UnitPrice/UnitPriceFragment.js +0 -1
- package/dist/esnext/components/Video/VideoFragment.d.ts +0 -15
- package/dist/esnext/components/Video/VideoFragment.js +0 -1
- package/dist/esnext/foundation/Router/FileRoutes.d.ts +0 -18
- package/dist/esnext/foundation/Router/Route.server.d.ts +0 -9
- package/dist/esnext/foundation/Router/Route.server.js +0 -6
- package/dist/esnext/foundation/Router/useParams.d.ts +0 -1
- package/dist/esnext/foundation/Router/useParams.js +0 -5
- package/dist/esnext/fragments.d.ts +0 -20
- package/dist/esnext/fragments.js +0 -10
- package/dist/esnext/graphql/graphql-constants.d.ts +0 -1756
- package/dist/esnext/graphql/graphql-constants.js +0 -3447
- package/dist/esnext/hooks/useAvailableCountries/index.d.ts +0 -1
- package/dist/esnext/hooks/useAvailableCountries/index.js +0 -1
- package/dist/esnext/hooks/useAvailableCountries/useAvailableCountries.d.ts +0 -11
- package/dist/esnext/hooks/useAvailableCountries/useAvailableCountries.js +0 -17
- package/dist/esnext/hooks/useNavigate/index.d.ts +0 -1
- package/dist/esnext/hooks/useNavigate/index.js +0 -1
- package/dist/esnext/hooks/useProductOptions/SellingPlanFragment.d.ts +0 -31
- package/dist/esnext/hooks/useProductOptions/SellingPlanFragment.js +0 -1
- package/dist/esnext/hooks/useProductOptions/SellingPlanGroupsFragment.d.ts +0 -46
- package/dist/esnext/hooks/useProductOptions/SellingPlanGroupsFragment.js +0 -1
- package/dist/esnext/hooks/useProductOptions/VariantFragment.d.ts +0 -106
- package/dist/esnext/hooks/useProductOptions/VariantFragment.js +0 -1
- package/fragments.d.ts +0 -1
- package/fragments.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
2
|
+
* @license React
|
|
3
3
|
* react-server-dom-vite-writer.browser.server.js
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -8,20 +8,14 @@
|
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from 'react';
|
|
11
|
+
import { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, createServerContext } from 'react';
|
|
12
12
|
|
|
13
13
|
var ReactSharedInternals = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
14
14
|
|
|
15
15
|
function error(format) {
|
|
16
16
|
{
|
|
17
17
|
{
|
|
18
|
-
for (
|
|
19
|
-
var _len2 = arguments.length,
|
|
20
|
-
args = new Array(_len2 > 1 ? _len2 - 1 : 0),
|
|
21
|
-
_key2 = 1;
|
|
22
|
-
_key2 < _len2;
|
|
23
|
-
_key2++
|
|
24
|
-
) {
|
|
18
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
25
19
|
args[_key2 - 1] = arguments[_key2];
|
|
26
20
|
}
|
|
27
21
|
|
|
@@ -42,6 +36,7 @@ function printWarning(level, format, args) {
|
|
|
42
36
|
args = args.concat([stack]);
|
|
43
37
|
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
44
38
|
|
|
39
|
+
|
|
45
40
|
var argsWithFormat = args.map(function (item) {
|
|
46
41
|
return String(item);
|
|
47
42
|
}); // Careful: RN currently depends on this prefix
|
|
@@ -57,9 +52,68 @@ function printWarning(level, format, args) {
|
|
|
57
52
|
function scheduleWork(callback) {
|
|
58
53
|
callback();
|
|
59
54
|
}
|
|
55
|
+
var VIEW_SIZE = 512;
|
|
56
|
+
var currentView = null;
|
|
57
|
+
var writtenBytes = 0;
|
|
58
|
+
function beginWriting(destination) {
|
|
59
|
+
currentView = new Uint8Array(VIEW_SIZE);
|
|
60
|
+
writtenBytes = 0;
|
|
61
|
+
}
|
|
60
62
|
function writeChunk(destination, chunk) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
if (chunk.length === 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (chunk.length > VIEW_SIZE) {
|
|
68
|
+
// this chunk may overflow a single view which implies it was not
|
|
69
|
+
// one that is cached by the streaming renderer. We will enqueu
|
|
70
|
+
// it directly and expect it is not re-used
|
|
71
|
+
if (writtenBytes > 0) {
|
|
72
|
+
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
|
|
73
|
+
currentView = new Uint8Array(VIEW_SIZE);
|
|
74
|
+
writtenBytes = 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
destination.enqueue(chunk);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var bytesToWrite = chunk;
|
|
82
|
+
var allowableBytes = currentView.length - writtenBytes;
|
|
83
|
+
|
|
84
|
+
if (allowableBytes < bytesToWrite.length) {
|
|
85
|
+
// this chunk would overflow the current view. We enqueue a full view
|
|
86
|
+
// and start a new view with the remaining chunk
|
|
87
|
+
if (allowableBytes === 0) {
|
|
88
|
+
// the current view is already full, send it
|
|
89
|
+
destination.enqueue(currentView);
|
|
90
|
+
} else {
|
|
91
|
+
// fill up the current view and apply the remaining chunk bytes
|
|
92
|
+
// to a new view.
|
|
93
|
+
currentView.set(bytesToWrite.subarray(0, allowableBytes), writtenBytes); // writtenBytes += allowableBytes; // this can be skipped because we are going to immediately reset the view
|
|
94
|
+
|
|
95
|
+
destination.enqueue(currentView);
|
|
96
|
+
bytesToWrite = bytesToWrite.subarray(allowableBytes);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
currentView = new Uint8Array(VIEW_SIZE);
|
|
100
|
+
writtenBytes = 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
currentView.set(bytesToWrite, writtenBytes);
|
|
104
|
+
writtenBytes += bytesToWrite.length;
|
|
105
|
+
}
|
|
106
|
+
function writeChunkAndReturn(destination, chunk) {
|
|
107
|
+
writeChunk(destination, chunk); // in web streams there is no backpressure so we can alwas write more
|
|
108
|
+
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
function completeWriting(destination) {
|
|
112
|
+
if (currentView && writtenBytes > 0) {
|
|
113
|
+
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
|
|
114
|
+
currentView = null;
|
|
115
|
+
writtenBytes = 0;
|
|
116
|
+
}
|
|
63
117
|
}
|
|
64
118
|
function close(destination) {
|
|
65
119
|
destination.close();
|
|
@@ -68,6 +122,9 @@ var textEncoder = new TextEncoder();
|
|
|
68
122
|
function stringToChunk(content) {
|
|
69
123
|
return textEncoder.encode(content);
|
|
70
124
|
}
|
|
125
|
+
function stringToPrecomputedChunk(content) {
|
|
126
|
+
return textEncoder.encode(content);
|
|
127
|
+
}
|
|
71
128
|
function closeWithError(destination, error) {
|
|
72
129
|
if (typeof destination.error === 'function') {
|
|
73
130
|
// $FlowFixMe: This is an Error object or the destination accepts other types.
|
|
@@ -93,7 +150,7 @@ function serializeRowHeader(tag, id) {
|
|
|
93
150
|
function processErrorChunk(request, id, message, stack) {
|
|
94
151
|
var errorInfo = {
|
|
95
152
|
message: message,
|
|
96
|
-
stack: stack
|
|
153
|
+
stack: stack
|
|
97
154
|
};
|
|
98
155
|
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
|
99
156
|
return stringToChunk(row);
|
|
@@ -108,6 +165,10 @@ function processModuleChunk(request, id, moduleMetaData) {
|
|
|
108
165
|
var row = serializeRowHeader('M', id) + json + '\n';
|
|
109
166
|
return stringToChunk(row);
|
|
110
167
|
}
|
|
168
|
+
function processProviderChunk(request, id, contextName) {
|
|
169
|
+
var row = serializeRowHeader('P', id) + contextName + '\n';
|
|
170
|
+
return stringToChunk(row);
|
|
171
|
+
}
|
|
111
172
|
function processSymbolChunk(request, id, name) {
|
|
112
173
|
var json = stringify(name);
|
|
113
174
|
var row = serializeRowHeader('S', id) + json + '\n';
|
|
@@ -125,53 +186,308 @@ function isModuleReference(reference) {
|
|
|
125
186
|
function resolveModuleMetaData(config, moduleReference) {
|
|
126
187
|
return {
|
|
127
188
|
id: moduleReference.filepath,
|
|
128
|
-
name: moduleReference.name
|
|
189
|
+
name: moduleReference.name
|
|
129
190
|
};
|
|
130
191
|
}
|
|
131
192
|
|
|
132
193
|
// ATTENTION
|
|
133
194
|
// When adding new symbols to this file,
|
|
134
195
|
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
135
|
-
// The Symbol used to tag the ReactElement-like types.
|
|
136
|
-
|
|
137
|
-
var
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
196
|
+
// The Symbol used to tag the ReactElement-like types.
|
|
197
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
198
|
+
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
199
|
+
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
200
|
+
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
|
201
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
202
|
+
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
|
203
|
+
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
204
|
+
var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
|
|
205
|
+
|
|
206
|
+
// A reserved attribute.
|
|
207
|
+
// It is handled by React separately and shouldn't be written to the DOM.
|
|
208
|
+
var RESERVED = 0; // A simple string attribute.
|
|
209
|
+
// Attributes that aren't in the filter are presumed to have this type.
|
|
210
|
+
|
|
211
|
+
var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
|
|
212
|
+
// "enumerated" attributes with "true" and "false" as possible values.
|
|
213
|
+
// When true, it should be set to a "true" string.
|
|
214
|
+
// When false, it should be set to a "false" string.
|
|
215
|
+
|
|
216
|
+
var BOOLEANISH_STRING = 2; // A real boolean attribute.
|
|
217
|
+
// When true, it should be present (set either to an empty string or its name).
|
|
218
|
+
// When false, it should be omitted.
|
|
219
|
+
|
|
220
|
+
var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
|
|
221
|
+
// When true, it should be present (set either to an empty string or its name).
|
|
222
|
+
// When false, it should be omitted.
|
|
223
|
+
// For any other value, should be present with that value.
|
|
224
|
+
|
|
225
|
+
var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
|
|
226
|
+
// When falsy, it should be removed.
|
|
227
|
+
|
|
228
|
+
var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
|
|
229
|
+
// When falsy, it should be removed.
|
|
230
|
+
|
|
231
|
+
var POSITIVE_NUMERIC = 6;
|
|
232
|
+
|
|
233
|
+
function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
|
|
234
|
+
this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
|
|
235
|
+
this.attributeName = attributeName;
|
|
236
|
+
this.attributeNamespace = attributeNamespace;
|
|
237
|
+
this.mustUseProperty = mustUseProperty;
|
|
238
|
+
this.propertyName = name;
|
|
239
|
+
this.type = type;
|
|
240
|
+
this.sanitizeURL = sanitizeURL;
|
|
241
|
+
this.removeEmptyString = removeEmptyString;
|
|
242
|
+
} // When adding attributes to this list, be sure to also add them to
|
|
243
|
+
// the `possibleStandardNames` module to ensure casing and incorrect
|
|
244
|
+
// name warnings.
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
|
|
248
|
+
|
|
249
|
+
var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
|
|
250
|
+
// elements (not just inputs). Now that ReactDOMInput assigns to the
|
|
251
|
+
// defaultValue property -- do we need this?
|
|
252
|
+
'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'];
|
|
253
|
+
|
|
254
|
+
{
|
|
255
|
+
reservedProps.push('innerText', 'textContent');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
reservedProps.forEach(function (name) {
|
|
259
|
+
properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
|
|
260
|
+
name, // attributeName
|
|
261
|
+
null, // attributeNamespace
|
|
262
|
+
false, // sanitizeURL
|
|
263
|
+
false);
|
|
264
|
+
}); // A few React string attributes have a different name.
|
|
265
|
+
// This is a mapping from React prop names to the attribute names.
|
|
266
|
+
|
|
267
|
+
[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
|
|
268
|
+
var name = _ref[0],
|
|
269
|
+
attributeName = _ref[1];
|
|
270
|
+
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
271
|
+
attributeName, // attributeName
|
|
272
|
+
null, // attributeNamespace
|
|
273
|
+
false, // sanitizeURL
|
|
274
|
+
false);
|
|
275
|
+
}); // These are "enumerated" HTML attributes that accept "true" and "false".
|
|
276
|
+
// In React, we let users pass `true` and `false` even though technically
|
|
277
|
+
// these aren't boolean attributes (they are coerced to strings).
|
|
278
|
+
|
|
279
|
+
['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
|
|
280
|
+
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
|
|
281
|
+
name.toLowerCase(), // attributeName
|
|
282
|
+
null, // attributeNamespace
|
|
283
|
+
false, // sanitizeURL
|
|
284
|
+
false);
|
|
285
|
+
}); // These are "enumerated" SVG attributes that accept "true" and "false".
|
|
286
|
+
// In React, we let users pass `true` and `false` even though technically
|
|
287
|
+
// these aren't boolean attributes (they are coerced to strings).
|
|
288
|
+
// Since these are SVG attributes, their attribute names are case-sensitive.
|
|
289
|
+
|
|
290
|
+
['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
|
|
291
|
+
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
|
|
292
|
+
name, // attributeName
|
|
293
|
+
null, // attributeNamespace
|
|
294
|
+
false, // sanitizeURL
|
|
295
|
+
false);
|
|
296
|
+
}); // These are HTML boolean attributes.
|
|
297
|
+
|
|
298
|
+
['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
|
|
299
|
+
// on the client side because the browsers are inconsistent. Instead we call focus().
|
|
300
|
+
'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
|
|
301
|
+
'itemScope'].forEach(function (name) {
|
|
302
|
+
properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
|
|
303
|
+
name.toLowerCase(), // attributeName
|
|
304
|
+
null, // attributeNamespace
|
|
305
|
+
false, // sanitizeURL
|
|
306
|
+
false);
|
|
307
|
+
}); // These are the few React props that we set as DOM properties
|
|
308
|
+
// rather than attributes. These are all booleans.
|
|
309
|
+
|
|
310
|
+
['checked', // Note: `option.selected` is not updated if `select.multiple` is
|
|
311
|
+
// disabled with `removeAttribute`. We have special logic for handling this.
|
|
312
|
+
'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list,
|
|
313
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
314
|
+
// instead in the assignment below.
|
|
315
|
+
].forEach(function (name) {
|
|
316
|
+
properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
|
|
317
|
+
name, // attributeName
|
|
318
|
+
null, // attributeNamespace
|
|
319
|
+
false, // sanitizeURL
|
|
320
|
+
false);
|
|
321
|
+
}); // These are HTML attributes that are "overloaded booleans": they behave like
|
|
322
|
+
// booleans, but can also accept a string value.
|
|
323
|
+
|
|
324
|
+
['capture', 'download' // NOTE: if you add a camelCased prop to this list,
|
|
325
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
326
|
+
// instead in the assignment below.
|
|
327
|
+
].forEach(function (name) {
|
|
328
|
+
properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
|
|
329
|
+
name, // attributeName
|
|
330
|
+
null, // attributeNamespace
|
|
331
|
+
false, // sanitizeURL
|
|
332
|
+
false);
|
|
333
|
+
}); // These are HTML attributes that must be positive numbers.
|
|
334
|
+
|
|
335
|
+
['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list,
|
|
336
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
337
|
+
// instead in the assignment below.
|
|
338
|
+
].forEach(function (name) {
|
|
339
|
+
properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
|
|
340
|
+
name, // attributeName
|
|
341
|
+
null, // attributeNamespace
|
|
342
|
+
false, // sanitizeURL
|
|
343
|
+
false);
|
|
344
|
+
}); // These are HTML attributes that must be numbers.
|
|
345
|
+
|
|
346
|
+
['rowSpan', 'start'].forEach(function (name) {
|
|
347
|
+
properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
|
|
348
|
+
name.toLowerCase(), // attributeName
|
|
349
|
+
null, // attributeNamespace
|
|
350
|
+
false, // sanitizeURL
|
|
351
|
+
false);
|
|
352
|
+
});
|
|
353
|
+
var CAMELIZE = /[\-\:]([a-z])/g;
|
|
354
|
+
|
|
355
|
+
var capitalize = function (token) {
|
|
356
|
+
return token[1].toUpperCase();
|
|
357
|
+
}; // This is a list of all SVG attributes that need special casing, namespacing,
|
|
358
|
+
// or boolean value assignment. Regular attributes that just accept strings
|
|
359
|
+
// and have the same names are omitted, just like in the HTML attribute filter.
|
|
360
|
+
// Some of these attributes can be hard to find. This list was created by
|
|
361
|
+
// scraping the MDN documentation.
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list,
|
|
365
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
366
|
+
// instead in the assignment below.
|
|
367
|
+
].forEach(function (attributeName) {
|
|
368
|
+
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
369
|
+
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
370
|
+
attributeName, null, // attributeNamespace
|
|
371
|
+
false, // sanitizeURL
|
|
372
|
+
false);
|
|
373
|
+
}); // String SVG attributes with the xlink namespace.
|
|
374
|
+
|
|
375
|
+
['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list,
|
|
376
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
377
|
+
// instead in the assignment below.
|
|
378
|
+
].forEach(function (attributeName) {
|
|
379
|
+
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
380
|
+
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
381
|
+
attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL
|
|
382
|
+
false);
|
|
383
|
+
}); // String SVG attributes with the xml namespace.
|
|
384
|
+
|
|
385
|
+
['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list,
|
|
386
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
387
|
+
// instead in the assignment below.
|
|
388
|
+
].forEach(function (attributeName) {
|
|
389
|
+
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
390
|
+
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
391
|
+
attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL
|
|
392
|
+
false);
|
|
393
|
+
}); // These attribute exists both in HTML and SVG.
|
|
394
|
+
// The attribute name is case-sensitive in SVG so we can't just use
|
|
395
|
+
// the React name like we do for attributes that exist only in HTML.
|
|
396
|
+
|
|
397
|
+
['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
|
|
398
|
+
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
|
|
399
|
+
attributeName.toLowerCase(), // attributeName
|
|
400
|
+
null, // attributeNamespace
|
|
401
|
+
false, // sanitizeURL
|
|
402
|
+
false);
|
|
403
|
+
}); // These attributes accept URLs. These must not allow javascript: URLS.
|
|
404
|
+
// These will also need to accept Trusted Types object in the future.
|
|
405
|
+
|
|
406
|
+
var xlinkHref = 'xlinkHref';
|
|
407
|
+
properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
|
|
408
|
+
'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL
|
|
409
|
+
false);
|
|
410
|
+
['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
|
|
411
|
+
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
|
|
412
|
+
attributeName.toLowerCase(), // attributeName
|
|
413
|
+
null, // attributeNamespace
|
|
414
|
+
true, // sanitizeURL
|
|
415
|
+
true);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* CSS properties which accept numbers but are not in units of "px".
|
|
420
|
+
*/
|
|
421
|
+
var isUnitlessNumber = {
|
|
422
|
+
animationIterationCount: true,
|
|
423
|
+
aspectRatio: true,
|
|
424
|
+
borderImageOutset: true,
|
|
425
|
+
borderImageSlice: true,
|
|
426
|
+
borderImageWidth: true,
|
|
427
|
+
boxFlex: true,
|
|
428
|
+
boxFlexGroup: true,
|
|
429
|
+
boxOrdinalGroup: true,
|
|
430
|
+
columnCount: true,
|
|
431
|
+
columns: true,
|
|
432
|
+
flex: true,
|
|
433
|
+
flexGrow: true,
|
|
434
|
+
flexPositive: true,
|
|
435
|
+
flexShrink: true,
|
|
436
|
+
flexNegative: true,
|
|
437
|
+
flexOrder: true,
|
|
438
|
+
gridArea: true,
|
|
439
|
+
gridRow: true,
|
|
440
|
+
gridRowEnd: true,
|
|
441
|
+
gridRowSpan: true,
|
|
442
|
+
gridRowStart: true,
|
|
443
|
+
gridColumn: true,
|
|
444
|
+
gridColumnEnd: true,
|
|
445
|
+
gridColumnSpan: true,
|
|
446
|
+
gridColumnStart: true,
|
|
447
|
+
fontWeight: true,
|
|
448
|
+
lineClamp: true,
|
|
449
|
+
lineHeight: true,
|
|
450
|
+
opacity: true,
|
|
451
|
+
order: true,
|
|
452
|
+
orphans: true,
|
|
453
|
+
tabSize: true,
|
|
454
|
+
widows: true,
|
|
455
|
+
zIndex: true,
|
|
456
|
+
zoom: true,
|
|
457
|
+
// SVG-related properties
|
|
458
|
+
fillOpacity: true,
|
|
459
|
+
floodOpacity: true,
|
|
460
|
+
stopOpacity: true,
|
|
461
|
+
strokeDasharray: true,
|
|
462
|
+
strokeDashoffset: true,
|
|
463
|
+
strokeMiterlimit: true,
|
|
464
|
+
strokeOpacity: true,
|
|
465
|
+
strokeWidth: true
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
|
469
|
+
* @param {string} key style name, eg: transitionDuration
|
|
470
|
+
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
|
471
|
+
* WebkitTransitionDuration
|
|
472
|
+
*/
|
|
473
|
+
|
|
474
|
+
function prefixKey(prefix, key) {
|
|
475
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
174
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Support style names that may come passed in prefixed by adding permutations
|
|
479
|
+
* of vendor prefixes.
|
|
480
|
+
*/
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
|
|
484
|
+
// infinite loop, because it iterates over the newly added props too.
|
|
485
|
+
|
|
486
|
+
Object.keys(isUnitlessNumber).forEach(function (prop) {
|
|
487
|
+
prefixes.forEach(function (prefix) {
|
|
488
|
+
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
|
489
|
+
});
|
|
490
|
+
});
|
|
175
491
|
|
|
176
492
|
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
|
177
493
|
|
|
@@ -179,6 +495,456 @@ function isArray(a) {
|
|
|
179
495
|
return isArrayImpl(a);
|
|
180
496
|
}
|
|
181
497
|
|
|
498
|
+
var startInlineScript = stringToPrecomputedChunk('<script>');
|
|
499
|
+
var endInlineScript = stringToPrecomputedChunk('</script>');
|
|
500
|
+
var startScriptSrc = stringToPrecomputedChunk('<script src="');
|
|
501
|
+
var startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
|
|
502
|
+
var endAsyncScript = stringToPrecomputedChunk('" async=""></script>'); // Allows us to keep track of what we've already written so we can refer back to it.
|
|
503
|
+
|
|
504
|
+
var textSeparator = stringToPrecomputedChunk('<!-- -->');
|
|
505
|
+
|
|
506
|
+
var styleAttributeStart = stringToPrecomputedChunk(' style="');
|
|
507
|
+
var styleAssign = stringToPrecomputedChunk(':');
|
|
508
|
+
var styleSeparator = stringToPrecomputedChunk(';');
|
|
509
|
+
|
|
510
|
+
var attributeSeparator = stringToPrecomputedChunk(' ');
|
|
511
|
+
var attributeAssign = stringToPrecomputedChunk('="');
|
|
512
|
+
var attributeEnd = stringToPrecomputedChunk('"');
|
|
513
|
+
var attributeEmptyString = stringToPrecomputedChunk('=""');
|
|
514
|
+
|
|
515
|
+
var endOfStartTag = stringToPrecomputedChunk('>');
|
|
516
|
+
var endOfStartTagSelfClosing = stringToPrecomputedChunk('/>');
|
|
517
|
+
|
|
518
|
+
var selectedMarkerAttribute = stringToPrecomputedChunk(' selected=""');
|
|
519
|
+
|
|
520
|
+
var leadingNewline = stringToPrecomputedChunk('\n');
|
|
521
|
+
|
|
522
|
+
var DOCTYPE = stringToPrecomputedChunk('<!DOCTYPE html>');
|
|
523
|
+
var endTag1 = stringToPrecomputedChunk('</');
|
|
524
|
+
var endTag2 = stringToPrecomputedChunk('>');
|
|
525
|
+
// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
|
|
526
|
+
// display. It's never visible to users. We use the template tag because it can be used in every
|
|
527
|
+
// type of parent. <script> tags also work in every other tag except <colgroup>.
|
|
528
|
+
|
|
529
|
+
var placeholder1 = stringToPrecomputedChunk('<template id="');
|
|
530
|
+
var placeholder2 = stringToPrecomputedChunk('"></template>');
|
|
531
|
+
|
|
532
|
+
var startCompletedSuspenseBoundary = stringToPrecomputedChunk('<!--$-->');
|
|
533
|
+
var startPendingSuspenseBoundary1 = stringToPrecomputedChunk('<!--$?--><template id="');
|
|
534
|
+
var startPendingSuspenseBoundary2 = stringToPrecomputedChunk('"></template>');
|
|
535
|
+
var startClientRenderedSuspenseBoundary = stringToPrecomputedChunk('<!--$!-->');
|
|
536
|
+
var endSuspenseBoundary = stringToPrecomputedChunk('<!--/$-->');
|
|
537
|
+
var startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
|
|
538
|
+
var startSegmentHTML2 = stringToPrecomputedChunk('">');
|
|
539
|
+
var endSegmentHTML = stringToPrecomputedChunk('</div>');
|
|
540
|
+
var startSegmentSVG = stringToPrecomputedChunk('<svg aria-hidden="true" style="display:none" id="');
|
|
541
|
+
var startSegmentSVG2 = stringToPrecomputedChunk('">');
|
|
542
|
+
var endSegmentSVG = stringToPrecomputedChunk('</svg>');
|
|
543
|
+
var startSegmentMathML = stringToPrecomputedChunk('<math aria-hidden="true" style="display:none" id="');
|
|
544
|
+
var startSegmentMathML2 = stringToPrecomputedChunk('">');
|
|
545
|
+
var endSegmentMathML = stringToPrecomputedChunk('</math>');
|
|
546
|
+
var startSegmentTable = stringToPrecomputedChunk('<table hidden id="');
|
|
547
|
+
var startSegmentTable2 = stringToPrecomputedChunk('">');
|
|
548
|
+
var endSegmentTable = stringToPrecomputedChunk('</table>');
|
|
549
|
+
var startSegmentTableBody = stringToPrecomputedChunk('<table hidden><tbody id="');
|
|
550
|
+
var startSegmentTableBody2 = stringToPrecomputedChunk('">');
|
|
551
|
+
var endSegmentTableBody = stringToPrecomputedChunk('</tbody></table>');
|
|
552
|
+
var startSegmentTableRow = stringToPrecomputedChunk('<table hidden><tr id="');
|
|
553
|
+
var startSegmentTableRow2 = stringToPrecomputedChunk('">');
|
|
554
|
+
var endSegmentTableRow = stringToPrecomputedChunk('</tr></table>');
|
|
555
|
+
var startSegmentColGroup = stringToPrecomputedChunk('<table hidden><colgroup id="');
|
|
556
|
+
var startSegmentColGroup2 = stringToPrecomputedChunk('">');
|
|
557
|
+
var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
|
|
558
|
+
// The following code is the source scripts that we then minify and inline below,
|
|
559
|
+
// with renamed function names that we hope don't collide:
|
|
560
|
+
// const COMMENT_NODE = 8;
|
|
561
|
+
// const SUSPENSE_START_DATA = '$';
|
|
562
|
+
// const SUSPENSE_END_DATA = '/$';
|
|
563
|
+
// const SUSPENSE_PENDING_START_DATA = '$?';
|
|
564
|
+
// const SUSPENSE_FALLBACK_START_DATA = '$!';
|
|
565
|
+
//
|
|
566
|
+
// function clientRenderBoundary(suspenseBoundaryID) {
|
|
567
|
+
// // Find the fallback's first element.
|
|
568
|
+
// const suspenseIdNode = document.getElementById(suspenseBoundaryID);
|
|
569
|
+
// if (!suspenseIdNode) {
|
|
570
|
+
// // The user must have already navigated away from this tree.
|
|
571
|
+
// // E.g. because the parent was hydrated.
|
|
572
|
+
// return;
|
|
573
|
+
// }
|
|
574
|
+
// // Find the boundary around the fallback. This is always the previous node.
|
|
575
|
+
// const suspenseNode = suspenseIdNode.previousSibling;
|
|
576
|
+
// // Tag it to be client rendered.
|
|
577
|
+
// suspenseNode.data = SUSPENSE_FALLBACK_START_DATA;
|
|
578
|
+
// // Tell React to retry it if the parent already hydrated.
|
|
579
|
+
// if (suspenseNode._reactRetry) {
|
|
580
|
+
// suspenseNode._reactRetry();
|
|
581
|
+
// }
|
|
582
|
+
// }
|
|
583
|
+
//
|
|
584
|
+
// function completeBoundary(suspenseBoundaryID, contentID) {
|
|
585
|
+
// // Find the fallback's first element.
|
|
586
|
+
// const suspenseIdNode = document.getElementById(suspenseBoundaryID);
|
|
587
|
+
// const contentNode = document.getElementById(contentID);
|
|
588
|
+
// // We'll detach the content node so that regardless of what happens next we don't leave in the tree.
|
|
589
|
+
// // This might also help by not causing recalcing each time we move a child from here to the target.
|
|
590
|
+
// contentNode.parentNode.removeChild(contentNode);
|
|
591
|
+
// if (!suspenseIdNode) {
|
|
592
|
+
// // The user must have already navigated away from this tree.
|
|
593
|
+
// // E.g. because the parent was hydrated. That's fine there's nothing to do
|
|
594
|
+
// // but we have to make sure that we already deleted the container node.
|
|
595
|
+
// return;
|
|
596
|
+
// }
|
|
597
|
+
// // Find the boundary around the fallback. This is always the previous node.
|
|
598
|
+
// const suspenseNode = suspenseIdNode.previousSibling;
|
|
599
|
+
//
|
|
600
|
+
// // Clear all the existing children. This is complicated because
|
|
601
|
+
// // there can be embedded Suspense boundaries in the fallback.
|
|
602
|
+
// // This is similar to clearSuspenseBoundary in ReactDOMHostConfig.
|
|
603
|
+
// // TODO: We could avoid this if we never emitted suspense boundaries in fallback trees.
|
|
604
|
+
// // They never hydrate anyway. However, currently we support incrementally loading the fallback.
|
|
605
|
+
// const parentInstance = suspenseNode.parentNode;
|
|
606
|
+
// let node = suspenseNode.nextSibling;
|
|
607
|
+
// let depth = 0;
|
|
608
|
+
// do {
|
|
609
|
+
// if (node && node.nodeType === COMMENT_NODE) {
|
|
610
|
+
// const data = node.data;
|
|
611
|
+
// if (data === SUSPENSE_END_DATA) {
|
|
612
|
+
// if (depth === 0) {
|
|
613
|
+
// break;
|
|
614
|
+
// } else {
|
|
615
|
+
// depth--;
|
|
616
|
+
// }
|
|
617
|
+
// } else if (
|
|
618
|
+
// data === SUSPENSE_START_DATA ||
|
|
619
|
+
// data === SUSPENSE_PENDING_START_DATA ||
|
|
620
|
+
// data === SUSPENSE_FALLBACK_START_DATA
|
|
621
|
+
// ) {
|
|
622
|
+
// depth++;
|
|
623
|
+
// }
|
|
624
|
+
// }
|
|
625
|
+
//
|
|
626
|
+
// const nextNode = node.nextSibling;
|
|
627
|
+
// parentInstance.removeChild(node);
|
|
628
|
+
// node = nextNode;
|
|
629
|
+
// } while (node);
|
|
630
|
+
//
|
|
631
|
+
// const endOfBoundary = node;
|
|
632
|
+
//
|
|
633
|
+
// // Insert all the children from the contentNode between the start and end of suspense boundary.
|
|
634
|
+
// while (contentNode.firstChild) {
|
|
635
|
+
// parentInstance.insertBefore(contentNode.firstChild, endOfBoundary);
|
|
636
|
+
// }
|
|
637
|
+
// suspenseNode.data = SUSPENSE_START_DATA;
|
|
638
|
+
// if (suspenseNode._reactRetry) {
|
|
639
|
+
// suspenseNode._reactRetry();
|
|
640
|
+
// }
|
|
641
|
+
// }
|
|
642
|
+
//
|
|
643
|
+
// function completeSegment(containerID, placeholderID) {
|
|
644
|
+
// const segmentContainer = document.getElementById(containerID);
|
|
645
|
+
// const placeholderNode = document.getElementById(placeholderID);
|
|
646
|
+
// // We always expect both nodes to exist here because, while we might
|
|
647
|
+
// // have navigated away from the main tree, we still expect the detached
|
|
648
|
+
// // tree to exist.
|
|
649
|
+
// segmentContainer.parentNode.removeChild(segmentContainer);
|
|
650
|
+
// while (segmentContainer.firstChild) {
|
|
651
|
+
// placeholderNode.parentNode.insertBefore(
|
|
652
|
+
// segmentContainer.firstChild,
|
|
653
|
+
// placeholderNode,
|
|
654
|
+
// );
|
|
655
|
+
// }
|
|
656
|
+
// placeholderNode.parentNode.removeChild(placeholderNode);
|
|
657
|
+
// }
|
|
658
|
+
|
|
659
|
+
var completeSegmentFunction = 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)}';
|
|
660
|
+
var completeBoundaryFunction = 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}}';
|
|
661
|
+
var clientRenderFunction = 'function $RX(a){if(a=document.getElementById(a))a=a.previousSibling,a.data="$!",a._reactRetry&&a._reactRetry()}';
|
|
662
|
+
var completeSegmentScript1Full = stringToPrecomputedChunk(completeSegmentFunction + ';$RS("');
|
|
663
|
+
var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
|
|
664
|
+
var completeSegmentScript2 = stringToPrecomputedChunk('","');
|
|
665
|
+
var completeSegmentScript3 = stringToPrecomputedChunk('")</script>');
|
|
666
|
+
var completeBoundaryScript1Full = stringToPrecomputedChunk(completeBoundaryFunction + ';$RC("');
|
|
667
|
+
var completeBoundaryScript1Partial = stringToPrecomputedChunk('$RC("');
|
|
668
|
+
var completeBoundaryScript2 = stringToPrecomputedChunk('","');
|
|
669
|
+
var completeBoundaryScript3 = stringToPrecomputedChunk('")</script>');
|
|
670
|
+
var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderFunction + ';$RX("');
|
|
671
|
+
var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("');
|
|
672
|
+
var clientRenderScript2 = stringToPrecomputedChunk('")</script>');
|
|
673
|
+
|
|
674
|
+
var rendererSigil;
|
|
675
|
+
|
|
676
|
+
{
|
|
677
|
+
// Use this to detect multiple renderers using the same context
|
|
678
|
+
rendererSigil = {};
|
|
679
|
+
} // Used to store the parent path of all context overrides in a shared linked list.
|
|
680
|
+
// Forming a reverse tree.
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
|
|
684
|
+
// This global (actually thread local) state represents what state all those "current",
|
|
685
|
+
// fields are currently in.
|
|
686
|
+
|
|
687
|
+
var currentActiveSnapshot = null;
|
|
688
|
+
|
|
689
|
+
function popNode(prev) {
|
|
690
|
+
{
|
|
691
|
+
prev.context._currentValue = prev.parentValue;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function pushNode(next) {
|
|
696
|
+
{
|
|
697
|
+
next.context._currentValue = next.value;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
function popToNearestCommonAncestor(prev, next) {
|
|
702
|
+
if (prev === next) ; else {
|
|
703
|
+
popNode(prev);
|
|
704
|
+
var parentPrev = prev.parent;
|
|
705
|
+
var parentNext = next.parent;
|
|
706
|
+
|
|
707
|
+
if (parentPrev === null) {
|
|
708
|
+
if (parentNext !== null) {
|
|
709
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
|
710
|
+
}
|
|
711
|
+
} else {
|
|
712
|
+
if (parentNext === null) {
|
|
713
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
popToNearestCommonAncestor(parentPrev, parentNext); // On the way back, we push the new ones that weren't common.
|
|
717
|
+
|
|
718
|
+
pushNode(next);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function popAllPrevious(prev) {
|
|
724
|
+
popNode(prev);
|
|
725
|
+
var parentPrev = prev.parent;
|
|
726
|
+
|
|
727
|
+
if (parentPrev !== null) {
|
|
728
|
+
popAllPrevious(parentPrev);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
function pushAllNext(next) {
|
|
733
|
+
var parentNext = next.parent;
|
|
734
|
+
|
|
735
|
+
if (parentNext !== null) {
|
|
736
|
+
pushAllNext(parentNext);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
pushNode(next);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function popPreviousToCommonLevel(prev, next) {
|
|
743
|
+
popNode(prev);
|
|
744
|
+
var parentPrev = prev.parent;
|
|
745
|
+
|
|
746
|
+
if (parentPrev === null) {
|
|
747
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
if (parentPrev.depth === next.depth) {
|
|
751
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
|
752
|
+
popToNearestCommonAncestor(parentPrev, next);
|
|
753
|
+
} else {
|
|
754
|
+
// We must still be deeper.
|
|
755
|
+
popPreviousToCommonLevel(parentPrev, next);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function popNextToCommonLevel(prev, next) {
|
|
760
|
+
var parentNext = next.parent;
|
|
761
|
+
|
|
762
|
+
if (parentNext === null) {
|
|
763
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (prev.depth === parentNext.depth) {
|
|
767
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
|
768
|
+
popToNearestCommonAncestor(prev, parentNext);
|
|
769
|
+
} else {
|
|
770
|
+
// We must still be deeper.
|
|
771
|
+
popNextToCommonLevel(prev, parentNext);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
pushNode(next);
|
|
775
|
+
} // Perform context switching to the new snapshot.
|
|
776
|
+
// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
|
|
777
|
+
// updating all the context's current values. That way reads, always just read the current value.
|
|
778
|
+
// At the cost of updating contexts even if they're never read by this subtree.
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
function switchContext(newSnapshot) {
|
|
782
|
+
// The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
|
|
783
|
+
// We also need to update any new contexts that are now on the stack with the deepest value.
|
|
784
|
+
// The easiest way to update new contexts is to just reapply them in reverse order from the
|
|
785
|
+
// perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
|
|
786
|
+
// for that. Therefore this algorithm is recursive.
|
|
787
|
+
// 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
|
|
788
|
+
// 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
|
|
789
|
+
// 3) Then we reapply new contexts on the way back up the stack.
|
|
790
|
+
var prev = currentActiveSnapshot;
|
|
791
|
+
var next = newSnapshot;
|
|
792
|
+
|
|
793
|
+
if (prev !== next) {
|
|
794
|
+
if (prev === null) {
|
|
795
|
+
// $FlowFixMe: This has to be non-null since it's not equal to prev.
|
|
796
|
+
pushAllNext(next);
|
|
797
|
+
} else if (next === null) {
|
|
798
|
+
popAllPrevious(prev);
|
|
799
|
+
} else if (prev.depth === next.depth) {
|
|
800
|
+
popToNearestCommonAncestor(prev, next);
|
|
801
|
+
} else if (prev.depth > next.depth) {
|
|
802
|
+
popPreviousToCommonLevel(prev, next);
|
|
803
|
+
} else {
|
|
804
|
+
popNextToCommonLevel(prev, next);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
currentActiveSnapshot = next;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function pushProvider(context, nextValue) {
|
|
811
|
+
var prevValue;
|
|
812
|
+
|
|
813
|
+
{
|
|
814
|
+
prevValue = context._currentValue;
|
|
815
|
+
context._currentValue = nextValue;
|
|
816
|
+
|
|
817
|
+
{
|
|
818
|
+
if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) {
|
|
819
|
+
error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
context._currentRenderer = rendererSigil;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
var prevNode = currentActiveSnapshot;
|
|
827
|
+
var newNode = {
|
|
828
|
+
parent: prevNode,
|
|
829
|
+
depth: prevNode === null ? 0 : prevNode.depth + 1,
|
|
830
|
+
context: context,
|
|
831
|
+
parentValue: prevValue,
|
|
832
|
+
value: nextValue
|
|
833
|
+
};
|
|
834
|
+
currentActiveSnapshot = newNode;
|
|
835
|
+
return newNode;
|
|
836
|
+
}
|
|
837
|
+
function popProvider() {
|
|
838
|
+
var prevSnapshot = currentActiveSnapshot;
|
|
839
|
+
|
|
840
|
+
if (prevSnapshot === null) {
|
|
841
|
+
throw new Error('Tried to pop a Context at the root of the app. This is a bug in React.');
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
{
|
|
845
|
+
var value = prevSnapshot.parentValue;
|
|
846
|
+
|
|
847
|
+
if (value === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
|
|
848
|
+
prevSnapshot.context._currentValue = prevSnapshot.context._defaultValue;
|
|
849
|
+
} else {
|
|
850
|
+
prevSnapshot.context._currentValue = value;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
return currentActiveSnapshot = prevSnapshot.parent;
|
|
855
|
+
}
|
|
856
|
+
function getActiveContext() {
|
|
857
|
+
return currentActiveSnapshot;
|
|
858
|
+
}
|
|
859
|
+
function readContext(context) {
|
|
860
|
+
var value = context._currentValue ;
|
|
861
|
+
return value;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function readContext$1(context) {
|
|
865
|
+
{
|
|
866
|
+
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
|
|
867
|
+
error('Only ServerContext is supported in Flight');
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
if (currentCache === null) {
|
|
871
|
+
error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
return readContext(context);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
var Dispatcher = {
|
|
879
|
+
useMemo: function (nextCreate) {
|
|
880
|
+
return nextCreate();
|
|
881
|
+
},
|
|
882
|
+
useCallback: function (callback) {
|
|
883
|
+
return callback;
|
|
884
|
+
},
|
|
885
|
+
useDebugValue: function () {},
|
|
886
|
+
useDeferredValue: unsupportedHook,
|
|
887
|
+
useTransition: unsupportedHook,
|
|
888
|
+
getCacheForType: function (resourceType) {
|
|
889
|
+
if (!currentCache) {
|
|
890
|
+
throw new Error('Reading the cache is only supported while rendering.');
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
var entry = currentCache.get(resourceType);
|
|
894
|
+
|
|
895
|
+
if (entry === undefined) {
|
|
896
|
+
entry = resourceType(); // TODO: Warn if undefined?
|
|
897
|
+
|
|
898
|
+
currentCache.set(resourceType, entry);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return entry;
|
|
902
|
+
},
|
|
903
|
+
readContext: readContext$1,
|
|
904
|
+
useContext: readContext$1,
|
|
905
|
+
useReducer: unsupportedHook,
|
|
906
|
+
useRef: unsupportedHook,
|
|
907
|
+
useState: unsupportedHook,
|
|
908
|
+
useInsertionEffect: unsupportedHook,
|
|
909
|
+
useLayoutEffect: unsupportedHook,
|
|
910
|
+
useImperativeHandle: unsupportedHook,
|
|
911
|
+
useEffect: unsupportedHook,
|
|
912
|
+
useId: unsupportedHook,
|
|
913
|
+
useMutableSource: unsupportedHook,
|
|
914
|
+
useSyncExternalStore: unsupportedHook,
|
|
915
|
+
useCacheRefresh: function () {
|
|
916
|
+
return unsupportedRefresh;
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
function unsupportedHook() {
|
|
921
|
+
throw new Error('This Hook is not supported in Server Components.');
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
function unsupportedRefresh() {
|
|
925
|
+
if (!currentCache) {
|
|
926
|
+
throw new Error('Refreshing the cache is not supported in Server Components.');
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
var currentCache = null;
|
|
931
|
+
function setCurrentCache(cache) {
|
|
932
|
+
currentCache = cache;
|
|
933
|
+
return currentCache;
|
|
934
|
+
}
|
|
935
|
+
function getCurrentCache() {
|
|
936
|
+
return currentCache;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
var ContextRegistry = ReactSharedInternals.ContextRegistry;
|
|
940
|
+
function getOrCreateServerContext(globalName) {
|
|
941
|
+
if (!ContextRegistry[globalName]) {
|
|
942
|
+
ContextRegistry[globalName] = createServerContext(globalName, REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
return ContextRegistry[globalName];
|
|
946
|
+
}
|
|
947
|
+
|
|
182
948
|
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
183
949
|
|
|
184
950
|
function defaultErrorHandler(error) {
|
|
@@ -188,7 +954,7 @@ function defaultErrorHandler(error) {
|
|
|
188
954
|
var OPEN = 0;
|
|
189
955
|
var CLOSING = 1;
|
|
190
956
|
var CLOSED = 2;
|
|
191
|
-
function createRequest(model, bundlerConfig, onError) {
|
|
957
|
+
function createRequest(model, bundlerConfig, onError, context) {
|
|
192
958
|
var pingedSegments = [];
|
|
193
959
|
var request = {
|
|
194
960
|
status: OPEN,
|
|
@@ -204,25 +970,31 @@ function createRequest(model, bundlerConfig, onError) {
|
|
|
204
970
|
completedErrorChunks: [],
|
|
205
971
|
writtenSymbols: new Map(),
|
|
206
972
|
writtenModules: new Map(),
|
|
973
|
+
writtenProviders: new Map(),
|
|
207
974
|
onError: onError === undefined ? defaultErrorHandler : onError,
|
|
208
975
|
toJSON: function (key, value) {
|
|
209
976
|
return resolveModelToJSON(request, this, key, value);
|
|
210
|
-
}
|
|
977
|
+
}
|
|
211
978
|
};
|
|
212
979
|
request.pendingChunks++;
|
|
213
|
-
var
|
|
980
|
+
var rootContext = createRootContext(context);
|
|
981
|
+
var rootSegment = createSegment(request, model, rootContext);
|
|
214
982
|
pingedSegments.push(rootSegment);
|
|
215
983
|
return request;
|
|
216
984
|
}
|
|
217
985
|
|
|
986
|
+
function createRootContext(reqContext) {
|
|
987
|
+
return importServerContexts(reqContext);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
var POP = {};
|
|
991
|
+
|
|
218
992
|
function attemptResolveElement(type, key, ref, props) {
|
|
219
993
|
if (ref !== null && ref !== undefined) {
|
|
220
994
|
// When the ref moves to the regular props object this will implicitly
|
|
221
995
|
// throw for functions. We could probably relax it to a DEV warning for other
|
|
222
996
|
// cases.
|
|
223
|
-
throw new Error(
|
|
224
|
-
'Refs cannot be used in server components, nor passed to client components.'
|
|
225
|
-
);
|
|
997
|
+
throw new Error('Refs cannot be used in server components, nor passed to client components.');
|
|
226
998
|
}
|
|
227
999
|
|
|
228
1000
|
if (typeof type === 'function') {
|
|
@@ -241,6 +1013,7 @@ function attemptResolveElement(type, key, ref, props) {
|
|
|
241
1013
|
} // This might be a built-in React component. We'll let the client decide.
|
|
242
1014
|
// Any built-in works as long as its props are serializable.
|
|
243
1015
|
|
|
1016
|
+
|
|
244
1017
|
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
245
1018
|
} else if (type != null && typeof type === 'object') {
|
|
246
1019
|
if (isModuleReference(type)) {
|
|
@@ -249,20 +1022,54 @@ function attemptResolveElement(type, key, ref, props) {
|
|
|
249
1022
|
}
|
|
250
1023
|
|
|
251
1024
|
switch (type.$$typeof) {
|
|
252
|
-
case
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
1025
|
+
case REACT_LAZY_TYPE:
|
|
1026
|
+
{
|
|
1027
|
+
var payload = type._payload;
|
|
1028
|
+
var init = type._init;
|
|
1029
|
+
var wrappedType = init(payload);
|
|
1030
|
+
return attemptResolveElement(wrappedType, key, ref, props);
|
|
1031
|
+
}
|
|
256
1032
|
|
|
257
|
-
case
|
|
258
|
-
|
|
259
|
-
|
|
1033
|
+
case REACT_FORWARD_REF_TYPE:
|
|
1034
|
+
{
|
|
1035
|
+
var render = type.render;
|
|
1036
|
+
return render(props, undefined);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
case REACT_MEMO_TYPE:
|
|
1040
|
+
{
|
|
1041
|
+
return attemptResolveElement(type.type, key, ref, props);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
case REACT_PROVIDER_TYPE:
|
|
1045
|
+
{
|
|
1046
|
+
pushProvider(type._context, props.value);
|
|
1047
|
+
|
|
1048
|
+
{
|
|
1049
|
+
var extraKeys = Object.keys(props).filter(function (value) {
|
|
1050
|
+
if (value === 'children' || value === 'value') {
|
|
1051
|
+
return false;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
return true;
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
if (extraKeys.length !== 0) {
|
|
1058
|
+
error('ServerContext can only have a value prop and children. Found: %s', JSON.stringify(extraKeys));
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
return [REACT_ELEMENT_TYPE, type, key, // Rely on __popProvider being serialized last to pop the provider.
|
|
1063
|
+
{
|
|
1064
|
+
value: props.value,
|
|
1065
|
+
children: props.children,
|
|
1066
|
+
__pop: POP
|
|
1067
|
+
}];
|
|
1068
|
+
}
|
|
260
1069
|
}
|
|
261
1070
|
}
|
|
262
1071
|
|
|
263
|
-
throw new Error(
|
|
264
|
-
'Unsupported server component type: ' + describeValueForErrorMessage(type)
|
|
265
|
-
);
|
|
1072
|
+
throw new Error("Unsupported server component type: " + describeValueForErrorMessage(type));
|
|
266
1073
|
}
|
|
267
1074
|
|
|
268
1075
|
function pingSegment(request, segment) {
|
|
@@ -276,14 +1083,15 @@ function pingSegment(request, segment) {
|
|
|
276
1083
|
}
|
|
277
1084
|
}
|
|
278
1085
|
|
|
279
|
-
function createSegment(request, model) {
|
|
1086
|
+
function createSegment(request, model, context) {
|
|
280
1087
|
var id = request.nextChunkId++;
|
|
281
1088
|
var segment = {
|
|
282
1089
|
id: id,
|
|
283
1090
|
model: model,
|
|
1091
|
+
context: context,
|
|
284
1092
|
ping: function () {
|
|
285
1093
|
return pingSegment(request, segment);
|
|
286
|
-
}
|
|
1094
|
+
}
|
|
287
1095
|
};
|
|
288
1096
|
return segment;
|
|
289
1097
|
}
|
|
@@ -309,7 +1117,7 @@ function escapeStringValue(value) {
|
|
|
309
1117
|
function isObjectPrototype(object) {
|
|
310
1118
|
if (!object) {
|
|
311
1119
|
return false;
|
|
312
|
-
}
|
|
1120
|
+
}
|
|
313
1121
|
|
|
314
1122
|
var ObjectPrototype = Object.prototype;
|
|
315
1123
|
|
|
@@ -318,6 +1126,7 @@ function isObjectPrototype(object) {
|
|
|
318
1126
|
} // It might be an object from a different Realm which is
|
|
319
1127
|
// still just a plain simple object.
|
|
320
1128
|
|
|
1129
|
+
|
|
321
1130
|
if (Object.getPrototypeOf(object)) {
|
|
322
1131
|
return false;
|
|
323
1132
|
}
|
|
@@ -348,10 +1157,7 @@ function isSimpleObject(object) {
|
|
|
348
1157
|
}
|
|
349
1158
|
|
|
350
1159
|
if (!descriptor.enumerable) {
|
|
351
|
-
if (
|
|
352
|
-
(names[i] === 'key' || names[i] === 'ref') &&
|
|
353
|
-
typeof descriptor.get === 'function'
|
|
354
|
-
) {
|
|
1160
|
+
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
|
355
1161
|
// React adds key and ref getters to props objects to issue warnings.
|
|
356
1162
|
// Those getters will not be transferred to the client, but that's ok,
|
|
357
1163
|
// so we'll special case them.
|
|
@@ -379,25 +1185,25 @@ function describeKeyForErrorMessage(key) {
|
|
|
379
1185
|
|
|
380
1186
|
function describeValueForErrorMessage(value) {
|
|
381
1187
|
switch (typeof value) {
|
|
382
|
-
case 'string':
|
|
383
|
-
|
|
384
|
-
value.length <= 10 ? value : value.substr(0, 10) + '...'
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
case 'object': {
|
|
389
|
-
if (isArray(value)) {
|
|
390
|
-
return '[...]';
|
|
1188
|
+
case 'string':
|
|
1189
|
+
{
|
|
1190
|
+
return JSON.stringify(value.length <= 10 ? value : value.substr(0, 10) + '...');
|
|
391
1191
|
}
|
|
392
1192
|
|
|
393
|
-
|
|
1193
|
+
case 'object':
|
|
1194
|
+
{
|
|
1195
|
+
if (isArray(value)) {
|
|
1196
|
+
return '[...]';
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
var name = objectName(value);
|
|
394
1200
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
1201
|
+
if (name === 'Object') {
|
|
1202
|
+
return '{...}';
|
|
1203
|
+
}
|
|
398
1204
|
|
|
399
|
-
|
|
400
|
-
|
|
1205
|
+
return name;
|
|
1206
|
+
}
|
|
401
1207
|
|
|
402
1208
|
case 'function':
|
|
403
1209
|
return 'function';
|
|
@@ -410,8 +1216,7 @@ function describeValueForErrorMessage(value) {
|
|
|
410
1216
|
|
|
411
1217
|
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
412
1218
|
if (isArray(objectOrArray)) {
|
|
413
|
-
var str = '[';
|
|
414
|
-
|
|
1219
|
+
var str = '[';
|
|
415
1220
|
var array = objectOrArray;
|
|
416
1221
|
|
|
417
1222
|
for (var i = 0; i < array.length; i++) {
|
|
@@ -426,11 +1231,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
|
426
1231
|
|
|
427
1232
|
var _value = array[i];
|
|
428
1233
|
|
|
429
|
-
if (
|
|
430
|
-
'' + i === expandedName &&
|
|
431
|
-
typeof _value === 'object' &&
|
|
432
|
-
_value !== null
|
|
433
|
-
) {
|
|
1234
|
+
if ('' + i === expandedName && typeof _value === 'object' && _value !== null) {
|
|
434
1235
|
str += describeObjectForErrorMessage(_value);
|
|
435
1236
|
} else {
|
|
436
1237
|
str += describeValueForErrorMessage(_value);
|
|
@@ -440,8 +1241,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
|
440
1241
|
str += ']';
|
|
441
1242
|
return str;
|
|
442
1243
|
} else {
|
|
443
|
-
var _str = '{';
|
|
444
|
-
|
|
1244
|
+
var _str = '{';
|
|
445
1245
|
var object = objectOrArray;
|
|
446
1246
|
var names = Object.keys(object);
|
|
447
1247
|
|
|
@@ -459,11 +1259,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
|
459
1259
|
_str += describeKeyForErrorMessage(name) + ': ';
|
|
460
1260
|
var _value2 = object[name];
|
|
461
1261
|
|
|
462
|
-
if (
|
|
463
|
-
name === expandedName &&
|
|
464
|
-
typeof _value2 === 'object' &&
|
|
465
|
-
_value2 !== null
|
|
466
|
-
) {
|
|
1262
|
+
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
|
467
1263
|
_str += describeObjectForErrorMessage(_value2);
|
|
468
1264
|
} else {
|
|
469
1265
|
_str += describeValueForErrorMessage(_value2);
|
|
@@ -475,59 +1271,71 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
|
475
1271
|
}
|
|
476
1272
|
}
|
|
477
1273
|
|
|
1274
|
+
var insideContextProps = null;
|
|
1275
|
+
var isInsideContextValue = false;
|
|
478
1276
|
function resolveModelToJSON(request, parent, key, value) {
|
|
479
1277
|
{
|
|
480
1278
|
// $FlowFixMe
|
|
481
1279
|
var originalValue = parent[key];
|
|
482
1280
|
|
|
483
1281
|
if (typeof originalValue === 'object' && originalValue !== value) {
|
|
484
|
-
error(
|
|
485
|
-
'Only plain objects can be passed to client components from server components. ' +
|
|
486
|
-
'Objects with toJSON methods are not supported. Convert it manually ' +
|
|
487
|
-
'to a simple value before passing it to props. ' +
|
|
488
|
-
'Remove %s from these props: %s',
|
|
489
|
-
describeKeyForErrorMessage(key),
|
|
490
|
-
describeObjectForErrorMessage(parent)
|
|
491
|
-
);
|
|
1282
|
+
error('Only plain objects can be passed to client components from server components. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props. ' + 'Remove %s from these props: %s', describeKeyForErrorMessage(key), describeObjectForErrorMessage(parent));
|
|
492
1283
|
}
|
|
493
1284
|
} // Special Symbols
|
|
494
1285
|
|
|
1286
|
+
|
|
495
1287
|
switch (value) {
|
|
496
1288
|
case REACT_ELEMENT_TYPE:
|
|
497
1289
|
return '$';
|
|
1290
|
+
}
|
|
498
1291
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
1292
|
+
{
|
|
1293
|
+
if (parent[0] === REACT_ELEMENT_TYPE && parent[1] && parent[1].$$typeof === REACT_PROVIDER_TYPE && key === '3') {
|
|
1294
|
+
insideContextProps = value;
|
|
1295
|
+
} else if (insideContextProps === parent && key === 'value') {
|
|
1296
|
+
isInsideContextValue = true;
|
|
1297
|
+
} else if (insideContextProps === parent && key === 'children') {
|
|
1298
|
+
isInsideContextValue = false;
|
|
1299
|
+
}
|
|
503
1300
|
} // Resolve server components.
|
|
504
1301
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
1302
|
+
|
|
1303
|
+
while (typeof value === 'object' && value !== null && (value.$$typeof === REACT_ELEMENT_TYPE || value.$$typeof === REACT_LAZY_TYPE)) {
|
|
1304
|
+
{
|
|
1305
|
+
if (isInsideContextValue) {
|
|
1306
|
+
error('React elements are not allowed in ServerContext');
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
512
1309
|
|
|
513
1310
|
try {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
1311
|
+
switch (value.$$typeof) {
|
|
1312
|
+
case REACT_ELEMENT_TYPE:
|
|
1313
|
+
{
|
|
1314
|
+
// TODO: Concatenate keys of parents onto children.
|
|
1315
|
+
var element = value; // Attempt to render the server component.
|
|
1316
|
+
|
|
1317
|
+
value = attemptResolveElement(element.type, element.key, element.ref, element.props);
|
|
1318
|
+
break;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
case REACT_LAZY_TYPE:
|
|
1322
|
+
{
|
|
1323
|
+
var payload = value._payload;
|
|
1324
|
+
var init = value._init;
|
|
1325
|
+
value = init(payload);
|
|
1326
|
+
break;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
521
1329
|
} catch (x) {
|
|
522
1330
|
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
|
523
1331
|
// Something suspended, we'll need to create a new segment and resolve it later.
|
|
524
1332
|
request.pendingChunks++;
|
|
525
|
-
var newSegment = createSegment(request, value);
|
|
1333
|
+
var newSegment = createSegment(request, value, getActiveContext());
|
|
526
1334
|
var ping = newSegment.ping;
|
|
527
1335
|
x.then(ping, ping);
|
|
528
1336
|
return serializeByRefID(newSegment.id);
|
|
529
1337
|
} else {
|
|
530
|
-
|
|
1338
|
+
logRecoverableError(request, x); // Something errored. We'll still send everything we have up until this point.
|
|
531
1339
|
// We'll replace this element with a lazy reference that throws on the client
|
|
532
1340
|
// once it gets rendered.
|
|
533
1341
|
|
|
@@ -564,10 +1372,7 @@ function resolveModelToJSON(request, parent, key, value) {
|
|
|
564
1372
|
}
|
|
565
1373
|
|
|
566
1374
|
try {
|
|
567
|
-
var moduleMetaData = resolveModuleMetaData(
|
|
568
|
-
request.bundlerConfig,
|
|
569
|
-
moduleReference
|
|
570
|
-
);
|
|
1375
|
+
var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
|
|
571
1376
|
request.pendingChunks++;
|
|
572
1377
|
var moduleId = request.nextChunkId++;
|
|
573
1378
|
emitModuleChunk(request, moduleId, moduleMetaData);
|
|
@@ -591,40 +1396,42 @@ function resolveModelToJSON(request, parent, key, value) {
|
|
|
591
1396
|
emitErrorChunk(request, _errorId, x);
|
|
592
1397
|
return serializeByValueID(_errorId);
|
|
593
1398
|
}
|
|
1399
|
+
} else if (value.$$typeof === REACT_PROVIDER_TYPE) {
|
|
1400
|
+
var providerKey = value._context._globalName;
|
|
1401
|
+
var writtenProviders = request.writtenProviders;
|
|
1402
|
+
var providerId = writtenProviders.get(key);
|
|
1403
|
+
|
|
1404
|
+
if (providerId === undefined) {
|
|
1405
|
+
request.pendingChunks++;
|
|
1406
|
+
providerId = request.nextChunkId++;
|
|
1407
|
+
writtenProviders.set(providerKey, providerId);
|
|
1408
|
+
emitProviderChunk(request, providerId, providerKey);
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
return serializeByValueID(providerId);
|
|
1412
|
+
} else if (value === POP) {
|
|
1413
|
+
popProvider();
|
|
1414
|
+
|
|
1415
|
+
{
|
|
1416
|
+
insideContextProps = null;
|
|
1417
|
+
isInsideContextValue = false;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
return undefined;
|
|
594
1421
|
}
|
|
595
1422
|
|
|
596
1423
|
{
|
|
597
1424
|
if (value !== null && !isArray(value)) {
|
|
598
1425
|
// Verify that this is a simple plain object.
|
|
599
1426
|
if (objectName(value) !== 'Object') {
|
|
600
|
-
error(
|
|
601
|
-
'Only plain objects can be passed to client components from server components. ' +
|
|
602
|
-
'Built-ins like %s are not supported. ' +
|
|
603
|
-
'Remove %s from these props: %s',
|
|
604
|
-
objectName(value),
|
|
605
|
-
describeKeyForErrorMessage(key),
|
|
606
|
-
describeObjectForErrorMessage(parent)
|
|
607
|
-
);
|
|
1427
|
+
error('Only plain objects can be passed to client components from server components. ' + 'Built-ins like %s are not supported. ' + 'Remove %s from these props: %s', objectName(value), describeKeyForErrorMessage(key), describeObjectForErrorMessage(parent));
|
|
608
1428
|
} else if (!isSimpleObject(value)) {
|
|
609
|
-
error(
|
|
610
|
-
'Only plain objects can be passed to client components from server components. ' +
|
|
611
|
-
'Classes or other objects with methods are not supported. ' +
|
|
612
|
-
'Remove %s from these props: %s',
|
|
613
|
-
describeKeyForErrorMessage(key),
|
|
614
|
-
describeObjectForErrorMessage(parent, key)
|
|
615
|
-
);
|
|
1429
|
+
error('Only plain objects can be passed to client components from server components. ' + 'Classes or other objects with methods are not supported. ' + 'Remove %s from these props: %s', describeKeyForErrorMessage(key), describeObjectForErrorMessage(parent, key));
|
|
616
1430
|
} else if (Object.getOwnPropertySymbols) {
|
|
617
1431
|
var symbols = Object.getOwnPropertySymbols(value);
|
|
618
1432
|
|
|
619
1433
|
if (symbols.length > 0) {
|
|
620
|
-
error(
|
|
621
|
-
'Only plain objects can be passed to client components from server components. ' +
|
|
622
|
-
'Objects with symbol properties like %s are not supported. ' +
|
|
623
|
-
'Remove %s from these props: %s',
|
|
624
|
-
symbols[0].description,
|
|
625
|
-
describeKeyForErrorMessage(key),
|
|
626
|
-
describeObjectForErrorMessage(parent, key)
|
|
627
|
-
);
|
|
1434
|
+
error('Only plain objects can be passed to client components from server components. ' + 'Objects with symbol properties like %s are not supported. ' + 'Remove %s from these props: %s', symbols[0].description, describeKeyForErrorMessage(key), describeObjectForErrorMessage(parent, key));
|
|
628
1435
|
}
|
|
629
1436
|
}
|
|
630
1437
|
}
|
|
@@ -637,36 +1444,15 @@ function resolveModelToJSON(request, parent, key, value) {
|
|
|
637
1444
|
return escapeStringValue(value);
|
|
638
1445
|
}
|
|
639
1446
|
|
|
640
|
-
if (
|
|
641
|
-
typeof value === 'boolean' ||
|
|
642
|
-
typeof value === 'number' ||
|
|
643
|
-
typeof value === 'undefined'
|
|
644
|
-
) {
|
|
1447
|
+
if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'undefined') {
|
|
645
1448
|
return value;
|
|
646
1449
|
}
|
|
647
1450
|
|
|
648
1451
|
if (typeof value === 'function') {
|
|
649
1452
|
if (/^on[A-Z]/.test(key)) {
|
|
650
|
-
throw new Error(
|
|
651
|
-
'Event handlers cannot be passed to client component props. ' +
|
|
652
|
-
('Remove ' +
|
|
653
|
-
describeKeyForErrorMessage(key) +
|
|
654
|
-
' from these props if possible: ' +
|
|
655
|
-
describeObjectForErrorMessage(parent) +
|
|
656
|
-
'\n') +
|
|
657
|
-
'If you need interactivity, consider converting part of this to a client component.'
|
|
658
|
-
);
|
|
1453
|
+
throw new Error('Event handlers cannot be passed to client component props. ' + ("Remove " + describeKeyForErrorMessage(key) + " from these props if possible: " + describeObjectForErrorMessage(parent) + "\n") + 'If you need interactivity, consider converting part of this to a client component.');
|
|
659
1454
|
} else {
|
|
660
|
-
throw new Error(
|
|
661
|
-
'Functions cannot be passed directly to client components ' +
|
|
662
|
-
"because they're not serializable. " +
|
|
663
|
-
('Remove ' +
|
|
664
|
-
describeKeyForErrorMessage(key) +
|
|
665
|
-
' (' +
|
|
666
|
-
(value.displayName || value.name || 'function') +
|
|
667
|
-
') from this object, or avoid the entire object: ' +
|
|
668
|
-
describeObjectForErrorMessage(parent))
|
|
669
|
-
);
|
|
1455
|
+
throw new Error('Functions cannot be passed directly to client components ' + "because they're not serializable. " + ("Remove " + describeKeyForErrorMessage(key) + " (" + (value.displayName || value.name || 'function') + ") from this object, or avoid the entire object: " + describeObjectForErrorMessage(parent)));
|
|
670
1456
|
}
|
|
671
1457
|
}
|
|
672
1458
|
|
|
@@ -682,16 +1468,7 @@ function resolveModelToJSON(request, parent, key, value) {
|
|
|
682
1468
|
var name = value.description;
|
|
683
1469
|
|
|
684
1470
|
if (Symbol.for(name) !== value) {
|
|
685
|
-
throw new Error(
|
|
686
|
-
'Only global symbols received from Symbol.for(...) can be passed to client components. ' +
|
|
687
|
-
('The symbol Symbol.for(' +
|
|
688
|
-
value.description +
|
|
689
|
-
') cannot be found among global symbols. ') +
|
|
690
|
-
('Remove ' +
|
|
691
|
-
describeKeyForErrorMessage(key) +
|
|
692
|
-
' from this object, or avoid the entire object: ' +
|
|
693
|
-
describeObjectForErrorMessage(parent))
|
|
694
|
-
);
|
|
1471
|
+
throw new Error('Only global symbols received from Symbol.for(...) can be passed to client components. ' + ("The symbol Symbol.for(" + value.description + ") cannot be found among global symbols. ") + ("Remove " + describeKeyForErrorMessage(key) + " from this object, or avoid the entire object: " + describeObjectForErrorMessage(parent)));
|
|
695
1472
|
}
|
|
696
1473
|
|
|
697
1474
|
request.pendingChunks++;
|
|
@@ -701,30 +1478,15 @@ function resolveModelToJSON(request, parent, key, value) {
|
|
|
701
1478
|
return serializeByValueID(symbolId);
|
|
702
1479
|
} // $FlowFixMe: bigint isn't added to Flow yet.
|
|
703
1480
|
|
|
1481
|
+
|
|
704
1482
|
if (typeof value === 'bigint') {
|
|
705
|
-
throw new Error(
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
describeObjectForErrorMessage(parent))
|
|
713
|
-
);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
throw new Error(
|
|
717
|
-
'Type ' +
|
|
718
|
-
typeof value +
|
|
719
|
-
' is not supported in client component props. ' +
|
|
720
|
-
('Remove ' +
|
|
721
|
-
describeKeyForErrorMessage(key) +
|
|
722
|
-
' from this object, or avoid the entire object: ' +
|
|
723
|
-
describeObjectForErrorMessage(parent))
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
function reportError(request, error) {
|
|
1483
|
+
throw new Error("BigInt (" + value + ") is not yet supported in client component props. " + ("Remove " + describeKeyForErrorMessage(key) + " from this object or use a plain number instead: " + describeObjectForErrorMessage(parent)));
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
throw new Error("Type " + typeof value + " is not supported in client component props. " + ("Remove " + describeKeyForErrorMessage(key) + " from this object, or avoid the entire object: " + describeObjectForErrorMessage(parent)));
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
function logRecoverableError(request, error) {
|
|
728
1490
|
var onError = request.onError;
|
|
729
1491
|
onError(error);
|
|
730
1492
|
}
|
|
@@ -774,27 +1536,25 @@ function emitSymbolChunk(request, id, name) {
|
|
|
774
1536
|
request.completedModuleChunks.push(processedChunk);
|
|
775
1537
|
}
|
|
776
1538
|
|
|
1539
|
+
function emitProviderChunk(request, id, contextName) {
|
|
1540
|
+
var processedChunk = processProviderChunk(request, id, contextName);
|
|
1541
|
+
request.completedJSONChunks.push(processedChunk);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
777
1544
|
function retrySegment(request, segment) {
|
|
1545
|
+
switchContext(segment.context);
|
|
1546
|
+
|
|
778
1547
|
try {
|
|
779
1548
|
var _value3 = segment.model;
|
|
780
1549
|
|
|
781
|
-
while (
|
|
782
|
-
typeof _value3 === 'object' &&
|
|
783
|
-
_value3 !== null &&
|
|
784
|
-
_value3.$$typeof === REACT_ELEMENT_TYPE
|
|
785
|
-
) {
|
|
1550
|
+
while (typeof _value3 === 'object' && _value3 !== null && _value3.$$typeof === REACT_ELEMENT_TYPE) {
|
|
786
1551
|
// TODO: Concatenate keys of parents onto children.
|
|
787
1552
|
var element = _value3; // Attempt to render the server component.
|
|
788
1553
|
// Doing this here lets us reuse this same segment if the next component
|
|
789
1554
|
// also suspends.
|
|
790
1555
|
|
|
791
1556
|
segment.model = _value3;
|
|
792
|
-
_value3 = attemptResolveElement(
|
|
793
|
-
element.type,
|
|
794
|
-
element.key,
|
|
795
|
-
element.ref,
|
|
796
|
-
element.props
|
|
797
|
-
);
|
|
1557
|
+
_value3 = attemptResolveElement(element.type, element.key, element.ref, element.props);
|
|
798
1558
|
}
|
|
799
1559
|
|
|
800
1560
|
var processedChunk = processModelChunk(request, segment.id, _value3);
|
|
@@ -806,7 +1566,7 @@ function retrySegment(request, segment) {
|
|
|
806
1566
|
x.then(ping, ping);
|
|
807
1567
|
return;
|
|
808
1568
|
} else {
|
|
809
|
-
|
|
1569
|
+
logRecoverableError(request, x); // This errored, we need to serialize this error to the
|
|
810
1570
|
|
|
811
1571
|
emitErrorChunk(request, segment.id, x);
|
|
812
1572
|
}
|
|
@@ -815,9 +1575,9 @@ function retrySegment(request, segment) {
|
|
|
815
1575
|
|
|
816
1576
|
function performWork(request) {
|
|
817
1577
|
var prevDispatcher = ReactCurrentDispatcher.current;
|
|
818
|
-
var prevCache =
|
|
1578
|
+
var prevCache = getCurrentCache();
|
|
819
1579
|
ReactCurrentDispatcher.current = Dispatcher;
|
|
820
|
-
|
|
1580
|
+
setCurrentCache(request.cache);
|
|
821
1581
|
|
|
822
1582
|
try {
|
|
823
1583
|
var pingedSegments = request.pingedSegments;
|
|
@@ -832,18 +1592,17 @@ function performWork(request) {
|
|
|
832
1592
|
flushCompletedChunks(request, request.destination);
|
|
833
1593
|
}
|
|
834
1594
|
} catch (error) {
|
|
835
|
-
|
|
1595
|
+
logRecoverableError(request, error);
|
|
836
1596
|
fatalError(request, error);
|
|
837
1597
|
} finally {
|
|
838
1598
|
ReactCurrentDispatcher.current = prevDispatcher;
|
|
839
|
-
|
|
1599
|
+
setCurrentCache(prevCache);
|
|
840
1600
|
}
|
|
841
1601
|
}
|
|
842
1602
|
|
|
843
|
-
let reentrant = false;
|
|
844
1603
|
function flushCompletedChunks(request, destination) {
|
|
845
|
-
|
|
846
|
-
|
|
1604
|
+
beginWriting();
|
|
1605
|
+
|
|
847
1606
|
try {
|
|
848
1607
|
// We emit module chunks first in the stream so that
|
|
849
1608
|
// they can be preloaded as early as possible.
|
|
@@ -853,8 +1612,9 @@ function flushCompletedChunks(request, destination) {
|
|
|
853
1612
|
for (; i < moduleChunks.length; i++) {
|
|
854
1613
|
request.pendingChunks--;
|
|
855
1614
|
var chunk = moduleChunks[i];
|
|
1615
|
+
var keepWriting = writeChunkAndReturn(destination, chunk);
|
|
856
1616
|
|
|
857
|
-
if (!
|
|
1617
|
+
if (!keepWriting) {
|
|
858
1618
|
request.destination = null;
|
|
859
1619
|
i++;
|
|
860
1620
|
break;
|
|
@@ -870,7 +1630,9 @@ function flushCompletedChunks(request, destination) {
|
|
|
870
1630
|
request.pendingChunks--;
|
|
871
1631
|
var _chunk = jsonChunks[i];
|
|
872
1632
|
|
|
873
|
-
|
|
1633
|
+
var _keepWriting = writeChunkAndReturn(destination, _chunk);
|
|
1634
|
+
|
|
1635
|
+
if (!_keepWriting) {
|
|
874
1636
|
request.destination = null;
|
|
875
1637
|
i++;
|
|
876
1638
|
break;
|
|
@@ -888,7 +1650,9 @@ function flushCompletedChunks(request, destination) {
|
|
|
888
1650
|
request.pendingChunks--;
|
|
889
1651
|
var _chunk2 = errorChunks[i];
|
|
890
1652
|
|
|
891
|
-
|
|
1653
|
+
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
|
|
1654
|
+
|
|
1655
|
+
if (!_keepWriting2) {
|
|
892
1656
|
request.destination = null;
|
|
893
1657
|
i++;
|
|
894
1658
|
break;
|
|
@@ -897,7 +1661,7 @@ function flushCompletedChunks(request, destination) {
|
|
|
897
1661
|
|
|
898
1662
|
errorChunks.splice(0, i);
|
|
899
1663
|
} finally {
|
|
900
|
-
|
|
1664
|
+
completeWriting(destination);
|
|
901
1665
|
}
|
|
902
1666
|
|
|
903
1667
|
if (request.pendingChunks === 0) {
|
|
@@ -922,93 +1686,56 @@ function startFlowing(request, destination) {
|
|
|
922
1686
|
return;
|
|
923
1687
|
}
|
|
924
1688
|
|
|
1689
|
+
if (request.destination !== null) {
|
|
1690
|
+
// We're already flowing.
|
|
1691
|
+
return;
|
|
1692
|
+
}
|
|
1693
|
+
|
|
925
1694
|
request.destination = destination;
|
|
926
1695
|
|
|
927
1696
|
try {
|
|
928
1697
|
flushCompletedChunks(request, destination);
|
|
929
1698
|
} catch (error) {
|
|
930
|
-
|
|
1699
|
+
logRecoverableError(request, error);
|
|
931
1700
|
fatalError(request, error);
|
|
932
1701
|
}
|
|
933
1702
|
}
|
|
934
1703
|
|
|
935
|
-
function
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
var currentCache = null;
|
|
948
|
-
var Dispatcher = {
|
|
949
|
-
useMemo: function (nextCreate) {
|
|
950
|
-
return nextCreate();
|
|
951
|
-
},
|
|
952
|
-
useCallback: function (callback) {
|
|
953
|
-
return callback;
|
|
954
|
-
},
|
|
955
|
-
useDebugValue: function () {},
|
|
956
|
-
useDeferredValue: unsupportedHook,
|
|
957
|
-
useTransition: unsupportedHook,
|
|
958
|
-
getCacheForType: function (resourceType) {
|
|
959
|
-
if (!currentCache) {
|
|
960
|
-
throw new Error('Reading the cache is only supported while rendering.');
|
|
1704
|
+
function importServerContexts(contexts) {
|
|
1705
|
+
if (contexts) {
|
|
1706
|
+
var prevContext = getActiveContext();
|
|
1707
|
+
switchContext(rootContextSnapshot);
|
|
1708
|
+
|
|
1709
|
+
for (var i = 0; i < contexts.length; i++) {
|
|
1710
|
+
var _contexts$i = contexts[i],
|
|
1711
|
+
name = _contexts$i[0],
|
|
1712
|
+
_value4 = _contexts$i[1];
|
|
1713
|
+
var context = getOrCreateServerContext(name);
|
|
1714
|
+
pushProvider(context, _value4);
|
|
961
1715
|
}
|
|
962
1716
|
|
|
963
|
-
var
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
currentCache.set(resourceType, entry);
|
|
969
|
-
}
|
|
1717
|
+
var importedContext = getActiveContext();
|
|
1718
|
+
switchContext(prevContext);
|
|
1719
|
+
return importedContext;
|
|
1720
|
+
}
|
|
970
1721
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
readContext: unsupportedHook,
|
|
974
|
-
useContext: unsupportedHook,
|
|
975
|
-
useReducer: unsupportedHook,
|
|
976
|
-
useRef: unsupportedHook,
|
|
977
|
-
useState: unsupportedHook,
|
|
978
|
-
useInsertionEffect: unsupportedHook,
|
|
979
|
-
useLayoutEffect: unsupportedHook,
|
|
980
|
-
useImperativeHandle: unsupportedHook,
|
|
981
|
-
useEffect: unsupportedHook,
|
|
982
|
-
useId: unsupportedHook,
|
|
983
|
-
useMutableSource: unsupportedHook,
|
|
984
|
-
useSyncExternalStore: unsupportedHook,
|
|
985
|
-
useCacheRefresh: function () {
|
|
986
|
-
return unsupportedRefresh;
|
|
987
|
-
},
|
|
988
|
-
};
|
|
1722
|
+
return rootContextSnapshot;
|
|
1723
|
+
}
|
|
989
1724
|
|
|
990
|
-
function renderToReadableStream(model, options) {
|
|
991
|
-
var request = createRequest(
|
|
992
|
-
|
|
993
|
-
{}, // Manifest, not used
|
|
994
|
-
options ? options.onError : undefined
|
|
995
|
-
);
|
|
1725
|
+
function renderToReadableStream(model, options, context) {
|
|
1726
|
+
var request = createRequest(model, {}, // Manifest, not used
|
|
1727
|
+
options ? options.onError : undefined, context);
|
|
996
1728
|
var stream = new ReadableStream({
|
|
1729
|
+
type: 'bytes',
|
|
997
1730
|
start: function (controller) {
|
|
998
1731
|
startWork(request);
|
|
999
1732
|
},
|
|
1000
1733
|
pull: function (controller) {
|
|
1001
|
-
|
|
1002
|
-
// That's buffering too early. We want to start buffering once the stream
|
|
1003
|
-
// is actually used by something so we can give it the best result possible
|
|
1004
|
-
// at that point.
|
|
1005
|
-
if (stream.locked) {
|
|
1006
|
-
startFlowing(request, controller);
|
|
1007
|
-
}
|
|
1734
|
+
startFlowing(request, controller);
|
|
1008
1735
|
},
|
|
1009
|
-
cancel: function (reason) {}
|
|
1736
|
+
cancel: function (reason) {}
|
|
1010
1737
|
});
|
|
1011
1738
|
return stream;
|
|
1012
1739
|
}
|
|
1013
1740
|
|
|
1014
|
-
export {renderToReadableStream};
|
|
1741
|
+
export { renderToReadableStream };
|