one 1.2.46 → 1.2.48

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 (818) hide show
  1. package/dist/cjs/Root.js +6 -1
  2. package/dist/cjs/Root.js.map +1 -1
  3. package/dist/cjs/Root.native.js.map +1 -1
  4. package/dist/cjs/babel-plugins/one-router-metro.js +4 -1
  5. package/dist/cjs/babel-plugins/one-router-metro.js.map +1 -1
  6. package/dist/cjs/babel-plugins/one-router-metro.native.js.map +1 -1
  7. package/dist/cjs/babel-plugins/remove-server-code.js +3 -1
  8. package/dist/cjs/babel-plugins/remove-server-code.js.map +1 -1
  9. package/dist/cjs/babel-plugins/remove-server-code.native.js.map +1 -1
  10. package/dist/cjs/cli/build.js +31 -8
  11. package/dist/cjs/cli/build.js.map +1 -1
  12. package/dist/cjs/cli/build.native.js.map +1 -1
  13. package/dist/cjs/cli/buildPage.cjs +16 -7
  14. package/dist/cjs/cli/buildPage.js +26 -7
  15. package/dist/cjs/cli/buildPage.js.map +1 -1
  16. package/dist/cjs/cli/buildPage.native.js +17 -8
  17. package/dist/cjs/cli/buildPage.native.js.map +1 -1
  18. package/dist/cjs/cli/generateRoutes.js +3 -1
  19. package/dist/cjs/cli/generateRoutes.js.map +1 -1
  20. package/dist/cjs/cli/generateRoutes.native.js.map +1 -1
  21. package/dist/cjs/cli/generateSitemap.js.map +1 -1
  22. package/dist/cjs/cli/generateSitemap.native.js.map +1 -1
  23. package/dist/cjs/cli/generateSitemap.test.js +14 -4
  24. package/dist/cjs/cli/generateSitemap.test.js.map +1 -1
  25. package/dist/cjs/cli/generateSitemap.test.native.js.map +1 -1
  26. package/dist/cjs/cli/main.js +4 -2
  27. package/dist/cjs/cli/main.js.map +1 -1
  28. package/dist/cjs/cli/main.native.js.map +1 -1
  29. package/dist/cjs/cli/prebuild.js.map +1 -1
  30. package/dist/cjs/cli/prebuild.native.js.map +1 -1
  31. package/dist/cjs/clientLoaderResolver.js.map +1 -1
  32. package/dist/cjs/clientLoaderResolver.native.js.map +1 -1
  33. package/dist/cjs/config.js +3 -1
  34. package/dist/cjs/config.js.map +1 -1
  35. package/dist/cjs/config.native.js.map +1 -1
  36. package/dist/cjs/constants.js.map +1 -1
  37. package/dist/cjs/constants.native.js.map +1 -1
  38. package/dist/cjs/createApp.js +9 -1
  39. package/dist/cjs/createApp.js.map +1 -1
  40. package/dist/cjs/createHandleRequest.js +9 -3
  41. package/dist/cjs/createHandleRequest.js.map +1 -1
  42. package/dist/cjs/createHandleRequest.native.js.map +1 -1
  43. package/dist/cjs/fork/__tests__/getPathFromState.test.js +90 -88
  44. package/dist/cjs/fork/__tests__/getPathFromState.test.js.map +1 -1
  45. package/dist/cjs/fork/__tests__/getPathFromState.test.native.js.map +1 -1
  46. package/dist/cjs/fork/__tests__/getStateFromPath.test.js +163 -86
  47. package/dist/cjs/fork/__tests__/getStateFromPath.test.js.map +1 -1
  48. package/dist/cjs/fork/__tests__/getStateFromPath.test.native.js.map +1 -1
  49. package/dist/cjs/fork/_shared.js.map +1 -1
  50. package/dist/cjs/fork/_shared.native.js.map +1 -1
  51. package/dist/cjs/fork/extractPathFromURL.js.map +1 -1
  52. package/dist/cjs/fork/extractPathFromURL.native.js.map +1 -1
  53. package/dist/cjs/fork/getPathFromState-mods.js +4 -1
  54. package/dist/cjs/fork/getPathFromState-mods.js.map +1 -1
  55. package/dist/cjs/fork/getPathFromState-mods.native.js.map +1 -1
  56. package/dist/cjs/fork/getPathFromState.js +3 -1
  57. package/dist/cjs/fork/getPathFromState.js.map +1 -1
  58. package/dist/cjs/fork/getPathFromState.native.js.map +1 -1
  59. package/dist/cjs/fork/getStateFromPath-mods.js.map +1 -1
  60. package/dist/cjs/fork/getStateFromPath-mods.native.js.map +1 -1
  61. package/dist/cjs/fork/getStateFromPath.js +7 -1
  62. package/dist/cjs/fork/getStateFromPath.js.map +1 -1
  63. package/dist/cjs/fork/getStateFromPath.native.js.map +1 -1
  64. package/dist/cjs/fork/getStateFromPath.test.js +21 -8
  65. package/dist/cjs/fork/getStateFromPath.test.js.map +1 -1
  66. package/dist/cjs/fork/getStateFromPath.test.native.js.map +1 -1
  67. package/dist/cjs/fork/useBackButton.js.map +1 -1
  68. package/dist/cjs/fork/useDocumentTitle.js +4 -1
  69. package/dist/cjs/fork/useDocumentTitle.js.map +1 -1
  70. package/dist/cjs/fork/useLinking.js +4 -1
  71. package/dist/cjs/fork/useLinking.js.map +1 -1
  72. package/dist/cjs/fork/validatePathConfig.js.map +1 -1
  73. package/dist/cjs/fork/validatePathConfig.native.js.map +1 -1
  74. package/dist/cjs/hooks.js.map +1 -1
  75. package/dist/cjs/hooks.native.js.map +1 -1
  76. package/dist/cjs/index.js.map +1 -1
  77. package/dist/cjs/layouts/Tabs.js.map +1 -1
  78. package/dist/cjs/layouts/Tabs.native.js.map +1 -1
  79. package/dist/cjs/layouts/withLayoutContext.js +10 -8
  80. package/dist/cjs/layouts/withLayoutContext.js.map +1 -1
  81. package/dist/cjs/layouts/withLayoutContext.native.js.map +1 -1
  82. package/dist/cjs/link/Link.js.map +1 -1
  83. package/dist/cjs/link/Link.native.js.map +1 -1
  84. package/dist/cjs/link/linking.js +3 -1
  85. package/dist/cjs/link/linking.js.map +1 -1
  86. package/dist/cjs/link/linking.native.js.map +1 -1
  87. package/dist/cjs/link/useLinkTo.js.map +1 -1
  88. package/dist/cjs/link/useLinkTo.native.js.map +1 -1
  89. package/dist/cjs/link/useLoadedNavigation.js.map +1 -1
  90. package/dist/cjs/link/useLoadedNavigation.native.js.map +1 -1
  91. package/dist/cjs/metro-config/getViteMetroPluginOptions.cjs +6 -8
  92. package/dist/cjs/metro-config/getViteMetroPluginOptions.js +8 -10
  93. package/dist/cjs/metro-config/getViteMetroPluginOptions.js.map +1 -1
  94. package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js +9 -11
  95. package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
  96. package/dist/cjs/polyfills-mobile.cjs +3 -1
  97. package/dist/cjs/polyfills-mobile.js +2 -1
  98. package/dist/cjs/polyfills-mobile.js.map +2 -2
  99. package/dist/cjs/polyfills-mobile.native.js +8 -4
  100. package/dist/cjs/polyfills-mobile.native.js.map +1 -1
  101. package/dist/cjs/router/Route.js.map +1 -1
  102. package/dist/cjs/router/Route.native.js.map +1 -1
  103. package/dist/cjs/router/RouteInfoContext.js +7 -1
  104. package/dist/cjs/router/RouteInfoContext.js.map +1 -1
  105. package/dist/cjs/router/RouteInfoContext.native.js.map +1 -1
  106. package/dist/cjs/router/filterRootHTML.js.map +1 -1
  107. package/dist/cjs/router/filterRootHTML.native.js.map +1 -1
  108. package/dist/cjs/router/getLinkingConfig.js.map +1 -1
  109. package/dist/cjs/router/getLinkingConfig.native.js.map +1 -1
  110. package/dist/cjs/router/getNormalizedStatePath.js.map +1 -1
  111. package/dist/cjs/router/getNormalizedStatePath.native.js.map +1 -1
  112. package/dist/cjs/router/getRoutes.js +3 -1
  113. package/dist/cjs/router/getRoutes.js.map +1 -1
  114. package/dist/cjs/router/getRoutes.native.js.map +1 -1
  115. package/dist/cjs/router/linkingConfig.js.map +1 -1
  116. package/dist/cjs/router/linkingConfig.native.js.map +1 -1
  117. package/dist/cjs/router/matchers.cjs +1 -1
  118. package/dist/cjs/router/matchers.js +1 -1
  119. package/dist/cjs/router/matchers.js.map +1 -1
  120. package/dist/cjs/router/matchers.native.js +1 -1
  121. package/dist/cjs/router/matchers.native.js.map +1 -1
  122. package/dist/cjs/router/matchers.test.js +6 -2
  123. package/dist/cjs/router/matchers.test.js.map +1 -1
  124. package/dist/cjs/router/matchers.test.native.js.map +1 -1
  125. package/dist/cjs/router/router.cjs +3 -1
  126. package/dist/cjs/router/router.js +15 -4
  127. package/dist/cjs/router/router.js.map +1 -1
  128. package/dist/cjs/router/router.native.js +7 -3
  129. package/dist/cjs/router/router.native.js.map +1 -1
  130. package/dist/cjs/router/useNavigation.js.map +1 -1
  131. package/dist/cjs/router/useNavigation.native.js.map +1 -1
  132. package/dist/cjs/router/useScreens.js +13 -11
  133. package/dist/cjs/router/useScreens.js.map +1 -1
  134. package/dist/cjs/router/useScreens.native.js.map +1 -1
  135. package/dist/cjs/router/useViteRoutes.js.map +1 -1
  136. package/dist/cjs/router/useViteRoutes.native.js.map +1 -1
  137. package/dist/cjs/router/utils/getNavigateAction.js.map +1 -1
  138. package/dist/cjs/router/utils/getNavigateAction.native.js.map +1 -1
  139. package/dist/cjs/server/createRoutesManifest.js.map +1 -1
  140. package/dist/cjs/server/createRoutesManifest.native.js.map +1 -1
  141. package/dist/cjs/server/getServerManifest.js +3 -1
  142. package/dist/cjs/server/getServerManifest.js.map +1 -1
  143. package/dist/cjs/server/getServerManifest.native.js.map +1 -1
  144. package/dist/cjs/server/oneServe.cjs +10 -2
  145. package/dist/cjs/server/oneServe.js +21 -3
  146. package/dist/cjs/server/oneServe.js.map +1 -1
  147. package/dist/cjs/server/oneServe.native.js +10 -3
  148. package/dist/cjs/server/oneServe.native.js.map +1 -1
  149. package/dist/cjs/server/setupBuildOptions.js.map +1 -1
  150. package/dist/cjs/server/setupBuildOptions.native.js.map +1 -1
  151. package/dist/cjs/server/staticHtmlFetcher.js.map +1 -1
  152. package/dist/cjs/server/staticHtmlFetcher.native.js.map +1 -1
  153. package/dist/cjs/server-render.js.map +1 -1
  154. package/dist/cjs/server-render.native.js.map +1 -1
  155. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.js +14 -2
  156. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.js.map +1 -1
  157. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  158. package/dist/cjs/typed-routes/injectRouteHelpers.js +4 -1
  159. package/dist/cjs/typed-routes/injectRouteHelpers.js.map +1 -1
  160. package/dist/cjs/typed-routes/injectRouteHelpers.native.js.map +1 -1
  161. package/dist/cjs/ui/Slot.js.map +1 -1
  162. package/dist/cjs/ui/Slot.native.js.map +1 -1
  163. package/dist/cjs/ui/TabContext.js +3 -1
  164. package/dist/cjs/ui/TabContext.js.map +1 -1
  165. package/dist/cjs/ui/TabContext.native.js.map +1 -1
  166. package/dist/cjs/ui/TabRouter.js.map +1 -1
  167. package/dist/cjs/ui/TabRouter.native.js.map +1 -1
  168. package/dist/cjs/ui/TabTrigger.js +17 -2
  169. package/dist/cjs/ui/TabTrigger.js.map +1 -1
  170. package/dist/cjs/ui/TabTrigger.native.js.map +1 -1
  171. package/dist/cjs/ui/Tabs.js +5 -1
  172. package/dist/cjs/ui/Tabs.js.map +1 -1
  173. package/dist/cjs/ui/Tabs.native.js.map +1 -1
  174. package/dist/cjs/ui/common.js +3 -1
  175. package/dist/cjs/ui/common.js.map +1 -1
  176. package/dist/cjs/ui/common.native.js.map +1 -1
  177. package/dist/cjs/useLoader.js +4 -1
  178. package/dist/cjs/useLoader.js.map +1 -1
  179. package/dist/cjs/useLoader.native.js.map +1 -1
  180. package/dist/cjs/utils/cleanUrl.js.map +1 -1
  181. package/dist/cjs/utils/cleanUrl.native.js.map +1 -1
  182. package/dist/cjs/utils/url.js +3 -1
  183. package/dist/cjs/utils/url.js.map +1 -1
  184. package/dist/cjs/utils/url.native.js.map +1 -1
  185. package/dist/cjs/vercel/build/buildVercelOutputDirectory.js +29 -10
  186. package/dist/cjs/vercel/build/buildVercelOutputDirectory.js.map +1 -1
  187. package/dist/cjs/vercel/build/buildVercelOutputDirectory.native.js.map +1 -1
  188. package/dist/cjs/vercel/build/generate/createApiServerlessFunction.js +11 -3
  189. package/dist/cjs/vercel/build/generate/createApiServerlessFunction.js.map +1 -1
  190. package/dist/cjs/vercel/build/generate/createApiServerlessFunction.native.js.map +1 -1
  191. package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.js +9 -2
  192. package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.js.map +1 -1
  193. package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.native.js.map +1 -1
  194. package/dist/cjs/vercel/build/getPathFromRoute.js +4 -1
  195. package/dist/cjs/vercel/build/getPathFromRoute.js.map +1 -1
  196. package/dist/cjs/vercel/build/getPathFromRoute.native.js.map +1 -1
  197. package/dist/cjs/views/Navigator.js +16 -8
  198. package/dist/cjs/views/Navigator.js.map +1 -1
  199. package/dist/cjs/views/Navigator.native.js.map +1 -1
  200. package/dist/cjs/views/RootErrorBoundary.js +4 -2
  201. package/dist/cjs/views/RootErrorBoundary.js.map +1 -1
  202. package/dist/cjs/views/RootErrorBoundary.native.js.map +1 -1
  203. package/dist/cjs/views/Screen.js +4 -1
  204. package/dist/cjs/views/Screen.js.map +1 -1
  205. package/dist/cjs/views/Screen.native.js.map +1 -1
  206. package/dist/cjs/vite/loadConfig.js +6 -2
  207. package/dist/cjs/vite/loadConfig.js.map +1 -1
  208. package/dist/cjs/vite/loadConfig.native.js.map +1 -1
  209. package/dist/cjs/vite/one-server-only.js +3 -1
  210. package/dist/cjs/vite/one-server-only.js.map +1 -1
  211. package/dist/cjs/vite/one.js +9 -3
  212. package/dist/cjs/vite/one.js.map +1 -1
  213. package/dist/cjs/vite/one.native.js.map +1 -1
  214. package/dist/cjs/vite/plugins/SSRCSSPlugin.js +5 -1
  215. package/dist/cjs/vite/plugins/SSRCSSPlugin.js.map +1 -1
  216. package/dist/cjs/vite/plugins/SSRCSSPlugin.native.js.map +1 -1
  217. package/dist/cjs/vite/plugins/clientTreeShakePlugin.js +8 -2
  218. package/dist/cjs/vite/plugins/clientTreeShakePlugin.js.map +1 -1
  219. package/dist/cjs/vite/plugins/clientTreeShakePlugin.native.js.map +1 -1
  220. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +1 -0
  221. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js +13 -4
  222. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
  223. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +1 -0
  224. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  225. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
  226. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  227. package/dist/cjs/vite/plugins/removeReactNativeWebAnimatedPlugin.js.map +1 -1
  228. package/dist/cjs/vite/plugins/removeReactNativeWebAnimatedPlugin.native.js.map +1 -1
  229. package/dist/cjs/vite/plugins/virtualEntryPlugin.cjs +7 -3
  230. package/dist/cjs/vite/plugins/virtualEntryPlugin.js +16 -5
  231. package/dist/cjs/vite/plugins/virtualEntryPlugin.js.map +1 -1
  232. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js +5 -2
  233. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  234. package/dist/cjs/vite/replaceLoader.js +4 -1
  235. package/dist/cjs/vite/replaceLoader.js.map +1 -1
  236. package/dist/cjs/vite/replaceLoader.native.js.map +1 -1
  237. package/dist/cjs/vite/resolveResponse.js.map +1 -1
  238. package/dist/cjs/vite/resolveResponse.native.js.map +1 -1
  239. package/dist/cjs/zero/subscribeToQuery.js.map +1 -1
  240. package/dist/cjs/zero/subscribeToQuery.native.js.map +1 -1
  241. package/dist/cjs/zero/useQueryZero.js +3 -1
  242. package/dist/cjs/zero/useQueryZero.js.map +1 -1
  243. package/dist/cjs/zero/useQueryZero.native.js.map +1 -1
  244. package/dist/esm/Root.js +6 -1
  245. package/dist/esm/Root.js.map +1 -1
  246. package/dist/esm/Root.mjs.map +1 -1
  247. package/dist/esm/Root.native.js.map +1 -1
  248. package/dist/esm/babel-plugins/one-router-metro.js +4 -1
  249. package/dist/esm/babel-plugins/one-router-metro.js.map +1 -1
  250. package/dist/esm/babel-plugins/one-router-metro.mjs.map +1 -1
  251. package/dist/esm/babel-plugins/one-router-metro.native.js.map +1 -1
  252. package/dist/esm/babel-plugins/remove-server-code.js +7 -2
  253. package/dist/esm/babel-plugins/remove-server-code.js.map +1 -1
  254. package/dist/esm/babel-plugins/remove-server-code.mjs.map +1 -1
  255. package/dist/esm/babel-plugins/remove-server-code.native.js.map +1 -1
  256. package/dist/esm/cli/build.js +31 -8
  257. package/dist/esm/cli/build.js.map +1 -1
  258. package/dist/esm/cli/build.mjs.map +1 -1
  259. package/dist/esm/cli/build.native.js.map +1 -1
  260. package/dist/esm/cli/buildPage.js +26 -6
  261. package/dist/esm/cli/buildPage.js.map +1 -1
  262. package/dist/esm/cli/buildPage.mjs +16 -7
  263. package/dist/esm/cli/buildPage.mjs.map +1 -1
  264. package/dist/esm/cli/buildPage.native.js +17 -8
  265. package/dist/esm/cli/buildPage.native.js.map +1 -1
  266. package/dist/esm/cli/generateRoutes.js +3 -1
  267. package/dist/esm/cli/generateRoutes.js.map +1 -1
  268. package/dist/esm/cli/generateRoutes.mjs.map +1 -1
  269. package/dist/esm/cli/generateRoutes.native.js.map +1 -1
  270. package/dist/esm/cli/generateSitemap.js.map +1 -1
  271. package/dist/esm/cli/generateSitemap.mjs.map +1 -1
  272. package/dist/esm/cli/generateSitemap.native.js.map +1 -1
  273. package/dist/esm/cli/generateSitemap.test.js +14 -4
  274. package/dist/esm/cli/generateSitemap.test.js.map +1 -1
  275. package/dist/esm/cli/generateSitemap.test.mjs.map +1 -1
  276. package/dist/esm/cli/generateSitemap.test.native.js.map +1 -1
  277. package/dist/esm/cli/main.js +4 -2
  278. package/dist/esm/cli/main.js.map +1 -1
  279. package/dist/esm/cli/main.mjs.map +1 -1
  280. package/dist/esm/cli/main.native.js.map +1 -1
  281. package/dist/esm/cli/prebuild.js.map +1 -1
  282. package/dist/esm/cli/prebuild.mjs.map +1 -1
  283. package/dist/esm/cli/prebuild.native.js.map +1 -1
  284. package/dist/esm/clientLoaderResolver.js.map +1 -1
  285. package/dist/esm/clientLoaderResolver.mjs.map +1 -1
  286. package/dist/esm/clientLoaderResolver.native.js.map +1 -1
  287. package/dist/esm/config.js +3 -1
  288. package/dist/esm/config.js.map +1 -1
  289. package/dist/esm/config.mjs.map +1 -1
  290. package/dist/esm/config.native.js.map +1 -1
  291. package/dist/esm/constants.js.map +1 -1
  292. package/dist/esm/constants.mjs.map +1 -1
  293. package/dist/esm/constants.native.js.map +1 -1
  294. package/dist/esm/createApp.js +9 -1
  295. package/dist/esm/createApp.js.map +1 -1
  296. package/dist/esm/createApp.mjs.map +1 -1
  297. package/dist/esm/createHandleRequest.js +9 -3
  298. package/dist/esm/createHandleRequest.js.map +1 -1
  299. package/dist/esm/createHandleRequest.mjs.map +1 -1
  300. package/dist/esm/createHandleRequest.native.js.map +1 -1
  301. package/dist/esm/fork/__tests__/getPathFromState.test.js +90 -88
  302. package/dist/esm/fork/__tests__/getPathFromState.test.js.map +1 -1
  303. package/dist/esm/fork/__tests__/getPathFromState.test.mjs.map +1 -1
  304. package/dist/esm/fork/__tests__/getPathFromState.test.native.js.map +1 -1
  305. package/dist/esm/fork/__tests__/getStateFromPath.test.js +163 -86
  306. package/dist/esm/fork/__tests__/getStateFromPath.test.js.map +1 -1
  307. package/dist/esm/fork/__tests__/getStateFromPath.test.mjs.map +1 -1
  308. package/dist/esm/fork/__tests__/getStateFromPath.test.native.js.map +1 -1
  309. package/dist/esm/fork/_shared.js.map +1 -1
  310. package/dist/esm/fork/_shared.mjs.map +1 -1
  311. package/dist/esm/fork/_shared.native.js.map +1 -1
  312. package/dist/esm/fork/extractPathFromURL.js.map +1 -1
  313. package/dist/esm/fork/extractPathFromURL.mjs.map +1 -1
  314. package/dist/esm/fork/extractPathFromURL.native.js.map +1 -1
  315. package/dist/esm/fork/getPathFromState-mods.js +4 -1
  316. package/dist/esm/fork/getPathFromState-mods.js.map +1 -1
  317. package/dist/esm/fork/getPathFromState-mods.mjs.map +1 -1
  318. package/dist/esm/fork/getPathFromState-mods.native.js.map +1 -1
  319. package/dist/esm/fork/getPathFromState.js +3 -1
  320. package/dist/esm/fork/getPathFromState.js.map +1 -1
  321. package/dist/esm/fork/getPathFromState.mjs.map +1 -1
  322. package/dist/esm/fork/getPathFromState.native.js.map +1 -1
  323. package/dist/esm/fork/getStateFromPath-mods.js.map +1 -1
  324. package/dist/esm/fork/getStateFromPath-mods.mjs.map +1 -1
  325. package/dist/esm/fork/getStateFromPath-mods.native.js.map +1 -1
  326. package/dist/esm/fork/getStateFromPath.js +7 -1
  327. package/dist/esm/fork/getStateFromPath.js.map +1 -1
  328. package/dist/esm/fork/getStateFromPath.mjs.map +1 -1
  329. package/dist/esm/fork/getStateFromPath.native.js.map +1 -1
  330. package/dist/esm/fork/getStateFromPath.test.js +25 -9
  331. package/dist/esm/fork/getStateFromPath.test.js.map +1 -1
  332. package/dist/esm/fork/getStateFromPath.test.mjs.map +1 -1
  333. package/dist/esm/fork/getStateFromPath.test.native.js.map +1 -1
  334. package/dist/esm/fork/useBackButton.js.map +1 -1
  335. package/dist/esm/fork/useBackButton.mjs.map +1 -1
  336. package/dist/esm/fork/useDocumentTitle.js +4 -1
  337. package/dist/esm/fork/useDocumentTitle.js.map +1 -1
  338. package/dist/esm/fork/useDocumentTitle.mjs.map +1 -1
  339. package/dist/esm/fork/useLinking.js +4 -1
  340. package/dist/esm/fork/useLinking.js.map +1 -1
  341. package/dist/esm/fork/useLinking.mjs.map +1 -1
  342. package/dist/esm/fork/validatePathConfig.js.map +1 -1
  343. package/dist/esm/fork/validatePathConfig.mjs.map +1 -1
  344. package/dist/esm/fork/validatePathConfig.native.js.map +1 -1
  345. package/dist/esm/hooks.js.map +1 -1
  346. package/dist/esm/hooks.mjs.map +1 -1
  347. package/dist/esm/hooks.native.js.map +1 -1
  348. package/dist/esm/index.js +3 -1
  349. package/dist/esm/index.js.map +1 -1
  350. package/dist/esm/index.mjs.map +1 -1
  351. package/dist/esm/index.native.js.map +1 -1
  352. package/dist/esm/layouts/Tabs.js.map +1 -1
  353. package/dist/esm/layouts/Tabs.mjs.map +1 -1
  354. package/dist/esm/layouts/Tabs.native.js.map +1 -1
  355. package/dist/esm/layouts/withLayoutContext.js +10 -8
  356. package/dist/esm/layouts/withLayoutContext.js.map +1 -1
  357. package/dist/esm/layouts/withLayoutContext.mjs.map +1 -1
  358. package/dist/esm/layouts/withLayoutContext.native.js.map +1 -1
  359. package/dist/esm/link/Link.js.map +1 -1
  360. package/dist/esm/link/Link.mjs.map +1 -1
  361. package/dist/esm/link/Link.native.js.map +1 -1
  362. package/dist/esm/link/linking.js +3 -1
  363. package/dist/esm/link/linking.js.map +1 -1
  364. package/dist/esm/link/linking.mjs.map +1 -1
  365. package/dist/esm/link/linking.native.js.map +1 -1
  366. package/dist/esm/link/useLinkTo.js.map +1 -1
  367. package/dist/esm/link/useLinkTo.mjs.map +1 -1
  368. package/dist/esm/link/useLinkTo.native.js.map +1 -1
  369. package/dist/esm/link/useLoadedNavigation.js +3 -1
  370. package/dist/esm/link/useLoadedNavigation.js.map +1 -1
  371. package/dist/esm/link/useLoadedNavigation.mjs.map +1 -1
  372. package/dist/esm/link/useLoadedNavigation.native.js.map +1 -1
  373. package/dist/esm/metro-config/getViteMetroPluginOptions.js +8 -10
  374. package/dist/esm/metro-config/getViteMetroPluginOptions.js.map +1 -1
  375. package/dist/esm/metro-config/getViteMetroPluginOptions.mjs +6 -8
  376. package/dist/esm/metro-config/getViteMetroPluginOptions.mjs.map +1 -1
  377. package/dist/esm/metro-config/getViteMetroPluginOptions.native.js +9 -11
  378. package/dist/esm/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
  379. package/dist/esm/polyfills-mobile.js +2 -0
  380. package/dist/esm/polyfills-mobile.js.map +1 -1
  381. package/dist/esm/polyfills-mobile.mjs +2 -0
  382. package/dist/esm/polyfills-mobile.mjs.map +1 -1
  383. package/dist/esm/polyfills-mobile.native.js +5 -3
  384. package/dist/esm/polyfills-mobile.native.js.map +1 -1
  385. package/dist/esm/router/Route.js.map +1 -1
  386. package/dist/esm/router/Route.mjs.map +1 -1
  387. package/dist/esm/router/Route.native.js.map +1 -1
  388. package/dist/esm/router/RouteInfoContext.js +7 -1
  389. package/dist/esm/router/RouteInfoContext.js.map +1 -1
  390. package/dist/esm/router/RouteInfoContext.mjs.map +1 -1
  391. package/dist/esm/router/RouteInfoContext.native.js.map +1 -1
  392. package/dist/esm/router/filterRootHTML.js.map +1 -1
  393. package/dist/esm/router/filterRootHTML.mjs.map +1 -1
  394. package/dist/esm/router/filterRootHTML.native.js.map +1 -1
  395. package/dist/esm/router/getLinkingConfig.js.map +1 -1
  396. package/dist/esm/router/getLinkingConfig.mjs.map +1 -1
  397. package/dist/esm/router/getLinkingConfig.native.js.map +1 -1
  398. package/dist/esm/router/getNormalizedStatePath.js.map +1 -1
  399. package/dist/esm/router/getNormalizedStatePath.mjs.map +1 -1
  400. package/dist/esm/router/getNormalizedStatePath.native.js.map +1 -1
  401. package/dist/esm/router/getRoutes.js +3 -1
  402. package/dist/esm/router/getRoutes.js.map +1 -1
  403. package/dist/esm/router/getRoutes.mjs.map +1 -1
  404. package/dist/esm/router/getRoutes.native.js.map +1 -1
  405. package/dist/esm/router/linkingConfig.js +3 -1
  406. package/dist/esm/router/linkingConfig.js.map +1 -1
  407. package/dist/esm/router/linkingConfig.mjs.map +1 -1
  408. package/dist/esm/router/linkingConfig.native.js.map +1 -1
  409. package/dist/esm/router/matchers.js +1 -1
  410. package/dist/esm/router/matchers.js.map +1 -1
  411. package/dist/esm/router/matchers.mjs +1 -1
  412. package/dist/esm/router/matchers.mjs.map +1 -1
  413. package/dist/esm/router/matchers.native.js +1 -1
  414. package/dist/esm/router/matchers.native.js.map +1 -1
  415. package/dist/esm/router/matchers.test.js +6 -2
  416. package/dist/esm/router/matchers.test.js.map +1 -1
  417. package/dist/esm/router/matchers.test.mjs.map +1 -1
  418. package/dist/esm/router/router.js +18 -5
  419. package/dist/esm/router/router.js.map +1 -1
  420. package/dist/esm/router/router.mjs +3 -1
  421. package/dist/esm/router/router.mjs.map +1 -1
  422. package/dist/esm/router/router.native.js +7 -3
  423. package/dist/esm/router/router.native.js.map +1 -1
  424. package/dist/esm/router/useNavigation.js.map +1 -1
  425. package/dist/esm/router/useNavigation.mjs.map +1 -1
  426. package/dist/esm/router/useNavigation.native.js.map +1 -1
  427. package/dist/esm/router/useScreens.js +13 -11
  428. package/dist/esm/router/useScreens.js.map +1 -1
  429. package/dist/esm/router/useScreens.mjs.map +1 -1
  430. package/dist/esm/router/useScreens.native.js.map +1 -1
  431. package/dist/esm/router/useViteRoutes.js.map +1 -1
  432. package/dist/esm/router/useViteRoutes.mjs.map +1 -1
  433. package/dist/esm/router/useViteRoutes.native.js.map +1 -1
  434. package/dist/esm/router/utils/getNavigateAction.js.map +1 -1
  435. package/dist/esm/router/utils/getNavigateAction.mjs.map +1 -1
  436. package/dist/esm/router/utils/getNavigateAction.native.js.map +1 -1
  437. package/dist/esm/server/createRoutesManifest.js.map +1 -1
  438. package/dist/esm/server/createRoutesManifest.mjs.map +1 -1
  439. package/dist/esm/server/createRoutesManifest.native.js.map +1 -1
  440. package/dist/esm/server/getServerManifest.js +3 -1
  441. package/dist/esm/server/getServerManifest.js.map +1 -1
  442. package/dist/esm/server/getServerManifest.mjs.map +1 -1
  443. package/dist/esm/server/getServerManifest.native.js.map +1 -1
  444. package/dist/esm/server/oneServe.js +21 -3
  445. package/dist/esm/server/oneServe.js.map +1 -1
  446. package/dist/esm/server/oneServe.mjs +10 -2
  447. package/dist/esm/server/oneServe.mjs.map +1 -1
  448. package/dist/esm/server/oneServe.native.js +10 -3
  449. package/dist/esm/server/oneServe.native.js.map +1 -1
  450. package/dist/esm/server/setupBuildOptions.js.map +1 -1
  451. package/dist/esm/server/setupBuildOptions.mjs.map +1 -1
  452. package/dist/esm/server/setupBuildOptions.native.js.map +1 -1
  453. package/dist/esm/server/staticHtmlFetcher.js.map +1 -1
  454. package/dist/esm/server/staticHtmlFetcher.mjs.map +1 -1
  455. package/dist/esm/server/staticHtmlFetcher.native.js.map +1 -1
  456. package/dist/esm/server-render.js.map +1 -1
  457. package/dist/esm/server-render.mjs.map +1 -1
  458. package/dist/esm/server-render.native.js.map +1 -1
  459. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.js +14 -2
  460. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.js.map +1 -1
  461. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs.map +1 -1
  462. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  463. package/dist/esm/typed-routes/injectRouteHelpers.js +4 -1
  464. package/dist/esm/typed-routes/injectRouteHelpers.js.map +1 -1
  465. package/dist/esm/typed-routes/injectRouteHelpers.mjs.map +1 -1
  466. package/dist/esm/typed-routes/injectRouteHelpers.native.js.map +1 -1
  467. package/dist/esm/ui/Slot.js.map +1 -1
  468. package/dist/esm/ui/Slot.mjs.map +1 -1
  469. package/dist/esm/ui/Slot.native.js.map +1 -1
  470. package/dist/esm/ui/TabContext.js +3 -1
  471. package/dist/esm/ui/TabContext.js.map +1 -1
  472. package/dist/esm/ui/TabContext.mjs.map +1 -1
  473. package/dist/esm/ui/TabContext.native.js.map +1 -1
  474. package/dist/esm/ui/TabRouter.js.map +1 -1
  475. package/dist/esm/ui/TabRouter.mjs.map +1 -1
  476. package/dist/esm/ui/TabRouter.native.js.map +1 -1
  477. package/dist/esm/ui/TabTrigger.js +21 -3
  478. package/dist/esm/ui/TabTrigger.js.map +1 -1
  479. package/dist/esm/ui/TabTrigger.mjs.map +1 -1
  480. package/dist/esm/ui/TabTrigger.native.js.map +1 -1
  481. package/dist/esm/ui/Tabs.js +5 -1
  482. package/dist/esm/ui/Tabs.js.map +1 -1
  483. package/dist/esm/ui/Tabs.mjs.map +1 -1
  484. package/dist/esm/ui/Tabs.native.js.map +1 -1
  485. package/dist/esm/ui/common.js +8 -2
  486. package/dist/esm/ui/common.js.map +1 -1
  487. package/dist/esm/ui/common.mjs.map +1 -1
  488. package/dist/esm/ui/common.native.js.map +1 -1
  489. package/dist/esm/useLoader.js +4 -1
  490. package/dist/esm/useLoader.js.map +1 -1
  491. package/dist/esm/useLoader.mjs.map +1 -1
  492. package/dist/esm/useLoader.native.js.map +1 -1
  493. package/dist/esm/utils/cleanUrl.js.map +1 -1
  494. package/dist/esm/utils/cleanUrl.mjs.map +1 -1
  495. package/dist/esm/utils/cleanUrl.native.js.map +1 -1
  496. package/dist/esm/utils/url.js +3 -1
  497. package/dist/esm/utils/url.js.map +1 -1
  498. package/dist/esm/utils/url.mjs.map +1 -1
  499. package/dist/esm/utils/url.native.js.map +1 -1
  500. package/dist/esm/vercel/build/buildVercelOutputDirectory.js +29 -10
  501. package/dist/esm/vercel/build/buildVercelOutputDirectory.js.map +1 -1
  502. package/dist/esm/vercel/build/buildVercelOutputDirectory.mjs.map +1 -1
  503. package/dist/esm/vercel/build/buildVercelOutputDirectory.native.js.map +1 -1
  504. package/dist/esm/vercel/build/generate/createApiServerlessFunction.js +11 -3
  505. package/dist/esm/vercel/build/generate/createApiServerlessFunction.js.map +1 -1
  506. package/dist/esm/vercel/build/generate/createApiServerlessFunction.mjs.map +1 -1
  507. package/dist/esm/vercel/build/generate/createApiServerlessFunction.native.js.map +1 -1
  508. package/dist/esm/vercel/build/generate/createSsrServerlessFunction.js +9 -2
  509. package/dist/esm/vercel/build/generate/createSsrServerlessFunction.js.map +1 -1
  510. package/dist/esm/vercel/build/generate/createSsrServerlessFunction.mjs.map +1 -1
  511. package/dist/esm/vercel/build/generate/createSsrServerlessFunction.native.js.map +1 -1
  512. package/dist/esm/vercel/build/getPathFromRoute.js +4 -1
  513. package/dist/esm/vercel/build/getPathFromRoute.js.map +1 -1
  514. package/dist/esm/vercel/build/getPathFromRoute.mjs.map +1 -1
  515. package/dist/esm/vercel/build/getPathFromRoute.native.js.map +1 -1
  516. package/dist/esm/views/Navigator.js +20 -9
  517. package/dist/esm/views/Navigator.js.map +1 -1
  518. package/dist/esm/views/Navigator.mjs.map +1 -1
  519. package/dist/esm/views/Navigator.native.js.map +1 -1
  520. package/dist/esm/views/RootErrorBoundary.js +4 -2
  521. package/dist/esm/views/RootErrorBoundary.js.map +1 -1
  522. package/dist/esm/views/RootErrorBoundary.mjs.map +1 -1
  523. package/dist/esm/views/RootErrorBoundary.native.js.map +1 -1
  524. package/dist/esm/views/Screen.js +4 -1
  525. package/dist/esm/views/Screen.js.map +1 -1
  526. package/dist/esm/views/Screen.mjs.map +1 -1
  527. package/dist/esm/views/Screen.native.js.map +1 -1
  528. package/dist/esm/vite/loadConfig.js +6 -2
  529. package/dist/esm/vite/loadConfig.js.map +1 -1
  530. package/dist/esm/vite/loadConfig.mjs.map +1 -1
  531. package/dist/esm/vite/loadConfig.native.js.map +1 -1
  532. package/dist/esm/vite/one-server-only.js +3 -1
  533. package/dist/esm/vite/one-server-only.js.map +1 -1
  534. package/dist/esm/vite/one-server-only.mjs.map +1 -1
  535. package/dist/esm/vite/one.js +9 -3
  536. package/dist/esm/vite/one.js.map +1 -1
  537. package/dist/esm/vite/one.mjs.map +1 -1
  538. package/dist/esm/vite/one.native.js.map +1 -1
  539. package/dist/esm/vite/plugins/SSRCSSPlugin.js +5 -1
  540. package/dist/esm/vite/plugins/SSRCSSPlugin.js.map +1 -1
  541. package/dist/esm/vite/plugins/SSRCSSPlugin.mjs.map +1 -1
  542. package/dist/esm/vite/plugins/SSRCSSPlugin.native.js.map +1 -1
  543. package/dist/esm/vite/plugins/clientTreeShakePlugin.js +12 -3
  544. package/dist/esm/vite/plugins/clientTreeShakePlugin.js.map +1 -1
  545. package/dist/esm/vite/plugins/clientTreeShakePlugin.mjs.map +1 -1
  546. package/dist/esm/vite/plugins/clientTreeShakePlugin.native.js.map +1 -1
  547. package/dist/esm/vite/plugins/fileSystemRouterPlugin.js +13 -4
  548. package/dist/esm/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
  549. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +1 -0
  550. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
  551. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +1 -0
  552. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  553. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
  554. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs.map +1 -1
  555. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  556. package/dist/esm/vite/plugins/removeReactNativeWebAnimatedPlugin.js.map +1 -1
  557. package/dist/esm/vite/plugins/removeReactNativeWebAnimatedPlugin.mjs.map +1 -1
  558. package/dist/esm/vite/plugins/removeReactNativeWebAnimatedPlugin.native.js.map +1 -1
  559. package/dist/esm/vite/plugins/virtualEntryPlugin.js +16 -4
  560. package/dist/esm/vite/plugins/virtualEntryPlugin.js.map +1 -1
  561. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs +6 -2
  562. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs.map +1 -1
  563. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js +4 -1
  564. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  565. package/dist/esm/vite/replaceLoader.js +4 -1
  566. package/dist/esm/vite/replaceLoader.js.map +1 -1
  567. package/dist/esm/vite/replaceLoader.mjs.map +1 -1
  568. package/dist/esm/vite/replaceLoader.native.js.map +1 -1
  569. package/dist/esm/vite/resolveResponse.js +5 -1
  570. package/dist/esm/vite/resolveResponse.js.map +1 -1
  571. package/dist/esm/vite/resolveResponse.mjs.map +1 -1
  572. package/dist/esm/vite/resolveResponse.native.js.map +1 -1
  573. package/dist/esm/zero/subscribeToQuery.js.map +1 -1
  574. package/dist/esm/zero/subscribeToQuery.mjs.map +1 -1
  575. package/dist/esm/zero/subscribeToQuery.native.js.map +1 -1
  576. package/dist/esm/zero/useQueryZero.js +3 -1
  577. package/dist/esm/zero/useQueryZero.js.map +1 -1
  578. package/dist/esm/zero/useQueryZero.mjs.map +1 -1
  579. package/dist/esm/zero/useQueryZero.native.js.map +1 -1
  580. package/metro-entry-ctx.js +2 -1
  581. package/package.json +11 -10
  582. package/src/Root.tsx +14 -5
  583. package/src/babel-plugins/one-router-metro.ts +4 -1
  584. package/src/babel-plugins/remove-server-code.ts +15 -4
  585. package/src/cli/build.ts +33 -8
  586. package/src/cli/buildPage.ts +36 -6
  587. package/src/cli/generateRoutes.ts +3 -1
  588. package/src/cli/generateSitemap.test.ts +14 -4
  589. package/src/cli/generateSitemap.ts +7 -2
  590. package/src/cli/main.ts +3 -1
  591. package/src/cli/prebuild.ts +5 -1
  592. package/src/clientLoaderResolver.ts +4 -1
  593. package/src/config.ts +6 -2
  594. package/src/constants.ts +4 -2
  595. package/src/createApp.tsx +11 -3
  596. package/src/createHandleRequest.ts +17 -6
  597. package/src/fork/__tests__/getPathFromState.test.tsx +128 -107
  598. package/src/fork/__tests__/getStateFromPath.test.tsx +181 -95
  599. package/src/fork/_shared.ts +2 -1
  600. package/src/fork/extractPathFromURL.ts +2 -1
  601. package/src/fork/getPathFromState-mods.ts +8 -2
  602. package/src/fork/getPathFromState.ts +16 -5
  603. package/src/fork/getStateFromPath-mods.ts +13 -3
  604. package/src/fork/getStateFromPath.test.ts +25 -9
  605. package/src/fork/getStateFromPath.ts +21 -5
  606. package/src/fork/useBackButton.native.tsx +3 -1
  607. package/src/fork/useBackButton.tsx +3 -1
  608. package/src/fork/useDocumentTitle.tsx +4 -1
  609. package/src/fork/useLinking.native.ts +3 -1
  610. package/src/fork/useLinking.ts +9 -3
  611. package/src/fork/validatePathConfig.ts +6 -1
  612. package/src/head/Head.ios.tsx +3 -1
  613. package/src/hooks.tsx +4 -2
  614. package/src/index.ts +4 -1
  615. package/src/interfaces/router.ts +29 -13
  616. package/src/layouts/Tabs.tsx +5 -1
  617. package/src/layouts/withLayoutContext.tsx +24 -21
  618. package/src/link/Link.tsx +3 -1
  619. package/src/link/linking.ts +3 -1
  620. package/src/link/useLinkTo.tsx +3 -1
  621. package/src/link/useLoadedNavigation.ts +5 -1
  622. package/src/metro-config/getViteMetroPluginOptions.ts +20 -22
  623. package/src/polyfills-mobile.ts +7 -0
  624. package/src/router/Route.tsx +3 -1
  625. package/src/router/RouteInfoContext.tsx +3 -1
  626. package/src/router/filterRootHTML.ts +5 -1
  627. package/src/router/getLinkingConfig.ts +4 -1
  628. package/src/router/getNormalizedStatePath.tsx +4 -1
  629. package/src/router/getRoutes.ts +13 -4
  630. package/src/router/linkingConfig.ts +4 -1
  631. package/src/router/matchers.test.ts +6 -2
  632. package/src/router/matchers.ts +1 -1
  633. package/src/router/router.ts +26 -7
  634. package/src/router/useNavigation.ts +4 -1
  635. package/src/router/useScreens.tsx +27 -14
  636. package/src/router/useViteRoutes.tsx +2 -1
  637. package/src/router/utils/getNavigateAction.ts +4 -2
  638. package/src/server/createRoutesManifest.ts +4 -1
  639. package/src/server/getServerManifest.ts +7 -2
  640. package/src/server/oneServe.ts +37 -9
  641. package/src/server/setupBuildOptions.ts +2 -1
  642. package/src/server/staticHtmlFetcher.ts +3 -1
  643. package/src/server-render.tsx +4 -1
  644. package/src/typed-routes/getTypedRoutesDeclarationFile.ts +20 -4
  645. package/src/typed-routes/injectRouteHelpers.ts +12 -3
  646. package/src/types.ts +2 -2
  647. package/src/ui/Slot.tsx +4 -2
  648. package/src/ui/TabContext.tsx +3 -1
  649. package/src/ui/TabRouter.tsx +7 -2
  650. package/src/ui/TabTrigger.tsx +20 -3
  651. package/src/ui/Tabs.tsx +8 -2
  652. package/src/ui/common.tsx +19 -5
  653. package/src/useLoader.ts +9 -4
  654. package/src/utils/cleanUrl.ts +5 -1
  655. package/src/utils/url.ts +3 -1
  656. package/src/vercel/build/buildVercelOutputDirectory.ts +31 -10
  657. package/src/vercel/build/generate/createApiServerlessFunction.ts +11 -3
  658. package/src/vercel/build/generate/createSsrServerlessFunction.ts +10 -3
  659. package/src/vercel/build/getPathFromRoute.ts +4 -1
  660. package/src/views/Navigator.tsx +21 -9
  661. package/src/views/RootErrorBoundary.tsx +3 -1
  662. package/src/views/Screen.tsx +4 -1
  663. package/src/vite/loadConfig.ts +6 -2
  664. package/src/vite/one-server-only.tsx +10 -4
  665. package/src/vite/one.ts +61 -46
  666. package/src/vite/plugins/SSRCSSPlugin.ts +9 -2
  667. package/src/vite/plugins/clientTreeShakePlugin.ts +22 -6
  668. package/src/vite/plugins/fileSystemRouterPlugin.tsx +15 -3
  669. package/src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx +2 -1
  670. package/src/vite/plugins/removeReactNativeWebAnimatedPlugin.ts +3 -1
  671. package/src/vite/plugins/virtualEntryPlugin.ts +28 -5
  672. package/src/vite/replaceLoader.ts +7 -1
  673. package/src/vite/resolveResponse.ts +6 -2
  674. package/src/vite/types.ts +6 -3
  675. package/src/zero/subscribeToQuery.ts +4 -1
  676. package/src/zero/types.ts +8 -9
  677. package/src/zero/useQuery.ts +1 -1
  678. package/src/zero/useQueryZero.ts +3 -1
  679. package/types/Root.d.ts.map +1 -1
  680. package/types/babel-plugins/one-router-metro.d.ts.map +1 -1
  681. package/types/babel-plugins/remove-server-code.d.ts.map +1 -1
  682. package/types/cli/build.d.ts.map +1 -1
  683. package/types/cli/buildPage.d.ts.map +1 -1
  684. package/types/cli/generateRoutes.d.ts.map +1 -1
  685. package/types/cli/generateSitemap.d.ts.map +1 -1
  686. package/types/cli/main.d.ts.map +1 -1
  687. package/types/cli/prebuild.d.ts.map +1 -1
  688. package/types/clientLoaderResolver.d.ts.map +1 -1
  689. package/types/config.d.ts.map +1 -1
  690. package/types/constants.d.ts.map +1 -1
  691. package/types/createApp.d.ts.map +1 -1
  692. package/types/createHandleRequest.d.ts +1 -1
  693. package/types/createHandleRequest.d.ts.map +1 -1
  694. package/types/fork/_shared.d.ts.map +1 -1
  695. package/types/fork/extractPathFromURL.d.ts.map +1 -1
  696. package/types/fork/getPathFromState.d.ts.map +1 -1
  697. package/types/fork/getStateFromPath-mods.d.ts.map +1 -1
  698. package/types/fork/getStateFromPath.d.ts.map +1 -1
  699. package/types/fork/useBackButton.d.ts.map +1 -1
  700. package/types/fork/useBackButton.native.d.ts.map +1 -1
  701. package/types/fork/useDocumentTitle.d.ts.map +1 -1
  702. package/types/fork/useLinking.d.ts.map +1 -1
  703. package/types/fork/useLinking.native.d.ts.map +1 -1
  704. package/types/fork/validatePathConfig.d.ts.map +1 -1
  705. package/types/head/Head.ios.d.ts.map +1 -1
  706. package/types/hooks.d.ts +2 -2
  707. package/types/hooks.d.ts.map +1 -1
  708. package/types/index.d.ts +1 -1
  709. package/types/index.d.ts.map +1 -1
  710. package/types/interfaces/router.d.ts.map +1 -1
  711. package/types/layouts/Tabs.d.ts.map +1 -1
  712. package/types/layouts/withLayoutContext.d.ts.map +1 -1
  713. package/types/link/Link.d.ts.map +1 -1
  714. package/types/link/linking.d.ts.map +1 -1
  715. package/types/link/useLinkTo.d.ts.map +1 -1
  716. package/types/link/useLoadedNavigation.d.ts.map +1 -1
  717. package/types/metro-config/getViteMetroPluginOptions.d.ts.map +1 -1
  718. package/types/polyfills-mobile.d.ts.map +1 -1
  719. package/types/router/Route.d.ts.map +1 -1
  720. package/types/router/RouteInfoContext.d.ts.map +1 -1
  721. package/types/router/filterRootHTML.d.ts.map +1 -1
  722. package/types/router/getNormalizedStatePath.d.ts.map +1 -1
  723. package/types/router/getRoutes.d.ts.map +1 -1
  724. package/types/router/linkingConfig.d.ts.map +1 -1
  725. package/types/router/router.d.ts.map +1 -1
  726. package/types/router/useNavigation.d.ts.map +1 -1
  727. package/types/router/useScreens.d.ts.map +1 -1
  728. package/types/router/useViteRoutes.d.ts.map +1 -1
  729. package/types/router/utils/getNavigateAction.d.ts.map +1 -1
  730. package/types/server/createRoutesManifest.d.ts.map +1 -1
  731. package/types/server/getServerManifest.d.ts.map +1 -1
  732. package/types/server/oneServe.d.ts.map +1 -1
  733. package/types/server/setupBuildOptions.d.ts.map +1 -1
  734. package/types/server/staticHtmlFetcher.d.ts.map +1 -1
  735. package/types/server-render.d.ts.map +1 -1
  736. package/types/types.d.ts +2 -2
  737. package/types/ui/Slot.d.ts.map +1 -1
  738. package/types/ui/TabContext.d.ts.map +1 -1
  739. package/types/ui/TabRouter.d.ts.map +1 -1
  740. package/types/ui/TabTrigger.d.ts.map +1 -1
  741. package/types/ui/Tabs.d.ts.map +1 -1
  742. package/types/ui/common.d.ts.map +1 -1
  743. package/types/useLoader.d.ts.map +1 -1
  744. package/types/utils/cleanUrl.d.ts.map +1 -1
  745. package/types/utils/url.d.ts.map +1 -1
  746. package/types/vercel/build/buildVercelOutputDirectory.d.ts.map +1 -1
  747. package/types/vercel/build/generate/createApiServerlessFunction.d.ts.map +1 -1
  748. package/types/vercel/build/generate/createSsrServerlessFunction.d.ts.map +1 -1
  749. package/types/vercel/build/getPathFromRoute.d.ts.map +1 -1
  750. package/types/views/Navigator.d.ts +1 -1
  751. package/types/views/Navigator.d.ts.map +1 -1
  752. package/types/views/RootErrorBoundary.d.ts.map +1 -1
  753. package/types/views/Screen.d.ts +1 -1
  754. package/types/views/Screen.d.ts.map +1 -1
  755. package/types/vite/loadConfig.d.ts.map +1 -1
  756. package/types/vite/one-server-only.d.ts +2 -2
  757. package/types/vite/one-server-only.d.ts.map +1 -1
  758. package/types/vite/one.d.ts.map +1 -1
  759. package/types/vite/plugins/SSRCSSPlugin.d.ts.map +1 -1
  760. package/types/vite/plugins/clientTreeShakePlugin.d.ts.map +1 -1
  761. package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
  762. package/types/vite/plugins/generateFileSystemRouteTypesPlugin.d.ts.map +1 -1
  763. package/types/vite/plugins/removeReactNativeWebAnimatedPlugin.d.ts.map +1 -1
  764. package/types/vite/plugins/virtualEntryPlugin.d.ts.map +1 -1
  765. package/types/vite/replaceLoader.d.ts +2 -2
  766. package/types/vite/replaceLoader.d.ts.map +1 -1
  767. package/types/vite/resolveResponse.d.ts.map +1 -1
  768. package/types/vite/types.d.ts +1 -1
  769. package/types/vite/types.d.ts.map +1 -1
  770. package/types/zero/subscribeToQuery.d.ts.map +1 -1
  771. package/types/zero/types.d.ts.map +1 -1
  772. package/types/zero/useQueryZero.d.ts.map +1 -1
  773. package/vendor/react/cjs/react-jsx-dev-runtime.development.js +1230 -1078
  774. package/vendor/react/cjs/react-jsx-dev-runtime.production.min.js +4 -1
  775. package/vendor/react/cjs/react-jsx-dev-runtime.profiling.min.js +4 -1
  776. package/vendor/react/cjs/react-jsx-runtime.development.js +1244 -1092
  777. package/vendor/react/cjs/react-jsx-runtime.production.min.js +23 -2
  778. package/vendor/react/cjs/react-jsx-runtime.profiling.min.js +23 -2
  779. package/vendor/react/cjs/react.development.js +2604 -2324
  780. package/vendor/react/cjs/react.production.min.js +360 -17
  781. package/vendor/react/cjs/react.shared-subset.development.js +9 -7
  782. package/vendor/react/cjs/react.shared-subset.production.min.js +2 -1
  783. package/vendor/react/index.js +3 -3
  784. package/vendor/react/jsx-dev-runtime.js +3 -3
  785. package/vendor/react/jsx-runtime.js +3 -3
  786. package/vendor/react/react.shared-subset.js +3 -3
  787. package/vendor/react/umd/react.development.js +1430 -1152
  788. package/vendor/react/umd/react.production.min.js +657 -22
  789. package/vendor/react/umd/react.profiling.min.js +657 -22
  790. package/vendor/react-dom/cjs/react-dom-server-legacy.browser.development.js +7183 -5938
  791. package/vendor/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +1941 -84
  792. package/vendor/react-dom/cjs/react-dom-server-legacy.node.development.js +7239 -5986
  793. package/vendor/react-dom/cjs/react-dom-server-legacy.node.production.min.js +2055 -92
  794. package/vendor/react-dom/cjs/react-dom-server.browser.development.js +7146 -5924
  795. package/vendor/react-dom/cjs/react-dom-server.browser.production.min.js +1997 -87
  796. package/vendor/react-dom/cjs/react-dom-server.node.development.js +7210 -5976
  797. package/vendor/react-dom/cjs/react-dom-server.node.production.min.js +2075 -93
  798. package/vendor/react-dom/cjs/react-dom-test-utils.development.js +1700 -1487
  799. package/vendor/react-dom/cjs/react-dom-test-utils.production.min.js +653 -31
  800. package/vendor/react-dom/cjs/react-dom.development.js +29568 -25248
  801. package/vendor/react-dom/cjs/react-dom.production.min.js +8208 -310
  802. package/vendor/react-dom/cjs/react-dom.profiling.min.js +8750 -343
  803. package/vendor/react-dom/client.js +15 -15
  804. package/vendor/react-dom/index.js +8 -8
  805. package/vendor/react-dom/profiling.js +8 -8
  806. package/vendor/react-dom/server.browser.js +12 -12
  807. package/vendor/react-dom/server.js +2 -2
  808. package/vendor/react-dom/server.node.js +12 -12
  809. package/vendor/react-dom/test-utils.js +3 -3
  810. package/vendor/react-dom/umd/react-dom-server-legacy.browser.development.js +3735 -2502
  811. package/vendor/react-dom/umd/react-dom-server-legacy.browser.production.min.js +1964 -66
  812. package/vendor/react-dom/umd/react-dom-server.browser.development.js +3724 -2511
  813. package/vendor/react-dom/umd/react-dom-server.browser.production.min.js +2017 -67
  814. package/vendor/react-dom/umd/react-dom-test-utils.development.js +777 -563
  815. package/vendor/react-dom/umd/react-dom-test-utils.production.min.js +678 -24
  816. package/vendor/react-dom/umd/react-dom.development.js +15978 -11854
  817. package/vendor/react-dom/umd/react-dom.production.min.js +8328 -256
  818. package/vendor/react-dom/umd/react-dom.profiling.min.js +8868 -274
@@ -8,1756 +8,1969 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
 
11
- 'use strict';
12
-
13
- if (process.env.NODE_ENV !== "production") {
14
- (function() {
15
- 'use strict';
16
-
17
- var React = require('react');
18
- var ReactDOM = require('react-dom');
19
-
20
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
21
-
22
- // by calls to these methods by a Babel plugin.
23
- //
24
- // In PROD (or in packages without access to React internals),
25
- // they are left as they are instead.
11
+ 'use strict'
12
+
13
+ if (process.env.NODE_ENV !== 'production') {
14
+ ;(function () {
15
+ 'use strict'
16
+
17
+ var React = require('react')
18
+ var ReactDOM = require('react-dom')
19
+
20
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
21
+
22
+ // by calls to these methods by a Babel plugin.
23
+ //
24
+ // In PROD (or in packages without access to React internals),
25
+ // they are left as they are instead.
26
+
27
+ function warn(format) {
28
+ {
29
+ {
30
+ for (
31
+ var _len = arguments.length,
32
+ args = new Array(_len > 1 ? _len - 1 : 0),
33
+ _key = 1;
34
+ _key < _len;
35
+ _key++
36
+ ) {
37
+ args[_key - 1] = arguments[_key]
38
+ }
26
39
 
27
- function warn(format) {
28
- {
29
- {
30
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
31
- args[_key - 1] = arguments[_key];
40
+ printWarning('warn', format, args)
41
+ }
32
42
  }
33
-
34
- printWarning('warn', format, args);
35
43
  }
36
- }
37
- }
38
- function error(format) {
39
- {
40
- {
41
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
42
- args[_key2 - 1] = arguments[_key2];
43
- }
44
+ function error(format) {
45
+ {
46
+ {
47
+ for (
48
+ var _len2 = arguments.length,
49
+ args = new Array(_len2 > 1 ? _len2 - 1 : 0),
50
+ _key2 = 1;
51
+ _key2 < _len2;
52
+ _key2++
53
+ ) {
54
+ args[_key2 - 1] = arguments[_key2]
55
+ }
44
56
 
45
- printWarning('error', format, args);
57
+ printWarning('error', format, args)
58
+ }
59
+ }
46
60
  }
47
- }
48
- }
49
61
 
50
- function printWarning(level, format, args) {
51
- // When changing this logic, you might want to also
52
- // update consoleWithStackDev.www.js as well.
53
- {
54
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
55
- var stack = ReactDebugCurrentFrame.getStackAddendum();
62
+ function printWarning(level, format, args) {
63
+ // When changing this logic, you might want to also
64
+ // update consoleWithStackDev.www.js as well.
65
+ {
66
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame
67
+ var stack = ReactDebugCurrentFrame.getStackAddendum()
56
68
 
57
- if (stack !== '') {
58
- format += '%s';
59
- args = args.concat([stack]);
60
- } // eslint-disable-next-line react-internal/safe-string-coercion
69
+ if (stack !== '') {
70
+ format += '%s'
71
+ args = args.concat([stack])
72
+ } // eslint-disable-next-line react-internal/safe-string-coercion
61
73
 
74
+ var argsWithFormat = args.map(function (item) {
75
+ return String(item)
76
+ }) // Careful: RN currently depends on this prefix
62
77
 
63
- var argsWithFormat = args.map(function (item) {
64
- return String(item);
65
- }); // Careful: RN currently depends on this prefix
78
+ argsWithFormat.unshift('Warning: ' + format) // We intentionally don't use spread (or .apply) directly because it
79
+ // breaks IE9: https://github.com/facebook/react/issues/13610
80
+ // eslint-disable-next-line react-internal/no-production-logging
66
81
 
67
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
68
- // breaks IE9: https://github.com/facebook/react/issues/13610
69
- // eslint-disable-next-line react-internal/no-production-logging
82
+ Function.prototype.apply.call(console[level], console, argsWithFormat)
83
+ }
84
+ }
70
85
 
71
- Function.prototype.apply.call(console[level], console, argsWithFormat);
72
- }
73
- }
86
+ /**
87
+ * `ReactInstanceMap` maintains a mapping from a public facing stateful
88
+ * instance (key) and the internal representation (value). This allows public
89
+ * methods to accept the user facing instance as an argument and map them back
90
+ * to internal methods.
91
+ *
92
+ * Note that this module is currently shared and assumed to be stateless.
93
+ * If this becomes an actual Map, that will break.
94
+ */
95
+ function get(key) {
96
+ return key._reactInternals
97
+ }
74
98
 
75
- /**
76
- * `ReactInstanceMap` maintains a mapping from a public facing stateful
77
- * instance (key) and the internal representation (value). This allows public
78
- * methods to accept the user facing instance as an argument and map them back
79
- * to internal methods.
80
- *
81
- * Note that this module is currently shared and assumed to be stateless.
82
- * If this becomes an actual Map, that will break.
83
- */
84
- function get(key) {
85
- return key._reactInternals;
86
- }
99
+ var FunctionComponent = 0
100
+ var ClassComponent = 1
87
101
 
88
- var FunctionComponent = 0;
89
- var ClassComponent = 1;
102
+ var HostRoot = 3 // Root of a host tree. Could be nested inside another node.
90
103
 
91
- var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
104
+ var HostComponent = 5
105
+ var HostText = 6
92
106
 
93
- var HostComponent = 5;
94
- var HostText = 6;
107
+ // Don't change these two values. They're used by React Dev Tools.
108
+ var NoFlags =
109
+ /* */
110
+ 0
95
111
 
96
- // Don't change these two values. They're used by React Dev Tools.
97
- var NoFlags =
98
- /* */
99
- 0;
112
+ var Placement =
113
+ /* */
114
+ 2
115
+ var Hydrating =
116
+ /* */
117
+ 4096
100
118
 
101
- var Placement =
102
- /* */
103
- 2;
104
- var Hydrating =
105
- /* */
106
- 4096;
119
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner
120
+ function getNearestMountedFiber(fiber) {
121
+ var node = fiber
122
+ var nearestMounted = fiber
107
123
 
108
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
109
- function getNearestMountedFiber(fiber) {
110
- var node = fiber;
111
- var nearestMounted = fiber;
124
+ if (!fiber.alternate) {
125
+ // If there is no alternate, this might be a new tree that isn't inserted
126
+ // yet. If it is, then it will have a pending insertion effect on it.
127
+ var nextNode = node
112
128
 
113
- if (!fiber.alternate) {
114
- // If there is no alternate, this might be a new tree that isn't inserted
115
- // yet. If it is, then it will have a pending insertion effect on it.
116
- var nextNode = node;
129
+ do {
130
+ node = nextNode
117
131
 
118
- do {
119
- node = nextNode;
132
+ if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
133
+ // This is an insertion or in-progress hydration. The nearest possible
134
+ // mounted fiber is the parent but we need to continue to figure out
135
+ // if that one is still mounted.
136
+ nearestMounted = node.return
137
+ }
120
138
 
121
- if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
122
- // This is an insertion or in-progress hydration. The nearest possible
123
- // mounted fiber is the parent but we need to continue to figure out
124
- // if that one is still mounted.
125
- nearestMounted = node.return;
139
+ nextNode = node.return
140
+ } while (nextNode)
141
+ } else {
142
+ while (node.return) {
143
+ node = node.return
144
+ }
126
145
  }
127
146
 
128
- nextNode = node.return;
129
- } while (nextNode);
130
- } else {
131
- while (node.return) {
132
- node = node.return;
133
- }
134
- }
135
-
136
- if (node.tag === HostRoot) {
137
- // TODO: Check if this was a nested HostRoot when used with
138
- // renderContainerIntoSubtree.
139
- return nearestMounted;
140
- } // If we didn't hit the root, that means that we're in an disconnected tree
141
- // that has been unmounted.
142
-
143
-
144
- return null;
145
- }
146
-
147
- function assertIsMounted(fiber) {
148
- if (getNearestMountedFiber(fiber) !== fiber) {
149
- throw new Error('Unable to find node on an unmounted component.');
150
- }
151
- }
147
+ if (node.tag === HostRoot) {
148
+ // TODO: Check if this was a nested HostRoot when used with
149
+ // renderContainerIntoSubtree.
150
+ return nearestMounted
151
+ } // If we didn't hit the root, that means that we're in an disconnected tree
152
+ // that has been unmounted.
152
153
 
153
- function findCurrentFiberUsingSlowPath(fiber) {
154
- var alternate = fiber.alternate;
155
-
156
- if (!alternate) {
157
- // If there is no alternate, then we only need to check if it is mounted.
158
- var nearestMounted = getNearestMountedFiber(fiber);
159
-
160
- if (nearestMounted === null) {
161
- throw new Error('Unable to find node on an unmounted component.');
154
+ return null
162
155
  }
163
156
 
164
- if (nearestMounted !== fiber) {
165
- return null;
157
+ function assertIsMounted(fiber) {
158
+ if (getNearestMountedFiber(fiber) !== fiber) {
159
+ throw new Error('Unable to find node on an unmounted component.')
160
+ }
166
161
  }
167
162
 
168
- return fiber;
169
- } // If we have two possible branches, we'll walk backwards up to the root
170
- // to see what path the root points to. On the way we may hit one of the
171
- // special cases and we'll deal with them.
172
-
163
+ function findCurrentFiberUsingSlowPath(fiber) {
164
+ var alternate = fiber.alternate
173
165
 
174
- var a = fiber;
175
- var b = alternate;
166
+ if (!alternate) {
167
+ // If there is no alternate, then we only need to check if it is mounted.
168
+ var nearestMounted = getNearestMountedFiber(fiber)
176
169
 
177
- while (true) {
178
- var parentA = a.return;
170
+ if (nearestMounted === null) {
171
+ throw new Error('Unable to find node on an unmounted component.')
172
+ }
179
173
 
180
- if (parentA === null) {
181
- // We're at the root.
182
- break;
183
- }
174
+ if (nearestMounted !== fiber) {
175
+ return null
176
+ }
184
177
 
185
- var parentB = parentA.alternate;
178
+ return fiber
179
+ } // If we have two possible branches, we'll walk backwards up to the root
180
+ // to see what path the root points to. On the way we may hit one of the
181
+ // special cases and we'll deal with them.
186
182
 
187
- if (parentB === null) {
188
- // There is no alternate. This is an unusual case. Currently, it only
189
- // happens when a Suspense component is hidden. An extra fragment fiber
190
- // is inserted in between the Suspense fiber and its children. Skip
191
- // over this extra fragment fiber and proceed to the next parent.
192
- var nextParent = parentA.return;
183
+ var a = fiber
184
+ var b = alternate
193
185
 
194
- if (nextParent !== null) {
195
- a = b = nextParent;
196
- continue;
197
- } // If there's no parent, we're at the root.
186
+ while (true) {
187
+ var parentA = a.return
198
188
 
189
+ if (parentA === null) {
190
+ // We're at the root.
191
+ break
192
+ }
199
193
 
200
- break;
201
- } // If both copies of the parent fiber point to the same child, we can
202
- // assume that the child is current. This happens when we bailout on low
203
- // priority: the bailed out fiber's child reuses the current child.
194
+ var parentB = parentA.alternate
195
+
196
+ if (parentB === null) {
197
+ // There is no alternate. This is an unusual case. Currently, it only
198
+ // happens when a Suspense component is hidden. An extra fragment fiber
199
+ // is inserted in between the Suspense fiber and its children. Skip
200
+ // over this extra fragment fiber and proceed to the next parent.
201
+ var nextParent = parentA.return
202
+
203
+ if (nextParent !== null) {
204
+ a = b = nextParent
205
+ continue
206
+ } // If there's no parent, we're at the root.
207
+
208
+ break
209
+ } // If both copies of the parent fiber point to the same child, we can
210
+ // assume that the child is current. This happens when we bailout on low
211
+ // priority: the bailed out fiber's child reuses the current child.
212
+
213
+ if (parentA.child === parentB.child) {
214
+ var child = parentA.child
215
+
216
+ while (child) {
217
+ if (child === a) {
218
+ // We've determined that A is the current branch.
219
+ assertIsMounted(parentA)
220
+ return fiber
221
+ }
204
222
 
223
+ if (child === b) {
224
+ // We've determined that B is the current branch.
225
+ assertIsMounted(parentA)
226
+ return alternate
227
+ }
205
228
 
206
- if (parentA.child === parentB.child) {
207
- var child = parentA.child;
229
+ child = child.sibling
230
+ } // We should never have an alternate for any mounting node. So the only
231
+ // way this could possibly happen is if this was unmounted, if at all.
208
232
 
209
- while (child) {
210
- if (child === a) {
211
- // We've determined that A is the current branch.
212
- assertIsMounted(parentA);
213
- return fiber;
233
+ throw new Error('Unable to find node on an unmounted component.')
214
234
  }
215
235
 
216
- if (child === b) {
217
- // We've determined that B is the current branch.
218
- assertIsMounted(parentA);
219
- return alternate;
220
- }
236
+ if (a.return !== b.return) {
237
+ // The return pointer of A and the return pointer of B point to different
238
+ // fibers. We assume that return pointers never criss-cross, so A must
239
+ // belong to the child set of A.return, and B must belong to the child
240
+ // set of B.return.
241
+ a = parentA
242
+ b = parentB
243
+ } else {
244
+ // The return pointers point to the same fiber. We'll have to use the
245
+ // default, slow path: scan the child sets of each parent alternate to see
246
+ // which child belongs to which set.
247
+ //
248
+ // Search parent A's child set
249
+ var didFindChild = false
250
+ var _child = parentA.child
251
+
252
+ while (_child) {
253
+ if (_child === a) {
254
+ didFindChild = true
255
+ a = parentA
256
+ b = parentB
257
+ break
258
+ }
221
259
 
222
- child = child.sibling;
223
- } // We should never have an alternate for any mounting node. So the only
224
- // way this could possibly happen is if this was unmounted, if at all.
260
+ if (_child === b) {
261
+ didFindChild = true
262
+ b = parentA
263
+ a = parentB
264
+ break
265
+ }
225
266
 
267
+ _child = _child.sibling
268
+ }
226
269
 
227
- throw new Error('Unable to find node on an unmounted component.');
228
- }
270
+ if (!didFindChild) {
271
+ // Search parent B's child set
272
+ _child = parentB.child
273
+
274
+ while (_child) {
275
+ if (_child === a) {
276
+ didFindChild = true
277
+ a = parentB
278
+ b = parentA
279
+ break
280
+ }
281
+
282
+ if (_child === b) {
283
+ didFindChild = true
284
+ b = parentB
285
+ a = parentA
286
+ break
287
+ }
288
+
289
+ _child = _child.sibling
290
+ }
229
291
 
230
- if (a.return !== b.return) {
231
- // The return pointer of A and the return pointer of B point to different
232
- // fibers. We assume that return pointers never criss-cross, so A must
233
- // belong to the child set of A.return, and B must belong to the child
234
- // set of B.return.
235
- a = parentA;
236
- b = parentB;
237
- } else {
238
- // The return pointers point to the same fiber. We'll have to use the
239
- // default, slow path: scan the child sets of each parent alternate to see
240
- // which child belongs to which set.
241
- //
242
- // Search parent A's child set
243
- var didFindChild = false;
244
- var _child = parentA.child;
245
-
246
- while (_child) {
247
- if (_child === a) {
248
- didFindChild = true;
249
- a = parentA;
250
- b = parentB;
251
- break;
292
+ if (!didFindChild) {
293
+ throw new Error(
294
+ 'Child was not found in either parent set. This indicates a bug ' +
295
+ 'in React related to the return pointer. Please file an issue.'
296
+ )
297
+ }
298
+ }
252
299
  }
253
300
 
254
- if (_child === b) {
255
- didFindChild = true;
256
- b = parentA;
257
- a = parentB;
258
- break;
301
+ if (a.alternate !== b) {
302
+ throw new Error(
303
+ "Return fibers should always be each others' alternates. " +
304
+ 'This error is likely caused by a bug in React. Please file an issue.'
305
+ )
259
306
  }
307
+ } // If the root is not a host container, we're in a disconnected tree. I.e.
308
+ // unmounted.
260
309
 
261
- _child = _child.sibling;
310
+ if (a.tag !== HostRoot) {
311
+ throw new Error('Unable to find node on an unmounted component.')
262
312
  }
263
313
 
264
- if (!didFindChild) {
265
- // Search parent B's child set
266
- _child = parentB.child;
314
+ if (a.stateNode.current === a) {
315
+ // We've determined that A is the current branch.
316
+ return fiber
317
+ } // Otherwise B has to be current branch.
267
318
 
268
- while (_child) {
269
- if (_child === a) {
270
- didFindChild = true;
271
- a = parentB;
272
- b = parentA;
273
- break;
274
- }
319
+ return alternate
320
+ }
275
321
 
276
- if (_child === b) {
277
- didFindChild = true;
278
- b = parentB;
279
- a = parentA;
280
- break;
281
- }
322
+ var assign = Object.assign
282
323
 
283
- _child = _child.sibling;
284
- }
324
+ /**
325
+ * `charCode` represents the actual "character code" and is safe to use with
326
+ * `String.fromCharCode`. As such, only keys that correspond to printable
327
+ * characters produce a valid `charCode`, the only exception to this is Enter.
328
+ * The Tab-key is considered non-printable and does not have a `charCode`,
329
+ * presumably because it does not produce a tab-character in browsers.
330
+ *
331
+ * @param {object} nativeEvent Native browser event.
332
+ * @return {number} Normalized `charCode` property.
333
+ */
334
+ function getEventCharCode(nativeEvent) {
335
+ var charCode
336
+ var keyCode = nativeEvent.keyCode
337
+
338
+ if ('charCode' in nativeEvent) {
339
+ charCode = nativeEvent.charCode // FF does not set `charCode` for the Enter-key, check against `keyCode`.
285
340
 
286
- if (!didFindChild) {
287
- throw new Error('Child was not found in either parent set. This indicates a bug ' + 'in React related to the return pointer. Please file an issue.');
341
+ if (charCode === 0 && keyCode === 13) {
342
+ charCode = 13
288
343
  }
344
+ } else {
345
+ // IE8 does not implement `charCode`, but `keyCode` has the correct value.
346
+ charCode = keyCode
347
+ } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
348
+ // report Enter as charCode 10 when ctrl is pressed.
349
+
350
+ if (charCode === 10) {
351
+ charCode = 13
352
+ } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
353
+ // Must not discard the (non-)printable Enter-key.
354
+
355
+ if (charCode >= 32 || charCode === 13) {
356
+ return charCode
289
357
  }
290
- }
291
358
 
292
- if (a.alternate !== b) {
293
- throw new Error("Return fibers should always be each others' alternates. " + 'This error is likely caused by a bug in React. Please file an issue.');
359
+ return 0
294
360
  }
295
- } // If the root is not a host container, we're in a disconnected tree. I.e.
296
- // unmounted.
297
361
 
362
+ function functionThatReturnsTrue() {
363
+ return true
364
+ }
298
365
 
299
- if (a.tag !== HostRoot) {
300
- throw new Error('Unable to find node on an unmounted component.');
301
- }
366
+ function functionThatReturnsFalse() {
367
+ return false
368
+ } // This is intentionally a factory so that we have different returned constructors.
369
+ // If we had a single constructor, it would be megamorphic and engines would deopt.
370
+
371
+ function createSyntheticEvent(Interface) {
372
+ /**
373
+ * Synthetic events are dispatched by event plugins, typically in response to a
374
+ * top-level event delegation handler.
375
+ *
376
+ * These systems should generally use pooling to reduce the frequency of garbage
377
+ * collection. The system should check `isPersistent` to determine whether the
378
+ * event should be released into the pool after being dispatched. Users that
379
+ * need a persisted event should invoke `persist`.
380
+ *
381
+ * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
382
+ * normalizing browser quirks. Subclasses do not necessarily have to implement a
383
+ * DOM interface; custom application-specific events can also subclass this.
384
+ */
385
+ function SyntheticBaseEvent(
386
+ reactName,
387
+ reactEventType,
388
+ targetInst,
389
+ nativeEvent,
390
+ nativeEventTarget
391
+ ) {
392
+ this._reactName = reactName
393
+ this._targetInst = targetInst
394
+ this.type = reactEventType
395
+ this.nativeEvent = nativeEvent
396
+ this.target = nativeEventTarget
397
+ this.currentTarget = null
398
+
399
+ for (var _propName in Interface) {
400
+ if (!Interface.hasOwnProperty(_propName)) {
401
+ continue
402
+ }
302
403
 
303
- if (a.stateNode.current === a) {
304
- // We've determined that A is the current branch.
305
- return fiber;
306
- } // Otherwise B has to be current branch.
404
+ var normalize = Interface[_propName]
307
405
 
406
+ if (normalize) {
407
+ this[_propName] = normalize(nativeEvent)
408
+ } else {
409
+ this[_propName] = nativeEvent[_propName]
410
+ }
411
+ }
308
412
 
309
- return alternate;
310
- }
413
+ var defaultPrevented =
414
+ nativeEvent.defaultPrevented != null
415
+ ? nativeEvent.defaultPrevented
416
+ : nativeEvent.returnValue === false
311
417
 
312
- var assign = Object.assign;
418
+ if (defaultPrevented) {
419
+ this.isDefaultPrevented = functionThatReturnsTrue
420
+ } else {
421
+ this.isDefaultPrevented = functionThatReturnsFalse
422
+ }
313
423
 
314
- /**
315
- * `charCode` represents the actual "character code" and is safe to use with
316
- * `String.fromCharCode`. As such, only keys that correspond to printable
317
- * characters produce a valid `charCode`, the only exception to this is Enter.
318
- * The Tab-key is considered non-printable and does not have a `charCode`,
319
- * presumably because it does not produce a tab-character in browsers.
320
- *
321
- * @param {object} nativeEvent Native browser event.
322
- * @return {number} Normalized `charCode` property.
323
- */
324
- function getEventCharCode(nativeEvent) {
325
- var charCode;
326
- var keyCode = nativeEvent.keyCode;
424
+ this.isPropagationStopped = functionThatReturnsFalse
425
+ return this
426
+ }
327
427
 
328
- if ('charCode' in nativeEvent) {
329
- charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`.
428
+ assign(SyntheticBaseEvent.prototype, {
429
+ preventDefault: function () {
430
+ this.defaultPrevented = true
431
+ var event = this.nativeEvent
330
432
 
331
- if (charCode === 0 && keyCode === 13) {
332
- charCode = 13;
333
- }
334
- } else {
335
- // IE8 does not implement `charCode`, but `keyCode` has the correct value.
336
- charCode = keyCode;
337
- } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
338
- // report Enter as charCode 10 when ctrl is pressed.
433
+ if (!event) {
434
+ return
435
+ }
339
436
 
437
+ if (event.preventDefault) {
438
+ event.preventDefault() // $FlowFixMe - flow is not aware of `unknown` in IE
439
+ } else if (typeof event.returnValue !== 'unknown') {
440
+ event.returnValue = false
441
+ }
340
442
 
341
- if (charCode === 10) {
342
- charCode = 13;
343
- } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
344
- // Must not discard the (non-)printable Enter-key.
443
+ this.isDefaultPrevented = functionThatReturnsTrue
444
+ },
445
+ stopPropagation: function () {
446
+ var event = this.nativeEvent
345
447
 
448
+ if (!event) {
449
+ return
450
+ }
346
451
 
347
- if (charCode >= 32 || charCode === 13) {
348
- return charCode;
349
- }
452
+ if (event.stopPropagation) {
453
+ event.stopPropagation() // $FlowFixMe - flow is not aware of `unknown` in IE
454
+ } else if (typeof event.cancelBubble !== 'unknown') {
455
+ // The ChangeEventPlugin registers a "propertychange" event for
456
+ // IE. This event does not support bubbling or cancelling, and
457
+ // any references to cancelBubble throw "Member not found". A
458
+ // typeof check of "unknown" circumvents this issue (and is also
459
+ // IE specific).
460
+ event.cancelBubble = true
461
+ }
350
462
 
351
- return 0;
352
- }
463
+ this.isPropagationStopped = functionThatReturnsTrue
464
+ },
465
+
466
+ /**
467
+ * We release all dispatched `SyntheticEvent`s after each event loop, adding
468
+ * them back into the pool. This allows a way to hold onto a reference that
469
+ * won't be added back into the pool.
470
+ */
471
+ persist: function () {
472
+ // Modern event system doesn't use pooling.
473
+ },
474
+
475
+ /**
476
+ * Checks if this event should be released back into the pool.
477
+ *
478
+ * @return {boolean} True if this should not be released, false otherwise.
479
+ */
480
+ isPersistent: functionThatReturnsTrue,
481
+ })
482
+ return SyntheticBaseEvent
483
+ }
484
+ /**
485
+ * @interface Event
486
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
487
+ */
353
488
 
354
- function functionThatReturnsTrue() {
355
- return true;
356
- }
489
+ var EventInterface = {
490
+ eventPhase: 0,
491
+ bubbles: 0,
492
+ cancelable: 0,
493
+ timeStamp: function (event) {
494
+ return event.timeStamp || Date.now()
495
+ },
496
+ defaultPrevented: 0,
497
+ isTrusted: 0,
498
+ }
499
+ var SyntheticEvent = createSyntheticEvent(EventInterface)
500
+
501
+ var UIEventInterface = assign({}, EventInterface, {
502
+ view: 0,
503
+ detail: 0,
504
+ })
505
+
506
+ var SyntheticUIEvent = createSyntheticEvent(UIEventInterface)
507
+ var lastMovementX
508
+ var lastMovementY
509
+ var lastMouseEvent
510
+
511
+ function updateMouseMovementPolyfillState(event) {
512
+ if (event !== lastMouseEvent) {
513
+ if (lastMouseEvent && event.type === 'mousemove') {
514
+ lastMovementX = event.screenX - lastMouseEvent.screenX
515
+ lastMovementY = event.screenY - lastMouseEvent.screenY
516
+ } else {
517
+ lastMovementX = 0
518
+ lastMovementY = 0
519
+ }
357
520
 
358
- function functionThatReturnsFalse() {
359
- return false;
360
- } // This is intentionally a factory so that we have different returned constructors.
361
- // If we had a single constructor, it would be megamorphic and engines would deopt.
362
-
363
-
364
- function createSyntheticEvent(Interface) {
365
- /**
366
- * Synthetic events are dispatched by event plugins, typically in response to a
367
- * top-level event delegation handler.
368
- *
369
- * These systems should generally use pooling to reduce the frequency of garbage
370
- * collection. The system should check `isPersistent` to determine whether the
371
- * event should be released into the pool after being dispatched. Users that
372
- * need a persisted event should invoke `persist`.
373
- *
374
- * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
375
- * normalizing browser quirks. Subclasses do not necessarily have to implement a
376
- * DOM interface; custom application-specific events can also subclass this.
377
- */
378
- function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) {
379
- this._reactName = reactName;
380
- this._targetInst = targetInst;
381
- this.type = reactEventType;
382
- this.nativeEvent = nativeEvent;
383
- this.target = nativeEventTarget;
384
- this.currentTarget = null;
385
-
386
- for (var _propName in Interface) {
387
- if (!Interface.hasOwnProperty(_propName)) {
388
- continue;
521
+ lastMouseEvent = event
389
522
  }
523
+ }
524
+ /**
525
+ * @interface MouseEvent
526
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
527
+ */
390
528
 
391
- var normalize = Interface[_propName];
529
+ var MouseEventInterface = assign({}, UIEventInterface, {
530
+ screenX: 0,
531
+ screenY: 0,
532
+ clientX: 0,
533
+ clientY: 0,
534
+ pageX: 0,
535
+ pageY: 0,
536
+ ctrlKey: 0,
537
+ shiftKey: 0,
538
+ altKey: 0,
539
+ metaKey: 0,
540
+ getModifierState: getEventModifierState,
541
+ button: 0,
542
+ buttons: 0,
543
+ relatedTarget: function (event) {
544
+ if (event.relatedTarget === undefined)
545
+ return event.fromElement === event.srcElement
546
+ ? event.toElement
547
+ : event.fromElement
548
+ return event.relatedTarget
549
+ },
550
+ movementX: function (event) {
551
+ if ('movementX' in event) {
552
+ return event.movementX
553
+ }
392
554
 
393
- if (normalize) {
394
- this[_propName] = normalize(nativeEvent);
395
- } else {
396
- this[_propName] = nativeEvent[_propName];
397
- }
398
- }
555
+ updateMouseMovementPolyfillState(event)
556
+ return lastMovementX
557
+ },
558
+ movementY: function (event) {
559
+ if ('movementY' in event) {
560
+ return event.movementY
561
+ } // Don't need to call updateMouseMovementPolyfillState() here
562
+ // because it's guaranteed to have already run when movementX
563
+ // was copied.
564
+
565
+ return lastMovementY
566
+ },
567
+ })
568
+
569
+ var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface)
570
+ /**
571
+ * @interface DragEvent
572
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
573
+ */
399
574
 
400
- var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
575
+ var DragEventInterface = assign({}, MouseEventInterface, {
576
+ dataTransfer: 0,
577
+ })
401
578
 
402
- if (defaultPrevented) {
403
- this.isDefaultPrevented = functionThatReturnsTrue;
404
- } else {
405
- this.isDefaultPrevented = functionThatReturnsFalse;
406
- }
579
+ var SyntheticDragEvent = createSyntheticEvent(DragEventInterface)
580
+ /**
581
+ * @interface FocusEvent
582
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
583
+ */
407
584
 
408
- this.isPropagationStopped = functionThatReturnsFalse;
409
- return this;
410
- }
585
+ var FocusEventInterface = assign({}, UIEventInterface, {
586
+ relatedTarget: 0,
587
+ })
411
588
 
412
- assign(SyntheticBaseEvent.prototype, {
413
- preventDefault: function () {
414
- this.defaultPrevented = true;
415
- var event = this.nativeEvent;
589
+ var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface)
590
+ /**
591
+ * @interface Event
592
+ * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
593
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
594
+ */
416
595
 
417
- if (!event) {
418
- return;
419
- }
596
+ var AnimationEventInterface = assign({}, EventInterface, {
597
+ animationName: 0,
598
+ elapsedTime: 0,
599
+ pseudoElement: 0,
600
+ })
420
601
 
421
- if (event.preventDefault) {
422
- event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE
423
- } else if (typeof event.returnValue !== 'unknown') {
424
- event.returnValue = false;
425
- }
602
+ var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface)
603
+ /**
604
+ * @interface Event
605
+ * @see http://www.w3.org/TR/clipboard-apis/
606
+ */
426
607
 
427
- this.isDefaultPrevented = functionThatReturnsTrue;
428
- },
429
- stopPropagation: function () {
430
- var event = this.nativeEvent;
608
+ var ClipboardEventInterface = assign({}, EventInterface, {
609
+ clipboardData: function (event) {
610
+ return 'clipboardData' in event ? event.clipboardData : window.clipboardData
611
+ },
612
+ })
431
613
 
432
- if (!event) {
433
- return;
434
- }
614
+ var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface)
615
+ /**
616
+ * @interface Event
617
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
618
+ */
435
619
 
436
- if (event.stopPropagation) {
437
- event.stopPropagation(); // $FlowFixMe - flow is not aware of `unknown` in IE
438
- } else if (typeof event.cancelBubble !== 'unknown') {
439
- // The ChangeEventPlugin registers a "propertychange" event for
440
- // IE. This event does not support bubbling or cancelling, and
441
- // any references to cancelBubble throw "Member not found". A
442
- // typeof check of "unknown" circumvents this issue (and is also
443
- // IE specific).
444
- event.cancelBubble = true;
445
- }
620
+ var CompositionEventInterface = assign({}, EventInterface, {
621
+ data: 0,
622
+ })
446
623
 
447
- this.isPropagationStopped = functionThatReturnsTrue;
448
- },
624
+ var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface)
625
+ /**
626
+ * Normalization of deprecated HTML5 `key` values
627
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
628
+ */
449
629
 
630
+ var normalizeKey = {
631
+ Esc: 'Escape',
632
+ Spacebar: ' ',
633
+ Left: 'ArrowLeft',
634
+ Up: 'ArrowUp',
635
+ Right: 'ArrowRight',
636
+ Down: 'ArrowDown',
637
+ Del: 'Delete',
638
+ Win: 'OS',
639
+ Menu: 'ContextMenu',
640
+ Apps: 'ContextMenu',
641
+ Scroll: 'ScrollLock',
642
+ MozPrintableKey: 'Unidentified',
643
+ }
450
644
  /**
451
- * We release all dispatched `SyntheticEvent`s after each event loop, adding
452
- * them back into the pool. This allows a way to hold onto a reference that
453
- * won't be added back into the pool.
645
+ * Translation from legacy `keyCode` to HTML5 `key`
646
+ * Only special keys supported, all others depend on keyboard layout or browser
647
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
454
648
  */
455
- persist: function () {// Modern event system doesn't use pooling.
456
- },
457
649
 
650
+ var translateToKey = {
651
+ 8: 'Backspace',
652
+ 9: 'Tab',
653
+ 12: 'Clear',
654
+ 13: 'Enter',
655
+ 16: 'Shift',
656
+ 17: 'Control',
657
+ 18: 'Alt',
658
+ 19: 'Pause',
659
+ 20: 'CapsLock',
660
+ 27: 'Escape',
661
+ 32: ' ',
662
+ 33: 'PageUp',
663
+ 34: 'PageDown',
664
+ 35: 'End',
665
+ 36: 'Home',
666
+ 37: 'ArrowLeft',
667
+ 38: 'ArrowUp',
668
+ 39: 'ArrowRight',
669
+ 40: 'ArrowDown',
670
+ 45: 'Insert',
671
+ 46: 'Delete',
672
+ 112: 'F1',
673
+ 113: 'F2',
674
+ 114: 'F3',
675
+ 115: 'F4',
676
+ 116: 'F5',
677
+ 117: 'F6',
678
+ 118: 'F7',
679
+ 119: 'F8',
680
+ 120: 'F9',
681
+ 121: 'F10',
682
+ 122: 'F11',
683
+ 123: 'F12',
684
+ 144: 'NumLock',
685
+ 145: 'ScrollLock',
686
+ 224: 'Meta',
687
+ }
458
688
  /**
459
- * Checks if this event should be released back into the pool.
460
- *
461
- * @return {boolean} True if this should not be released, false otherwise.
689
+ * @param {object} nativeEvent Native browser event.
690
+ * @return {string} Normalized `key` property.
462
691
  */
463
- isPersistent: functionThatReturnsTrue
464
- });
465
- return SyntheticBaseEvent;
466
- }
467
- /**
468
- * @interface Event
469
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
470
- */
471
692
 
693
+ function getEventKey(nativeEvent) {
694
+ if (nativeEvent.key) {
695
+ // Normalize inconsistent values reported by browsers due to
696
+ // implementations of a working draft specification.
697
+ // FireFox implements `key` but returns `MozPrintableKey` for all
698
+ // printable characters (normalized to `Unidentified`), ignore it.
699
+ var key = normalizeKey[nativeEvent.key] || nativeEvent.key
472
700
 
473
- var EventInterface = {
474
- eventPhase: 0,
475
- bubbles: 0,
476
- cancelable: 0,
477
- timeStamp: function (event) {
478
- return event.timeStamp || Date.now();
479
- },
480
- defaultPrevented: 0,
481
- isTrusted: 0
482
- };
483
- var SyntheticEvent = createSyntheticEvent(EventInterface);
484
-
485
- var UIEventInterface = assign({}, EventInterface, {
486
- view: 0,
487
- detail: 0
488
- });
489
-
490
- var SyntheticUIEvent = createSyntheticEvent(UIEventInterface);
491
- var lastMovementX;
492
- var lastMovementY;
493
- var lastMouseEvent;
494
-
495
- function updateMouseMovementPolyfillState(event) {
496
- if (event !== lastMouseEvent) {
497
- if (lastMouseEvent && event.type === 'mousemove') {
498
- lastMovementX = event.screenX - lastMouseEvent.screenX;
499
- lastMovementY = event.screenY - lastMouseEvent.screenY;
500
- } else {
501
- lastMovementX = 0;
502
- lastMovementY = 0;
503
- }
701
+ if (key !== 'Unidentified') {
702
+ return key
703
+ }
704
+ } // Browser does not implement `key`, polyfill as much of it as we can.
504
705
 
505
- lastMouseEvent = event;
506
- }
507
- }
508
- /**
509
- * @interface MouseEvent
510
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
511
- */
706
+ if (nativeEvent.type === 'keypress') {
707
+ var charCode = getEventCharCode(nativeEvent) // The enter-key is technically both printable and non-printable and can
708
+ // thus be captured by `keypress`, no other non-printable key should.
512
709
 
710
+ return charCode === 13 ? 'Enter' : String.fromCharCode(charCode)
711
+ }
513
712
 
514
- var MouseEventInterface = assign({}, UIEventInterface, {
515
- screenX: 0,
516
- screenY: 0,
517
- clientX: 0,
518
- clientY: 0,
519
- pageX: 0,
520
- pageY: 0,
521
- ctrlKey: 0,
522
- shiftKey: 0,
523
- altKey: 0,
524
- metaKey: 0,
525
- getModifierState: getEventModifierState,
526
- button: 0,
527
- buttons: 0,
528
- relatedTarget: function (event) {
529
- if (event.relatedTarget === undefined) return event.fromElement === event.srcElement ? event.toElement : event.fromElement;
530
- return event.relatedTarget;
531
- },
532
- movementX: function (event) {
533
- if ('movementX' in event) {
534
- return event.movementX;
535
- }
713
+ if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
714
+ // While user keyboard layout determines the actual meaning of each
715
+ // `keyCode` value, almost all function keys have a universal value.
716
+ return translateToKey[nativeEvent.keyCode] || 'Unidentified'
717
+ }
536
718
 
537
- updateMouseMovementPolyfillState(event);
538
- return lastMovementX;
539
- },
540
- movementY: function (event) {
541
- if ('movementY' in event) {
542
- return event.movementY;
543
- } // Don't need to call updateMouseMovementPolyfillState() here
544
- // because it's guaranteed to have already run when movementX
545
- // was copied.
719
+ return ''
720
+ }
721
+ /**
722
+ * Translation from modifier key to the associated property in the event.
723
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
724
+ */
546
725
 
726
+ var modifierKeyToProp = {
727
+ Alt: 'altKey',
728
+ Control: 'ctrlKey',
729
+ Meta: 'metaKey',
730
+ Shift: 'shiftKey',
731
+ } // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
732
+ // getModifierState. If getModifierState is not supported, we map it to a set of
733
+ // modifier keys exposed by the event. In this case, Lock-keys are not supported.
734
+
735
+ function modifierStateGetter(keyArg) {
736
+ var syntheticEvent = this
737
+ var nativeEvent = syntheticEvent.nativeEvent
738
+
739
+ if (nativeEvent.getModifierState) {
740
+ return nativeEvent.getModifierState(keyArg)
741
+ }
547
742
 
548
- return lastMovementY;
549
- }
550
- });
743
+ var keyProp = modifierKeyToProp[keyArg]
744
+ return keyProp ? !!nativeEvent[keyProp] : false
745
+ }
551
746
 
552
- var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface);
553
- /**
554
- * @interface DragEvent
555
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
556
- */
747
+ function getEventModifierState(nativeEvent) {
748
+ return modifierStateGetter
749
+ }
750
+ /**
751
+ * @interface KeyboardEvent
752
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
753
+ */
557
754
 
558
- var DragEventInterface = assign({}, MouseEventInterface, {
559
- dataTransfer: 0
560
- });
755
+ var KeyboardEventInterface = assign({}, UIEventInterface, {
756
+ key: getEventKey,
757
+ code: 0,
758
+ location: 0,
759
+ ctrlKey: 0,
760
+ shiftKey: 0,
761
+ altKey: 0,
762
+ metaKey: 0,
763
+ repeat: 0,
764
+ locale: 0,
765
+ getModifierState: getEventModifierState,
766
+ // Legacy Interface
767
+ charCode: function (event) {
768
+ // `charCode` is the result of a KeyPress event and represents the value of
769
+ // the actual printable character.
770
+ // KeyPress is deprecated, but its replacement is not yet final and not
771
+ // implemented in any major browser. Only KeyPress has charCode.
772
+ if (event.type === 'keypress') {
773
+ return getEventCharCode(event)
774
+ }
561
775
 
562
- var SyntheticDragEvent = createSyntheticEvent(DragEventInterface);
563
- /**
564
- * @interface FocusEvent
565
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
566
- */
776
+ return 0
777
+ },
778
+ keyCode: function (event) {
779
+ // `keyCode` is the result of a KeyDown/Up event and represents the value of
780
+ // physical keyboard key.
781
+ // The actual meaning of the value depends on the users' keyboard layout
782
+ // which cannot be detected. Assuming that it is a US keyboard layout
783
+ // provides a surprisingly accurate mapping for US and European users.
784
+ // Due to this, it is left to the user to implement at this time.
785
+ if (event.type === 'keydown' || event.type === 'keyup') {
786
+ return event.keyCode
787
+ }
567
788
 
568
- var FocusEventInterface = assign({}, UIEventInterface, {
569
- relatedTarget: 0
570
- });
789
+ return 0
790
+ },
791
+ which: function (event) {
792
+ // `which` is an alias for either `keyCode` or `charCode` depending on the
793
+ // type of the event.
794
+ if (event.type === 'keypress') {
795
+ return getEventCharCode(event)
796
+ }
571
797
 
572
- var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface);
573
- /**
574
- * @interface Event
575
- * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
576
- * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
577
- */
798
+ if (event.type === 'keydown' || event.type === 'keyup') {
799
+ return event.keyCode
800
+ }
578
801
 
579
- var AnimationEventInterface = assign({}, EventInterface, {
580
- animationName: 0,
581
- elapsedTime: 0,
582
- pseudoElement: 0
583
- });
802
+ return 0
803
+ },
804
+ })
584
805
 
585
- var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface);
586
- /**
587
- * @interface Event
588
- * @see http://www.w3.org/TR/clipboard-apis/
589
- */
806
+ var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface)
807
+ /**
808
+ * @interface PointerEvent
809
+ * @see http://www.w3.org/TR/pointerevents/
810
+ */
590
811
 
591
- var ClipboardEventInterface = assign({}, EventInterface, {
592
- clipboardData: function (event) {
593
- return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
594
- }
595
- });
812
+ var PointerEventInterface = assign({}, MouseEventInterface, {
813
+ pointerId: 0,
814
+ width: 0,
815
+ height: 0,
816
+ pressure: 0,
817
+ tangentialPressure: 0,
818
+ tiltX: 0,
819
+ tiltY: 0,
820
+ twist: 0,
821
+ pointerType: 0,
822
+ isPrimary: 0,
823
+ })
824
+
825
+ var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface)
826
+ /**
827
+ * @interface TouchEvent
828
+ * @see http://www.w3.org/TR/touch-events/
829
+ */
596
830
 
597
- var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface);
598
- /**
599
- * @interface Event
600
- * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
601
- */
831
+ var TouchEventInterface = assign({}, UIEventInterface, {
832
+ touches: 0,
833
+ targetTouches: 0,
834
+ changedTouches: 0,
835
+ altKey: 0,
836
+ metaKey: 0,
837
+ ctrlKey: 0,
838
+ shiftKey: 0,
839
+ getModifierState: getEventModifierState,
840
+ })
841
+
842
+ var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface)
843
+ /**
844
+ * @interface Event
845
+ * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
846
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
847
+ */
602
848
 
603
- var CompositionEventInterface = assign({}, EventInterface, {
604
- data: 0
605
- });
849
+ var TransitionEventInterface = assign({}, EventInterface, {
850
+ propertyName: 0,
851
+ elapsedTime: 0,
852
+ pseudoElement: 0,
853
+ })
606
854
 
607
- var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface);
608
- /**
609
- * Normalization of deprecated HTML5 `key` values
610
- * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
611
- */
855
+ var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface)
856
+ /**
857
+ * @interface WheelEvent
858
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
859
+ */
612
860
 
613
- var normalizeKey = {
614
- Esc: 'Escape',
615
- Spacebar: ' ',
616
- Left: 'ArrowLeft',
617
- Up: 'ArrowUp',
618
- Right: 'ArrowRight',
619
- Down: 'ArrowDown',
620
- Del: 'Delete',
621
- Win: 'OS',
622
- Menu: 'ContextMenu',
623
- Apps: 'ContextMenu',
624
- Scroll: 'ScrollLock',
625
- MozPrintableKey: 'Unidentified'
626
- };
627
- /**
628
- * Translation from legacy `keyCode` to HTML5 `key`
629
- * Only special keys supported, all others depend on keyboard layout or browser
630
- * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
631
- */
861
+ var WheelEventInterface = assign({}, MouseEventInterface, {
862
+ deltaX: function (event) {
863
+ return 'deltaX' in event
864
+ ? event.deltaX // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
865
+ : 'wheelDeltaX' in event
866
+ ? -event.wheelDeltaX
867
+ : 0
868
+ },
869
+ deltaY: function (event) {
870
+ return 'deltaY' in event
871
+ ? event.deltaY // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
872
+ : 'wheelDeltaY' in event
873
+ ? -event.wheelDeltaY // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
874
+ : 'wheelDelta' in event
875
+ ? -event.wheelDelta
876
+ : 0
877
+ },
878
+ deltaZ: 0,
879
+ // Browsers without "deltaMode" is reporting in raw wheel delta where one
880
+ // notch on the scroll is always +/- 120, roughly equivalent to pixels.
881
+ // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
882
+ // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
883
+ deltaMode: 0,
884
+ })
885
+
886
+ var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface)
632
887
 
633
- var translateToKey = {
634
- '8': 'Backspace',
635
- '9': 'Tab',
636
- '12': 'Clear',
637
- '13': 'Enter',
638
- '16': 'Shift',
639
- '17': 'Control',
640
- '18': 'Alt',
641
- '19': 'Pause',
642
- '20': 'CapsLock',
643
- '27': 'Escape',
644
- '32': ' ',
645
- '33': 'PageUp',
646
- '34': 'PageDown',
647
- '35': 'End',
648
- '36': 'Home',
649
- '37': 'ArrowLeft',
650
- '38': 'ArrowUp',
651
- '39': 'ArrowRight',
652
- '40': 'ArrowDown',
653
- '45': 'Insert',
654
- '46': 'Delete',
655
- '112': 'F1',
656
- '113': 'F2',
657
- '114': 'F3',
658
- '115': 'F4',
659
- '116': 'F5',
660
- '117': 'F6',
661
- '118': 'F7',
662
- '119': 'F8',
663
- '120': 'F9',
664
- '121': 'F10',
665
- '122': 'F11',
666
- '123': 'F12',
667
- '144': 'NumLock',
668
- '145': 'ScrollLock',
669
- '224': 'Meta'
670
- };
671
- /**
672
- * @param {object} nativeEvent Native browser event.
673
- * @return {string} Normalized `key` property.
674
- */
888
+ /**
889
+ * HTML nodeType values that represent the type of the node
890
+ */
891
+ var ELEMENT_NODE = 1
675
892
 
676
- function getEventKey(nativeEvent) {
677
- if (nativeEvent.key) {
678
- // Normalize inconsistent values reported by browsers due to
679
- // implementations of a working draft specification.
680
- // FireFox implements `key` but returns `MozPrintableKey` for all
681
- // printable characters (normalized to `Unidentified`), ignore it.
682
- var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
893
+ function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
894
+ var funcArgs = Array.prototype.slice.call(arguments, 3)
683
895
 
684
- if (key !== 'Unidentified') {
685
- return key;
896
+ try {
897
+ func.apply(context, funcArgs)
898
+ } catch (error) {
899
+ this.onError(error)
900
+ }
686
901
  }
687
- } // Browser does not implement `key`, polyfill as much of it as we can.
688
902
 
903
+ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd
689
904
 
690
- if (nativeEvent.type === 'keypress') {
691
- var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can
692
- // thus be captured by `keypress`, no other non-printable key should.
693
-
694
- return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
695
- }
905
+ {
906
+ // In DEV mode, we swap out invokeGuardedCallback for a special version
907
+ // that plays more nicely with the browser's DevTools. The idea is to preserve
908
+ // "Pause on exceptions" behavior. Because React wraps all user-provided
909
+ // functions in invokeGuardedCallback, and the production version of
910
+ // invokeGuardedCallback uses a try-catch, all user exceptions are treated
911
+ // like caught exceptions, and the DevTools won't pause unless the developer
912
+ // takes the extra step of enabling pause on caught exceptions. This is
913
+ // unintuitive, though, because even though React has caught the error, from
914
+ // the developer's perspective, the error is uncaught.
915
+ //
916
+ // To preserve the expected "Pause on exceptions" behavior, we don't use a
917
+ // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
918
+ // DOM node, and call the user-provided callback from inside an event handler
919
+ // for that fake event. If the callback throws, the error is "captured" using
920
+ // a global event handler. But because the error happens in a different
921
+ // event loop context, it does not interrupt the normal program flow.
922
+ // Effectively, this gives us try-catch behavior without actually using
923
+ // try-catch. Neat!
924
+ // Check that the browser supports the APIs we need to implement our special
925
+ // DEV version of invokeGuardedCallback
926
+ if (
927
+ typeof window !== 'undefined' &&
928
+ typeof window.dispatchEvent === 'function' &&
929
+ typeof document !== 'undefined' &&
930
+ typeof document.createEvent === 'function'
931
+ ) {
932
+ var fakeNode = document.createElement('react')
933
+
934
+ invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(
935
+ name,
936
+ func,
937
+ context,
938
+ a,
939
+ b,
940
+ c,
941
+ d,
942
+ e,
943
+ f
944
+ ) {
945
+ // If document doesn't exist we know for sure we will crash in this method
946
+ // when we call document.createEvent(). However this can cause confusing
947
+ // errors: https://github.com/facebook/create-react-app/issues/3482
948
+ // So we preemptively throw with a better message instead.
949
+ if (typeof document === 'undefined' || document === null) {
950
+ throw new Error(
951
+ 'The `document` global was defined when React was initialized, but is not ' +
952
+ 'defined anymore. This can happen in a test environment if a component ' +
953
+ 'schedules an update from an asynchronous callback, but the test has already ' +
954
+ 'finished running. To solve this, you can either unmount the component at ' +
955
+ 'the end of your test (and ensure that any asynchronous operations get ' +
956
+ 'canceled in `componentWillUnmount`), or you can change the test itself ' +
957
+ 'to be asynchronous.'
958
+ )
959
+ }
696
960
 
697
- if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
698
- // While user keyboard layout determines the actual meaning of each
699
- // `keyCode` value, almost all function keys have a universal value.
700
- return translateToKey[nativeEvent.keyCode] || 'Unidentified';
701
- }
961
+ var evt = document.createEvent('Event')
962
+ var didCall = false // Keeps track of whether the user-provided callback threw an error. We
963
+ // set this to true at the beginning, then set it to false right after
964
+ // calling the function. If the function errors, `didError` will never be
965
+ // set to false. This strategy works even if the browser is flaky and
966
+ // fails to call our global error handler, because it doesn't rely on
967
+ // the error event at all.
968
+
969
+ var didError = true // Keeps track of the value of window.event so that we can reset it
970
+ // during the callback to let user code access window.event in the
971
+ // browsers that support it.
972
+
973
+ var windowEvent = window.event // Keeps track of the descriptor of window.event to restore it after event
974
+ // dispatching: https://github.com/facebook/react/issues/13688
975
+
976
+ var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event')
977
+
978
+ function restoreAfterDispatch() {
979
+ // We immediately remove the callback from event listeners so that
980
+ // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
981
+ // nested call would trigger the fake event handlers of any call higher
982
+ // in the stack.
983
+ fakeNode.removeEventListener(evtType, callCallback, false) // We check for window.hasOwnProperty('event') to prevent the
984
+ // window.event assignment in both IE <= 10 as they throw an error
985
+ // "Member not found" in strict mode, and in Firefox which does not
986
+ // support window.event.
987
+
988
+ if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
989
+ window.event = windowEvent
990
+ }
991
+ } // Create an event handler for our fake event. We will synchronously
992
+ // dispatch our fake event using `dispatchEvent`. Inside the handler, we
993
+ // call the user-provided callback.
994
+
995
+ var funcArgs = Array.prototype.slice.call(arguments, 3)
996
+
997
+ function callCallback() {
998
+ didCall = true
999
+ restoreAfterDispatch()
1000
+ func.apply(context, funcArgs)
1001
+ didError = false
1002
+ } // Create a global error event handler. We use this to capture the value
1003
+ // that was thrown. It's possible that this error handler will fire more
1004
+ // than once; for example, if non-React code also calls `dispatchEvent`
1005
+ // and a handler for that event throws. We should be resilient to most of
1006
+ // those cases. Even if our error event handler fires more than once, the
1007
+ // last error event is always used. If the callback actually does error,
1008
+ // we know that the last error event is the correct one, because it's not
1009
+ // possible for anything else to have happened in between our callback
1010
+ // erroring and the code that follows the `dispatchEvent` call below. If
1011
+ // the callback doesn't error, but the error event was fired, we know to
1012
+ // ignore it because `didError` will be false, as described above.
1013
+
1014
+ var error // Use this to track whether the error event is ever called.
1015
+
1016
+ var didSetError = false
1017
+ var isCrossOriginError = false
1018
+
1019
+ function handleWindowError(event) {
1020
+ error = event.error
1021
+ didSetError = true
1022
+
1023
+ if (error === null && event.colno === 0 && event.lineno === 0) {
1024
+ isCrossOriginError = true
1025
+ }
702
1026
 
703
- return '';
704
- }
705
- /**
706
- * Translation from modifier key to the associated property in the event.
707
- * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
708
- */
1027
+ if (event.defaultPrevented) {
1028
+ // Some other error handler has prevented default.
1029
+ // Browsers silence the error report if this happens.
1030
+ // We'll remember this to later decide whether to log it or not.
1031
+ if (error != null && typeof error === 'object') {
1032
+ try {
1033
+ error._suppressLogging = true
1034
+ } catch (inner) {
1035
+ // Ignore.
1036
+ }
1037
+ }
1038
+ }
1039
+ } // Create a fake event type.
709
1040
 
1041
+ var evtType = 'react-' + (name ? name : 'invokeguardedcallback') // Attach our event handlers
710
1042
 
711
- var modifierKeyToProp = {
712
- Alt: 'altKey',
713
- Control: 'ctrlKey',
714
- Meta: 'metaKey',
715
- Shift: 'shiftKey'
716
- }; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
717
- // getModifierState. If getModifierState is not supported, we map it to a set of
718
- // modifier keys exposed by the event. In this case, Lock-keys are not supported.
1043
+ window.addEventListener('error', handleWindowError)
1044
+ fakeNode.addEventListener(evtType, callCallback, false) // Synchronously dispatch our fake event. If the user-provided function
1045
+ // errors, it will trigger our global error handler.
719
1046
 
720
- function modifierStateGetter(keyArg) {
721
- var syntheticEvent = this;
722
- var nativeEvent = syntheticEvent.nativeEvent;
1047
+ evt.initEvent(evtType, false, false)
1048
+ fakeNode.dispatchEvent(evt)
723
1049
 
724
- if (nativeEvent.getModifierState) {
725
- return nativeEvent.getModifierState(keyArg);
726
- }
1050
+ if (windowEventDescriptor) {
1051
+ Object.defineProperty(window, 'event', windowEventDescriptor)
1052
+ }
727
1053
 
728
- var keyProp = modifierKeyToProp[keyArg];
729
- return keyProp ? !!nativeEvent[keyProp] : false;
730
- }
1054
+ if (didCall && didError) {
1055
+ if (!didSetError) {
1056
+ // The callback errored, but the error event never fired.
1057
+ // eslint-disable-next-line react-internal/prod-error-codes
1058
+ error = new Error(
1059
+ 'An error was thrown inside one of your components, but React ' +
1060
+ "doesn't know what it was. This is likely due to browser " +
1061
+ 'flakiness. React does its best to preserve the "Pause on ' +
1062
+ 'exceptions" behavior of the DevTools, which requires some ' +
1063
+ "DEV-mode only tricks. It's possible that these don't work in " +
1064
+ 'your browser. Try triggering the error in production mode, ' +
1065
+ 'or switching to a modern browser. If you suspect that this is ' +
1066
+ 'actually an issue with React, please file an issue.'
1067
+ )
1068
+ } else if (isCrossOriginError) {
1069
+ // eslint-disable-next-line react-internal/prod-error-codes
1070
+ error = new Error(
1071
+ "A cross-origin error was thrown. React doesn't have access to " +
1072
+ 'the actual error object in development. ' +
1073
+ 'See https://reactjs.org/link/crossorigin-error for more information.'
1074
+ )
1075
+ }
731
1076
 
732
- function getEventModifierState(nativeEvent) {
733
- return modifierStateGetter;
734
- }
735
- /**
736
- * @interface KeyboardEvent
737
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
738
- */
1077
+ this.onError(error)
1078
+ } // Remove our event listeners
739
1079
 
1080
+ window.removeEventListener('error', handleWindowError)
740
1081
 
741
- var KeyboardEventInterface = assign({}, UIEventInterface, {
742
- key: getEventKey,
743
- code: 0,
744
- location: 0,
745
- ctrlKey: 0,
746
- shiftKey: 0,
747
- altKey: 0,
748
- metaKey: 0,
749
- repeat: 0,
750
- locale: 0,
751
- getModifierState: getEventModifierState,
752
- // Legacy Interface
753
- charCode: function (event) {
754
- // `charCode` is the result of a KeyPress event and represents the value of
755
- // the actual printable character.
756
- // KeyPress is deprecated, but its replacement is not yet final and not
757
- // implemented in any major browser. Only KeyPress has charCode.
758
- if (event.type === 'keypress') {
759
- return getEventCharCode(event);
1082
+ if (!didCall) {
1083
+ // Something went really wrong, and our event was not dispatched.
1084
+ // https://github.com/facebook/react/issues/16734
1085
+ // https://github.com/facebook/react/issues/16585
1086
+ // Fall back to the production implementation.
1087
+ restoreAfterDispatch()
1088
+ return invokeGuardedCallbackProd.apply(this, arguments)
1089
+ }
1090
+ }
1091
+ }
760
1092
  }
761
1093
 
762
- return 0;
763
- },
764
- keyCode: function (event) {
765
- // `keyCode` is the result of a KeyDown/Up event and represents the value of
766
- // physical keyboard key.
767
- // The actual meaning of the value depends on the users' keyboard layout
768
- // which cannot be detected. Assuming that it is a US keyboard layout
769
- // provides a surprisingly accurate mapping for US and European users.
770
- // Due to this, it is left to the user to implement at this time.
771
- if (event.type === 'keydown' || event.type === 'keyup') {
772
- return event.keyCode;
773
- }
1094
+ var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl
774
1095
 
775
- return 0;
776
- },
777
- which: function (event) {
778
- // `which` is an alias for either `keyCode` or `charCode` depending on the
779
- // type of the event.
780
- if (event.type === 'keypress') {
781
- return getEventCharCode(event);
782
- }
1096
+ var hasError = false
1097
+ var caughtError = null // Used by event system to capture/rethrow the first error.
783
1098
 
784
- if (event.type === 'keydown' || event.type === 'keyup') {
785
- return event.keyCode;
1099
+ var hasRethrowError = false
1100
+ var rethrowError = null
1101
+ var reporter = {
1102
+ onError: function (error) {
1103
+ hasError = true
1104
+ caughtError = error
1105
+ },
786
1106
  }
1107
+ /**
1108
+ * Call a function while guarding against errors that happens within it.
1109
+ * Returns an error if it throws, otherwise null.
1110
+ *
1111
+ * In production, this is implemented using a try-catch. The reason we don't
1112
+ * use a try-catch directly is so that we can swap out a different
1113
+ * implementation in DEV mode.
1114
+ *
1115
+ * @param {String} name of the guard to use for logging or debugging
1116
+ * @param {Function} func The function to invoke
1117
+ * @param {*} context The context to use when calling the function
1118
+ * @param {...*} args Arguments for function
1119
+ */
787
1120
 
788
- return 0;
789
- }
790
- });
1121
+ function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
1122
+ hasError = false
1123
+ caughtError = null
1124
+ invokeGuardedCallbackImpl$1.apply(reporter, arguments)
1125
+ }
1126
+ /**
1127
+ * Same as invokeGuardedCallback, but instead of returning an error, it stores
1128
+ * it in a global so it can be rethrown by `rethrowCaughtError` later.
1129
+ * TODO: See if caughtError and rethrowError can be unified.
1130
+ *
1131
+ * @param {String} name of the guard to use for logging or debugging
1132
+ * @param {Function} func The function to invoke
1133
+ * @param {*} context The context to use when calling the function
1134
+ * @param {...*} args Arguments for function
1135
+ */
791
1136
 
792
- var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface);
793
- /**
794
- * @interface PointerEvent
795
- * @see http://www.w3.org/TR/pointerevents/
796
- */
1137
+ function invokeGuardedCallbackAndCatchFirstError(
1138
+ name,
1139
+ func,
1140
+ context,
1141
+ a,
1142
+ b,
1143
+ c,
1144
+ d,
1145
+ e,
1146
+ f
1147
+ ) {
1148
+ invokeGuardedCallback.apply(this, arguments)
1149
+
1150
+ if (hasError) {
1151
+ var error = clearCaughtError()
1152
+
1153
+ if (!hasRethrowError) {
1154
+ hasRethrowError = true
1155
+ rethrowError = error
1156
+ }
1157
+ }
1158
+ }
1159
+ /**
1160
+ * During execution of guarded functions we will capture the first error which
1161
+ * we will rethrow to be handled by the top level error handler.
1162
+ */
797
1163
 
798
- var PointerEventInterface = assign({}, MouseEventInterface, {
799
- pointerId: 0,
800
- width: 0,
801
- height: 0,
802
- pressure: 0,
803
- tangentialPressure: 0,
804
- tiltX: 0,
805
- tiltY: 0,
806
- twist: 0,
807
- pointerType: 0,
808
- isPrimary: 0
809
- });
810
-
811
- var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface);
812
- /**
813
- * @interface TouchEvent
814
- * @see http://www.w3.org/TR/touch-events/
815
- */
1164
+ function rethrowCaughtError() {
1165
+ if (hasRethrowError) {
1166
+ var error = rethrowError
1167
+ hasRethrowError = false
1168
+ rethrowError = null
1169
+ throw error
1170
+ }
1171
+ }
1172
+ function clearCaughtError() {
1173
+ if (hasError) {
1174
+ var error = caughtError
1175
+ hasError = false
1176
+ caughtError = null
1177
+ return error
1178
+ } else {
1179
+ throw new Error(
1180
+ 'clearCaughtError was called but no error was captured. This error ' +
1181
+ 'is likely caused by a bug in React. Please file an issue.'
1182
+ )
1183
+ }
1184
+ }
816
1185
 
817
- var TouchEventInterface = assign({}, UIEventInterface, {
818
- touches: 0,
819
- targetTouches: 0,
820
- changedTouches: 0,
821
- altKey: 0,
822
- metaKey: 0,
823
- ctrlKey: 0,
824
- shiftKey: 0,
825
- getModifierState: getEventModifierState
826
- });
827
-
828
- var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface);
829
- /**
830
- * @interface Event
831
- * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
832
- * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
833
- */
1186
+ var isArrayImpl = Array.isArray // eslint-disable-next-line no-redeclare
834
1187
 
835
- var TransitionEventInterface = assign({}, EventInterface, {
836
- propertyName: 0,
837
- elapsedTime: 0,
838
- pseudoElement: 0
839
- });
1188
+ function isArray(a) {
1189
+ return isArrayImpl(a)
1190
+ }
840
1191
 
841
- var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface);
842
- /**
843
- * @interface WheelEvent
844
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
845
- */
1192
+ var SecretInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
1193
+ var EventInternals = SecretInternals.Events
1194
+ var getInstanceFromNode = EventInternals[0]
1195
+ var getNodeFromInstance = EventInternals[1]
1196
+ var getFiberCurrentPropsFromNode = EventInternals[2]
1197
+ var enqueueStateRestore = EventInternals[3]
1198
+ var restoreStateIfNeeded = EventInternals[4]
1199
+ var reactAct = React.unstable_act
846
1200
 
847
- var WheelEventInterface = assign({}, MouseEventInterface, {
848
- deltaX: function (event) {
849
- return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
850
- 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
851
- },
852
- deltaY: function (event) {
853
- return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
854
- 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
855
- 'wheelDelta' in event ? -event.wheelDelta : 0;
856
- },
857
- deltaZ: 0,
858
- // Browsers without "deltaMode" is reporting in raw wheel delta where one
859
- // notch on the scroll is always +/- 120, roughly equivalent to pixels.
860
- // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
861
- // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
862
- deltaMode: 0
863
- });
864
-
865
- var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface);
1201
+ function Event(suffix) {}
866
1202
 
867
- /**
868
- * HTML nodeType values that represent the type of the node
869
- */
870
- var ELEMENT_NODE = 1;
1203
+ var hasWarnedAboutDeprecatedMockComponent = false
1204
+ /**
1205
+ * @class ReactTestUtils
1206
+ */
871
1207
 
872
- function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
873
- var funcArgs = Array.prototype.slice.call(arguments, 3);
1208
+ function findAllInRenderedFiberTreeInternal(fiber, test) {
1209
+ if (!fiber) {
1210
+ return []
1211
+ }
874
1212
 
875
- try {
876
- func.apply(context, funcArgs);
877
- } catch (error) {
878
- this.onError(error);
879
- }
880
- }
1213
+ var currentParent = findCurrentFiberUsingSlowPath(fiber)
881
1214
 
882
- var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
883
-
884
- {
885
- // In DEV mode, we swap out invokeGuardedCallback for a special version
886
- // that plays more nicely with the browser's DevTools. The idea is to preserve
887
- // "Pause on exceptions" behavior. Because React wraps all user-provided
888
- // functions in invokeGuardedCallback, and the production version of
889
- // invokeGuardedCallback uses a try-catch, all user exceptions are treated
890
- // like caught exceptions, and the DevTools won't pause unless the developer
891
- // takes the extra step of enabling pause on caught exceptions. This is
892
- // unintuitive, though, because even though React has caught the error, from
893
- // the developer's perspective, the error is uncaught.
894
- //
895
- // To preserve the expected "Pause on exceptions" behavior, we don't use a
896
- // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
897
- // DOM node, and call the user-provided callback from inside an event handler
898
- // for that fake event. If the callback throws, the error is "captured" using
899
- // a global event handler. But because the error happens in a different
900
- // event loop context, it does not interrupt the normal program flow.
901
- // Effectively, this gives us try-catch behavior without actually using
902
- // try-catch. Neat!
903
- // Check that the browser supports the APIs we need to implement our special
904
- // DEV version of invokeGuardedCallback
905
- if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
906
- var fakeNode = document.createElement('react');
907
-
908
- invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a, b, c, d, e, f) {
909
- // If document doesn't exist we know for sure we will crash in this method
910
- // when we call document.createEvent(). However this can cause confusing
911
- // errors: https://github.com/facebook/create-react-app/issues/3482
912
- // So we preemptively throw with a better message instead.
913
- if (typeof document === 'undefined' || document === null) {
914
- throw new Error('The `document` global was defined when React was initialized, but is not ' + 'defined anymore. This can happen in a test environment if a component ' + 'schedules an update from an asynchronous callback, but the test has already ' + 'finished running. To solve this, you can either unmount the component at ' + 'the end of your test (and ensure that any asynchronous operations get ' + 'canceled in `componentWillUnmount`), or you can change the test itself ' + 'to be asynchronous.');
1215
+ if (!currentParent) {
1216
+ return []
915
1217
  }
916
1218
 
917
- var evt = document.createEvent('Event');
918
- var didCall = false; // Keeps track of whether the user-provided callback threw an error. We
919
- // set this to true at the beginning, then set it to false right after
920
- // calling the function. If the function errors, `didError` will never be
921
- // set to false. This strategy works even if the browser is flaky and
922
- // fails to call our global error handler, because it doesn't rely on
923
- // the error event at all.
924
-
925
- var didError = true; // Keeps track of the value of window.event so that we can reset it
926
- // during the callback to let user code access window.event in the
927
- // browsers that support it.
928
-
929
- var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event
930
- // dispatching: https://github.com/facebook/react/issues/13688
931
-
932
- var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
933
-
934
- function restoreAfterDispatch() {
935
- // We immediately remove the callback from event listeners so that
936
- // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
937
- // nested call would trigger the fake event handlers of any call higher
938
- // in the stack.
939
- fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the
940
- // window.event assignment in both IE <= 10 as they throw an error
941
- // "Member not found" in strict mode, and in Firefox which does not
942
- // support window.event.
943
-
944
- if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
945
- window.event = windowEvent;
946
- }
947
- } // Create an event handler for our fake event. We will synchronously
948
- // dispatch our fake event using `dispatchEvent`. Inside the handler, we
949
- // call the user-provided callback.
950
-
951
-
952
- var funcArgs = Array.prototype.slice.call(arguments, 3);
953
-
954
- function callCallback() {
955
- didCall = true;
956
- restoreAfterDispatch();
957
- func.apply(context, funcArgs);
958
- didError = false;
959
- } // Create a global error event handler. We use this to capture the value
960
- // that was thrown. It's possible that this error handler will fire more
961
- // than once; for example, if non-React code also calls `dispatchEvent`
962
- // and a handler for that event throws. We should be resilient to most of
963
- // those cases. Even if our error event handler fires more than once, the
964
- // last error event is always used. If the callback actually does error,
965
- // we know that the last error event is the correct one, because it's not
966
- // possible for anything else to have happened in between our callback
967
- // erroring and the code that follows the `dispatchEvent` call below. If
968
- // the callback doesn't error, but the error event was fired, we know to
969
- // ignore it because `didError` will be false, as described above.
970
-
971
-
972
- var error; // Use this to track whether the error event is ever called.
973
-
974
- var didSetError = false;
975
- var isCrossOriginError = false;
976
-
977
- function handleWindowError(event) {
978
- error = event.error;
979
- didSetError = true;
980
-
981
- if (error === null && event.colno === 0 && event.lineno === 0) {
982
- isCrossOriginError = true;
983
- }
1219
+ var node = currentParent
1220
+ var ret = []
984
1221
 
985
- if (event.defaultPrevented) {
986
- // Some other error handler has prevented default.
987
- // Browsers silence the error report if this happens.
988
- // We'll remember this to later decide whether to log it or not.
989
- if (error != null && typeof error === 'object') {
990
- try {
991
- error._suppressLogging = true;
992
- } catch (inner) {// Ignore.
993
- }
1222
+ while (true) {
1223
+ if (
1224
+ node.tag === HostComponent ||
1225
+ node.tag === HostText ||
1226
+ node.tag === ClassComponent ||
1227
+ node.tag === FunctionComponent
1228
+ ) {
1229
+ var publicInst = node.stateNode
1230
+
1231
+ if (test(publicInst)) {
1232
+ ret.push(publicInst)
994
1233
  }
995
1234
  }
996
- } // Create a fake event type.
997
-
998
-
999
- var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers
1000
1235
 
1001
- window.addEventListener('error', handleWindowError);
1002
- fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function
1003
- // errors, it will trigger our global error handler.
1004
-
1005
- evt.initEvent(evtType, false, false);
1006
- fakeNode.dispatchEvent(evt);
1007
-
1008
- if (windowEventDescriptor) {
1009
- Object.defineProperty(window, 'event', windowEventDescriptor);
1010
- }
1011
-
1012
- if (didCall && didError) {
1013
- if (!didSetError) {
1014
- // The callback errored, but the error event never fired.
1015
- // eslint-disable-next-line react-internal/prod-error-codes
1016
- error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
1017
- } else if (isCrossOriginError) {
1018
- // eslint-disable-next-line react-internal/prod-error-codes
1019
- error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://reactjs.org/link/crossorigin-error for more information.');
1236
+ if (node.child) {
1237
+ node.child.return = node
1238
+ node = node.child
1239
+ continue
1020
1240
  }
1021
1241
 
1022
- this.onError(error);
1023
- } // Remove our event listeners
1242
+ if (node === currentParent) {
1243
+ return ret
1244
+ }
1024
1245
 
1246
+ while (!node.sibling) {
1247
+ if (!node.return || node.return === currentParent) {
1248
+ return ret
1249
+ }
1025
1250
 
1026
- window.removeEventListener('error', handleWindowError);
1251
+ node = node.return
1252
+ }
1027
1253
 
1028
- if (!didCall) {
1029
- // Something went really wrong, and our event was not dispatched.
1030
- // https://github.com/facebook/react/issues/16734
1031
- // https://github.com/facebook/react/issues/16585
1032
- // Fall back to the production implementation.
1033
- restoreAfterDispatch();
1034
- return invokeGuardedCallbackProd.apply(this, arguments);
1254
+ node.sibling.return = node.return
1255
+ node = node.sibling
1035
1256
  }
1036
- };
1037
- }
1038
- }
1039
-
1040
- var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
1041
-
1042
- var hasError = false;
1043
- var caughtError = null; // Used by event system to capture/rethrow the first error.
1044
-
1045
- var hasRethrowError = false;
1046
- var rethrowError = null;
1047
- var reporter = {
1048
- onError: function (error) {
1049
- hasError = true;
1050
- caughtError = error;
1051
- }
1052
- };
1053
- /**
1054
- * Call a function while guarding against errors that happens within it.
1055
- * Returns an error if it throws, otherwise null.
1056
- *
1057
- * In production, this is implemented using a try-catch. The reason we don't
1058
- * use a try-catch directly is so that we can swap out a different
1059
- * implementation in DEV mode.
1060
- *
1061
- * @param {String} name of the guard to use for logging or debugging
1062
- * @param {Function} func The function to invoke
1063
- * @param {*} context The context to use when calling the function
1064
- * @param {...*} args Arguments for function
1065
- */
1066
-
1067
- function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
1068
- hasError = false;
1069
- caughtError = null;
1070
- invokeGuardedCallbackImpl$1.apply(reporter, arguments);
1071
- }
1072
- /**
1073
- * Same as invokeGuardedCallback, but instead of returning an error, it stores
1074
- * it in a global so it can be rethrown by `rethrowCaughtError` later.
1075
- * TODO: See if caughtError and rethrowError can be unified.
1076
- *
1077
- * @param {String} name of the guard to use for logging or debugging
1078
- * @param {Function} func The function to invoke
1079
- * @param {*} context The context to use when calling the function
1080
- * @param {...*} args Arguments for function
1081
- */
1082
-
1083
- function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
1084
- invokeGuardedCallback.apply(this, arguments);
1085
-
1086
- if (hasError) {
1087
- var error = clearCaughtError();
1088
-
1089
- if (!hasRethrowError) {
1090
- hasRethrowError = true;
1091
- rethrowError = error;
1092
1257
  }
1093
- }
1094
- }
1095
- /**
1096
- * During execution of guarded functions we will capture the first error which
1097
- * we will rethrow to be handled by the top level error handler.
1098
- */
1099
1258
 
1100
- function rethrowCaughtError() {
1101
- if (hasRethrowError) {
1102
- var error = rethrowError;
1103
- hasRethrowError = false;
1104
- rethrowError = null;
1105
- throw error;
1106
- }
1107
- }
1108
- function clearCaughtError() {
1109
- if (hasError) {
1110
- var error = caughtError;
1111
- hasError = false;
1112
- caughtError = null;
1113
- return error;
1114
- } else {
1115
- throw new Error('clearCaughtError was called but no error was captured. This error ' + 'is likely caused by a bug in React. Please file an issue.');
1116
- }
1117
- }
1259
+ function validateClassInstance(inst, methodName) {
1260
+ if (!inst) {
1261
+ // This is probably too relaxed but it's existing behavior.
1262
+ return
1263
+ }
1118
1264
 
1119
- var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
1265
+ if (get(inst)) {
1266
+ // This is a public instance indeed.
1267
+ return
1268
+ }
1120
1269
 
1121
- function isArray(a) {
1122
- return isArrayImpl(a);
1123
- }
1270
+ var received
1271
+ var stringified = String(inst)
1124
1272
 
1125
- var SecretInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1126
- var EventInternals = SecretInternals.Events;
1127
- var getInstanceFromNode = EventInternals[0];
1128
- var getNodeFromInstance = EventInternals[1];
1129
- var getFiberCurrentPropsFromNode = EventInternals[2];
1130
- var enqueueStateRestore = EventInternals[3];
1131
- var restoreStateIfNeeded = EventInternals[4];
1132
- var reactAct = React.unstable_act;
1273
+ if (isArray(inst)) {
1274
+ received = 'an array'
1275
+ } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
1276
+ received = 'a DOM node'
1277
+ } else if (stringified === '[object Object]') {
1278
+ received = 'object with keys {' + Object.keys(inst).join(', ') + '}'
1279
+ } else {
1280
+ received = stringified
1281
+ }
1133
1282
 
1134
- function Event(suffix) {}
1283
+ throw new Error(
1284
+ methodName +
1285
+ '(...): the first argument must be a React class instance. ' +
1286
+ ('Instead received: ' + received + '.')
1287
+ )
1288
+ }
1289
+ /**
1290
+ * Utilities for making it easy to test React components.
1291
+ *
1292
+ * See https://reactjs.org/docs/test-utils.html
1293
+ *
1294
+ * Todo: Support the entire DOM.scry query syntax. For now, these simple
1295
+ * utilities will suffice for testing purposes.
1296
+ * @lends ReactTestUtils
1297
+ */
1135
1298
 
1136
- var hasWarnedAboutDeprecatedMockComponent = false;
1137
- /**
1138
- * @class ReactTestUtils
1139
- */
1299
+ var didWarnAboutReactTestUtilsDeprecation = false
1140
1300
 
1141
- function findAllInRenderedFiberTreeInternal(fiber, test) {
1142
- if (!fiber) {
1143
- return [];
1144
- }
1301
+ function renderIntoDocument(element) {
1302
+ {
1303
+ if (!didWarnAboutReactTestUtilsDeprecation) {
1304
+ didWarnAboutReactTestUtilsDeprecation = true
1145
1305
 
1146
- var currentParent = findCurrentFiberUsingSlowPath(fiber);
1306
+ error(
1307
+ 'ReactDOMTestUtils is deprecated and will be removed in a future ' +
1308
+ 'major release, because it exposes internal implementation details ' +
1309
+ 'that are highly likely to change between releases. Upgrade to a ' +
1310
+ 'modern testing library, such as @testing-library/react. See ' +
1311
+ 'https://react.dev/warnings/react-dom-test-utils for more info.'
1312
+ )
1313
+ }
1314
+ }
1147
1315
 
1148
- if (!currentParent) {
1149
- return [];
1150
- }
1316
+ var div = document.createElement('div') // None of our tests actually require attaching the container to the
1317
+ // DOM, and doing so creates a mess that we rely on test isolation to
1318
+ // clean up, so we're going to stop honoring the name of this method
1319
+ // (and probably rename it eventually) if no problems arise.
1320
+ // document.documentElement.appendChild(div);
1151
1321
 
1152
- var node = currentParent;
1153
- var ret = [];
1322
+ return ReactDOM.render(element, div)
1323
+ }
1154
1324
 
1155
- while (true) {
1156
- if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionComponent) {
1157
- var publicInst = node.stateNode;
1325
+ function isElement(element) {
1326
+ return React.isValidElement(element)
1327
+ }
1158
1328
 
1159
- if (test(publicInst)) {
1160
- ret.push(publicInst);
1161
- }
1329
+ function isElementOfType(inst, convenienceConstructor) {
1330
+ return React.isValidElement(inst) && inst.type === convenienceConstructor
1162
1331
  }
1163
1332
 
1164
- if (node.child) {
1165
- node.child.return = node;
1166
- node = node.child;
1167
- continue;
1333
+ function isDOMComponent(inst) {
1334
+ return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName)
1168
1335
  }
1169
1336
 
1170
- if (node === currentParent) {
1171
- return ret;
1337
+ function isDOMComponentElement(inst) {
1338
+ return !!(inst && React.isValidElement(inst) && !!inst.tagName)
1172
1339
  }
1173
1340
 
1174
- while (!node.sibling) {
1175
- if (!node.return || node.return === currentParent) {
1176
- return ret;
1341
+ function isCompositeComponent(inst) {
1342
+ if (isDOMComponent(inst)) {
1343
+ // Accessing inst.setState warns; just return false as that'll be what
1344
+ // this returns when we have DOM nodes as refs directly
1345
+ return false
1177
1346
  }
1178
1347
 
1179
- node = node.return;
1348
+ return (
1349
+ inst != null &&
1350
+ typeof inst.render === 'function' &&
1351
+ typeof inst.setState === 'function'
1352
+ )
1180
1353
  }
1181
1354
 
1182
- node.sibling.return = node.return;
1183
- node = node.sibling;
1184
- }
1185
- }
1186
-
1187
- function validateClassInstance(inst, methodName) {
1188
- if (!inst) {
1189
- // This is probably too relaxed but it's existing behavior.
1190
- return;
1191
- }
1192
-
1193
- if (get(inst)) {
1194
- // This is a public instance indeed.
1195
- return;
1196
- }
1197
-
1198
- var received;
1199
- var stringified = String(inst);
1200
-
1201
- if (isArray(inst)) {
1202
- received = 'an array';
1203
- } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
1204
- received = 'a DOM node';
1205
- } else if (stringified === '[object Object]') {
1206
- received = 'object with keys {' + Object.keys(inst).join(', ') + '}';
1207
- } else {
1208
- received = stringified;
1209
- }
1210
-
1211
- throw new Error(methodName + "(...): the first argument must be a React class instance. " + ("Instead received: " + received + "."));
1212
- }
1213
- /**
1214
- * Utilities for making it easy to test React components.
1215
- *
1216
- * See https://reactjs.org/docs/test-utils.html
1217
- *
1218
- * Todo: Support the entire DOM.scry query syntax. For now, these simple
1219
- * utilities will suffice for testing purposes.
1220
- * @lends ReactTestUtils
1221
- */
1222
-
1223
-
1224
- var didWarnAboutReactTestUtilsDeprecation = false;
1225
-
1226
- function renderIntoDocument(element) {
1227
- {
1228
- if (!didWarnAboutReactTestUtilsDeprecation) {
1229
- didWarnAboutReactTestUtilsDeprecation = true;
1355
+ function isCompositeComponentWithType(inst, type) {
1356
+ if (!isCompositeComponent(inst)) {
1357
+ return false
1358
+ }
1230
1359
 
1231
- error('ReactDOMTestUtils is deprecated and will be removed in a future ' + 'major release, because it exposes internal implementation details ' + 'that are highly likely to change between releases. Upgrade to a ' + 'modern testing library, such as @testing-library/react. See ' + 'https://react.dev/warnings/react-dom-test-utils for more info.');
1360
+ var internalInstance = get(inst)
1361
+ var constructor = internalInstance.type
1362
+ return constructor === type
1232
1363
  }
1233
- }
1234
-
1235
- var div = document.createElement('div'); // None of our tests actually require attaching the container to the
1236
- // DOM, and doing so creates a mess that we rely on test isolation to
1237
- // clean up, so we're going to stop honoring the name of this method
1238
- // (and probably rename it eventually) if no problems arise.
1239
- // document.documentElement.appendChild(div);
1240
1364
 
1241
- return ReactDOM.render(element, div);
1242
- }
1243
-
1244
- function isElement(element) {
1245
- return React.isValidElement(element);
1246
- }
1365
+ function findAllInRenderedTree(inst, test) {
1366
+ validateClassInstance(inst, 'findAllInRenderedTree')
1247
1367
 
1248
- function isElementOfType(inst, convenienceConstructor) {
1249
- return React.isValidElement(inst) && inst.type === convenienceConstructor;
1250
- }
1251
-
1252
- function isDOMComponent(inst) {
1253
- return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
1254
- }
1255
-
1256
- function isDOMComponentElement(inst) {
1257
- return !!(inst && React.isValidElement(inst) && !!inst.tagName);
1258
- }
1259
-
1260
- function isCompositeComponent(inst) {
1261
- if (isDOMComponent(inst)) {
1262
- // Accessing inst.setState warns; just return false as that'll be what
1263
- // this returns when we have DOM nodes as refs directly
1264
- return false;
1265
- }
1368
+ if (!inst) {
1369
+ return []
1370
+ }
1266
1371
 
1267
- return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
1268
- }
1372
+ var internalInstance = get(inst)
1373
+ return findAllInRenderedFiberTreeInternal(internalInstance, test)
1374
+ }
1375
+ /**
1376
+ * Finds all instances of components in the rendered tree that are DOM
1377
+ * components with the class name matching `className`.
1378
+ * @return {array} an array of all the matches.
1379
+ */
1269
1380
 
1270
- function isCompositeComponentWithType(inst, type) {
1271
- if (!isCompositeComponent(inst)) {
1272
- return false;
1273
- }
1381
+ function scryRenderedDOMComponentsWithClass(root, classNames) {
1382
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithClass')
1383
+ return findAllInRenderedTree(root, function (inst) {
1384
+ if (isDOMComponent(inst)) {
1385
+ var className = inst.className
1274
1386
 
1275
- var internalInstance = get(inst);
1276
- var constructor = internalInstance.type;
1277
- return constructor === type;
1278
- }
1387
+ if (typeof className !== 'string') {
1388
+ // SVG, probably.
1389
+ className = inst.getAttribute('class') || ''
1390
+ }
1279
1391
 
1280
- function findAllInRenderedTree(inst, test) {
1281
- validateClassInstance(inst, 'findAllInRenderedTree');
1392
+ var classList = className.split(/\s+/)
1282
1393
 
1283
- if (!inst) {
1284
- return [];
1285
- }
1394
+ if (!isArray(classNames)) {
1395
+ if (classNames === undefined) {
1396
+ throw new Error(
1397
+ 'TestUtils.scryRenderedDOMComponentsWithClass expects a ' +
1398
+ 'className as a second argument.'
1399
+ )
1400
+ }
1286
1401
 
1287
- var internalInstance = get(inst);
1288
- return findAllInRenderedFiberTreeInternal(internalInstance, test);
1289
- }
1290
- /**
1291
- * Finds all instances of components in the rendered tree that are DOM
1292
- * components with the class name matching `className`.
1293
- * @return {array} an array of all the matches.
1294
- */
1402
+ classNames = classNames.split(/\s+/)
1403
+ }
1295
1404
 
1405
+ return classNames.every(function (name) {
1406
+ return classList.indexOf(name) !== -1
1407
+ })
1408
+ }
1296
1409
 
1297
- function scryRenderedDOMComponentsWithClass(root, classNames) {
1298
- validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
1299
- return findAllInRenderedTree(root, function (inst) {
1300
- if (isDOMComponent(inst)) {
1301
- var className = inst.className;
1410
+ return false
1411
+ })
1412
+ }
1413
+ /**
1414
+ * Like scryRenderedDOMComponentsWithClass but expects there to be one result,
1415
+ * and returns that one result, or throws exception if there is any other
1416
+ * number of matches besides one.
1417
+ * @return {!ReactDOMComponent} The one match.
1418
+ */
1302
1419
 
1303
- if (typeof className !== 'string') {
1304
- // SVG, probably.
1305
- className = inst.getAttribute('class') || '';
1420
+ function findRenderedDOMComponentWithClass(root, className) {
1421
+ validateClassInstance(root, 'findRenderedDOMComponentWithClass')
1422
+ var all = scryRenderedDOMComponentsWithClass(root, className)
1423
+
1424
+ if (all.length !== 1) {
1425
+ throw new Error(
1426
+ 'Did not find exactly one match (found: ' +
1427
+ all.length +
1428
+ ') ' +
1429
+ 'for class:' +
1430
+ className
1431
+ )
1306
1432
  }
1307
1433
 
1308
- var classList = className.split(/\s+/);
1434
+ return all[0]
1435
+ }
1436
+ /**
1437
+ * Finds all instances of components in the rendered tree that are DOM
1438
+ * components with the tag name matching `tagName`.
1439
+ * @return {array} an array of all the matches.
1440
+ */
1309
1441
 
1310
- if (!isArray(classNames)) {
1311
- if (classNames === undefined) {
1312
- throw new Error('TestUtils.scryRenderedDOMComponentsWithClass expects a ' + 'className as a second argument.');
1313
- }
1442
+ function scryRenderedDOMComponentsWithTag(root, tagName) {
1443
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithTag')
1444
+ return findAllInRenderedTree(root, function (inst) {
1445
+ return (
1446
+ isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase()
1447
+ )
1448
+ })
1449
+ }
1450
+ /**
1451
+ * Like scryRenderedDOMComponentsWithTag but expects there to be one result,
1452
+ * and returns that one result, or throws exception if there is any other
1453
+ * number of matches besides one.
1454
+ * @return {!ReactDOMComponent} The one match.
1455
+ */
1314
1456
 
1315
- classNames = classNames.split(/\s+/);
1457
+ function findRenderedDOMComponentWithTag(root, tagName) {
1458
+ validateClassInstance(root, 'findRenderedDOMComponentWithTag')
1459
+ var all = scryRenderedDOMComponentsWithTag(root, tagName)
1460
+
1461
+ if (all.length !== 1) {
1462
+ throw new Error(
1463
+ 'Did not find exactly one match (found: ' +
1464
+ all.length +
1465
+ ') ' +
1466
+ 'for tag:' +
1467
+ tagName
1468
+ )
1316
1469
  }
1317
1470
 
1318
- return classNames.every(function (name) {
1319
- return classList.indexOf(name) !== -1;
1320
- });
1471
+ return all[0]
1321
1472
  }
1473
+ /**
1474
+ * Finds all instances of components with type equal to `componentType`.
1475
+ * @return {array} an array of all the matches.
1476
+ */
1322
1477
 
1323
- return false;
1324
- });
1325
- }
1326
- /**
1327
- * Like scryRenderedDOMComponentsWithClass but expects there to be one result,
1328
- * and returns that one result, or throws exception if there is any other
1329
- * number of matches besides one.
1330
- * @return {!ReactDOMComponent} The one match.
1331
- */
1332
-
1333
-
1334
- function findRenderedDOMComponentWithClass(root, className) {
1335
- validateClassInstance(root, 'findRenderedDOMComponentWithClass');
1336
- var all = scryRenderedDOMComponentsWithClass(root, className);
1337
-
1338
- if (all.length !== 1) {
1339
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
1340
- }
1341
-
1342
- return all[0];
1343
- }
1344
- /**
1345
- * Finds all instances of components in the rendered tree that are DOM
1346
- * components with the tag name matching `tagName`.
1347
- * @return {array} an array of all the matches.
1348
- */
1349
-
1350
-
1351
- function scryRenderedDOMComponentsWithTag(root, tagName) {
1352
- validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
1353
- return findAllInRenderedTree(root, function (inst) {
1354
- return isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
1355
- });
1356
- }
1357
- /**
1358
- * Like scryRenderedDOMComponentsWithTag but expects there to be one result,
1359
- * and returns that one result, or throws exception if there is any other
1360
- * number of matches besides one.
1361
- * @return {!ReactDOMComponent} The one match.
1362
- */
1363
-
1364
-
1365
- function findRenderedDOMComponentWithTag(root, tagName) {
1366
- validateClassInstance(root, 'findRenderedDOMComponentWithTag');
1367
- var all = scryRenderedDOMComponentsWithTag(root, tagName);
1368
-
1369
- if (all.length !== 1) {
1370
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
1371
- }
1372
-
1373
- return all[0];
1374
- }
1375
- /**
1376
- * Finds all instances of components with type equal to `componentType`.
1377
- * @return {array} an array of all the matches.
1378
- */
1379
-
1380
-
1381
- function scryRenderedComponentsWithType(root, componentType) {
1382
- validateClassInstance(root, 'scryRenderedComponentsWithType');
1383
- return findAllInRenderedTree(root, function (inst) {
1384
- return isCompositeComponentWithType(inst, componentType);
1385
- });
1386
- }
1387
- /**
1388
- * Same as `scryRenderedComponentsWithType` but expects there to be one result
1389
- * and returns that one result, or throws exception if there is any other
1390
- * number of matches besides one.
1391
- * @return {!ReactComponent} The one match.
1392
- */
1393
-
1394
-
1395
- function findRenderedComponentWithType(root, componentType) {
1396
- validateClassInstance(root, 'findRenderedComponentWithType');
1397
- var all = scryRenderedComponentsWithType(root, componentType);
1398
-
1399
- if (all.length !== 1) {
1400
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
1401
- }
1402
-
1403
- return all[0];
1404
- }
1405
- /**
1406
- * Pass a mocked component module to this method to augment it with
1407
- * useful methods that allow it to be used as a dummy React component.
1408
- * Instead of rendering as usual, the component will become a simple
1409
- * <div> containing any provided children.
1410
- *
1411
- * @param {object} module the mock function object exported from a
1412
- * module that defines the component to be mocked
1413
- * @param {?string} mockTagName optional dummy root tag name to return
1414
- * from render method (overrides
1415
- * module.mockTagName if provided)
1416
- * @return {object} the ReactTestUtils object (for chaining)
1417
- */
1418
-
1478
+ function scryRenderedComponentsWithType(root, componentType) {
1479
+ validateClassInstance(root, 'scryRenderedComponentsWithType')
1480
+ return findAllInRenderedTree(root, function (inst) {
1481
+ return isCompositeComponentWithType(inst, componentType)
1482
+ })
1483
+ }
1484
+ /**
1485
+ * Same as `scryRenderedComponentsWithType` but expects there to be one result
1486
+ * and returns that one result, or throws exception if there is any other
1487
+ * number of matches besides one.
1488
+ * @return {!ReactComponent} The one match.
1489
+ */
1419
1490
 
1420
- function mockComponent(module, mockTagName) {
1421
- {
1422
- if (!hasWarnedAboutDeprecatedMockComponent) {
1423
- hasWarnedAboutDeprecatedMockComponent = true;
1491
+ function findRenderedComponentWithType(root, componentType) {
1492
+ validateClassInstance(root, 'findRenderedComponentWithType')
1493
+ var all = scryRenderedComponentsWithType(root, componentType)
1494
+
1495
+ if (all.length !== 1) {
1496
+ throw new Error(
1497
+ 'Did not find exactly one match (found: ' +
1498
+ all.length +
1499
+ ') ' +
1500
+ 'for componentType:' +
1501
+ componentType
1502
+ )
1503
+ }
1424
1504
 
1425
- warn('ReactTestUtils.mockComponent() is deprecated. ' + 'Use shallow rendering or jest.mock() instead.\n\n' + 'See https://reactjs.org/link/test-utils-mock-component for more information.');
1505
+ return all[0]
1426
1506
  }
1427
- }
1507
+ /**
1508
+ * Pass a mocked component module to this method to augment it with
1509
+ * useful methods that allow it to be used as a dummy React component.
1510
+ * Instead of rendering as usual, the component will become a simple
1511
+ * <div> containing any provided children.
1512
+ *
1513
+ * @param {object} module the mock function object exported from a
1514
+ * module that defines the component to be mocked
1515
+ * @param {?string} mockTagName optional dummy root tag name to return
1516
+ * from render method (overrides
1517
+ * module.mockTagName if provided)
1518
+ * @return {object} the ReactTestUtils object (for chaining)
1519
+ */
1428
1520
 
1429
- mockTagName = mockTagName || module.mockTagName || 'div';
1430
- module.prototype.render.mockImplementation(function () {
1431
- return React.createElement(mockTagName, null, this.props.children);
1432
- });
1433
- return this;
1434
- }
1521
+ function mockComponent(module, mockTagName) {
1522
+ {
1523
+ if (!hasWarnedAboutDeprecatedMockComponent) {
1524
+ hasWarnedAboutDeprecatedMockComponent = true
1435
1525
 
1436
- function nativeTouchData(x, y) {
1437
- return {
1438
- touches: [{
1439
- pageX: x,
1440
- pageY: y
1441
- }]
1442
- };
1443
- } // Start of inline: the below functions were inlined from
1444
- // EventPropagator.js, as they deviated from ReactDOM's newer
1445
- // implementations.
1526
+ warn(
1527
+ 'ReactTestUtils.mockComponent() is deprecated. ' +
1528
+ 'Use shallow rendering or jest.mock() instead.\n\n' +
1529
+ 'See https://reactjs.org/link/test-utils-mock-component for more information.'
1530
+ )
1531
+ }
1532
+ }
1446
1533
 
1447
- /**
1448
- * Dispatch the event to the listener.
1449
- * @param {SyntheticEvent} event SyntheticEvent to handle
1450
- * @param {function} listener Application-level callback
1451
- * @param {*} inst Internal component instance
1452
- */
1534
+ mockTagName = mockTagName || module.mockTagName || 'div'
1535
+ module.prototype.render.mockImplementation(function () {
1536
+ return React.createElement(mockTagName, null, this.props.children)
1537
+ })
1538
+ return this
1539
+ }
1453
1540
 
1541
+ function nativeTouchData(x, y) {
1542
+ return {
1543
+ touches: [
1544
+ {
1545
+ pageX: x,
1546
+ pageY: y,
1547
+ },
1548
+ ],
1549
+ }
1550
+ } // Start of inline: the below functions were inlined from
1551
+ // EventPropagator.js, as they deviated from ReactDOM's newer
1552
+ // implementations.
1454
1553
 
1455
- function executeDispatch(event, listener, inst) {
1456
- var type = event.type || 'unknown-event';
1457
- event.currentTarget = getNodeFromInstance(inst);
1458
- invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
1459
- event.currentTarget = null;
1460
- }
1461
- /**
1462
- * Standard/simple iteration through an event's collected dispatches.
1463
- */
1554
+ /**
1555
+ * Dispatch the event to the listener.
1556
+ * @param {SyntheticEvent} event SyntheticEvent to handle
1557
+ * @param {function} listener Application-level callback
1558
+ * @param {*} inst Internal component instance
1559
+ */
1464
1560
 
1561
+ function executeDispatch(event, listener, inst) {
1562
+ var type = event.type || 'unknown-event'
1563
+ event.currentTarget = getNodeFromInstance(inst)
1564
+ invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event)
1565
+ event.currentTarget = null
1566
+ }
1567
+ /**
1568
+ * Standard/simple iteration through an event's collected dispatches.
1569
+ */
1465
1570
 
1466
- function executeDispatchesInOrder(event) {
1467
- var dispatchListeners = event._dispatchListeners;
1468
- var dispatchInstances = event._dispatchInstances;
1571
+ function executeDispatchesInOrder(event) {
1572
+ var dispatchListeners = event._dispatchListeners
1573
+ var dispatchInstances = event._dispatchInstances
1469
1574
 
1470
- if (isArray(dispatchListeners)) {
1471
- for (var i = 0; i < dispatchListeners.length; i++) {
1472
- if (event.isPropagationStopped()) {
1473
- break;
1474
- } // Listeners and Instances are two parallel arrays that are always in sync.
1575
+ if (isArray(dispatchListeners)) {
1576
+ for (var i = 0; i < dispatchListeners.length; i++) {
1577
+ if (event.isPropagationStopped()) {
1578
+ break
1579
+ } // Listeners and Instances are two parallel arrays that are always in sync.
1475
1580
 
1581
+ executeDispatch(event, dispatchListeners[i], dispatchInstances[i])
1582
+ }
1583
+ } else if (dispatchListeners) {
1584
+ executeDispatch(event, dispatchListeners, dispatchInstances)
1585
+ }
1476
1586
 
1477
- executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
1587
+ event._dispatchListeners = null
1588
+ event._dispatchInstances = null
1478
1589
  }
1479
- } else if (dispatchListeners) {
1480
- executeDispatch(event, dispatchListeners, dispatchInstances);
1481
- }
1482
-
1483
- event._dispatchListeners = null;
1484
- event._dispatchInstances = null;
1485
- }
1486
- /**
1487
- * Dispatches an event and releases it back into the pool, unless persistent.
1488
- *
1489
- * @param {?object} event Synthetic event to be dispatched.
1490
- * @private
1491
- */
1492
-
1590
+ /**
1591
+ * Dispatches an event and releases it back into the pool, unless persistent.
1592
+ *
1593
+ * @param {?object} event Synthetic event to be dispatched.
1594
+ * @private
1595
+ */
1493
1596
 
1494
- var executeDispatchesAndRelease = function (event) {
1495
- if (event) {
1496
- executeDispatchesInOrder(event);
1597
+ var executeDispatchesAndRelease = function (event) {
1598
+ if (event) {
1599
+ executeDispatchesInOrder(event)
1497
1600
 
1498
- if (!event.isPersistent()) {
1499
- event.constructor.release(event);
1601
+ if (!event.isPersistent()) {
1602
+ event.constructor.release(event)
1603
+ }
1604
+ }
1500
1605
  }
1501
- }
1502
- };
1503
1606
 
1504
- function isInteractive(tag) {
1505
- return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
1506
- }
1607
+ function isInteractive(tag) {
1608
+ return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'
1609
+ }
1507
1610
 
1508
- function getParent(inst) {
1509
- do {
1510
- inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
1511
- // That is depending on if we want nested subtrees (layers) to bubble
1512
- // events to their parent. We could also go through parentNode on the
1513
- // host node but that wouldn't work for React Native and doesn't let us
1514
- // do the portal feature.
1515
- } while (inst && inst.tag !== HostComponent);
1611
+ function getParent(inst) {
1612
+ do {
1613
+ inst = inst.return // TODO: If this is a HostRoot we might want to bail out.
1614
+ // That is depending on if we want nested subtrees (layers) to bubble
1615
+ // events to their parent. We could also go through parentNode on the
1616
+ // host node but that wouldn't work for React Native and doesn't let us
1617
+ // do the portal feature.
1618
+ } while (inst && inst.tag !== HostComponent)
1619
+
1620
+ if (inst) {
1621
+ return inst
1622
+ }
1516
1623
 
1517
- if (inst) {
1518
- return inst;
1519
- }
1624
+ return null
1625
+ }
1626
+ /**
1627
+ * Simulates the traversal of a two-phase, capture/bubble event dispatch.
1628
+ */
1520
1629
 
1521
- return null;
1522
- }
1523
- /**
1524
- * Simulates the traversal of a two-phase, capture/bubble event dispatch.
1525
- */
1630
+ function traverseTwoPhase(inst, fn, arg) {
1631
+ var path = []
1526
1632
 
1633
+ while (inst) {
1634
+ path.push(inst)
1635
+ inst = getParent(inst)
1636
+ }
1527
1637
 
1528
- function traverseTwoPhase(inst, fn, arg) {
1529
- var path = [];
1638
+ var i
1530
1639
 
1531
- while (inst) {
1532
- path.push(inst);
1533
- inst = getParent(inst);
1534
- }
1640
+ for (i = path.length; i-- > 0; ) {
1641
+ fn(path[i], 'captured', arg)
1642
+ }
1535
1643
 
1536
- var i;
1644
+ for (i = 0; i < path.length; i++) {
1645
+ fn(path[i], 'bubbled', arg)
1646
+ }
1647
+ }
1537
1648
 
1538
- for (i = path.length; i-- > 0;) {
1539
- fn(path[i], 'captured', arg);
1540
- }
1649
+ function shouldPreventMouseEvent(name, type, props) {
1650
+ switch (name) {
1651
+ case 'onClick':
1652
+ case 'onClickCapture':
1653
+ case 'onDoubleClick':
1654
+ case 'onDoubleClickCapture':
1655
+ case 'onMouseDown':
1656
+ case 'onMouseDownCapture':
1657
+ case 'onMouseMove':
1658
+ case 'onMouseMoveCapture':
1659
+ case 'onMouseUp':
1660
+ case 'onMouseUpCapture':
1661
+ case 'onMouseEnter':
1662
+ return !!(props.disabled && isInteractive(type))
1663
+
1664
+ default:
1665
+ return false
1666
+ }
1667
+ }
1668
+ /**
1669
+ * @param {object} inst The instance, which is the source of events.
1670
+ * @param {string} registrationName Name of listener (e.g. `onClick`).
1671
+ * @return {?function} The stored callback.
1672
+ */
1541
1673
 
1542
- for (i = 0; i < path.length; i++) {
1543
- fn(path[i], 'bubbled', arg);
1544
- }
1545
- }
1674
+ function getListener(inst, registrationName) {
1675
+ // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
1676
+ // live here; needs to be moved to a better place soon
1677
+ var stateNode = inst.stateNode
1546
1678
 
1547
- function shouldPreventMouseEvent(name, type, props) {
1548
- switch (name) {
1549
- case 'onClick':
1550
- case 'onClickCapture':
1551
- case 'onDoubleClick':
1552
- case 'onDoubleClickCapture':
1553
- case 'onMouseDown':
1554
- case 'onMouseDownCapture':
1555
- case 'onMouseMove':
1556
- case 'onMouseMoveCapture':
1557
- case 'onMouseUp':
1558
- case 'onMouseUpCapture':
1559
- case 'onMouseEnter':
1560
- return !!(props.disabled && isInteractive(type));
1561
-
1562
- default:
1563
- return false;
1564
- }
1565
- }
1566
- /**
1567
- * @param {object} inst The instance, which is the source of events.
1568
- * @param {string} registrationName Name of listener (e.g. `onClick`).
1569
- * @return {?function} The stored callback.
1570
- */
1679
+ if (!stateNode) {
1680
+ // Work in progress (ex: onload events in incremental mode).
1681
+ return null
1682
+ }
1571
1683
 
1684
+ var props = getFiberCurrentPropsFromNode(stateNode)
1572
1685
 
1573
- function getListener(inst, registrationName) {
1574
- // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
1575
- // live here; needs to be moved to a better place soon
1576
- var stateNode = inst.stateNode;
1686
+ if (!props) {
1687
+ // Work in progress.
1688
+ return null
1689
+ }
1577
1690
 
1578
- if (!stateNode) {
1579
- // Work in progress (ex: onload events in incremental mode).
1580
- return null;
1581
- }
1691
+ var listener = props[registrationName]
1582
1692
 
1583
- var props = getFiberCurrentPropsFromNode(stateNode);
1693
+ if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
1694
+ return null
1695
+ }
1584
1696
 
1585
- if (!props) {
1586
- // Work in progress.
1587
- return null;
1588
- }
1697
+ if (listener && typeof listener !== 'function') {
1698
+ throw new Error(
1699
+ 'Expected `' +
1700
+ registrationName +
1701
+ '` listener to be a function, instead got a value of `' +
1702
+ typeof listener +
1703
+ '` type.'
1704
+ )
1705
+ }
1589
1706
 
1590
- var listener = props[registrationName];
1707
+ return listener
1708
+ }
1591
1709
 
1592
- if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
1593
- return null;
1594
- }
1710
+ function listenerAtPhase(inst, event, propagationPhase) {
1711
+ var registrationName = event._reactName
1595
1712
 
1596
- if (listener && typeof listener !== 'function') {
1597
- throw new Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type.");
1598
- }
1713
+ if (propagationPhase === 'captured') {
1714
+ registrationName += 'Capture'
1715
+ }
1599
1716
 
1600
- return listener;
1601
- }
1717
+ return getListener(inst, registrationName)
1718
+ }
1602
1719
 
1603
- function listenerAtPhase(inst, event, propagationPhase) {
1604
- var registrationName = event._reactName;
1720
+ function accumulateDispatches(inst, ignoredDirection, event) {
1721
+ if (inst && event && event._reactName) {
1722
+ var registrationName = event._reactName
1723
+ var listener = getListener(inst, registrationName)
1605
1724
 
1606
- if (propagationPhase === 'captured') {
1607
- registrationName += 'Capture';
1608
- }
1725
+ if (listener) {
1726
+ if (event._dispatchListeners == null) {
1727
+ event._dispatchListeners = []
1728
+ }
1609
1729
 
1610
- return getListener(inst, registrationName);
1611
- }
1730
+ if (event._dispatchInstances == null) {
1731
+ event._dispatchInstances = []
1732
+ }
1612
1733
 
1613
- function accumulateDispatches(inst, ignoredDirection, event) {
1614
- if (inst && event && event._reactName) {
1615
- var registrationName = event._reactName;
1616
- var listener = getListener(inst, registrationName);
1734
+ event._dispatchListeners.push(listener)
1617
1735
 
1618
- if (listener) {
1619
- if (event._dispatchListeners == null) {
1620
- event._dispatchListeners = [];
1736
+ event._dispatchInstances.push(inst)
1737
+ }
1621
1738
  }
1739
+ }
1622
1740
 
1623
- if (event._dispatchInstances == null) {
1624
- event._dispatchInstances = [];
1741
+ function accumulateDirectionalDispatches(inst, phase, event) {
1742
+ {
1743
+ if (!inst) {
1744
+ error('Dispatching inst must not be null')
1745
+ }
1625
1746
  }
1626
1747
 
1627
- event._dispatchListeners.push(listener);
1748
+ var listener = listenerAtPhase(inst, event, phase)
1628
1749
 
1629
- event._dispatchInstances.push(inst);
1630
- }
1631
- }
1632
- }
1750
+ if (listener) {
1751
+ if (event._dispatchListeners == null) {
1752
+ event._dispatchListeners = []
1753
+ }
1633
1754
 
1634
- function accumulateDirectionalDispatches(inst, phase, event) {
1635
- {
1636
- if (!inst) {
1637
- error('Dispatching inst must not be null');
1638
- }
1639
- }
1755
+ if (event._dispatchInstances == null) {
1756
+ event._dispatchInstances = []
1757
+ }
1640
1758
 
1641
- var listener = listenerAtPhase(inst, event, phase);
1759
+ event._dispatchListeners.push(listener)
1642
1760
 
1643
- if (listener) {
1644
- if (event._dispatchListeners == null) {
1645
- event._dispatchListeners = [];
1761
+ event._dispatchInstances.push(inst)
1762
+ }
1646
1763
  }
1647
1764
 
1648
- if (event._dispatchInstances == null) {
1649
- event._dispatchInstances = [];
1765
+ function accumulateDirectDispatchesSingle(event) {
1766
+ if (event && event._reactName) {
1767
+ accumulateDispatches(event._targetInst, null, event)
1768
+ }
1650
1769
  }
1651
1770
 
1652
- event._dispatchListeners.push(listener);
1653
-
1654
- event._dispatchInstances.push(inst);
1655
- }
1656
- }
1657
-
1658
- function accumulateDirectDispatchesSingle(event) {
1659
- if (event && event._reactName) {
1660
- accumulateDispatches(event._targetInst, null, event);
1661
- }
1662
- }
1771
+ function accumulateTwoPhaseDispatchesSingle(event) {
1772
+ if (event && event._reactName) {
1773
+ traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event)
1774
+ }
1775
+ } // End of inline
1776
+
1777
+ var Simulate = {}
1778
+ var directDispatchEventTypes = new Set([
1779
+ 'mouseEnter',
1780
+ 'mouseLeave',
1781
+ 'pointerEnter',
1782
+ 'pointerLeave',
1783
+ ])
1784
+ /**
1785
+ * Exports:
1786
+ *
1787
+ * - `Simulate.click(Element)`
1788
+ * - `Simulate.mouseMove(Element)`
1789
+ * - `Simulate.change(Element)`
1790
+ * - ... (All keys from event plugin `eventTypes` objects)
1791
+ */
1663
1792
 
1664
- function accumulateTwoPhaseDispatchesSingle(event) {
1665
- if (event && event._reactName) {
1666
- traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
1667
- }
1668
- } // End of inline
1793
+ function makeSimulator(eventType) {
1794
+ return function (domNode, eventData) {
1795
+ if (React.isValidElement(domNode)) {
1796
+ throw new Error(
1797
+ 'TestUtils.Simulate expected a DOM node as the first argument but received ' +
1798
+ 'a React element. Pass the DOM node you wish to simulate the event on instead. ' +
1799
+ 'Note that TestUtils.Simulate will not work if you are using shallow rendering.'
1800
+ )
1801
+ }
1669
1802
 
1803
+ if (isCompositeComponent(domNode)) {
1804
+ throw new Error(
1805
+ 'TestUtils.Simulate expected a DOM node as the first argument but received ' +
1806
+ 'a component instance. Pass the DOM node you wish to simulate the event on instead.'
1807
+ )
1808
+ }
1670
1809
 
1671
- var Simulate = {};
1672
- var directDispatchEventTypes = new Set(['mouseEnter', 'mouseLeave', 'pointerEnter', 'pointerLeave']);
1673
- /**
1674
- * Exports:
1675
- *
1676
- * - `Simulate.click(Element)`
1677
- * - `Simulate.mouseMove(Element)`
1678
- * - `Simulate.change(Element)`
1679
- * - ... (All keys from event plugin `eventTypes` objects)
1680
- */
1810
+ var reactName = 'on' + eventType[0].toUpperCase() + eventType.slice(1)
1811
+ var fakeNativeEvent = new Event()
1812
+ fakeNativeEvent.target = domNode
1813
+ fakeNativeEvent.type = eventType.toLowerCase()
1814
+ var targetInst = getInstanceFromNode(domNode)
1815
+ var event = new SyntheticEvent(
1816
+ reactName,
1817
+ fakeNativeEvent.type,
1818
+ targetInst,
1819
+ fakeNativeEvent,
1820
+ domNode
1821
+ ) // Since we aren't using pooling, always persist the event. This will make
1822
+ // sure it's marked and won't warn when setting additional properties.
1823
+
1824
+ event.persist()
1825
+ assign(event, eventData)
1826
+
1827
+ if (directDispatchEventTypes.has(eventType)) {
1828
+ accumulateDirectDispatchesSingle(event)
1829
+ } else {
1830
+ accumulateTwoPhaseDispatchesSingle(event)
1831
+ }
1681
1832
 
1682
- function makeSimulator(eventType) {
1683
- return function (domNode, eventData) {
1684
- if (React.isValidElement(domNode)) {
1685
- throw new Error('TestUtils.Simulate expected a DOM node as the first argument but received ' + 'a React element. Pass the DOM node you wish to simulate the event on instead. ' + 'Note that TestUtils.Simulate will not work if you are using shallow rendering.');
1833
+ ReactDOM.unstable_batchedUpdates(function () {
1834
+ // Normally extractEvent enqueues a state restore, but we'll just always
1835
+ // do that since we're by-passing it here.
1836
+ enqueueStateRestore(domNode)
1837
+ executeDispatchesAndRelease(event)
1838
+ rethrowCaughtError()
1839
+ })
1840
+ restoreStateIfNeeded()
1841
+ }
1842
+ } // A one-time snapshot with no plans to update. We'll probably want to deprecate Simulate API.
1843
+
1844
+ var simulatedEventTypes = [
1845
+ 'blur',
1846
+ 'cancel',
1847
+ 'click',
1848
+ 'close',
1849
+ 'contextMenu',
1850
+ 'copy',
1851
+ 'cut',
1852
+ 'auxClick',
1853
+ 'doubleClick',
1854
+ 'dragEnd',
1855
+ 'dragStart',
1856
+ 'drop',
1857
+ 'focus',
1858
+ 'input',
1859
+ 'invalid',
1860
+ 'keyDown',
1861
+ 'keyPress',
1862
+ 'keyUp',
1863
+ 'mouseDown',
1864
+ 'mouseUp',
1865
+ 'paste',
1866
+ 'pause',
1867
+ 'play',
1868
+ 'pointerCancel',
1869
+ 'pointerDown',
1870
+ 'pointerUp',
1871
+ 'rateChange',
1872
+ 'reset',
1873
+ 'resize',
1874
+ 'seeked',
1875
+ 'submit',
1876
+ 'touchCancel',
1877
+ 'touchEnd',
1878
+ 'touchStart',
1879
+ 'volumeChange',
1880
+ 'drag',
1881
+ 'dragEnter',
1882
+ 'dragExit',
1883
+ 'dragLeave',
1884
+ 'dragOver',
1885
+ 'mouseMove',
1886
+ 'mouseOut',
1887
+ 'mouseOver',
1888
+ 'pointerMove',
1889
+ 'pointerOut',
1890
+ 'pointerOver',
1891
+ 'scroll',
1892
+ 'toggle',
1893
+ 'touchMove',
1894
+ 'wheel',
1895
+ 'abort',
1896
+ 'animationEnd',
1897
+ 'animationIteration',
1898
+ 'animationStart',
1899
+ 'canPlay',
1900
+ 'canPlayThrough',
1901
+ 'durationChange',
1902
+ 'emptied',
1903
+ 'encrypted',
1904
+ 'ended',
1905
+ 'error',
1906
+ 'gotPointerCapture',
1907
+ 'load',
1908
+ 'loadedData',
1909
+ 'loadedMetadata',
1910
+ 'loadStart',
1911
+ 'lostPointerCapture',
1912
+ 'playing',
1913
+ 'progress',
1914
+ 'seeking',
1915
+ 'stalled',
1916
+ 'suspend',
1917
+ 'timeUpdate',
1918
+ 'transitionEnd',
1919
+ 'waiting',
1920
+ 'mouseEnter',
1921
+ 'mouseLeave',
1922
+ 'pointerEnter',
1923
+ 'pointerLeave',
1924
+ 'change',
1925
+ 'select',
1926
+ 'beforeInput',
1927
+ 'compositionEnd',
1928
+ 'compositionStart',
1929
+ 'compositionUpdate',
1930
+ ]
1931
+
1932
+ function buildSimulators() {
1933
+ simulatedEventTypes.forEach(function (eventType) {
1934
+ Simulate[eventType] = makeSimulator(eventType)
1935
+ })
1686
1936
  }
1687
1937
 
1688
- if (isCompositeComponent(domNode)) {
1689
- throw new Error('TestUtils.Simulate expected a DOM node as the first argument but received ' + 'a component instance. Pass the DOM node you wish to simulate the event on instead.');
1690
- }
1938
+ buildSimulators()
1939
+ var didWarnAboutUsingAct = false
1940
+ var act = function actWithWarning(callback) {
1941
+ {
1942
+ if (!didWarnAboutUsingAct) {
1943
+ didWarnAboutUsingAct = true
1944
+
1945
+ error(
1946
+ '`ReactDOMTestUtils.act` is deprecated in favor of `React.act`. ' +
1947
+ 'Import `act` from `react` instead of `react-dom/test-utils`. ' +
1948
+ 'See https://react.dev/warnings/react-dom-test-utils for more info.'
1949
+ )
1950
+ }
1951
+ }
1691
1952
 
1692
- var reactName = 'on' + eventType[0].toUpperCase() + eventType.slice(1);
1693
- var fakeNativeEvent = new Event();
1694
- fakeNativeEvent.target = domNode;
1695
- fakeNativeEvent.type = eventType.toLowerCase();
1696
- var targetInst = getInstanceFromNode(domNode);
1697
- var event = new SyntheticEvent(reactName, fakeNativeEvent.type, targetInst, fakeNativeEvent, domNode); // Since we aren't using pooling, always persist the event. This will make
1698
- // sure it's marked and won't warn when setting additional properties.
1699
-
1700
- event.persist();
1701
- assign(event, eventData);
1702
-
1703
- if (directDispatchEventTypes.has(eventType)) {
1704
- accumulateDirectDispatchesSingle(event);
1705
- } else {
1706
- accumulateTwoPhaseDispatchesSingle(event);
1953
+ return reactAct(callback)
1707
1954
  }
1708
1955
 
1709
- ReactDOM.unstable_batchedUpdates(function () {
1710
- // Normally extractEvent enqueues a state restore, but we'll just always
1711
- // do that since we're by-passing it here.
1712
- enqueueStateRestore(domNode);
1713
- executeDispatchesAndRelease(event);
1714
- rethrowCaughtError();
1715
- });
1716
- restoreStateIfNeeded();
1717
- };
1718
- } // A one-time snapshot with no plans to update. We'll probably want to deprecate Simulate API.
1719
-
1720
-
1721
- var simulatedEventTypes = ['blur', 'cancel', 'click', 'close', 'contextMenu', 'copy', 'cut', 'auxClick', 'doubleClick', 'dragEnd', 'dragStart', 'drop', 'focus', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'mouseDown', 'mouseUp', 'paste', 'pause', 'play', 'pointerCancel', 'pointerDown', 'pointerUp', 'rateChange', 'reset', 'resize', 'seeked', 'submit', 'touchCancel', 'touchEnd', 'touchStart', 'volumeChange', 'drag', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'mouseMove', 'mouseOut', 'mouseOver', 'pointerMove', 'pointerOut', 'pointerOver', 'scroll', 'toggle', 'touchMove', 'wheel', 'abort', 'animationEnd', 'animationIteration', 'animationStart', 'canPlay', 'canPlayThrough', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'gotPointerCapture', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'lostPointerCapture', 'playing', 'progress', 'seeking', 'stalled', 'suspend', 'timeUpdate', 'transitionEnd', 'waiting', 'mouseEnter', 'mouseLeave', 'pointerEnter', 'pointerLeave', 'change', 'select', 'beforeInput', 'compositionEnd', 'compositionStart', 'compositionUpdate'];
1722
-
1723
- function buildSimulators() {
1724
- simulatedEventTypes.forEach(function (eventType) {
1725
- Simulate[eventType] = makeSimulator(eventType);
1726
- });
1727
- }
1728
-
1729
- buildSimulators();
1730
- var didWarnAboutUsingAct = false;
1731
- var act = function actWithWarning(callback) {
1732
- {
1733
- if (!didWarnAboutUsingAct) {
1734
- didWarnAboutUsingAct = true;
1735
-
1736
- error('`ReactDOMTestUtils.act` is deprecated in favor of `React.act`. ' + 'Import `act` from `react` instead of `react-dom/test-utils`. ' + 'See https://react.dev/warnings/react-dom-test-utils for more info.');
1737
- }
1738
- }
1739
-
1740
- return reactAct(callback);
1741
- } ;
1742
-
1743
- exports.Simulate = Simulate;
1744
- exports.act = act;
1745
- exports.findAllInRenderedTree = findAllInRenderedTree;
1746
- exports.findRenderedComponentWithType = findRenderedComponentWithType;
1747
- exports.findRenderedDOMComponentWithClass = findRenderedDOMComponentWithClass;
1748
- exports.findRenderedDOMComponentWithTag = findRenderedDOMComponentWithTag;
1749
- exports.isCompositeComponent = isCompositeComponent;
1750
- exports.isCompositeComponentWithType = isCompositeComponentWithType;
1751
- exports.isDOMComponent = isDOMComponent;
1752
- exports.isDOMComponentElement = isDOMComponentElement;
1753
- exports.isElement = isElement;
1754
- exports.isElementOfType = isElementOfType;
1755
- exports.mockComponent = mockComponent;
1756
- exports.nativeTouchData = nativeTouchData;
1757
- exports.renderIntoDocument = renderIntoDocument;
1758
- exports.scryRenderedComponentsWithType = scryRenderedComponentsWithType;
1759
- exports.scryRenderedDOMComponentsWithClass = scryRenderedDOMComponentsWithClass;
1760
- exports.scryRenderedDOMComponentsWithTag = scryRenderedDOMComponentsWithTag;
1761
- exports.traverseTwoPhase = traverseTwoPhase;
1762
- })();
1956
+ exports.Simulate = Simulate
1957
+ exports.act = act
1958
+ exports.findAllInRenderedTree = findAllInRenderedTree
1959
+ exports.findRenderedComponentWithType = findRenderedComponentWithType
1960
+ exports.findRenderedDOMComponentWithClass = findRenderedDOMComponentWithClass
1961
+ exports.findRenderedDOMComponentWithTag = findRenderedDOMComponentWithTag
1962
+ exports.isCompositeComponent = isCompositeComponent
1963
+ exports.isCompositeComponentWithType = isCompositeComponentWithType
1964
+ exports.isDOMComponent = isDOMComponent
1965
+ exports.isDOMComponentElement = isDOMComponentElement
1966
+ exports.isElement = isElement
1967
+ exports.isElementOfType = isElementOfType
1968
+ exports.mockComponent = mockComponent
1969
+ exports.nativeTouchData = nativeTouchData
1970
+ exports.renderIntoDocument = renderIntoDocument
1971
+ exports.scryRenderedComponentsWithType = scryRenderedComponentsWithType
1972
+ exports.scryRenderedDOMComponentsWithClass = scryRenderedDOMComponentsWithClass
1973
+ exports.scryRenderedDOMComponentsWithTag = scryRenderedDOMComponentsWithTag
1974
+ exports.traverseTwoPhase = traverseTwoPhase
1975
+ })()
1763
1976
  }