@faststore/core 3.99.1 → 4.0.0-dev.4

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 (543) hide show
  1. package/.turbo/turbo-generate.log +29 -0
  2. package/.turbo/turbo-test.log +47 -16
  3. package/@generated/cached-operations.json +24 -0
  4. package/@generated/gql.ts +134 -210
  5. package/@generated/graphql.ts +1628 -3037
  6. package/@generated/index.ts +1 -1
  7. package/@generated/persisted-documents.json +1 -1
  8. package/@generated/schema.graphql +1854 -1743
  9. package/CHANGELOG.md +28 -4
  10. package/README.md +2 -1
  11. package/api/index.ts +6 -7
  12. package/cms/faststore/base.jsonc +1 -1
  13. package/cms/faststore/components/cms_component__alert.jsonc +5 -1
  14. package/cms/faststore/components/cms_component__bannernewsletter.jsonc +5 -1
  15. package/cms/faststore/components/cms_component__bannertext.jsonc +5 -1
  16. package/cms/faststore/components/cms_component__breadcrumb.jsonc +16 -4
  17. package/cms/faststore/components/cms_component__cartsidebar.jsonc +21 -1
  18. package/cms/faststore/components/cms_component__children.jsonc +5 -1
  19. package/cms/faststore/components/cms_component__crosssellingshelf.jsonc +5 -1
  20. package/cms/faststore/components/cms_component__emptystate.jsonc +8 -3
  21. package/cms/faststore/components/cms_component__footer.jsonc +9 -3
  22. package/cms/faststore/components/cms_component__hero.jsonc +5 -1
  23. package/cms/faststore/components/cms_component__incentives.jsonc +5 -1
  24. package/cms/faststore/components/cms_component__navbar.jsonc +139 -1
  25. package/cms/faststore/components/cms_component__newsletter.jsonc +5 -1
  26. package/cms/faststore/components/cms_component__productdetails.jsonc +33 -1
  27. package/cms/faststore/components/cms_component__productgallery.jsonc +113 -15
  28. package/cms/faststore/components/cms_component__productshelf.jsonc +5 -1
  29. package/cms/faststore/components/cms_component__producttiles.jsonc +5 -1
  30. package/cms/faststore/components/cms_component__regionbar.jsonc +5 -1
  31. package/cms/faststore/components/cms_component__regionmodal.jsonc +5 -1
  32. package/cms/faststore/components/cms_component__regionpopover.jsonc +5 -1
  33. package/cms/faststore/components/cms_component__scrolltotopbutton.jsonc +29 -0
  34. package/cms/faststore/components/cms_component__search.jsonc +5 -1
  35. package/cms/faststore/content-types.json +115 -0
  36. package/cms/faststore/pages/cms_content_type__globalsections.jsonc +52 -0
  37. package/cms/faststore/pages/cms_content_type__home.jsonc +6 -0
  38. package/cms/faststore/pages/cms_content_type__landingpage.jsonc +8 -1
  39. package/cms/faststore/pages/cms_content_type__pdp.jsonc +6 -0
  40. package/cms/faststore/pages/cms_content_type__plp.jsonc +17 -0
  41. package/cms/faststore/pages/cms_content_type__search.jsonc +17 -0
  42. package/cms/faststore/schema.json +547 -43
  43. package/cms/faststore/sections.json +330 -21
  44. package/discovery.config.default.js +49 -3
  45. package/next-env.d.ts +2 -1
  46. package/next.config.js +48 -26
  47. package/package.json +47 -60
  48. package/public/icons.svg +5 -1
  49. package/scripts/i18n.js +76 -0
  50. package/src/components/account/MyAccountDrawer/OrganizationDrawer/OrganizationDrawer.tsx +2 -1
  51. package/src/components/account/MyAccountDrawer/OrganizationDrawer/section.module.scss +25 -24
  52. package/src/components/account/MyAccountDrawer/ProfileSummary/profile-summary.scss +8 -6
  53. package/src/components/account/MyAccountLayout/styles.scss +16 -12
  54. package/src/components/account/MyAccountMenu/styles.scss +21 -22
  55. package/src/components/account/MyAccountUserDetails/styles.module.scss +4 -2
  56. package/src/components/account/components/MyAccountAccordion/styles.scss +4 -2
  57. package/src/components/account/components/MyAccountHeader/styles.scss +3 -1
  58. package/src/components/account/components/MyAccountTable/styles.scss +6 -4
  59. package/src/components/account/orders/MyAccountListOrders/MyAccountFilterSlider/section.module.scss +21 -19
  60. package/src/components/account/orders/MyAccountListOrders/MyAccountListOrdersTable/MyAccountListOrdersTable.tsx +3 -1
  61. package/src/components/account/orders/MyAccountListOrders/MyAccountListOrdersTable/styles.scss +5 -3
  62. package/src/components/account/orders/MyAccountListOrders/styles.module.scss +25 -22
  63. package/src/components/account/orders/MyAccountOrderDetails/MyAccountBudgetsCard/styles.scss +7 -5
  64. package/src/components/account/orders/MyAccountOrderDetails/MyAccountDeliveryOptionAccordion/styles.scss +7 -5
  65. package/src/components/account/orders/MyAccountOrderDetails/MyAccountMoreInformationCard/styles.scss +3 -1
  66. package/src/components/account/orders/MyAccountOrderDetails/MyAccountOrderActionModal/styles.module.scss +8 -6
  67. package/src/components/account/orders/MyAccountOrderDetails/MyAccountOrderActions/styles.scss +3 -1
  68. package/src/components/account/orders/MyAccountOrderDetails/MyAccountStatusCard/styles.scss +8 -6
  69. package/src/components/account/orders/MyAccountOrderDetails/section.module.scss +36 -43
  70. package/src/components/account/profile/profile.module.scss +3 -1
  71. package/src/components/account/section.module.scss +3 -1
  72. package/src/components/account/security/styles.module.scss +14 -8
  73. package/src/components/cart/CartSidebar/CartSidebar.tsx +10 -1
  74. package/src/components/cart/CartSidebar/section.module.scss +19 -17
  75. package/src/components/cart/EmptyCart/EmptyCart.tsx +12 -4
  76. package/src/components/cms/GlobalSections.tsx +12 -12
  77. package/src/components/cms/RenderSections.tsx +10 -2
  78. package/src/components/cms/plp/Components.ts +9 -0
  79. package/src/components/common/Alert/section.module.scss +10 -5
  80. package/src/components/common/PreviewTag/section.module.scss +48 -40
  81. package/src/components/common/Toast/section.module.scss +4 -2
  82. package/src/components/localization/LocalizationSelector/LocalizationSelector.tsx +320 -0
  83. package/src/components/localization/LocalizationSelector/index.ts +1 -0
  84. package/src/components/localization/LocalizationSelector/section.module.scss +18 -0
  85. package/src/components/localization/index.ts +1 -0
  86. package/src/components/navigation/Navbar/Navbar.tsx +49 -1
  87. package/src/components/navigation/NavbarSlider/NavbarSlider.tsx +19 -1
  88. package/src/components/navigation/NavbarSlider/section.module.scss +12 -10
  89. package/src/components/product/OutOfStock/OutOfStock.tsx +6 -1
  90. package/src/components/product/ProductCard/ProductCard.tsx +1 -1
  91. package/src/components/region/RegionModal/RegionModal.tsx +4 -1
  92. package/src/components/region/RegionModal/section.module.scss +10 -8
  93. package/src/components/region/RegionPopover/RegionPopover.tsx +6 -5
  94. package/src/components/region/RegionPopover/section.module.scss +9 -7
  95. package/src/components/region/RegionSlider/RegionSlider.tsx +5 -2
  96. package/src/components/region/RegionSlider/section.module.scss +16 -13
  97. package/src/components/search/Filter/FilterDeliveryMethodFacet.tsx +5 -5
  98. package/src/components/search/Filter/FilterDesktop.tsx +13 -4
  99. package/src/components/search/Filter/FilterSlider.tsx +18 -6
  100. package/src/components/search/Filter/section.module.scss +21 -19
  101. package/src/components/search/SearchDropdown/SearchDropdown.tsx +9 -7
  102. package/src/components/search/SearchHistory/SearchHistory.tsx +7 -2
  103. package/src/components/search/SearchInput/SearchInput.tsx +21 -8
  104. package/src/components/search/SearchProductItem/SearchProductItem.tsx +10 -3
  105. package/src/components/search/SearchTop/SearchTop.tsx +30 -24
  106. package/src/components/search/Sort/Sort.tsx +17 -19
  107. package/src/components/sections/Alert/Alert.tsx +6 -1
  108. package/src/components/sections/BannerNewsletter/section.module.scss +6 -4
  109. package/src/components/sections/BannerText/section.module.scss +5 -3
  110. package/src/components/sections/Breadcrumb/Breadcrumb.tsx +6 -2
  111. package/src/components/sections/Breadcrumb/section.module.scss +7 -5
  112. package/src/components/sections/EmptyState/section.module.scss +5 -3
  113. package/src/components/sections/Footer/Footer.tsx +1 -5
  114. package/src/components/sections/Footer/section.module.scss +10 -8
  115. package/src/components/sections/Hero/Hero.tsx +3 -1
  116. package/src/components/sections/Hero/section.module.scss +6 -4
  117. package/src/components/sections/Incentives/section.module.scss +5 -3
  118. package/src/components/sections/Navbar/Navbar.tsx +45 -0
  119. package/src/components/sections/Navbar/section.module.scss +34 -33
  120. package/src/components/sections/Newsletter/section.module.scss +10 -8
  121. package/src/components/sections/ProductDetails/ProductDetails.tsx +23 -1
  122. package/src/components/sections/ProductDetails/section.module.scss +32 -30
  123. package/src/components/sections/ProductGallery/EmptyGallery.tsx +13 -16
  124. package/src/components/sections/ProductGallery/section.module.scss +42 -39
  125. package/src/components/sections/ProductShelf/section.module.scss +22 -17
  126. package/src/components/sections/ProductTiles/section.module.scss +15 -13
  127. package/src/components/sections/RegionBar/section.module.scss +5 -3
  128. package/src/components/sections/ScrollToTopButton/ScrollToTopButton.tsx +4 -3
  129. package/src/components/sections/ScrollToTopButton/section.module.scss +4 -2
  130. package/src/components/templates/LandingPage/LandingPage.tsx +22 -16
  131. package/src/components/templates/ProductListingPage/ProductListing.tsx +1 -13
  132. package/src/components/templates/ProductListingPage/ProductListingPage.tsx +8 -3
  133. package/src/components/ui/Breadcrumb/Breadcrumb.tsx +14 -11
  134. package/src/components/ui/Button/ButtonSignIn/ButtonSignIn.tsx +2 -1
  135. package/src/components/ui/Button/ButtonSignIn/ButtonSignInFallback/ButtonSignInFallback.tsx +3 -1
  136. package/src/components/ui/Link/Link.tsx +19 -2
  137. package/src/components/ui/LinkButton/LinkButton.tsx +28 -0
  138. package/src/components/ui/LinkButton/index.ts +2 -0
  139. package/src/components/ui/LocalizationButton/LocalizationButton.tsx +124 -0
  140. package/src/components/ui/LocalizationButton/index.ts +1 -0
  141. package/src/components/ui/PickupPoints/PickupPointCards.tsx +2 -4
  142. package/src/components/ui/ProductComparison/ProductComparisonSidebar.tsx +34 -17
  143. package/src/components/ui/ProductDescription/ProductDescription.tsx +8 -3
  144. package/src/components/ui/ProductDetails/AddToCartLoadingSkeleton.tsx +6 -2
  145. package/src/components/ui/ProductDetails/ProductDetailsSettings.tsx +17 -5
  146. package/src/components/ui/ProductGallery/ProductGallery.tsx +7 -3
  147. package/src/components/ui/ProductGallery/ProductGalleryPage.tsx +1 -3
  148. package/src/components/ui/ShippingSimulation/ShippingSimulation.tsx +6 -1
  149. package/src/customizations/src/styles/custom-mixins.scss +0 -2
  150. package/src/experimental/index.ts +26 -0
  151. package/src/experimental/myAccountServerSideProps.ts +11 -2
  152. package/src/experimental/searchServerSideFunctions/getServerSideProps.ts +13 -7
  153. package/src/experimental/searchServerSideFunctions/getStaticProps.ts +5 -4
  154. package/src/instrumentation.ts +20 -6
  155. package/src/pages/404.tsx +5 -4
  156. package/src/pages/500.tsx +5 -4
  157. package/src/pages/[...slug].tsx +7 -4
  158. package/src/pages/[slug]/p.tsx +26 -8
  159. package/src/pages/_app.tsx +9 -1
  160. package/src/pages/api/fs/logout.ts +3 -2
  161. package/src/pages/api/graphql.ts +7 -23
  162. package/src/pages/api/preview.ts +21 -8
  163. package/src/pages/checkout.tsx +15 -5
  164. package/src/pages/index.tsx +19 -10
  165. package/src/pages/login.tsx +5 -4
  166. package/src/pages/pvt/account/403.tsx +11 -2
  167. package/src/pages/pvt/account/404.tsx +13 -3
  168. package/src/pages/pvt/account/index.tsx +6 -4
  169. package/src/pages/pvt/account/orders/[id].tsx +11 -3
  170. package/src/pages/pvt/account/orders/index.tsx +11 -3
  171. package/src/pages/pvt/account/profile.tsx +11 -2
  172. package/src/pages/pvt/account/security.tsx +11 -2
  173. package/src/pages/pvt/account/user-details.tsx +11 -2
  174. package/src/pages/s.tsx +26 -6
  175. package/src/proxy.ts +154 -0
  176. package/src/sdk/account/refreshToken.ts +4 -4
  177. package/src/sdk/account/useReorder.ts +8 -2
  178. package/src/sdk/analytics/platform/vtex/search.ts +3 -2
  179. package/src/sdk/cart/redirectToCheckout.ts +14 -8
  180. package/src/sdk/cart/useCheckoutButton.ts +7 -1
  181. package/src/sdk/deliveryPromise/useDeliveryPromise.ts +10 -18
  182. package/src/sdk/graphql/request.ts +102 -50
  183. package/src/sdk/localization/bindingSelector.ts +91 -0
  184. package/src/sdk/localization/index.ts +4 -0
  185. package/src/sdk/localization/match-url.ts +64 -0
  186. package/src/sdk/localization/types.ts +31 -0
  187. package/src/sdk/localization/useBindingSelector.ts +183 -0
  188. package/src/sdk/localization/useLocaleValidation.ts +49 -0
  189. package/src/sdk/localization/useLocalizationConfig.tsx +160 -0
  190. package/src/sdk/offer/fetcher.ts +3 -2
  191. package/src/sdk/product/useLocalizedVariables.ts +1 -1
  192. package/src/sdk/product/usePageProductsQuery.ts +2 -2
  193. package/src/sdk/product/useProductGalleryQuery.ts +1 -2
  194. package/src/sdk/product/useProductLink.ts +3 -1
  195. package/src/sdk/search/formatSearchPath.ts +28 -3
  196. package/src/sdk/search/state.ts +22 -13
  197. package/src/sdk/search/useSearchBase.ts +10 -0
  198. package/src/sdk/search/useSearchHistory.ts +41 -7
  199. package/src/sdk/session/index.ts +21 -3
  200. package/src/sdk/shipping/useShippingSimulation.ts +10 -2
  201. package/src/sdk/tsconfig.json +6 -0
  202. package/src/sdk/ui/useLink.ts +48 -0
  203. package/src/server/cms/global.ts +40 -0
  204. package/src/server/cms/index.ts +18 -10
  205. package/src/server/cms/pdp.ts +1 -0
  206. package/src/server/cms/plp.ts +3 -0
  207. package/src/server/content/service.ts +36 -24
  208. package/src/server/content/types.ts +10 -3
  209. package/src/server/index.ts +27 -20
  210. package/src/server/options.ts +27 -2
  211. package/src/styles/global/index.scss +10 -7
  212. package/src/styles/main.scss +3 -3
  213. package/src/typings/locales.ts +41 -0
  214. package/src/utils/fetchProductGallerySSR.ts +3 -1
  215. package/src/utils/getBaseDomain.ts +2 -1
  216. package/src/utils/getRequestHostname.ts +26 -0
  217. package/src/utils/globalSettings.ts +11 -0
  218. package/src/utils/localization/bindingPaths.ts +337 -0
  219. package/src/utils/localization/validateLocaleForHostname.ts +69 -0
  220. package/src/utils/localization/withLocaleValidation.ts +36 -0
  221. package/src/utils/utilities.ts +22 -0
  222. package/test/pages/api/preview.test.ts +93 -0
  223. package/test/sdk/localization/bindingSelector.test.ts +246 -0
  224. package/test/sdk/localization/store-url.browser.test.ts +140 -0
  225. package/test/sdk/localization/store-url.test.ts +96 -0
  226. package/test/sdk/localization/useBindingSelector.test.tsx +219 -0
  227. package/test/sdk/search/useSearchHistory.test.ts +222 -0
  228. package/test/server/cms/index.test.ts +3 -4
  229. package/test/server/content/service.test.ts +98 -0
  230. package/test/server/index.test.ts +10 -22
  231. package/test/utils/cookieCacheBusting.test.ts +32 -24
  232. package/test/utils/getRequestHostname.test.ts +71 -0
  233. package/test/utils/localization/bindingPaths.test.ts +706 -0
  234. package/test/utils/match-url.test.ts +388 -0
  235. package/tsconfig.json +11 -3
  236. package/vitest.config.ts +61 -0
  237. package/.next/BUILD_ID +0 -1
  238. package/.next/build-manifest.json +0 -197
  239. package/.next/cache/.tsbuildinfo +0 -1
  240. package/.next/cache/config.json +0 -7
  241. package/.next/cache/webpack/client-production/0.pack +0 -0
  242. package/.next/cache/webpack/client-production/index.pack +0 -0
  243. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  244. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  245. package/.next/cache/webpack/server-production/0.pack +0 -0
  246. package/.next/cache/webpack/server-production/index.pack +0 -0
  247. package/.next/export-marker.json +0 -1
  248. package/.next/images-manifest.json +0 -1
  249. package/.next/next-minimal-server.js.nft.json +0 -1
  250. package/.next/next-server.js.nft.json +0 -1
  251. package/.next/package.json +0 -1
  252. package/.next/prerender-manifest.js +0 -1
  253. package/.next/prerender-manifest.json +0 -1
  254. package/.next/react-loadable-manifest.json +0 -478
  255. package/.next/required-server-files.json +0 -1
  256. package/.next/routes-manifest.json +0 -1
  257. package/.next/server/chunks/1280.js +0 -1
  258. package/.next/server/chunks/1454.js +0 -1
  259. package/.next/server/chunks/1554.js +0 -1
  260. package/.next/server/chunks/1607.js +0 -1
  261. package/.next/server/chunks/1780.js +0 -1
  262. package/.next/server/chunks/1917.js +0 -1
  263. package/.next/server/chunks/1972.js +0 -1
  264. package/.next/server/chunks/2230.js +0 -1
  265. package/.next/server/chunks/2249.js +0 -1
  266. package/.next/server/chunks/2430.js +0 -1
  267. package/.next/server/chunks/2445.js +0 -12
  268. package/.next/server/chunks/2570.js +0 -1
  269. package/.next/server/chunks/2792.js +0 -1
  270. package/.next/server/chunks/2903.js +0 -1
  271. package/.next/server/chunks/294.js +0 -1
  272. package/.next/server/chunks/2955.js +0 -1
  273. package/.next/server/chunks/3006.js +0 -1
  274. package/.next/server/chunks/3029.js +0 -1
  275. package/.next/server/chunks/3060.js +0 -1
  276. package/.next/server/chunks/3408.js +0 -1
  277. package/.next/server/chunks/3483.js +0 -1
  278. package/.next/server/chunks/3683.js +0 -1
  279. package/.next/server/chunks/3836.js +0 -1
  280. package/.next/server/chunks/3890.js +0 -494
  281. package/.next/server/chunks/3922.js +0 -1
  282. package/.next/server/chunks/3945.js +0 -1
  283. package/.next/server/chunks/3951.js +0 -7
  284. package/.next/server/chunks/416.js +0 -1
  285. package/.next/server/chunks/4194.js +0 -1
  286. package/.next/server/chunks/4365.js +0 -1
  287. package/.next/server/chunks/4451.js +0 -1
  288. package/.next/server/chunks/4803.js +0 -1
  289. package/.next/server/chunks/4913.js +0 -13
  290. package/.next/server/chunks/5402.js +0 -1
  291. package/.next/server/chunks/5723.js +0 -13
  292. package/.next/server/chunks/5796.js +0 -1
  293. package/.next/server/chunks/6393.js +0 -1
  294. package/.next/server/chunks/6457.js +0 -6
  295. package/.next/server/chunks/6698.js +0 -1
  296. package/.next/server/chunks/6804.js +0 -6
  297. package/.next/server/chunks/6886.js +0 -1
  298. package/.next/server/chunks/7098.js +0 -9
  299. package/.next/server/chunks/7169.js +0 -1
  300. package/.next/server/chunks/7228.js +0 -1
  301. package/.next/server/chunks/7275.js +0 -1
  302. package/.next/server/chunks/7371.js +0 -1
  303. package/.next/server/chunks/7692.js +0 -1
  304. package/.next/server/chunks/7799.js +0 -1
  305. package/.next/server/chunks/8068.js +0 -1
  306. package/.next/server/chunks/83.js +0 -1
  307. package/.next/server/chunks/831.js +0 -1
  308. package/.next/server/chunks/8563.js +0 -1
  309. package/.next/server/chunks/8569.js +0 -1
  310. package/.next/server/chunks/8687.js +0 -1
  311. package/.next/server/chunks/870.js +0 -1
  312. package/.next/server/chunks/8737.js +0 -1
  313. package/.next/server/chunks/8741.js +0 -1
  314. package/.next/server/chunks/9088.js +0 -1
  315. package/.next/server/chunks/9117.js +0 -1
  316. package/.next/server/chunks/9237.js +0 -1
  317. package/.next/server/chunks/948.js +0 -3
  318. package/.next/server/chunks/9563.js +0 -3
  319. package/.next/server/chunks/9570.js +0 -1
  320. package/.next/server/chunks/9740.js +0 -1
  321. package/.next/server/chunks/9853.js +0 -1
  322. package/.next/server/chunks/9984.js +0 -1
  323. package/.next/server/chunks/9985.js +0 -1
  324. package/.next/server/chunks/9990.js +0 -1
  325. package/.next/server/chunks/ButtonSignIn.js +0 -1
  326. package/.next/server/chunks/Dropdown.js +0 -1
  327. package/.next/server/chunks/DropdownButton.js +0 -1
  328. package/.next/server/chunks/DropdownItem.js +0 -1
  329. package/.next/server/chunks/DropdownMenu.js +0 -1
  330. package/.next/server/chunks/FilterSkeleton.js +0 -1
  331. package/.next/server/chunks/ScrollToTopButton.js +0 -1
  332. package/.next/server/chunks/UIBannerText.js +0 -1
  333. package/.next/server/chunks/UISKUMatrixSidebar.js +0 -1
  334. package/.next/server/chunks/font-manifest.json +0 -1
  335. package/.next/server/edge-instrumentation.js +0 -2
  336. package/.next/server/edge-instrumentation.js.map +0 -1
  337. package/.next/server/edge-runtime-webpack.js +0 -157
  338. package/.next/server/edge-runtime-webpack.js.map +0 -1
  339. package/.next/server/font-manifest.json +0 -1
  340. package/.next/server/functions-config-manifest.json +0 -1
  341. package/.next/server/instrumentation.js +0 -1
  342. package/.next/server/instrumentation.js.nft.json +0 -1
  343. package/.next/server/middleware-build-manifest.js +0 -1
  344. package/.next/server/middleware-manifest.json +0 -6
  345. package/.next/server/middleware-react-loadable-manifest.js +0 -1
  346. package/.next/server/next-font-manifest.js +0 -1
  347. package/.next/server/next-font-manifest.json +0 -1
  348. package/.next/server/pages/404.js +0 -1
  349. package/.next/server/pages/404.js.nft.json +0 -1
  350. package/.next/server/pages/500.js +0 -1
  351. package/.next/server/pages/500.js.nft.json +0 -1
  352. package/.next/server/pages/[...slug].js +0 -1
  353. package/.next/server/pages/[...slug].js.nft.json +0 -1
  354. package/.next/server/pages/[slug]/p.js +0 -1
  355. package/.next/server/pages/[slug]/p.js.nft.json +0 -1
  356. package/.next/server/pages/_app.js +0 -1
  357. package/.next/server/pages/_app.js.nft.json +0 -1
  358. package/.next/server/pages/_document.js +0 -1
  359. package/.next/server/pages/_document.js.nft.json +0 -1
  360. package/.next/server/pages/_error.js +0 -1
  361. package/.next/server/pages/_error.js.nft.json +0 -1
  362. package/.next/server/pages/api/fs/logout.js +0 -1
  363. package/.next/server/pages/api/fs/logout.js.nft.json +0 -1
  364. package/.next/server/pages/api/graphql.js +0 -3
  365. package/.next/server/pages/api/graphql.js.nft.json +0 -1
  366. package/.next/server/pages/api/health/live.js +0 -1
  367. package/.next/server/pages/api/health/live.js.nft.json +0 -1
  368. package/.next/server/pages/api/health/ready.js +0 -1
  369. package/.next/server/pages/api/health/ready.js.nft.json +0 -1
  370. package/.next/server/pages/api/preview.js +0 -1
  371. package/.next/server/pages/api/preview.js.nft.json +0 -1
  372. package/.next/server/pages/checkout.js +0 -1
  373. package/.next/server/pages/checkout.js.nft.json +0 -1
  374. package/.next/server/pages/en-US/404.html +0 -42
  375. package/.next/server/pages/en-US/404.json +0 -1
  376. package/.next/server/pages/en-US/500.html +0 -42
  377. package/.next/server/pages/en-US/500.json +0 -1
  378. package/.next/server/pages/en-US/checkout.html +0 -42
  379. package/.next/server/pages/en-US/checkout.json +0 -1
  380. package/.next/server/pages/en-US/login.html +0 -42
  381. package/.next/server/pages/en-US/login.json +0 -1
  382. package/.next/server/pages/en-US/s.html +0 -42
  383. package/.next/server/pages/en-US/s.json +0 -1
  384. package/.next/server/pages/en-US.html +0 -42
  385. package/.next/server/pages/en-US.json +0 -1
  386. package/.next/server/pages/index.js +0 -1
  387. package/.next/server/pages/index.js.nft.json +0 -1
  388. package/.next/server/pages/login.js +0 -1
  389. package/.next/server/pages/login.js.nft.json +0 -1
  390. package/.next/server/pages/pvt/account/403.js +0 -1
  391. package/.next/server/pages/pvt/account/403.js.nft.json +0 -1
  392. package/.next/server/pages/pvt/account/404.js +0 -1
  393. package/.next/server/pages/pvt/account/404.js.nft.json +0 -1
  394. package/.next/server/pages/pvt/account/[...unknown].js +0 -1
  395. package/.next/server/pages/pvt/account/[...unknown].js.nft.json +0 -1
  396. package/.next/server/pages/pvt/account/orders/[id].js +0 -1
  397. package/.next/server/pages/pvt/account/orders/[id].js.nft.json +0 -1
  398. package/.next/server/pages/pvt/account/orders.js +0 -1
  399. package/.next/server/pages/pvt/account/orders.js.nft.json +0 -1
  400. package/.next/server/pages/pvt/account/profile.js +0 -1
  401. package/.next/server/pages/pvt/account/profile.js.nft.json +0 -1
  402. package/.next/server/pages/pvt/account/security.js +0 -1
  403. package/.next/server/pages/pvt/account/security.js.nft.json +0 -1
  404. package/.next/server/pages/pvt/account/user-details.js +0 -1
  405. package/.next/server/pages/pvt/account/user-details.js.nft.json +0 -1
  406. package/.next/server/pages/pvt/account.js +0 -1
  407. package/.next/server/pages/pvt/account.js.nft.json +0 -1
  408. package/.next/server/pages/s.js +0 -1
  409. package/.next/server/pages/s.js.nft.json +0 -1
  410. package/.next/server/pages-manifest.json +0 -1
  411. package/.next/server/webpack-api-runtime.js +0 -1
  412. package/.next/server/webpack-runtime.js +0 -1
  413. package/.next/static/NAuY8lqaeBBZf9CMZuYI2/_buildManifest.js +0 -1
  414. package/.next/static/NAuY8lqaeBBZf9CMZuYI2/_ssgManifest.js +0 -1
  415. package/.next/static/chunks/227-f109b24190a008ab.js +0 -8
  416. package/.next/static/chunks/2284.185d834d9829b652.js +0 -1
  417. package/.next/static/chunks/2851.e68ed3c8d27a032a.js +0 -1
  418. package/.next/static/chunks/2927.5a79877943a6bf7c.js +0 -1
  419. package/.next/static/chunks/3155.7bc4c730a79d9ecb.js +0 -1
  420. package/.next/static/chunks/3166-0b30a3887c0c346d.js +0 -1
  421. package/.next/static/chunks/3399.017c5209b74b0d97.js +0 -1
  422. package/.next/static/chunks/3483.ef53d632a763da3f.js +0 -1
  423. package/.next/static/chunks/349.b3b38e1e9f719dda.js +0 -1
  424. package/.next/static/chunks/3802.5e8b0b689eacc0f8.js +0 -1
  425. package/.next/static/chunks/3836.620480018be48233.js +0 -1
  426. package/.next/static/chunks/4436.e7af66f0b654ee36.js +0 -1
  427. package/.next/static/chunks/4803.b1920b6e3a1a6304.js +0 -1
  428. package/.next/static/chunks/5796.4351370494d8b8b6.js +0 -1
  429. package/.next/static/chunks/6393.55f991b1a6bb4fe7.js +0 -1
  430. package/.next/static/chunks/6700.b23221a57514e737.js +0 -1
  431. package/.next/static/chunks/6789.960162355435a81d.js +0 -1
  432. package/.next/static/chunks/7191-befad64ba238a817.js +0 -1
  433. package/.next/static/chunks/7692.8d5bf4560341a2f6.js +0 -1
  434. package/.next/static/chunks/7861.7f9f1a124a43da30.js +0 -6
  435. package/.next/static/chunks/8068.43663fb64762f7b8.js +0 -1
  436. package/.next/static/chunks/83.e0c16f0299b364a5.js +0 -1
  437. package/.next/static/chunks/8325.dabe9aa22eaadeed.js +0 -1
  438. package/.next/static/chunks/8587.53c8ce185ed1a2cb.js +0 -1
  439. package/.next/static/chunks/9173-e89da04079c35360.js +0 -2
  440. package/.next/static/chunks/9237.7555603703f81bf7.js +0 -1
  441. package/.next/static/chunks/9298-1d1ed0a54133cb59.js +0 -28
  442. package/.next/static/chunks/9399.d116a7fd62024783.js +0 -1
  443. package/.next/static/chunks/941.3e2782ab9c490eb0.js +0 -1
  444. package/.next/static/chunks/9701.f9a0bfffba8807dc.js +0 -1
  445. package/.next/static/chunks/9909.787576b171184aa5.js +0 -1
  446. package/.next/static/chunks/9960.7ef77f8a8b046170.js +0 -1
  447. package/.next/static/chunks/9979.aedbc094bdc2c599.js +0 -1
  448. package/.next/static/chunks/BannerNewsletter.00328ad162109908.js +0 -1
  449. package/.next/static/chunks/BannerText.dbbec87cadb8a521.js +0 -1
  450. package/.next/static/chunks/ButtonSignIn.f6e210eaca873e48.js +0 -1
  451. package/.next/static/chunks/CartItem.b34e295377f6f94f.js +0 -1
  452. package/.next/static/chunks/CartSidebar.ac447d1ef6276da1.js +0 -1
  453. package/.next/static/chunks/Dropdown.38b48c749bad6b60.js +0 -1
  454. package/.next/static/chunks/DropdownButton.66fa6b25dddb3a07.js +0 -1
  455. package/.next/static/chunks/DropdownItem.38b8f5a07c7f422a.js +0 -1
  456. package/.next/static/chunks/DropdownMenu.48b11521a24c6efd.js +0 -1
  457. package/.next/static/chunks/EmptyCart.320e2f94a0d5e6b1.js +0 -1
  458. package/.next/static/chunks/FilterSkeleton.7ab99e28f92341c9.js +0 -1
  459. package/.next/static/chunks/Footer.166b02c2f13980c6.js +0 -1
  460. package/.next/static/chunks/Gift.c49ba26da2fbab5e.js +0 -1
  461. package/.next/static/chunks/Newsletter.fc406f6029057022.js +0 -1
  462. package/.next/static/chunks/OrderSummary.5957d69f990d9add.js +0 -1
  463. package/.next/static/chunks/PreviewTag.f4f0c8710a7bcad9.js +0 -1
  464. package/.next/static/chunks/ProductShelf.cc46f5cdeeaeaff6.js +0 -1
  465. package/.next/static/chunks/ProductTiles.9b804e51b0704d60.js +0 -1
  466. package/.next/static/chunks/RegionModal.319ad44250cb12d2.js +0 -1
  467. package/.next/static/chunks/RegionSlider.0e0e93369f4f9c92.js +0 -1
  468. package/.next/static/chunks/ScrollToTopButton.c15431f2e8bb93ef.js +0 -1
  469. package/.next/static/chunks/ShoppingAssistant.ba191eb4dbed67e5.js +0 -1
  470. package/.next/static/chunks/Toast.5f90f0436708be5e.js +0 -1
  471. package/.next/static/chunks/UIBannerText.7315b16af4457059.js +0 -1
  472. package/.next/static/chunks/UISKUMatrixSidebar.b4349b2682bbe183.js +0 -1
  473. package/.next/static/chunks/UIToast.19a8664c01a00d3a.js +0 -1
  474. package/.next/static/chunks/framework-d514426edf885c68.js +0 -33
  475. package/.next/static/chunks/main-ec03882c4375091d.js +0 -1
  476. package/.next/static/chunks/pages/404-e3dfbbac003b02a2.js +0 -1
  477. package/.next/static/chunks/pages/500-c7814e085081d7b8.js +0 -1
  478. package/.next/static/chunks/pages/[...slug]-dc8a395a43b081f1.js +0 -1
  479. package/.next/static/chunks/pages/[slug]/p-644f1132f5a0f736.js +0 -1
  480. package/.next/static/chunks/pages/_app-84aaff8a9d4de60e.js +0 -1
  481. package/.next/static/chunks/pages/_error-2b0148be56a716e9.js +0 -1
  482. package/.next/static/chunks/pages/checkout-2071467ad42dfb99.js +0 -1
  483. package/.next/static/chunks/pages/index-8774d5b4a8744eb2.js +0 -1
  484. package/.next/static/chunks/pages/login-e74747c9f9cb5b49.js +0 -1
  485. package/.next/static/chunks/pages/pvt/account/403-491e6b062487b30f.js +0 -1
  486. package/.next/static/chunks/pages/pvt/account/404-5ad472d9f2ee1980.js +0 -1
  487. package/.next/static/chunks/pages/pvt/account/[...unknown]-f80f645594d2740c.js +0 -1
  488. package/.next/static/chunks/pages/pvt/account/orders/[id]-64e42157c0974c48.js +0 -1
  489. package/.next/static/chunks/pages/pvt/account/orders-faab39f2aff05fae.js +0 -1
  490. package/.next/static/chunks/pages/pvt/account/profile-9672177ee2665bc0.js +0 -1
  491. package/.next/static/chunks/pages/pvt/account/security-03eb1ccab9a30563.js +0 -1
  492. package/.next/static/chunks/pages/pvt/account/user-details-7838e3f79781596c.js +0 -1
  493. package/.next/static/chunks/pages/pvt/account-65fefcc699344bdb.js +0 -1
  494. package/.next/static/chunks/pages/s-162ba789e6611175.js +0 -1
  495. package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
  496. package/.next/static/chunks/webpack-f621ff3e951d2982.js +0 -1
  497. package/.next/static/css/02259c549b2179f2.css +0 -1
  498. package/.next/static/css/02eaf202d3d11fd1.css +0 -1
  499. package/.next/static/css/033e241c58ba6fbb.css +0 -1
  500. package/.next/static/css/042d012bc1895b5c.css +0 -1
  501. package/.next/static/css/14176a4704ff97b2.css +0 -1
  502. package/.next/static/css/146a8678babc61bf.css +0 -1
  503. package/.next/static/css/16d65422bfa80f51.css +0 -1
  504. package/.next/static/css/1c4983f11b861ea0.css +0 -1
  505. package/.next/static/css/204754bbd8cc4bef.css +0 -1
  506. package/.next/static/css/24d91007fc96be10.css +0 -1
  507. package/.next/static/css/2980acad3f8e1028.css +0 -1
  508. package/.next/static/css/2c19433e38fd7533.css +0 -1
  509. package/.next/static/css/31380ebc6e671486.css +0 -1
  510. package/.next/static/css/42df884711219edb.css +0 -1
  511. package/.next/static/css/4f0597b0bf0ef2e1.css +0 -1
  512. package/.next/static/css/54cedf4b65e5863f.css +0 -1
  513. package/.next/static/css/6580147d7ab8fcca.css +0 -1
  514. package/.next/static/css/6819dddf2b1b5ea7.css +0 -1
  515. package/.next/static/css/7ef7762f412ed665.css +0 -1
  516. package/.next/static/css/82f3cd529b672812.css +0 -1
  517. package/.next/static/css/837662922091162f.css +0 -1
  518. package/.next/static/css/8e6ab59ace21e03b.css +0 -1
  519. package/.next/static/css/a852afa9be31e946.css +0 -1
  520. package/.next/static/css/b684b347c5cc6514.css +0 -1
  521. package/.next/static/css/bcdaef0a83277ef5.css +0 -1
  522. package/.next/static/css/c33615999008d3f9.css +0 -1
  523. package/.next/static/css/c34f6ea9953e2f63.css +0 -1
  524. package/.next/static/css/ea11d74a2848b093.css +0 -1
  525. package/.next/static/css/f16438bcf4508fb3.css +0 -1
  526. package/.next/static/css/f60366555f563deb.css +0 -1
  527. package/.next/trace +0 -143
  528. package/.turbo/turbo-build.log +0 -140
  529. package/jest.config.js +0 -17
  530. package/public/~partytown/debug/partytown-atomics.js +0 -556
  531. package/public/~partytown/debug/partytown-media.js +0 -374
  532. package/public/~partytown/debug/partytown-sandbox-sw.js +0 -543
  533. package/public/~partytown/debug/partytown-sw.js +0 -59
  534. package/public/~partytown/debug/partytown-ww-atomics.js +0 -1789
  535. package/public/~partytown/debug/partytown-ww-sw.js +0 -1781
  536. package/public/~partytown/debug/partytown.js +0 -72
  537. package/public/~partytown/partytown-atomics.js +0 -2
  538. package/public/~partytown/partytown-media.js +0 -2
  539. package/public/~partytown/partytown-sw.js +0 -2
  540. package/public/~partytown/partytown.js +0 -2
  541. package/src/middleware__DISABLED.ts +0 -65
  542. package/src/server/generator/generateGraphQLSchemaFile.ts +0 -3
  543. package/src/server/generator/schema.ts +0 -81
@@ -1,1789 +0,0 @@
1
- /* Partytown 0.6.4 - MIT builder.io */
2
- (self => {
3
- const WinIdKey = Symbol();
4
- const InstanceIdKey = Symbol();
5
- const InstanceDataKey = Symbol();
6
- const NamespaceKey = Symbol();
7
- const ApplyPathKey = Symbol();
8
- const InstanceStateKey = Symbol();
9
- const HookContinue = Symbol();
10
- const HookPrevent = Symbol();
11
- const webWorkerInstances = new Map;
12
- const webWorkerRefsByRefId = {};
13
- const webWorkerRefIdsByRef = new WeakMap;
14
- const postMessages = [];
15
- const webWorkerCtx = {};
16
- const webWorkerlocalStorage = new Map;
17
- const webWorkerSessionStorage = new Map;
18
- const environments = {};
19
- const cachedDimensions = new Map;
20
- const cachedStructure = new Map;
21
- const commaSplit = str => str.split(",");
22
- const partytownLibUrl = url => {
23
- url = webWorkerCtx.$libPath$ + url;
24
- if (new URL(url).origin != location.origin) {
25
- throw "Invalid " + url;
26
- }
27
- return url;
28
- };
29
- const getterDimensionPropNames = commaSplit("clientWidth,clientHeight,clientTop,clientLeft,innerWidth,innerHeight,offsetWidth,offsetHeight,offsetTop,offsetLeft,outerWidth,outerHeight,pageXOffset,pageYOffset,scrollWidth,scrollHeight,scrollTop,scrollLeft");
30
- const elementStructurePropNames = commaSplit("childElementCount,children,firstElementChild,lastElementChild,nextElementSibling,previousElementSibling");
31
- const structureChangingMethodNames = commaSplit("insertBefore,remove,removeChild,replaceChild");
32
- const dimensionChangingSetterNames = commaSplit("className,width,height,hidden,innerHTML,innerText,textContent");
33
- const dimensionChangingMethodNames = commaSplit("setAttribute,setAttributeNS,setProperty");
34
- const eventTargetMethods = commaSplit("addEventListener,dispatchEvent,removeEventListener");
35
- const nonBlockingMethods = eventTargetMethods.concat(dimensionChangingMethodNames, commaSplit("add,observe,remove,unobserve"));
36
- const IS_TAG_REG = /^[A-Z_]([A-Z0-9-]*[A-Z0-9])?$/;
37
- const noop = () => {};
38
- const len = obj => obj.length;
39
- const getConstructorName = obj => {
40
- var _a, _b, _c;
41
- try {
42
- const constructorName = null === (_a = null == obj ? void 0 : obj.constructor) || void 0 === _a ? void 0 : _a.name;
43
- if (constructorName) {
44
- return constructorName;
45
- }
46
- } catch (e) {}
47
- try {
48
- const zoneJsConstructorName = null === (_c = null === (_b = null == obj ? void 0 : obj.__zone_symbol__originalInstance) || void 0 === _b ? void 0 : _b.constructor) || void 0 === _c ? void 0 : _c.name;
49
- if (zoneJsConstructorName) {
50
- return zoneJsConstructorName;
51
- }
52
- } catch (e) {}
53
- return "";
54
- };
55
- const EMPTY_ARRAY = [];
56
- const randomId = () => Math.round(Math.random() * Number.MAX_SAFE_INTEGER).toString(36);
57
- const defineProperty = (obj, memberName, descriptor) => Object.defineProperty(obj, memberName, {
58
- ...descriptor,
59
- configurable: true
60
- });
61
- const defineConstructorName = (Cstr, value) => defineProperty(Cstr, "name", {
62
- value: value
63
- });
64
- const definePrototypeProperty = (Cstr, memberName, descriptor) => defineProperty(Cstr.prototype, memberName, descriptor);
65
- const definePrototypePropertyDescriptor = (Cstr, propertyDescriptorMap) => Object.defineProperties(Cstr.prototype, propertyDescriptorMap);
66
- const definePrototypeValue = (Cstr, memberName, value) => definePrototypeProperty(Cstr, memberName, {
67
- value: value,
68
- writable: true
69
- });
70
- const hasInstanceStateValue = (instance, stateKey) => stateKey in instance[InstanceStateKey];
71
- const getInstanceStateValue = (instance, stateKey) => instance[InstanceStateKey][stateKey];
72
- const setInstanceStateValue = (instance, stateKey, stateValue) => instance[InstanceStateKey][stateKey] = stateValue;
73
- const setWorkerRef = (ref, refId) => {
74
- if (!(refId = webWorkerRefIdsByRef.get(ref))) {
75
- webWorkerRefIdsByRef.set(ref, refId = randomId());
76
- webWorkerRefsByRefId[refId] = ref;
77
- }
78
- return refId;
79
- };
80
- const getOrCreateNodeInstance = (winId, instanceId, nodeName, namespace, instance) => {
81
- instance = webWorkerInstances.get(instanceId);
82
- if (!instance && nodeName && environments[winId]) {
83
- instance = environments[winId].$createNode$(nodeName, instanceId, namespace);
84
- webWorkerInstances.set(instanceId, instance);
85
- }
86
- return instance;
87
- };
88
- const definePrototypeNodeType = (Cstr, nodeType) => definePrototypeValue(Cstr, "nodeType", nodeType);
89
- const cachedTreeProps = (Cstr, treeProps) => treeProps.map((propName => definePrototypeProperty(Cstr, propName, {
90
- get() {
91
- let cacheKey = getInstanceCacheKey(this, propName);
92
- let result = cachedStructure.get(cacheKey);
93
- if (!result) {
94
- result = getter(this, [ propName ]);
95
- cachedStructure.set(cacheKey, result);
96
- }
97
- return result;
98
- }
99
- })));
100
- const getInstanceCacheKey = (instance, memberName, args) => [ instance[WinIdKey], instance[InstanceIdKey], memberName, ...(args || EMPTY_ARRAY).map((arg => String(arg && arg[WinIdKey] ? arg[InstanceIdKey] : arg))) ].join(".");
101
- const cachedProps = (Cstr, propNames) => commaSplit(propNames).map((propName => definePrototypeProperty(Cstr, propName, {
102
- get() {
103
- hasInstanceStateValue(this, propName) || setInstanceStateValue(this, propName, getter(this, [ propName ]));
104
- return getInstanceStateValue(this, propName);
105
- },
106
- set(val) {
107
- getInstanceStateValue(this, propName) !== val && setter(this, [ propName ], val);
108
- setInstanceStateValue(this, propName, val);
109
- }
110
- })));
111
- const cachedDimensionProps = Cstr => getterDimensionPropNames.map((propName => definePrototypeProperty(Cstr, propName, {
112
- get() {
113
- const dimension = cachedDimensions.get(getInstanceCacheKey(this, propName));
114
- if ("number" == typeof dimension) {
115
- return dimension;
116
- }
117
- const groupedDimensions = getter(this, [ propName ], getterDimensionPropNames);
118
- if (groupedDimensions && "object" == typeof groupedDimensions) {
119
- Object.entries(groupedDimensions).map((([dimensionPropName, value]) => cachedDimensions.set(getInstanceCacheKey(this, dimensionPropName), value)));
120
- return groupedDimensions[propName];
121
- }
122
- return groupedDimensions;
123
- }
124
- })));
125
- const cachedDimensionMethods = (Cstr, dimensionMethodNames) => dimensionMethodNames.map((methodName => {
126
- Cstr.prototype[methodName] = function(...args) {
127
- let cacheKey = getInstanceCacheKey(this, methodName, args);
128
- let dimensions = cachedDimensions.get(cacheKey);
129
- if (!dimensions) {
130
- dimensions = callMethod(this, [ methodName ], args);
131
- cachedDimensions.set(cacheKey, dimensions);
132
- }
133
- return dimensions;
134
- };
135
- }));
136
- const serializeForMain = ($winId$, $instanceId$, value, added, type) => void 0 !== value && (type = typeof value) ? "string" === type || "boolean" === type || "number" === type || null == value ? [ 0, value ] : "function" === type ? [ 4, {
137
- $winId$: $winId$,
138
- $instanceId$: $instanceId$,
139
- $refId$: setWorkerRef(value)
140
- } ] : (added = added || new Set) && Array.isArray(value) ? added.has(value) ? [ 1, [] ] : added.add(value) && [ 1, value.map((v => serializeForMain($winId$, $instanceId$, v, added))) ] : "object" === type ? value[InstanceIdKey] ? [ 3, [ value[WinIdKey], value[InstanceIdKey] ] ] : value instanceof Event ? [ 5, serializeObjectForMain($winId$, $instanceId$, value, false, added) ] : supportsTrustedHTML && value instanceof TrustedHTML ? [ 0, value.toString() ] : value instanceof ArrayBuffer ? [ 8, value ] : ArrayBuffer.isView(value) ? [ 9, value.buffer, getConstructorName(value) ] : [ 2, serializeObjectForMain($winId$, $instanceId$, value, true, added) ] : void 0 : value;
141
- const supportsTrustedHTML = "undefined" != typeof TrustedHTML;
142
- const serializeObjectForMain = (winId, instanceId, obj, includeFunctions, added, serializedObj, propName, propValue) => {
143
- serializedObj = {};
144
- if (!added.has(obj)) {
145
- added.add(obj);
146
- for (propName in obj) {
147
- propValue = obj[propName];
148
- (includeFunctions || "function" != typeof propValue) && (serializedObj[propName] = serializeForMain(winId, instanceId, propValue, added));
149
- }
150
- }
151
- return serializedObj;
152
- };
153
- const serializeInstanceForMain = (instance, value) => instance ? serializeForMain(instance[WinIdKey], instance[InstanceIdKey], value) : [ 0, value ];
154
- const deserializeFromMain = (winId, instanceId, applyPath, serializedValueTransfer, serializedType, serializedValue, obj, key) => {
155
- if (serializedValueTransfer) {
156
- serializedType = serializedValueTransfer[0];
157
- serializedValue = serializedValueTransfer[1];
158
- if (0 === serializedType || 11 === serializedType || 12 === serializedType) {
159
- return serializedValue;
160
- }
161
- if (4 === serializedType) {
162
- return deserializeRefFromMain(applyPath, serializedValue);
163
- }
164
- if (6 === serializedType) {
165
- return winId && applyPath.length > 0 ? (...args) => callMethod(environments[winId].$window$, applyPath, args, 1) : noop;
166
- }
167
- if (3 === serializedType) {
168
- return getOrCreateSerializedInstance(serializedValue);
169
- }
170
- if (7 === serializedType) {
171
- return new NodeList(serializedValue.map(getOrCreateSerializedInstance));
172
- }
173
- if (10 === serializedType) {
174
- return new Attr(serializedValue);
175
- }
176
- if (1 === serializedType) {
177
- return serializedValue.map((v => deserializeFromMain(winId, instanceId, applyPath, v)));
178
- }
179
- if (14 === serializedType) {
180
- return new CustomError(serializedValue);
181
- }
182
- obj = {};
183
- for (key in serializedValue) {
184
- obj[key] = deserializeFromMain(winId, instanceId, [ ...applyPath, key ], serializedValue[key]);
185
- }
186
- if (13 === serializedType) {
187
- return new environments[winId].$window$.CSSStyleDeclaration(winId, instanceId, applyPath, obj);
188
- }
189
- if (5 === serializedType) {
190
- if ("message" === obj.type && obj.origin) {
191
- let postMessageKey = JSON.stringify(obj.data);
192
- let postMessageData = postMessages.find((pm => pm.$data$ === postMessageKey));
193
- let env;
194
- if (postMessageData) {
195
- env = environments[postMessageData.$winId$];
196
- if (env) {
197
- obj.source = env.$window$;
198
- obj.origin = env.$location$.origin;
199
- }
200
- }
201
- }
202
- return new Proxy(new Event(obj.type, obj), {
203
- get: (target, propName) => propName in obj ? obj[propName] : "function" == typeof target[String(propName)] ? noop : target[String(propName)]
204
- });
205
- }
206
- if (2 === serializedType) {
207
- return obj;
208
- }
209
- }
210
- };
211
- const getOrCreateSerializedInstance = ([winId, instanceId, nodeName]) => instanceId === winId && environments[winId] ? environments[winId].$window$ : getOrCreateNodeInstance(winId, instanceId, nodeName);
212
- const deserializeRefFromMain = (applyPath, {$winId$: $winId$, $instanceId$: $instanceId$, $nodeName$: $nodeName$, $refId$: $refId$}) => {
213
- webWorkerRefsByRefId[$refId$] || webWorkerRefIdsByRef.set(webWorkerRefsByRefId[$refId$] = function(...args) {
214
- const instance = getOrCreateNodeInstance($winId$, $instanceId$, $nodeName$);
215
- return callMethod(instance, applyPath, args);
216
- }, $refId$);
217
- return webWorkerRefsByRefId[$refId$];
218
- };
219
- class CustomError extends Error {
220
- constructor(errorObject) {
221
- super(errorObject.message);
222
- this.name = errorObject.name;
223
- this.message = errorObject.message;
224
- this.stack = errorObject.stack;
225
- }
226
- }
227
- const NodeList = class {
228
- constructor(nodes) {
229
- (this._ = nodes).map(((node, index) => this[index] = node));
230
- }
231
- entries() {
232
- return this._.entries();
233
- }
234
- forEach(cb, thisArg) {
235
- this._.map(cb, thisArg);
236
- }
237
- item(index) {
238
- return this[index];
239
- }
240
- keys() {
241
- return this._.keys();
242
- }
243
- get length() {
244
- return len(this._);
245
- }
246
- values() {
247
- return this._.values();
248
- }
249
- [Symbol.iterator]() {
250
- return this._[Symbol.iterator]();
251
- }
252
- };
253
- const Attr = class {
254
- constructor(serializedAttr) {
255
- this.name = serializedAttr[0];
256
- this.value = serializedAttr[1];
257
- }
258
- get nodeName() {
259
- return this.name;
260
- }
261
- get nodeType() {
262
- return 2;
263
- }
264
- };
265
- const warnCrossOrgin = (apiType, apiName, env) => console.warn(`Partytown unable to ${apiType} cross-origin ${apiName}: ` + env.$location$);
266
- const logWorker = (msg, winId) => {
267
- try {
268
- const config = webWorkerCtx.$config$;
269
- if (config.logStackTraces) {
270
- const frames = (new Error).stack.split("\n");
271
- const i = frames.findIndex((f => f.includes("logWorker")));
272
- msg += "\n" + frames.slice(i + 1).join("\n");
273
- }
274
- let prefix;
275
- let color;
276
- if (winId) {
277
- prefix = `Worker (${normalizedWinId(winId)}) 🎉`;
278
- color = winColor(winId);
279
- } else {
280
- prefix = self.name;
281
- color = "#9844bf";
282
- }
283
- if (webWorkerCtx.lastLog !== msg) {
284
- webWorkerCtx.lastLog = msg;
285
- console.debug.apply(console, [ `%c${prefix}`, `background: ${color}; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;`, msg ]);
286
- }
287
- } catch (e) {}
288
- };
289
- const winIds = [];
290
- const normalizedWinId = winId => {
291
- winIds.includes(winId) || winIds.push(winId);
292
- return winIds.indexOf(winId) + 1;
293
- };
294
- const winColor = winId => {
295
- const colors = [ "#00309e", "#ea3655", "#eea727" ];
296
- const index = normalizedWinId(winId) - 1;
297
- return colors[index] || colors[colors.length - 1];
298
- };
299
- const getTargetProp = (target, applyPath) => {
300
- let n = "";
301
- if (target) {
302
- target[InstanceIdKey];
303
- const cstrName = getConstructorName(target);
304
- if ("Window" === cstrName) {
305
- n = "";
306
- } else if ("string" == typeof target[InstanceDataKey]) {
307
- let nodeName = target[InstanceDataKey];
308
- n = "#text" === nodeName ? "textNode." : "#comment" === nodeName ? "commentNode." : "#document" === nodeName ? "document." : "html" === nodeName ? "doctype." : nodeName.toLowerCase() + ".";
309
- } else {
310
- n = "nodeType" in target && 2 === target.nodeType ? "attributes." : "CanvasRenderingContext2D" === cstrName ? "context2D." : "CanvasRenderingContextWebGL" === cstrName ? "contextWebGL." : "CSSStyleDeclaration" === cstrName ? "style." : "MutationObserver" === cstrName ? "mutationObserver." : "NamedNodeMap" === cstrName ? "namedNodeMap." : "ResizeObserver" === cstrName ? "resizeObserver." : cstrName.substring(0, 1).toLowerCase() + cstrName.substring(1) + ".";
311
- }
312
- target[ApplyPathKey] && target[ApplyPathKey].length && (n += [ ...target[ApplyPathKey] ].join(".") + ".");
313
- }
314
- if (applyPath.length > 1) {
315
- const first = applyPath.slice(0, applyPath.length - 1);
316
- const last = applyPath[applyPath.length - 1];
317
- if (!isNaN(last)) {
318
- return n + `${first.join(".")}[${last}]`;
319
- }
320
- }
321
- return n + applyPath.join(".");
322
- };
323
- const getLogValue = (applyPath, v) => {
324
- const type = typeof v;
325
- if (void 0 === v) {
326
- return "undefined";
327
- }
328
- if ("boolean" === type || "number" === type || null == v) {
329
- return JSON.stringify(v);
330
- }
331
- if ("string" === type) {
332
- return applyPath.includes("cookie") ? JSON.stringify(v.slice(0, 10) + "...") : JSON.stringify(v.length > 50 ? v.slice(0, 40) + "..." : v);
333
- }
334
- if (Array.isArray(v)) {
335
- return `[${v.map(getLogValue).join(", ")}]`;
336
- }
337
- if ("object" === type) {
338
- const instanceId = v[InstanceIdKey];
339
- const cstrName = getConstructorName(v);
340
- if ("string" == typeof instanceId) {
341
- if ("Window" === cstrName) {
342
- return "window";
343
- }
344
- if ("string" == typeof v[InstanceDataKey]) {
345
- if (1 === v.nodeType) {
346
- return `<${v[InstanceDataKey].toLowerCase()}>`;
347
- }
348
- if (10 === v.nodeType) {
349
- return `<!DOCTYPE ${v[InstanceDataKey]}>`;
350
- }
351
- if (v.nodeType <= 11) {
352
- return v[InstanceDataKey];
353
- }
354
- }
355
- return "¯\\_(ツ)_/¯ instance obj";
356
- }
357
- return v[Symbol.iterator] ? `[${Array.from(v).map((i => getLogValue(applyPath, i))).join(", ")}]` : "value" in v ? "string" == typeof v.value ? `"${v.value}"` : objToString(v.value) : objToString(v);
358
- }
359
- return (v => "object" == typeof v && v && v.then)(v) ? "Promise" : "function" === type ? `ƒ() ${v.name || ""}`.trim() : `¯\\_(ツ)_/¯ ${String(v)}`.trim();
360
- };
361
- const objToString = obj => {
362
- const s = [];
363
- for (let key in obj) {
364
- const value = obj[key];
365
- const type = typeof value;
366
- "string" === type ? s.push(`${key}: "${value}"`) : "function" === type ? s.push(`${key}: ƒ`) : Array.isArray(type) ? s.push(`${key}: [..]`) : "object" === type && value ? s.push(`${key}: {..}`) : s.push(`${key}: ${String(value)}`);
367
- }
368
- let str = s.join(", ");
369
- str.length > 200 && (str = str.substring(0, 200) + "..");
370
- return `{ ${str} }`;
371
- };
372
- const logDimensionCacheClearStyle = (target, propName) => {
373
- (webWorkerCtx.$config$.logGetters || webWorkerCtx.$config$.logSetters) && logWorker(`Dimension cache cleared from style.${propName} setter`, target[WinIdKey]);
374
- };
375
- const logDimensionCacheClearMethod = (target, methodName) => {
376
- (webWorkerCtx.$config$.logGetters || webWorkerCtx.$config$.logCalls) && logWorker(`Dimension cache cleared from method call ${methodName}()`, target[WinIdKey]);
377
- };
378
- const taskQueue = [];
379
- const queue = (instance, $applyPath$, callType, $assignInstanceId$, $groupedGetters$, buffer) => {
380
- if (instance[ApplyPathKey]) {
381
- taskQueue.push({
382
- $winId$: instance[WinIdKey],
383
- $instanceId$: instance[InstanceIdKey],
384
- $applyPath$: [ ...instance[ApplyPathKey], ...$applyPath$ ],
385
- $assignInstanceId$: $assignInstanceId$,
386
- $groupedGetters$: $groupedGetters$
387
- });
388
- taskQueue[len(taskQueue) - 1].$debug$ = ((target, applyPath, callType) => {
389
- let m = getTargetProp(target, applyPath);
390
- 1 === callType ? m += " (blocking)" : 2 === callType ? m += " (non-blocking)" : 3 === callType && (m += " (non-blocking, no-side-effect)");
391
- return m.trim();
392
- })(instance, $applyPath$, callType);
393
- buffer && 3 !== callType && console.error("buffer must be sent NonBlockingNoSideEffect");
394
- if (3 === callType) {
395
- webWorkerCtx.$postMessage$([ 12, {
396
- $msgId$: randomId(),
397
- $tasks$: [ ...taskQueue ]
398
- } ], buffer ? [ buffer instanceof ArrayBuffer ? buffer : buffer.buffer ] : void 0);
399
- taskQueue.length = 0;
400
- } else if (1 === callType) {
401
- return sendToMain(true);
402
- }
403
- webWorkerCtx.$asyncMsgTimer$ = setTimeout(sendToMain, 20);
404
- }
405
- };
406
- const sendToMain = isBlocking => {
407
- clearTimeout(webWorkerCtx.$asyncMsgTimer$);
408
- if (len(taskQueue)) {
409
- webWorkerCtx.$config$.logMainAccess && logWorker(`Main access, tasks sent: ${taskQueue.length}`);
410
- const endTask = taskQueue[len(taskQueue) - 1];
411
- const accessReq = {
412
- $msgId$: randomId(),
413
- $tasks$: [ ...taskQueue ]
414
- };
415
- taskQueue.length = 0;
416
- if (isBlocking) {
417
- const accessRsp = ((webWorkerCtx, accessReq) => {
418
- const sharedDataBuffer = webWorkerCtx.$sharedDataBuffer$;
419
- const sharedData = new Int32Array(sharedDataBuffer);
420
- Atomics.store(sharedData, 0, 0);
421
- webWorkerCtx.$postMessage$([ 11, accessReq ]);
422
- Atomics.wait(sharedData, 0, 0);
423
- let dataLength = Atomics.load(sharedData, 0);
424
- let accessRespStr = "";
425
- let i = 0;
426
- for (;i < dataLength; i++) {
427
- accessRespStr += String.fromCharCode(sharedData[i + 1]);
428
- }
429
- return JSON.parse(accessRespStr);
430
- })(webWorkerCtx, accessReq);
431
- const isPromise = accessRsp.$isPromise$;
432
- const rtnValue = deserializeFromMain(endTask.$winId$, endTask.$instanceId$, endTask.$applyPath$, accessRsp.$rtnValue$);
433
- if (accessRsp.$error$) {
434
- if (isPromise) {
435
- return Promise.reject(accessRsp.$error$);
436
- }
437
- throw new Error(accessRsp.$error$);
438
- }
439
- return isPromise ? Promise.resolve(rtnValue) : rtnValue;
440
- }
441
- webWorkerCtx.$postMessage$([ 12, accessReq ]);
442
- }
443
- };
444
- const getter = (instance, applyPath, groupedGetters, rtnValue) => {
445
- if (webWorkerCtx.$config$.get) {
446
- rtnValue = webWorkerCtx.$config$.get(createHookOptions(instance, applyPath));
447
- if (rtnValue !== HookContinue) {
448
- return rtnValue;
449
- }
450
- }
451
- rtnValue = queue(instance, applyPath, 1, void 0, groupedGetters);
452
- ((target, applyPath, rtnValue, restrictedToWorker = false, groupedGetters = false) => {
453
- if (webWorkerCtx.$config$.logGetters) {
454
- try {
455
- const msg = `Get ${getTargetProp(target, applyPath)}, returned: ${getLogValue(applyPath, rtnValue)}${restrictedToWorker ? " (restricted to worker)" : ""}${groupedGetters ? " (grouped getter)" : ""}`;
456
- msg.includes("Symbol(") || logWorker(msg, target[WinIdKey]);
457
- } catch (e) {}
458
- }
459
- })(instance, applyPath, rtnValue, false, !!groupedGetters);
460
- return rtnValue;
461
- };
462
- const setter = (instance, applyPath, value, hookSetterValue) => {
463
- if (webWorkerCtx.$config$.set) {
464
- hookSetterValue = webWorkerCtx.$config$.set({
465
- value: value,
466
- prevent: HookPrevent,
467
- ...createHookOptions(instance, applyPath)
468
- });
469
- if (hookSetterValue === HookPrevent) {
470
- return;
471
- }
472
- hookSetterValue !== HookContinue && (value = hookSetterValue);
473
- }
474
- if (dimensionChangingSetterNames.some((s => applyPath.includes(s)))) {
475
- cachedDimensions.clear();
476
- ((target, propName) => {
477
- (webWorkerCtx.$config$.logGetters || webWorkerCtx.$config$.logSetters) && logWorker(`Dimension cache cleared from setter "${propName}"`, target[WinIdKey]);
478
- })(instance, applyPath[applyPath.length - 1]);
479
- }
480
- applyPath = [ ...applyPath, serializeInstanceForMain(instance, value), 0 ];
481
- ((target, applyPath, value, restrictedToWorker = false) => {
482
- if (webWorkerCtx.$config$.logSetters) {
483
- try {
484
- applyPath = applyPath.slice(0, applyPath.length - 2);
485
- logWorker(`Set ${getTargetProp(target, applyPath)}, value: ${getLogValue(applyPath, value)}${restrictedToWorker ? " (restricted to worker)" : ""}`, target[WinIdKey]);
486
- } catch (e) {}
487
- }
488
- })(instance, applyPath, value);
489
- queue(instance, applyPath, 2);
490
- };
491
- const callMethod = (instance, applyPath, args, callType, assignInstanceId, buffer, rtnValue, methodName) => {
492
- if (webWorkerCtx.$config$.apply) {
493
- rtnValue = webWorkerCtx.$config$.apply({
494
- args: args,
495
- ...createHookOptions(instance, applyPath)
496
- });
497
- if (rtnValue !== HookContinue) {
498
- return rtnValue;
499
- }
500
- }
501
- methodName = applyPath[len(applyPath) - 1];
502
- applyPath = [ ...applyPath, serializeInstanceForMain(instance, args) ];
503
- callType = callType || (nonBlockingMethods.includes(methodName) ? 2 : 1);
504
- if ("setAttribute" === methodName && hasInstanceStateValue(instance, args[0])) {
505
- setInstanceStateValue(instance, args[0], args[1]);
506
- } else if (structureChangingMethodNames.includes(methodName)) {
507
- cachedDimensions.clear();
508
- cachedStructure.clear();
509
- ((target, methodName) => {
510
- (webWorkerCtx.$config$.logGetters || webWorkerCtx.$config$.logCalls) && logWorker(`Dimension and DOM structure cache cleared from method call ${methodName}()`, target[WinIdKey]);
511
- })(instance, methodName);
512
- } else if (dimensionChangingMethodNames.includes(methodName)) {
513
- callType = 2;
514
- cachedDimensions.clear();
515
- logDimensionCacheClearMethod(instance, methodName);
516
- }
517
- rtnValue = queue(instance, applyPath, callType, assignInstanceId, void 0, buffer);
518
- ((target, applyPath, args, rtnValue) => {
519
- if (webWorkerCtx.$config$.logCalls) {
520
- try {
521
- applyPath = applyPath.slice(0, applyPath.length - 1);
522
- logWorker(`Call ${getTargetProp(target, applyPath)}(${args.map((v => getLogValue(applyPath, v))).join(", ")}), returned: ${getLogValue(applyPath, rtnValue)}`, target[WinIdKey]);
523
- } catch (e) {}
524
- }
525
- })(instance, applyPath, args, rtnValue);
526
- return rtnValue;
527
- };
528
- const constructGlobal = (instance, cstrName, args) => {
529
- ((target, cstrName, args) => {
530
- if (webWorkerCtx.$config$.logCalls) {
531
- try {
532
- logWorker(`Construct new ${cstrName}(${args.map((v => getLogValue([], v))).join(", ")})`, target[WinIdKey]);
533
- } catch (e) {}
534
- }
535
- })(instance, cstrName, args);
536
- queue(instance, [ 1, cstrName, serializeInstanceForMain(instance, args) ], 1);
537
- };
538
- const createHookOptions = (instance, applyPath) => ({
539
- name: applyPath.join("."),
540
- continue: HookContinue,
541
- nodeName: instance[InstanceDataKey],
542
- constructor: getConstructorName(instance)
543
- });
544
- const addStorageApi = (win, storageName, storages, isSameOrigin, env) => {
545
- let getItems = items => {
546
- items = storages.get(win.origin);
547
- items || storages.set(win.origin, items = []);
548
- return items;
549
- };
550
- let getIndexByKey = key => getItems().findIndex((i => i[STORAGE_KEY] === key));
551
- let index;
552
- let item;
553
- let storage = {
554
- getItem(key) {
555
- index = getIndexByKey(key);
556
- return index > -1 ? getItems()[index][STORAGE_VALUE] : null;
557
- },
558
- setItem(key, value) {
559
- index = getIndexByKey(key);
560
- index > -1 ? getItems()[index][STORAGE_VALUE] = value : getItems().push([ key, value ]);
561
- isSameOrigin ? callMethod(win, [ storageName, "setItem" ], [ key, value ], 2) : warnCrossOrgin("set", storageName, env);
562
- },
563
- removeItem(key) {
564
- index = getIndexByKey(key);
565
- index > -1 && getItems().splice(index, 1);
566
- isSameOrigin ? callMethod(win, [ storageName, "removeItem" ], [ key ], 2) : warnCrossOrgin("remove", storageName, env);
567
- },
568
- key(index) {
569
- item = getItems()[index];
570
- return item ? item[STORAGE_KEY] : null;
571
- },
572
- clear() {
573
- getItems().length = 0;
574
- isSameOrigin ? callMethod(win, [ storageName, "clear" ], EMPTY_ARRAY, 2) : warnCrossOrgin("clear", storageName, env);
575
- },
576
- get length() {
577
- return getItems().length;
578
- }
579
- };
580
- win[storageName] = storage;
581
- };
582
- const STORAGE_KEY = 0;
583
- const STORAGE_VALUE = 1;
584
- const createCSSStyleDeclarationCstr = (win, WorkerBase, cstrName) => {
585
- win[cstrName] = defineConstructorName(class extends WorkerBase {
586
- constructor(winId, instanceId, applyPath, styles) {
587
- super(winId, instanceId, applyPath, styles || {});
588
- return new Proxy(this, {
589
- get(target, propName) {
590
- if (target[propName]) {
591
- return target[propName];
592
- }
593
- target[propName] || "string" != typeof propName || target[InstanceDataKey][propName] || (target[InstanceDataKey][propName] = getter(target, [ propName ]));
594
- return target[InstanceDataKey][propName];
595
- },
596
- set(target, propName, propValue) {
597
- target[InstanceDataKey][propName] = propValue;
598
- setter(target, [ propName ], propValue);
599
- logDimensionCacheClearStyle(target, propName);
600
- cachedDimensions.clear();
601
- return true;
602
- }
603
- });
604
- }
605
- setProperty(...args) {
606
- this[InstanceDataKey][args[0]] = args[1];
607
- callMethod(this, [ "setProperty" ], args, 2);
608
- logDimensionCacheClearStyle(this, args[0]);
609
- cachedDimensions.clear();
610
- }
611
- getPropertyValue(propName) {
612
- return this[propName];
613
- }
614
- removeProperty(propName) {
615
- let value = this[InstanceDataKey][propName];
616
- callMethod(this, [ "removeProperty" ], [ propName ], 2);
617
- logDimensionCacheClearStyle(this, propName);
618
- cachedDimensions.clear();
619
- this[InstanceDataKey][propName] = void 0;
620
- return value;
621
- }
622
- }, cstrName);
623
- };
624
- const createCSSStyleSheetConstructor = (win, cssStyleSheetCstrName) => {
625
- win[cssStyleSheetCstrName] = defineConstructorName(class {
626
- constructor(ownerNode) {
627
- this.ownerNode = ownerNode;
628
- }
629
- get cssRules() {
630
- const ownerNode = this.ownerNode;
631
- return new Proxy({}, {
632
- get(target, propKey) {
633
- const propName = String(propKey);
634
- return "item" === propName ? index => getCssRule(ownerNode, index) : "length" === propName ? getCssRules(ownerNode).length : isNaN(propName) ? target[propKey] : getCssRule(ownerNode, propName);
635
- }
636
- });
637
- }
638
- insertRule(ruleText, index) {
639
- const cssRules = getCssRules(this.ownerNode);
640
- index = void 0 === index ? 0 : index;
641
- if (index >= 0 && index <= cssRules.length) {
642
- callMethod(this.ownerNode, [ "sheet", "insertRule" ], [ ruleText, index ], 2);
643
- cssRules.splice(index, 0, 0);
644
- }
645
- logDimensionCacheClearMethod(this.ownerNode, "insertRule");
646
- cachedDimensions.clear();
647
- return index;
648
- }
649
- deleteRule(index) {
650
- callMethod(this.ownerNode, [ "sheet", "deleteRule" ], [ index ], 2);
651
- getCssRules(this.ownerNode).splice(index, 1);
652
- logDimensionCacheClearMethod(this.ownerNode, "deleteRule");
653
- cachedDimensions.clear();
654
- }
655
- get type() {
656
- return "text/css";
657
- }
658
- }, cssStyleSheetCstrName);
659
- const HTMLStyleDescriptorMap = {
660
- sheet: {
661
- get() {
662
- return new win[cssStyleSheetCstrName](this);
663
- }
664
- }
665
- };
666
- definePrototypePropertyDescriptor(win.HTMLStyleElement, HTMLStyleDescriptorMap);
667
- };
668
- const getCssRules = (ownerNode, cssRules) => {
669
- cssRules = getInstanceStateValue(ownerNode, 2);
670
- if (!cssRules) {
671
- cssRules = getter(ownerNode, [ "sheet", "cssRules" ]);
672
- setInstanceStateValue(ownerNode, 2, cssRules);
673
- }
674
- return cssRules;
675
- };
676
- const getCssRule = (ownerNode, index, cssRules) => {
677
- cssRules = getCssRules(ownerNode);
678
- 0 === cssRules[index] && (cssRules[index] = getter(ownerNode, [ "sheet", "cssRules", parseInt(index, 10) ]));
679
- return cssRules[index];
680
- };
681
- const runScriptContent = (env, instanceId, scriptContent, winId, errorMsg) => {
682
- try {
683
- webWorkerCtx.$config$.logScriptExecution && logWorker(`Execute script: ${scriptContent.substring(0, 100).split("\n").map((l => l.trim())).join(" ").trim().substring(0, 60)}...`, winId);
684
- env.$currentScriptId$ = instanceId;
685
- run(env, scriptContent);
686
- } catch (contentError) {
687
- console.error(scriptContent, contentError);
688
- errorMsg = String(contentError.stack || contentError);
689
- }
690
- env.$currentScriptId$ = "";
691
- return errorMsg;
692
- };
693
- const run = (env, scriptContent, scriptUrl) => {
694
- env.$runWindowLoadEvent$ = 1;
695
- scriptContent = `with(this){${(webWorkerCtx.$config$.globalFns || []).filter((globalFnName => /[a-zA-Z_$][0-9a-zA-Z_$]*/.test(globalFnName))).map((g => `(typeof ${g}=='function'&&(window.${g}=${g}))`)).join(";") + scriptContent.replace(/\bthis\b/g, "(thi$(this)?window:this)").replace(/\/\/# so/g, "//Xso")}\n;function thi$(t){return t===this}}` + (scriptUrl ? "\n//# sourceURL=" + scriptUrl : "");
696
- env.$isSameOrigin$ || (scriptContent = scriptContent.replace(/.postMessage\(/g, `.postMessage('${env.$winId$}',`));
697
- new Function(scriptContent).call(env.$window$);
698
- env.$runWindowLoadEvent$ = 0;
699
- };
700
- const runStateLoadHandlers = (instance, type, handlers) => {
701
- handlers = getInstanceStateValue(instance, type);
702
- handlers && setTimeout((() => handlers.map((cb => cb({
703
- type: type
704
- })))));
705
- };
706
- const resolveToUrl = (env, url, type, baseLocation, resolvedUrl, configResolvedUrl) => {
707
- baseLocation = env.$location$;
708
- while (!baseLocation.host) {
709
- env = environments[env.$parentWinId$];
710
- baseLocation = env.$location$;
711
- if (env.$winId$ === env.$parentWinId$) {
712
- break;
713
- }
714
- }
715
- resolvedUrl = new URL(url || "", baseLocation);
716
- if (type && webWorkerCtx.$config$.resolveUrl) {
717
- configResolvedUrl = webWorkerCtx.$config$.resolveUrl(resolvedUrl, baseLocation, type);
718
- if (configResolvedUrl) {
719
- return configResolvedUrl;
720
- }
721
- }
722
- return resolvedUrl;
723
- };
724
- const resolveUrl = (env, url, type) => resolveToUrl(env, url, type) + "";
725
- const getPartytownScript = () => `<script src="${partytownLibUrl("partytown.js?v=0.6.4")}"><\/script>`;
726
- const createImageConstructor = env => class HTMLImageElement {
727
- constructor() {
728
- this.s = "";
729
- this.l = [];
730
- this.e = [];
731
- }
732
- get src() {
733
- return this.s;
734
- }
735
- set src(src) {
736
- webWorkerCtx.$config$.logImageRequests && logWorker(`Image() request: ${resolveUrl(env, src, null)}`, env.$winId$);
737
- this.s = src;
738
- fetch(resolveUrl(env, src, null), {
739
- mode: "no-cors",
740
- credentials: "include",
741
- keepalive: true
742
- }).then((rsp => {
743
- rsp.ok || 0 === rsp.status ? this.l.map((cb => cb({
744
- type: "load"
745
- }))) : this.e.map((cb => cb({
746
- type: "error"
747
- })));
748
- }), (() => this.e.forEach((cb => cb({
749
- type: "error"
750
- })))));
751
- }
752
- addEventListener(eventName, cb) {
753
- "load" === eventName && this.l.push(cb);
754
- "error" === eventName && this.e.push(cb);
755
- }
756
- get onload() {
757
- return this.l[0];
758
- }
759
- set onload(cb) {
760
- this.l = [ cb ];
761
- }
762
- get onerror() {
763
- return this.e[0];
764
- }
765
- set onerror(cb) {
766
- this.e = [ cb ];
767
- }
768
- };
769
- const HTMLSrcElementDescriptorMap = {
770
- addEventListener: {
771
- value(...args) {
772
- const eventName = args[0];
773
- const callbacks = getInstanceStateValue(this, eventName) || [];
774
- callbacks.push(args[1]);
775
- setInstanceStateValue(this, eventName, callbacks);
776
- }
777
- },
778
- async: {
779
- get: noop,
780
- set: noop
781
- },
782
- defer: {
783
- get: noop,
784
- set: noop
785
- },
786
- onload: {
787
- get() {
788
- let callbacks = getInstanceStateValue(this, "load");
789
- return callbacks && callbacks[0] || null;
790
- },
791
- set(cb) {
792
- setInstanceStateValue(this, "load", cb ? [ cb ] : null);
793
- }
794
- },
795
- onerror: {
796
- get() {
797
- let callbacks = getInstanceStateValue(this, "error");
798
- return callbacks && callbacks[0] || null;
799
- },
800
- set(cb) {
801
- setInstanceStateValue(this, "error", cb ? [ cb ] : null);
802
- }
803
- },
804
- getAttribute: {
805
- value(attrName) {
806
- return "src" === attrName ? this.src : callMethod(this, [ "getAttribute" ], [ attrName ]);
807
- }
808
- },
809
- setAttribute: {
810
- value(attrName, attrValue) {
811
- scriptAttrPropNames.includes(attrName) ? this[attrName] = attrValue : callMethod(this, [ "setAttribute" ], [ attrName, attrValue ]);
812
- }
813
- }
814
- };
815
- const scriptAttrPropNames = commaSplit("src,type");
816
- const patchHTMLScriptElement = (WorkerHTMLScriptElement, env) => {
817
- const HTMLScriptDescriptorMap = {
818
- innerHTML: innerHTMLDescriptor,
819
- innerText: innerHTMLDescriptor,
820
- src: {
821
- get() {
822
- return getInstanceStateValue(this, 4) || "";
823
- },
824
- set(url) {
825
- const orgUrl = resolveUrl(env, url, null);
826
- const config = webWorkerCtx.$config$;
827
- url = resolveUrl(env, url, "script");
828
- setInstanceStateValue(this, 4, url);
829
- setter(this, [ "src" ], url);
830
- orgUrl !== url && setter(this, [ "dataset", "ptsrc" ], orgUrl);
831
- if (this.type && config.loadScriptsOnMainThread) {
832
- const shouldExecuteScriptViaMainThread = config.loadScriptsOnMainThread.some((scriptUrl => scriptUrl === url));
833
- shouldExecuteScriptViaMainThread && setter(this, [ "type" ], "text/javascript");
834
- }
835
- }
836
- },
837
- textContent: innerHTMLDescriptor,
838
- type: {
839
- get() {
840
- return getter(this, [ "type" ]);
841
- },
842
- set(type) {
843
- if (!isScriptJsType(type)) {
844
- setInstanceStateValue(this, 5, type);
845
- setter(this, [ "type" ], type);
846
- }
847
- }
848
- },
849
- ...HTMLSrcElementDescriptorMap
850
- };
851
- definePrototypePropertyDescriptor(WorkerHTMLScriptElement, HTMLScriptDescriptorMap);
852
- };
853
- const innerHTMLDescriptor = {
854
- get() {
855
- return getInstanceStateValue(this, 3) || "";
856
- },
857
- set(scriptContent) {
858
- setInstanceStateValue(this, 3, scriptContent);
859
- }
860
- };
861
- const isScriptJsType = scriptType => !scriptType || "text/javascript" === scriptType;
862
- const createNodeCstr = (win, env, WorkerBase) => {
863
- const WorkerNode = defineConstructorName(class extends WorkerBase {
864
- appendChild(node) {
865
- return this.insertBefore(node, null);
866
- }
867
- get href() {}
868
- set href(_) {}
869
- insertBefore(newNode, referenceNode) {
870
- const winId = newNode[WinIdKey] = this[WinIdKey];
871
- const instanceId = newNode[InstanceIdKey];
872
- const nodeName = newNode[InstanceDataKey];
873
- const isScript = "SCRIPT" === nodeName;
874
- const isIFrame = "IFRAME" === nodeName;
875
- if (isScript) {
876
- const scriptContent = getInstanceStateValue(newNode, 3);
877
- const scriptType = getInstanceStateValue(newNode, 5);
878
- if (scriptContent) {
879
- if (isScriptJsType(scriptType)) {
880
- const errorMsg = runScriptContent(env, instanceId, scriptContent, winId, "");
881
- const datasetType = errorMsg ? "pterror" : "ptid";
882
- const datasetValue = errorMsg || instanceId;
883
- setter(newNode, [ "type" ], "text/partytown-x");
884
- setter(newNode, [ "dataset", datasetType ], datasetValue);
885
- }
886
- setter(newNode, [ "innerHTML" ], scriptContent);
887
- }
888
- }
889
- callMethod(this, [ "insertBefore" ], [ newNode, referenceNode ], 2);
890
- if (isIFrame) {
891
- const src = getInstanceStateValue(newNode, 0);
892
- if (src && src.startsWith("javascript:")) {
893
- const scriptContent = src.split("javascript:")[1];
894
- runScriptContent(env, instanceId, scriptContent, winId, "");
895
- }
896
- ((winId, iframe) => {
897
- let i = 0;
898
- let type;
899
- let handlers;
900
- let callback = () => {
901
- if (environments[winId] && environments[winId].$isInitialized$ && !environments[winId].$isLoading$) {
902
- type = getInstanceStateValue(iframe, 1) ? "error" : "load";
903
- handlers = getInstanceStateValue(iframe, type);
904
- handlers && handlers.map((handler => handler({
905
- type: type
906
- })));
907
- } else if (i++ > 2e3) {
908
- handlers = getInstanceStateValue(iframe, "error");
909
- handlers && handlers.map((handler => handler({
910
- type: "error"
911
- })));
912
- } else {
913
- setTimeout(callback, 9);
914
- }
915
- };
916
- callback();
917
- })(instanceId, newNode);
918
- }
919
- if (isScript) {
920
- sendToMain(true);
921
- webWorkerCtx.$postMessage$([ 7, winId ]);
922
- }
923
- return newNode;
924
- }
925
- get nodeName() {
926
- return "#s" === this[InstanceDataKey] ? "#document-fragment" : this[InstanceDataKey];
927
- }
928
- get nodeType() {
929
- return 3;
930
- }
931
- get ownerDocument() {
932
- return env.$document$;
933
- }
934
- }, "Node");
935
- cachedTreeProps(WorkerNode, commaSplit("childNodes,firstChild,isConnected,lastChild,nextSibling,parentElement,parentNode,previousSibling"));
936
- win.Node = WorkerNode;
937
- };
938
- const htmlMedia = commaSplit("AUDIO,CANVAS,VIDEO");
939
- const windowMediaConstructors = commaSplit("Audio,MediaSource");
940
- const patchDocument = (WorkerDocument, env, isDocumentImplementation) => {
941
- const DocumentDescriptorMap = {
942
- body: {
943
- get: () => env.$body$
944
- },
945
- cookie: {
946
- get() {
947
- if (env.$isSameOrigin$) {
948
- return getter(this, [ "cookie" ]);
949
- }
950
- warnCrossOrgin("get", "cookie", env);
951
- return "";
952
- },
953
- set(value) {
954
- if (env.$isSameOrigin$) {
955
- setter(this, [ "cookie" ], value);
956
- } else {
957
- warnCrossOrgin("set", "cookie", env);
958
- }
959
- }
960
- },
961
- createElement: {
962
- value(tagName) {
963
- tagName = tagName.toUpperCase();
964
- if (!IS_TAG_REG.test(tagName)) {
965
- throw tagName + " not valid";
966
- }
967
- const isIframe = "IFRAME" === tagName;
968
- const winId = this[WinIdKey];
969
- const instanceId = (isIframe ? "f_" : "") + randomId();
970
- callMethod(this, [ "createElement" ], [ tagName ], 2, instanceId);
971
- const elm = getOrCreateNodeInstance(winId, instanceId, tagName);
972
- if (isIframe) {
973
- const env = createEnvironment({
974
- $winId$: instanceId,
975
- $parentWinId$: winId,
976
- $url$: "about:blank"
977
- }, true);
978
- env.$window$.fetch = fetch;
979
- setter(elm, [ "srcdoc" ], getPartytownScript());
980
- } else if ("SCRIPT" === tagName) {
981
- const scriptType = getInstanceStateValue(elm, 5);
982
- isScriptJsType(scriptType) && setter(elm, [ "type" ], "text/partytown");
983
- }
984
- return elm;
985
- }
986
- },
987
- createElementNS: {
988
- value(namespace, tagName) {
989
- const instanceId = randomId();
990
- const nsElm = getOrCreateNodeInstance(this[WinIdKey], instanceId, tagName, namespace);
991
- callMethod(this, [ "createElementNS" ], [ namespace, tagName ], 2, instanceId);
992
- return nsElm;
993
- }
994
- },
995
- createTextNode: {
996
- value(text) {
997
- const winId = this[WinIdKey];
998
- const instanceId = randomId();
999
- const textNode = getOrCreateNodeInstance(winId, instanceId, "#text");
1000
- callMethod(this, [ "createTextNode" ], [ text ], 2, instanceId);
1001
- return textNode;
1002
- }
1003
- },
1004
- createEvent: {
1005
- value: type => new Event(type)
1006
- },
1007
- currentScript: {
1008
- get() {
1009
- return env.$currentScriptId$ ? getOrCreateNodeInstance(this[WinIdKey], env.$currentScriptId$, "SCRIPT") : null;
1010
- }
1011
- },
1012
- defaultView: {
1013
- get: () => isDocumentImplementation ? null : env.$window$
1014
- },
1015
- documentElement: {
1016
- get: () => env.$documentElement$
1017
- },
1018
- getElementsByTagName: {
1019
- value(tagName) {
1020
- tagName = tagName.toUpperCase();
1021
- return "BODY" === tagName ? [ env.$body$ ] : "HEAD" === tagName ? [ env.$head$ ] : callMethod(this, [ "getElementsByTagName" ], [ tagName ]);
1022
- }
1023
- },
1024
- head: {
1025
- get: () => env.$head$
1026
- },
1027
- images: {
1028
- get() {
1029
- return getter(this, [ "images" ]);
1030
- }
1031
- },
1032
- implementation: {
1033
- get() {
1034
- return {
1035
- hasFeature: () => true,
1036
- createHTMLDocument: title => {
1037
- const $winId$ = randomId();
1038
- callMethod(this, [ "implementation", "createHTMLDocument" ], [ title ], 1, {
1039
- $winId$: $winId$
1040
- });
1041
- const docEnv = createEnvironment({
1042
- $winId$: $winId$,
1043
- $parentWinId$: $winId$,
1044
- $url$: env.$location$ + "",
1045
- $visibilityState$: "hidden"
1046
- }, true, true);
1047
- return docEnv.$document$;
1048
- }
1049
- };
1050
- }
1051
- },
1052
- location: {
1053
- get: () => env.$location$,
1054
- set(url) {
1055
- env.$location$.href = url + "";
1056
- }
1057
- },
1058
- nodeType: {
1059
- value: 9
1060
- },
1061
- parentNode: {
1062
- value: null
1063
- },
1064
- parentElement: {
1065
- value: null
1066
- },
1067
- readyState: {
1068
- value: "complete"
1069
- },
1070
- visibilityState: {
1071
- get: () => env.$visibilityState$ || "visible"
1072
- }
1073
- };
1074
- definePrototypePropertyDescriptor(WorkerDocument, DocumentDescriptorMap);
1075
- cachedProps(WorkerDocument, "compatMode,referrer,forms");
1076
- };
1077
- const patchDocumentElementChild = (WokerDocumentElementChild, env) => {
1078
- const DocumentElementChildDescriptorMap = {
1079
- parentElement: {
1080
- get() {
1081
- return this.parentNode;
1082
- }
1083
- },
1084
- parentNode: {
1085
- get: () => env.$documentElement$
1086
- }
1087
- };
1088
- definePrototypePropertyDescriptor(WokerDocumentElementChild, DocumentElementChildDescriptorMap);
1089
- };
1090
- const patchElement = (WorkerElement, WorkerHTMLElement) => {
1091
- const ElementDescriptorMap = {
1092
- localName: {
1093
- get() {
1094
- return this[InstanceDataKey].toLowerCase();
1095
- }
1096
- },
1097
- namespaceURI: {
1098
- get() {
1099
- return this[NamespaceKey] || "http://www.w3.org/1999/xhtml";
1100
- }
1101
- },
1102
- nodeType: {
1103
- value: 1
1104
- },
1105
- tagName: {
1106
- get() {
1107
- return this[InstanceDataKey];
1108
- }
1109
- }
1110
- };
1111
- definePrototypePropertyDescriptor(WorkerElement, ElementDescriptorMap);
1112
- cachedTreeProps(WorkerElement, elementStructurePropNames);
1113
- cachedProps(WorkerElement, "id");
1114
- cachedDimensionProps(WorkerHTMLElement);
1115
- cachedDimensionMethods(WorkerHTMLElement, commaSplit("getClientRects,getBoundingClientRect"));
1116
- };
1117
- const patchHTMLAnchorElement = (WorkerHTMLAnchorElement, env) => {
1118
- const HTMLAnchorDescriptorMap = {};
1119
- commaSplit("hash,host,hostname,href,origin,pathname,port,protocol,search").map((anchorProp => {
1120
- HTMLAnchorDescriptorMap[anchorProp] = {
1121
- get() {
1122
- let value = getInstanceStateValue(this, 4);
1123
- let href;
1124
- if ("string" != typeof value) {
1125
- href = getter(this, [ "href" ]);
1126
- setInstanceStateValue(this, 4, href);
1127
- value = new URL(href)[anchorProp];
1128
- }
1129
- return resolveToUrl(env, value, null)[anchorProp];
1130
- },
1131
- set(value) {
1132
- let url;
1133
- if ("href" === anchorProp) {
1134
- if ((url => {
1135
- try {
1136
- new URL(url);
1137
- return true;
1138
- } catch (_) {
1139
- return false;
1140
- }
1141
- })(value)) {
1142
- url = new URL(value);
1143
- } else {
1144
- const baseHref = env.$location$.href;
1145
- url = resolveToUrl(env, baseHref, null);
1146
- url.href = new URL(value + "", url.href);
1147
- }
1148
- } else {
1149
- url = resolveToUrl(env, this.href, null);
1150
- url[anchorProp] = value;
1151
- }
1152
- setInstanceStateValue(this, 4, url.href);
1153
- setter(this, [ "href" ], url.href);
1154
- }
1155
- };
1156
- }));
1157
- definePrototypePropertyDescriptor(WorkerHTMLAnchorElement, HTMLAnchorDescriptorMap);
1158
- };
1159
- const patchHTMLIFrameElement = (WorkerHTMLIFrameElement, env) => {
1160
- const HTMLIFrameDescriptorMap = {
1161
- contentDocument: {
1162
- get() {
1163
- return getIframeEnv(this).$document$;
1164
- }
1165
- },
1166
- contentWindow: {
1167
- get() {
1168
- return getIframeEnv(this).$window$;
1169
- }
1170
- },
1171
- src: {
1172
- get() {
1173
- let src = getInstanceStateValue(this, 0);
1174
- if (src && src.startsWith("javascript:")) {
1175
- return src;
1176
- }
1177
- src = getIframeEnv(this).$location$.href;
1178
- return src.startsWith("about:") ? "" : src;
1179
- },
1180
- set(src) {
1181
- if (src) {
1182
- if (src.startsWith("javascript:")) {
1183
- setInstanceStateValue(this, 0, src);
1184
- } else if (!src.startsWith("about:")) {
1185
- let xhr = new XMLHttpRequest;
1186
- let xhrStatus;
1187
- let env = getIframeEnv(this);
1188
- env.$location$.href = src = resolveUrl(env, src, "iframe");
1189
- env.$isLoading$ = 1;
1190
- setInstanceStateValue(this, 1, void 0);
1191
- xhr.open("GET", src, false);
1192
- xhr.send();
1193
- xhrStatus = xhr.status;
1194
- if (xhrStatus > 199 && xhrStatus < 300) {
1195
- setter(this, [ "srcdoc" ], `<base href="${src}">` + xhr.responseText.replace(/<script>/g, '<script type="text/partytown">').replace(/<script /g, '<script type="text/partytown" ').replace(/text\/javascript/g, "text/partytown") + getPartytownScript());
1196
- sendToMain(true);
1197
- webWorkerCtx.$postMessage$([ 7, env.$winId$ ]);
1198
- } else {
1199
- setInstanceStateValue(this, 1, xhrStatus);
1200
- env.$isLoading$ = 0;
1201
- }
1202
- }
1203
- }
1204
- }
1205
- },
1206
- ...HTMLSrcElementDescriptorMap
1207
- };
1208
- definePrototypePropertyDescriptor(WorkerHTMLIFrameElement, HTMLIFrameDescriptorMap);
1209
- };
1210
- const getIframeEnv = iframe => {
1211
- const $winId$ = iframe[InstanceIdKey];
1212
- environments[$winId$] || createEnvironment({
1213
- $winId$: $winId$,
1214
- $parentWinId$: iframe[WinIdKey],
1215
- $url$: getter(iframe, [ "src" ]) || "about:blank"
1216
- }, true);
1217
- return environments[$winId$];
1218
- };
1219
- const patchSvgElement = WorkerSVGGraphicsElement => {
1220
- const getMatrix = (elm, methodName) => {
1221
- const {a: a, b: b, c: c, d: d, e: e, f: f} = callMethod(elm, [ methodName ], EMPTY_ARRAY);
1222
- return new DOMMatrixReadOnly([ a, b, c, d, e, f ]);
1223
- };
1224
- const SVGGraphicsElementDescriptorMap = {
1225
- ...WorkerSVGGraphicsElement,
1226
- getCTM: {
1227
- value: function() {
1228
- return getMatrix(this, "getCTM");
1229
- }
1230
- },
1231
- getScreenCTM: {
1232
- value: function() {
1233
- return getMatrix(this, "getScreenCTM");
1234
- }
1235
- }
1236
- };
1237
- definePrototypePropertyDescriptor(WorkerSVGGraphicsElement, SVGGraphicsElementDescriptorMap);
1238
- };
1239
- const createWindow = ($winId$, $parentWinId$, url, $visibilityState$, isIframeWindow, isDocumentImplementation) => {
1240
- let cstrInstanceId;
1241
- let cstrNodeName;
1242
- let cstrNamespace;
1243
- const WorkerBase = class {
1244
- constructor(winId, instanceId, applyPath, instanceData, namespace) {
1245
- this[WinIdKey] = winId || $winId$;
1246
- this[InstanceIdKey] = instanceId || cstrInstanceId || randomId();
1247
- this[ApplyPathKey] = applyPath || [];
1248
- this[InstanceDataKey] = instanceData || cstrNodeName;
1249
- this[NamespaceKey] = namespace || cstrNamespace;
1250
- this[InstanceStateKey] = {};
1251
- cstrInstanceId = cstrNodeName = cstrNamespace = void 0;
1252
- }
1253
- };
1254
- const WorkerLocation = defineConstructorName(class extends URL {
1255
- assign() {
1256
- logWorker("location.assign(), noop");
1257
- }
1258
- reload() {
1259
- logWorker("location.reload(), noop");
1260
- }
1261
- replace() {
1262
- logWorker("location.replace(), noop");
1263
- }
1264
- }, "Location");
1265
- const $location$ = new WorkerLocation(url);
1266
- const $isSameOrigin$ = $location$.origin === webWorkerCtx.$origin$ || "about:blank" === $location$.origin;
1267
- const $isTopWindow$ = $parentWinId$ === $winId$;
1268
- const env = {};
1269
- const getChildEnvs = () => {
1270
- let childEnv = [];
1271
- let envWinId;
1272
- let otherEnv;
1273
- for (envWinId in environments) {
1274
- otherEnv = environments[envWinId];
1275
- otherEnv.$parentWinId$ !== $winId$ || otherEnv.$isTopWindow$ || childEnv.push(otherEnv);
1276
- }
1277
- return childEnv;
1278
- };
1279
- const WorkerWindow = defineConstructorName(class extends WorkerBase {
1280
- constructor() {
1281
- super($winId$, $winId$);
1282
- let win = this;
1283
- let value;
1284
- let historyState;
1285
- let hasInitializedMedia = 0;
1286
- let initWindowMedia = () => {
1287
- if (!hasInitializedMedia) {
1288
- (() => {
1289
- if (!webWorkerCtx.$initWindowMedia$) {
1290
- self.$bridgeToMedia$ = [ getter, setter, callMethod, constructGlobal, definePrototypePropertyDescriptor, randomId, WinIdKey, InstanceIdKey, ApplyPathKey ];
1291
- webWorkerCtx.$importScripts$(partytownLibUrl("partytown-media.js?v=0.6.4"));
1292
- webWorkerCtx.$initWindowMedia$ = self.$bridgeFromMedia$;
1293
- delete self.$bridgeFromMedia$;
1294
- }
1295
- return webWorkerCtx.$initWindowMedia$;
1296
- })()(WorkerBase, WorkerEventTargetProxy, env, win, windowMediaConstructors);
1297
- hasInitializedMedia = 1;
1298
- }
1299
- };
1300
- let nodeCstrs = {};
1301
- let $createNode$ = (nodeName, instanceId, namespace) => {
1302
- htmlMedia.includes(nodeName) && initWindowMedia();
1303
- const NodeCstr = nodeCstrs[nodeName] ? nodeCstrs[nodeName] : nodeName.includes("-") ? nodeCstrs.UNKNOWN : nodeCstrs.I;
1304
- cstrInstanceId = instanceId;
1305
- cstrNodeName = nodeName;
1306
- cstrNamespace = namespace;
1307
- return new NodeCstr;
1308
- };
1309
- win.Window = WorkerWindow;
1310
- win.name = name + `${normalizedWinId($winId$)} (${$winId$})`;
1311
- createNodeCstr(win, env, WorkerBase);
1312
- createCSSStyleDeclarationCstr(win, WorkerBase, "CSSStyleDeclaration");
1313
- ((win, WorkerBase, cstrName) => {
1314
- win[cstrName] = defineConstructorName(class extends WorkerBase {
1315
- now() {
1316
- return performance.now();
1317
- }
1318
- }, cstrName);
1319
- })(win, WorkerBase, "Performance");
1320
- ((win, nodeCstrs) => {
1321
- const registry = new Map;
1322
- win.customElements = {
1323
- define(tagName, Cstr, opts) {
1324
- registry.set(tagName, Cstr);
1325
- nodeCstrs[tagName.toUpperCase()] = Cstr;
1326
- const ceData = [ Cstr.name, Cstr.observedAttributes ];
1327
- callMethod(win, [ "customElements", "define" ], [ tagName, ceData, opts ]);
1328
- },
1329
- get: tagName => registry.get(tagName) || callMethod(win, [ "customElements", "get" ], [ tagName ]),
1330
- whenDefined: tagName => registry.has(tagName) ? Promise.resolve() : callMethod(win, [ "customElements", "whenDefined" ], [ tagName ]),
1331
- upgrade: elm => callMethod(win, [ "customElements", "upgrade" ], [ elm ])
1332
- };
1333
- })(win, nodeCstrs);
1334
- webWorkerCtx.$interfaces$.map((([cstrName, superCstrName, members, interfaceType, nodeName]) => {
1335
- const SuperCstr = TrapConstructors[cstrName] ? WorkerTrapProxy : "EventTarget" === superCstrName ? WorkerEventTargetProxy : "Object" === superCstrName ? WorkerBase : win[superCstrName];
1336
- const Cstr = win[cstrName] = defineConstructorName(12 === interfaceType ? class extends WorkerBase {
1337
- constructor(...args) {
1338
- super();
1339
- constructGlobal(this, cstrName, args);
1340
- }
1341
- } : win[cstrName] || class extends SuperCstr {}, cstrName);
1342
- nodeName && (nodeCstrs[nodeName] = Cstr);
1343
- members.map((([memberName, memberType, staticValue]) => {
1344
- memberName in Cstr.prototype || memberName in SuperCstr.prototype || ("string" == typeof memberType ? definePrototypeProperty(Cstr, memberName, {
1345
- get() {
1346
- if (!hasInstanceStateValue(this, memberName)) {
1347
- const instanceId = this[InstanceIdKey];
1348
- const applyPath = [ ...this[ApplyPathKey], memberName ];
1349
- const PropCstr = win[memberType];
1350
- PropCstr && setInstanceStateValue(this, memberName, new PropCstr($winId$, instanceId, applyPath));
1351
- }
1352
- return getInstanceStateValue(this, memberName);
1353
- },
1354
- set(value) {
1355
- setInstanceStateValue(this, memberName, value);
1356
- }
1357
- }) : 5 === memberType ? definePrototypeValue(Cstr, memberName, (function(...args) {
1358
- return callMethod(this, [ memberName ], args);
1359
- })) : memberType > 0 && (void 0 !== staticValue ? definePrototypeValue(Cstr, memberName, staticValue) : definePrototypeProperty(Cstr, memberName, {
1360
- get() {
1361
- return getter(this, [ memberName ]);
1362
- },
1363
- set(value) {
1364
- return setter(this, [ memberName ], value);
1365
- }
1366
- })));
1367
- }));
1368
- }));
1369
- commaSplit("atob,btoa,crypto,indexedDB,setTimeout,setInterval,clearTimeout,clearInterval").map((globalName => {
1370
- delete WorkerWindow.prototype[globalName];
1371
- if (!(globalName in win)) {
1372
- value = self[globalName];
1373
- null != value && (win[globalName] = "function" != typeof value || value.toString().startsWith("class") ? value : value.bind(self));
1374
- }
1375
- }));
1376
- Object.getOwnPropertyNames(self).map((globalName => {
1377
- globalName in win || (win[globalName] = self[globalName]);
1378
- }));
1379
- windowMediaConstructors.map((cstrName => defineProperty(win, cstrName, {
1380
- get() {
1381
- initWindowMedia();
1382
- return win[cstrName];
1383
- }
1384
- })));
1385
- "trustedTypes" in self && (win.trustedTypes = self.trustedTypes);
1386
- patchElement(win.Element, win.HTMLElement);
1387
- patchDocument(win.Document, env, isDocumentImplementation);
1388
- (WorkerDocumentFragment => {
1389
- definePrototypeNodeType(WorkerDocumentFragment, 11);
1390
- cachedTreeProps(WorkerDocumentFragment, elementStructurePropNames);
1391
- })(win.DocumentFragment);
1392
- patchHTMLAnchorElement(win.HTMLAnchorElement, env);
1393
- (WorkerHTMLFormElement => {
1394
- definePrototypePropertyDescriptor(WorkerHTMLFormElement, {});
1395
- cachedProps(WorkerHTMLFormElement, "elements");
1396
- })(win.HTMLFormElement);
1397
- patchHTMLIFrameElement(win.HTMLIFrameElement);
1398
- patchHTMLScriptElement(win.HTMLScriptElement, env);
1399
- patchSvgElement(win.SVGGraphicsElement);
1400
- patchDocumentElementChild(win.HTMLHeadElement, env);
1401
- patchDocumentElementChild(win.HTMLBodyElement, env);
1402
- ((WorkerHTMLHtmlElement, env) => {
1403
- const DocumentElementDescriptorMap = {
1404
- parentElement: {
1405
- value: null
1406
- },
1407
- parentNode: {
1408
- get: () => env.$document$
1409
- }
1410
- };
1411
- definePrototypePropertyDescriptor(WorkerHTMLHtmlElement, DocumentElementDescriptorMap);
1412
- })(win.HTMLHtmlElement, env);
1413
- createCSSStyleSheetConstructor(win, "CSSStyleSheet");
1414
- definePrototypeNodeType(win.Comment, 8);
1415
- definePrototypeNodeType(win.DocumentType, 10);
1416
- Object.assign(env, {
1417
- $winId$: $winId$,
1418
- $parentWinId$: $parentWinId$,
1419
- $window$: new Proxy(win, {
1420
- get: (win, propName) => {
1421
- var _a;
1422
- if ("string" != typeof propName || isNaN(propName)) {
1423
- return (null === (_a = webWorkerCtx.$config$.mainWindowAccessors) || void 0 === _a ? void 0 : _a.includes(propName)) ? getter(this, [ propName ]) : win[propName];
1424
- }
1425
- {
1426
- let frame = getChildEnvs()[propName];
1427
- return frame ? frame.$window$ : void 0;
1428
- }
1429
- },
1430
- has: () => true
1431
- }),
1432
- $document$: $createNode$("#document", $winId$ + ".d"),
1433
- $documentElement$: $createNode$("HTML", $winId$ + ".e"),
1434
- $head$: $createNode$("HEAD", $winId$ + ".h"),
1435
- $body$: $createNode$("BODY", $winId$ + ".b"),
1436
- $location$: $location$,
1437
- $visibilityState$: $visibilityState$,
1438
- $isSameOrigin$: $isSameOrigin$,
1439
- $isTopWindow$: $isTopWindow$,
1440
- $createNode$: $createNode$
1441
- });
1442
- win.requestAnimationFrame = cb => setTimeout((() => cb(performance.now())), 9);
1443
- win.cancelAnimationFrame = id => clearTimeout(id);
1444
- win.requestIdleCallback = (cb, start) => {
1445
- start = Date.now();
1446
- return setTimeout((() => cb({
1447
- didTimeout: false,
1448
- timeRemaining: () => Math.max(0, 50 - (Date.now() - start))
1449
- })), 1);
1450
- };
1451
- win.cancelIdleCallback = id => clearTimeout(id);
1452
- addStorageApi(win, "localStorage", webWorkerlocalStorage, $isSameOrigin$, env);
1453
- addStorageApi(win, "sessionStorage", webWorkerSessionStorage, $isSameOrigin$, env);
1454
- $isSameOrigin$ || (win.indexeddb = void 0);
1455
- if (isIframeWindow) {
1456
- historyState = {};
1457
- win.history = {
1458
- pushState(stateObj) {
1459
- historyState = stateObj;
1460
- },
1461
- replaceState(stateObj) {
1462
- historyState = stateObj;
1463
- },
1464
- get state() {
1465
- return historyState;
1466
- },
1467
- length: 0
1468
- };
1469
- win.indexeddb = void 0;
1470
- } else {
1471
- const originalPushState = win.history.pushState.bind(win.history);
1472
- const originalReplaceState = win.history.replaceState.bind(win.history);
1473
- win.history.pushState = (stateObj, _, newUrl) => {
1474
- false !== env.$propagateHistoryChange$ && originalPushState(stateObj, _, newUrl);
1475
- };
1476
- win.history.replaceState = (stateObj, _, newUrl) => {
1477
- false !== env.$propagateHistoryChange$ && originalReplaceState(stateObj, _, newUrl);
1478
- };
1479
- }
1480
- win.Worker = void 0;
1481
- }
1482
- addEventListener(...args) {
1483
- "load" === args[0] ? env.$runWindowLoadEvent$ && setTimeout((() => args[1]({
1484
- type: "load"
1485
- }))) : callMethod(this, [ "addEventListener" ], args, 2);
1486
- }
1487
- get body() {
1488
- return env.$body$;
1489
- }
1490
- get document() {
1491
- return env.$document$;
1492
- }
1493
- get documentElement() {
1494
- return env.$documentElement$;
1495
- }
1496
- fetch(input, init) {
1497
- input = "string" == typeof input || input instanceof URL ? String(input) : input.url;
1498
- return fetch(resolveUrl(env, input, "fetch"), init);
1499
- }
1500
- get frames() {
1501
- return env.$window$;
1502
- }
1503
- get frameElement() {
1504
- return $isTopWindow$ ? null : getOrCreateNodeInstance($parentWinId$, $winId$, "IFRAME");
1505
- }
1506
- get globalThis() {
1507
- return env.$window$;
1508
- }
1509
- get head() {
1510
- return env.$head$;
1511
- }
1512
- get length() {
1513
- return getChildEnvs().length;
1514
- }
1515
- get location() {
1516
- return $location$;
1517
- }
1518
- set location(loc) {
1519
- $location$.href = loc + "";
1520
- }
1521
- get Image() {
1522
- return createImageConstructor(env);
1523
- }
1524
- get navigator() {
1525
- return (env => {
1526
- let key;
1527
- let nav = {
1528
- sendBeacon: (url, body) => {
1529
- if (webWorkerCtx.$config$.logSendBeaconRequests) {
1530
- try {
1531
- logWorker(`sendBeacon: ${resolveUrl(env, url, null)}${body ? ", data: " + JSON.stringify(body) : ""}`);
1532
- } catch (e) {
1533
- console.error(e);
1534
- }
1535
- }
1536
- try {
1537
- fetch(resolveUrl(env, url, null), {
1538
- method: "POST",
1539
- body: body,
1540
- mode: "no-cors",
1541
- keepalive: true
1542
- });
1543
- return true;
1544
- } catch (e) {
1545
- console.error(e);
1546
- return false;
1547
- }
1548
- }
1549
- };
1550
- for (key in navigator) {
1551
- nav[key] = navigator[key];
1552
- }
1553
- return nav;
1554
- })(env);
1555
- }
1556
- get origin() {
1557
- return $location$.origin;
1558
- }
1559
- set origin(_) {}
1560
- get parent() {
1561
- for (let envWinId in environments) {
1562
- if (environments[envWinId].$winId$ === $parentWinId$) {
1563
- return environments[envWinId].$window$;
1564
- }
1565
- }
1566
- return env.$window$;
1567
- }
1568
- postMessage(...args) {
1569
- if (environments[args[0]]) {
1570
- len(postMessages) > 50 && postMessages.splice(0, 5);
1571
- postMessages.push({
1572
- $winId$: args[0],
1573
- $data$: JSON.stringify(args[1])
1574
- });
1575
- args = args.slice(1);
1576
- }
1577
- callMethod(this, [ "postMessage" ], args, 3);
1578
- }
1579
- get self() {
1580
- return env.$window$;
1581
- }
1582
- get top() {
1583
- for (let envWinId in environments) {
1584
- if (environments[envWinId].$isTopWindow$) {
1585
- return environments[envWinId].$window$;
1586
- }
1587
- }
1588
- return env.$window$;
1589
- }
1590
- get window() {
1591
- return env.$window$;
1592
- }
1593
- get XMLHttpRequest() {
1594
- const Xhr = XMLHttpRequest;
1595
- const str = String(Xhr);
1596
- const ExtendedXhr = defineConstructorName(class extends Xhr {
1597
- open(...args) {
1598
- args[1] = resolveUrl(env, args[1], "xhr");
1599
- super.open(...args);
1600
- }
1601
- set withCredentials(_) {}
1602
- toString() {
1603
- return str;
1604
- }
1605
- }, getConstructorName(Xhr));
1606
- ExtendedXhr.prototype.constructor.toString = () => str;
1607
- return ExtendedXhr;
1608
- }
1609
- }, "Window");
1610
- const WorkerTrapProxy = class extends WorkerBase {
1611
- constructor(winId, instanceId, applyPath, nodeName) {
1612
- super(winId, instanceId, applyPath, nodeName);
1613
- return new Proxy(this, {
1614
- get: (instance, propName) => getter(instance, [ propName ]),
1615
- set(instance, propName, propValue) {
1616
- setter(instance, [ propName ], propValue);
1617
- return true;
1618
- }
1619
- });
1620
- }
1621
- };
1622
- const WorkerEventTargetProxy = class extends WorkerBase {};
1623
- eventTargetMethods.map((methodName => WorkerEventTargetProxy.prototype[methodName] = function(...args) {
1624
- return callMethod(this, [ methodName ], args, 2);
1625
- }));
1626
- cachedProps(WorkerWindow, "devicePixelRatio");
1627
- cachedDimensionProps(WorkerWindow);
1628
- cachedDimensionMethods(WorkerWindow, [ "getComputedStyle" ]);
1629
- new WorkerWindow;
1630
- return env;
1631
- };
1632
- const TrapConstructors = {
1633
- DOMStringMap: 1,
1634
- NamedNodeMap: 1
1635
- };
1636
- const createEnvironment = ({$winId$: $winId$, $parentWinId$: $parentWinId$, $url$: $url$, $visibilityState$: $visibilityState$}, isIframeWindow, isDocumentImplementation) => {
1637
- if (!environments[$winId$]) {
1638
- environments[$winId$] = createWindow($winId$, $parentWinId$, $url$, $visibilityState$, isIframeWindow, isDocumentImplementation);
1639
- {
1640
- const winType = $winId$ === $parentWinId$ ? "top" : "iframe";
1641
- logWorker(`Created ${winType} window ${normalizedWinId($winId$)} environment`, $winId$);
1642
- }
1643
- }
1644
- webWorkerCtx.$postMessage$([ 7, $winId$ ]);
1645
- return environments[$winId$];
1646
- };
1647
- const queuedEvents = [];
1648
- const receiveMessageFromSandboxToWorker = ev => {
1649
- const msg = ev.data;
1650
- const msgType = msg[0];
1651
- const msgValue = msg[1];
1652
- if (webWorkerCtx.$isInitialized$) {
1653
- if (7 === msgType) {
1654
- (async initScript => {
1655
- let winId = initScript.$winId$;
1656
- let instanceId = initScript.$instanceId$;
1657
- let instance = getOrCreateNodeInstance(winId, instanceId, "SCRIPT");
1658
- let scriptContent = initScript.$content$;
1659
- let scriptSrc = initScript.$url$;
1660
- let scriptOrgSrc = initScript.$orgUrl$;
1661
- let errorMsg = "";
1662
- let env = environments[winId];
1663
- let rsp;
1664
- if (scriptSrc) {
1665
- try {
1666
- scriptSrc = resolveToUrl(env, scriptSrc, "script") + "";
1667
- setInstanceStateValue(instance, 4, scriptSrc);
1668
- webWorkerCtx.$config$.logScriptExecution && logWorker(`Execute script src: ${scriptOrgSrc}`, winId);
1669
- rsp = await fetch(scriptSrc);
1670
- if (rsp.ok) {
1671
- scriptContent = await rsp.text();
1672
- env.$currentScriptId$ = instanceId;
1673
- run(env, scriptContent, scriptOrgSrc || scriptSrc);
1674
- runStateLoadHandlers(instance, "load");
1675
- } else {
1676
- errorMsg = rsp.statusText;
1677
- runStateLoadHandlers(instance, "error");
1678
- }
1679
- } catch (urlError) {
1680
- console.error(urlError);
1681
- errorMsg = String(urlError.stack || urlError);
1682
- runStateLoadHandlers(instance, "error");
1683
- }
1684
- } else {
1685
- scriptContent && (errorMsg = runScriptContent(env, instanceId, scriptContent, winId, errorMsg));
1686
- }
1687
- env.$currentScriptId$ = "";
1688
- webWorkerCtx.$postMessage$([ 6, winId, instanceId, errorMsg ]);
1689
- })(msgValue);
1690
- } else if (9 === msgType) {
1691
- (({$winId$: $winId$, $instanceId$: $instanceId$, $refId$: $refId$, $thisArg$: $thisArg$, $args$: $args$}) => {
1692
- if (webWorkerRefsByRefId[$refId$]) {
1693
- try {
1694
- webWorkerRefsByRefId[$refId$].apply(deserializeFromMain($winId$, $instanceId$, [], $thisArg$), deserializeFromMain($winId$, $instanceId$, [], $args$));
1695
- } catch (e) {
1696
- console.error(e);
1697
- }
1698
- }
1699
- })(msgValue);
1700
- } else if (10 === msgType) {
1701
- (({$winId$: $winId$, $forward$: $forward$, $args$: $args$}) => {
1702
- try {
1703
- let target = environments[$winId$].$window$;
1704
- let i = 0;
1705
- let l = len($forward$);
1706
- for (;i < l; i++) {
1707
- i + 1 < l ? target = target[$forward$[i]] : target[$forward$[i]].apply(target, deserializeFromMain(null, $winId$, [], $args$));
1708
- }
1709
- } catch (e) {
1710
- console.error(e);
1711
- }
1712
- })(msgValue);
1713
- } else if (5 === msgType) {
1714
- createEnvironment(msgValue);
1715
- } else if (8 === msgType) {
1716
- if (1 !== environments[msgValue].$isInitialized$) {
1717
- const winId = msgValue;
1718
- const env = environments[winId];
1719
- const winType = env.$winId$ === env.$parentWinId$ ? "top" : "iframe";
1720
- logWorker(`Initialized ${winType} window ${normalizedWinId(winId)} environment 🎉`, winId);
1721
- }
1722
- environments[msgValue].$isInitialized$ = 1;
1723
- environments[msgValue].$isLoading$ = 0;
1724
- } else if (14 === msgType) {
1725
- environments[msgValue].$visibilityState$ = msg[2];
1726
- } else if (13 === msgType) {
1727
- const $winId$ = msgValue.$winId$;
1728
- const env = environments[$winId$];
1729
- env.$location$.href = msgValue.url;
1730
- !function($winId$, env, data) {
1731
- const history = env.$window$.history;
1732
- switch (data.type) {
1733
- case 0:
1734
- env.$propagateHistoryChange$ = false;
1735
- try {
1736
- history.pushState(data.state, "", data.newUrl);
1737
- } catch (e) {}
1738
- env.$propagateHistoryChange$ = true;
1739
- break;
1740
-
1741
- case 1:
1742
- env.$propagateHistoryChange$ = false;
1743
- try {
1744
- history.replaceState(data.state, "", data.newUrl);
1745
- } catch (e) {}
1746
- env.$propagateHistoryChange$ = true;
1747
- }
1748
- }(msgValue.$winId$, env, msgValue);
1749
- } else {
1750
- 15 === msgType && ((_type, winId, instanceId, callbackName, args) => {
1751
- const elm = getOrCreateNodeInstance(winId, instanceId);
1752
- elm && "function" == typeof elm[callbackName] && elm[callbackName].apply(elm, args);
1753
- })(...msg);
1754
- }
1755
- } else if (1 === msgType) {
1756
- (initWebWorkerData => {
1757
- const config = webWorkerCtx.$config$ = JSON.parse(initWebWorkerData.$config$);
1758
- const locOrigin = initWebWorkerData.$origin$;
1759
- webWorkerCtx.$importScripts$ = importScripts.bind(self);
1760
- webWorkerCtx.$interfaces$ = initWebWorkerData.$interfaces$;
1761
- webWorkerCtx.$libPath$ = initWebWorkerData.$libPath$;
1762
- webWorkerCtx.$origin$ = locOrigin;
1763
- webWorkerCtx.$postMessage$ = postMessage.bind(self);
1764
- webWorkerCtx.$sharedDataBuffer$ = initWebWorkerData.$sharedDataBuffer$;
1765
- webWorkerlocalStorage.set(locOrigin, initWebWorkerData.$localStorage$);
1766
- webWorkerSessionStorage.set(locOrigin, initWebWorkerData.$sessionStorage$);
1767
- self.importScripts = void 0;
1768
- delete self.postMessage;
1769
- delete self.WorkerGlobalScope;
1770
- commaSplit("resolveUrl,get,set,apply").map((configName => {
1771
- config[configName] && (config[configName] = new Function("return " + config[configName])());
1772
- }));
1773
- })(msgValue);
1774
- webWorkerCtx.$postMessage$([ 2 ]);
1775
- } else if (3 === msgType) {
1776
- webWorkerCtx.$interfaces$ = [ ...webWorkerCtx.$interfaces$, ...msgValue ];
1777
- webWorkerCtx.$isInitialized$ = 1;
1778
- logWorker("Initialized web worker");
1779
- webWorkerCtx.$postMessage$([ 4 ]);
1780
- queuedEvents.length && logWorker(`Queued ready messages: ${queuedEvents.length}`);
1781
- [ ...queuedEvents ].map(receiveMessageFromSandboxToWorker);
1782
- queuedEvents.length = 0;
1783
- } else {
1784
- queuedEvents.push(ev);
1785
- }
1786
- };
1787
- self.onmessage = receiveMessageFromSandboxToWorker;
1788
- postMessage([ 0 ]);
1789
- })(self);