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