@bleedingdev/tanstack-redact 0.0.0-bootstrap → 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 +1 -1
  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 +113 -8
  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,454 @@
1
+ import { FiberTag, type Fiber, type FiberRoot } from '../../../core';
2
+ import { REACT_VIEW_TRANSITION_TYPE, type ViewTransitionClass, type ViewTransitionInstance, type ViewTransitionProps, type ViewTransitionPseudoElement, } from '../../../react/view-transition';
3
+ import { isFunction } from '../../../core/functions';
4
+ import { transitionResources, type TransitionImages } from './resources';
5
+ type Kind = 'enter' | 'exit' | 'update' | 'share';
6
+ type Host = HTMLElement | SVGElement;
7
+ type Rect = [
8
+ number,
9
+ number,
10
+ number,
11
+ number
12
+ ];
13
+ interface Boundary {
14
+ f: Fiber;
15
+ p: ViewTransitionProps;
16
+ h: Host[];
17
+ a: Fiber[];
18
+ r: Fiber | null;
19
+ n: string;
20
+ e: boolean;
21
+ s: Rect[];
22
+ c: string;
23
+ v: boolean;
24
+ }
25
+ interface Snapshot {
26
+ b: Map<Fiber, Boundary>;
27
+ v: Set<Fiber>;
28
+ i: TransitionImages;
29
+ }
30
+ interface Capture {
31
+ o?: Boundary | undefined;
32
+ n?: Boundary | undefined;
33
+ k: Kind;
34
+ s: string;
35
+ h: Host[];
36
+ e: boolean;
37
+ }
38
+ interface Event {
39
+ b: Boundary;
40
+ k: Kind;
41
+ n: string;
42
+ }
43
+ const names = new WeakMap<Fiber, string>();
44
+ const styleProperties = ['view-transition-name', 'view-transition-class'];
45
+ let nextName = 0;
46
+ function pseudo(doc: Document, kind: string, name: string): ViewTransitionPseudoElement {
47
+ const scope = doc.documentElement;
48
+ const selector = '::view-transition-' + kind + '(' + nativeName(name) + ')';
49
+ return {
50
+ animate(keyframes, options) {
51
+ return scope.animate(keyframes, { ...(typeof options === 'number' ? { duration: options } : options), pseudoElement: selector });
52
+ },
53
+ getAnimations() {
54
+ return scope.getAnimations({ subtree: true }).filter(animation => {
55
+ const effect = animation.effect as KeyframeEffect | null;
56
+ return effect?.target === scope && effect.pseudoElement === selector;
57
+ });
58
+ },
59
+ getComputedStyle() { return doc.defaultView!.getComputedStyle(scope, selector); },
60
+ };
61
+ }
62
+ // Ignore nested boundary content: its mutations belong to that boundary.
63
+ function contents(node: Node, nested: Set<Node>, first?: boolean): string {
64
+ if (!first && nested.has(node))
65
+ return '|';
66
+ if (node.nodeType === 3)
67
+ return JSON.stringify(node.nodeValue);
68
+ if (node.nodeType !== 1)
69
+ return '';
70
+ const element = node as Host;
71
+ let result = '<' + element.nodeName;
72
+ for (const attribute of element.attributes) {
73
+ if (attribute.name !== 'style')
74
+ result += ' ' + attribute.name + '=' + JSON.stringify(attribute.value);
75
+ }
76
+ for (let i = 0; i < element.style.length; i++) {
77
+ const property = element.style[i]!;
78
+ if (property !== 'view-transition-name' && property !== 'view-transition-class') {
79
+ result += ';' + property + ':' + element.style.getPropertyValue(property) + '!' + element.style.getPropertyPriority(property);
80
+ }
81
+ }
82
+ if ('value' in element)
83
+ result += '=' + (element as HTMLInputElement).value;
84
+ if ('checked' in element)
85
+ result += ':' + (element as HTMLInputElement).checked;
86
+ result += '>';
87
+ for (let child = node.firstChild; child; child = child.nextSibling)
88
+ result += contents(child, nested);
89
+ return result + '</' + element.nodeName + '>';
90
+ }
91
+ function className(props: ViewTransitionProps, kind: Kind, types: string[]): string | undefined {
92
+ const value = byType(props[kind], types) ?? byType(props.default, types);
93
+ return value === 'auto' ? undefined : value;
94
+ }
95
+ function snapshot(roots: FiberRoot[], doc: Document, types: string[], connected = true): Snapshot {
96
+ const boundaries = new Map<Fiber, Boundary>();
97
+ const visible = new Set<Fiber>();
98
+ const images: TransitionImages = new Map();
99
+ const allHosts = new Set<Node>();
100
+ const empty: Boundary[] = [];
101
+ const ancestors: Fiber[] = [];
102
+ function walk(fiber: Fiber, parent: Fiber | null, pending: Boundary[]): void {
103
+ if (fiber.u)
104
+ return;
105
+ if (fiber.type === REACT_VIEW_TRANSITION_TYPE) {
106
+ const props: ViewTransitionProps = fiber.v ?? {};
107
+ const explicitName = byType(props.name, types);
108
+ let name = explicitName;
109
+ if (name == null || name === 'auto') {
110
+ name = names.get(fiber);
111
+ if (!name)
112
+ names.set(fiber, name = '_redact_t_' + (++nextName).toString(32));
113
+ }
114
+ const boundary: Boundary = {
115
+ f: fiber, p: props, h: [], a: ancestors.slice(), r: parent, n: name,
116
+ e: explicitName != null && explicitName !== 'auto', s: [], c: '', v: false,
117
+ };
118
+ boundaries.set(fiber, boundary);
119
+ pending = pending.concat(boundary);
120
+ parent = fiber;
121
+ }
122
+ if (fiber.t === FiberTag.Host) {
123
+ visible.add(fiber);
124
+ const dom = fiber.n as Host | null;
125
+ if (parent && fiber.type === 'img' && dom?.ownerDocument === doc) {
126
+ images.set(dom as HTMLImageElement, fiber.v);
127
+ }
128
+ if (pending.length && dom?.ownerDocument === doc && (!connected || dom.isConnected) && dom.style) {
129
+ for (const boundary of pending)
130
+ boundary.h.push(dom);
131
+ allHosts.add(dom);
132
+ }
133
+ pending = empty;
134
+ ancestors.push(fiber);
135
+ }
136
+ visibleChildren(fiber, child => walk(child, parent, pending));
137
+ if (fiber.t === FiberTag.Host)
138
+ ancestors.pop();
139
+ }
140
+ for (const root of roots)
141
+ walk(root.r, null, empty);
142
+ const view = doc.defaultView;
143
+ if (connected)
144
+ for (const boundary of boundaries.values()) {
145
+ boundary.s = boundary.h.map(host => {
146
+ const rect = host.getBoundingClientRect();
147
+ return [rect.x, rect.y, rect.width, rect.height];
148
+ });
149
+ boundary.v = boundary.s.some(([x, y, width, height]) => width > 0 && height > 0 && x + width > 0 && y + height > 0 && x < (view?.innerWidth ?? Infinity) && y < (view?.innerHeight ?? Infinity));
150
+ boundary.c = boundary.h.map(host => contents(host, allHosts, true)).join('');
151
+ }
152
+ return { b: boundaries, v: visible, i: images };
153
+ }
154
+ export function prepareViewTransition(rootIterable: Iterable<FiberRoot>, types: string[]): PreparedViewTransition | null {
155
+ const roots = Array.from(rootIterable);
156
+ const container = roots[0]?.c;
157
+ const doc = (container?.ownerDocument || container) as Document | undefined;
158
+ if (!doc?.documentElement)
159
+ return null;
160
+ const before = snapshot(roots, doc, types);
161
+ const saved = new Map<Host, string[]>();
162
+ const suppressed = new Set<string>();
163
+ const events: Event[] = [];
164
+ const cleanups: (() => void)[] = [];
165
+ const captures: Capture[] = [];
166
+ let done = false;
167
+ let after: Snapshot;
168
+ let resources: ReturnType<typeof transitionResources> | undefined;
169
+ function apply(host: Host, name: string, classes?: string): void {
170
+ let previous = saved.get(host);
171
+ if (!previous)
172
+ saved.set(host, previous = []);
173
+ for (let index = 0; index < 2; index++) {
174
+ const property = styleProperties[index]!;
175
+ const offset = index * 3;
176
+ const current = host.style.getPropertyValue(property);
177
+ // A committed style prop may replace either temporary value.
178
+ if (current !== previous[offset + 2]) {
179
+ previous[offset] = current;
180
+ previous[offset + 1] = host.style.getPropertyPriority(property);
181
+ }
182
+ const value = index ? classes === 'none' ? '' : classes ?? previous[offset]! : nativeName(name);
183
+ host.style.setProperty(property, previous[offset + 2] = value, 'important');
184
+ }
185
+ }
186
+ function applyHosts(hosts: Host[], name: string, props: ViewTransitionProps, kind: Kind): void {
187
+ const classes = className(props, kind, types);
188
+ hosts.forEach((host, index) => apply(host, index ? name + '_' + index : name, classes));
189
+ }
190
+ function suppress(hosts: Host[], name: string): void {
191
+ hosts.forEach((_, index) => suppressed.add(index ? name + '_' + index : name));
192
+ }
193
+ function ownership(side: 'o' | 'n'): Map<Host, Capture> {
194
+ const owners = new Map<Host, Capture>();
195
+ for (const capture of captures) {
196
+ if (side === 'n' && !capture.e)
197
+ continue;
198
+ for (const host of capture[side]?.h ?? [])
199
+ owners.set(host, capture);
200
+ }
201
+ return owners;
202
+ }
203
+ function capture(kind: Kind, old?: Boundary, next?: Boundary, enabled = true): void {
204
+ captures.push({ o: old, n: next, k: kind, s: (old ?? next)!.n, h: [], e: !!next && enabled });
205
+ }
206
+ function restore(): void {
207
+ for (const [host, previous] of saved) {
208
+ for (let index = 0; index < 2; index++) {
209
+ const property = styleProperties[index]!;
210
+ const offset = index * 3;
211
+ if (host.style.getPropertyValue(property) === previous[offset + 2]) {
212
+ host.style.setProperty(property, previous[offset]!, previous[offset + 1]);
213
+ }
214
+ }
215
+ }
216
+ saved.clear();
217
+ }
218
+ function finish(): void {
219
+ if (done)
220
+ return;
221
+ done = true;
222
+ resources?.cancel();
223
+ restore();
224
+ let error: unknown;
225
+ let failed = false;
226
+ for (const cleanup of cleanups.splice(0)) {
227
+ try {
228
+ cleanup();
229
+ }
230
+ catch (caught) {
231
+ if (!failed) {
232
+ error = caught;
233
+ failed = true;
234
+ }
235
+ }
236
+ }
237
+ if (failed)
238
+ throw error;
239
+ }
240
+ return {
241
+ document: doc,
242
+ exclude(root) {
243
+ const index = roots.indexOf(root);
244
+ if (index >= 0)
245
+ roots.splice(index, 1);
246
+ for (const [fiber] of before.b)
247
+ if (fiber.r === root)
248
+ before.b.delete(fiber);
249
+ },
250
+ prepare() {
251
+ after = snapshot(roots, doc, types, false);
252
+ resources = transitionResources(doc, before.i, after.i);
253
+ return resources.before();
254
+ },
255
+ waitForResources(fontsWereLoaded) {
256
+ if (!done)
257
+ return resources?.after(fontsWereLoaded);
258
+ },
259
+ beforeCommit() {
260
+ if (done)
261
+ return false;
262
+ const entering = new Map<string, Boundary>();
263
+ const paired = new Set<Fiber>();
264
+ for (const boundary of after.b.values()) {
265
+ if (!before.b.has(boundary.f) && boundary.e)
266
+ entering.set(boundary.n, boundary);
267
+ }
268
+ for (const old of before.b.values()) {
269
+ const current = after.b.get(old.f);
270
+ if (current) {
271
+ if (className(current.p, 'update', types) !== 'none')
272
+ capture('update', old, current);
273
+ }
274
+ else {
275
+ const shared = old.e && old.v ? entering.get(old.n) : undefined;
276
+ if (shared) {
277
+ entering.delete(old.n);
278
+ if (className(old.p, 'share', types) !== 'none') {
279
+ paired.add(shared.f);
280
+ capture('share', old, shared, className(shared.p, 'share', types) !== 'none');
281
+ }
282
+ }
283
+ else if (topLevel(old, after, before) && old.v && className(old.p, 'exit', types) !== 'none') {
284
+ capture('exit', old);
285
+ }
286
+ }
287
+ }
288
+ for (const boundary of after.b.values()) {
289
+ if (before.b.has(boundary.f) || paired.has(boundary.f))
290
+ continue;
291
+ if (topLevel(boundary, before, after) && className(boundary.p, 'enter', types) !== 'none') {
292
+ capture('enter', undefined, boundary);
293
+ }
294
+ }
295
+ // A directly nested boundary owns updates; an outer presence boundary
296
+ // owns entering/exiting hosts. Shared descendants take precedence.
297
+ captures.sort((a, b) => (a.k === 'share' ? 2 : a.k === 'update' ? 0 : 1) - (b.k === 'share' ? 2 : b.k === 'update' ? 0 : 1));
298
+ if (!captures.some(capture => capture.o?.h.length || (capture.e && capture.n?.h.length)))
299
+ return false;
300
+ const owners = ownership('o');
301
+ apply(doc.documentElement, 'none');
302
+ for (const boundary of before.b.values())
303
+ for (const host of boundary.h)
304
+ apply(host, 'none');
305
+ for (const capture of captures) {
306
+ capture.h = capture.o?.h.filter(host => owners.get(host) === capture) ?? [];
307
+ const props = capture.k === 'update' ? capture.n!.p : capture.o?.p;
308
+ if (props)
309
+ applyHosts(capture.h, capture.s, props, capture.k);
310
+ }
311
+ return true;
312
+ },
313
+ afterCommit() {
314
+ if (done)
315
+ return;
316
+ const after = snapshot(roots, doc, types);
317
+ for (const capture of captures) {
318
+ if (capture.n)
319
+ capture.n = after.b.get(capture.n.f);
320
+ if (capture.k !== 'update' && !capture.n?.v)
321
+ capture.e = false;
322
+ }
323
+ const owners = ownership('n');
324
+ for (const boundary of after.b.values())
325
+ for (const host of boundary.h)
326
+ apply(host, 'none');
327
+ for (const capture of captures) {
328
+ const newHosts = capture.n?.h.filter(host => owners.get(host) === capture) ?? [];
329
+ if (capture.n)
330
+ applyHosts(newHosts, capture.s, capture.n.p, capture.k);
331
+ if (!capture.h.length && !newHosts.length)
332
+ continue;
333
+ if (capture.k === 'update') {
334
+ if (capture.n && capture.o && changed(capture.o, capture.n))
335
+ events.push({ b: capture.n, n: capture.s, k: 'update' });
336
+ else
337
+ suppress(capture.h, capture.s);
338
+ }
339
+ else {
340
+ const boundary = capture.k === 'enter' ? capture.n : capture.o;
341
+ if (boundary)
342
+ events.push({ b: boundary, n: capture.s, k: capture.k });
343
+ }
344
+ }
345
+ },
346
+ ready() {
347
+ if (done)
348
+ return;
349
+ // These captures were needed before the synchronous commit could tell
350
+ // which boundaries changed. Cancel their native animations, not the DOM.
351
+ const nativeSuppressed = new Set([...suppressed].map(nativeName));
352
+ for (const animation of doc.documentElement.getAnimations({ subtree: true })) {
353
+ const effect = animation.effect as KeyframeEffect | null;
354
+ const selector = effect?.pseudoElement;
355
+ if (effect?.target !== doc.documentElement || !selector)
356
+ continue;
357
+ const start = selector.indexOf('(');
358
+ if (start >= 0 && nativeSuppressed.has(selector.slice(start + 1, -1)))
359
+ animation.cancel();
360
+ }
361
+ for (const name of suppressed) {
362
+ const animation = pseudo(doc, 'group', name).animate({ opacity: 0 }, { duration: 0, fill: 'forwards' });
363
+ cleanups.push(() => animation.cancel());
364
+ }
365
+ let error: unknown;
366
+ let failed = false;
367
+ for (const event of events) {
368
+ if (done)
369
+ break;
370
+ const callback = event.b.p[('on' + event.k[0]!.toUpperCase() + event.k.slice(1)) as 'onEnter'];
371
+ if (callback) {
372
+ try {
373
+ const cleanup = callback(instance(doc, event.n), types);
374
+ if (isFunction(cleanup)) {
375
+ if (done)
376
+ cleanup();
377
+ else
378
+ cleanups.push(cleanup);
379
+ }
380
+ }
381
+ catch (caught) {
382
+ if (!failed) {
383
+ error = caught;
384
+ failed = true;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ if (failed)
390
+ throw error;
391
+ },
392
+ restore,
393
+ finish,
394
+ cancel: finish,
395
+ };
396
+ }
397
+ function visibleChildren(fiber: Fiber, visit: (child: Fiber) => void): void {
398
+ if (fiber.t === FiberTag.Activity && fiber.v?.mode === 'hidden')
399
+ return;
400
+ if (fiber.t === FiberTag.Suspense && fiber.b?.f) {
401
+ visit(fiber.b.f);
402
+ return;
403
+ }
404
+ for (let child = fiber.c; child; child = child.s)
405
+ visit(child);
406
+ }
407
+ const nativeName = (name: string): string => (CSS.escape(name) === name ? name : CSS.escape('r-' + btoa(name).replace(/=/g, '')));
408
+ const instance = (doc: Document, name: string): ViewTransitionInstance => ({
409
+ name,
410
+ group: pseudo(doc, 'group', name),
411
+ imagePair: pseudo(doc, 'image-pair', name),
412
+ old: pseudo(doc, 'old', name),
413
+ new: pseudo(doc, 'new', name),
414
+ });
415
+ function byType(value: ViewTransitionClass | undefined, types: string[]): string | undefined {
416
+ if (isString(value))
417
+ return value;
418
+ if (!value)
419
+ return undefined;
420
+ let result: string | undefined;
421
+ for (const type of types) {
422
+ const match = value[type];
423
+ if (match === 'none')
424
+ return match;
425
+ if (match != null)
426
+ result = result == null ? match : result + ' ' + match;
427
+ }
428
+ return result ?? value.default;
429
+ }
430
+ const changed = (before: Boundary, after: Boundary): boolean => (before.c !== after.c || before.h.length !== after.h.length ||
431
+ before.h.some((host, i) => host !== after.h[i] || before.s[i]!.some((value, axis) => value !== after.s[i]![axis])));
432
+ export interface PreparedViewTransition {
433
+ document: Document;
434
+ exclude(root: FiberRoot): void;
435
+ prepare(): Promise<void> | undefined;
436
+ waitForResources(fontsWereLoaded: boolean): Promise<void> | undefined;
437
+ beforeCommit(): boolean;
438
+ afterCommit(): void;
439
+ ready(): void;
440
+ restore(): void;
441
+ finish(): void;
442
+ cancel(): void;
443
+ }
444
+ function topLevel(boundary: Boundary, other: Snapshot, side: Snapshot): boolean {
445
+ // An inserted/deleted host wrapper owns its subtree's enter/exit animation.
446
+ if (boundary.a.some(fiber => !other.v.has(fiber)))
447
+ return false;
448
+ for (let parent = boundary.r; parent; parent = side.b.get(parent)?.r ?? null) {
449
+ if (!other.b.has(parent))
450
+ return false;
451
+ }
452
+ return true;
453
+ }
454
+ import { isString } from "../../../core/functions";
@@ -0,0 +1,69 @@
1
+ import { walkRetained } from './walk';
2
+ import { syncInputValue, syncTextareaValue, syncSelectValue } from './form-controls';
3
+ import { FiberTag, type Fiber } from '../core';
4
+ import { runAction } from '../react/action-scope';
5
+ import { formState, idleFormStatus, publishForm } from '../react/form-state';
6
+ import { getRootContainer } from './root-internal';
7
+ const forms = new WeakMap<HTMLFormElement, Fiber>();
8
+ const listening = new WeakSet<Node>();
9
+ const handled = new WeakSet<Event>();
10
+ export const formActions = new WeakMap<Element, (data: FormData) => unknown>();
11
+ function resetForm(form: HTMLFormElement, owner: Fiber): void {
12
+ form.ownerDocument.defaultView!.HTMLFormElement.prototype.reset.call(form);
13
+ walkRetained(owner.r!.r, fiber => {
14
+ const props = fiber.m;
15
+ if (fiber.n && props && (fiber.n as HTMLInputElement).form === form) {
16
+ if (fiber.type === 'input')
17
+ syncInputValue(fiber.n as HTMLInputElement, props, props);
18
+ else if (fiber.type === 'textarea')
19
+ syncTextareaValue(fiber.n as HTMLTextAreaElement, props);
20
+ else if (fiber.type === 'select' && props.value != null) {
21
+ const select = fiber.n as HTMLSelectElement;
22
+ syncSelectValue(select, props);
23
+ }
24
+ }
25
+ });
26
+ }
27
+ export function requestFormReset(form: HTMLFormElement): void {
28
+ const owner = forms.get(form);
29
+ if (!owner || owner.u)
30
+ throw new Error(process.env.NODE_ENV !== 'production' ? 'requestFormReset expects a mounted form rendered by Redact.' : '');
31
+ resetForm(form, owner);
32
+ }
33
+ export function bindForm(fiber: Fiber, onError: (fiber: Fiber, error: unknown) => void): void {
34
+ const form = fiber.n as HTMLFormElement;
35
+ forms.set(form, fiber);
36
+ const container = getRootContainer(fiber);
37
+ if (listening.has(container))
38
+ return;
39
+ listening.add(container);
40
+ container.addEventListener('submit', event => {
41
+ if (event.defaultPrevented || handled.has(event))
42
+ return;
43
+ const form = event.target as HTMLFormElement;
44
+ const owner = forms.get(form);
45
+ if (!owner || owner.u)
46
+ return;
47
+ const submitter = (event as SubmitEvent).submitter as HTMLButtonElement | HTMLInputElement | null;
48
+ const override = submitter?.hasAttribute('formaction') || (submitter && formActions.has(submitter));
49
+ const action = override ? formActions.get(submitter!) : formActions.get(form);
50
+ if (!action)
51
+ return;
52
+ handled.add(event);
53
+ event.preventDefault();
54
+ const data = new FormData(form, submitter);
55
+ const state = formState(owner);
56
+ const generation = ++state.g;
57
+ publishForm(state, { pending: true, data, method: 'post', action });
58
+ const scope = runAction(() => action(data));
59
+ scope.d.then(() => {
60
+ if (owner.u || generation !== state.g)
61
+ return;
62
+ if (!scope.f)
63
+ resetForm(form, owner);
64
+ publishForm(state, idleFormStatus);
65
+ if (scope.f && !scope.h)
66
+ onError(owner, scope.e);
67
+ });
68
+ });
69
+ }
@@ -0,0 +1,91 @@
1
+ import { trackInputValue } from './dom';
2
+ export function syncTextareaValue(el: HTMLTextAreaElement, props: any, mounting?: boolean): void {
3
+ if (mounting) {
4
+ const children = props.children;
5
+ const initial = props.value ?? props.defaultValue ?? (Array.isArray(children) ? children[0] : children) ?? '';
6
+ el.defaultValue = initial;
7
+ // The strict check also preserves React's clean numeric-default state.
8
+ if (initial !== '' && el.textContent === initial) {
9
+ el.value = initial;
10
+ trackInputValue(el);
11
+ }
12
+ return;
13
+ }
14
+ const value = props.value;
15
+ if (value != null && el.value !== '' + value) {
16
+ el.value = '' + value;
17
+ trackInputValue(el);
18
+ }
19
+ const fallback = props.defaultValue ?? value ?? '';
20
+ if (el.defaultValue !== '' + fallback)
21
+ el.defaultValue = '' + fallback;
22
+ }
23
+ export function syncInputValue(el: HTMLInputElement, props: any, prev?: any): void {
24
+ if (!prev) {
25
+ el.checked = el.defaultChecked = !!(props.checked ?? props.defaultChecked);
26
+ }
27
+ else if (props.checked != null) {
28
+ el.checked = !!props.checked;
29
+ }
30
+ else if (props.defaultChecked != null) {
31
+ el.defaultChecked = !!props.defaultChecked;
32
+ }
33
+ const value = props.value;
34
+ const fallback = props.defaultValue;
35
+ if (!prev) {
36
+ if (value == null && (el.type === 'submit' || el.type === 'reset'))
37
+ return;
38
+ if (value != null || fallback != null) {
39
+ const initial = '' + (value ?? fallback);
40
+ if (el.value !== initial) {
41
+ el.value = initial;
42
+ trackInputValue(el);
43
+ }
44
+ el.defaultValue = initial;
45
+ }
46
+ return;
47
+ }
48
+ if (value != null) {
49
+ // Number inputs keep equivalent user spelling, including trailing zeroes.
50
+ if (el.type === 'number' ? (value === 0 && el.value === '') || el.value != value : el.value !== '' + value) {
51
+ el.value = '' + value;
52
+ trackInputValue(el);
53
+ }
54
+ const nextDefault = el.type === 'number' && el.value == value ? el.value : '' + value;
55
+ if (el.defaultValue !== nextDefault)
56
+ el.defaultValue = nextDefault;
57
+ }
58
+ else if (fallback != null) {
59
+ if (el.defaultValue !== '' + fallback)
60
+ el.defaultValue = '' + fallback;
61
+ }
62
+ else if (prev.defaultValue != null || el.type === 'submit' || el.type === 'reset') {
63
+ el.removeAttribute('value');
64
+ }
65
+ }
66
+ export function syncSelectValue(select: HTMLSelectElement, props: any, prev?: any): void {
67
+ const multiple = select.multiple;
68
+ const value = props.value ?? ((!prev || !!prev.multiple !== multiple) ? props.defaultValue ?? (prev && []) : null);
69
+ if (value == null)
70
+ return;
71
+ const defaults = props.value == null && props.defaultValue != null;
72
+ const selected = new Set(multiple ? value.map(String) : ['' + value]);
73
+ let fallback: HTMLOptionElement | undefined;
74
+ for (const option of select.options) {
75
+ const match = selected.has(option.value);
76
+ if (defaults && match)
77
+ option.defaultSelected = true;
78
+ if (multiple)
79
+ option.selected = match;
80
+ else {
81
+ if (match) {
82
+ fallback = option;
83
+ break;
84
+ }
85
+ if (!fallback && !option.disabled)
86
+ fallback = option;
87
+ }
88
+ }
89
+ if (fallback)
90
+ fallback.selected = true;
91
+ }