@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
package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js
CHANGED
|
@@ -10,1044 +10,1703 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
if (process.env.NODE_ENV !==
|
|
14
|
-
(function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var React = require('react');
|
|
13
|
+
if (process.env.NODE_ENV !== "production") {
|
|
14
|
+
(function() {
|
|
15
|
+
'use strict';
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
17
|
+
var React = require('react');
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
{
|
|
25
|
-
for (
|
|
26
|
-
var _len2 = arguments.length,
|
|
27
|
-
args = new Array(_len2 > 1 ? _len2 - 1 : 0),
|
|
28
|
-
_key2 = 1;
|
|
29
|
-
_key2 < _len2;
|
|
30
|
-
_key2++
|
|
31
|
-
) {
|
|
32
|
-
args[_key2 - 1] = arguments[_key2];
|
|
33
|
-
}
|
|
19
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
function error(format) {
|
|
22
|
+
{
|
|
23
|
+
{
|
|
24
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
25
|
+
args[_key2 - 1] = arguments[_key2];
|
|
37
26
|
}
|
|
27
|
+
|
|
28
|
+
printWarning('error', format, args);
|
|
38
29
|
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
33
|
+
function printWarning(level, format, args) {
|
|
34
|
+
// When changing this logic, you might want to also
|
|
35
|
+
// update consoleWithStackDev.www.js as well.
|
|
36
|
+
{
|
|
37
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
38
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
47
39
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
if (stack !== '') {
|
|
41
|
+
format += '%s';
|
|
42
|
+
args = args.concat([stack]);
|
|
43
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
52
44
|
|
|
53
|
-
var argsWithFormat = args.map(function (item) {
|
|
54
|
-
return String(item);
|
|
55
|
-
}); // Careful: RN currently depends on this prefix
|
|
56
45
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
var argsWithFormat = args.map(function (item) {
|
|
47
|
+
return String(item);
|
|
48
|
+
}); // Careful: RN currently depends on this prefix
|
|
60
49
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
51
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
52
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
64
53
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
54
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function scheduleWork(callback) {
|
|
59
|
+
setImmediate(callback);
|
|
60
|
+
}
|
|
61
|
+
function flushBuffered(destination) {
|
|
62
|
+
// If we don't have any more data to send right now.
|
|
63
|
+
// Flush whatever is in the buffer to the wire.
|
|
64
|
+
if (typeof destination.flush === 'function') {
|
|
65
|
+
// By convention the Zlib streams provide a flush function for this purpose.
|
|
66
|
+
// For Express, compression middleware adds this method.
|
|
67
|
+
destination.flush();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function beginWriting(destination) {
|
|
71
|
+
// Older Node streams like http.createServer don't have this.
|
|
72
|
+
if (typeof destination.cork === 'function') {
|
|
73
|
+
destination.cork();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function writeChunkAndReturn(destination, chunk) {
|
|
77
|
+
var nodeBuffer = chunk; // close enough
|
|
78
|
+
|
|
79
|
+
return destination.write(nodeBuffer);
|
|
80
|
+
}
|
|
81
|
+
function completeWriting(destination) {
|
|
82
|
+
// Older Node streams like http.createServer don't have this.
|
|
83
|
+
if (typeof destination.uncork === 'function') {
|
|
84
|
+
destination.uncork();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function close(destination) {
|
|
88
|
+
destination.end();
|
|
89
|
+
}
|
|
90
|
+
function stringToChunk(content) {
|
|
91
|
+
return content;
|
|
92
|
+
}
|
|
93
|
+
function stringToPrecomputedChunk(content) {
|
|
94
|
+
return Buffer.from(content, 'utf8');
|
|
95
|
+
}
|
|
96
|
+
function closeWithError(destination, error) {
|
|
97
|
+
// $FlowFixMe: This is an Error object or the destination accepts other types.
|
|
98
|
+
destination.destroy(error);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// This file is an intermediate layer to translate between Flight
|
|
102
|
+
var stringify = JSON.stringify;
|
|
103
|
+
|
|
104
|
+
function serializeRowHeader(tag, id) {
|
|
105
|
+
return tag + id.toString(16) + ':';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function processErrorChunk(request, id, message, stack) {
|
|
109
|
+
var errorInfo = {
|
|
110
|
+
message: message,
|
|
111
|
+
stack: stack
|
|
112
|
+
};
|
|
113
|
+
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
|
114
|
+
return stringToChunk(row);
|
|
115
|
+
}
|
|
116
|
+
function processModelChunk(request, id, model) {
|
|
117
|
+
var json = stringify(model, request.toJSON);
|
|
118
|
+
var row = serializeRowHeader('J', id) + json + '\n';
|
|
119
|
+
return stringToChunk(row);
|
|
120
|
+
}
|
|
121
|
+
function processModuleChunk(request, id, moduleMetaData) {
|
|
122
|
+
var json = stringify(moduleMetaData);
|
|
123
|
+
var row = serializeRowHeader('M', id) + json + '\n';
|
|
124
|
+
return stringToChunk(row);
|
|
125
|
+
}
|
|
126
|
+
function processProviderChunk(request, id, contextName) {
|
|
127
|
+
var row = serializeRowHeader('P', id) + contextName + '\n';
|
|
128
|
+
return stringToChunk(row);
|
|
129
|
+
}
|
|
130
|
+
function processSymbolChunk(request, id, name) {
|
|
131
|
+
var json = stringify(name);
|
|
132
|
+
var row = serializeRowHeader('S', id) + json + '\n';
|
|
133
|
+
return stringToChunk(row);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// eslint-disable-next-line no-unused-vars
|
|
137
|
+
var MODULE_TAG = Symbol.for('react.module.reference');
|
|
138
|
+
function getModuleKey(reference) {
|
|
139
|
+
return reference.filepath + '#' + reference.name;
|
|
140
|
+
}
|
|
141
|
+
function isModuleReference(reference) {
|
|
142
|
+
return (reference.$$typeof_rsc || reference.$$typeof) === MODULE_TAG;
|
|
143
|
+
}
|
|
144
|
+
function resolveModuleMetaData(config, moduleReference) {
|
|
145
|
+
return {
|
|
146
|
+
id: moduleReference.filepath,
|
|
147
|
+
name: moduleReference.name
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ATTENTION
|
|
152
|
+
// When adding new symbols to this file,
|
|
153
|
+
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
154
|
+
// The Symbol used to tag the ReactElement-like types.
|
|
155
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
156
|
+
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
157
|
+
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
158
|
+
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
|
159
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
160
|
+
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
|
161
|
+
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
162
|
+
var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
|
|
163
|
+
|
|
164
|
+
// A reserved attribute.
|
|
165
|
+
// It is handled by React separately and shouldn't be written to the DOM.
|
|
166
|
+
var RESERVED = 0; // A simple string attribute.
|
|
167
|
+
// Attributes that aren't in the filter are presumed to have this type.
|
|
168
|
+
|
|
169
|
+
var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
|
|
170
|
+
// "enumerated" attributes with "true" and "false" as possible values.
|
|
171
|
+
// When true, it should be set to a "true" string.
|
|
172
|
+
// When false, it should be set to a "false" string.
|
|
173
|
+
|
|
174
|
+
var BOOLEANISH_STRING = 2; // A real boolean attribute.
|
|
175
|
+
// When true, it should be present (set either to an empty string or its name).
|
|
176
|
+
// When false, it should be omitted.
|
|
177
|
+
|
|
178
|
+
var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
|
|
179
|
+
// When true, it should be present (set either to an empty string or its name).
|
|
180
|
+
// When false, it should be omitted.
|
|
181
|
+
// For any other value, should be present with that value.
|
|
182
|
+
|
|
183
|
+
var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
|
|
184
|
+
// When falsy, it should be removed.
|
|
185
|
+
|
|
186
|
+
var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
|
|
187
|
+
// When falsy, it should be removed.
|
|
188
|
+
|
|
189
|
+
var POSITIVE_NUMERIC = 6;
|
|
190
|
+
|
|
191
|
+
function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
|
|
192
|
+
this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
|
|
193
|
+
this.attributeName = attributeName;
|
|
194
|
+
this.attributeNamespace = attributeNamespace;
|
|
195
|
+
this.mustUseProperty = mustUseProperty;
|
|
196
|
+
this.propertyName = name;
|
|
197
|
+
this.type = type;
|
|
198
|
+
this.sanitizeURL = sanitizeURL;
|
|
199
|
+
this.removeEmptyString = removeEmptyString;
|
|
200
|
+
} // When adding attributes to this list, be sure to also add them to
|
|
201
|
+
// the `possibleStandardNames` module to ensure casing and incorrect
|
|
202
|
+
// name warnings.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
|
|
206
|
+
|
|
207
|
+
var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
|
|
208
|
+
// elements (not just inputs). Now that ReactDOMInput assigns to the
|
|
209
|
+
// defaultValue property -- do we need this?
|
|
210
|
+
'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'];
|
|
211
|
+
|
|
212
|
+
{
|
|
213
|
+
reservedProps.push('innerText', 'textContent');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
reservedProps.forEach(function (name) {
|
|
217
|
+
properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
|
|
218
|
+
name, // attributeName
|
|
219
|
+
null, // attributeNamespace
|
|
220
|
+
false, // sanitizeURL
|
|
221
|
+
false);
|
|
222
|
+
}); // A few React string attributes have a different name.
|
|
223
|
+
// This is a mapping from React prop names to the attribute names.
|
|
224
|
+
|
|
225
|
+
[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
|
|
226
|
+
var name = _ref[0],
|
|
227
|
+
attributeName = _ref[1];
|
|
228
|
+
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
229
|
+
attributeName, // attributeName
|
|
230
|
+
null, // attributeNamespace
|
|
231
|
+
false, // sanitizeURL
|
|
232
|
+
false);
|
|
233
|
+
}); // These are "enumerated" HTML attributes that accept "true" and "false".
|
|
234
|
+
// In React, we let users pass `true` and `false` even though technically
|
|
235
|
+
// these aren't boolean attributes (they are coerced to strings).
|
|
236
|
+
|
|
237
|
+
['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
|
|
238
|
+
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
|
|
239
|
+
name.toLowerCase(), // attributeName
|
|
240
|
+
null, // attributeNamespace
|
|
241
|
+
false, // sanitizeURL
|
|
242
|
+
false);
|
|
243
|
+
}); // These are "enumerated" SVG attributes that accept "true" and "false".
|
|
244
|
+
// In React, we let users pass `true` and `false` even though technically
|
|
245
|
+
// these aren't boolean attributes (they are coerced to strings).
|
|
246
|
+
// Since these are SVG attributes, their attribute names are case-sensitive.
|
|
247
|
+
|
|
248
|
+
['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
|
|
249
|
+
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
|
|
250
|
+
name, // attributeName
|
|
251
|
+
null, // attributeNamespace
|
|
252
|
+
false, // sanitizeURL
|
|
253
|
+
false);
|
|
254
|
+
}); // These are HTML boolean attributes.
|
|
255
|
+
|
|
256
|
+
['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
|
|
257
|
+
// on the client side because the browsers are inconsistent. Instead we call focus().
|
|
258
|
+
'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
|
|
259
|
+
'itemScope'].forEach(function (name) {
|
|
260
|
+
properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
|
|
261
|
+
name.toLowerCase(), // attributeName
|
|
262
|
+
null, // attributeNamespace
|
|
263
|
+
false, // sanitizeURL
|
|
264
|
+
false);
|
|
265
|
+
}); // These are the few React props that we set as DOM properties
|
|
266
|
+
// rather than attributes. These are all booleans.
|
|
267
|
+
|
|
268
|
+
['checked', // Note: `option.selected` is not updated if `select.multiple` is
|
|
269
|
+
// disabled with `removeAttribute`. We have special logic for handling this.
|
|
270
|
+
'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list,
|
|
271
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
272
|
+
// instead in the assignment below.
|
|
273
|
+
].forEach(function (name) {
|
|
274
|
+
properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
|
|
275
|
+
name, // attributeName
|
|
276
|
+
null, // attributeNamespace
|
|
277
|
+
false, // sanitizeURL
|
|
278
|
+
false);
|
|
279
|
+
}); // These are HTML attributes that are "overloaded booleans": they behave like
|
|
280
|
+
// booleans, but can also accept a string value.
|
|
281
|
+
|
|
282
|
+
['capture', 'download' // NOTE: if you add a camelCased prop to this list,
|
|
283
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
284
|
+
// instead in the assignment below.
|
|
285
|
+
].forEach(function (name) {
|
|
286
|
+
properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
|
|
287
|
+
name, // attributeName
|
|
288
|
+
null, // attributeNamespace
|
|
289
|
+
false, // sanitizeURL
|
|
290
|
+
false);
|
|
291
|
+
}); // These are HTML attributes that must be positive numbers.
|
|
292
|
+
|
|
293
|
+
['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list,
|
|
294
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
295
|
+
// instead in the assignment below.
|
|
296
|
+
].forEach(function (name) {
|
|
297
|
+
properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
|
|
298
|
+
name, // attributeName
|
|
299
|
+
null, // attributeNamespace
|
|
300
|
+
false, // sanitizeURL
|
|
301
|
+
false);
|
|
302
|
+
}); // These are HTML attributes that must be numbers.
|
|
303
|
+
|
|
304
|
+
['rowSpan', 'start'].forEach(function (name) {
|
|
305
|
+
properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
|
|
306
|
+
name.toLowerCase(), // attributeName
|
|
307
|
+
null, // attributeNamespace
|
|
308
|
+
false, // sanitizeURL
|
|
309
|
+
false);
|
|
310
|
+
});
|
|
311
|
+
var CAMELIZE = /[\-\:]([a-z])/g;
|
|
312
|
+
|
|
313
|
+
var capitalize = function (token) {
|
|
314
|
+
return token[1].toUpperCase();
|
|
315
|
+
}; // This is a list of all SVG attributes that need special casing, namespacing,
|
|
316
|
+
// or boolean value assignment. Regular attributes that just accept strings
|
|
317
|
+
// and have the same names are omitted, just like in the HTML attribute filter.
|
|
318
|
+
// Some of these attributes can be hard to find. This list was created by
|
|
319
|
+
// scraping the MDN documentation.
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
['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,
|
|
323
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
324
|
+
// instead in the assignment below.
|
|
325
|
+
].forEach(function (attributeName) {
|
|
326
|
+
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
327
|
+
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
328
|
+
attributeName, null, // attributeNamespace
|
|
329
|
+
false, // sanitizeURL
|
|
330
|
+
false);
|
|
331
|
+
}); // String SVG attributes with the xlink namespace.
|
|
332
|
+
|
|
333
|
+
['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list,
|
|
334
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
335
|
+
// instead in the assignment below.
|
|
336
|
+
].forEach(function (attributeName) {
|
|
337
|
+
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
338
|
+
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
339
|
+
attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL
|
|
340
|
+
false);
|
|
341
|
+
}); // String SVG attributes with the xml namespace.
|
|
342
|
+
|
|
343
|
+
['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list,
|
|
344
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
345
|
+
// instead in the assignment below.
|
|
346
|
+
].forEach(function (attributeName) {
|
|
347
|
+
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
348
|
+
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
349
|
+
attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL
|
|
350
|
+
false);
|
|
351
|
+
}); // These attribute exists both in HTML and SVG.
|
|
352
|
+
// The attribute name is case-sensitive in SVG so we can't just use
|
|
353
|
+
// the React name like we do for attributes that exist only in HTML.
|
|
354
|
+
|
|
355
|
+
['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
|
|
356
|
+
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
|
|
357
|
+
attributeName.toLowerCase(), // attributeName
|
|
358
|
+
null, // attributeNamespace
|
|
359
|
+
false, // sanitizeURL
|
|
360
|
+
false);
|
|
361
|
+
}); // These attributes accept URLs. These must not allow javascript: URLS.
|
|
362
|
+
// These will also need to accept Trusted Types object in the future.
|
|
363
|
+
|
|
364
|
+
var xlinkHref = 'xlinkHref';
|
|
365
|
+
properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
|
|
366
|
+
'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL
|
|
367
|
+
false);
|
|
368
|
+
['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
|
|
369
|
+
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
|
|
370
|
+
attributeName.toLowerCase(), // attributeName
|
|
371
|
+
null, // attributeNamespace
|
|
372
|
+
true, // sanitizeURL
|
|
373
|
+
true);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* CSS properties which accept numbers but are not in units of "px".
|
|
378
|
+
*/
|
|
379
|
+
var isUnitlessNumber = {
|
|
380
|
+
animationIterationCount: true,
|
|
381
|
+
aspectRatio: true,
|
|
382
|
+
borderImageOutset: true,
|
|
383
|
+
borderImageSlice: true,
|
|
384
|
+
borderImageWidth: true,
|
|
385
|
+
boxFlex: true,
|
|
386
|
+
boxFlexGroup: true,
|
|
387
|
+
boxOrdinalGroup: true,
|
|
388
|
+
columnCount: true,
|
|
389
|
+
columns: true,
|
|
390
|
+
flex: true,
|
|
391
|
+
flexGrow: true,
|
|
392
|
+
flexPositive: true,
|
|
393
|
+
flexShrink: true,
|
|
394
|
+
flexNegative: true,
|
|
395
|
+
flexOrder: true,
|
|
396
|
+
gridArea: true,
|
|
397
|
+
gridRow: true,
|
|
398
|
+
gridRowEnd: true,
|
|
399
|
+
gridRowSpan: true,
|
|
400
|
+
gridRowStart: true,
|
|
401
|
+
gridColumn: true,
|
|
402
|
+
gridColumnEnd: true,
|
|
403
|
+
gridColumnSpan: true,
|
|
404
|
+
gridColumnStart: true,
|
|
405
|
+
fontWeight: true,
|
|
406
|
+
lineClamp: true,
|
|
407
|
+
lineHeight: true,
|
|
408
|
+
opacity: true,
|
|
409
|
+
order: true,
|
|
410
|
+
orphans: true,
|
|
411
|
+
tabSize: true,
|
|
412
|
+
widows: true,
|
|
413
|
+
zIndex: true,
|
|
414
|
+
zoom: true,
|
|
415
|
+
// SVG-related properties
|
|
416
|
+
fillOpacity: true,
|
|
417
|
+
floodOpacity: true,
|
|
418
|
+
stopOpacity: true,
|
|
419
|
+
strokeDasharray: true,
|
|
420
|
+
strokeDashoffset: true,
|
|
421
|
+
strokeMiterlimit: true,
|
|
422
|
+
strokeOpacity: true,
|
|
423
|
+
strokeWidth: true
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
|
427
|
+
* @param {string} key style name, eg: transitionDuration
|
|
428
|
+
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
|
429
|
+
* WebkitTransitionDuration
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
function prefixKey(prefix, key) {
|
|
433
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Support style names that may come passed in prefixed by adding permutations
|
|
437
|
+
* of vendor prefixes.
|
|
438
|
+
*/
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
|
|
442
|
+
// infinite loop, because it iterates over the newly added props too.
|
|
443
|
+
|
|
444
|
+
Object.keys(isUnitlessNumber).forEach(function (prop) {
|
|
445
|
+
prefixes.forEach(function (prefix) {
|
|
446
|
+
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
|
451
|
+
|
|
452
|
+
function isArray(a) {
|
|
453
|
+
return isArrayImpl(a);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
var startInlineScript = stringToPrecomputedChunk('<script>');
|
|
457
|
+
var endInlineScript = stringToPrecomputedChunk('</script>');
|
|
458
|
+
var startScriptSrc = stringToPrecomputedChunk('<script src="');
|
|
459
|
+
var startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
|
|
460
|
+
var endAsyncScript = stringToPrecomputedChunk('" async=""></script>'); // Allows us to keep track of what we've already written so we can refer back to it.
|
|
461
|
+
|
|
462
|
+
var textSeparator = stringToPrecomputedChunk('<!-- -->');
|
|
463
|
+
|
|
464
|
+
var styleAttributeStart = stringToPrecomputedChunk(' style="');
|
|
465
|
+
var styleAssign = stringToPrecomputedChunk(':');
|
|
466
|
+
var styleSeparator = stringToPrecomputedChunk(';');
|
|
467
|
+
|
|
468
|
+
var attributeSeparator = stringToPrecomputedChunk(' ');
|
|
469
|
+
var attributeAssign = stringToPrecomputedChunk('="');
|
|
470
|
+
var attributeEnd = stringToPrecomputedChunk('"');
|
|
471
|
+
var attributeEmptyString = stringToPrecomputedChunk('=""');
|
|
472
|
+
|
|
473
|
+
var endOfStartTag = stringToPrecomputedChunk('>');
|
|
474
|
+
var endOfStartTagSelfClosing = stringToPrecomputedChunk('/>');
|
|
475
|
+
|
|
476
|
+
var selectedMarkerAttribute = stringToPrecomputedChunk(' selected=""');
|
|
477
|
+
|
|
478
|
+
var leadingNewline = stringToPrecomputedChunk('\n');
|
|
479
|
+
|
|
480
|
+
var DOCTYPE = stringToPrecomputedChunk('<!DOCTYPE html>');
|
|
481
|
+
var endTag1 = stringToPrecomputedChunk('</');
|
|
482
|
+
var endTag2 = stringToPrecomputedChunk('>');
|
|
483
|
+
// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
|
|
484
|
+
// display. It's never visible to users. We use the template tag because it can be used in every
|
|
485
|
+
// type of parent. <script> tags also work in every other tag except <colgroup>.
|
|
486
|
+
|
|
487
|
+
var placeholder1 = stringToPrecomputedChunk('<template id="');
|
|
488
|
+
var placeholder2 = stringToPrecomputedChunk('"></template>');
|
|
489
|
+
|
|
490
|
+
var startCompletedSuspenseBoundary = stringToPrecomputedChunk('<!--$-->');
|
|
491
|
+
var startPendingSuspenseBoundary1 = stringToPrecomputedChunk('<!--$?--><template id="');
|
|
492
|
+
var startPendingSuspenseBoundary2 = stringToPrecomputedChunk('"></template>');
|
|
493
|
+
var startClientRenderedSuspenseBoundary = stringToPrecomputedChunk('<!--$!-->');
|
|
494
|
+
var endSuspenseBoundary = stringToPrecomputedChunk('<!--/$-->');
|
|
495
|
+
var startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
|
|
496
|
+
var startSegmentHTML2 = stringToPrecomputedChunk('">');
|
|
497
|
+
var endSegmentHTML = stringToPrecomputedChunk('</div>');
|
|
498
|
+
var startSegmentSVG = stringToPrecomputedChunk('<svg aria-hidden="true" style="display:none" id="');
|
|
499
|
+
var startSegmentSVG2 = stringToPrecomputedChunk('">');
|
|
500
|
+
var endSegmentSVG = stringToPrecomputedChunk('</svg>');
|
|
501
|
+
var startSegmentMathML = stringToPrecomputedChunk('<math aria-hidden="true" style="display:none" id="');
|
|
502
|
+
var startSegmentMathML2 = stringToPrecomputedChunk('">');
|
|
503
|
+
var endSegmentMathML = stringToPrecomputedChunk('</math>');
|
|
504
|
+
var startSegmentTable = stringToPrecomputedChunk('<table hidden id="');
|
|
505
|
+
var startSegmentTable2 = stringToPrecomputedChunk('">');
|
|
506
|
+
var endSegmentTable = stringToPrecomputedChunk('</table>');
|
|
507
|
+
var startSegmentTableBody = stringToPrecomputedChunk('<table hidden><tbody id="');
|
|
508
|
+
var startSegmentTableBody2 = stringToPrecomputedChunk('">');
|
|
509
|
+
var endSegmentTableBody = stringToPrecomputedChunk('</tbody></table>');
|
|
510
|
+
var startSegmentTableRow = stringToPrecomputedChunk('<table hidden><tr id="');
|
|
511
|
+
var startSegmentTableRow2 = stringToPrecomputedChunk('">');
|
|
512
|
+
var endSegmentTableRow = stringToPrecomputedChunk('</tr></table>');
|
|
513
|
+
var startSegmentColGroup = stringToPrecomputedChunk('<table hidden><colgroup id="');
|
|
514
|
+
var startSegmentColGroup2 = stringToPrecomputedChunk('">');
|
|
515
|
+
var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
|
|
516
|
+
// The following code is the source scripts that we then minify and inline below,
|
|
517
|
+
// with renamed function names that we hope don't collide:
|
|
518
|
+
// const COMMENT_NODE = 8;
|
|
519
|
+
// const SUSPENSE_START_DATA = '$';
|
|
520
|
+
// const SUSPENSE_END_DATA = '/$';
|
|
521
|
+
// const SUSPENSE_PENDING_START_DATA = '$?';
|
|
522
|
+
// const SUSPENSE_FALLBACK_START_DATA = '$!';
|
|
523
|
+
//
|
|
524
|
+
// function clientRenderBoundary(suspenseBoundaryID) {
|
|
525
|
+
// // Find the fallback's first element.
|
|
526
|
+
// const suspenseIdNode = document.getElementById(suspenseBoundaryID);
|
|
527
|
+
// if (!suspenseIdNode) {
|
|
528
|
+
// // The user must have already navigated away from this tree.
|
|
529
|
+
// // E.g. because the parent was hydrated.
|
|
530
|
+
// return;
|
|
531
|
+
// }
|
|
532
|
+
// // Find the boundary around the fallback. This is always the previous node.
|
|
533
|
+
// const suspenseNode = suspenseIdNode.previousSibling;
|
|
534
|
+
// // Tag it to be client rendered.
|
|
535
|
+
// suspenseNode.data = SUSPENSE_FALLBACK_START_DATA;
|
|
536
|
+
// // Tell React to retry it if the parent already hydrated.
|
|
537
|
+
// if (suspenseNode._reactRetry) {
|
|
538
|
+
// suspenseNode._reactRetry();
|
|
539
|
+
// }
|
|
540
|
+
// }
|
|
541
|
+
//
|
|
542
|
+
// function completeBoundary(suspenseBoundaryID, contentID) {
|
|
543
|
+
// // Find the fallback's first element.
|
|
544
|
+
// const suspenseIdNode = document.getElementById(suspenseBoundaryID);
|
|
545
|
+
// const contentNode = document.getElementById(contentID);
|
|
546
|
+
// // We'll detach the content node so that regardless of what happens next we don't leave in the tree.
|
|
547
|
+
// // This might also help by not causing recalcing each time we move a child from here to the target.
|
|
548
|
+
// contentNode.parentNode.removeChild(contentNode);
|
|
549
|
+
// if (!suspenseIdNode) {
|
|
550
|
+
// // The user must have already navigated away from this tree.
|
|
551
|
+
// // E.g. because the parent was hydrated. That's fine there's nothing to do
|
|
552
|
+
// // but we have to make sure that we already deleted the container node.
|
|
553
|
+
// return;
|
|
554
|
+
// }
|
|
555
|
+
// // Find the boundary around the fallback. This is always the previous node.
|
|
556
|
+
// const suspenseNode = suspenseIdNode.previousSibling;
|
|
557
|
+
//
|
|
558
|
+
// // Clear all the existing children. This is complicated because
|
|
559
|
+
// // there can be embedded Suspense boundaries in the fallback.
|
|
560
|
+
// // This is similar to clearSuspenseBoundary in ReactDOMHostConfig.
|
|
561
|
+
// // TODO: We could avoid this if we never emitted suspense boundaries in fallback trees.
|
|
562
|
+
// // They never hydrate anyway. However, currently we support incrementally loading the fallback.
|
|
563
|
+
// const parentInstance = suspenseNode.parentNode;
|
|
564
|
+
// let node = suspenseNode.nextSibling;
|
|
565
|
+
// let depth = 0;
|
|
566
|
+
// do {
|
|
567
|
+
// if (node && node.nodeType === COMMENT_NODE) {
|
|
568
|
+
// const data = node.data;
|
|
569
|
+
// if (data === SUSPENSE_END_DATA) {
|
|
570
|
+
// if (depth === 0) {
|
|
571
|
+
// break;
|
|
572
|
+
// } else {
|
|
573
|
+
// depth--;
|
|
574
|
+
// }
|
|
575
|
+
// } else if (
|
|
576
|
+
// data === SUSPENSE_START_DATA ||
|
|
577
|
+
// data === SUSPENSE_PENDING_START_DATA ||
|
|
578
|
+
// data === SUSPENSE_FALLBACK_START_DATA
|
|
579
|
+
// ) {
|
|
580
|
+
// depth++;
|
|
581
|
+
// }
|
|
582
|
+
// }
|
|
583
|
+
//
|
|
584
|
+
// const nextNode = node.nextSibling;
|
|
585
|
+
// parentInstance.removeChild(node);
|
|
586
|
+
// node = nextNode;
|
|
587
|
+
// } while (node);
|
|
588
|
+
//
|
|
589
|
+
// const endOfBoundary = node;
|
|
590
|
+
//
|
|
591
|
+
// // Insert all the children from the contentNode between the start and end of suspense boundary.
|
|
592
|
+
// while (contentNode.firstChild) {
|
|
593
|
+
// parentInstance.insertBefore(contentNode.firstChild, endOfBoundary);
|
|
594
|
+
// }
|
|
595
|
+
// suspenseNode.data = SUSPENSE_START_DATA;
|
|
596
|
+
// if (suspenseNode._reactRetry) {
|
|
597
|
+
// suspenseNode._reactRetry();
|
|
598
|
+
// }
|
|
599
|
+
// }
|
|
600
|
+
//
|
|
601
|
+
// function completeSegment(containerID, placeholderID) {
|
|
602
|
+
// const segmentContainer = document.getElementById(containerID);
|
|
603
|
+
// const placeholderNode = document.getElementById(placeholderID);
|
|
604
|
+
// // We always expect both nodes to exist here because, while we might
|
|
605
|
+
// // have navigated away from the main tree, we still expect the detached
|
|
606
|
+
// // tree to exist.
|
|
607
|
+
// segmentContainer.parentNode.removeChild(segmentContainer);
|
|
608
|
+
// while (segmentContainer.firstChild) {
|
|
609
|
+
// placeholderNode.parentNode.insertBefore(
|
|
610
|
+
// segmentContainer.firstChild,
|
|
611
|
+
// placeholderNode,
|
|
612
|
+
// );
|
|
613
|
+
// }
|
|
614
|
+
// placeholderNode.parentNode.removeChild(placeholderNode);
|
|
615
|
+
// }
|
|
616
|
+
|
|
617
|
+
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)}';
|
|
618
|
+
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()}}';
|
|
619
|
+
var clientRenderFunction = 'function $RX(a){if(a=document.getElementById(a))a=a.previousSibling,a.data="$!",a._reactRetry&&a._reactRetry()}';
|
|
620
|
+
var completeSegmentScript1Full = stringToPrecomputedChunk(completeSegmentFunction + ';$RS("');
|
|
621
|
+
var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
|
|
622
|
+
var completeSegmentScript2 = stringToPrecomputedChunk('","');
|
|
623
|
+
var completeSegmentScript3 = stringToPrecomputedChunk('")</script>');
|
|
624
|
+
var completeBoundaryScript1Full = stringToPrecomputedChunk(completeBoundaryFunction + ';$RC("');
|
|
625
|
+
var completeBoundaryScript1Partial = stringToPrecomputedChunk('$RC("');
|
|
626
|
+
var completeBoundaryScript2 = stringToPrecomputedChunk('","');
|
|
627
|
+
var completeBoundaryScript3 = stringToPrecomputedChunk('")</script>');
|
|
628
|
+
var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderFunction + ';$RX("');
|
|
629
|
+
var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("');
|
|
630
|
+
var clientRenderScript2 = stringToPrecomputedChunk('")</script>');
|
|
631
|
+
|
|
632
|
+
var rendererSigil;
|
|
633
|
+
|
|
634
|
+
{
|
|
635
|
+
// Use this to detect multiple renderers using the same context
|
|
636
|
+
rendererSigil = {};
|
|
637
|
+
} // Used to store the parent path of all context overrides in a shared linked list.
|
|
638
|
+
// Forming a reverse tree.
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
|
|
642
|
+
// This global (actually thread local) state represents what state all those "current",
|
|
643
|
+
// fields are currently in.
|
|
644
|
+
|
|
645
|
+
var currentActiveSnapshot = null;
|
|
646
|
+
|
|
647
|
+
function popNode(prev) {
|
|
648
|
+
{
|
|
649
|
+
prev.context._currentValue = prev.parentValue;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function pushNode(next) {
|
|
654
|
+
{
|
|
655
|
+
next.context._currentValue = next.value;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
function popToNearestCommonAncestor(prev, next) {
|
|
660
|
+
if (prev === next) ; else {
|
|
661
|
+
popNode(prev);
|
|
662
|
+
var parentPrev = prev.parent;
|
|
663
|
+
var parentNext = next.parent;
|
|
664
|
+
|
|
665
|
+
if (parentPrev === null) {
|
|
666
|
+
if (parentNext !== null) {
|
|
667
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
|
75
668
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (typeof destination.cork === 'function') {
|
|
80
|
-
destination.cork();
|
|
669
|
+
} else {
|
|
670
|
+
if (parentNext === null) {
|
|
671
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
|
81
672
|
}
|
|
673
|
+
|
|
674
|
+
popToNearestCommonAncestor(parentPrev, parentNext); // On the way back, we push the new ones that weren't common.
|
|
675
|
+
|
|
676
|
+
pushNode(next);
|
|
82
677
|
}
|
|
83
|
-
|
|
84
|
-
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function popAllPrevious(prev) {
|
|
682
|
+
popNode(prev);
|
|
683
|
+
var parentPrev = prev.parent;
|
|
85
684
|
|
|
86
|
-
|
|
685
|
+
if (parentPrev !== null) {
|
|
686
|
+
popAllPrevious(parentPrev);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function pushAllNext(next) {
|
|
691
|
+
var parentNext = next.parent;
|
|
692
|
+
|
|
693
|
+
if (parentNext !== null) {
|
|
694
|
+
pushAllNext(parentNext);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
pushNode(next);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function popPreviousToCommonLevel(prev, next) {
|
|
701
|
+
popNode(prev);
|
|
702
|
+
var parentPrev = prev.parent;
|
|
703
|
+
|
|
704
|
+
if (parentPrev === null) {
|
|
705
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (parentPrev.depth === next.depth) {
|
|
709
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
|
710
|
+
popToNearestCommonAncestor(parentPrev, next);
|
|
711
|
+
} else {
|
|
712
|
+
// We must still be deeper.
|
|
713
|
+
popPreviousToCommonLevel(parentPrev, next);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
function popNextToCommonLevel(prev, next) {
|
|
718
|
+
var parentNext = next.parent;
|
|
719
|
+
|
|
720
|
+
if (parentNext === null) {
|
|
721
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
if (prev.depth === parentNext.depth) {
|
|
725
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
|
726
|
+
popToNearestCommonAncestor(prev, parentNext);
|
|
727
|
+
} else {
|
|
728
|
+
// We must still be deeper.
|
|
729
|
+
popNextToCommonLevel(prev, parentNext);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
pushNode(next);
|
|
733
|
+
} // Perform context switching to the new snapshot.
|
|
734
|
+
// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
|
|
735
|
+
// updating all the context's current values. That way reads, always just read the current value.
|
|
736
|
+
// At the cost of updating contexts even if they're never read by this subtree.
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
function switchContext(newSnapshot) {
|
|
740
|
+
// The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
|
|
741
|
+
// We also need to update any new contexts that are now on the stack with the deepest value.
|
|
742
|
+
// The easiest way to update new contexts is to just reapply them in reverse order from the
|
|
743
|
+
// perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
|
|
744
|
+
// for that. Therefore this algorithm is recursive.
|
|
745
|
+
// 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
|
|
746
|
+
// 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
|
|
747
|
+
// 3) Then we reapply new contexts on the way back up the stack.
|
|
748
|
+
var prev = currentActiveSnapshot;
|
|
749
|
+
var next = newSnapshot;
|
|
750
|
+
|
|
751
|
+
if (prev !== next) {
|
|
752
|
+
if (prev === null) {
|
|
753
|
+
// $FlowFixMe: This has to be non-null since it's not equal to prev.
|
|
754
|
+
pushAllNext(next);
|
|
755
|
+
} else if (next === null) {
|
|
756
|
+
popAllPrevious(prev);
|
|
757
|
+
} else if (prev.depth === next.depth) {
|
|
758
|
+
popToNearestCommonAncestor(prev, next);
|
|
759
|
+
} else if (prev.depth > next.depth) {
|
|
760
|
+
popPreviousToCommonLevel(prev, next);
|
|
761
|
+
} else {
|
|
762
|
+
popNextToCommonLevel(prev, next);
|
|
87
763
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
764
|
+
|
|
765
|
+
currentActiveSnapshot = next;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
function pushProvider(context, nextValue) {
|
|
769
|
+
var prevValue;
|
|
770
|
+
|
|
771
|
+
{
|
|
772
|
+
prevValue = context._currentValue;
|
|
773
|
+
context._currentValue = nextValue;
|
|
774
|
+
|
|
775
|
+
{
|
|
776
|
+
if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) {
|
|
777
|
+
error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
|
|
92
778
|
}
|
|
779
|
+
|
|
780
|
+
context._currentRenderer = rendererSigil;
|
|
93
781
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
var prevNode = currentActiveSnapshot;
|
|
785
|
+
var newNode = {
|
|
786
|
+
parent: prevNode,
|
|
787
|
+
depth: prevNode === null ? 0 : prevNode.depth + 1,
|
|
788
|
+
context: context,
|
|
789
|
+
parentValue: prevValue,
|
|
790
|
+
value: nextValue
|
|
791
|
+
};
|
|
792
|
+
currentActiveSnapshot = newNode;
|
|
793
|
+
return newNode;
|
|
794
|
+
}
|
|
795
|
+
function popProvider() {
|
|
796
|
+
var prevSnapshot = currentActiveSnapshot;
|
|
104
797
|
|
|
105
|
-
|
|
106
|
-
|
|
798
|
+
if (prevSnapshot === null) {
|
|
799
|
+
throw new Error('Tried to pop a Context at the root of the app. This is a bug in React.');
|
|
800
|
+
}
|
|
107
801
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
802
|
+
{
|
|
803
|
+
var value = prevSnapshot.parentValue;
|
|
111
804
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
117
|
-
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
|
118
|
-
return stringToChunk(row);
|
|
119
|
-
}
|
|
120
|
-
function processModelChunk(request, id, model) {
|
|
121
|
-
var json = stringify(model, request.toJSON);
|
|
122
|
-
var row = serializeRowHeader('J', id) + json + '\n';
|
|
123
|
-
return stringToChunk(row);
|
|
124
|
-
}
|
|
125
|
-
function processModuleChunk(request, id, moduleMetaData) {
|
|
126
|
-
var json = stringify(moduleMetaData);
|
|
127
|
-
var row = serializeRowHeader('M', id) + json + '\n';
|
|
128
|
-
return stringToChunk(row);
|
|
129
|
-
}
|
|
130
|
-
function processSymbolChunk(request, id, name) {
|
|
131
|
-
var json = stringify(name);
|
|
132
|
-
var row = serializeRowHeader('S', id) + json + '\n';
|
|
133
|
-
return stringToChunk(row);
|
|
805
|
+
if (value === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
|
|
806
|
+
prevSnapshot.context._currentValue = prevSnapshot.context._defaultValue;
|
|
807
|
+
} else {
|
|
808
|
+
prevSnapshot.context._currentValue = value;
|
|
134
809
|
}
|
|
810
|
+
}
|
|
135
811
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
812
|
+
return currentActiveSnapshot = prevSnapshot.parent;
|
|
813
|
+
}
|
|
814
|
+
function getActiveContext() {
|
|
815
|
+
return currentActiveSnapshot;
|
|
816
|
+
}
|
|
817
|
+
function readContext(context) {
|
|
818
|
+
var value = context._currentValue ;
|
|
819
|
+
return value;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function readContext$1(context) {
|
|
823
|
+
{
|
|
824
|
+
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
|
|
825
|
+
error('Only ServerContext is supported in Flight');
|
|
143
826
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
name: moduleReference.name,
|
|
148
|
-
};
|
|
827
|
+
|
|
828
|
+
if (currentCache === null) {
|
|
829
|
+
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().');
|
|
149
830
|
}
|
|
831
|
+
}
|
|
150
832
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
var REACT_LAZY_TYPE = 0xead4;
|
|
168
|
-
var REACT_SCOPE_TYPE = 0xead7;
|
|
169
|
-
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
|
170
|
-
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
|
171
|
-
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
|
172
|
-
var REACT_CACHE_TYPE = 0xeae4;
|
|
173
|
-
|
|
174
|
-
if (typeof Symbol === 'function' && Symbol.for) {
|
|
175
|
-
var symbolFor = Symbol.for;
|
|
176
|
-
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
|
177
|
-
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
|
178
|
-
REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
|
|
179
|
-
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
|
180
|
-
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
|
181
|
-
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
|
182
|
-
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
|
183
|
-
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
|
184
|
-
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
|
185
|
-
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
|
186
|
-
REACT_MEMO_TYPE = symbolFor('react.memo');
|
|
187
|
-
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
|
188
|
-
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
|
189
|
-
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
|
190
|
-
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
|
191
|
-
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
|
192
|
-
REACT_CACHE_TYPE = symbolFor('react.cache');
|
|
833
|
+
return readContext(context);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
var Dispatcher = {
|
|
837
|
+
useMemo: function (nextCreate) {
|
|
838
|
+
return nextCreate();
|
|
839
|
+
},
|
|
840
|
+
useCallback: function (callback) {
|
|
841
|
+
return callback;
|
|
842
|
+
},
|
|
843
|
+
useDebugValue: function () {},
|
|
844
|
+
useDeferredValue: unsupportedHook,
|
|
845
|
+
useTransition: unsupportedHook,
|
|
846
|
+
getCacheForType: function (resourceType) {
|
|
847
|
+
if (!currentCache) {
|
|
848
|
+
throw new Error('Reading the cache is only supported while rendering.');
|
|
193
849
|
}
|
|
194
850
|
|
|
195
|
-
var
|
|
851
|
+
var entry = currentCache.get(resourceType);
|
|
852
|
+
|
|
853
|
+
if (entry === undefined) {
|
|
854
|
+
entry = resourceType(); // TODO: Warn if undefined?
|
|
196
855
|
|
|
197
|
-
|
|
198
|
-
return isArrayImpl(a);
|
|
856
|
+
currentCache.set(resourceType, entry);
|
|
199
857
|
}
|
|
200
858
|
|
|
201
|
-
|
|
859
|
+
return entry;
|
|
860
|
+
},
|
|
861
|
+
readContext: readContext$1,
|
|
862
|
+
useContext: readContext$1,
|
|
863
|
+
useReducer: unsupportedHook,
|
|
864
|
+
useRef: unsupportedHook,
|
|
865
|
+
useState: unsupportedHook,
|
|
866
|
+
useInsertionEffect: unsupportedHook,
|
|
867
|
+
useLayoutEffect: unsupportedHook,
|
|
868
|
+
useImperativeHandle: unsupportedHook,
|
|
869
|
+
useEffect: unsupportedHook,
|
|
870
|
+
useId: unsupportedHook,
|
|
871
|
+
useMutableSource: unsupportedHook,
|
|
872
|
+
useSyncExternalStore: unsupportedHook,
|
|
873
|
+
useCacheRefresh: function () {
|
|
874
|
+
return unsupportedRefresh;
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
function unsupportedHook() {
|
|
879
|
+
throw new Error('This Hook is not supported in Server Components.');
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
function unsupportedRefresh() {
|
|
883
|
+
if (!currentCache) {
|
|
884
|
+
throw new Error('Refreshing the cache is not supported in Server Components.');
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
var currentCache = null;
|
|
889
|
+
function setCurrentCache(cache) {
|
|
890
|
+
currentCache = cache;
|
|
891
|
+
return currentCache;
|
|
892
|
+
}
|
|
893
|
+
function getCurrentCache() {
|
|
894
|
+
return currentCache;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
var ContextRegistry = ReactSharedInternals.ContextRegistry;
|
|
898
|
+
function getOrCreateServerContext(globalName) {
|
|
899
|
+
if (!ContextRegistry[globalName]) {
|
|
900
|
+
ContextRegistry[globalName] = React.createServerContext(globalName, REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
|
|
901
|
+
}
|
|
202
902
|
|
|
203
|
-
|
|
204
|
-
|
|
903
|
+
return ContextRegistry[globalName];
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
907
|
+
|
|
908
|
+
function defaultErrorHandler(error) {
|
|
909
|
+
console['error'](error); // Don't transform to our wrapper
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
var OPEN = 0;
|
|
913
|
+
var CLOSING = 1;
|
|
914
|
+
var CLOSED = 2;
|
|
915
|
+
function createRequest(model, bundlerConfig, onError, context) {
|
|
916
|
+
var pingedSegments = [];
|
|
917
|
+
var request = {
|
|
918
|
+
status: OPEN,
|
|
919
|
+
fatalError: null,
|
|
920
|
+
destination: null,
|
|
921
|
+
bundlerConfig: bundlerConfig,
|
|
922
|
+
cache: new Map(),
|
|
923
|
+
nextChunkId: 0,
|
|
924
|
+
pendingChunks: 0,
|
|
925
|
+
pingedSegments: pingedSegments,
|
|
926
|
+
completedModuleChunks: [],
|
|
927
|
+
completedJSONChunks: [],
|
|
928
|
+
completedErrorChunks: [],
|
|
929
|
+
writtenSymbols: new Map(),
|
|
930
|
+
writtenModules: new Map(),
|
|
931
|
+
writtenProviders: new Map(),
|
|
932
|
+
onError: onError === undefined ? defaultErrorHandler : onError,
|
|
933
|
+
toJSON: function (key, value) {
|
|
934
|
+
return resolveModelToJSON(request, this, key, value);
|
|
205
935
|
}
|
|
936
|
+
};
|
|
937
|
+
request.pendingChunks++;
|
|
938
|
+
var rootContext = createRootContext(context);
|
|
939
|
+
var rootSegment = createSegment(request, model, rootContext);
|
|
940
|
+
pingedSegments.push(rootSegment);
|
|
941
|
+
return request;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function createRootContext(reqContext) {
|
|
945
|
+
return importServerContexts(reqContext);
|
|
946
|
+
}
|
|
206
947
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
948
|
+
var POP = {};
|
|
949
|
+
|
|
950
|
+
function attemptResolveElement(type, key, ref, props) {
|
|
951
|
+
if (ref !== null && ref !== undefined) {
|
|
952
|
+
// When the ref moves to the regular props object this will implicitly
|
|
953
|
+
// throw for functions. We could probably relax it to a DEV warning for other
|
|
954
|
+
// cases.
|
|
955
|
+
throw new Error('Refs cannot be used in server components, nor passed to client components.');
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
if (typeof type === 'function') {
|
|
959
|
+
// This is a server-side component.
|
|
960
|
+
return type(props);
|
|
961
|
+
} else if (typeof type === 'string') {
|
|
962
|
+
// This is a host element. E.g. HTML.
|
|
963
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
964
|
+
} else if (typeof type === 'symbol') {
|
|
965
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
966
|
+
// For key-less fragments, we add a small optimization to avoid serializing
|
|
967
|
+
// it as a wrapper.
|
|
968
|
+
// TODO: If a key is specified, we should propagate its key to any children.
|
|
969
|
+
// Same as if a server component has a key.
|
|
970
|
+
return props.children;
|
|
971
|
+
} // This might be a built-in React component. We'll let the client decide.
|
|
972
|
+
// Any built-in works as long as its props are serializable.
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
976
|
+
} else if (type != null && typeof type === 'object') {
|
|
977
|
+
if (isModuleReference(type)) {
|
|
978
|
+
// This is a reference to a client component.
|
|
979
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
235
980
|
}
|
|
236
981
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
982
|
+
switch (type.$$typeof) {
|
|
983
|
+
case REACT_LAZY_TYPE:
|
|
984
|
+
{
|
|
985
|
+
var payload = type._payload;
|
|
986
|
+
var init = type._init;
|
|
987
|
+
var wrappedType = init(payload);
|
|
988
|
+
return attemptResolveElement(wrappedType, key, ref, props);
|
|
989
|
+
}
|
|
246
990
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
// This is a host element. E.g. HTML.
|
|
252
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
253
|
-
} else if (typeof type === 'symbol') {
|
|
254
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
|
255
|
-
// For key-less fragments, we add a small optimization to avoid serializing
|
|
256
|
-
// it as a wrapper.
|
|
257
|
-
// TODO: If a key is specified, we should propagate its key to any children.
|
|
258
|
-
// Same as if a server component has a key.
|
|
259
|
-
return props.children;
|
|
260
|
-
} // This might be a built-in React component. We'll let the client decide.
|
|
261
|
-
// Any built-in works as long as its props are serializable.
|
|
262
|
-
|
|
263
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
264
|
-
} else if (type != null && typeof type === 'object') {
|
|
265
|
-
if (isModuleReference(type)) {
|
|
266
|
-
// This is a reference to a client component.
|
|
267
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
991
|
+
case REACT_FORWARD_REF_TYPE:
|
|
992
|
+
{
|
|
993
|
+
var render = type.render;
|
|
994
|
+
return render(props, undefined);
|
|
268
995
|
}
|
|
269
996
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
997
|
+
case REACT_MEMO_TYPE:
|
|
998
|
+
{
|
|
999
|
+
return attemptResolveElement(type.type, key, ref, props);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
case REACT_PROVIDER_TYPE:
|
|
1003
|
+
{
|
|
1004
|
+
pushProvider(type._context, props.value);
|
|
1005
|
+
|
|
1006
|
+
{
|
|
1007
|
+
var extraKeys = Object.keys(props).filter(function (value) {
|
|
1008
|
+
if (value === 'children' || value === 'value') {
|
|
1009
|
+
return false;
|
|
1010
|
+
}
|
|
275
1011
|
|
|
276
|
-
|
|
277
|
-
|
|
1012
|
+
return true;
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
if (extraKeys.length !== 0) {
|
|
1016
|
+
error('ServerContext can only have a value prop and children. Found: %s', JSON.stringify(extraKeys));
|
|
1017
|
+
}
|
|
278
1018
|
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
1019
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
1020
|
+
return [REACT_ELEMENT_TYPE, type, key, // Rely on __popProvider being serialized last to pop the provider.
|
|
1021
|
+
{
|
|
1022
|
+
value: props.value,
|
|
1023
|
+
children: props.children,
|
|
1024
|
+
__pop: POP
|
|
1025
|
+
}];
|
|
1026
|
+
}
|
|
286
1027
|
}
|
|
1028
|
+
}
|
|
287
1029
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
pingedSegments.push(segment);
|
|
1030
|
+
throw new Error("Unsupported server component type: " + describeValueForErrorMessage(type));
|
|
1031
|
+
}
|
|
291
1032
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
}
|
|
1033
|
+
function pingSegment(request, segment) {
|
|
1034
|
+
var pingedSegments = request.pingedSegments;
|
|
1035
|
+
pingedSegments.push(segment);
|
|
298
1036
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return pingSegment(request, segment);
|
|
306
|
-
},
|
|
307
|
-
};
|
|
308
|
-
return segment;
|
|
309
|
-
}
|
|
1037
|
+
if (pingedSegments.length === 1) {
|
|
1038
|
+
scheduleWork(function () {
|
|
1039
|
+
return performWork(request);
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
310
1043
|
|
|
311
|
-
|
|
312
|
-
|
|
1044
|
+
function createSegment(request, model, context) {
|
|
1045
|
+
var id = request.nextChunkId++;
|
|
1046
|
+
var segment = {
|
|
1047
|
+
id: id,
|
|
1048
|
+
model: model,
|
|
1049
|
+
context: context,
|
|
1050
|
+
ping: function () {
|
|
1051
|
+
return pingSegment(request, segment);
|
|
313
1052
|
}
|
|
1053
|
+
};
|
|
1054
|
+
return segment;
|
|
1055
|
+
}
|
|
314
1056
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
1057
|
+
function serializeByValueID(id) {
|
|
1058
|
+
return '$' + id.toString(16);
|
|
1059
|
+
}
|
|
318
1060
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
1061
|
+
function serializeByRefID(id) {
|
|
1062
|
+
return '@' + id.toString(16);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
function escapeStringValue(value) {
|
|
1066
|
+
if (value[0] === '$' || value[0] === '@') {
|
|
1067
|
+
// We need to escape $ or @ prefixed strings since we use those to encode
|
|
1068
|
+
// references to IDs and as special symbol values.
|
|
1069
|
+
return '$' + value;
|
|
1070
|
+
} else {
|
|
1071
|
+
return value;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
328
1074
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
1075
|
+
function isObjectPrototype(object) {
|
|
1076
|
+
if (!object) {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
333
1079
|
|
|
334
|
-
|
|
1080
|
+
var ObjectPrototype = Object.prototype;
|
|
335
1081
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
1082
|
+
if (object === ObjectPrototype) {
|
|
1083
|
+
return true;
|
|
1084
|
+
} // It might be an object from a different Realm which is
|
|
1085
|
+
// still just a plain simple object.
|
|
340
1086
|
|
|
341
|
-
if (Object.getPrototypeOf(object)) {
|
|
342
|
-
return false;
|
|
343
|
-
}
|
|
344
1087
|
|
|
345
|
-
|
|
1088
|
+
if (Object.getPrototypeOf(object)) {
|
|
1089
|
+
return false;
|
|
1090
|
+
}
|
|
346
1091
|
|
|
347
|
-
|
|
348
|
-
if (!(names[i] in ObjectPrototype)) {
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
1092
|
+
var names = Object.getOwnPropertyNames(object);
|
|
352
1093
|
|
|
353
|
-
|
|
1094
|
+
for (var i = 0; i < names.length; i++) {
|
|
1095
|
+
if (!(names[i] in ObjectPrototype)) {
|
|
1096
|
+
return false;
|
|
354
1097
|
}
|
|
1098
|
+
}
|
|
355
1099
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return false;
|
|
359
|
-
}
|
|
1100
|
+
return true;
|
|
1101
|
+
}
|
|
360
1102
|
|
|
361
|
-
|
|
1103
|
+
function isSimpleObject(object) {
|
|
1104
|
+
if (!isObjectPrototype(Object.getPrototypeOf(object))) {
|
|
1105
|
+
return false;
|
|
1106
|
+
}
|
|
362
1107
|
|
|
363
|
-
|
|
364
|
-
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
|
1108
|
+
var names = Object.getOwnPropertyNames(object);
|
|
365
1109
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
1110
|
+
for (var i = 0; i < names.length; i++) {
|
|
1111
|
+
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
|
369
1112
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
typeof descriptor.get === 'function'
|
|
374
|
-
) {
|
|
375
|
-
// React adds key and ref getters to props objects to issue warnings.
|
|
376
|
-
// Those getters will not be transferred to the client, but that's ok,
|
|
377
|
-
// so we'll special case them.
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
1113
|
+
if (!descriptor) {
|
|
1114
|
+
return false;
|
|
1115
|
+
}
|
|
380
1116
|
|
|
381
|
-
|
|
382
|
-
|
|
1117
|
+
if (!descriptor.enumerable) {
|
|
1118
|
+
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
|
1119
|
+
// React adds key and ref getters to props objects to issue warnings.
|
|
1120
|
+
// Those getters will not be transferred to the client, but that's ok,
|
|
1121
|
+
// so we'll special case them.
|
|
1122
|
+
continue;
|
|
383
1123
|
}
|
|
384
1124
|
|
|
385
|
-
return
|
|
1125
|
+
return false;
|
|
386
1126
|
}
|
|
1127
|
+
}
|
|
387
1128
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
|
391
|
-
return p0;
|
|
392
|
-
});
|
|
393
|
-
}
|
|
1129
|
+
return true;
|
|
1130
|
+
}
|
|
394
1131
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
1132
|
+
function objectName(object) {
|
|
1133
|
+
var name = Object.prototype.toString.call(object);
|
|
1134
|
+
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
|
1135
|
+
return p0;
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
399
1138
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
value.length <= 10 ? value : value.substr(0, 10) + '...'
|
|
405
|
-
);
|
|
406
|
-
}
|
|
1139
|
+
function describeKeyForErrorMessage(key) {
|
|
1140
|
+
var encodedKey = JSON.stringify(key);
|
|
1141
|
+
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
|
1142
|
+
}
|
|
407
1143
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
1144
|
+
function describeValueForErrorMessage(value) {
|
|
1145
|
+
switch (typeof value) {
|
|
1146
|
+
case 'string':
|
|
1147
|
+
{
|
|
1148
|
+
return JSON.stringify(value.length <= 10 ? value : value.substr(0, 10) + '...');
|
|
1149
|
+
}
|
|
412
1150
|
|
|
413
|
-
|
|
1151
|
+
case 'object':
|
|
1152
|
+
{
|
|
1153
|
+
if (isArray(value)) {
|
|
1154
|
+
return '[...]';
|
|
1155
|
+
}
|
|
414
1156
|
|
|
415
|
-
|
|
416
|
-
return '{...}';
|
|
417
|
-
}
|
|
1157
|
+
var name = objectName(value);
|
|
418
1158
|
|
|
419
|
-
|
|
1159
|
+
if (name === 'Object') {
|
|
1160
|
+
return '{...}';
|
|
420
1161
|
}
|
|
421
1162
|
|
|
422
|
-
|
|
423
|
-
return 'function';
|
|
424
|
-
|
|
425
|
-
default:
|
|
426
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
427
|
-
return String(value);
|
|
1163
|
+
return name;
|
|
428
1164
|
}
|
|
429
|
-
}
|
|
430
1165
|
|
|
431
|
-
function
|
|
432
|
-
|
|
433
|
-
var str = '['; // $FlowFixMe: Should be refined by now.
|
|
1166
|
+
case 'function':
|
|
1167
|
+
return 'function';
|
|
434
1168
|
|
|
435
|
-
|
|
1169
|
+
default:
|
|
1170
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
1171
|
+
return String(value);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
436
1174
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
1175
|
+
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1176
|
+
if (isArray(objectOrArray)) {
|
|
1177
|
+
var str = '[';
|
|
1178
|
+
var array = objectOrArray;
|
|
441
1179
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1180
|
+
for (var i = 0; i < array.length; i++) {
|
|
1181
|
+
if (i > 0) {
|
|
1182
|
+
str += ', ';
|
|
1183
|
+
}
|
|
446
1184
|
|
|
447
|
-
|
|
1185
|
+
if (i > 6) {
|
|
1186
|
+
str += '...';
|
|
1187
|
+
break;
|
|
1188
|
+
}
|
|
448
1189
|
|
|
449
|
-
|
|
450
|
-
'' + i === expandedName &&
|
|
451
|
-
typeof _value === 'object' &&
|
|
452
|
-
_value !== null
|
|
453
|
-
) {
|
|
454
|
-
str += describeObjectForErrorMessage(_value);
|
|
455
|
-
} else {
|
|
456
|
-
str += describeValueForErrorMessage(_value);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
1190
|
+
var _value = array[i];
|
|
459
1191
|
|
|
460
|
-
|
|
461
|
-
|
|
1192
|
+
if ('' + i === expandedName && typeof _value === 'object' && _value !== null) {
|
|
1193
|
+
str += describeObjectForErrorMessage(_value);
|
|
462
1194
|
} else {
|
|
463
|
-
|
|
1195
|
+
str += describeValueForErrorMessage(_value);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
464
1198
|
|
|
465
|
-
|
|
466
|
-
|
|
1199
|
+
str += ']';
|
|
1200
|
+
return str;
|
|
1201
|
+
} else {
|
|
1202
|
+
var _str = '{';
|
|
1203
|
+
var object = objectOrArray;
|
|
1204
|
+
var names = Object.keys(object);
|
|
467
1205
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
1206
|
+
for (var _i = 0; _i < names.length; _i++) {
|
|
1207
|
+
if (_i > 0) {
|
|
1208
|
+
_str += ', ';
|
|
1209
|
+
}
|
|
472
1210
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
1211
|
+
if (_i > 6) {
|
|
1212
|
+
_str += '...';
|
|
1213
|
+
break;
|
|
1214
|
+
}
|
|
477
1215
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
if (
|
|
483
|
-
name === expandedName &&
|
|
484
|
-
typeof _value2 === 'object' &&
|
|
485
|
-
_value2 !== null
|
|
486
|
-
) {
|
|
487
|
-
_str += describeObjectForErrorMessage(_value2);
|
|
488
|
-
} else {
|
|
489
|
-
_str += describeValueForErrorMessage(_value2);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
1216
|
+
var name = names[_i];
|
|
1217
|
+
_str += describeKeyForErrorMessage(name) + ': ';
|
|
1218
|
+
var _value2 = object[name];
|
|
492
1219
|
|
|
493
|
-
|
|
494
|
-
|
|
1220
|
+
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
|
1221
|
+
_str += describeObjectForErrorMessage(_value2);
|
|
1222
|
+
} else {
|
|
1223
|
+
_str += describeValueForErrorMessage(_value2);
|
|
495
1224
|
}
|
|
496
1225
|
}
|
|
497
1226
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
if (typeof originalValue === 'object' && originalValue !== value) {
|
|
504
|
-
error(
|
|
505
|
-
'Only plain objects can be passed to client components from server components. ' +
|
|
506
|
-
'Objects with toJSON methods are not supported. Convert it manually ' +
|
|
507
|
-
'to a simple value before passing it to props. ' +
|
|
508
|
-
'Remove %s from these props: %s',
|
|
509
|
-
describeKeyForErrorMessage(key),
|
|
510
|
-
describeObjectForErrorMessage(parent)
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
} // Special Symbols
|
|
1227
|
+
_str += '}';
|
|
1228
|
+
return _str;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
514
1231
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
1232
|
+
var insideContextProps = null;
|
|
1233
|
+
var isInsideContextValue = false;
|
|
1234
|
+
function resolveModelToJSON(request, parent, key, value) {
|
|
1235
|
+
{
|
|
1236
|
+
// $FlowFixMe
|
|
1237
|
+
var originalValue = parent[key];
|
|
518
1238
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
} // Resolve server components.
|
|
524
|
-
|
|
525
|
-
while (
|
|
526
|
-
typeof value === 'object' &&
|
|
527
|
-
value !== null &&
|
|
528
|
-
value.$$typeof === REACT_ELEMENT_TYPE
|
|
529
|
-
) {
|
|
530
|
-
// TODO: Concatenate keys of parents onto children.
|
|
531
|
-
var element = value;
|
|
532
|
-
|
|
533
|
-
try {
|
|
534
|
-
// Attempt to render the server component.
|
|
535
|
-
value = attemptResolveElement(
|
|
536
|
-
element.type,
|
|
537
|
-
element.key,
|
|
538
|
-
element.ref,
|
|
539
|
-
element.props
|
|
540
|
-
);
|
|
541
|
-
} catch (x) {
|
|
542
|
-
if (
|
|
543
|
-
typeof x === 'object' &&
|
|
544
|
-
x !== null &&
|
|
545
|
-
typeof x.then === 'function'
|
|
546
|
-
) {
|
|
547
|
-
// Something suspended, we'll need to create a new segment and resolve it later.
|
|
548
|
-
request.pendingChunks++;
|
|
549
|
-
var newSegment = createSegment(request, value);
|
|
550
|
-
var ping = newSegment.ping;
|
|
551
|
-
x.then(ping, ping);
|
|
552
|
-
return serializeByRefID(newSegment.id);
|
|
553
|
-
} else {
|
|
554
|
-
reportError(request, x); // Something errored. We'll still send everything we have up until this point.
|
|
555
|
-
// We'll replace this element with a lazy reference that throws on the client
|
|
556
|
-
// once it gets rendered.
|
|
557
|
-
|
|
558
|
-
request.pendingChunks++;
|
|
559
|
-
var errorId = request.nextChunkId++;
|
|
560
|
-
emitErrorChunk(request, errorId, x);
|
|
561
|
-
return serializeByRefID(errorId);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}
|
|
1239
|
+
if (typeof originalValue === 'object' && originalValue !== value) {
|
|
1240
|
+
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));
|
|
1241
|
+
}
|
|
1242
|
+
} // Special Symbols
|
|
565
1243
|
|
|
566
|
-
if (value === null) {
|
|
567
|
-
return null;
|
|
568
|
-
}
|
|
569
1244
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
var writtenModules = request.writtenModules;
|
|
575
|
-
var existingId = writtenModules.get(moduleKey);
|
|
576
|
-
|
|
577
|
-
if (existingId !== undefined) {
|
|
578
|
-
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
|
579
|
-
// If we're encoding the "type" of an element, we can refer
|
|
580
|
-
// to that by a lazy reference instead of directly since React
|
|
581
|
-
// knows how to deal with lazy values. This lets us suspend
|
|
582
|
-
// on this component rather than its parent until the code has
|
|
583
|
-
// loaded.
|
|
584
|
-
return serializeByRefID(existingId);
|
|
585
|
-
}
|
|
1245
|
+
switch (value) {
|
|
1246
|
+
case REACT_ELEMENT_TYPE:
|
|
1247
|
+
return '$';
|
|
1248
|
+
}
|
|
586
1249
|
|
|
587
|
-
|
|
588
|
-
|
|
1250
|
+
{
|
|
1251
|
+
if (parent[0] === REACT_ELEMENT_TYPE && parent[1] && parent[1].$$typeof === REACT_PROVIDER_TYPE && key === '3') {
|
|
1252
|
+
insideContextProps = value;
|
|
1253
|
+
} else if (insideContextProps === parent && key === 'value') {
|
|
1254
|
+
isInsideContextValue = true;
|
|
1255
|
+
} else if (insideContextProps === parent && key === 'children') {
|
|
1256
|
+
isInsideContextValue = false;
|
|
1257
|
+
}
|
|
1258
|
+
} // Resolve server components.
|
|
589
1259
|
|
|
590
|
-
try {
|
|
591
|
-
var moduleMetaData = resolveModuleMetaData(
|
|
592
|
-
request.bundlerConfig,
|
|
593
|
-
moduleReference
|
|
594
|
-
);
|
|
595
|
-
request.pendingChunks++;
|
|
596
|
-
var moduleId = request.nextChunkId++;
|
|
597
|
-
emitModuleChunk(request, moduleId, moduleMetaData);
|
|
598
|
-
writtenModules.set(moduleKey, moduleId);
|
|
599
|
-
|
|
600
|
-
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
|
601
|
-
// If we're encoding the "type" of an element, we can refer
|
|
602
|
-
// to that by a lazy reference instead of directly since React
|
|
603
|
-
// knows how to deal with lazy values. This lets us suspend
|
|
604
|
-
// on this component rather than its parent until the code has
|
|
605
|
-
// loaded.
|
|
606
|
-
return serializeByRefID(moduleId);
|
|
607
|
-
}
|
|
608
1260
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
1261
|
+
while (typeof value === 'object' && value !== null && (value.$$typeof === REACT_ELEMENT_TYPE || value.$$typeof === REACT_LAZY_TYPE)) {
|
|
1262
|
+
{
|
|
1263
|
+
if (isInsideContextValue) {
|
|
1264
|
+
error('React elements are not allowed in ServerContext');
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
612
1267
|
|
|
613
|
-
|
|
1268
|
+
try {
|
|
1269
|
+
switch (value.$$typeof) {
|
|
1270
|
+
case REACT_ELEMENT_TYPE:
|
|
1271
|
+
{
|
|
1272
|
+
// TODO: Concatenate keys of parents onto children.
|
|
1273
|
+
var element = value; // Attempt to render the server component.
|
|
614
1274
|
|
|
615
|
-
|
|
616
|
-
|
|
1275
|
+
value = attemptResolveElement(element.type, element.key, element.ref, element.props);
|
|
1276
|
+
break;
|
|
617
1277
|
}
|
|
618
|
-
}
|
|
619
1278
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
'Built-ins like %s are not supported. ' +
|
|
627
|
-
'Remove %s from these props: %s',
|
|
628
|
-
objectName(value),
|
|
629
|
-
describeKeyForErrorMessage(key),
|
|
630
|
-
describeObjectForErrorMessage(parent)
|
|
631
|
-
);
|
|
632
|
-
} else if (!isSimpleObject(value)) {
|
|
633
|
-
error(
|
|
634
|
-
'Only plain objects can be passed to client components from server components. ' +
|
|
635
|
-
'Classes or other objects with methods are not supported. ' +
|
|
636
|
-
'Remove %s from these props: %s',
|
|
637
|
-
describeKeyForErrorMessage(key),
|
|
638
|
-
describeObjectForErrorMessage(parent, key)
|
|
639
|
-
);
|
|
640
|
-
} else if (Object.getOwnPropertySymbols) {
|
|
641
|
-
var symbols = Object.getOwnPropertySymbols(value);
|
|
642
|
-
|
|
643
|
-
if (symbols.length > 0) {
|
|
644
|
-
error(
|
|
645
|
-
'Only plain objects can be passed to client components from server components. ' +
|
|
646
|
-
'Objects with symbol properties like %s are not supported. ' +
|
|
647
|
-
'Remove %s from these props: %s',
|
|
648
|
-
symbols[0].description,
|
|
649
|
-
describeKeyForErrorMessage(key),
|
|
650
|
-
describeObjectForErrorMessage(parent, key)
|
|
651
|
-
);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
1279
|
+
case REACT_LAZY_TYPE:
|
|
1280
|
+
{
|
|
1281
|
+
var payload = value._payload;
|
|
1282
|
+
var init = value._init;
|
|
1283
|
+
value = init(payload);
|
|
1284
|
+
break;
|
|
654
1285
|
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
return value;
|
|
658
1286
|
}
|
|
1287
|
+
} catch (x) {
|
|
1288
|
+
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
|
1289
|
+
// Something suspended, we'll need to create a new segment and resolve it later.
|
|
1290
|
+
request.pendingChunks++;
|
|
1291
|
+
var newSegment = createSegment(request, value, getActiveContext());
|
|
1292
|
+
var ping = newSegment.ping;
|
|
1293
|
+
x.then(ping, ping);
|
|
1294
|
+
return serializeByRefID(newSegment.id);
|
|
1295
|
+
} else {
|
|
1296
|
+
logRecoverableError(request, x); // Something errored. We'll still send everything we have up until this point.
|
|
1297
|
+
// We'll replace this element with a lazy reference that throws on the client
|
|
1298
|
+
// once it gets rendered.
|
|
659
1299
|
|
|
660
|
-
|
|
661
|
-
|
|
1300
|
+
request.pendingChunks++;
|
|
1301
|
+
var errorId = request.nextChunkId++;
|
|
1302
|
+
emitErrorChunk(request, errorId, x);
|
|
1303
|
+
return serializeByRefID(errorId);
|
|
662
1304
|
}
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
if (value === null) {
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
if (typeof value === 'object') {
|
|
1313
|
+
if (isModuleReference(value)) {
|
|
1314
|
+
var moduleReference = value;
|
|
1315
|
+
var moduleKey = getModuleKey(moduleReference);
|
|
1316
|
+
var writtenModules = request.writtenModules;
|
|
1317
|
+
var existingId = writtenModules.get(moduleKey);
|
|
1318
|
+
|
|
1319
|
+
if (existingId !== undefined) {
|
|
1320
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
|
1321
|
+
// If we're encoding the "type" of an element, we can refer
|
|
1322
|
+
// to that by a lazy reference instead of directly since React
|
|
1323
|
+
// knows how to deal with lazy values. This lets us suspend
|
|
1324
|
+
// on this component rather than its parent until the code has
|
|
1325
|
+
// loaded.
|
|
1326
|
+
return serializeByRefID(existingId);
|
|
1327
|
+
}
|
|
663
1328
|
|
|
664
|
-
|
|
665
|
-
typeof value === 'boolean' ||
|
|
666
|
-
typeof value === 'number' ||
|
|
667
|
-
typeof value === 'undefined'
|
|
668
|
-
) {
|
|
669
|
-
return value;
|
|
1329
|
+
return serializeByValueID(existingId);
|
|
670
1330
|
}
|
|
671
1331
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
"because they're not serializable. " +
|
|
687
|
-
('Remove ' +
|
|
688
|
-
describeKeyForErrorMessage(key) +
|
|
689
|
-
' (' +
|
|
690
|
-
(value.displayName || value.name || 'function') +
|
|
691
|
-
') from this object, or avoid the entire object: ' +
|
|
692
|
-
describeObjectForErrorMessage(parent))
|
|
693
|
-
);
|
|
1332
|
+
try {
|
|
1333
|
+
var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
|
|
1334
|
+
request.pendingChunks++;
|
|
1335
|
+
var moduleId = request.nextChunkId++;
|
|
1336
|
+
emitModuleChunk(request, moduleId, moduleMetaData);
|
|
1337
|
+
writtenModules.set(moduleKey, moduleId);
|
|
1338
|
+
|
|
1339
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
|
1340
|
+
// If we're encoding the "type" of an element, we can refer
|
|
1341
|
+
// to that by a lazy reference instead of directly since React
|
|
1342
|
+
// knows how to deal with lazy values. This lets us suspend
|
|
1343
|
+
// on this component rather than its parent until the code has
|
|
1344
|
+
// loaded.
|
|
1345
|
+
return serializeByRefID(moduleId);
|
|
694
1346
|
}
|
|
695
|
-
}
|
|
696
1347
|
|
|
697
|
-
|
|
698
|
-
|
|
1348
|
+
return serializeByValueID(moduleId);
|
|
1349
|
+
} catch (x) {
|
|
1350
|
+
request.pendingChunks++;
|
|
699
1351
|
|
|
700
|
-
var
|
|
1352
|
+
var _errorId = request.nextChunkId++;
|
|
701
1353
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
throw new Error(
|
|
710
|
-
'Only global symbols received from Symbol.for(...) can be passed to client components. ' +
|
|
711
|
-
('The symbol Symbol.for(' +
|
|
712
|
-
value.description +
|
|
713
|
-
') cannot be found among global symbols. ') +
|
|
714
|
-
('Remove ' +
|
|
715
|
-
describeKeyForErrorMessage(key) +
|
|
716
|
-
' from this object, or avoid the entire object: ' +
|
|
717
|
-
describeObjectForErrorMessage(parent))
|
|
718
|
-
);
|
|
719
|
-
}
|
|
1354
|
+
emitErrorChunk(request, _errorId, x);
|
|
1355
|
+
return serializeByValueID(_errorId);
|
|
1356
|
+
}
|
|
1357
|
+
} else if (value.$$typeof === REACT_PROVIDER_TYPE) {
|
|
1358
|
+
var providerKey = value._context._globalName;
|
|
1359
|
+
var writtenProviders = request.writtenProviders;
|
|
1360
|
+
var providerId = writtenProviders.get(key);
|
|
720
1361
|
|
|
1362
|
+
if (providerId === undefined) {
|
|
721
1363
|
request.pendingChunks++;
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
return serializeByValueID(symbolId);
|
|
726
|
-
} // $FlowFixMe: bigint isn't added to Flow yet.
|
|
727
|
-
|
|
728
|
-
if (typeof value === 'bigint') {
|
|
729
|
-
throw new Error(
|
|
730
|
-
'BigInt (' +
|
|
731
|
-
value +
|
|
732
|
-
') is not yet supported in client component props. ' +
|
|
733
|
-
('Remove ' +
|
|
734
|
-
describeKeyForErrorMessage(key) +
|
|
735
|
-
' from this object or use a plain number instead: ' +
|
|
736
|
-
describeObjectForErrorMessage(parent))
|
|
737
|
-
);
|
|
1364
|
+
providerId = request.nextChunkId++;
|
|
1365
|
+
writtenProviders.set(providerKey, providerId);
|
|
1366
|
+
emitProviderChunk(request, providerId, providerKey);
|
|
738
1367
|
}
|
|
739
1368
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
' is not supported in client component props. ' +
|
|
744
|
-
('Remove ' +
|
|
745
|
-
describeKeyForErrorMessage(key) +
|
|
746
|
-
' from this object, or avoid the entire object: ' +
|
|
747
|
-
describeObjectForErrorMessage(parent))
|
|
748
|
-
);
|
|
749
|
-
}
|
|
1369
|
+
return serializeByValueID(providerId);
|
|
1370
|
+
} else if (value === POP) {
|
|
1371
|
+
popProvider();
|
|
750
1372
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
1373
|
+
{
|
|
1374
|
+
insideContextProps = null;
|
|
1375
|
+
isInsideContextValue = false;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
return undefined;
|
|
754
1379
|
}
|
|
755
1380
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
1381
|
+
{
|
|
1382
|
+
if (value !== null && !isArray(value)) {
|
|
1383
|
+
// Verify that this is a simple plain object.
|
|
1384
|
+
if (objectName(value) !== 'Object') {
|
|
1385
|
+
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));
|
|
1386
|
+
} else if (!isSimpleObject(value)) {
|
|
1387
|
+
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));
|
|
1388
|
+
} else if (Object.getOwnPropertySymbols) {
|
|
1389
|
+
var symbols = Object.getOwnPropertySymbols(value);
|
|
1390
|
+
|
|
1391
|
+
if (symbols.length > 0) {
|
|
1392
|
+
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));
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
764
1395
|
}
|
|
765
1396
|
}
|
|
766
1397
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
// Give this an error code instead and log on the server.
|
|
770
|
-
// We can serialize the error in DEV as a convenience.
|
|
771
|
-
var message;
|
|
772
|
-
var stack = '';
|
|
1398
|
+
return value;
|
|
1399
|
+
}
|
|
773
1400
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
|
1401
|
+
if (typeof value === 'string') {
|
|
1402
|
+
return escapeStringValue(value);
|
|
1403
|
+
}
|
|
778
1404
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
} catch (x) {
|
|
784
|
-
message = 'An error occurred but serializing the error message failed.';
|
|
785
|
-
}
|
|
1405
|
+
if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'undefined') {
|
|
1406
|
+
return value;
|
|
1407
|
+
}
|
|
786
1408
|
|
|
787
|
-
|
|
788
|
-
|
|
1409
|
+
if (typeof value === 'function') {
|
|
1410
|
+
if (/^on[A-Z]/.test(key)) {
|
|
1411
|
+
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.');
|
|
1412
|
+
} else {
|
|
1413
|
+
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)));
|
|
789
1414
|
}
|
|
1415
|
+
}
|
|
790
1416
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
1417
|
+
if (typeof value === 'symbol') {
|
|
1418
|
+
var writtenSymbols = request.writtenSymbols;
|
|
1419
|
+
|
|
1420
|
+
var _existingId = writtenSymbols.get(value);
|
|
795
1421
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
request.completedModuleChunks.push(processedChunk);
|
|
1422
|
+
if (_existingId !== undefined) {
|
|
1423
|
+
return serializeByValueID(_existingId);
|
|
799
1424
|
}
|
|
800
1425
|
|
|
801
|
-
|
|
802
|
-
try {
|
|
803
|
-
var _value3 = segment.model;
|
|
804
|
-
|
|
805
|
-
while (
|
|
806
|
-
typeof _value3 === 'object' &&
|
|
807
|
-
_value3 !== null &&
|
|
808
|
-
_value3.$$typeof === REACT_ELEMENT_TYPE
|
|
809
|
-
) {
|
|
810
|
-
// TODO: Concatenate keys of parents onto children.
|
|
811
|
-
var element = _value3; // Attempt to render the server component.
|
|
812
|
-
// Doing this here lets us reuse this same segment if the next component
|
|
813
|
-
// also suspends.
|
|
814
|
-
|
|
815
|
-
segment.model = _value3;
|
|
816
|
-
_value3 = attemptResolveElement(
|
|
817
|
-
element.type,
|
|
818
|
-
element.key,
|
|
819
|
-
element.ref,
|
|
820
|
-
element.props
|
|
821
|
-
);
|
|
822
|
-
}
|
|
1426
|
+
var name = value.description;
|
|
823
1427
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
} catch (x) {
|
|
827
|
-
if (
|
|
828
|
-
typeof x === 'object' &&
|
|
829
|
-
x !== null &&
|
|
830
|
-
typeof x.then === 'function'
|
|
831
|
-
) {
|
|
832
|
-
// Something suspended again, let's pick it back up later.
|
|
833
|
-
var ping = segment.ping;
|
|
834
|
-
x.then(ping, ping);
|
|
835
|
-
return;
|
|
836
|
-
} else {
|
|
837
|
-
reportError(request, x); // This errored, we need to serialize this error to the
|
|
838
|
-
|
|
839
|
-
emitErrorChunk(request, segment.id, x);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
1428
|
+
if (Symbol.for(name) !== value) {
|
|
1429
|
+
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)));
|
|
842
1430
|
}
|
|
843
1431
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1432
|
+
request.pendingChunks++;
|
|
1433
|
+
var symbolId = request.nextChunkId++;
|
|
1434
|
+
emitSymbolChunk(request, symbolId, name);
|
|
1435
|
+
writtenSymbols.set(value, symbolId);
|
|
1436
|
+
return serializeByValueID(symbolId);
|
|
1437
|
+
} // $FlowFixMe: bigint isn't added to Flow yet.
|
|
849
1438
|
|
|
850
|
-
try {
|
|
851
|
-
var pingedSegments = request.pingedSegments;
|
|
852
|
-
request.pingedSegments = [];
|
|
853
1439
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
1440
|
+
if (typeof value === 'bigint') {
|
|
1441
|
+
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)));
|
|
1442
|
+
}
|
|
858
1443
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
}
|
|
862
|
-
} catch (error) {
|
|
863
|
-
reportError(request, error);
|
|
864
|
-
fatalError(request, error);
|
|
865
|
-
} finally {
|
|
866
|
-
ReactCurrentDispatcher.current = prevDispatcher;
|
|
867
|
-
currentCache = prevCache;
|
|
868
|
-
}
|
|
869
|
-
}
|
|
1444
|
+
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)));
|
|
1445
|
+
}
|
|
870
1446
|
|
|
871
|
-
|
|
872
|
-
|
|
1447
|
+
function logRecoverableError(request, error) {
|
|
1448
|
+
var onError = request.onError;
|
|
1449
|
+
onError(error);
|
|
1450
|
+
}
|
|
873
1451
|
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if (!writeChunk(destination, chunk)) {
|
|
885
|
-
request.destination = null;
|
|
886
|
-
i++;
|
|
887
|
-
break;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
1452
|
+
function fatalError(request, error) {
|
|
1453
|
+
// This is called outside error handling code such as if an error happens in React internals.
|
|
1454
|
+
if (request.destination !== null) {
|
|
1455
|
+
request.status = CLOSED;
|
|
1456
|
+
closeWithError(request.destination, error);
|
|
1457
|
+
} else {
|
|
1458
|
+
request.status = CLOSING;
|
|
1459
|
+
request.fatalError = error;
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
890
1462
|
|
|
891
|
-
|
|
1463
|
+
function emitErrorChunk(request, id, error) {
|
|
1464
|
+
// TODO: We should not leak error messages to the client in prod.
|
|
1465
|
+
// Give this an error code instead and log on the server.
|
|
1466
|
+
// We can serialize the error in DEV as a convenience.
|
|
1467
|
+
var message;
|
|
1468
|
+
var stack = '';
|
|
1469
|
+
|
|
1470
|
+
try {
|
|
1471
|
+
if (error instanceof Error) {
|
|
1472
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
1473
|
+
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
|
1474
|
+
|
|
1475
|
+
stack = String(error.stack);
|
|
1476
|
+
} else {
|
|
1477
|
+
message = 'Error: ' + error;
|
|
1478
|
+
}
|
|
1479
|
+
} catch (x) {
|
|
1480
|
+
message = 'An error occurred but serializing the error message failed.';
|
|
1481
|
+
}
|
|
892
1482
|
|
|
893
|
-
|
|
894
|
-
|
|
1483
|
+
var processedChunk = processErrorChunk(request, id, message, stack);
|
|
1484
|
+
request.completedErrorChunks.push(processedChunk);
|
|
1485
|
+
}
|
|
895
1486
|
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
1487
|
+
function emitModuleChunk(request, id, moduleMetaData) {
|
|
1488
|
+
var processedChunk = processModuleChunk(request, id, moduleMetaData);
|
|
1489
|
+
request.completedModuleChunks.push(processedChunk);
|
|
1490
|
+
}
|
|
899
1491
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1492
|
+
function emitSymbolChunk(request, id, name) {
|
|
1493
|
+
var processedChunk = processSymbolChunk(request, id, name);
|
|
1494
|
+
request.completedModuleChunks.push(processedChunk);
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
function emitProviderChunk(request, id, contextName) {
|
|
1498
|
+
var processedChunk = processProviderChunk(request, id, contextName);
|
|
1499
|
+
request.completedJSONChunks.push(processedChunk);
|
|
1500
|
+
}
|
|
906
1501
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
// the page.
|
|
1502
|
+
function retrySegment(request, segment) {
|
|
1503
|
+
switchContext(segment.context);
|
|
910
1504
|
|
|
911
|
-
|
|
912
|
-
|
|
1505
|
+
try {
|
|
1506
|
+
var _value3 = segment.model;
|
|
913
1507
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1508
|
+
while (typeof _value3 === 'object' && _value3 !== null && _value3.$$typeof === REACT_ELEMENT_TYPE) {
|
|
1509
|
+
// TODO: Concatenate keys of parents onto children.
|
|
1510
|
+
var element = _value3; // Attempt to render the server component.
|
|
1511
|
+
// Doing this here lets us reuse this same segment if the next component
|
|
1512
|
+
// also suspends.
|
|
917
1513
|
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
break;
|
|
922
|
-
}
|
|
923
|
-
}
|
|
1514
|
+
segment.model = _value3;
|
|
1515
|
+
_value3 = attemptResolveElement(element.type, element.key, element.ref, element.props);
|
|
1516
|
+
}
|
|
924
1517
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1518
|
+
var processedChunk = processModelChunk(request, segment.id, _value3);
|
|
1519
|
+
request.completedJSONChunks.push(processedChunk);
|
|
1520
|
+
} catch (x) {
|
|
1521
|
+
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
|
1522
|
+
// Something suspended again, let's pick it back up later.
|
|
1523
|
+
var ping = segment.ping;
|
|
1524
|
+
x.then(ping, ping);
|
|
1525
|
+
return;
|
|
1526
|
+
} else {
|
|
1527
|
+
logRecoverableError(request, x); // This errored, we need to serialize this error to the
|
|
1528
|
+
|
|
1529
|
+
emitErrorChunk(request, segment.id, x);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
929
1533
|
|
|
930
|
-
|
|
1534
|
+
function performWork(request) {
|
|
1535
|
+
var prevDispatcher = ReactCurrentDispatcher.current;
|
|
1536
|
+
var prevCache = getCurrentCache();
|
|
1537
|
+
ReactCurrentDispatcher.current = Dispatcher;
|
|
1538
|
+
setCurrentCache(request.cache);
|
|
931
1539
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1540
|
+
try {
|
|
1541
|
+
var pingedSegments = request.pingedSegments;
|
|
1542
|
+
request.pingedSegments = [];
|
|
1543
|
+
|
|
1544
|
+
for (var i = 0; i < pingedSegments.length; i++) {
|
|
1545
|
+
var segment = pingedSegments[i];
|
|
1546
|
+
retrySegment(request, segment);
|
|
936
1547
|
}
|
|
937
1548
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
return performWork(request);
|
|
941
|
-
});
|
|
1549
|
+
if (request.destination !== null) {
|
|
1550
|
+
flushCompletedChunks(request, request.destination);
|
|
942
1551
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1552
|
+
} catch (error) {
|
|
1553
|
+
logRecoverableError(request, error);
|
|
1554
|
+
fatalError(request, error);
|
|
1555
|
+
} finally {
|
|
1556
|
+
ReactCurrentDispatcher.current = prevDispatcher;
|
|
1557
|
+
setCurrentCache(prevCache);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
949
1560
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
}
|
|
1561
|
+
function flushCompletedChunks(request, destination) {
|
|
1562
|
+
beginWriting(destination);
|
|
953
1563
|
|
|
954
|
-
|
|
1564
|
+
try {
|
|
1565
|
+
// We emit module chunks first in the stream so that
|
|
1566
|
+
// they can be preloaded as early as possible.
|
|
1567
|
+
var moduleChunks = request.completedModuleChunks;
|
|
1568
|
+
var i = 0;
|
|
955
1569
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1570
|
+
for (; i < moduleChunks.length; i++) {
|
|
1571
|
+
request.pendingChunks--;
|
|
1572
|
+
var chunk = moduleChunks[i];
|
|
1573
|
+
var keepWriting = writeChunkAndReturn(destination, chunk);
|
|
1574
|
+
|
|
1575
|
+
if (!keepWriting) {
|
|
1576
|
+
request.destination = null;
|
|
1577
|
+
i++;
|
|
1578
|
+
break;
|
|
961
1579
|
}
|
|
962
1580
|
}
|
|
963
1581
|
|
|
964
|
-
|
|
965
|
-
|
|
1582
|
+
moduleChunks.splice(0, i); // Next comes model data.
|
|
1583
|
+
|
|
1584
|
+
var jsonChunks = request.completedJSONChunks;
|
|
1585
|
+
i = 0;
|
|
1586
|
+
|
|
1587
|
+
for (; i < jsonChunks.length; i++) {
|
|
1588
|
+
request.pendingChunks--;
|
|
1589
|
+
var _chunk = jsonChunks[i];
|
|
1590
|
+
|
|
1591
|
+
var _keepWriting = writeChunkAndReturn(destination, _chunk);
|
|
1592
|
+
|
|
1593
|
+
if (!_keepWriting) {
|
|
1594
|
+
request.destination = null;
|
|
1595
|
+
i++;
|
|
1596
|
+
break;
|
|
1597
|
+
}
|
|
966
1598
|
}
|
|
967
1599
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1600
|
+
jsonChunks.splice(0, i); // Finally, errors are sent. The idea is that it's ok to delay
|
|
1601
|
+
// any error messages and prioritize display of other parts of
|
|
1602
|
+
// the page.
|
|
1603
|
+
|
|
1604
|
+
var errorChunks = request.completedErrorChunks;
|
|
1605
|
+
i = 0;
|
|
1606
|
+
|
|
1607
|
+
for (; i < errorChunks.length; i++) {
|
|
1608
|
+
request.pendingChunks--;
|
|
1609
|
+
var _chunk2 = errorChunks[i];
|
|
1610
|
+
|
|
1611
|
+
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
|
|
1612
|
+
|
|
1613
|
+
if (!_keepWriting2) {
|
|
1614
|
+
request.destination = null;
|
|
1615
|
+
i++;
|
|
1616
|
+
break;
|
|
973
1617
|
}
|
|
974
1618
|
}
|
|
975
1619
|
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
},
|
|
981
|
-
useCallback: function (callback) {
|
|
982
|
-
return callback;
|
|
983
|
-
},
|
|
984
|
-
useDebugValue: function () {},
|
|
985
|
-
useDeferredValue: unsupportedHook,
|
|
986
|
-
useTransition: unsupportedHook,
|
|
987
|
-
getCacheForType: function (resourceType) {
|
|
988
|
-
if (!currentCache) {
|
|
989
|
-
throw new Error(
|
|
990
|
-
'Reading the cache is only supported while rendering.'
|
|
991
|
-
);
|
|
992
|
-
}
|
|
1620
|
+
errorChunks.splice(0, i);
|
|
1621
|
+
} finally {
|
|
1622
|
+
completeWriting(destination);
|
|
1623
|
+
}
|
|
993
1624
|
|
|
994
|
-
|
|
1625
|
+
flushBuffered(destination);
|
|
995
1626
|
|
|
996
|
-
|
|
997
|
-
|
|
1627
|
+
if (request.pendingChunks === 0) {
|
|
1628
|
+
// We're done.
|
|
1629
|
+
close(destination);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
998
1632
|
|
|
999
|
-
|
|
1000
|
-
|
|
1633
|
+
function startWork(request) {
|
|
1634
|
+
scheduleWork(function () {
|
|
1635
|
+
return performWork(request);
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
function startFlowing(request, destination) {
|
|
1639
|
+
if (request.status === CLOSING) {
|
|
1640
|
+
request.status = CLOSED;
|
|
1641
|
+
closeWithError(destination, request.fatalError);
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
if (request.status === CLOSED) {
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
if (request.destination !== null) {
|
|
1650
|
+
// We're already flowing.
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
request.destination = destination;
|
|
1655
|
+
|
|
1656
|
+
try {
|
|
1657
|
+
flushCompletedChunks(request, destination);
|
|
1658
|
+
} catch (error) {
|
|
1659
|
+
logRecoverableError(request, error);
|
|
1660
|
+
fatalError(request, error);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1001
1663
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
useId: unsupportedHook,
|
|
1014
|
-
useMutableSource: unsupportedHook,
|
|
1015
|
-
useSyncExternalStore: unsupportedHook,
|
|
1016
|
-
useCacheRefresh: function () {
|
|
1017
|
-
return unsupportedRefresh;
|
|
1018
|
-
},
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
function createDrainHandler(destination, request) {
|
|
1022
|
-
return function () {
|
|
1023
|
-
return startFlowing(request, destination);
|
|
1024
|
-
};
|
|
1664
|
+
function importServerContexts(contexts) {
|
|
1665
|
+
if (contexts) {
|
|
1666
|
+
var prevContext = getActiveContext();
|
|
1667
|
+
switchContext(rootContextSnapshot);
|
|
1668
|
+
|
|
1669
|
+
for (var i = 0; i < contexts.length; i++) {
|
|
1670
|
+
var _contexts$i = contexts[i],
|
|
1671
|
+
name = _contexts$i[0],
|
|
1672
|
+
_value4 = _contexts$i[1];
|
|
1673
|
+
var context = getOrCreateServerContext(name);
|
|
1674
|
+
pushProvider(context, _value4);
|
|
1025
1675
|
}
|
|
1026
1676
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
options ? options.onError : undefined
|
|
1032
|
-
);
|
|
1033
|
-
var hasStartedFlowing = false;
|
|
1034
|
-
startWork(request);
|
|
1035
|
-
return {
|
|
1036
|
-
pipe: function (destination) {
|
|
1037
|
-
if (hasStartedFlowing) {
|
|
1038
|
-
throw new Error(
|
|
1039
|
-
'React currently only supports piping to one writable stream.'
|
|
1040
|
-
);
|
|
1041
|
-
}
|
|
1677
|
+
var importedContext = getActiveContext();
|
|
1678
|
+
switchContext(prevContext);
|
|
1679
|
+
return importedContext;
|
|
1680
|
+
}
|
|
1042
1681
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1682
|
+
return rootContextSnapshot;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
function createDrainHandler(destination, request) {
|
|
1686
|
+
return function () {
|
|
1687
|
+
return startFlowing(request, destination);
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
function renderToPipeableStream(model, options, context) {
|
|
1692
|
+
var request = createRequest(model, {}, // Manifest, not used
|
|
1693
|
+
options ? options.onError : undefined, context);
|
|
1694
|
+
var hasStartedFlowing = false;
|
|
1695
|
+
startWork(request);
|
|
1696
|
+
return {
|
|
1697
|
+
pipe: function (destination) {
|
|
1698
|
+
if (hasStartedFlowing) {
|
|
1699
|
+
throw new Error('React currently only supports piping to one writable stream.');
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
hasStartedFlowing = true;
|
|
1703
|
+
startFlowing(request, destination);
|
|
1704
|
+
destination.on('drain', createDrainHandler(destination, request));
|
|
1705
|
+
return destination;
|
|
1049
1706
|
}
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1050
1709
|
|
|
1051
|
-
|
|
1710
|
+
exports.renderToPipeableStream = renderToPipeableStream;
|
|
1052
1711
|
})();
|
|
1053
1712
|
}
|