@bleedingdev/tanstack-redact 0.0.0-stage → 0.2.2

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 +37 -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 +27 -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,476 @@
1
+ import { invokeCommit } from './reconcile';
2
+ import { isFunction } from '../core/functions';
3
+ import { scheduleUpdate, enqueueEffect, readContext, rememberActivityEffect, disposeCleanup, handleCommitError, findRoot } from './reconcile';
4
+ import { p as deferTransitionPassive } from './features/view-transition';
5
+ import { readThenable } from '../react/thenable';
6
+ import type { Hook, Fiber, FiberRoot, Effect, ReactNode } from '../core';
7
+ import { reactId } from './features/hydration';
8
+ import { ReactSharedInternals, REACT_CONTEXT_TYPE } from '../react';
9
+ import { runAction, trackAction, withinAction, type ActionScope } from '../react/action-scope';
10
+ import { REACT_RECOVERABLE_TYPE } from '../core/browser';
11
+ import { isRefreshing, finishRefresh, resolveRefreshType } from './refresh';
12
+ import { formState, idleFormStatus, actionInitialState } from '../react/form-state';
13
+ import { transitionScope } from '../react/hooks';
14
+ import { queueCommitEffects } from './commit';
15
+ import { q as queueTransition, r as reduceTransition, v as deferValue } from './features/suspense-runtime';
16
+ import { devToolsDispatcher, wrapDevToolsRender } from './devtools';
17
+ // The renderer owns action lifetimes, including calls through another copy
18
+ // of the public React API that shares these internals.
19
+ ReactSharedInternals.X = action => {
20
+ const scope = runAction(action);
21
+ return scope.d.then(() => {
22
+ if (scope.f && !scope.h)
23
+ throw scope.e;
24
+ });
25
+ };
26
+ export function cleanupEffect(hook: Hook, fiber: Fiber): void {
27
+ if (!hook.c)
28
+ return;
29
+ const cleanup = hook.c;
30
+ hook.c = null;
31
+ disposeCleanup(fiber, cleanup);
32
+ }
33
+ function hookValue(hook: Hook, value: any): any {
34
+ if (!Object.is(hook.s, value))
35
+ hookFlags |= 1;
36
+ return hook.s = value;
37
+ }
38
+ function initializeReducer(hook: Hook, fiber: Fiber, initialArg: any, init: ((arg: any) => any) | undefined, eager: boolean): void {
39
+ hook.d = hook.s = init ? init(initialArg) : initialArg;
40
+ hook.q = (action: any) => {
41
+ if (fiber.u || fiber.pd)
42
+ return;
43
+ if (queueTransition?.(hook, fiber, action))
44
+ return;
45
+ if (eager && ReactSharedInternals.F !== fiber && !hook.c) {
46
+ try {
47
+ const next = basicReducer(hook.s, action);
48
+ if (Object.is(next, hook.s))
49
+ return;
50
+ hook.s = next;
51
+ hook.c = 0;
52
+ }
53
+ catch {
54
+ hook.c = [action];
55
+ }
56
+ }
57
+ else
58
+ (hook.c ||= []).push(action);
59
+ scheduleUpdate(fiber);
60
+ };
61
+ }
62
+ type BasicStateAction<S> = S | ((p: S) => S);
63
+ // Reducer slots reuse the effect-cleanup field for pending actions. Zero marks
64
+ // eager state work, null means no update. Replacing arrays lets retries restore
65
+ // pending actions without copying or shifting them.
66
+ // State and reducer slots keep their last rendered value in d, even undefined.
67
+ const initialState = (value: any): any => (isFunction(value) ? value() : value);
68
+ function getCurrentFiber(): Fiber {
69
+ const f = ReactSharedInternals.F;
70
+ if (!f) {
71
+ if (process.env.NODE_ENV !== 'production') {
72
+ throw new Error('Hook called outside a function component render.');
73
+ }
74
+ throw new Error();
75
+ }
76
+ return f;
77
+ }
78
+ let hookEffects: any[] | undefined;
79
+ // Bit 1 records a changed value; bit 2 records a processed reducer queue.
80
+ let hookFlags = 0;
81
+ export const HOOK_BAILOUT = Symbol();
82
+ function nextHook(): Hook {
83
+ const hooks = getCurrentFiber().h ||= [];
84
+ const index = ReactSharedInternals.I++;
85
+ return hooks[index] ||= { s: undefined, q: undefined, d: undefined, c: undefined };
86
+ }
87
+ export function renderWithHooks(fiber: Fiber, render: (props: any, ref?: any) => ReactNode, props: any, ref?: any, canBail?: boolean): ReactNode | typeof HOOK_BAILOUT {
88
+ if (process.env.NODE_ENV !== 'production') {
89
+ render = resolveRefreshType(render);
90
+ if (isRefreshing(fiber))
91
+ canBail = false;
92
+ }
93
+ const previousDispatcher = ReactSharedInternals.H, previousFiber = ReactSharedInternals.F, previousIndex = ReactSharedInternals.I;
94
+ if (process.env.NODE_ENV !== 'production') render = wrapDevToolsRender(render);
95
+ const previousEffects = hookEffects, previousFlags = hookFlags;
96
+ hookEffects = undefined;
97
+ hookFlags = 0;
98
+ ReactSharedInternals.H = DISPATCHER;
99
+ ReactSharedInternals.F = fiber;
100
+ try {
101
+ let rendered: ReactNode, attempts = 0;
102
+ do {
103
+ if (++attempts > 25)
104
+ throw new Error(process.env.NODE_ENV !== 'production' ? 'Too many re-renders.' : '');
105
+ if (hookEffects) {
106
+ resetHookEffects(hookEffects);
107
+ hookEffects = undefined;
108
+ }
109
+ if (fiber.r?.ri)
110
+ fiber.il = 0;
111
+ ReactSharedInternals.I = 0;
112
+ if (process.env.NODE_ENV !== 'production') ReactSharedInternals.H = devToolsDispatcher(fiber, DISPATCHER);
113
+ fiber.g = false;
114
+ rendered = render(props, ref);
115
+ } while (fiber.g);
116
+ if (canBail && hookFlags === 2) {
117
+ // React accepts the rendered dependencies on a reducer bailout, but
118
+ // keeps the previous committed effect descriptions until real work.
119
+ hookEffects = undefined;
120
+ return HOOK_BAILOUT;
121
+ }
122
+ if (hookEffects) {
123
+ const effects: any[] = hookEffects;
124
+ for (let index = 0; index < effects.length; index += 4) {
125
+ const hook = effects[index], effect = effects[index + 2];
126
+ rememberActivityEffect(fiber, hook, effect);
127
+ if (effects[index + 3])
128
+ enqueueEffect(fiber, effect);
129
+ }
130
+ hookEffects = undefined;
131
+ }
132
+ if (process.env.NODE_ENV !== 'production')
133
+ finishRefresh(fiber);
134
+ return rendered;
135
+ }
136
+ finally {
137
+ if (hookEffects)
138
+ resetHookEffects(hookEffects);
139
+ hookEffects = previousEffects;
140
+ hookFlags = previousFlags;
141
+ ReactSharedInternals.H = previousDispatcher;
142
+ ReactSharedInternals.F = previousFiber;
143
+ ReactSharedInternals.I = previousIndex;
144
+ }
145
+ }
146
+ function useEffectImpl(type: Effect['t'], create: () => any, deps?: ReadonlyArray<unknown>, subscription?: boolean): void {
147
+ const hook = nextHook();
148
+ const fiber = getCurrentFiber();
149
+ const changed = hook.d === undefined || !depsEqual(hook.d, deps);
150
+ if (!changed && !fiber.r?.a && !(type === 1 && !subscription && fiber.r?.sp))
151
+ return;
152
+ const previous = hook.d;
153
+ hook.d = deps;
154
+ const effect: Effect = {
155
+ t: type,
156
+ s: subscription,
157
+ c: () => {
158
+ cleanupEffect(hook, fiber);
159
+ const cleanup = create();
160
+ // Each effect owns its cleanup even when hooks return the same function.
161
+ hook.c = isFunction(cleanup) ? () => {
162
+ if (type === 0) {
163
+ const dispose = () => invokeCommit(fiber, cleanup);
164
+ if (!(deferTransitionPassive && deferTransitionPassive(dispose)))
165
+ queueCommitEffects(dispose);
166
+ }
167
+ else
168
+ cleanup();
169
+ } : null;
170
+ return hook.c;
171
+ },
172
+ };
173
+ if (type !== 2 && !subscription)
174
+ effect.d = () => cleanupEffect(hook, fiber);
175
+ (hookEffects ||= []).push(hook, previous, effect, changed);
176
+ }
177
+ function depsEqual(a: ReadonlyArray<unknown> | undefined, b: ReadonlyArray<unknown> | undefined): boolean {
178
+ if (process.env.NODE_ENV !== 'production' && isRefreshing(ReactSharedInternals.F))
179
+ return false;
180
+ if (a === b)
181
+ return true;
182
+ if (!a || !b)
183
+ return false;
184
+ if (a.length !== b.length)
185
+ return false;
186
+ for (let i = 0; i < a.length; i++) {
187
+ if (!Object.is(a[i], b[i]))
188
+ return false;
189
+ }
190
+ return true;
191
+ }
192
+ function resetHookEffects(effects: any[]): void {
193
+ for (let index = 0; index < effects.length; index += 4)
194
+ effects[index].d = effects[index + 1];
195
+ }
196
+ // Singleton — every method reads render context via ReactSharedInternals,
197
+ // and per-hook closures live on the hook itself, so nothing is render-local
198
+ // to capture. Allocating a fresh wrapper + 17 method closures per function-
199
+ // component render was pure GC pressure.
200
+ const DISPATCHER = {
201
+ useTransition(): [
202
+ boolean,
203
+ (fn: () => void) => void
204
+ ] {
205
+ const hook = nextHook(), fiber = getCurrentFiber();
206
+ const queue = hook.q ||= { p: 0, f: false, e: undefined };
207
+ hook.c ||= (fn: () => void) => {
208
+ const scope = transitionScope(() => runAction(fn, fiber.r, scope => {
209
+ scope.n = undefined;
210
+ queue.p++;
211
+ scheduleUpdate(fiber);
212
+ fiber.bt = false;
213
+ }));
214
+ const finish = () => {
215
+ if (scope.f && !scope.h) {
216
+ queue.f = true;
217
+ queue.e = scope.e;
218
+ }
219
+ if (!scope.n)
220
+ queue.p--;
221
+ scheduleUpdate(fiber);
222
+ };
223
+ if (!scope.p) {
224
+ finish();
225
+ return;
226
+ }
227
+ if (scope.p > (scope.v || 0))
228
+ scope.n?.(scope);
229
+ scope.d.then(finish);
230
+ };
231
+ if (queue.f)
232
+ throw queue.e;
233
+ return [hookValue(hook, queue.p > 0), hook.c];
234
+ },
235
+ useMemo<T>(factory: () => T, deps?: ReadonlyArray<unknown>) {
236
+ const hook = nextHook();
237
+ if (hook.d === undefined || !depsEqual(hook.d, deps)) {
238
+ hook.s = factory();
239
+ hook.d = deps;
240
+ }
241
+ return hook.s as T;
242
+ },
243
+ useLayoutEffect(create: () => any, deps?: ReadonlyArray<unknown>) {
244
+ useEffectImpl(1, create, deps);
245
+ },
246
+ useInsertionEffect(create: () => any, deps?: ReadonlyArray<unknown>) {
247
+ useEffectImpl(2, create, deps);
248
+ },
249
+ useCallback<T extends Function>(fn: T, deps?: ReadonlyArray<unknown>): T {
250
+ return this.useMemo(() => fn, deps) as T;
251
+ },
252
+ useRef<T>(initial: T) {
253
+ return (nextHook().s ||= { current: initial }) as {
254
+ current: T;
255
+ };
256
+ },
257
+ useContext<T>(ctx: any): T {
258
+ return readContext(getCurrentFiber(), ctx);
259
+ },
260
+ useImperativeHandle<T>(ref: any, factory: () => T, deps?: ReadonlyArray<unknown>) {
261
+ useEffectImpl(1, () => {
262
+ if (!ref)
263
+ return;
264
+ const value = factory();
265
+ if (isFunction(ref)) {
266
+ const cleanup = ref(value);
267
+ return isFunction(cleanup) ? cleanup : () => ref(null);
268
+ }
269
+ ref.current = value;
270
+ return () => { ref.current = null; };
271
+ }, deps == null ? undefined : [...deps, ref]);
272
+ },
273
+ use<T>(resource: any): T {
274
+ if (resource?.$$typeof === REACT_RECOVERABLE_TYPE)
275
+ return undefined as T;
276
+ if (resource?.$$typeof === REACT_CONTEXT_TYPE) {
277
+ return readContext(getCurrentFiber(), resource);
278
+ }
279
+ if (isFunction(resource?.then)) {
280
+ return readThenable(resource) as T;
281
+ }
282
+ if (process.env.NODE_ENV !== 'production') {
283
+ throw new Error(resource == null ? 'use() received null or undefined' : 'use() expected a Promise or Context');
284
+ }
285
+ throw new Error();
286
+ },
287
+ useDebugValue<T>(_value: T, _formatter?: (v: T) => any): void {
288
+ // noop
289
+ },
290
+ useDeferredValue<T>(v: T): T {
291
+ if (!deferValue)
292
+ return v;
293
+ const hook = nextHook();
294
+ return hookValue(hook, deferValue(hook, getCurrentFiber(), v));
295
+ },
296
+ useReducer<S, A>(reducer: (s: S, a: A) => S, initialArg: any, init?: (a: any) => S) {
297
+ const hook = nextHook();
298
+ if (hook.q === undefined)
299
+ initializeReducer(hook, getCurrentFiber(), initialArg, init, reducer === basicReducer);
300
+ const reduced = reduceTransition?.(hook, reducer);
301
+ const actions = hook.c;
302
+ if (actions != null || reduced) {
303
+ hook.c = null;
304
+ let state = hook.s;
305
+ if (actions)
306
+ for (const action of actions)
307
+ state = reducer(state, action);
308
+ hookFlags |= Object.is(state, hook.d) ? 2 : 3;
309
+ hook.d = hook.s = state;
310
+ }
311
+ return [hook.s, hook.q] as [
312
+ S,
313
+ (a: A) => void
314
+ ];
315
+ },
316
+ useSyncExternalStore<T>(subscribe: (cb: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T {
317
+ const fiber = getCurrentFiber();
318
+ const hook = nextHook();
319
+ const store: {
320
+ g: () => T;
321
+ } = hook.q ||= {};
322
+ store.g = getSnapshot;
323
+ // During hydration, use the server snapshot (if provided) so the tree
324
+ // matches the SSR output. Components like TanStack Router's ClientOnly
325
+ // rely on this: they render `false` on server, `true` on client — and
326
+ // if we return `true` during hydration, client and server diverge and
327
+ // the tree mounts fresh next to the SSR fallback DOM.
328
+ const root = fiber.r ?? findRoot(fiber);
329
+ const isHydrating = Boolean(root?.h);
330
+ const value = isHydrating && getServerSnapshot ? getServerSnapshot() : getSnapshot();
331
+ hookValue(hook, value);
332
+ useEffectImpl(1, () => {
333
+ let active = true;
334
+ const check = () => {
335
+ if (!active || fiber.u)
336
+ return;
337
+ try {
338
+ if (Object.is(hook.s, store.g()))
339
+ return;
340
+ }
341
+ catch { }
342
+ scheduleUpdate(fiber);
343
+ };
344
+ const unsubscribe = subscribe(check);
345
+ check();
346
+ return () => {
347
+ active = false;
348
+ if (isFunction(unsubscribe))
349
+ unsubscribe();
350
+ };
351
+ }, [subscribe], true);
352
+ return value;
353
+ },
354
+ useActionState<S, P>(action: (state: Awaited<S>, payload: P) => S | Promise<S>, initial: Awaited<S>): [
355
+ Awaited<S>,
356
+ (payload: P) => void,
357
+ boolean
358
+ ] {
359
+ const hook = nextHook(), fiber = getCurrentFiber();
360
+ // q is included in commit checkpoints. Each queue owns the committed
361
+ // callback, latest result, outstanding count, failure and async tail.
362
+ const queue = hook.q ||= { a: action, v: actionInitialState(fiber, initial), p: 0, f: false, e: undefined, t: null };
363
+ useEffectImpl(2, () => { queue.a = action; }, [action]);
364
+ hook.c ||= (payload: P) => {
365
+ if (queue.f || fiber.u || fiber.pd)
366
+ return;
367
+ const invoke = queue.a, scope = ReactSharedInternals.B;
368
+ if (scope) {
369
+ queue.p++;
370
+ scheduleUpdate(fiber);
371
+ }
372
+ const execute = async () => {
373
+ if (queue.f)
374
+ return;
375
+ try {
376
+ queue.v = await withinAction(scope, () => invoke(queue.v, payload));
377
+ }
378
+ catch (error) {
379
+ queue.f = true;
380
+ queue.e = error;
381
+ if (scope) {
382
+ scope.f = true;
383
+ scope.h = true;
384
+ scope.e = error;
385
+ }
386
+ }
387
+ scheduleUpdate(fiber);
388
+ };
389
+ const task = queue.t ? queue.t.then(execute) : execute();
390
+ queue.t = task;
391
+ if (scope)
392
+ trackAction(scope, task);
393
+ task.then(() => {
394
+ if (queue.t === task)
395
+ queue.t = null;
396
+ if (scope) {
397
+ queue.p--;
398
+ scheduleUpdate(fiber);
399
+ }
400
+ });
401
+ };
402
+ if (queue.f)
403
+ throw queue.e;
404
+ const pending = queue.p > 0;
405
+ if (!Object.is(hook.s, queue.v) || hook.d !== pending)
406
+ hookFlags |= 1;
407
+ hook.s = queue.v;
408
+ hook.d = pending;
409
+ return [queue.v, hook.c, pending];
410
+ },
411
+ useOptimistic<S, A>(state: S, updateFn?: (state: S, action: A) => S): [
412
+ S,
413
+ (action: A) => void
414
+ ] {
415
+ const hook = nextHook(), fiber = getCurrentFiber();
416
+ if (!hook.q) {
417
+ hook.s = [];
418
+ const update = () => scheduleUpdate(fiber);
419
+ hook.q = (action: A) => {
420
+ const scope = ReactSharedInternals.B;
421
+ if (!scope?.p || fiber.u || fiber.pd)
422
+ return;
423
+ hook.s = [...hook.s, [scope, action]];
424
+ scope.l.add(update);
425
+ update();
426
+ };
427
+ }
428
+ hook.s = hook.s.filter(([scope]: [
429
+ ActionScope
430
+ ]) => scope.p > 0);
431
+ let value = state;
432
+ for (const [, action] of hook.s)
433
+ value = updateFn ? updateFn(value, action) : action;
434
+ if (!Object.is(hook.d, value))
435
+ hookFlags |= 1;
436
+ hook.d = value;
437
+ return [value, hook.q];
438
+ },
439
+ useEffect(create: () => any, deps?: ReadonlyArray<unknown>) {
440
+ useEffectImpl(0, create, deps);
441
+ },
442
+ useCacheRefresh(): () => void {
443
+ // There is no client cache to invalidate. Preserve hook identity and
444
+ // leave state and scheduling alone, as with the uncached client cache().
445
+ return this.useCallback(() => { }, []);
446
+ },
447
+ useState<S>(initial: S | (() => S)): [
448
+ S,
449
+ (a: BasicStateAction<S>) => void
450
+ ] {
451
+ return DISPATCHER.useReducer<S, BasicStateAction<S>>(basicReducer, initial, initialState);
452
+ },
453
+ useFormStatus() {
454
+ let parent = getCurrentFiber().p;
455
+ while (parent && parent.type !== 'form')
456
+ parent = parent.p;
457
+ const state = parent ? formState(parent) : null;
458
+ const subscribe = this.useCallback((listener: () => void) => {
459
+ state?.l.add(listener);
460
+ return () => { state?.l.delete(listener); };
461
+ }, [state]);
462
+ return this.useSyncExternalStore(subscribe, () => state?.s ?? idleFormStatus, () => idleFormStatus);
463
+ },
464
+ useId(): string {
465
+ const hook = nextHook();
466
+ const fiber = getCurrentFiber();
467
+ const root = findRoot(fiber);
468
+ if (root?.ri) {
469
+ const id = reactId(fiber, root);
470
+ return hook.s ??= id;
471
+ }
472
+ return hook.s ??= (root?.i ?? (root?.h ? ':R' : ':r')) + (root?.h ? root.ic++ : idCounter++).toString(36);
473
+ }
474
+ };
475
+ const basicReducer = <S>(state: S, action: BasicStateAction<S>): S => (isFunction(action) ? (action as (p: S) => S)(state) : action);
476
+ let idCounter = 0;
@@ -0,0 +1,41 @@
1
+ import { FiberTag, type Fiber } from '../core';
2
+ export function documentSingleton(fiber: Fiber): HTMLElement | null {
3
+ const doc = fiber.r?.c as Document | undefined;
4
+ return doc?.nodeType === 9 && DOCUMENT_SHELL_TAGS.test(fiber.type) ? doc[fiber.type === 'html' ? 'documentElement' : fiber.type as 'head' | 'body'] : null;
5
+ }
6
+ export const DOCUMENT_HEAD_TAGS = /^(base|link|meta|script|style|title)$/;
7
+ export const DOCUMENT_SHELL_TAGS = /^(html|head|body)$/;
8
+ export function clearAttributes(node: Element): void {
9
+ for (let attribute; attribute = node.attributes[0];)
10
+ node.removeAttribute(attribute.name);
11
+ }
12
+ // React's document server renderer hoists metadata even when a component
13
+ // returns it inside a body wrapper or a Suspense boundary.
14
+ export function documentMetadataParent(fiber: Fiber): HTMLHeadElement | null {
15
+ const container = fiber.r?.c;
16
+ const doc = container?.nodeType === 9 ? container as unknown as Document : container?.ownerDocument;
17
+ if (!doc?.head || fiber.v?.itemProp != null ||
18
+ !['title', 'meta', 'base', 'link'].includes(fiber.type) ||
19
+ fiber.type === 'link' && fiber.v?.rel === 'stylesheet')
20
+ return null;
21
+ for (let parent = fiber.p; parent; parent = parent.p) {
22
+ if (parent.t === FiberTag.Portal || parent.type === 'svg')
23
+ return null;
24
+ if (parent.type === 'foreignObject')
25
+ break;
26
+ }
27
+ return doc.head;
28
+ }
29
+ export function clearHostContainer(container: Node): void {
30
+ if (container.nodeType !== 9 && !DOCUMENT_SHELL_TAGS.test((container as Element).localName)) {
31
+ container.textContent = '';
32
+ return;
33
+ }
34
+ for (let index = container.childNodes.length; index--;) {
35
+ const node = container.childNodes[index]!, tag = (node as Element).localName;
36
+ if (DOCUMENT_SHELL_TAGS.test(tag))
37
+ clearHostContainer(node);
38
+ else if (node.nodeType !== 10 && !/^(script|style)$/.test(tag) && !(tag === 'link' && /^stylesheet$/i.test((node as HTMLLinkElement).rel)))
39
+ node.remove();
40
+ }
41
+ }
package/src/dom/dom.ts ADDED
@@ -0,0 +1,181 @@
1
+ import { createSyntheticEvent } from './synthetic-event';
2
+ import { UNITLESS_STYLE } from '../core/unitless-style';
3
+ import { devToolsMetadata } from '../core/devtools';
4
+ import { formActions } from './form-actions';
5
+ import { attributeName, attributeValue } from '../core/attributes';
6
+ import { isString } from "../core/functions";
7
+ const SVG_NS = 'http://www.w3.org/2000/svg';
8
+ const IDL_ATTRS = /^(value|checked|selected|disabled|multiple|muted|readonly)$/;
9
+ export const isSvgElement = (el: Element): boolean => (el.namespaceURI === SVG_NS);
10
+ export function setProp(el: Element, name: string, next: any, prev: any, isSvg: boolean): void {
11
+ if (isReservedProp(name))
12
+ return;
13
+ // These names need no alias or boolean-attribute normalization.
14
+ if (/^(aria|data)-./.test(name)) {
15
+ if (next == null)
16
+ el.removeAttribute(name);
17
+ else
18
+ el.setAttribute(name, '' + next);
19
+ return;
20
+ }
21
+ if (name === 'action' || name === 'formAction') {
22
+ if (isFunction(next)) {
23
+ formActions.set(el, next);
24
+ el.removeAttribute(name.toLowerCase());
25
+ return;
26
+ }
27
+ formActions.delete(el);
28
+ }
29
+ // defaultValue / defaultChecked are IDL-property-only — they seed the
30
+ // initial value/checked of a form control on first mount and must NOT be
31
+ // emitted as HTML attributes (which would leak as `defaultValue="..."`).
32
+ // Setting `el.defaultValue` on a fresh control also sets the initial
33
+ // `el.value`, which is what consumers expect. Skip on hydrated DOM so we
34
+ // don't clobber a live user-typed value.
35
+ if (name === 'defaultValue' || name === 'defaultChecked') {
36
+ if (prev === undefined && next != null) {
37
+ try {
38
+ ;
39
+ (el as any)[name] = next;
40
+ }
41
+ catch { }
42
+ }
43
+ return;
44
+ }
45
+ if (name === 'className' && !isSvg) {
46
+ ;
47
+ (el as HTMLElement).className = next == null ? '' : '' + next;
48
+ return;
49
+ }
50
+ if (name === 'style') {
51
+ setStyle(el as HTMLElement, next, prev);
52
+ return;
53
+ }
54
+ if (name === 'dangerouslySetInnerHTML') {
55
+ const nextHtml = next?.__html ?? '';
56
+ const prevHtml = prev?.__html ?? '';
57
+ if (nextHtml !== prevHtml)
58
+ (el as HTMLElement).innerHTML = nextHtml;
59
+ return;
60
+ }
61
+ if (name[0] === 'o' && name[1] === 'n') {
62
+ setEventHandler(el, name, next);
63
+ return;
64
+ }
65
+ const attr = attributeName(name, isSvg);
66
+ if (!isSvg && IDL_ATTRS.test(name) && name in el) {
67
+ try {
68
+ (el as any)[name] = next == null ? '' : next;
69
+ return;
70
+ } catch {}
71
+ }
72
+ const value = attributeValue(name, next, attr);
73
+ if (value === null) el.removeAttribute(attr);
74
+ else el.setAttribute(attr, value);
75
+ }
76
+ function setStyleProperty(style: CSSStyleDeclaration, key: string, value: any): void {
77
+ if (key[0] === '-') {
78
+ style.setProperty(key, value == null ? '' : '' + value);
79
+ }
80
+ else {
81
+ ;
82
+ (style as any)[key] = value == null || value === '' ? ''
83
+ : value + (typeof value === 'number' && !UNITLESS_STYLE.test(key) ? 'px' : '');
84
+ }
85
+ }
86
+ function setStyle(el: HTMLElement, next: any, prev: any): void {
87
+ const style = el.style;
88
+ if (isString(next)) {
89
+ style.cssText = next;
90
+ return;
91
+ }
92
+ if (isString(prev))
93
+ style.cssText = '';
94
+ if (prev && isObject(prev)) {
95
+ for (const k in prev) {
96
+ if (!next || !(k in next))
97
+ setStyleProperty(style, k, '');
98
+ }
99
+ }
100
+ if (next && isObject(next)) {
101
+ for (const k in next) {
102
+ if (!prev || prev[k] !== next[k])
103
+ setStyleProperty(style, k, next[k]);
104
+ }
105
+ }
106
+ }
107
+ function setEventHandler(el: Element, name: string, next: any): void {
108
+ // Only function handlers are accepted. Reject strings/objects/etc — the
109
+ // legacy `onclick="..."` HTML attribute (string handler) is a known XSS
110
+ // vector if a parent spreads untrusted props onto a host element. React
111
+ // also ignores non-function handlers.
112
+ const enabled = isFunction(next);
113
+ const capture = name.endsWith('Capture') && !name.endsWith('PointerCapture');
114
+ const lower = name.slice(2, capture ? -7 : undefined).toLowerCase();
115
+ const events = lower === 'change' && (el.tagName === 'TEXTAREA' ||
116
+ (el.tagName === 'INPUT' && !/^(checkbox|radio|file)$/.test((el as HTMLInputElement).type)))
117
+ ? ['input', 'change']
118
+ : [lower === 'focus' ? 'focusin' : lower === 'blur' ? 'focusout' : lower === 'doubleclick' ? 'dblclick' : lower];
119
+ // Key by the React prop name (not DOM event name) so `onChange` and
120
+ // `onInput` on the same text input — which both dispatch from the native
121
+ // `input` event — can coexist without clobbering each other's handlers.
122
+ const handlers = ((el as any).__h ||= Object.create(null));
123
+ let existing = handlers[name];
124
+ // Replace the listener when a control's type changes its native event.
125
+ if (existing && (!enabled || existing.e[0] !== events[0])) {
126
+ for (const event of existing.e)
127
+ el.removeEventListener(event, existing, capture);
128
+ if (enabled) delete (el as any).__v;
129
+ existing = handlers[name] = null;
130
+ }
131
+ if (!enabled)
132
+ return;
133
+ if (!existing) {
134
+ const entry = ((e: Event) => {
135
+ if (events.length > 1) {
136
+ const value = (el as HTMLInputElement).value;
137
+ if (e.type === 'change' && (el as any).__v === value)
138
+ return;
139
+ (el as any).__v = e.type === 'input' ? value : undefined;
140
+ }
141
+ const event = createSyntheticEvent(e);
142
+ try {
143
+ if (process.env.NODE_ENV !== 'production') {
144
+ const previous = devToolsMetadata.current;
145
+ devToolsMetadata.current = devToolsMetadata.hosts.get(el) || null;
146
+ try { entry.c(event); } finally { devToolsMetadata.current = previous; }
147
+ } else entry.c(event);
148
+ } finally { event.currentTarget = null; }
149
+ }) as ((e: Event) => void) & {
150
+ c: Function;
151
+ e: string[];
152
+ };
153
+ entry.e = events;
154
+ existing = handlers[name] = entry;
155
+ for (const event of events)
156
+ el.addEventListener(event, entry, capture);
157
+ }
158
+ existing.c = next;
159
+ }
160
+
161
+ export interface SyntheticEvent extends Event {
162
+ nativeEvent: Event;
163
+ isDefaultPrevented(): boolean;
164
+ isPropagationStopped(): boolean;
165
+ persist(): void;
166
+ currentTarget: EventTarget & Element;
167
+ }
168
+ export function createHostNode(type: string, isSvg: boolean, owner: Document = document): Element {
169
+ if (isSvg || type === 'svg') {
170
+ return owner.createElementNS(SVG_NS, type);
171
+ }
172
+ return owner.createElement(type);
173
+ }
174
+ import { isObject } from '../core/functions';
175
+ import { isFunction, isReservedProp } from '../core/functions';
176
+
177
+ // Renderer writes have already been observed by the app. Native change events
178
+ // should only report a value that differs from that renderer-owned value.
179
+ export function trackInputValue(el: HTMLInputElement | HTMLTextAreaElement): void {
180
+ (el as any).__v = el.value;
181
+ }