@bleedingdev/tanstack-redact 0.0.0-stage → 0.2.1

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 (476) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cloudflare/index.d.ts +6 -0
  3. package/dist/cloudflare/index.js +39 -0
  4. package/dist/cloudflare/index.js.map +7 -0
  5. package/dist/core/attributes.d.ts +4 -0
  6. package/dist/core/attributes.js +30 -0
  7. package/dist/core/attributes.js.map +7 -0
  8. package/dist/core/browser.d.ts +9 -0
  9. package/dist/core/browser.js +32 -0
  10. package/dist/core/browser.js.map +7 -0
  11. package/dist/core/class-props.d.ts +1 -0
  12. package/dist/core/class-props.js +15 -0
  13. package/dist/core/class-props.js.map +7 -0
  14. package/dist/core/devtools.d.ts +26 -0
  15. package/dist/core/devtools.js +70 -0
  16. package/dist/core/devtools.js.map +7 -0
  17. package/dist/core/functions.d.ts +6 -0
  18. package/dist/core/functions.js +14 -0
  19. package/dist/core/functions.js.map +7 -0
  20. package/dist/core/index.d.ts +2 -0
  21. package/dist/core/index.js +3 -0
  22. package/dist/core/index.js.map +7 -0
  23. package/dist/core/internal.d.ts +103 -0
  24. package/dist/core/internal.js +43 -0
  25. package/dist/core/internal.js.map +7 -0
  26. package/dist/core/resource-hints.d.ts +7 -0
  27. package/dist/core/resource-hints.js +20 -0
  28. package/dist/core/resource-hints.js.map +7 -0
  29. package/dist/core/types.d.ts +23 -0
  30. package/dist/core/types.js +8 -0
  31. package/dist/core/types.js.map +7 -0
  32. package/dist/core/unitless-style.d.ts +1 -0
  33. package/dist/core/unitless-style.js +5 -0
  34. package/dist/core/unitless-style.js.map +7 -0
  35. package/dist/dom/_all.d.ts +27 -0
  36. package/dist/dom/_all.js +51 -0
  37. package/dist/dom/_all.js.map +7 -0
  38. package/dist/dom/client.d.ts +9 -0
  39. package/dist/dom/client.js +13 -0
  40. package/dist/dom/client.js.map +7 -0
  41. package/dist/dom/commit.d.ts +27 -0
  42. package/dist/dom/commit.js +237 -0
  43. package/dist/dom/commit.js.map +7 -0
  44. package/dist/dom/devtools-effects.d.ts +8 -0
  45. package/dist/dom/devtools-effects.js +80 -0
  46. package/dist/dom/devtools-effects.js.map +7 -0
  47. package/dist/dom/devtools.d.ts +33 -0
  48. package/dist/dom/devtools.js +635 -0
  49. package/dist/dom/devtools.js.map +7 -0
  50. package/dist/dom/dispatcher.d.ts +4 -0
  51. package/dist/dom/dispatcher.js +437 -0
  52. package/dist/dom/dispatcher.js.map +7 -0
  53. package/dist/dom/document-metadata.d.ts +7 -0
  54. package/dist/dom/document-metadata.js +44 -0
  55. package/dist/dom/document-metadata.js.map +7 -0
  56. package/dist/dom/dom.d.ts +11 -0
  57. package/dist/dom/dom.js +165 -0
  58. package/dist/dom/dom.js.map +7 -0
  59. package/dist/dom/error-info.d.ts +2 -0
  60. package/dist/dom/error-info.js +19 -0
  61. package/dist/dom/error-info.js.map +7 -0
  62. package/dist/dom/event-replay.d.ts +13 -0
  63. package/dist/dom/event-replay.js +24 -0
  64. package/dist/dom/event-replay.js.map +7 -0
  65. package/dist/dom/features/activity/full.d.ts +1 -0
  66. package/dist/dom/features/activity/full.js +140 -0
  67. package/dist/dom/features/activity/full.js.map +7 -0
  68. package/dist/dom/features/activity/index.d.ts +1 -0
  69. package/dist/dom/features/activity/index.js +2 -0
  70. package/dist/dom/features/activity/index.js.map +7 -0
  71. package/dist/dom/features/activity/stub.d.ts +1 -0
  72. package/dist/dom/features/activity/stub.js +10 -0
  73. package/dist/dom/features/activity/stub.js.map +7 -0
  74. package/dist/dom/features/class/full.d.ts +1 -0
  75. package/dist/dom/features/class/full.js +208 -0
  76. package/dist/dom/features/class/full.js.map +7 -0
  77. package/dist/dom/features/class/index.d.ts +1 -0
  78. package/dist/dom/features/class/index.js +2 -0
  79. package/dist/dom/features/class/index.js.map +7 -0
  80. package/dist/dom/features/class/stub.d.ts +1 -0
  81. package/dist/dom/features/class/stub.js +46 -0
  82. package/dist/dom/features/class/stub.js.map +7 -0
  83. package/dist/dom/features/context/full.d.ts +4 -0
  84. package/dist/dom/features/context/full.js +103 -0
  85. package/dist/dom/features/context/full.js.map +7 -0
  86. package/dist/dom/features/context/index.d.ts +1 -0
  87. package/dist/dom/features/context/index.js +2 -0
  88. package/dist/dom/features/context/index.js.map +7 -0
  89. package/dist/dom/features/context/stub.d.ts +4 -0
  90. package/dist/dom/features/context/stub.js +21 -0
  91. package/dist/dom/features/context/stub.js.map +7 -0
  92. package/dist/dom/features/forward-ref/full.d.ts +1 -0
  93. package/dist/dom/features/forward-ref/full.js +9 -0
  94. package/dist/dom/features/forward-ref/full.js.map +7 -0
  95. package/dist/dom/features/forward-ref/index.d.ts +1 -0
  96. package/dist/dom/features/forward-ref/index.js +2 -0
  97. package/dist/dom/features/forward-ref/index.js.map +7 -0
  98. package/dist/dom/features/forward-ref/stub.d.ts +1 -0
  99. package/dist/dom/features/forward-ref/stub.js +9 -0
  100. package/dist/dom/features/forward-ref/stub.js.map +7 -0
  101. package/dist/dom/features/fragment-refs/index.d.ts +1 -0
  102. package/dist/dom/features/fragment-refs/index.js +9 -0
  103. package/dist/dom/features/fragment-refs/index.js.map +7 -0
  104. package/dist/dom/features/fragment-refs/stub.d.ts +5 -0
  105. package/dist/dom/features/fragment-refs/stub.js +17 -0
  106. package/dist/dom/features/fragment-refs/stub.js.map +7 -0
  107. package/dist/dom/features/hydration/full.d.ts +68 -0
  108. package/dist/dom/features/hydration/full.js +493 -0
  109. package/dist/dom/features/hydration/full.js.map +7 -0
  110. package/dist/dom/features/hydration/index.d.ts +1 -0
  111. package/dist/dom/features/hydration/index.js +2 -0
  112. package/dist/dom/features/hydration/index.js.map +7 -0
  113. package/dist/dom/features/hydration/stub.d.ts +36 -0
  114. package/dist/dom/features/hydration/stub.js +80 -0
  115. package/dist/dom/features/hydration/stub.js.map +7 -0
  116. package/dist/dom/features/index.d.ts +8 -0
  117. package/dist/dom/features/index.js +9 -0
  118. package/dist/dom/features/index.js.map +7 -0
  119. package/dist/dom/features/lazy/full.d.ts +1 -0
  120. package/dist/dom/features/lazy/full.js +23 -0
  121. package/dist/dom/features/lazy/full.js.map +7 -0
  122. package/dist/dom/features/lazy/index.d.ts +1 -0
  123. package/dist/dom/features/lazy/index.js +2 -0
  124. package/dist/dom/features/lazy/index.js.map +7 -0
  125. package/dist/dom/features/lazy/stub.d.ts +1 -0
  126. package/dist/dom/features/lazy/stub.js +19 -0
  127. package/dist/dom/features/lazy/stub.js.map +7 -0
  128. package/dist/dom/features/memo/full.d.ts +1 -0
  129. package/dist/dom/features/memo/full.js +34 -0
  130. package/dist/dom/features/memo/full.js.map +7 -0
  131. package/dist/dom/features/memo/index.d.ts +1 -0
  132. package/dist/dom/features/memo/index.js +2 -0
  133. package/dist/dom/features/memo/index.js.map +7 -0
  134. package/dist/dom/features/memo/stub.d.ts +1 -0
  135. package/dist/dom/features/memo/stub.js +9 -0
  136. package/dist/dom/features/memo/stub.js.map +7 -0
  137. package/dist/dom/features/portal/full.d.ts +1 -0
  138. package/dist/dom/features/portal/full.js +11 -0
  139. package/dist/dom/features/portal/full.js.map +7 -0
  140. package/dist/dom/features/portal/index.d.ts +1 -0
  141. package/dist/dom/features/portal/index.js +2 -0
  142. package/dist/dom/features/portal/index.js.map +7 -0
  143. package/dist/dom/features/portal/stub.d.ts +1 -0
  144. package/dist/dom/features/portal/stub.js +5 -0
  145. package/dist/dom/features/portal/stub.js.map +7 -0
  146. package/dist/dom/features/suspense/full.d.ts +1 -0
  147. package/dist/dom/features/suspense/full.js +389 -0
  148. package/dist/dom/features/suspense/full.js.map +7 -0
  149. package/dist/dom/features/suspense/index.d.ts +1 -0
  150. package/dist/dom/features/suspense/index.js +2 -0
  151. package/dist/dom/features/suspense/index.js.map +7 -0
  152. package/dist/dom/features/suspense/stub.d.ts +1 -0
  153. package/dist/dom/features/suspense/stub.js +4 -0
  154. package/dist/dom/features/suspense/stub.js.map +7 -0
  155. package/dist/dom/features/suspense-runtime/index.d.ts +1 -0
  156. package/dist/dom/features/suspense-runtime/index.js +2 -0
  157. package/dist/dom/features/suspense-runtime/index.js.map +7 -0
  158. package/dist/dom/features/suspense-runtime/stub.d.ts +1 -0
  159. package/dist/dom/features/suspense-runtime/stub.js +11 -0
  160. package/dist/dom/features/suspense-runtime/stub.js.map +7 -0
  161. package/dist/dom/features/view-transition/full.d.ts +7 -0
  162. package/dist/dom/features/view-transition/full.js +324 -0
  163. package/dist/dom/features/view-transition/full.js.map +7 -0
  164. package/dist/dom/features/view-transition/index.d.ts +1 -0
  165. package/dist/dom/features/view-transition/index.js +2 -0
  166. package/dist/dom/features/view-transition/index.js.map +7 -0
  167. package/dist/dom/features/view-transition/resources.d.ts +11 -0
  168. package/dist/dom/features/view-transition/resources.js +117 -0
  169. package/dist/dom/features/view-transition/resources.js.map +7 -0
  170. package/dist/dom/features/view-transition/stub.d.ts +7 -0
  171. package/dist/dom/features/view-transition/stub.js +21 -0
  172. package/dist/dom/features/view-transition/stub.js.map +7 -0
  173. package/dist/dom/features/view-transition/visual.d.ts +14 -0
  174. package/dist/dom/features/view-transition/visual.js +404 -0
  175. package/dist/dom/features/view-transition/visual.js.map +7 -0
  176. package/dist/dom/form-actions.d.ts +4 -0
  177. package/dist/dom/form-actions.js +74 -0
  178. package/dist/dom/form-actions.js.map +7 -0
  179. package/dist/dom/form-controls.d.ts +3 -0
  180. package/dist/dom/form-controls.js +91 -0
  181. package/dist/dom/form-controls.js.map +7 -0
  182. package/dist/dom/fragment-instance.d.ts +33 -0
  183. package/dist/dom/fragment-instance.js +449 -0
  184. package/dist/dom/fragment-instance.js.map +7 -0
  185. package/dist/dom/index.d.ts +61 -0
  186. package/dist/dom/index.js +71 -0
  187. package/dist/dom/index.js.map +7 -0
  188. package/dist/dom/portal.d.ts +2 -0
  189. package/dist/dom/portal.js +14 -0
  190. package/dist/dom/portal.js.map +7 -0
  191. package/dist/dom/react-ids.d.ts +6 -0
  192. package/dist/dom/react-ids.js +38 -0
  193. package/dist/dom/react-ids.js.map +7 -0
  194. package/dist/dom/reconcile.d.ts +86 -0
  195. package/dist/dom/reconcile.js +1305 -0
  196. package/dist/dom/reconcile.js.map +7 -0
  197. package/dist/dom/refresh.d.ts +12 -0
  198. package/dist/dom/refresh.js +174 -0
  199. package/dist/dom/refresh.js.map +7 -0
  200. package/dist/dom/resource-hints.d.ts +6 -0
  201. package/dist/dom/resource-hints.js +107 -0
  202. package/dist/dom/resource-hints.js.map +7 -0
  203. package/dist/dom/resource-store.d.ts +13 -0
  204. package/dist/dom/resource-store.js +47 -0
  205. package/dist/dom/resource-store.js.map +7 -0
  206. package/dist/dom/resources.d.ts +1 -0
  207. package/dist/dom/resources.js +46 -0
  208. package/dist/dom/resources.js.map +7 -0
  209. package/dist/dom/retained-effects.d.ts +6 -0
  210. package/dist/dom/retained-effects.js +67 -0
  211. package/dist/dom/retained-effects.js.map +7 -0
  212. package/dist/dom/root-internal.d.ts +11 -0
  213. package/dist/dom/root-internal.js +35 -0
  214. package/dist/dom/root-internal.js.map +7 -0
  215. package/dist/dom/root.d.ts +17 -0
  216. package/dist/dom/root.js +38 -0
  217. package/dist/dom/root.js.map +7 -0
  218. package/dist/dom/synthetic-event.d.ts +1 -0
  219. package/dist/dom/synthetic-event.js +35 -0
  220. package/dist/dom/synthetic-event.js.map +7 -0
  221. package/dist/dom/test-utils.d.ts +1 -0
  222. package/dist/dom/test-utils.js +5 -0
  223. package/dist/dom/test-utils.js.map +7 -0
  224. package/dist/dom/transitions.d.ts +9 -0
  225. package/dist/dom/transitions.js +147 -0
  226. package/dist/dom/transitions.js.map +7 -0
  227. package/dist/dom/tree.d.ts +5 -0
  228. package/dist/dom/tree.js +62 -0
  229. package/dist/dom/tree.js.map +7 -0
  230. package/dist/dom/walk.d.ts +2 -0
  231. package/dist/dom/walk.js +14 -0
  232. package/dist/dom/walk.js.map +7 -0
  233. package/dist/next/client.d.ts +9 -0
  234. package/dist/next/client.js +14 -0
  235. package/dist/next/client.js.map +7 -0
  236. package/dist/next/dev-cache-loader.cjs +13 -0
  237. package/dist/next/index.d.ts +2 -0
  238. package/dist/next/index.js +97 -0
  239. package/dist/next/index.js.map +7 -0
  240. package/dist/next/loader.cjs +10 -0
  241. package/dist/next/react.d.ts +71 -0
  242. package/dist/next/react.js +9 -0
  243. package/dist/next/react.js.map +7 -0
  244. package/dist/react/act.d.ts +3 -0
  245. package/dist/react/act.js +124 -0
  246. package/dist/react/act.js.map +7 -0
  247. package/dist/react/action-scope.d.ts +17 -0
  248. package/dist/react/action-scope.js +60 -0
  249. package/dist/react/action-scope.js.map +7 -0
  250. package/dist/react/activity.d.ts +7 -0
  251. package/dist/react/activity.js +7 -0
  252. package/dist/react/activity.js.map +7 -0
  253. package/dist/react/children.d.ts +8 -0
  254. package/dist/react/children.js +76 -0
  255. package/dist/react/children.js.map +7 -0
  256. package/dist/react/class.d.ts +36 -0
  257. package/dist/react/class.js +39 -0
  258. package/dist/react/class.js.map +7 -0
  259. package/dist/react/compiler-runtime.d.ts +1 -0
  260. package/dist/react/compiler-runtime.js +9 -0
  261. package/dist/react/compiler-runtime.js.map +7 -0
  262. package/dist/react/context.d.ts +32 -0
  263. package/dist/react/context.js +25 -0
  264. package/dist/react/context.js.map +7 -0
  265. package/dist/react/element.d.ts +13 -0
  266. package/dist/react/element.js +70 -0
  267. package/dist/react/element.js.map +7 -0
  268. package/dist/react/form-state.d.ts +26 -0
  269. package/dist/react/form-state.js +30 -0
  270. package/dist/react/form-state.js.map +7 -0
  271. package/dist/react/hooks.d.ts +67 -0
  272. package/dist/react/hooks.js +165 -0
  273. package/dist/react/hooks.js.map +7 -0
  274. package/dist/react/index.d.ts +99 -0
  275. package/dist/react/index.js +143 -0
  276. package/dist/react/index.js.map +7 -0
  277. package/dist/react/jsx-runtime.d.ts +24 -0
  278. package/dist/react/jsx-runtime.js +37 -0
  279. package/dist/react/jsx-runtime.js.map +7 -0
  280. package/dist/react/memo.d.ts +20 -0
  281. package/dist/react/memo.js +27 -0
  282. package/dist/react/memo.js.map +7 -0
  283. package/dist/react/portal.d.ts +1 -0
  284. package/dist/react/portal.js +5 -0
  285. package/dist/react/portal.js.map +7 -0
  286. package/dist/react/shared-internals.d.ts +52 -0
  287. package/dist/react/shared-internals.js +22 -0
  288. package/dist/react/shared-internals.js.map +7 -0
  289. package/dist/react/suspense.d.ts +15 -0
  290. package/dist/react/suspense.js +15 -0
  291. package/dist/react/suspense.js.map +7 -0
  292. package/dist/react/thenable.d.ts +1 -0
  293. package/dist/react/thenable.js +25 -0
  294. package/dist/react/thenable.js.map +7 -0
  295. package/dist/react/view-transition.d.ts +32 -0
  296. package/dist/react/view-transition.js +12 -0
  297. package/dist/react/view-transition.js.map +7 -0
  298. package/dist/scheduler/index.d.ts +44 -0
  299. package/dist/scheduler/index.js +109 -0
  300. package/dist/scheduler/index.js.map +7 -0
  301. package/dist/server/bootstrap-script.d.ts +3 -0
  302. package/dist/server/bootstrap-script.js +17 -0
  303. package/dist/server/bootstrap-script.js.map +7 -0
  304. package/dist/server/dispatcher.d.ts +57 -0
  305. package/dist/server/dispatcher.js +157 -0
  306. package/dist/server/dispatcher.js.map +7 -0
  307. package/dist/server/escape.d.ts +6 -0
  308. package/dist/server/escape.js +75 -0
  309. package/dist/server/escape.js.map +7 -0
  310. package/dist/server/index.d.ts +16 -0
  311. package/dist/server/index.js +25 -0
  312. package/dist/server/index.js.map +7 -0
  313. package/dist/server/insertion-context.d.ts +3 -0
  314. package/dist/server/insertion-context.js +32 -0
  315. package/dist/server/renderToString.d.ts +7 -0
  316. package/dist/server/renderToString.js +33 -0
  317. package/dist/server/renderToString.js.map +7 -0
  318. package/dist/server/resource-hints.d.ts +22 -0
  319. package/dist/server/resource-hints.js +168 -0
  320. package/dist/server/resource-hints.js.map +7 -0
  321. package/dist/server/stream-ids.d.ts +3 -0
  322. package/dist/server/stream-ids.js +8 -0
  323. package/dist/server/stream.d.ts +61 -0
  324. package/dist/server/stream.js +418 -0
  325. package/dist/server/stream.js.map +7 -0
  326. package/dist/server/walk.d.ts +58 -0
  327. package/dist/server/walk.js +378 -0
  328. package/dist/server/walk.js.map +7 -0
  329. package/dist/vinext/compatibility.d.ts +23 -0
  330. package/dist/vinext/compatibility.js +127 -0
  331. package/dist/vinext/compatibility.js.map +7 -0
  332. package/dist/vinext/flight-timing.d.ts +1 -0
  333. package/dist/vinext/flight-timing.js +46 -0
  334. package/dist/vinext/flight-timing.js.map +7 -0
  335. package/dist/vinext/index.d.ts +5 -0
  336. package/dist/vinext/index.js +50 -0
  337. package/dist/vinext/index.js.map +7 -0
  338. package/dist/vite/index.d.ts +102 -0
  339. package/dist/vite/index.js +291 -0
  340. package/dist/vite/index.js.map +7 -0
  341. package/dist/vite/react18.d.ts +4 -0
  342. package/dist/vite/react18.js +74 -0
  343. package/dist/vite/react18.js.map +7 -0
  344. package/package.json +121 -4
  345. package/src/cloudflare/index.ts +44 -0
  346. package/src/core/attributes.ts +20 -0
  347. package/src/core/browser.ts +34 -0
  348. package/src/core/class-props.ts +12 -0
  349. package/src/core/devtools.ts +69 -0
  350. package/src/core/functions.ts +11 -0
  351. package/src/core/index.ts +2 -0
  352. package/src/core/internal.ts +123 -0
  353. package/src/core/resource-hints.ts +39 -0
  354. package/src/core/types.ts +39 -0
  355. package/src/core/unitless-style.ts +1 -0
  356. package/src/dom/_all.ts +46 -0
  357. package/src/dom/client.ts +17 -0
  358. package/src/dom/commit.ts +223 -0
  359. package/src/dom/devtools-effects.ts +78 -0
  360. package/src/dom/devtools.ts +527 -0
  361. package/src/dom/dispatcher.ts +476 -0
  362. package/src/dom/document-metadata.ts +41 -0
  363. package/src/dom/dom.ts +181 -0
  364. package/src/dom/error-info.ts +20 -0
  365. package/src/dom/event-replay.ts +39 -0
  366. package/src/dom/features/activity/full.ts +150 -0
  367. package/src/dom/features/activity/index.ts +1 -0
  368. package/src/dom/features/activity/stub.ts +12 -0
  369. package/src/dom/features/class/full.ts +202 -0
  370. package/src/dom/features/class/index.ts +1 -0
  371. package/src/dom/features/class/stub.ts +58 -0
  372. package/src/dom/features/context/full.ts +107 -0
  373. package/src/dom/features/context/index.ts +1 -0
  374. package/src/dom/features/context/stub.ts +26 -0
  375. package/src/dom/features/forward-ref/full.ts +9 -0
  376. package/src/dom/features/forward-ref/index.ts +1 -0
  377. package/src/dom/features/forward-ref/stub.ts +15 -0
  378. package/src/dom/features/fragment-refs/index.ts +1 -0
  379. package/src/dom/features/fragment-refs/stub.ts +6 -0
  380. package/src/dom/features/hydration/full.ts +563 -0
  381. package/src/dom/features/hydration/index.ts +1 -0
  382. package/src/dom/features/hydration/stub.ts +86 -0
  383. package/src/dom/features/index.ts +12 -0
  384. package/src/dom/features/lazy/full.ts +27 -0
  385. package/src/dom/features/lazy/index.ts +1 -0
  386. package/src/dom/features/lazy/stub.ts +24 -0
  387. package/src/dom/features/memo/full.ts +39 -0
  388. package/src/dom/features/memo/index.ts +1 -0
  389. package/src/dom/features/memo/stub.ts +13 -0
  390. package/src/dom/features/portal/full.ts +14 -0
  391. package/src/dom/features/portal/index.ts +1 -0
  392. package/src/dom/features/portal/stub.ts +11 -0
  393. package/src/dom/features/suspense/full.ts +469 -0
  394. package/src/dom/features/suspense/index.ts +1 -0
  395. package/src/dom/features/suspense/stub.ts +13 -0
  396. package/src/dom/features/suspense-runtime/index.ts +1 -0
  397. package/src/dom/features/suspense-runtime/stub.ts +1 -0
  398. package/src/dom/features/view-transition/full.ts +292 -0
  399. package/src/dom/features/view-transition/index.ts +1 -0
  400. package/src/dom/features/view-transition/resources.ts +123 -0
  401. package/src/dom/features/view-transition/stub.ts +8 -0
  402. package/src/dom/features/view-transition/visual.ts +454 -0
  403. package/src/dom/form-actions.ts +69 -0
  404. package/src/dom/form-controls.ts +91 -0
  405. package/src/dom/fragment-instance.ts +462 -0
  406. package/src/dom/index.ts +49 -0
  407. package/src/dom/portal.ts +16 -0
  408. package/src/dom/react-ids.ts +36 -0
  409. package/src/dom/reconcile.ts +1423 -0
  410. package/src/dom/refresh.ts +171 -0
  411. package/src/dom/resource-hints.ts +104 -0
  412. package/src/dom/resource-store.ts +50 -0
  413. package/src/dom/resources.ts +47 -0
  414. package/src/dom/retained-effects.ts +57 -0
  415. package/src/dom/root-internal.ts +37 -0
  416. package/src/dom/root.ts +59 -0
  417. package/src/dom/synthetic-event.ts +22 -0
  418. package/src/dom/test-utils.ts +1 -0
  419. package/src/dom/transitions.ts +141 -0
  420. package/src/dom/tree.ts +56 -0
  421. package/src/dom/walk.ts +8 -0
  422. package/src/next/client.ts +10 -0
  423. package/src/next/dev-cache-loader.cjs +13 -0
  424. package/src/next/index.ts +95 -0
  425. package/src/next/loader.cjs +10 -0
  426. package/src/next/react.ts +7 -0
  427. package/src/react/act.ts +105 -0
  428. package/src/react/action-scope.ts +57 -0
  429. package/src/react/activity.ts +10 -0
  430. package/src/react/children.ts +86 -0
  431. package/src/react/class.ts +66 -0
  432. package/src/react/compiler-runtime.ts +8 -0
  433. package/src/react/context.ts +46 -0
  434. package/src/react/element.ts +82 -0
  435. package/src/react/form-state.ts +35 -0
  436. package/src/react/hooks.ts +214 -0
  437. package/src/react/index.ts +91 -0
  438. package/src/react/jsx-runtime.ts +50 -0
  439. package/src/react/memo.ts +42 -0
  440. package/src/react/portal.ts +1 -0
  441. package/src/react/shared-internals.ts +80 -0
  442. package/src/react/suspense.ts +18 -0
  443. package/src/react/thenable.ts +21 -0
  444. package/src/react/view-transition.ts +41 -0
  445. package/src/scheduler/index.ts +124 -0
  446. package/src/server/bootstrap-script.ts +92 -0
  447. package/src/server/dispatcher.ts +168 -0
  448. package/src/server/escape.ts +102 -0
  449. package/src/server/index.ts +26 -0
  450. package/src/server/insertion-context.ts +28 -0
  451. package/src/server/renderToString.ts +35 -0
  452. package/src/server/resource-hints.ts +166 -0
  453. package/src/server/stream-ids.ts +5 -0
  454. package/src/server/stream.ts +525 -0
  455. package/src/server/walk.ts +555 -0
  456. package/src/vinext/compatibility.ts +122 -0
  457. package/src/vinext/flight-timing.ts +37 -0
  458. package/src/vinext/index.ts +47 -0
  459. package/src/vite/index.ts +476 -0
  460. package/src/vite/react18.ts +74 -0
  461. package/vendor/cloudflare-vite-plugin/LICENSE +25 -0
  462. package/vendor/cloudflare-vite-plugin/README.md +9 -0
  463. package/vendor/cloudflare-vite-plugin/dist/chunk-U6NEESU5-BmLHqeIt.mjs +43 -0
  464. package/vendor/cloudflare-vite-plugin/dist/index.d.mts +155 -0
  465. package/vendor/cloudflare-vite-plugin/dist/index.mjs +94700 -0
  466. package/vendor/cloudflare-vite-plugin/dist/open-PCXX3ZDZ-DYH87NhH.mjs +530 -0
  467. package/vendor/cloudflare-vite-plugin/dist/package-4cnqy5mM.mjs +84 -0
  468. package/vendor/cloudflare-vite-plugin/dist/workers/asset-worker/index.js +5996 -0
  469. package/vendor/cloudflare-vite-plugin/dist/workers/router-worker/index.js +6414 -0
  470. package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/index.js +457 -0
  471. package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/module-runner-legacy.js +1129 -0
  472. package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/module-runner.js +1259 -0
  473. package/vendor/cloudflare-vite-plugin/dist/workers/vite-proxy-worker/index.js +31 -0
  474. package/vendor/cloudflare-vite-plugin/package.json +90 -0
  475. package/vendor/cloudflare-vite-plugin/provenance.json +26 -0
  476. package/README.md +0 -3
@@ -0,0 +1,1423 @@
1
+ import { isTextContent } from '../core/functions';
2
+ import { devToolsMetadata, readOwnerStack, runWithOwnerStack } from '../core/devtools';
3
+ import { getRootContainer } from './root-internal';
4
+ export { getHostParent, findRoot, getAnchor, firstDomNode } from './tree';
5
+ export { isThenable } from '../core/functions';
6
+ import { HOOK_BAILOUT, renderWithHooks } from './dispatcher';
7
+ import { isString } from "../core/functions";
8
+ import { getHostParent, findRoot, getAnchor, firstDomNode } from './tree';
9
+ import { resourceKind } from '../core/resource-hints';
10
+ import { ReactSharedInternals, REACT_LAZY_TYPE, REACT_STRICT_MODE_TYPE, REACT_PROFILER_TYPE, REACT_VIEW_TRANSITION_TYPE, } from '../react';
11
+ import { componentStack } from './error-info';
12
+ import { syncInputValue, syncTextareaValue, syncSelectValue } from './form-controls';
13
+ export { deferHydration } from './features/hydration';
14
+ import { m as markTransitionUpdate, d as deferTransition, c as cancelTransitions, l as deferTransitionLayout, p as deferTransitionPassive } from './features/view-transition';
15
+ import { clearAttributes, clearHostContainer, documentMetadataParent, documentSingleton, DOCUMENT_HEAD_TAGS } from './document-metadata';
16
+ import { acquireResource } from './resources';
17
+ import { a as transitionRender, p as hasTransition, t as flushTransitions, c as cancelPendingTransitions, s as scheduleTransitionRoot } from './features/suspense-runtime';
18
+ import { commitFragmentRef, placeFragmentCommits, updateFragmentHost, refreshFragmentInstances } from './features/fragment-refs';
19
+ import { isObject } from '../core/functions';
20
+ import { FiberTag, createFiber, REACT_ELEMENT_TYPE, REACT_LEGACY_ELEMENT_TYPE, REACT_FRAGMENT_TYPE, type Fiber, type FiberRoot, type ReactElement, type ReactNode, type Effect, type Hook, } from '../core';
21
+ import { createHostNode, setProp } from './dom';
22
+ import { rememberRefreshRender, scheduleRefreshRoot, commitRefreshRoot, failRefreshRoot, failRefreshBoundary, resolveRefreshType, sameRefreshFamily, needsRefreshRemount } from './refresh';
23
+ import { forkId, assignReactIds, deferHydration, queueHydrationEnd, finishHydration, adoptHostDom, adoptTextDom, setHydrationCursor, getHydrationCursor, clearHydrationCursor, findHostParent as findHydrationHost, abortHydration, recoverHydration, isHydrationBailout, resumeHydration, } from './features/hydration';
24
+ import { rememberRetainedEffect, setRetainedFlag, disconnectClass } from './retained-effects';
25
+ import { readThenable } from '../react/thenable';
26
+ import { bindForm } from './form-actions';
27
+ // ---------------------------------------------------------------------------
28
+ // Render scheduling
29
+ // ---------------------------------------------------------------------------
30
+ let currentRoot: FiberRoot | null = null;
31
+ let flushing = false;
32
+ let isBatching = false;
33
+ const pendingRoots = new Set<FiberRoot>();
34
+ // Set by rerenderFiber to identify the exact memo-tagged fiber whose INTERNAL
35
+ // state (hook update, useSyncExternalStore notification) triggered this render
36
+ // pass. renderMemo checks this to bypass its prop-equality gate for that fiber.
37
+ // Without the bypass, a memo bail would swallow state changes: React's memo is
38
+ // only a parent-triggered gate — state-driven rerenders must always run the
39
+ // inner function. Router-adjacent components (Outlet, Match, MatchInner) are
40
+ // all memo-wrapped and subscribe to stores; missing this bypass breaks nav
41
+ // content updates even though the URL changes.
42
+ let forceRerenderingFiber: Fiber | null = null;
43
+ // ---------------------------------------------------------------------------
44
+ // Fiber creation
45
+ // ---------------------------------------------------------------------------
46
+ function tagForType(type: any, fallback = FiberTag.Host): FiberTag {
47
+ if (isString(type))
48
+ return FiberTag.Host;
49
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_VIEW_TRANSITION_TYPE)
50
+ return FiberTag.Fragment;
51
+ const marker = type?.$$typeof;
52
+ for (const match of TYPE_MATCHERS) {
53
+ const tag = match(type, marker);
54
+ if (tag !== null)
55
+ return tag;
56
+ }
57
+ return isFunction(type)
58
+ ? type.prototype?.isReactComponent ? FiberTag.Class : FiberTag.Function
59
+ : fallback;
60
+ }
61
+ export function registerElementMarker(sym: symbol): void {
62
+ ACCEPTED_ELEMENT_MARKERS.add(sym);
63
+ }
64
+ function collectHostDoms(fiber: Fiber, out: Node[]): void {
65
+ if (fiber.t === FiberTag.Suspense && fiber.b?.w) {
66
+ let node: Node | null = fiber.b.b;
67
+ while (node) {
68
+ out.push(node);
69
+ if (node === fiber.b.e)
70
+ break;
71
+ node = node.nextSibling;
72
+ }
73
+ return;
74
+ }
75
+ if (fiber.t <= FiberTag.Text) {
76
+ if (fiber.n && !documentMetadataParent(fiber))
77
+ out.push(fiber.n);
78
+ return;
79
+ }
80
+ if (fiber.t === FiberTag.Portal)
81
+ return;
82
+ if (fiber.t === FiberTag.Suspense && fiber.b?.b)
83
+ out.push(fiber.b.b);
84
+ let c = fiber.c;
85
+ while (c) {
86
+ collectHostDoms(c, out);
87
+ c = c.s;
88
+ }
89
+ if (fiber.t === FiberTag.Suspense && fiber.b?.f)
90
+ collectHostDoms(fiber.b.f, out);
91
+ if (fiber.t === FiberTag.Suspense && fiber.b?.e)
92
+ out.push(fiber.b.e);
93
+ }
94
+ export function stageCommit(fiber: Fiber, work: Effect | (() => void), ref = false): void {
95
+ let entries = stagedCommits.get(fiber);
96
+ if (!entries) {
97
+ stagedCommits.set(fiber, entries = []);
98
+ }
99
+ entries.push([fiber, work, ref]);
100
+ }
101
+ function markPendingDeletion(fiber: Fiber, deleted: Fiber[]): void {
102
+ if (fiber.pd)
103
+ return;
104
+ fiber.pd = true;
105
+ deleted.push(fiber);
106
+ for (let child = fiber.c; child; child = child.s)
107
+ markPendingDeletion(child, deleted);
108
+ if (fiber.t === FiberTag.Suspense && fiber.b?.f)
109
+ markPendingDeletion(fiber.b.f, deleted);
110
+ }
111
+ function resolvedType(type: any): any {
112
+ return type?.$$typeof === REACT_LAZY_TYPE ? resolvedType(type._init(type._payload))
113
+ : process.env.NODE_ENV !== 'production' ? resolveRefreshType(type) : type;
114
+ }
115
+ export function childrenToArray(children: ReactNode): NormalizedChild[] {
116
+ const out: NormalizedChild[] & {
117
+ ip?: bigint[];
118
+ } = [];
119
+ const ids = currentRoot?.h && currentRoot.ri ? [] as bigint[] : undefined;
120
+ pushChildren(children, out, ids);
121
+ if (ids)
122
+ out.ip = ids;
123
+ return out;
124
+ }
125
+ // ---------------------------------------------------------------------------
126
+ // DOM navigation helpers
127
+ // ---------------------------------------------------------------------------
128
+ export const fiberDepth = (fiber: Fiber): number => (fiber.d ??= fiber.p ? fiberDepth(fiber.p) + 1 : 0);
129
+ function pushChildren(node: ReactNode, out: NormalizedChild[], ids?: bigint[], path = 1n): void {
130
+ if (node == null || typeof node === 'boolean' || node === '') {
131
+ out.push(null);
132
+ ids?.push(path);
133
+ return;
134
+ }
135
+ if (isTextContent(node)) {
136
+ if (node !== '') {
137
+ out.push('' + node);
138
+ ids?.push(path);
139
+ }
140
+ return;
141
+ }
142
+ if (Array.isArray(node)) {
143
+ for (let i = 0; i < node.length; i++)
144
+ pushChildren(node[i], out, ids, ids ? forkId(path, node.length, i) : path);
145
+ return;
146
+ }
147
+ if (isObject(node)) {
148
+ const t = (node as any).$$typeof;
149
+ if (ACCEPTED_ELEMENT_MARKERS.has(t)) {
150
+ out.push(node as ReactElement);
151
+ ids?.push(path);
152
+ return;
153
+ }
154
+ // Raw React.lazy as a child. RSC Flight encodes 'use client' components
155
+ // (CodeBlock, CodeExplorer, etc.) as bare Lazy objects in the tree, not
156
+ // wrapped in REACT_ELEMENT_TYPE. Dropping them made code snippets
157
+ // disappear from docs pages. The RSC decoder pre-awaits payloads via
158
+ // `awaitLazyElements`, so by render time the status is 'fulfilled' and
159
+ // `_init()` returns the resolved element synchronously.
160
+ if (t === REACT_LAZY_TYPE || isThenable(node)) {
161
+ pushChildren(t === REACT_LAZY_TYPE ? resolvedType(node) : readThenable(node as unknown as PromiseLike<ReactNode>), out, ids, path);
162
+ return;
163
+ }
164
+ }
165
+ if (isIterable(node)) {
166
+ if (ids)
167
+ pushChildren(Array.from(node as Iterable<ReactNode>), out, ids, path);
168
+ else
169
+ for (const item of node as Iterable<ReactNode>)
170
+ pushChildren(item, out);
171
+ }
172
+ }
173
+ export function scheduleLifecycle(fiber: Fiber, fn: () => void): void {
174
+ if (isActivityHidden(fiber) || layoutIsDisconnected(fiber))
175
+ return;
176
+ stageCommit(fiber, fn);
177
+ }
178
+ // ---------------------------------------------------------------------------
179
+ // Element → children normalization
180
+ // ---------------------------------------------------------------------------
181
+ // Text children pass through as raw strings — no wrapper. The previous
182
+ // `{_text: string}` shape allocated tens of thousands of objects per
183
+ // stable-list re-render and dominated minor-GC pressure. `typeof === 'string'`
184
+ // is also robust to RSC renderable proxies (which have `has` traps that
185
+ // would fool a `'_text' in child` predicate but can't fool `typeof`).
186
+ type NormalizedChild = ReactElement | string | null;
187
+ function captureRootError(root: FiberRoot, stack: string, error: unknown): void {
188
+ if (process.env.NODE_ENV !== 'production')
189
+ failRefreshRoot(root);
190
+ const errors = root.er ||= [];
191
+ if (!errors.length)
192
+ root.u = undefined;
193
+ errors.push({ error, stack });
194
+ if (process.env.NODE_ENV !== 'production') errors[errors.length - 1]!.ownerStack = devToolsMetadata.errorStack ?? null;
195
+ scheduleUpdate(root.r);
196
+ }
197
+ function captureError(capture: RenderErrorCapture): void {
198
+ const fiber = capture.b;
199
+ if (process.env.NODE_ENV !== 'production')
200
+ failRefreshBoundary(fiber);
201
+ fiber.b = { ...fiber.b, error: capture };
202
+ scheduleUpdate(fiber);
203
+ }
204
+ const isIterable = (obj: any): boolean => (isFunction(obj[Symbol.iterator]));
205
+ function flushRoot(root: FiberRoot): void {
206
+ if (root.er) {
207
+ flushRootErrors(root);
208
+ return;
209
+ }
210
+ const render = root.u;
211
+ root.u = undefined;
212
+ if (render)
213
+ render();
214
+ // Ancestors run first, but keep descendants in the queue: an ancestor can
215
+ // bail out without reaching a descendant's independently scheduled update.
216
+ const pending = [...root.p];
217
+ root.p.clear();
218
+ renderUpdates(root, pending);
219
+ flushTransitions?.(root, renderUpdates);
220
+ runEffects(root);
221
+ if (process.env.NODE_ENV !== 'production') commitRefreshRoot(root);
222
+ }
223
+ export function rememberActivityEffect(fiber: Fiber, hook: Hook, effect: Effect): void {
224
+ if (fiber.r?.a || (fiber.r?.sp && effect.t === 1 && !effect.s))
225
+ rememberRetainedEffect(fiber, hook, effect);
226
+ }
227
+ // ---------------------------------------------------------------------------
228
+ // Error handling + default Suspense capability
229
+ // ---------------------------------------------------------------------------
230
+ // Default handler when the Suspense feature isn't installed: just schedule
231
+ // a re-render when the thrown thenable settles. No boundary walk, no
232
+ // fallback swap — children render empty during the pending window.
233
+ export function defaultHandleSuspended(fiber: Fiber, thenable: Promise<any>): void {
234
+ fiber.bs = true;
235
+ const retry = () => scheduleUpdate(fiber);
236
+ thenable.then(retry, retry);
237
+ }
238
+ export function detachRef(ref: any, fiber?: Fiber): void {
239
+ if (ref && isObject(ref))
240
+ queueMutation(() => invokeCommit(fiber, () => { ref.current = null; }));
241
+ }
242
+ export function withCurrentRoot<T>(root: FiberRoot | null, fn: () => T): T {
243
+ const prev = currentRoot;
244
+ currentRoot = root;
245
+ try {
246
+ return fn();
247
+ }
248
+ finally {
249
+ currentRoot = prev;
250
+ }
251
+ }
252
+ export function flushSyncWork(fn: () => void): void {
253
+ cancelTransitions && cancelTransitions();
254
+ const transition = ReactSharedInternals.T;
255
+ ReactSharedInternals.T = null;
256
+ const wasBatching = isBatching;
257
+ isBatching = true;
258
+ try {
259
+ fn();
260
+ // Include transitions started inside the synchronous callback.
261
+ cancelTransitions && cancelTransitions();
262
+ isBatching = wasBatching;
263
+ flushPending();
264
+ }
265
+ finally {
266
+ isBatching = wasBatching;
267
+ ReactSharedInternals.T = transition;
268
+ }
269
+ }
270
+ export function syncRefIfChanged(fiber: Fiber, value: any): void {
271
+ const ref = fiber.ref ?? (fiber.v?.ref ?? null);
272
+ if (!ref && !fiber.cr)
273
+ return;
274
+ if (isActivityHidden(fiber) || layoutIsDisconnected(fiber))
275
+ return;
276
+ const previous = fiber.cr ?? null;
277
+ if (previous !== ref) {
278
+ const cleanup = fiber.rc;
279
+ queueMutation(() => {
280
+ if (cleanup) {
281
+ fiber.rc = null;
282
+ disposeCleanup(fiber, cleanup);
283
+ }
284
+ detachRef(previous, fiber);
285
+ fiber.cr = null;
286
+ });
287
+ attachRef(fiber, value);
288
+ }
289
+ else if (ref && isObject(ref) && ref.current !== value)
290
+ attachRef(fiber, value);
291
+ }
292
+ export function unmountAllChildren(parent: Fiber): void {
293
+ let c = parent.c;
294
+ while (c) {
295
+ const next = c.s;
296
+ removeFiber(c);
297
+ c = next;
298
+ }
299
+ parent.c = null;
300
+ }
301
+ function fiberFromChild(child: Exclude<NormalizedChild, null>, parent: Fiber): Fiber {
302
+ const text = isString(child);
303
+ const type = text ? null : process.env.NODE_ENV !== 'production' ? resolveRefreshType(child.type) : child.type;
304
+ const fiber = createFiber(text ? FiberTag.Text : tagForType(type), type, text ? null : child.key ?? null);
305
+ fiber.ref = text ? null : (child as any).ref ?? null;
306
+ fiber.v = text ? child : child.props;
307
+ if (process.env.NODE_ENV !== 'production' && !text) rememberDevToolsFiber(fiber, child);
308
+ fiber.p = parent;
309
+ if (currentCommit?.c.length)
310
+ onCommitRollback(() => { fiber.u = true; });
311
+ return fiber;
312
+ }
313
+ function getDocumentInsertionParent(parent: Node, node: Node): HTMLElement | null {
314
+ if (parent.nodeType !== 9 || node.nodeType !== 1)
315
+ return null;
316
+ const tag = (node as Element).tagName.toLowerCase();
317
+ if (tag === 'html')
318
+ return null;
319
+ return DOCUMENT_HEAD_TAGS.test(tag) ? (parent as Document).head : (parent as Document).body;
320
+ }
321
+ // ---------------------------------------------------------------------------
322
+ // Rendering per fiber tag
323
+ // ---------------------------------------------------------------------------
324
+ export type RenderFn = (fiber: Fiber) => void;
325
+ export type TypeMatcher = (type: any, marker: any) => FiberTag | null;
326
+ // Mutable renderer registry indexed by FiberTag. Feature modules install their
327
+ // renderer via installRenderer(); unregistered features render as no-ops. The
328
+ // initial registrations below rely on function-declaration hoisting — every
329
+ // render* function is declared with `function` later in this file.
330
+ const RENDERERS: Array<RenderFn | undefined> = new Array(13);
331
+ // Element-marker allowlist for child normalization (pushChildren). Core-always
332
+ // markers are seeded here; features add their own via registerElementMarker.
333
+ const ACCEPTED_ELEMENT_MARKERS = new Set<symbol>([
334
+ REACT_ELEMENT_TYPE as symbol,
335
+ REACT_LEGACY_ELEMENT_TYPE as symbol,
336
+ ]);
337
+ // Type-to-tag matchers tried in registration order from fiberFromChild's
338
+ // fallback branch. Features register here for element types that aren't
339
+ // marker-based (e.g. Portal, where element.type IS the symbol).
340
+ const TYPE_MATCHERS: TypeMatcher[] = [];
341
+ function renderUpdates(root: FiberRoot, pending: Fiber[], update?: () => void): void {
342
+ pending.sort((a, b) => fiberDepth(a) - fiberDepth(b));
343
+ if (transitionRender)
344
+ for (const fiber of pending)
345
+ fiber.g = true;
346
+ update?.();
347
+ for (const fiber of pending) {
348
+ if (!fiber.g || fiber.u || fiber.pd)
349
+ continue;
350
+ // An ancestor earlier in this batch may have retained this subscriber.
351
+ if (fiber.su) {
352
+ scheduleUpdate(fiber);
353
+ continue;
354
+ }
355
+ if (!transitionRender) {
356
+ if (fiber.bt && hasTransition?.(fiber))
357
+ continue;
358
+ let ancestor = fiber.p;
359
+ while (ancestor && !ancestor.bs)
360
+ ancestor = ancestor.p;
361
+ if (ancestor && fiber.bt)
362
+ continue;
363
+ }
364
+ const boundary = root.eb && findErrorBoundary(fiber);
365
+ const checkpoint = boundary || (root.sp && findSuspenseBoundary(fiber)) ? checkpointCommit(fiber) : -1;
366
+ try {
367
+ rerenderFiber(fiber, root);
368
+ }
369
+ catch (error) {
370
+ if (error instanceof RenderSuspenseCapture) {
371
+ rewindCommit(checkpoint);
372
+ error.b.b.u = true;
373
+ scheduleUpdate(error.b);
374
+ continue;
375
+ }
376
+ if (error instanceof RenderErrorCapture) {
377
+ if (error.b.t === FiberTag.Root)
378
+ throw error;
379
+ rewindCommit(checkpoint);
380
+ captureError(error);
381
+ continue;
382
+ }
383
+ if (!recoverHydration(root, error))
384
+ throw error;
385
+ break;
386
+ }
387
+ }
388
+ }
389
+ // ---------------------------------------------------------------------------
390
+ // Refs
391
+ // ---------------------------------------------------------------------------
392
+ export function attachRef(fiber: Fiber, value: any): void {
393
+ const ref = fiber.ref ?? (fiber.v?.ref ?? null);
394
+ if (!ref)
395
+ return;
396
+ if (isActivityHidden(fiber) || layoutIsDisconnected(fiber))
397
+ return;
398
+ stageCommit(fiber, () => {
399
+ if (fiber.t === FiberTag.Resource)
400
+ value = fiber.i;
401
+ fiber.cr = ref;
402
+ if (isFunction(ref)) {
403
+ // Callback refs run during commit, after insertion effects install
404
+ // event callback implementations and in subtree layout order.
405
+ const cleanup = ref(value);
406
+ const detach = isFunction(cleanup) ? cleanup : () => ref(null);
407
+ fiber.rc = detach;
408
+ (fiber.e ||= []).push(detach);
409
+ }
410
+ else {
411
+ ref.current = value;
412
+ }
413
+ }, true);
414
+ }
415
+ export function enqueueEffect(fiber: Fiber, effect: Effect): void {
416
+ if (effect.t !== 2 && (isActivityHidden(fiber) || activityIsDisconnected(fiber) || (effect.t === 1 && !effect.s && fiber.ld)))
417
+ return;
418
+ if (effect.t === 2)
419
+ pendingInsertionEffects.push([fiber, effect]);
420
+ else if (effect.t === 1)
421
+ stageCommit(fiber, effect);
422
+ else
423
+ pendingEffects.push([fiber, effect]);
424
+ }
425
+ // Accessor + scoped setter for the module-level `currentRoot`. Feature modules
426
+ // need these to participate in the render loop (e.g. Suspense re-hydration
427
+ // must temporarily set the root while rebuilding a boundary subtree).
428
+ export const getCurrentRoot = (): FiberRoot | null => (currentRoot);
429
+ function sameType(fiber: Fiber, child: Exclude<NormalizedChild, null>): boolean {
430
+ if (isString(child))
431
+ return fiber.t === FiberTag.Text;
432
+ if (process.env.NODE_ENV !== 'production' && sameRefreshFamily(fiber.type, child.type))
433
+ return (fiber.key === (child.key ?? null));
434
+ return fiber.key === (child.key ?? null) && (fiber.type === child.type || resolvedType(fiber.type) === resolvedType(child.type));
435
+ }
436
+ // The memo feature uses this to bypass its prop-equality gate on state-driven
437
+ // rerenders of the memoized fiber itself (hook update / subscribed store),
438
+ // where props haven't changed by definition.
439
+ export const getForceRerenderingFiber = (): Fiber | null => (forceRerenderingFiber);
440
+ installRenderer(FiberTag.Text, renderText);
441
+ installRenderer(FiberTag.Host, renderHost);
442
+ installRenderer(FiberTag.Resource, renderHost);
443
+ installRenderer(FiberTag.Function, renderFunction);
444
+ installRenderer(FiberTag.Fragment, renderFragment);
445
+ function placeDomsInOrder(doms: Node[], domParent: Node): void {
446
+ // Document siblings can be projected into head or body by the HTML parser.
447
+ // Keep them in their physical container when their logical parent is Document.
448
+ if (domParent.nodeType === 9) {
449
+ const doc = domParent as Document;
450
+ const bodyNodes = doms.filter(node => getDocumentInsertionParent(doc, node) === doc.body);
451
+ if (bodyNodes.length)
452
+ placeDomsInOrder(bodyNodes, doc.body);
453
+ doms = doms.filter(node => !getDocumentInsertionParent(doc, node));
454
+ }
455
+ // Build fresh siblings in document order so native controls choose the first option.
456
+ if (doms.every(node => !node.parentNode)) {
457
+ for (const node of doms)
458
+ domParent.appendChild(node);
459
+ return;
460
+ }
461
+ // Reverse-iterate, anchoring each node before the one that should follow it.
462
+ // This works because by the time we're placing doms[i], doms[i+1] is already
463
+ // in its final slot. Forward iteration is buggy: insertBefore(doms[i],
464
+ // doms[i+1]) pulls doms[i] forward past any nodes that SHOULD move behind
465
+ // it, leaving those nodes mis-anchored (app-starter Analyze/Lucky swap, npm
466
+ // stats library dropdown reorder — both reported by users).
467
+ //
468
+ // Concrete example: start=[A, R, L], target=[A, L, R]. Forward pass gives
469
+ // [L, A, R] (wrong). Reverse pass moves R to end, then L and A are already
470
+ // correct — 1 move, matches target.
471
+ //
472
+ // Skip nodes already in their target position so CSS transitions on stable
473
+ // siblings aren't cancelled (e.g. drawer slide animation).
474
+ for (let i = doms.length - 1; i >= 0; i--) {
475
+ const d = doms[i]!;
476
+ const targetNext: Node | null = doms[i + 1] ?? null;
477
+ if (d.parentNode !== domParent || (targetNext && !(d.compareDocumentPosition(targetNext) & 4))) {
478
+ domParent.insertBefore(d, targetNext);
479
+ }
480
+ }
481
+ }
482
+ export function handleErrorInRender(fiber: Fiber, err: any): void {
483
+ if (err instanceof RenderErrorCapture)
484
+ throw err;
485
+ stagedCommits.delete(fiber);
486
+ removeEffects(candidate => candidate === fiber);
487
+ if (currentRoot?.h && findHydrationHost(fiber).hc) {
488
+ abortHydration(err, fiber);
489
+ }
490
+ // Bubble to nearest class boundary with getDerivedStateFromError / componentDidCatch
491
+ const boundary = findErrorBoundary(fiber);
492
+ if (boundary) {
493
+ const capture = new RenderErrorCapture(boundary, err, fiber);
494
+ if (currentCommit)
495
+ throw capture;
496
+ captureError(capture);
497
+ return;
498
+ }
499
+ // Abort the prepared render. Its mutation/effect queues must not commit
500
+ // before the root is cleared and the error callback runs.
501
+ const root = currentRoot ?? findRoot(fiber);
502
+ if (root && currentCommit && (flushing || root.ue))
503
+ throw new RenderErrorCapture(root.r, err, fiber);
504
+ if (root?.ue) {
505
+ if (process.env.NODE_ENV !== 'production') runWithOwnerStack(readOwnerStack(fiber), () => root.ue!(err, { componentStack: componentStack(fiber) }));
506
+ else root.ue(err, { componentStack: componentStack(fiber) });
507
+ }
508
+ else
509
+ throw err;
510
+ }
511
+ export function handleCommitError(fiber: Fiber, error: unknown): void {
512
+ const boundary = findErrorBoundary(fiber);
513
+ if (boundary) {
514
+ captureError(new RenderErrorCapture(boundary, error, fiber));
515
+ return;
516
+ }
517
+ const root = findRoot(fiber);
518
+ if (root) {
519
+ if (process.env.NODE_ENV !== 'production') runWithOwnerStack(readOwnerStack(fiber), () => captureRootError(root, componentStack(fiber), error));
520
+ else captureRootError(root, componentStack(fiber), error);
521
+ } else
522
+ queueMicrotask(() => { throw error; });
523
+ }
524
+ export function invokeCommit<T>(fiber: Fiber | undefined, callback: () => T): T | undefined {
525
+ try {
526
+ if (process.env.NODE_ENV !== 'production' && fiber) return invokeDevToolsCallback(fiber, callback);
527
+ return callback();
528
+ }
529
+ catch (error) {
530
+ if (!fiber) throw error;
531
+ handleCommitError(fiber, error);
532
+ }
533
+ }
534
+ export function renderFunction(fiber: Fiber, render = fiber.type, props = fiber.v ?? {}, ref?: any): void {
535
+ const canBail = fiber === forceRerenderingFiber && fiber.v === fiber.m;
536
+ fiber.cx?.clear();
537
+ let rendered: ReactNode | typeof HOOK_BAILOUT;
538
+ try {
539
+ rendered = renderWithHooks(fiber, render, props, ref, canBail);
540
+ }
541
+ catch (e: any) {
542
+ if (isThenable(e)) {
543
+ if (!deferHydration(fiber, e))
544
+ handleSuspended(fiber, e);
545
+ }
546
+ else
547
+ handleErrorInRender(fiber, e);
548
+ return;
549
+ }
550
+ if (rendered === HOOK_BAILOUT)
551
+ return;
552
+ reconcileRaw(fiber, rendered);
553
+ fiber.m = fiber.v;
554
+ // dy cleared at rerender start; leaving true lets mid-render schedule persist
555
+ }
556
+ export function registerTypeMatcher(m: TypeMatcher): void {
557
+ TYPE_MATCHERS.push(m);
558
+ }
559
+ function collectChildren(parent: Fiber): Fiber[] {
560
+ const out: Fiber[] = [];
561
+ let c = parent.c;
562
+ while (c) {
563
+ out.push(c);
564
+ c = c.s;
565
+ }
566
+ return out;
567
+ }
568
+ function removeEffects(matches: (fiber: Fiber) => boolean): void {
569
+ for (const queue of effectQueues) {
570
+ for (let index = queue.length - 1; index >= 0; index--) {
571
+ if (matches(queue[index]![0]))
572
+ (function (queue: Array<[
573
+ Fiber,
574
+ Effect
575
+ ] | LayoutCommit>, index: number): void {
576
+ const entry = queue[index]!;
577
+ queue.splice(index, 1);
578
+ if (currentCommit?.c.length)
579
+ onCommitRollback(() => { queue.splice(index, 0, entry); });
580
+ })(queue, index);
581
+ }
582
+ }
583
+ }
584
+ function renderText(fiber: Fiber): void {
585
+ const domParent = getHostParent(fiber);
586
+ const text = fiber.v as string;
587
+ // Native form reset replaces an <output>'s text node. Reattach the fiber to
588
+ // the replacement before writing, otherwise updates target a detached node.
589
+ if (fiber.n && fiber.m !== null && !fiber.n.parentNode &&
590
+ domParent.firstChild?.nodeType === 3 && !domParent.firstChild.nextSibling) {
591
+ fiber.n = domParent.firstChild;
592
+ }
593
+ // Identity-unchanged fast path: skip the native Text.data write entirely.
594
+ if (fiber.n && fiber.m === text)
595
+ return;
596
+ if (!fiber.n) {
597
+ const hydrated = currentRoot?.h ? adoptTextDom(fiber, fiber.p!, text) : false;
598
+ if (!hydrated) {
599
+ fiber.n = document.createTextNode(text);
600
+ }
601
+ updateFragmentHost(fiber, true);
602
+ }
603
+ else {
604
+ // Past the fast path, and adoptTextDom already realigned `.data` on
605
+ // hydration — `.data !== text` here is guaranteed, so write directly.
606
+ queueText(fiber.n as Text, text);
607
+ }
608
+ fiber.m = text;
609
+ // dy cleared at rerender start; leaving true lets mid-render schedule persist
610
+ }
611
+ // ---------------------------------------------------------------------------
612
+ // Capability hooks — cross-cutting behaviors that features override.
613
+ // Defaults here preserve today's behavior so the indirection is transparent
614
+ // when all features are loaded. A feature's full-module can install its own
615
+ // implementation via installCapability(); stubs leave the default in place,
616
+ // where the default may intentionally degrade (e.g. a no-Context build's
617
+ // readContext never walks the tree because no Provider fibers exist).
618
+ // ---------------------------------------------------------------------------
619
+ export interface Capabilities {
620
+ h: (fiber: Fiber, thenable: Promise<any>) => void;
621
+ c: (fiber: Fiber, ctx: any) => any;
622
+ i: (fiber: Fiber) => boolean;
623
+ d: (fiber: Fiber) => boolean;
624
+ p: (fiber: Fiber) => void;
625
+ s: (fiber: Fiber) => void;
626
+ }
627
+ const CAPABILITIES: Capabilities = {
628
+ h: defaultHandleSuspended,
629
+ c: defaultReadContext,
630
+ i: () => false,
631
+ d: () => false,
632
+ p: () => { },
633
+ s: () => { },
634
+ };
635
+ export const isActivityHidden = (fiber: Fiber): boolean => CAPABILITIES.i(fiber);
636
+ export const activityIsDisconnected = (fiber: Fiber): boolean => CAPABILITIES.d(fiber);
637
+ export const layoutIsDisconnected = (fiber: Fiber): boolean => (!!fiber.ld || activityIsDisconnected(fiber));
638
+ export function discardPendingWork(root: FiberRoot): void {
639
+ cancelPendingTransitions?.(root);
640
+ root.u = undefined;
641
+ root.p.clear();
642
+ root.s = false;
643
+ pendingRoots.delete(root);
644
+ }
645
+ function runEffect(fiber: Fiber, effect: Effect): void {
646
+ if (fiber.u)
647
+ return;
648
+ if (effect.t !== 2 && (isActivityHidden(fiber) || activityIsDisconnected(fiber) || (effect.t === 1 && !effect.s && fiber.ld)))
649
+ return;
650
+ const cleanup = invokeCommit(fiber, effect.c);
651
+ if (isFunction(cleanup))
652
+ (fiber.e ||= []).push(cleanup);
653
+ }
654
+ export class RenderSuspenseCapture {
655
+ constructor(public b: Fiber) { }
656
+ }
657
+ export function scheduleRootRender(root: FiberRoot, render: () => void): void {
658
+ if (process.env.NODE_ENV !== 'production')
659
+ rememberRefreshRender(root, render);
660
+ markTransitionUpdate && markTransitionUpdate(root);
661
+ if (!scheduleTransitionRoot?.(root, render)) root.u = render;
662
+ pendingRoots.add(root);
663
+ if (isBatching)
664
+ return;
665
+ if (process.env.NODE_ENV !== 'production' && ReactSharedInternals.A)
666
+ ReactSharedInternals.A.push(flushPending);
667
+ else
668
+ flushPending();
669
+ }
670
+ export class RenderErrorCapture {
671
+ s: string;
672
+ declare o?: string | null;
673
+ constructor(public b: Fiber, public e: unknown, source: Fiber = b) {
674
+ this.s = componentStack(source);
675
+ if (process.env.NODE_ENV !== 'production') this.o = readOwnerStack(source);
676
+ }
677
+ }
678
+ function flushRootErrors(root: FiberRoot): void {
679
+ const errors = root.er!;
680
+ root.er = undefined;
681
+ if (root.r.m === null)
682
+ queueMutation(() => clearHostContainer(root.c));
683
+ renderRoot(root, null);
684
+ queueCommitEffects(() => {
685
+ for (const captured of errors) {
686
+ try {
687
+ if (process.env.NODE_ENV !== 'production' && ReactSharedInternals.A) {
688
+ ReactSharedInternals.A.push(() => { throw captured.error; });
689
+ }
690
+ else if (root.ue) {
691
+ if (process.env.NODE_ENV !== 'production') runWithOwnerStack(captured.ownerStack ?? null, () => root.ue!(captured.error, { componentStack: captured.stack }));
692
+ else root.ue(captured.error, { componentStack: captured.stack });
693
+ }
694
+ else if (isFunction(globalThis.reportError))
695
+ globalThis.reportError(captured.error);
696
+ else
697
+ queueMicrotask(() => { throw captured.error; });
698
+ }
699
+ catch (error) {
700
+ setTimeout(() => { throw error; });
701
+ }
702
+ }
703
+ });
704
+ if (root.u)
705
+ pendingRoots.add(root);
706
+ }
707
+ function flushPending(): void {
708
+ if (flushing)
709
+ return;
710
+ flushing = true;
711
+ try {
712
+ let guard = 0;
713
+ while (pendingRoots.size > 0) {
714
+ if (++guard > 50) {
715
+ if (process.env.NODE_ENV !== 'production') {
716
+ throw new Error('flushPending exceeded 50 iterations — suspected infinite update loop.');
717
+ }
718
+ throw new Error();
719
+ }
720
+ const roots = [...pendingRoots];
721
+ pendingRoots.clear();
722
+ for (const root of roots) {
723
+ root.s = false;
724
+ const render = () => flushRoot(root);
725
+ if (!(deferTransition && deferTransition(root, render, flushPending))) {
726
+ try {
727
+ commitSynchronously(render);
728
+ }
729
+ catch (error) {
730
+ if (!recoverRootError(error))
731
+ throw error;
732
+ }
733
+ }
734
+ }
735
+ }
736
+ }
737
+ finally {
738
+ flushing = false;
739
+ }
740
+ }
741
+ export function batchedUpdates<T>(fn: () => T): T;
742
+ export function batchedUpdates<A, T>(fn: (arg: A) => T, arg: A): T;
743
+ export function batchedUpdates<T>(fn: (arg: any) => T, arg?: any): T {
744
+ const wasBatching = isBatching;
745
+ isBatching = true;
746
+ try {
747
+ return fn(arg);
748
+ }
749
+ finally {
750
+ isBatching = wasBatching;
751
+ if (!wasBatching)
752
+ flushPending();
753
+ }
754
+ }
755
+ // ---------------------------------------------------------------------------
756
+ // Reconciliation
757
+ // ---------------------------------------------------------------------------
758
+ /**
759
+ * Reconcile a parent fiber's child list against new normalized children.
760
+ * Mutates parent.c and the sibling chain.
761
+ * DOM placement runs after mutations and before layout effects.
762
+ */
763
+ export function reconcileChildren(parent: Fiber, nodes: Parameters<typeof reconcile>[1], _domParent: Node, _anchor: Node | null): void { reconcile(parent, nodes); }
764
+ export function installRenderer(tag: FiberTag, fn: RenderFn): void {
765
+ RENDERERS[tag] = fn;
766
+ }
767
+ export const recoveringBoundaries = new Set<Fiber>();
768
+ function findErrorBoundary(fiber: Fiber): Fiber | null {
769
+ for (let parent = fiber.p; parent; parent = parent.p) {
770
+ if (parent.u || parent.pd || recoveringBoundaries.has(parent))
771
+ continue;
772
+ const instance = parent.i;
773
+ if (instance?._f === parent && (parent.b?.b?.getDerivedStateFromError || instance.componentDidCatch))
774
+ return parent;
775
+ }
776
+ return null;
777
+ }
778
+ export function disposeCleanup(fiber: Fiber, cleanup: () => void): void {
779
+ const index = fiber.e?.indexOf(cleanup) ?? -1;
780
+ if (index >= 0)
781
+ fiber.e!.splice(index, 1);
782
+ invokeCommit(fiber, cleanup);
783
+ }
784
+ export function installCapability<K extends keyof Capabilities>(name: K, fn: Capabilities[K]): void {
785
+ CAPABILITIES[name] = fn;
786
+ }
787
+ // Preserve the extension helper signature while internal removals need no host argument.
788
+ export function unmountFiber(fiber: Fiber, _domParent: Node, remove = true): void { removeFiber(fiber, remove); }
789
+ function queueUnmount(fiber: Fiber, remove: boolean): void {
790
+ if (fiber.pd)
791
+ return;
792
+ // Keep committed DOM available for snapshots, but stop deleted work now.
793
+ const deleted: Fiber[] = [];
794
+ markPendingDeletion(fiber, deleted);
795
+ const restore = () => {
796
+ for (const child of deleted)
797
+ child.pd = false;
798
+ };
799
+ onCommitRollback(restore);
800
+ onCommitFailure(restore);
801
+ queueMutation(() => removeFiber(fiber, remove));
802
+ }
803
+ export function runEffects(root: FiberRoot): void {
804
+ if (root.fr)
805
+ refreshFragmentInstances(root);
806
+ if (effectQueues.some(queue => queue.length))
807
+ (function (): void {
808
+ const batches = effectQueues.map(queue => queue.splice(0));
809
+ const [batch, insertion, layout] = batches as [
810
+ Array<[
811
+ Fiber,
812
+ Effect
813
+ ]>,
814
+ Array<[
815
+ Fiber,
816
+ Effect
817
+ ]>,
818
+ LayoutCommit[]
819
+ ];
820
+ if (currentCommit?.c.length)
821
+ onCommitRollback(() => {
822
+ // A nested render can drain these queues before an enclosing attempt
823
+ // fails. Reuse the captured batches, then older checkpoints trim tails.
824
+ effectQueues.forEach((queue, index) => queue.unshift(...batches[index]!));
825
+ });
826
+ queueCommitEffects(() => {
827
+ if (process.env.NODE_ENV !== 'production') measureDevToolsLayout(root, () => {
828
+ for (const [fiber, effect] of insertion) runEffect(fiber, effect);
829
+ });
830
+ else for (const [fiber, effect] of insertion) runEffect(fiber, effect);
831
+ if (layout.length) {
832
+ if (process.env.NODE_ENV !== 'production') measureDevToolsLayout(root, () => {
833
+ for (const [fiber, work] of layout) {
834
+ if (!isFunction(work) && !fiber.u && !isActivityHidden(fiber) && !layoutIsDisconnected(fiber)) work.d?.();
835
+ }
836
+ });
837
+ else for (const [fiber, work] of layout) {
838
+ if (!isFunction(work) && !fiber.u && !isActivityHidden(fiber) && !layoutIsDisconnected(fiber)) work.d?.();
839
+ }
840
+ const runLayout = () => {
841
+ for (const [fiber, work] of layout) {
842
+ if (!isFunction(work))
843
+ runEffect(fiber, work);
844
+ else if (!fiber.u && !isActivityHidden(fiber) && !layoutIsDisconnected(fiber)) {
845
+ invokeCommit(fiber, work);
846
+ }
847
+ }
848
+ };
849
+ if (process.env.NODE_ENV !== 'production') {
850
+ const measured = wrapDevToolsLayout(root, runLayout);
851
+ if (!(deferTransitionLayout && deferTransitionLayout(measured))) measured();
852
+ } else if (!(deferTransitionLayout && deferTransitionLayout(runLayout))) runLayout();
853
+ }
854
+ // Passive fx on microtask
855
+ if (batch.length) {
856
+ const passive = () => {
857
+ for (const [fiber, effect] of batch)
858
+ if (!fiber.u && !isActivityHidden(fiber) && !activityIsDisconnected(fiber)) effect.d?.();
859
+ for (const [fiber, effect] of batch)
860
+ runEffect(fiber, effect);
861
+ };
862
+ if (process.env.NODE_ENV !== 'production') {
863
+ const measured = wrapDevToolsPassive(root, passive);
864
+ if (!(deferTransitionPassive && deferTransitionPassive(measured))) {
865
+ if (ReactSharedInternals.A) ReactSharedInternals.A.push(measured);
866
+ else queueMicrotask(measured);
867
+ }
868
+ } else if (!(deferTransitionPassive && deferTransitionPassive(passive))) queueMicrotask(passive);
869
+ }
870
+ });
871
+ })();
872
+ }
873
+ function renderFragment(fiber: Fiber): void {
874
+ const props = fiber.v ?? {};
875
+ reconcileRaw(fiber, props.children);
876
+ commitFragmentRef(fiber);
877
+ fiber.m = props;
878
+ // dy cleared at rerender start; leaving true lets mid-render schedule persist
879
+ }
880
+ export function findSuspenseBoundary(fiber: Fiber): Fiber | null {
881
+ let child = fiber;
882
+ for (let parent = fiber.p; parent; parent = parent.p) {
883
+ // Include the starting fiber: promised Activity children can suspend
884
+ // while normalizing the Activity itself, before a child fiber exists.
885
+ if (child.t === FiberTag.Activity && child.v?.mode === 'hidden')
886
+ return null;
887
+ if (parent.t === FiberTag.Suspense && parent.b?.f !== child)
888
+ return parent;
889
+ child = parent;
890
+ }
891
+ return null;
892
+ }
893
+ // ---------------------------------------------------------------------------
894
+ // Entry points (called by createRoot)
895
+ // ---------------------------------------------------------------------------
896
+ export function renderRoot(root: FiberRoot, children: ReactNode): void {
897
+ if (!currentCommit)
898
+ return commitSynchronously(() => renderRoot(root, children));
899
+ if (process.env.NODE_ENV !== 'production')
900
+ scheduleRefreshRoot(root, children);
901
+ const rootFiber = root.r;
902
+ rootFiber.v = { children };
903
+ currentRoot = root;
904
+ try {
905
+ reconcileRaw(rootFiber, children);
906
+ rootFiber.m = rootFiber.v;
907
+ rootFiber.g = false;
908
+ }
909
+ finally {
910
+ currentRoot = null;
911
+ }
912
+ // Layout effects can synchronously update stores, after hydration has ended.
913
+ queueHydrationEnd?.(root);
914
+ runEffects(root);
915
+ if (process.env.NODE_ENV !== 'production')
916
+ commitRefreshRoot(root);
917
+ }
918
+ // ---------------------------------------------------------------------------
919
+ // Context read — exported for dispatcher.ts (useContext, use()). Delegates to
920
+ // the installed capability so the Context feature can override with a walking
921
+ // implementation that finds the nearest Provider fiber. When the feature is
922
+ // stubbed, the default here returns ctx._currentValue — correct because no
923
+ // Provider fibers exist in the tree (Provider element → Fragment via the
924
+ // stub's type matcher).
925
+ // ---------------------------------------------------------------------------
926
+ export const readContext = (fiber: Fiber, ctx: any): any => (CAPABILITIES.c(fiber, ctx));
927
+ function rerenderFiber(fiber: Fiber, root: FiberRoot): void {
928
+ if (!fiber.g)
929
+ return;
930
+ // Skip fibers that were um between scheduling and flush. Without this,
931
+ // the flush loop re-enters a zombie fiber whose .p is still set; its
932
+ // render mounts fresh DOM into the old parent's still-attached DOM (since
933
+ // removeFiber only clears fiber.c, not fiber.p). Visible as route
934
+ // content from a previous location staying on screen after nav, because a
935
+ // pending rerender on the old route's LibraryLandingPage (um during
936
+ // Outlet's shallow-first render) still fires from root.pending.
937
+ if (fiber.u || fiber.pd)
938
+ return;
939
+ // Clear BEFORE rendering so a scheduleUpdate() triggered mid-render (e.g.
940
+ // error boundary catching a descendant throw) marks us dy for the next
941
+ // flush iteration instead of being wiped out when render() completes.
942
+ fiber.g = false;
943
+ currentRoot = root;
944
+ const finishHydration = resumeHydration(fiber, root);
945
+ const prevForcing = forceRerenderingFiber;
946
+ forceRerenderingFiber = fiber;
947
+ try {
948
+ renderNode(fiber);
949
+ }
950
+ finally {
951
+ forceRerenderingFiber = prevForcing;
952
+ finishHydration?.();
953
+ currentRoot = null;
954
+ }
955
+ }
956
+ function renderHost(fiber: Fiber): void {
957
+ const domParent = documentMetadataParent(fiber) || getHostParent(fiber);
958
+ const hadDom = !!fiber.n;
959
+ const props = fiber.v ?? {};
960
+ const prev = fiber.m;
961
+ const type = fiber.type as string;
962
+ const isSvg = type === 'svg' || (domParent as Element).namespaceURI === 'http://www.w3.org/2000/svg';
963
+ const singleton = !isSvg && documentSingleton(fiber);
964
+ const isResource = fiber.t === FiberTag.Resource;
965
+ const canAcquire = !isSvg && (isResource || !fiber.m) && resourceKind(type, props);
966
+ if (isResource || canAcquire) {
967
+ fiber.t = FiberTag.Resource;
968
+ if (canAcquire) {
969
+ let container: Node = domParent.ownerDocument || domParent;
970
+ if (type !== 'script') {
971
+ // Host assembly may still be detached. Style ownership follows the
972
+ // logical root or nearest portal, not that temporary DOM tree.
973
+ container = getRootContainer(fiber, domParent);
974
+ }
975
+ queueMutation(() => {
976
+ const resource = acquireResource(type, props, container);
977
+ fiber.i ||= resource;
978
+ });
979
+ }
980
+ if (fiber.m)
981
+ syncRefIfChanged(fiber, fiber.i);
982
+ else
983
+ attachRef(fiber, null);
984
+ fiber.m = props;
985
+ return;
986
+ }
987
+ // <select value> must be applied AFTER children mount — setting `.value`
988
+ // on a `<select>` with no matching `<option>` yet resets it to empty. Same
989
+ // for `defaultValue` on first mount. Stash and replay.
990
+ const isSelect = type === 'select';
991
+ const isInput = !isSvg && type === 'input';
992
+ const isTextarea = !isSvg && type === 'textarea';
993
+ const deferValue = isSelect || isInput || isTextarea;
994
+ let hydrated = false;
995
+ if (!fiber.n) {
996
+ hydrated = currentRoot?.h ? adoptHostDom(fiber, fiber.p!) : false;
997
+ if (!hydrated && singleton) {
998
+ fiber.n = singleton;
999
+ queueMutation(() => {
1000
+ clearAttributes(singleton);
1001
+ applyHostProps(singleton, props, undefined, false, false, false, false);
1002
+ });
1003
+ }
1004
+ else if (!hydrated) {
1005
+ fiber.n = createHostNode(type, isSvg);
1006
+ applyHostProps(fiber.n as Element, props, undefined, isSvg, isInput, isTextarea, deferValue);
1007
+ }
1008
+ updateFragmentHost(fiber, true);
1009
+ attachRef(fiber, fiber.n);
1010
+ }
1011
+ else if (prev !== props) {
1012
+ queueMutation(() => applyHostProps(fiber.n as Element, props, prev, isSvg, isInput, isTextarea, deferValue));
1013
+ }
1014
+ if (process.env.NODE_ENV !== 'production') {
1015
+ const node = fiber.n!;
1016
+ const previous = devToolsMetadata.hosts.get(node);
1017
+ onCommitRollback(() => {
1018
+ if (previous) devToolsMetadata.hosts.set(node, previous);
1019
+ else devToolsMetadata.hosts.delete(node);
1020
+ });
1021
+ devToolsMetadata.hosts.set(node, fiber);
1022
+ }
1023
+ if (type === 'form')
1024
+ queueMutation(() => bindForm(fiber, handleCommitError));
1025
+ if (hadDom)
1026
+ syncRefIfChanged(fiber, fiber.n);
1027
+ // Children go into this DOM node
1028
+ // Textarea's value/defaultValue owns its text node, not child fibers.
1029
+ reconcileRaw(fiber, isTextarea ? null : props.children);
1030
+ finishHydration(fiber, isTextarea);
1031
+ // Apply <select> value after options are mounted.
1032
+ if (isSelect && !hydrated)
1033
+ queueCommitEffects(() => syncSelectValue(fiber.n as HTMLSelectElement, props, prev));
1034
+ fiber.m = props;
1035
+ // dy cleared at rerender start; leaving true lets mid-render schedule persist
1036
+ }
1037
+ export function renderNode(fiber: Fiber): void {
1038
+ fiber.bs = false;
1039
+ if (process.env.NODE_ENV !== 'production') {
1040
+ if (needsRefreshRemount(fiber))
1041
+ fiber = (function (fiber: Fiber): Fiber {
1042
+ const parent = fiber.p!;
1043
+ const siblings = collectChildren(parent);
1044
+ rememberChildList(parent, siblings);
1045
+ onCommitRollback(() => {
1046
+ parent.c = siblings[0] ?? null;
1047
+ for (let i = 0; i < siblings.length; i++)
1048
+ siblings[i]!.s = siblings[i + 1] ?? null;
1049
+ });
1050
+ const next = fiberFromChild({ $$typeof: REACT_ELEMENT_TYPE, type: fiber.type, key: fiber.key, ref: fiber.ref, props: fiber.v }, parent);
1051
+ if (fiber.ix !== undefined) next.ix = fiber.ix;
1052
+ next.s = fiber.s;
1053
+ const previous = siblings[siblings.indexOf(fiber) - 1];
1054
+ if (previous)
1055
+ previous.s = next;
1056
+ else
1057
+ parent.c = next;
1058
+ removeFiber(fiber);
1059
+ return next;
1060
+ })(fiber);
1061
+ fiber.type = resolveRefreshType(fiber.type);
1062
+ }
1063
+ // Memo consumes pending state when it delegates to its inner renderer.
1064
+ if (fiber.t !== FiberTag.Memo)
1065
+ fiber.g = false;
1066
+ fiber.r ||= currentRoot || findRoot(fiber);
1067
+ if (fiber.r?.sp && fiber.p?.ld && fiber.m === null)
1068
+ setRetainedFlag(fiber, 'ld', true);
1069
+ if (fiber.r?.a)
1070
+ CAPABILITIES.p(fiber);
1071
+ const fn = RENDERERS[fiber.t];
1072
+ try {
1073
+ if (process.env.NODE_ENV !== 'production') renderWithDevTools(fiber, fn);
1074
+ else if (fn) fn(fiber);
1075
+ }
1076
+ catch (error) {
1077
+ stagedCommits.delete(fiber);
1078
+ if (currentRoot?.h && !findErrorBoundary(fiber) || error instanceof RenderErrorCapture || error instanceof RenderSuspenseCapture || isHydrationBailout(error))
1079
+ throw error;
1080
+ if (isThenable(error)) {
1081
+ if (currentRoot?.h)
1082
+ throw error;
1083
+ handleSuspended(fiber, error);
1084
+ }
1085
+ else
1086
+ handleErrorInRender(fiber, error);
1087
+ }
1088
+ if (fiber.r?.a)
1089
+ CAPABILITIES.s(fiber);
1090
+ flushFiberCommits(fiber);
1091
+ }
1092
+ // ---------------------------------------------------------------------------
1093
+ // Reconciliation
1094
+ // ---------------------------------------------------------------------------
1095
+ /**
1096
+ * Reconcile a parent fiber's child list against new normalized children.
1097
+ * Mutates parent.c and the sibling chain.
1098
+ * Mounts new host DOM into `domParent` before `anchor` (or appends if anchor === null).
1099
+ */
1100
+ function indexChildren(parent: Fiber, next: Fiber | null): Map<string | number, Fiber> {
1101
+ rememberChildList(parent, collectChildren(parent));
1102
+ const remaining = new Map<string | number, Fiber>();
1103
+ for (; next; next = next.s) remaining.set(next.key ?? next.ix!, next);
1104
+ return remaining;
1105
+ }
1106
+ export function reconcile(parent: Fiber, newChildren: NormalizedChild[]): void {
1107
+ // Keep positional updates allocation-free. Only a structural difference
1108
+ // needs the key index and deletion set; both paths share the same writes.
1109
+ let next = parent.c;
1110
+ let previous: Fiber | null = null;
1111
+ let remaining: Map<string | number, Fiber> | undefined;
1112
+ const hydrating = !!currentRoot?.h;
1113
+ for (let i = 0; i < newChildren.length; i++) {
1114
+ const child = newChildren[i];
1115
+ if (child == null) continue;
1116
+ let match: Fiber | undefined;
1117
+ if (!remaining && !hydrating && next && next.ix === i && sameType(next, child)) {
1118
+ match = next;
1119
+ next = next.s;
1120
+ } else {
1121
+ if (!remaining) {
1122
+ remaining = indexChildren(parent, next);
1123
+ }
1124
+ const key = isString(child) ? i : child.key ?? i;
1125
+ const candidate = remaining.get(key);
1126
+ if (candidate && sameType(candidate, child)) {
1127
+ match = candidate;
1128
+ remaining.delete(key);
1129
+ }
1130
+ }
1131
+ const fiber = match ?? fiberFromChild(child, parent);
1132
+ if (match) {
1133
+ if (isString(child)) fiber.v = child;
1134
+ else {
1135
+ if (fiber.type !== child.type) fiber.t = tagForType(child.type);
1136
+ fiber.type = child.type;
1137
+ fiber.v = child.props;
1138
+ if (process.env.NODE_ENV !== 'production') rememberDevToolsFiber(fiber, child);
1139
+ fiber.ref = (child as any).ref ?? null;
1140
+ }
1141
+ }
1142
+ fiber.ix = i;
1143
+ if (remaining) {
1144
+ fiber.p = parent;
1145
+ if (previous) previous.s = fiber;
1146
+ else parent.c = fiber;
1147
+ }
1148
+ previous = fiber;
1149
+ }
1150
+ if (!remaining && !next && !hydrating) {
1151
+ renderChildChain(parent);
1152
+ return;
1153
+ }
1154
+ if (!remaining && next) {
1155
+ remaining = indexChildren(parent, next);
1156
+ }
1157
+ if (previous) previous.s = null;
1158
+ else parent.c = null;
1159
+ // Deletions must commit before replacement document roots are placed.
1160
+ for (const fiber of remaining?.values() ?? []) removeFiber(fiber);
1161
+ if (hydrating) assignReactIds(parent, newChildren);
1162
+ renderChildChain(parent);
1163
+ }
1164
+ // ---------------------------------------------------------------------------
1165
+ // Effects
1166
+ // ---------------------------------------------------------------------------
1167
+ const pendingEffects: Array<[
1168
+ Fiber,
1169
+ Effect
1170
+ ]> = [];
1171
+ const pendingInsertionEffects: Array<[
1172
+ Fiber,
1173
+ Effect
1174
+ ]> = [];
1175
+ export type LayoutCommit = [
1176
+ Fiber,
1177
+ Effect | (() => void),
1178
+ boolean
1179
+ ];
1180
+ const pendingCommits: LayoutCommit[] = [];
1181
+ const effectQueues: Array<Array<[
1182
+ Fiber,
1183
+ Effect
1184
+ ] | LayoutCommit>> = [pendingEffects, pendingInsertionEffects, pendingCommits];
1185
+ let stagedCommits = new Map<Fiber, LayoutCommit[]>();
1186
+ function renderChildChain(parent: Fiber): void {
1187
+ for (let child = parent.c; child; child = child.s)
1188
+ renderNode(child);
1189
+ while (parent.t !== FiberTag.Host && parent.t !== FiberTag.Root && parent.t !== FiberTag.Portal)
1190
+ parent = parent.p!;
1191
+ queuePlacement(parent);
1192
+ }
1193
+ export function discardPendingEffects(root: FiberRoot): void {
1194
+ removeEffects(fiber => findRoot(fiber) === root);
1195
+ for (const fiber of stagedCommits.keys()) {
1196
+ if (findRoot(fiber) === root)
1197
+ stagedCommits.delete(fiber);
1198
+ }
1199
+ }
1200
+ export function commitPlacements(parents: Iterable<Fiber>): void {
1201
+ for (const parent of [...new Set(parents)].sort((a, b) => fiberDepth(b) - fiberDepth(a))) {
1202
+ if (parent.u || parent.pd)
1203
+ continue;
1204
+ const domParent = parent.t === FiberTag.Host ? parent.n! : parent.t === FiberTag.Portal ? parent.v.container : parent.r!.c;
1205
+ const doms: Node[] = [];
1206
+ for (let child = parent.c; child; child = child.s)
1207
+ collectHostDoms(child, doms);
1208
+ placeDomsInOrder(doms, domParent);
1209
+ const metadata = documentMetadataParent(parent);
1210
+ if (metadata && parent.n!.parentNode !== metadata)
1211
+ metadata.appendChild(parent.n!);
1212
+ }
1213
+ }
1214
+ // ---------------------------------------------------------------------------
1215
+ // Unmount
1216
+ // ---------------------------------------------------------------------------
1217
+ export function removeFiber(fiber: Fiber, remove = true): void {
1218
+ if (fiber.u)
1219
+ return;
1220
+ if (currentCommit)
1221
+ return queueUnmount(fiber, remove);
1222
+ stagedCommits.delete(fiber);
1223
+ commitFragmentRef(fiber, 1);
1224
+ fiber.u = true;
1225
+ if (fiber.t === FiberTag.Suspense && fiber.b?.b) {
1226
+ const state = fiber.b;
1227
+ state.x?.();
1228
+ state.b._reactRetry = undefined;
1229
+ if (remove && !state.w) {
1230
+ state.b.remove();
1231
+ state.e?.remove();
1232
+ }
1233
+ if (remove && state.w) {
1234
+ let node: Node | null = state.b;
1235
+ while (node) {
1236
+ const next: Node | null = node.nextSibling;
1237
+ (node as ChildNode).remove();
1238
+ if (node === state.e)
1239
+ break;
1240
+ node = next;
1241
+ }
1242
+ }
1243
+ }
1244
+ if (fiber.t <= FiberTag.Text)
1245
+ updateFragmentHost(fiber, false);
1246
+ commitFragmentRef(fiber, 2);
1247
+ if (fiber.t === FiberTag.Suspense && fiber.b?.f) {
1248
+ removeFiber(fiber.b.f, remove);
1249
+ fiber.b.f = null;
1250
+ }
1251
+ // Run cu (fx + layout fx)
1252
+ if (fiber.e) {
1253
+ const cleanups = fiber.e;
1254
+ fiber.e = null;
1255
+ for (const cleanup of cleanups) {
1256
+ invokeCommit(fiber, cleanup);
1257
+ }
1258
+ }
1259
+ disconnectClass(fiber, true);
1260
+ // Detach ref
1261
+ if (fiber.cr ?? fiber.ref)
1262
+ detachRef(fiber.cr ?? fiber.ref, fiber);
1263
+ const singleton = !!fiber.n && fiber.n === documentSingleton(fiber);
1264
+ if (singleton && remove)
1265
+ clearAttributes(fiber.n as Element);
1266
+ let c = fiber.c;
1267
+ while (c) {
1268
+ const next = c.s;
1269
+ removeFiber(c, fiber.t === FiberTag.Portal || (remove && (singleton || fiber.t !== FiberTag.Host)));
1270
+ c = next;
1271
+ }
1272
+ fiber.c = null;
1273
+ // Remove DOM if host
1274
+ if (!singleton && (remove || documentMetadataParent(fiber)) && (fiber.t <= FiberTag.Text) && fiber.n) {
1275
+ fiber.n.parentNode?.removeChild(fiber.n);
1276
+ }
1277
+ }
1278
+ // Rendering already visits the tree in order. Completing a fiber stages its
1279
+ // layout work after its children, without another tree walk at commit time.
1280
+ export function flushFiberCommits(fiber: Fiber): void {
1281
+ const entries = stagedCommits.get(fiber);
1282
+ if (!entries || layoutIsDisconnected(fiber))
1283
+ return;
1284
+ stagedCommits.delete(fiber);
1285
+ if (placeFragmentCommits(fiber, entries, pendingCommits))
1286
+ return;
1287
+ // Commit phase, rather than the wrapper's fiber tag, determines order.
1288
+ entries.sort((a, b) => +a[2] - +b[2]);
1289
+ for (const entry of entries)
1290
+ pendingCommits.push(entry);
1291
+ }
1292
+ // Wrapper for features that catch thrown thenables inside their render
1293
+ // functions. Delegates to the installed Suspense capability.
1294
+ export function handleSuspended(fiber: Fiber, thenable: Promise<any>): void {
1295
+ // Hidden work cannot hold a visible transition open. A Suspense boundary
1296
+ // inside that Activity still owns its fallback; an outside one does not.
1297
+ if (isActivityHidden(fiber) && !findSuspenseBoundary(fiber)) {
1298
+ defaultHandleSuspended(fiber, thenable);
1299
+ return;
1300
+ }
1301
+ if (transitionRender)
1302
+ throw thenable;
1303
+ CAPABILITIES.h(fiber, thenable);
1304
+ }
1305
+ export function scheduleUpdate(fiber: Fiber): void {
1306
+ // Drop updates scheduled on already-um fibers. Subscribers (router,
1307
+ // query, any external store) can fire after unmount if their cleanup was
1308
+ // missed, and letting those reach rerenderFiber mounts zombie DOM into the
1309
+ // old .p's DOM (which stays reachable via the stale pointer).
1310
+ if (fiber.u || fiber.pd)
1311
+ return;
1312
+ if (process.env.NODE_ENV !== 'production') markDevToolsUpdate(fiber);
1313
+ fiber.bt = !!ReactSharedInternals.T && (!fiber.g || !!fiber.bt);
1314
+ fiber.g = true;
1315
+ // A component finishes its render-phase updates before reconciling children.
1316
+ if (ReactSharedInternals.F === fiber)
1317
+ return;
1318
+ const root = findRoot(fiber);
1319
+ if (!root)
1320
+ return;
1321
+ // Retained Suspense primaries must retry their boundary, not commit a child
1322
+ // against the older props preserved by the failed attempt.
1323
+ while (fiber.su) {
1324
+ fiber = fiber.su;
1325
+ fiber.b.u = true;
1326
+ fiber.g = true;
1327
+ }
1328
+ markTransitionUpdate && markTransitionUpdate(root);
1329
+ root.p.add(fiber);
1330
+ pendingRoots.add(root);
1331
+ if (isBatching)
1332
+ return;
1333
+ if (!root.s) {
1334
+ root.s = true;
1335
+ if (process.env.NODE_ENV !== 'production' && ReactSharedInternals.A)
1336
+ ReactSharedInternals.A.push(flushPending);
1337
+ else
1338
+ queueMicrotask(flushPending);
1339
+ }
1340
+ }
1341
+ setCommitCheckpointHook(() => {
1342
+ // Restore effect queues and staged layout work at this checkpoint.
1343
+ const lengths = effectQueues.map(queue => queue.length);
1344
+ const staged = new Map([...stagedCommits].map(([fiber, work]) => [fiber, work.slice()]));
1345
+ onCommitRollback(() => {
1346
+ effectQueues.forEach((queue, index) => { queue.length = lengths[index]!; });
1347
+ stagedCommits = staged;
1348
+ });
1349
+ });
1350
+ // ---------------------------------------------------------------------------
1351
+ // Utilities
1352
+ // ---------------------------------------------------------------------------
1353
+ const isEventProp = (name: string): boolean => name[0] === 'o' && name[1] === 'n' && name[2]! >= 'A';
1354
+ function applyHostProps(el: Element, props: any, prev: any, isSvg: boolean, isInput: boolean, isTextarea: boolean, deferValue: boolean): void {
1355
+ const mounting = !prev;
1356
+ const previousProps = prev || {};
1357
+ // Radio groups stay disconnected until type, value and checked agree.
1358
+ if (isInput && !mounting)
1359
+ setProp(el, 'name', '', undefined, false);
1360
+ let events: string[] | undefined;
1361
+ for (const key in props) {
1362
+ const next = props[key], previous = previousProps[key];
1363
+ const changed = mounting || next !== previous;
1364
+ if ((!changed && !isInput) || isReservedProp(key) || (deferValue && (key === 'value' || key === 'defaultValue')) || (isInput && (key === 'checked' || key === 'defaultChecked' || key === 'name')))
1365
+ continue;
1366
+ if (isEventProp(key)) {
1367
+ (events ||= []).push(key);
1368
+ }
1369
+ else if (changed)
1370
+ setProp(el, key, next, previous, isSvg);
1371
+ }
1372
+ for (const key in previousProps) {
1373
+ if (isReservedProp(key) || ((isInput || isTextarea) && (key === 'value' || key === 'defaultValue')) || (isInput && (key === 'checked' || key === 'defaultChecked' || key === 'name')))
1374
+ continue;
1375
+ if (!(key in props))
1376
+ setProp(el, key, undefined, previousProps[key], isSvg);
1377
+ }
1378
+ // Event resolution sees the new input type, as it does on mount.
1379
+ if (events)
1380
+ for (const key of events)
1381
+ setProp(el, key, props[key], previousProps[key], isSvg);
1382
+ if (isInput) {
1383
+ syncInputValue(el as HTMLInputElement, props, prev);
1384
+ setProp(el, 'name', props.name, previousProps.name, false);
1385
+ }
1386
+ else if (isTextarea)
1387
+ syncTextareaValue(el as HTMLTextAreaElement, props, mounting);
1388
+ }
1389
+ export function renderFiber(fiber: Fiber, _domParent: Node, _anchor: Node | null): void { renderNode(fiber); }
1390
+ import { currentCommit, commitSynchronously, queueMutation, queueText, queueCommitEffects, setCommitCheckpointHook, onCommitRollback, onCommitFailure, checkpointCommit, rewindCommit, rememberChildList, queuePlacement, setCommitPlacementHook } from './commit';
1391
+ import { isFunction, isReservedProp, isThenable } from '../core/functions';
1392
+ import { renderWithDevTools, rememberDevToolsFiber, markDevToolsUpdate, invokeDevToolsCallback } from './devtools';
1393
+ import { measureDevToolsLayout, wrapDevToolsLayout, wrapDevToolsPassive } from './devtools-effects';
1394
+ setCommitPlacementHook(commitPlacements);
1395
+ export function recoverRootError(error: unknown, abort?: () => void): boolean {
1396
+ if (!(error instanceof RenderErrorCapture) || error.b.t !== FiberTag.Root)
1397
+ return false;
1398
+ const root = error.b.r!;
1399
+ abort?.();
1400
+ discardPendingWork(root);
1401
+ discardPendingEffects(root);
1402
+ if (process.env.NODE_ENV !== 'production') runWithOwnerStack(error.o ?? null, () => captureRootError(root, error.s, error.e));
1403
+ else captureRootError(root, error.s, error.e);
1404
+ return true;
1405
+ }
1406
+ // Memo, lazy and ref wrappers render through the same fiber. Always restore
1407
+ // the wrapper identity, including when the inner render suspends or throws.
1408
+ export function delegateFiber(fiber: Fiber, type: any, tag = tagForType(type, FiberTag.Fragment)): void {
1409
+ const previousType = fiber.type, previousTag = fiber.t;
1410
+ fiber.type = type;
1411
+ fiber.t = tag;
1412
+ try {
1413
+ renderNode(fiber);
1414
+ }
1415
+ finally {
1416
+ fiber.type = previousType;
1417
+ fiber.t = previousTag;
1418
+ }
1419
+ }
1420
+ function defaultReadContext(_f: Fiber, ctx: any): any {
1421
+ return ctx._currentValue;
1422
+ }
1423
+ export function reconcileRaw(fiber: Fiber, children: ReactNode): void { reconcile(fiber, childrenToArray(children)); }