@shopify/hydrogen 0.0.0-unstable-20220314172608
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 +869 -0
- package/README.md +29 -0
- package/client.d.ts +1 -0
- package/client.js +1 -0
- package/dist/esnext/client.d.ts +9 -0
- package/dist/esnext/client.js +9 -0
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +23 -0
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +47 -0
- package/dist/esnext/components/AddToCartButton/index.d.ts +1 -0
- package/dist/esnext/components/AddToCartButton/index.js +1 -0
- package/dist/esnext/components/BuyNowButton/BuyNowButton.client.d.ts +18 -0
- package/dist/esnext/components/BuyNowButton/BuyNowButton.client.js +26 -0
- package/dist/esnext/components/BuyNowButton/index.d.ts +1 -0
- package/dist/esnext/components/BuyNowButton/index.js +1 -0
- package/dist/esnext/components/CartCheckoutButton/CartCheckoutButton.client.d.ts +11 -0
- package/dist/esnext/components/CartCheckoutButton/CartCheckoutButton.client.js +17 -0
- package/dist/esnext/components/CartCheckoutButton/index.d.ts +1 -0
- package/dist/esnext/components/CartCheckoutButton/index.js +1 -0
- package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +14 -0
- package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.js +29 -0
- package/dist/esnext/components/CartEstimatedCost/index.d.ts +1 -0
- package/dist/esnext/components/CartEstimatedCost/index.js +1 -0
- package/dist/esnext/components/CartLineImage/CartLineImage.client.d.ts +12 -0
- package/dist/esnext/components/CartLineImage/CartLineImage.client.js +12 -0
- package/dist/esnext/components/CartLineImage/index.d.ts +1 -0
- package/dist/esnext/components/CartLineImage/index.js +1 -0
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.d.ts +12 -0
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.js +21 -0
- package/dist/esnext/components/CartLinePrice/index.d.ts +1 -0
- package/dist/esnext/components/CartLinePrice/index.js +1 -0
- package/dist/esnext/components/CartLineProductTitle/CartLineProductTitle.client.d.ts +8 -0
- package/dist/esnext/components/CartLineProductTitle/CartLineProductTitle.client.js +12 -0
- package/dist/esnext/components/CartLineProductTitle/index.d.ts +1 -0
- package/dist/esnext/components/CartLineProductTitle/index.js +1 -0
- package/dist/esnext/components/CartLineProvider/CartLineProvider.client.d.ts +11 -0
- package/dist/esnext/components/CartLineProvider/CartLineProvider.client.js +8 -0
- package/dist/esnext/components/CartLineProvider/context.d.ts +26 -0
- package/dist/esnext/components/CartLineProvider/context.js +2 -0
- package/dist/esnext/components/CartLineProvider/index.d.ts +2 -0
- package/dist/esnext/components/CartLineProvider/index.js +2 -0
- package/dist/esnext/components/CartLineQuantity/CartLineQuantity.client.d.ts +8 -0
- package/dist/esnext/components/CartLineQuantity/CartLineQuantity.client.js +12 -0
- package/dist/esnext/components/CartLineQuantity/index.d.ts +1 -0
- package/dist/esnext/components/CartLineQuantity/index.js +1 -0
- package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +14 -0
- package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +24 -0
- package/dist/esnext/components/CartLineQuantityAdjustButton/index.d.ts +1 -0
- package/dist/esnext/components/CartLineQuantityAdjustButton/index.js +1 -0
- package/dist/esnext/components/CartLines/CartLines.d.ts +15 -0
- package/dist/esnext/components/CartLines/CartLines.js +17 -0
- package/dist/esnext/components/CartLines/index.d.ts +1 -0
- package/dist/esnext/components/CartLines/index.js +1 -0
- package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +36 -0
- package/dist/esnext/components/CartProvider/CartProvider.client.js +486 -0
- package/dist/esnext/components/CartProvider/constants.d.ts +2 -0
- package/dist/esnext/components/CartProvider/constants.js +2 -0
- package/dist/esnext/components/CartProvider/context.d.ts +2 -0
- package/dist/esnext/components/CartProvider/context.js +2 -0
- package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +86 -0
- package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +86 -0
- package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +85 -0
- package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +86 -0
- package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +72 -0
- package/dist/esnext/components/CartProvider/graphql/CartFragment.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +86 -0
- package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +86 -0
- package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +86 -0
- package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +86 -0
- package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.js +1 -0
- package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +81 -0
- package/dist/esnext/components/CartProvider/graphql/CartQuery.js +1 -0
- package/dist/esnext/components/CartProvider/hooks.d.ts +15 -0
- package/dist/esnext/components/CartProvider/hooks.js +57 -0
- package/dist/esnext/components/CartProvider/index.d.ts +4 -0
- package/dist/esnext/components/CartProvider/index.js +3 -0
- package/dist/esnext/components/CartProvider/types.d.ts +100 -0
- package/dist/esnext/components/CartProvider/types.js +1 -0
- package/dist/esnext/components/CartShopPayButton/CartShopPayButton.client.d.ts +9 -0
- package/dist/esnext/components/CartShopPayButton/CartShopPayButton.client.js +19 -0
- package/dist/esnext/components/CartShopPayButton/index.d.ts +1 -0
- package/dist/esnext/components/CartShopPayButton/index.js +1 -0
- package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +20 -0
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +11 -0
- package/dist/esnext/components/ExternalVideo/ExternalVideoFragment.d.ts +8 -0
- package/dist/esnext/components/ExternalVideo/ExternalVideoFragment.js +1 -0
- package/dist/esnext/components/ExternalVideo/index.d.ts +1 -0
- package/dist/esnext/components/ExternalVideo/index.js +1 -0
- package/dist/esnext/components/Image/Image.d.ts +38 -0
- package/dist/esnext/components/Image/Image.js +51 -0
- package/dist/esnext/components/Image/ImageFragment.d.ts +8 -0
- package/dist/esnext/components/Image/ImageFragment.js +1 -0
- package/dist/esnext/components/Image/index.d.ts +1 -0
- package/dist/esnext/components/Image/index.js +1 -0
- package/dist/esnext/components/Link/Link.client.d.ts +18 -0
- package/dist/esnext/components/Link/Link.client.js +43 -0
- package/dist/esnext/components/Link/index.d.ts +1 -0
- package/dist/esnext/components/Link/index.js +1 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.d.ts +6 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.js +20 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationContext.client.d.ts +8 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationContext.client.js +2 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +21 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +22 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationQuery.d.ts +30 -0
- package/dist/esnext/components/LocalizationProvider/LocalizationQuery.js +1 -0
- package/dist/esnext/components/LocalizationProvider/index.d.ts +3 -0
- package/dist/esnext/components/LocalizationProvider/index.js +3 -0
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +18 -0
- package/dist/esnext/components/MediaFile/MediaFile.js +31 -0
- package/dist/esnext/components/MediaFile/MediaFileFragment.d.ts +36 -0
- package/dist/esnext/components/MediaFile/MediaFileFragment.js +1 -0
- package/dist/esnext/components/MediaFile/index.d.ts +1 -0
- package/dist/esnext/components/MediaFile/index.js +1 -0
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +17 -0
- package/dist/esnext/components/Metafield/Metafield.client.js +65 -0
- package/dist/esnext/components/Metafield/MetafieldFragment.d.ts +22 -0
- package/dist/esnext/components/Metafield/MetafieldFragment.js +1 -0
- package/dist/esnext/components/Metafield/components/StarRating/StarRating.d.ts +12 -0
- package/dist/esnext/components/Metafield/components/StarRating/StarRating.js +48 -0
- package/dist/esnext/components/Metafield/components/StarRating/index.d.ts +1 -0
- package/dist/esnext/components/Metafield/components/StarRating/index.js +1 -0
- package/dist/esnext/components/Metafield/components/index.d.ts +1 -0
- package/dist/esnext/components/Metafield/components/index.js +1 -0
- package/dist/esnext/components/Metafield/index.d.ts +2 -0
- package/dist/esnext/components/Metafield/index.js +1 -0
- package/dist/esnext/components/Metafield/types.d.ts +4 -0
- package/dist/esnext/components/Metafield/types.js +1 -0
- package/dist/esnext/components/ModelViewer/Model3DFragment.d.ts +15 -0
- package/dist/esnext/components/ModelViewer/Model3DFragment.js +1 -0
- package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +127 -0
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +99 -0
- package/dist/esnext/components/ModelViewer/index.d.ts +1 -0
- package/dist/esnext/components/ModelViewer/index.js +1 -0
- package/dist/esnext/components/Money/Money.client.d.ts +14 -0
- package/dist/esnext/components/Money/Money.client.js +13 -0
- package/dist/esnext/components/Money/MoneyFragment.d.ts +8 -0
- package/dist/esnext/components/Money/MoneyFragment.js +1 -0
- package/dist/esnext/components/Money/index.d.ts +1 -0
- package/dist/esnext/components/Money/index.js +1 -0
- package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +13 -0
- package/dist/esnext/components/ProductDescription/ProductDescription.client.js +16 -0
- package/dist/esnext/components/ProductDescription/index.d.ts +1 -0
- package/dist/esnext/components/ProductDescription/index.js +1 -0
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.d.ts +21 -0
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +42 -0
- package/dist/esnext/components/ProductMetafield/index.d.ts +2 -0
- package/dist/esnext/components/ProductMetafield/index.js +1 -0
- package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +16 -0
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +57 -0
- package/dist/esnext/components/ProductPrice/index.d.ts +1 -0
- package/dist/esnext/components/ProductPrice/index.js +1 -0
- package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.d.ts +8 -0
- package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.js +12 -0
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +19 -0
- package/dist/esnext/components/ProductProvider/ProductProvider.client.js +33 -0
- package/dist/esnext/components/ProductProvider/ProductProviderFragment.d.ts +247 -0
- package/dist/esnext/components/ProductProvider/ProductProviderFragment.js +1 -0
- package/dist/esnext/components/ProductProvider/context.d.ts +20 -0
- package/dist/esnext/components/ProductProvider/context.js +3 -0
- package/dist/esnext/components/ProductProvider/index.d.ts +2 -0
- package/dist/esnext/components/ProductProvider/index.js +2 -0
- package/dist/esnext/components/ProductProvider/types.d.ts +19 -0
- package/dist/esnext/components/ProductProvider/types.js +1 -0
- package/dist/esnext/components/ProductTitle/ProductTitle.client.d.ts +13 -0
- package/dist/esnext/components/ProductTitle/ProductTitle.client.js +16 -0
- package/dist/esnext/components/ProductTitle/index.d.ts +1 -0
- package/dist/esnext/components/ProductTitle/index.js +1 -0
- package/dist/esnext/components/Seo/CollectionSeo.client.d.ts +2 -0
- package/dist/esnext/components/Seo/CollectionSeo.client.js +15 -0
- package/dist/esnext/components/Seo/DefaultPageSeo.client.d.ts +2 -0
- package/dist/esnext/components/Seo/DefaultPageSeo.client.js +19 -0
- package/dist/esnext/components/Seo/DescriptionSeo.client.d.ts +4 -0
- package/dist/esnext/components/Seo/DescriptionSeo.client.js +10 -0
- package/dist/esnext/components/Seo/HomePageSeo.client.d.ts +2 -0
- package/dist/esnext/components/Seo/HomePageSeo.client.js +25 -0
- package/dist/esnext/components/Seo/ImageSeo.client.d.ts +2 -0
- package/dist/esnext/components/Seo/ImageSeo.client.js +10 -0
- package/dist/esnext/components/Seo/PageSeo.client.d.ts +2 -0
- package/dist/esnext/components/Seo/PageSeo.client.js +13 -0
- package/dist/esnext/components/Seo/ProductSeo.client.d.ts +5 -0
- package/dist/esnext/components/Seo/ProductSeo.client.js +58 -0
- package/dist/esnext/components/Seo/Seo.client.d.ts +23 -0
- package/dist/esnext/components/Seo/Seo.client.js +28 -0
- package/dist/esnext/components/Seo/SeoFragment.d.ts +66 -0
- package/dist/esnext/components/Seo/SeoFragment.js +1 -0
- package/dist/esnext/components/Seo/TitleSeo.client.d.ts +4 -0
- package/dist/esnext/components/Seo/TitleSeo.client.js +10 -0
- package/dist/esnext/components/Seo/TwitterSeo.client.d.ts +2 -0
- package/dist/esnext/components/Seo/TwitterSeo.client.js +9 -0
- package/dist/esnext/components/Seo/index.d.ts +1 -0
- package/dist/esnext/components/Seo/index.js +1 -0
- package/dist/esnext/components/Seo/types.d.ts +15 -0
- package/dist/esnext/components/Seo/types.js +1 -0
- package/dist/esnext/components/ShopPayButton/ShopPayButton.client.d.ts +38 -0
- package/dist/esnext/components/ShopPayButton/ShopPayButton.client.js +48 -0
- package/dist/esnext/components/ShopPayButton/index.d.ts +1 -0
- package/dist/esnext/components/ShopPayButton/index.js +1 -0
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +14 -0
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +22 -0
- package/dist/esnext/components/UnitPrice/UnitPriceFragment.d.ts +15 -0
- package/dist/esnext/components/UnitPrice/UnitPriceFragment.js +1 -0
- package/dist/esnext/components/UnitPrice/index.d.ts +1 -0
- package/dist/esnext/components/UnitPrice/index.js +1 -0
- package/dist/esnext/components/Video/Video.d.ts +13 -0
- package/dist/esnext/components/Video/Video.js +11 -0
- package/dist/esnext/components/Video/VideoFragment.d.ts +15 -0
- package/dist/esnext/components/Video/VideoFragment.js +1 -0
- package/dist/esnext/components/Video/index.d.ts +1 -0
- package/dist/esnext/components/Video/index.js +1 -0
- package/dist/esnext/components/index.d.ts +32 -0
- package/dist/esnext/components/index.js +30 -0
- package/dist/esnext/components/types.d.ts +71 -0
- package/dist/esnext/components/types.js +10 -0
- package/dist/esnext/constants.d.ts +1 -0
- package/dist/esnext/constants.js +1 -0
- package/dist/esnext/entry-client.d.ts +3 -0
- package/dist/esnext/entry-client.js +48 -0
- package/dist/esnext/entry-server.d.ts +22 -0
- package/dist/esnext/entry-server.js +511 -0
- package/dist/esnext/foundation/Boomerang/Boomerang.client.d.ts +9 -0
- package/dist/esnext/foundation/Boomerang/Boomerang.client.js +64 -0
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.d.ts +23 -0
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +78 -0
- package/dist/esnext/foundation/Head/Head.client.d.ts +5 -0
- package/dist/esnext/foundation/Head/Head.client.js +10 -0
- package/dist/esnext/foundation/Head/index.d.ts +1 -0
- package/dist/esnext/foundation/Head/index.js +1 -0
- package/dist/esnext/foundation/Route/Route.server.d.ts +13 -0
- package/dist/esnext/foundation/Route/Route.server.js +34 -0
- package/dist/esnext/foundation/Router/BrowserRouter.client.d.ts +13 -0
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +48 -0
- package/dist/esnext/foundation/Router/Router.server.d.ts +11 -0
- package/dist/esnext/foundation/Router/Router.server.js +10 -0
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +23 -0
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +113 -0
- package/dist/esnext/foundation/ServerRequestProvider/index.d.ts +1 -0
- package/dist/esnext/foundation/ServerRequestProvider/index.js +1 -0
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.d.ts +25 -0
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.js +47 -0
- package/dist/esnext/foundation/ServerStateProvider/index.d.ts +2 -0
- package/dist/esnext/foundation/ServerStateProvider/index.js +1 -0
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.client.d.ts +7 -0
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.client.js +8 -0
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.d.ts +9 -0
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +29 -0
- package/dist/esnext/foundation/ShopifyProvider/index.d.ts +1 -0
- package/dist/esnext/foundation/ShopifyProvider/index.js +1 -0
- package/dist/esnext/foundation/ShopifyProvider/types.d.ts +15 -0
- package/dist/esnext/foundation/ShopifyProvider/types.js +1 -0
- package/dist/esnext/foundation/constants.d.ts +1 -0
- package/dist/esnext/foundation/constants.js +3 -0
- package/dist/esnext/foundation/index.d.ts +3 -0
- package/dist/esnext/foundation/index.js +3 -0
- package/dist/esnext/foundation/ssr-interop.d.ts +29 -0
- package/dist/esnext/foundation/ssr-interop.js +35 -0
- package/dist/esnext/foundation/useNavigate/useNavigate.d.ts +13 -0
- package/dist/esnext/foundation/useNavigate/useNavigate.js +14 -0
- package/dist/esnext/foundation/useQuery/hooks.d.ts +31 -0
- package/dist/esnext/foundation/useQuery/hooks.js +85 -0
- package/dist/esnext/foundation/useQuery/index.d.ts +1 -0
- package/dist/esnext/foundation/useQuery/index.js +1 -0
- 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/useServerState/index.d.ts +1 -0
- package/dist/esnext/foundation/useServerState/index.js +1 -0
- package/dist/esnext/foundation/useServerState/use-server-state.d.ts +16 -0
- package/dist/esnext/foundation/useServerState/use-server-state.js +20 -0
- package/dist/esnext/foundation/useShop/index.d.ts +1 -0
- package/dist/esnext/foundation/useShop/index.js +1 -0
- package/dist/esnext/foundation/useShop/use-shop.d.ts +4 -0
- package/dist/esnext/foundation/useShop/use-shop.js +12 -0
- package/dist/esnext/foundation/useUrl/index.d.ts +1 -0
- package/dist/esnext/foundation/useUrl/index.js +1 -0
- package/dist/esnext/foundation/useUrl/useUrl.d.ts +4 -0
- package/dist/esnext/foundation/useUrl/useUrl.js +18 -0
- package/dist/esnext/fragments.d.ts +20 -0
- package/dist/esnext/fragments.js +10 -0
- package/dist/esnext/framework/CachingStrategy/index.d.ts +10 -0
- package/dist/esnext/framework/CachingStrategy/index.js +96 -0
- package/dist/esnext/framework/Hydration/Html.d.ts +11 -0
- package/dist/esnext/framework/Hydration/Html.js +84 -0
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +47 -0
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +114 -0
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +32 -0
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +55 -0
- package/dist/esnext/framework/Hydration/rsc.d.ts +11 -0
- package/dist/esnext/framework/Hydration/rsc.js +72 -0
- package/dist/esnext/framework/cache/in-memory.d.ts +11 -0
- package/dist/esnext/framework/cache/in-memory.js +48 -0
- package/dist/esnext/framework/cache.d.ts +26 -0
- package/dist/esnext/framework/cache.js +87 -0
- package/dist/esnext/framework/config.d.ts +6 -0
- package/dist/esnext/framework/config.js +6 -0
- package/dist/esnext/framework/graphiql.d.ts +1 -0
- package/dist/esnext/framework/graphiql.js +38 -0
- package/dist/esnext/framework/middleware.d.ts +22 -0
- package/dist/esnext/framework/middleware.js +107 -0
- package/dist/esnext/framework/plugin.d.ts +4 -0
- package/dist/esnext/framework/plugin.js +41 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydration-auto-import.d.ts +3 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydration-auto-import.js +38 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +9 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.js +37 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.d.ts +3 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +84 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +11 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +56 -0
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.d.ts +3 -0
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +70 -0
- package/dist/esnext/framework/plugins/vite-plugin-purge-query-cache.d.ts +3 -0
- package/dist/esnext/framework/plugins/vite-plugin-purge-query-cache.js +11 -0
- package/dist/esnext/framework/plugins/vite-plugin-ssr-interop.d.ts +3 -0
- package/dist/esnext/framework/plugins/vite-plugin-ssr-interop.js +13 -0
- package/dist/esnext/framework/runtime.d.ts +13 -0
- package/dist/esnext/framework/runtime.js +27 -0
- package/dist/esnext/graphql/graphql-constants.d.ts +1756 -0
- package/dist/esnext/graphql/graphql-constants.js +3447 -0
- package/dist/esnext/hooks/index.d.ts +6 -0
- package/dist/esnext/hooks/index.js +6 -0
- package/dist/esnext/hooks/useAvailableCountries/index.d.ts +1 -0
- package/dist/esnext/hooks/useAvailableCountries/index.js +1 -0
- package/dist/esnext/hooks/useAvailableCountries/useAvailableCountries.d.ts +11 -0
- package/dist/esnext/hooks/useAvailableCountries/useAvailableCountries.js +17 -0
- package/dist/esnext/hooks/useCart/index.d.ts +1 -0
- package/dist/esnext/hooks/useCart/index.js +1 -0
- package/dist/esnext/hooks/useCart/useCart.d.ts +4 -0
- package/dist/esnext/hooks/useCart/useCart.js +12 -0
- package/dist/esnext/hooks/useCartLine/index.d.ts +1 -0
- package/dist/esnext/hooks/useCartLine/index.js +1 -0
- package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +29 -0
- package/dist/esnext/hooks/useCartLine/useCartLine.js +12 -0
- package/dist/esnext/hooks/useCountry/index.d.ts +1 -0
- package/dist/esnext/hooks/useCountry/index.js +1 -0
- package/dist/esnext/hooks/useCountry/useCountry.d.ts +17 -0
- package/dist/esnext/hooks/useCountry/useCountry.js +17 -0
- package/dist/esnext/hooks/useLoadScript/index.d.ts +1 -0
- package/dist/esnext/hooks/useLoadScript/index.js +1 -0
- package/dist/esnext/hooks/useLoadScript/useLoadScript.d.ts +8 -0
- package/dist/esnext/hooks/useLoadScript/useLoadScript.js +22 -0
- package/dist/esnext/hooks/useMeasurement/hooks.d.ts +9 -0
- package/dist/esnext/hooks/useMeasurement/hooks.js +13 -0
- package/dist/esnext/hooks/useMeasurement/index.d.ts +1 -0
- package/dist/esnext/hooks/useMeasurement/index.js +1 -0
- package/dist/esnext/hooks/useMoney/hooks.d.ts +42 -0
- package/dist/esnext/hooks/useMoney/hooks.js +42 -0
- package/dist/esnext/hooks/useMoney/index.d.ts +1 -0
- package/dist/esnext/hooks/useMoney/index.js +1 -0
- package/dist/esnext/hooks/useParsedMetafields/index.d.ts +1 -0
- package/dist/esnext/hooks/useParsedMetafields/index.js +1 -0
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +6 -0
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +19 -0
- package/dist/esnext/hooks/useProduct/index.d.ts +1 -0
- package/dist/esnext/hooks/useProduct/index.js +1 -0
- package/dist/esnext/hooks/useProduct/useProduct.d.ts +114 -0
- package/dist/esnext/hooks/useProduct/useProduct.js +43 -0
- package/dist/esnext/hooks/useProductOptions/SellingPlanFragment.d.ts +31 -0
- package/dist/esnext/hooks/useProductOptions/SellingPlanFragment.js +1 -0
- package/dist/esnext/hooks/useProductOptions/SellingPlanGroupsFragment.d.ts +46 -0
- package/dist/esnext/hooks/useProductOptions/SellingPlanGroupsFragment.js +1 -0
- package/dist/esnext/hooks/useProductOptions/VariantFragment.d.ts +106 -0
- package/dist/esnext/hooks/useProductOptions/VariantFragment.js +1 -0
- package/dist/esnext/hooks/useProductOptions/helpers.d.ts +4 -0
- package/dist/esnext/hooks/useProductOptions/helpers.js +33 -0
- package/dist/esnext/hooks/useProductOptions/index.d.ts +2 -0
- package/dist/esnext/hooks/useProductOptions/index.js +2 -0
- package/dist/esnext/hooks/useProductOptions/types.d.ts +62 -0
- package/dist/esnext/hooks/useProductOptions/types.js +1 -0
- package/dist/esnext/hooks/useProductOptions/useProductOptions.d.ts +14 -0
- package/dist/esnext/hooks/useProductOptions/useProductOptions.js +115 -0
- package/dist/esnext/hooks/useShopQuery/hooks.d.ts +29 -0
- package/dist/esnext/hooks/useShopQuery/hooks.js +83 -0
- package/dist/esnext/hooks/useShopQuery/index.d.ts +1 -0
- package/dist/esnext/hooks/useShopQuery/index.js +1 -0
- package/dist/esnext/index.d.ts +15 -0
- package/dist/esnext/index.js +19 -0
- package/dist/esnext/platforms/node.d.ts +10 -0
- package/dist/esnext/platforms/node.js +38 -0
- package/dist/esnext/platforms/worker-event.d.ts +9 -0
- package/dist/esnext/platforms/worker-event.js +24 -0
- package/dist/esnext/storefront-api-types.d.ts +6121 -0
- package/dist/esnext/storefront-api-types.js +1709 -0
- package/dist/esnext/streaming.server.d.ts +20 -0
- package/dist/esnext/streaming.server.js +49 -0
- package/dist/esnext/types.d.ts +98 -0
- package/dist/esnext/types.js +1 -0
- package/dist/esnext/utilities/apiRoutes.d.ts +36 -0
- package/dist/esnext/utilities/apiRoutes.js +109 -0
- package/dist/esnext/utilities/bot-ua.d.ts +4 -0
- package/dist/esnext/utilities/bot-ua.js +54 -0
- package/dist/esnext/utilities/defer.d.ts +6 -0
- package/dist/esnext/utilities/defer.js +14 -0
- package/dist/esnext/utilities/error.d.ts +1 -0
- package/dist/esnext/utilities/error.js +6 -0
- package/dist/esnext/utilities/fetch.d.ts +4 -0
- package/dist/esnext/utilities/fetch.js +34 -0
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +5 -0
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +7 -0
- package/dist/esnext/utilities/flattenConnection/index.d.ts +1 -0
- package/dist/esnext/utilities/flattenConnection/index.js +1 -0
- package/dist/esnext/utilities/image_size.d.ts +29 -0
- package/dist/esnext/utilities/image_size.js +80 -0
- package/dist/esnext/utilities/index.d.ts +11 -0
- package/dist/esnext/utilities/index.js +11 -0
- package/dist/esnext/utilities/isClient/index.d.ts +1 -0
- package/dist/esnext/utilities/isClient/index.js +1 -0
- package/dist/esnext/utilities/isClient/isClient.d.ts +4 -0
- package/dist/esnext/utilities/isClient/isClient.js +6 -0
- package/dist/esnext/utilities/isServer/index.d.ts +1 -0
- package/dist/esnext/utilities/isServer/index.js +1 -0
- package/dist/esnext/utilities/isServer/isServer.d.ts +4 -0
- package/dist/esnext/utilities/isServer/isServer.js +7 -0
- package/dist/esnext/utilities/load_script.d.ts +3 -0
- package/dist/esnext/utilities/load_script.js +23 -0
- package/dist/esnext/utilities/log/index.d.ts +4 -0
- package/dist/esnext/utilities/log/index.js +4 -0
- package/dist/esnext/utilities/log/log-cache-api-status.d.ts +1 -0
- package/dist/esnext/utilities/log/log-cache-api-status.js +9 -0
- package/dist/esnext/utilities/log/log-cache-header.d.ts +10 -0
- package/dist/esnext/utilities/log/log-cache-header.js +30 -0
- package/dist/esnext/utilities/log/log-query-timeline.d.ts +12 -0
- package/dist/esnext/utilities/log/log-query-timeline.js +84 -0
- package/dist/esnext/utilities/log/log.d.ts +21 -0
- package/dist/esnext/utilities/log/log.js +66 -0
- package/dist/esnext/utilities/log/utils.d.ts +3 -0
- package/dist/esnext/utilities/log/utils.js +13 -0
- package/dist/esnext/utilities/matchPath.d.ts +10 -0
- package/dist/esnext/utilities/matchPath.js +54 -0
- package/dist/esnext/utilities/measurement.d.ts +3 -0
- package/dist/esnext/utilities/measurement.js +98 -0
- package/dist/esnext/utilities/object.d.ts +5 -0
- package/dist/esnext/utilities/object.js +7 -0
- package/dist/esnext/utilities/parseMetafieldValue/index.d.ts +1 -0
- package/dist/esnext/utilities/parseMetafieldValue/index.js +1 -0
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +5 -0
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.js +35 -0
- package/dist/esnext/utilities/suspense.d.ts +7 -0
- package/dist/esnext/utilities/suspense.js +26 -0
- package/dist/esnext/utilities/template.d.ts +9 -0
- package/dist/esnext/utilities/template.js +23 -0
- package/dist/esnext/utilities/timing.d.ts +7 -0
- package/dist/esnext/utilities/timing.js +14 -0
- package/dist/esnext/utilities/video_parameters.d.ts +47 -0
- package/dist/esnext/utilities/video_parameters.js +22 -0
- package/dist/esnext/utilities/web-api-polyfill.d.ts +1 -0
- package/dist/esnext/utilities/web-api-polyfill.js +19 -0
- package/dist/esnext/version.d.ts +1 -0
- package/dist/esnext/version.js +1 -0
- package/dist/node/constants.d.ts +1 -0
- package/dist/node/constants.js +4 -0
- package/dist/node/entry-server.d.ts +22 -0
- package/dist/node/entry-server.js +541 -0
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +23 -0
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +143 -0
- package/dist/node/foundation/ServerRequestProvider/index.d.ts +1 -0
- package/dist/node/foundation/ServerRequestProvider/index.js +17 -0
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.d.ts +25 -0
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.js +72 -0
- package/dist/node/foundation/ServerStateProvider/index.d.ts +2 -0
- package/dist/node/foundation/ServerStateProvider/index.js +6 -0
- package/dist/node/foundation/ShopifyProvider/types.d.ts +15 -0
- package/dist/node/foundation/ShopifyProvider/types.js +2 -0
- package/dist/node/framework/CachingStrategy/index.d.ts +10 -0
- package/dist/node/framework/CachingStrategy/index.js +108 -0
- package/dist/node/framework/Hydration/Html.d.ts +11 -0
- package/dist/node/framework/Hydration/Html.js +92 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +47 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.js +118 -0
- package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +32 -0
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +59 -0
- package/dist/node/framework/Hydration/rsc.d.ts +11 -0
- package/dist/node/framework/Hydration/rsc.js +75 -0
- package/dist/node/framework/cache/in-memory.d.ts +11 -0
- package/dist/node/framework/cache/in-memory.js +52 -0
- package/dist/node/framework/cache.d.ts +26 -0
- package/dist/node/framework/cache.js +97 -0
- package/dist/node/framework/config.d.ts +6 -0
- package/dist/node/framework/config.js +11 -0
- package/dist/node/framework/graphiql.d.ts +1 -0
- package/dist/node/framework/graphiql.js +42 -0
- package/dist/node/framework/middleware.d.ts +22 -0
- package/dist/node/framework/middleware.js +134 -0
- package/dist/node/framework/plugin.d.ts +4 -0
- package/dist/node/framework/plugin.js +69 -0
- package/dist/node/framework/plugins/vite-plugin-hydration-auto-import.d.ts +3 -0
- package/dist/node/framework/plugins/vite-plugin-hydration-auto-import.js +43 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +9 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.js +39 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.d.ts +3 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +86 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +11 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +62 -0
- package/dist/node/framework/plugins/vite-plugin-platform-entry.d.ts +3 -0
- package/dist/node/framework/plugins/vite-plugin-platform-entry.js +75 -0
- package/dist/node/framework/plugins/vite-plugin-purge-query-cache.d.ts +3 -0
- package/dist/node/framework/plugins/vite-plugin-purge-query-cache.js +16 -0
- package/dist/node/framework/plugins/vite-plugin-ssr-interop.d.ts +3 -0
- package/dist/node/framework/plugins/vite-plugin-ssr-interop.js +15 -0
- package/dist/node/framework/runtime.d.ts +13 -0
- package/dist/node/framework/runtime.js +35 -0
- package/dist/node/storefront-api-types.d.ts +6121 -0
- package/dist/node/storefront-api-types.js +1712 -0
- package/dist/node/streaming.server.d.ts +20 -0
- package/dist/node/streaming.server.js +49 -0
- package/dist/node/types.d.ts +98 -0
- package/dist/node/types.js +2 -0
- package/dist/node/utilities/apiRoutes.d.ts +36 -0
- package/dist/node/utilities/apiRoutes.js +115 -0
- package/dist/node/utilities/bot-ua.d.ts +4 -0
- package/dist/node/utilities/bot-ua.js +58 -0
- package/dist/node/utilities/defer.d.ts +6 -0
- package/dist/node/utilities/defer.js +18 -0
- package/dist/node/utilities/error.d.ts +1 -0
- package/dist/node/utilities/error.js +10 -0
- package/dist/node/utilities/fetch.d.ts +4 -0
- package/dist/node/utilities/fetch.js +40 -0
- package/dist/node/utilities/log/index.d.ts +4 -0
- package/dist/node/utilities/log/index.js +18 -0
- package/dist/node/utilities/log/log-cache-api-status.d.ts +1 -0
- package/dist/node/utilities/log/log-cache-api-status.js +13 -0
- package/dist/node/utilities/log/log-cache-header.d.ts +10 -0
- package/dist/node/utilities/log/log-cache-header.js +35 -0
- package/dist/node/utilities/log/log-query-timeline.d.ts +12 -0
- package/dist/node/utilities/log/log-query-timeline.js +89 -0
- package/dist/node/utilities/log/log.d.ts +21 -0
- package/dist/node/utilities/log/log.js +74 -0
- package/dist/node/utilities/log/utils.d.ts +3 -0
- package/dist/node/utilities/log/utils.js +18 -0
- package/dist/node/utilities/matchPath.d.ts +10 -0
- package/dist/node/utilities/matchPath.js +58 -0
- package/dist/node/utilities/template.d.ts +9 -0
- package/dist/node/utilities/template.js +27 -0
- package/dist/node/utilities/timing.d.ts +7 -0
- package/dist/node/utilities/timing.js +18 -0
- package/dist/node/utilities/web-api-polyfill.d.ts +1 -0
- package/dist/node/utilities/web-api-polyfill.js +47 -0
- package/dist/node/version.d.ts +1 -0
- package/dist/node/version.js +4 -0
- package/entry-client.d.ts +1 -0
- package/entry-client.js +1 -0
- package/entry-server.d.ts +1 -0
- package/entry-server.js +1 -0
- package/fragments.d.ts +1 -0
- package/fragments.js +1 -0
- package/middleware.d.ts +1 -0
- package/middleware.js +1 -0
- package/package.json +121 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +1 -0
- package/vendor/react-server-dom-vite/LICENSE +21 -0
- package/vendor/react-server-dom-vite/README.md +5 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +243 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +1031 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +430 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +1053 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +446 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +623 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +255 -0
- package/vendor/react-server-dom-vite/esm/package.json +3 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +83 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +239 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +1014 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +1032 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +613 -0
- package/vendor/react-server-dom-vite/index.js +7 -0
- package/vendor/react-server-dom-vite/package.json +68 -0
- package/vendor/react-server-dom-vite/plugin.js +3 -0
- package/vendor/react-server-dom-vite/writer.browser.server.js +7 -0
- package/vendor/react-server-dom-vite/writer.node.server.js +7 -0
- package/web-polyfills.js +1 -0
|
@@ -0,0 +1,1032 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-server-dom-vite-writer.node.server.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from 'react';
|
|
12
|
+
|
|
13
|
+
var ReactSharedInternals = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
14
|
+
|
|
15
|
+
function error(format) {
|
|
16
|
+
{
|
|
17
|
+
{
|
|
18
|
+
for (
|
|
19
|
+
var _len2 = arguments.length,
|
|
20
|
+
args = new Array(_len2 > 1 ? _len2 - 1 : 0),
|
|
21
|
+
_key2 = 1;
|
|
22
|
+
_key2 < _len2;
|
|
23
|
+
_key2++
|
|
24
|
+
) {
|
|
25
|
+
args[_key2 - 1] = arguments[_key2];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
printWarning('error', format, args);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
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();
|
|
39
|
+
|
|
40
|
+
if (stack !== '') {
|
|
41
|
+
format += '%s';
|
|
42
|
+
args = args.concat([stack]);
|
|
43
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
44
|
+
|
|
45
|
+
var argsWithFormat = args.map(function (item) {
|
|
46
|
+
return String(item);
|
|
47
|
+
}); // Careful: RN currently depends on this prefix
|
|
48
|
+
|
|
49
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
50
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
51
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
52
|
+
|
|
53
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function scheduleWork(callback) {
|
|
58
|
+
setImmediate(callback);
|
|
59
|
+
}
|
|
60
|
+
function flushBuffered(destination) {
|
|
61
|
+
// If we don't have any more data to send right now.
|
|
62
|
+
// Flush whatever is in the buffer to the wire.
|
|
63
|
+
if (typeof destination.flush === 'function') {
|
|
64
|
+
// By convention the Zlib streams provide a flush function for this purpose.
|
|
65
|
+
// For Express, compression middleware adds this method.
|
|
66
|
+
destination.flush();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function beginWriting(destination) {
|
|
70
|
+
// Older Node streams like http.createServer don't have this.
|
|
71
|
+
if (typeof destination.cork === 'function') {
|
|
72
|
+
destination.cork();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function writeChunk(destination, chunk) {
|
|
76
|
+
var nodeBuffer = chunk; // close enough
|
|
77
|
+
|
|
78
|
+
return destination.write(nodeBuffer);
|
|
79
|
+
}
|
|
80
|
+
function completeWriting(destination) {
|
|
81
|
+
// Older Node streams like http.createServer don't have this.
|
|
82
|
+
if (typeof destination.uncork === 'function') {
|
|
83
|
+
destination.uncork();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function close(destination) {
|
|
87
|
+
destination.end();
|
|
88
|
+
}
|
|
89
|
+
function stringToChunk(content) {
|
|
90
|
+
return content;
|
|
91
|
+
}
|
|
92
|
+
function closeWithError(destination, error) {
|
|
93
|
+
// $FlowFixMe: This is an Error object or the destination accepts other types.
|
|
94
|
+
destination.destroy(error);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// This file is an intermediate layer to translate between Flight
|
|
98
|
+
var stringify = JSON.stringify;
|
|
99
|
+
|
|
100
|
+
function serializeRowHeader(tag, id) {
|
|
101
|
+
return tag + id.toString(16) + ':';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function processErrorChunk(request, id, message, stack) {
|
|
105
|
+
var errorInfo = {
|
|
106
|
+
message: message,
|
|
107
|
+
stack: stack,
|
|
108
|
+
};
|
|
109
|
+
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
|
110
|
+
return stringToChunk(row);
|
|
111
|
+
}
|
|
112
|
+
function processModelChunk(request, id, model) {
|
|
113
|
+
var json = stringify(model, request.toJSON);
|
|
114
|
+
var row = serializeRowHeader('J', id) + json + '\n';
|
|
115
|
+
return stringToChunk(row);
|
|
116
|
+
}
|
|
117
|
+
function processModuleChunk(request, id, moduleMetaData) {
|
|
118
|
+
var json = stringify(moduleMetaData);
|
|
119
|
+
var row = serializeRowHeader('M', id) + json + '\n';
|
|
120
|
+
return stringToChunk(row);
|
|
121
|
+
}
|
|
122
|
+
function processSymbolChunk(request, id, name) {
|
|
123
|
+
var json = stringify(name);
|
|
124
|
+
var row = serializeRowHeader('S', id) + json + '\n';
|
|
125
|
+
return stringToChunk(row);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// eslint-disable-next-line no-unused-vars
|
|
129
|
+
var MODULE_TAG = Symbol.for('react.module.reference');
|
|
130
|
+
function getModuleKey(reference) {
|
|
131
|
+
return reference.filepath + '#' + reference.name;
|
|
132
|
+
}
|
|
133
|
+
function isModuleReference(reference) {
|
|
134
|
+
return (reference.$$typeof_rsc || reference.$$typeof) === MODULE_TAG;
|
|
135
|
+
}
|
|
136
|
+
function resolveModuleMetaData(config, moduleReference) {
|
|
137
|
+
return {
|
|
138
|
+
id: moduleReference.filepath,
|
|
139
|
+
name: moduleReference.name,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ATTENTION
|
|
144
|
+
// When adding new symbols to this file,
|
|
145
|
+
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
146
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
147
|
+
// nor polyfill, then a plain number is used for performance.
|
|
148
|
+
var REACT_ELEMENT_TYPE = 0xeac7;
|
|
149
|
+
var REACT_PORTAL_TYPE = 0xeaca;
|
|
150
|
+
var REACT_FRAGMENT_TYPE = 0xeacb;
|
|
151
|
+
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
|
152
|
+
var REACT_PROFILER_TYPE = 0xead2;
|
|
153
|
+
var REACT_PROVIDER_TYPE = 0xeacd;
|
|
154
|
+
var REACT_CONTEXT_TYPE = 0xeace;
|
|
155
|
+
var REACT_FORWARD_REF_TYPE = 0xead0;
|
|
156
|
+
var REACT_SUSPENSE_TYPE = 0xead1;
|
|
157
|
+
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
|
158
|
+
var REACT_MEMO_TYPE = 0xead3;
|
|
159
|
+
var REACT_LAZY_TYPE = 0xead4;
|
|
160
|
+
var REACT_SCOPE_TYPE = 0xead7;
|
|
161
|
+
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
|
162
|
+
var REACT_OFFSCREEN_TYPE = 0xeae2;
|
|
163
|
+
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
|
164
|
+
var REACT_CACHE_TYPE = 0xeae4;
|
|
165
|
+
|
|
166
|
+
if (typeof Symbol === 'function' && Symbol.for) {
|
|
167
|
+
var symbolFor = Symbol.for;
|
|
168
|
+
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
|
169
|
+
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
|
170
|
+
REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
|
|
171
|
+
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
|
172
|
+
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
|
173
|
+
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
|
174
|
+
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
|
175
|
+
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
|
176
|
+
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
|
177
|
+
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
|
178
|
+
REACT_MEMO_TYPE = symbolFor('react.memo');
|
|
179
|
+
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
|
180
|
+
REACT_SCOPE_TYPE = symbolFor('react.scope');
|
|
181
|
+
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
|
182
|
+
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
|
|
183
|
+
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
|
184
|
+
REACT_CACHE_TYPE = symbolFor('react.cache');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
|
188
|
+
|
|
189
|
+
function isArray(a) {
|
|
190
|
+
return isArrayImpl(a);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
194
|
+
|
|
195
|
+
function defaultErrorHandler(error) {
|
|
196
|
+
console['error'](error); // Don't transform to our wrapper
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var OPEN = 0;
|
|
200
|
+
var CLOSING = 1;
|
|
201
|
+
var CLOSED = 2;
|
|
202
|
+
function createRequest(model, bundlerConfig, onError) {
|
|
203
|
+
var pingedSegments = [];
|
|
204
|
+
var request = {
|
|
205
|
+
status: OPEN,
|
|
206
|
+
fatalError: null,
|
|
207
|
+
destination: null,
|
|
208
|
+
bundlerConfig: bundlerConfig,
|
|
209
|
+
cache: new Map(),
|
|
210
|
+
nextChunkId: 0,
|
|
211
|
+
pendingChunks: 0,
|
|
212
|
+
pingedSegments: pingedSegments,
|
|
213
|
+
completedModuleChunks: [],
|
|
214
|
+
completedJSONChunks: [],
|
|
215
|
+
completedErrorChunks: [],
|
|
216
|
+
writtenSymbols: new Map(),
|
|
217
|
+
writtenModules: new Map(),
|
|
218
|
+
onError: onError === undefined ? defaultErrorHandler : onError,
|
|
219
|
+
toJSON: function (key, value) {
|
|
220
|
+
return resolveModelToJSON(request, this, key, value);
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
request.pendingChunks++;
|
|
224
|
+
var rootSegment = createSegment(request, model);
|
|
225
|
+
pingedSegments.push(rootSegment);
|
|
226
|
+
return request;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function attemptResolveElement(type, key, ref, props) {
|
|
230
|
+
if (ref !== null && ref !== undefined) {
|
|
231
|
+
// When the ref moves to the regular props object this will implicitly
|
|
232
|
+
// throw for functions. We could probably relax it to a DEV warning for other
|
|
233
|
+
// cases.
|
|
234
|
+
throw new Error(
|
|
235
|
+
'Refs cannot be used in server components, nor passed to client components.'
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (typeof type === 'function') {
|
|
240
|
+
// This is a server-side component.
|
|
241
|
+
return type(props);
|
|
242
|
+
} else if (typeof type === 'string') {
|
|
243
|
+
// This is a host element. E.g. HTML.
|
|
244
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
245
|
+
} else if (typeof type === 'symbol') {
|
|
246
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
247
|
+
// For key-less fragments, we add a small optimization to avoid serializing
|
|
248
|
+
// it as a wrapper.
|
|
249
|
+
// TODO: If a key is specified, we should propagate its key to any children.
|
|
250
|
+
// Same as if a server component has a key.
|
|
251
|
+
return props.children;
|
|
252
|
+
} // This might be a built-in React component. We'll let the client decide.
|
|
253
|
+
// Any built-in works as long as its props are serializable.
|
|
254
|
+
|
|
255
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
256
|
+
} else if (type != null && typeof type === 'object') {
|
|
257
|
+
if (isModuleReference(type)) {
|
|
258
|
+
// This is a reference to a client component.
|
|
259
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
switch (type.$$typeof) {
|
|
263
|
+
case REACT_FORWARD_REF_TYPE: {
|
|
264
|
+
var render = type.render;
|
|
265
|
+
return render(props, undefined);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
case REACT_MEMO_TYPE: {
|
|
269
|
+
return attemptResolveElement(type.type, key, ref, props);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
throw new Error(
|
|
275
|
+
'Unsupported server component type: ' + describeValueForErrorMessage(type)
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function pingSegment(request, segment) {
|
|
280
|
+
var pingedSegments = request.pingedSegments;
|
|
281
|
+
pingedSegments.push(segment);
|
|
282
|
+
|
|
283
|
+
if (pingedSegments.length === 1) {
|
|
284
|
+
scheduleWork(function () {
|
|
285
|
+
return performWork(request);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function createSegment(request, model) {
|
|
291
|
+
var id = request.nextChunkId++;
|
|
292
|
+
var segment = {
|
|
293
|
+
id: id,
|
|
294
|
+
model: model,
|
|
295
|
+
ping: function () {
|
|
296
|
+
return pingSegment(request, segment);
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
return segment;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function serializeByValueID(id) {
|
|
303
|
+
return '$' + id.toString(16);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function serializeByRefID(id) {
|
|
307
|
+
return '@' + id.toString(16);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function escapeStringValue(value) {
|
|
311
|
+
if (value[0] === '$' || value[0] === '@') {
|
|
312
|
+
// We need to escape $ or @ prefixed strings since we use those to encode
|
|
313
|
+
// references to IDs and as special symbol values.
|
|
314
|
+
return '$' + value;
|
|
315
|
+
} else {
|
|
316
|
+
return value;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function isObjectPrototype(object) {
|
|
321
|
+
if (!object) {
|
|
322
|
+
return false;
|
|
323
|
+
} // $FlowFixMe
|
|
324
|
+
|
|
325
|
+
var ObjectPrototype = Object.prototype;
|
|
326
|
+
|
|
327
|
+
if (object === ObjectPrototype) {
|
|
328
|
+
return true;
|
|
329
|
+
} // It might be an object from a different Realm which is
|
|
330
|
+
// still just a plain simple object.
|
|
331
|
+
|
|
332
|
+
if (Object.getPrototypeOf(object)) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
var names = Object.getOwnPropertyNames(object);
|
|
337
|
+
|
|
338
|
+
for (var i = 0; i < names.length; i++) {
|
|
339
|
+
if (!(names[i] in ObjectPrototype)) {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function isSimpleObject(object) {
|
|
348
|
+
if (!isObjectPrototype(Object.getPrototypeOf(object))) {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
var names = Object.getOwnPropertyNames(object);
|
|
353
|
+
|
|
354
|
+
for (var i = 0; i < names.length; i++) {
|
|
355
|
+
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
|
356
|
+
|
|
357
|
+
if (!descriptor) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (!descriptor.enumerable) {
|
|
362
|
+
if (
|
|
363
|
+
(names[i] === 'key' || names[i] === 'ref') &&
|
|
364
|
+
typeof descriptor.get === 'function'
|
|
365
|
+
) {
|
|
366
|
+
// React adds key and ref getters to props objects to issue warnings.
|
|
367
|
+
// Those getters will not be transferred to the client, but that's ok,
|
|
368
|
+
// so we'll special case them.
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function objectName(object) {
|
|
380
|
+
var name = Object.prototype.toString.call(object);
|
|
381
|
+
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
|
382
|
+
return p0;
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function describeKeyForErrorMessage(key) {
|
|
387
|
+
var encodedKey = JSON.stringify(key);
|
|
388
|
+
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function describeValueForErrorMessage(value) {
|
|
392
|
+
switch (typeof value) {
|
|
393
|
+
case 'string': {
|
|
394
|
+
return JSON.stringify(
|
|
395
|
+
value.length <= 10 ? value : value.substr(0, 10) + '...'
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
case 'object': {
|
|
400
|
+
if (isArray(value)) {
|
|
401
|
+
return '[...]';
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
var name = objectName(value);
|
|
405
|
+
|
|
406
|
+
if (name === 'Object') {
|
|
407
|
+
return '{...}';
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return name;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
case 'function':
|
|
414
|
+
return 'function';
|
|
415
|
+
|
|
416
|
+
default:
|
|
417
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
418
|
+
return String(value);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
423
|
+
if (isArray(objectOrArray)) {
|
|
424
|
+
var str = '['; // $FlowFixMe: Should be refined by now.
|
|
425
|
+
|
|
426
|
+
var array = objectOrArray;
|
|
427
|
+
|
|
428
|
+
for (var i = 0; i < array.length; i++) {
|
|
429
|
+
if (i > 0) {
|
|
430
|
+
str += ', ';
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (i > 6) {
|
|
434
|
+
str += '...';
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
var _value = array[i];
|
|
439
|
+
|
|
440
|
+
if (
|
|
441
|
+
'' + i === expandedName &&
|
|
442
|
+
typeof _value === 'object' &&
|
|
443
|
+
_value !== null
|
|
444
|
+
) {
|
|
445
|
+
str += describeObjectForErrorMessage(_value);
|
|
446
|
+
} else {
|
|
447
|
+
str += describeValueForErrorMessage(_value);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
str += ']';
|
|
452
|
+
return str;
|
|
453
|
+
} else {
|
|
454
|
+
var _str = '{'; // $FlowFixMe: Should be refined by now.
|
|
455
|
+
|
|
456
|
+
var object = objectOrArray;
|
|
457
|
+
var names = Object.keys(object);
|
|
458
|
+
|
|
459
|
+
for (var _i = 0; _i < names.length; _i++) {
|
|
460
|
+
if (_i > 0) {
|
|
461
|
+
_str += ', ';
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (_i > 6) {
|
|
465
|
+
_str += '...';
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
var name = names[_i];
|
|
470
|
+
_str += describeKeyForErrorMessage(name) + ': ';
|
|
471
|
+
var _value2 = object[name];
|
|
472
|
+
|
|
473
|
+
if (
|
|
474
|
+
name === expandedName &&
|
|
475
|
+
typeof _value2 === 'object' &&
|
|
476
|
+
_value2 !== null
|
|
477
|
+
) {
|
|
478
|
+
_str += describeObjectForErrorMessage(_value2);
|
|
479
|
+
} else {
|
|
480
|
+
_str += describeValueForErrorMessage(_value2);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
_str += '}';
|
|
485
|
+
return _str;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function resolveModelToJSON(request, parent, key, value) {
|
|
490
|
+
{
|
|
491
|
+
// $FlowFixMe
|
|
492
|
+
var originalValue = parent[key];
|
|
493
|
+
|
|
494
|
+
if (typeof originalValue === 'object' && originalValue !== value) {
|
|
495
|
+
error(
|
|
496
|
+
'Only plain objects can be passed to client components from server components. ' +
|
|
497
|
+
'Objects with toJSON methods are not supported. Convert it manually ' +
|
|
498
|
+
'to a simple value before passing it to props. ' +
|
|
499
|
+
'Remove %s from these props: %s',
|
|
500
|
+
describeKeyForErrorMessage(key),
|
|
501
|
+
describeObjectForErrorMessage(parent)
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
} // Special Symbols
|
|
505
|
+
|
|
506
|
+
switch (value) {
|
|
507
|
+
case REACT_ELEMENT_TYPE:
|
|
508
|
+
return '$';
|
|
509
|
+
|
|
510
|
+
case REACT_LAZY_TYPE:
|
|
511
|
+
throw new Error(
|
|
512
|
+
'React Lazy Components are not yet supported on the server.'
|
|
513
|
+
);
|
|
514
|
+
} // Resolve server components.
|
|
515
|
+
|
|
516
|
+
while (
|
|
517
|
+
typeof value === 'object' &&
|
|
518
|
+
value !== null &&
|
|
519
|
+
value.$$typeof === REACT_ELEMENT_TYPE
|
|
520
|
+
) {
|
|
521
|
+
// TODO: Concatenate keys of parents onto children.
|
|
522
|
+
var element = value;
|
|
523
|
+
|
|
524
|
+
try {
|
|
525
|
+
// Attempt to render the server component.
|
|
526
|
+
value = attemptResolveElement(
|
|
527
|
+
element.type,
|
|
528
|
+
element.key,
|
|
529
|
+
element.ref,
|
|
530
|
+
element.props
|
|
531
|
+
);
|
|
532
|
+
} catch (x) {
|
|
533
|
+
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
|
534
|
+
// Something suspended, we'll need to create a new segment and resolve it later.
|
|
535
|
+
request.pendingChunks++;
|
|
536
|
+
var newSegment = createSegment(request, value);
|
|
537
|
+
var ping = newSegment.ping;
|
|
538
|
+
x.then(ping, ping);
|
|
539
|
+
return serializeByRefID(newSegment.id);
|
|
540
|
+
} else {
|
|
541
|
+
reportError(request, x); // Something errored. We'll still send everything we have up until this point.
|
|
542
|
+
// We'll replace this element with a lazy reference that throws on the client
|
|
543
|
+
// once it gets rendered.
|
|
544
|
+
|
|
545
|
+
request.pendingChunks++;
|
|
546
|
+
var errorId = request.nextChunkId++;
|
|
547
|
+
emitErrorChunk(request, errorId, x);
|
|
548
|
+
return serializeByRefID(errorId);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (value === null) {
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (typeof value === 'object') {
|
|
558
|
+
if (isModuleReference(value)) {
|
|
559
|
+
var moduleReference = value;
|
|
560
|
+
var moduleKey = getModuleKey(moduleReference);
|
|
561
|
+
var writtenModules = request.writtenModules;
|
|
562
|
+
var existingId = writtenModules.get(moduleKey);
|
|
563
|
+
|
|
564
|
+
if (existingId !== undefined) {
|
|
565
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
|
566
|
+
// If we're encoding the "type" of an element, we can refer
|
|
567
|
+
// to that by a lazy reference instead of directly since React
|
|
568
|
+
// knows how to deal with lazy values. This lets us suspend
|
|
569
|
+
// on this component rather than its parent until the code has
|
|
570
|
+
// loaded.
|
|
571
|
+
return serializeByRefID(existingId);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return serializeByValueID(existingId);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
try {
|
|
578
|
+
var moduleMetaData = resolveModuleMetaData(
|
|
579
|
+
request.bundlerConfig,
|
|
580
|
+
moduleReference
|
|
581
|
+
);
|
|
582
|
+
request.pendingChunks++;
|
|
583
|
+
var moduleId = request.nextChunkId++;
|
|
584
|
+
emitModuleChunk(request, moduleId, moduleMetaData);
|
|
585
|
+
writtenModules.set(moduleKey, moduleId);
|
|
586
|
+
|
|
587
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
|
588
|
+
// If we're encoding the "type" of an element, we can refer
|
|
589
|
+
// to that by a lazy reference instead of directly since React
|
|
590
|
+
// knows how to deal with lazy values. This lets us suspend
|
|
591
|
+
// on this component rather than its parent until the code has
|
|
592
|
+
// loaded.
|
|
593
|
+
return serializeByRefID(moduleId);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
return serializeByValueID(moduleId);
|
|
597
|
+
} catch (x) {
|
|
598
|
+
request.pendingChunks++;
|
|
599
|
+
|
|
600
|
+
var _errorId = request.nextChunkId++;
|
|
601
|
+
|
|
602
|
+
emitErrorChunk(request, _errorId, x);
|
|
603
|
+
return serializeByValueID(_errorId);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
{
|
|
608
|
+
if (value !== null && !isArray(value)) {
|
|
609
|
+
// Verify that this is a simple plain object.
|
|
610
|
+
if (objectName(value) !== 'Object') {
|
|
611
|
+
error(
|
|
612
|
+
'Only plain objects can be passed to client components from server components. ' +
|
|
613
|
+
'Built-ins like %s are not supported. ' +
|
|
614
|
+
'Remove %s from these props: %s',
|
|
615
|
+
objectName(value),
|
|
616
|
+
describeKeyForErrorMessage(key),
|
|
617
|
+
describeObjectForErrorMessage(parent)
|
|
618
|
+
);
|
|
619
|
+
} else if (!isSimpleObject(value)) {
|
|
620
|
+
error(
|
|
621
|
+
'Only plain objects can be passed to client components from server components. ' +
|
|
622
|
+
'Classes or other objects with methods are not supported. ' +
|
|
623
|
+
'Remove %s from these props: %s',
|
|
624
|
+
describeKeyForErrorMessage(key),
|
|
625
|
+
describeObjectForErrorMessage(parent, key)
|
|
626
|
+
);
|
|
627
|
+
} else if (Object.getOwnPropertySymbols) {
|
|
628
|
+
var symbols = Object.getOwnPropertySymbols(value);
|
|
629
|
+
|
|
630
|
+
if (symbols.length > 0) {
|
|
631
|
+
error(
|
|
632
|
+
'Only plain objects can be passed to client components from server components. ' +
|
|
633
|
+
'Objects with symbol properties like %s are not supported. ' +
|
|
634
|
+
'Remove %s from these props: %s',
|
|
635
|
+
symbols[0].description,
|
|
636
|
+
describeKeyForErrorMessage(key),
|
|
637
|
+
describeObjectForErrorMessage(parent, key)
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
return value;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (typeof value === 'string') {
|
|
648
|
+
return escapeStringValue(value);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
if (
|
|
652
|
+
typeof value === 'boolean' ||
|
|
653
|
+
typeof value === 'number' ||
|
|
654
|
+
typeof value === 'undefined'
|
|
655
|
+
) {
|
|
656
|
+
return value;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (typeof value === 'function') {
|
|
660
|
+
if (/^on[A-Z]/.test(key)) {
|
|
661
|
+
throw new Error(
|
|
662
|
+
'Event handlers cannot be passed to client component props. ' +
|
|
663
|
+
('Remove ' +
|
|
664
|
+
describeKeyForErrorMessage(key) +
|
|
665
|
+
' from these props if possible: ' +
|
|
666
|
+
describeObjectForErrorMessage(parent) +
|
|
667
|
+
'\n') +
|
|
668
|
+
'If you need interactivity, consider converting part of this to a client component.'
|
|
669
|
+
);
|
|
670
|
+
} else {
|
|
671
|
+
throw new Error(
|
|
672
|
+
'Functions cannot be passed directly to client components ' +
|
|
673
|
+
"because they're not serializable. " +
|
|
674
|
+
('Remove ' +
|
|
675
|
+
describeKeyForErrorMessage(key) +
|
|
676
|
+
' (' +
|
|
677
|
+
(value.displayName || value.name || 'function') +
|
|
678
|
+
') from this object, or avoid the entire object: ' +
|
|
679
|
+
describeObjectForErrorMessage(parent))
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
if (typeof value === 'symbol') {
|
|
685
|
+
var writtenSymbols = request.writtenSymbols;
|
|
686
|
+
|
|
687
|
+
var _existingId = writtenSymbols.get(value);
|
|
688
|
+
|
|
689
|
+
if (_existingId !== undefined) {
|
|
690
|
+
return serializeByValueID(_existingId);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
var name = value.description;
|
|
694
|
+
|
|
695
|
+
if (Symbol.for(name) !== value) {
|
|
696
|
+
throw new Error(
|
|
697
|
+
'Only global symbols received from Symbol.for(...) can be passed to client components. ' +
|
|
698
|
+
('The symbol Symbol.for(' +
|
|
699
|
+
value.description +
|
|
700
|
+
') cannot be found among global symbols. ') +
|
|
701
|
+
('Remove ' +
|
|
702
|
+
describeKeyForErrorMessage(key) +
|
|
703
|
+
' from this object, or avoid the entire object: ' +
|
|
704
|
+
describeObjectForErrorMessage(parent))
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
request.pendingChunks++;
|
|
709
|
+
var symbolId = request.nextChunkId++;
|
|
710
|
+
emitSymbolChunk(request, symbolId, name);
|
|
711
|
+
writtenSymbols.set(value, symbolId);
|
|
712
|
+
return serializeByValueID(symbolId);
|
|
713
|
+
} // $FlowFixMe: bigint isn't added to Flow yet.
|
|
714
|
+
|
|
715
|
+
if (typeof value === 'bigint') {
|
|
716
|
+
throw new Error(
|
|
717
|
+
'BigInt (' +
|
|
718
|
+
value +
|
|
719
|
+
') is not yet supported in client component props. ' +
|
|
720
|
+
('Remove ' +
|
|
721
|
+
describeKeyForErrorMessage(key) +
|
|
722
|
+
' from this object or use a plain number instead: ' +
|
|
723
|
+
describeObjectForErrorMessage(parent))
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
throw new Error(
|
|
728
|
+
'Type ' +
|
|
729
|
+
typeof value +
|
|
730
|
+
' is not supported in client component props. ' +
|
|
731
|
+
('Remove ' +
|
|
732
|
+
describeKeyForErrorMessage(key) +
|
|
733
|
+
' from this object, or avoid the entire object: ' +
|
|
734
|
+
describeObjectForErrorMessage(parent))
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function reportError(request, error) {
|
|
739
|
+
var onError = request.onError;
|
|
740
|
+
onError(error);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function fatalError(request, error) {
|
|
744
|
+
// This is called outside error handling code such as if an error happens in React internals.
|
|
745
|
+
if (request.destination !== null) {
|
|
746
|
+
request.status = CLOSED;
|
|
747
|
+
closeWithError(request.destination, error);
|
|
748
|
+
} else {
|
|
749
|
+
request.status = CLOSING;
|
|
750
|
+
request.fatalError = error;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function emitErrorChunk(request, id, error) {
|
|
755
|
+
// TODO: We should not leak error messages to the client in prod.
|
|
756
|
+
// Give this an error code instead and log on the server.
|
|
757
|
+
// We can serialize the error in DEV as a convenience.
|
|
758
|
+
var message;
|
|
759
|
+
var stack = '';
|
|
760
|
+
|
|
761
|
+
try {
|
|
762
|
+
if (error instanceof Error) {
|
|
763
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
764
|
+
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
|
765
|
+
|
|
766
|
+
stack = String(error.stack);
|
|
767
|
+
} else {
|
|
768
|
+
message = 'Error: ' + error;
|
|
769
|
+
}
|
|
770
|
+
} catch (x) {
|
|
771
|
+
message = 'An error occurred but serializing the error message failed.';
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
var processedChunk = processErrorChunk(request, id, message, stack);
|
|
775
|
+
request.completedErrorChunks.push(processedChunk);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
function emitModuleChunk(request, id, moduleMetaData) {
|
|
779
|
+
var processedChunk = processModuleChunk(request, id, moduleMetaData);
|
|
780
|
+
request.completedModuleChunks.push(processedChunk);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
function emitSymbolChunk(request, id, name) {
|
|
784
|
+
var processedChunk = processSymbolChunk(request, id, name);
|
|
785
|
+
request.completedModuleChunks.push(processedChunk);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function retrySegment(request, segment) {
|
|
789
|
+
try {
|
|
790
|
+
var _value3 = segment.model;
|
|
791
|
+
|
|
792
|
+
while (
|
|
793
|
+
typeof _value3 === 'object' &&
|
|
794
|
+
_value3 !== null &&
|
|
795
|
+
_value3.$$typeof === REACT_ELEMENT_TYPE
|
|
796
|
+
) {
|
|
797
|
+
// TODO: Concatenate keys of parents onto children.
|
|
798
|
+
var element = _value3; // Attempt to render the server component.
|
|
799
|
+
// Doing this here lets us reuse this same segment if the next component
|
|
800
|
+
// also suspends.
|
|
801
|
+
|
|
802
|
+
segment.model = _value3;
|
|
803
|
+
_value3 = attemptResolveElement(
|
|
804
|
+
element.type,
|
|
805
|
+
element.key,
|
|
806
|
+
element.ref,
|
|
807
|
+
element.props
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
var processedChunk = processModelChunk(request, segment.id, _value3);
|
|
812
|
+
request.completedJSONChunks.push(processedChunk);
|
|
813
|
+
} catch (x) {
|
|
814
|
+
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
|
815
|
+
// Something suspended again, let's pick it back up later.
|
|
816
|
+
var ping = segment.ping;
|
|
817
|
+
x.then(ping, ping);
|
|
818
|
+
return;
|
|
819
|
+
} else {
|
|
820
|
+
reportError(request, x); // This errored, we need to serialize this error to the
|
|
821
|
+
|
|
822
|
+
emitErrorChunk(request, segment.id, x);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function performWork(request) {
|
|
828
|
+
var prevDispatcher = ReactCurrentDispatcher.current;
|
|
829
|
+
var prevCache = currentCache;
|
|
830
|
+
ReactCurrentDispatcher.current = Dispatcher;
|
|
831
|
+
currentCache = request.cache;
|
|
832
|
+
|
|
833
|
+
try {
|
|
834
|
+
var pingedSegments = request.pingedSegments;
|
|
835
|
+
request.pingedSegments = [];
|
|
836
|
+
|
|
837
|
+
for (var i = 0; i < pingedSegments.length; i++) {
|
|
838
|
+
var segment = pingedSegments[i];
|
|
839
|
+
retrySegment(request, segment);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
if (request.destination !== null) {
|
|
843
|
+
flushCompletedChunks(request, request.destination);
|
|
844
|
+
}
|
|
845
|
+
} catch (error) {
|
|
846
|
+
reportError(request, error);
|
|
847
|
+
fatalError(request, error);
|
|
848
|
+
} finally {
|
|
849
|
+
ReactCurrentDispatcher.current = prevDispatcher;
|
|
850
|
+
currentCache = prevCache;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function flushCompletedChunks(request, destination) {
|
|
855
|
+
beginWriting(destination);
|
|
856
|
+
|
|
857
|
+
try {
|
|
858
|
+
// We emit module chunks first in the stream so that
|
|
859
|
+
// they can be preloaded as early as possible.
|
|
860
|
+
var moduleChunks = request.completedModuleChunks;
|
|
861
|
+
var i = 0;
|
|
862
|
+
|
|
863
|
+
for (; i < moduleChunks.length; i++) {
|
|
864
|
+
request.pendingChunks--;
|
|
865
|
+
var chunk = moduleChunks[i];
|
|
866
|
+
|
|
867
|
+
if (!writeChunk(destination, chunk)) {
|
|
868
|
+
request.destination = null;
|
|
869
|
+
i++;
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
moduleChunks.splice(0, i); // Next comes model data.
|
|
875
|
+
|
|
876
|
+
var jsonChunks = request.completedJSONChunks;
|
|
877
|
+
i = 0;
|
|
878
|
+
|
|
879
|
+
for (; i < jsonChunks.length; i++) {
|
|
880
|
+
request.pendingChunks--;
|
|
881
|
+
var _chunk = jsonChunks[i];
|
|
882
|
+
|
|
883
|
+
if (!writeChunk(destination, _chunk)) {
|
|
884
|
+
request.destination = null;
|
|
885
|
+
i++;
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
jsonChunks.splice(0, i); // Finally, errors are sent. The idea is that it's ok to delay
|
|
891
|
+
// any error messages and prioritize display of other parts of
|
|
892
|
+
// the page.
|
|
893
|
+
|
|
894
|
+
var errorChunks = request.completedErrorChunks;
|
|
895
|
+
i = 0;
|
|
896
|
+
|
|
897
|
+
for (; i < errorChunks.length; i++) {
|
|
898
|
+
request.pendingChunks--;
|
|
899
|
+
var _chunk2 = errorChunks[i];
|
|
900
|
+
|
|
901
|
+
if (!writeChunk(destination, _chunk2)) {
|
|
902
|
+
request.destination = null;
|
|
903
|
+
i++;
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
errorChunks.splice(0, i);
|
|
909
|
+
} finally {
|
|
910
|
+
completeWriting(destination);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
flushBuffered(destination);
|
|
914
|
+
|
|
915
|
+
if (request.pendingChunks === 0) {
|
|
916
|
+
// We're done.
|
|
917
|
+
close(destination);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
function startWork(request) {
|
|
922
|
+
scheduleWork(function () {
|
|
923
|
+
return performWork(request);
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
function startFlowing(request, destination) {
|
|
927
|
+
if (request.status === CLOSING) {
|
|
928
|
+
request.status = CLOSED;
|
|
929
|
+
closeWithError(destination, request.fatalError);
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
if (request.status === CLOSED) {
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
request.destination = destination;
|
|
938
|
+
|
|
939
|
+
try {
|
|
940
|
+
flushCompletedChunks(request, destination);
|
|
941
|
+
} catch (error) {
|
|
942
|
+
reportError(request, error);
|
|
943
|
+
fatalError(request, error);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
function unsupportedHook() {
|
|
948
|
+
throw new Error('This Hook is not supported in Server Components.');
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
function unsupportedRefresh() {
|
|
952
|
+
if (!currentCache) {
|
|
953
|
+
throw new Error(
|
|
954
|
+
'Refreshing the cache is not supported in Server Components.'
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
var currentCache = null;
|
|
960
|
+
var Dispatcher = {
|
|
961
|
+
useMemo: function (nextCreate) {
|
|
962
|
+
return nextCreate();
|
|
963
|
+
},
|
|
964
|
+
useCallback: function (callback) {
|
|
965
|
+
return callback;
|
|
966
|
+
},
|
|
967
|
+
useDebugValue: function () {},
|
|
968
|
+
useDeferredValue: unsupportedHook,
|
|
969
|
+
useTransition: unsupportedHook,
|
|
970
|
+
getCacheForType: function (resourceType) {
|
|
971
|
+
if (!currentCache) {
|
|
972
|
+
throw new Error('Reading the cache is only supported while rendering.');
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
var entry = currentCache.get(resourceType);
|
|
976
|
+
|
|
977
|
+
if (entry === undefined) {
|
|
978
|
+
entry = resourceType(); // TODO: Warn if undefined?
|
|
979
|
+
|
|
980
|
+
currentCache.set(resourceType, entry);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
return entry;
|
|
984
|
+
},
|
|
985
|
+
readContext: unsupportedHook,
|
|
986
|
+
useContext: unsupportedHook,
|
|
987
|
+
useReducer: unsupportedHook,
|
|
988
|
+
useRef: unsupportedHook,
|
|
989
|
+
useState: unsupportedHook,
|
|
990
|
+
useInsertionEffect: unsupportedHook,
|
|
991
|
+
useLayoutEffect: unsupportedHook,
|
|
992
|
+
useImperativeHandle: unsupportedHook,
|
|
993
|
+
useEffect: unsupportedHook,
|
|
994
|
+
useId: unsupportedHook,
|
|
995
|
+
useMutableSource: unsupportedHook,
|
|
996
|
+
useSyncExternalStore: unsupportedHook,
|
|
997
|
+
useCacheRefresh: function () {
|
|
998
|
+
return unsupportedRefresh;
|
|
999
|
+
},
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
function createDrainHandler(destination, request) {
|
|
1003
|
+
return function () {
|
|
1004
|
+
return startFlowing(request, destination);
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
function renderToPipeableStream(model, options) {
|
|
1009
|
+
var request = createRequest(
|
|
1010
|
+
model,
|
|
1011
|
+
{}, // Manifest, not used
|
|
1012
|
+
options ? options.onError : undefined
|
|
1013
|
+
);
|
|
1014
|
+
var hasStartedFlowing = false;
|
|
1015
|
+
startWork(request);
|
|
1016
|
+
return {
|
|
1017
|
+
pipe: function (destination) {
|
|
1018
|
+
if (hasStartedFlowing) {
|
|
1019
|
+
throw new Error(
|
|
1020
|
+
'React currently only supports piping to one writable stream.'
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
hasStartedFlowing = true;
|
|
1025
|
+
startFlowing(request, destination);
|
|
1026
|
+
destination.on('drain', createDrainHandler(destination, request));
|
|
1027
|
+
return destination;
|
|
1028
|
+
},
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
export {renderToPipeableStream};
|