@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,555 @@
1
+ import { boundaryId } from './stream-ids'
2
+ import { childInsertionContext, type InsertionContext } from './insertion-context'
3
+ import { forkId } from '../dom/react-ids'
4
+ import { isTextContent } from '../core/functions';
5
+ import { isFunction, isThenable } from '../core/functions'
6
+ import { resolveClassProps } from '../core/class-props'
7
+ import {
8
+ REACT_ELEMENT_TYPE,
9
+ REACT_LEGACY_ELEMENT_TYPE,
10
+ REACT_FRAGMENT_TYPE,
11
+ type ReactNode,
12
+ type ReactElement,
13
+ } from '../core'
14
+ import {
15
+ REACT_SUSPENSE_TYPE,
16
+ REACT_CONTEXT_TYPE,
17
+ REACT_PROVIDER_TYPE,
18
+ REACT_CONSUMER_TYPE,
19
+ REACT_FORWARD_REF_TYPE,
20
+ REACT_MEMO_TYPE,
21
+ REACT_LAZY_TYPE,
22
+ REACT_STRICT_MODE_TYPE,
23
+ REACT_PROFILER_TYPE,
24
+ REACT_PORTAL_TYPE,
25
+ REACT_ACTIVITY_TYPE,
26
+ REACT_VIEW_TRANSITION_TYPE,
27
+ } from '../react'
28
+ import {
29
+ escapeAttr,
30
+ attrToHtml,
31
+ escapeText,
32
+ escapeScript,
33
+ VOID_ELEMENTS,
34
+ RAW_TEXT_ELEMENTS,
35
+ } from './escape'
36
+ import {
37
+ pushContext,
38
+ popContext,
39
+ snapshotContexts,
40
+ recordHostResource,
41
+ currentSSRFrame,
42
+ type ContextSnapshot,
43
+ } from './dispatcher'
44
+ import { isBrowserError } from '../core/browser'
45
+ import { resourceKind } from '../core/resource-hints'
46
+ import type { ResourceScope } from './resource-hints'
47
+
48
+ export interface ServerErrorInfo {
49
+ componentStack: string
50
+ }
51
+
52
+ export type BrowserBailoutCallback = (error: Error, errorInfo: ServerErrorInfo) => void
53
+
54
+ /** Streamed output keeps pending boundaries addressable until it is written. */
55
+ export type HtmlPart = string | SuspendedBoundary
56
+
57
+ export interface SuspendedBoundary {
58
+ id: number
59
+ treeId: bigint
60
+ insertionContext: InsertionContext
61
+ fallback: HtmlPart[]
62
+ children: ReactNode
63
+ thenable: Promise<any>
64
+ contextSnapshot: ContextSnapshot
65
+ componentStack: string
66
+ // Set by the stream: completed content and failure markers are inlined
67
+ // when the boundary is written; `written` boundaries need a later reveal.
68
+ content?: HtmlPart[]
69
+ marker?: string
70
+ written?: boolean
71
+ }
72
+
73
+ export interface WalkOptions {
74
+ insertionContext?: InsertionContext | undefined
75
+ treeId?: bigint | undefined
76
+ emit: (chunk: HtmlPart) => void
77
+ onHead?: () => void
78
+ onSuspend?: ((boundary: SuspendedBoundary) => void) | undefined
79
+ onBrowserBailout?: BrowserBailoutCallback | undefined
80
+ onError?: ((error: unknown) => unknown) | undefined
81
+ componentStack?: string | undefined
82
+ thrownInfo?: { componentStack?: string | undefined }
83
+ nextBoundaryId: () => number
84
+ bootstrapped?: boolean | undefined
85
+ isBoundaryResolution?: boolean | undefined
86
+ resourceScope?: ResourceScope | undefined
87
+ // Shared traversal flags: SVG = 1, adjacent text = 2.
88
+ // Host children restore previous flags on return or throw.
89
+ textState?: { bits: number }
90
+ }
91
+
92
+ /**
93
+ * Synchronously walk a React node and emit HTML string pieces to `opts.emit`.
94
+ * Suspended boundaries are emitted as fallbacks with marker IDs; if `opts.onSuspend`
95
+ * is provided, the suspension is recorded for later streaming.
96
+ */
97
+ export function walk(node: ReactNode, opts: WalkOptions): void {
98
+ // Seed a text state if the caller didn't provide one so the separator logic
99
+ // is active for the whole tree.
100
+ if (!opts.textState) opts = { ...opts, textState: { bits: +(opts.insertionContext === 'svg') } }
101
+ walkNode(node, opts)
102
+ }
103
+
104
+ // --- <select> selection context ----------------------------------------------
105
+ // Stack of active select values (or `undefined` when the current select has
106
+ // no controlled value). `<option>` walks read the top of stack to decide
107
+ // whether to emit `selected=""`.
108
+ const selectValueStack: unknown[] = []
109
+ function pushSelectContext(value: unknown): void {
110
+ selectValueStack.push(value)
111
+ }
112
+ function popSelectContext(): void {
113
+ selectValueStack.pop()
114
+ }
115
+ function currentSelectValue(): unknown {
116
+ return selectValueStack.length ? selectValueStack[selectValueStack.length - 1] : undefined
117
+ }
118
+
119
+ function optionChildText(children: unknown): string {
120
+ // `<option>Text</option>` — if no `value` prop, the option's value is its
121
+ // flat string/number child content. Matches DOM semantics (`option.value`
122
+ // defaults to `textContent` when no attribute is set).
123
+ if (children == null) return ''
124
+ if (isTextContent(children)) return '' + children
125
+ if (Array.isArray(children)) return children.map(optionChildText).join('')
126
+ return ''
127
+ }
128
+
129
+ function emitText(text: string, opts: WalkOptions): void {
130
+ // Empty string renders no text node and doesn't start/extend a text flow —
131
+ // skip entirely so sibling text isn't separated by a stray `<!-- -->`.
132
+ if (text === '') return
133
+ if (opts.textState!.bits & 2) opts.emit('<!-- -->')
134
+ opts.emit(escapeText(text))
135
+ opts.textState!.bits |= 2
136
+ }
137
+
138
+ function walkNode(node: ReactNode, opts: WalkOptions): void {
139
+ if (node == null || node === false || node === true) return
140
+
141
+ if (isTextContent(node)) {
142
+ emitText('' + node, opts)
143
+ return
144
+ }
145
+ if (Array.isArray(node)) {
146
+ const treeId = opts.treeId ?? 1n
147
+ for (let i = 0; i < node.length; i++) walkNode(node[i], { ...opts, treeId: forkId(treeId, node.length, i) })
148
+ return
149
+ }
150
+ if (isFunction((node as any)[Symbol.iterator])) {
151
+ walkNode(Array.from(node as Iterable<ReactNode>), opts)
152
+ return
153
+ }
154
+
155
+ if (typeof node !== 'object') return
156
+ const t = (node as any).$$typeof
157
+
158
+ // Raw React.lazy in the tree (RSC Flight encodes 'use client' components —
159
+ // CodeBlock, CodeExplorer, etc. — as bare Lazy objects directly in the
160
+ // tree, not wrapped in REACT_ELEMENT_TYPE). SSR previously dropped these
161
+ // here, so code snippets never made it into the server HTML. The RSC
162
+ // decoder server-side awaits payloads before rendering, so status is
163
+ // 'fulfilled' and `_init()` returns the resolved element synchronously.
164
+ // If still pending (shouldn't happen post-awaitLazyElements), throw the
165
+ // thenable so streaming SSR suspends the current boundary and retries.
166
+ if (t === REACT_LAZY_TYPE) {
167
+ const lazy = node as any
168
+ const resolved = lazy._init(lazy._payload)
169
+ walkNode(resolved, opts)
170
+ return
171
+ }
172
+
173
+ if (t !== REACT_ELEMENT_TYPE && t !== REACT_LEGACY_ELEMENT_TYPE) return
174
+
175
+ const el = node as ReactElement
176
+ walkElement(el, opts)
177
+ }
178
+
179
+ function walkElement(el: ReactElement, opts: WalkOptions): void {
180
+ const type = el.type
181
+ const props = el.props ?? {}
182
+
183
+ if (typeof type === 'string') {
184
+ walkHost(type, props, opts)
185
+ return
186
+ }
187
+
188
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PROFILER_TYPE) {
189
+ walkNode(props.children, opts)
190
+ return
191
+ }
192
+
193
+ if (type === REACT_SUSPENSE_TYPE) {
194
+ walkSuspense(props, opts)
195
+ return
196
+ }
197
+
198
+ if (type === REACT_ACTIVITY_TYPE) {
199
+ if (props.mode !== 'hidden') walkNode(props.children, opts)
200
+ return
201
+ }
202
+ if (type === REACT_VIEW_TRANSITION_TYPE) {
203
+ walkNode(props.children, opts)
204
+ return
205
+ }
206
+
207
+ const marker = (type as any)?.$$typeof
208
+
209
+ if (marker === REACT_PORTAL_TYPE) {
210
+ // Portals don't render to the main HTML output on the server.
211
+ return
212
+ }
213
+
214
+ if (marker === REACT_CONTEXT_TYPE || marker === REACT_PROVIDER_TYPE) {
215
+ const ctx = (type as any)._context
216
+ pushContext(ctx, props.value)
217
+ try {
218
+ walkNode(props.children, opts)
219
+ } finally {
220
+ popContext(ctx)
221
+ }
222
+ return
223
+ }
224
+
225
+ if (marker === REACT_CONSUMER_TYPE) {
226
+ const render = props.children
227
+ if (isFunction(render)) {
228
+ walkNode(render((type as any)._context._currentValue), opts)
229
+ }
230
+ return
231
+ }
232
+
233
+ if (marker === REACT_FORWARD_REF_TYPE) {
234
+ const render = (type as any).render
235
+ const ref = (props as any).ref ?? null
236
+ const { ref: _omit, ...rest } = props as any
237
+ walkComponent(render, rest, opts, ref)
238
+ return
239
+ }
240
+
241
+ if (marker === REACT_MEMO_TYPE) {
242
+ const inner = (type as any).type
243
+ walkElement({ ...el, type: inner } as ReactElement, opts)
244
+ return
245
+ }
246
+
247
+ if (marker === REACT_LAZY_TYPE) {
248
+ const { _payload, _init } = type as any
249
+ const resolved = _init(_payload)
250
+ walkElement({ ...el, type: resolved } as ReactElement, opts)
251
+ return
252
+ }
253
+
254
+ if (isFunction(type)) {
255
+ walkComponent(type, props, opts)
256
+ return
257
+ }
258
+ }
259
+
260
+ function walkHost(
261
+ tag: string,
262
+ props: Record<string, any>,
263
+ opts: WalkOptions,
264
+ ): void {
265
+ const isSvg = !!(opts.textState!.bits & 1) || tag === 'svg'
266
+ if (!isSvg && resourceKind(tag, props) && recordHostResource(tag, props, opts.resourceScope)) return
267
+ // <textarea value="..."> serializes its value as a TEXT CHILD, not an
268
+ // attribute. `defaultValue` is the fallback when `value` is absent. This
269
+ // matches React and the HTML spec — `<textarea value="x">` is not valid
270
+ // HTML; the value is the element's textContent.
271
+ const isTextarea = tag === 'textarea'
272
+ const textareaValue = isTextarea
273
+ ? props.value != null
274
+ ? props.value
275
+ : props.defaultValue
276
+ : undefined
277
+
278
+ // <input defaultValue="..."> should parse with that value — emit it as a
279
+ // `value` attribute. Similarly `defaultChecked` becomes `checked`. This
280
+ // keeps hydration consistent: the browser parser sees the initial value,
281
+ // and on client commit our setProp seeds `.defaultValue`/`.defaultChecked`
282
+ // without stomping the user-typed value.
283
+ const isInput = tag === 'input'
284
+ const inputValueAttr =
285
+ isInput && props.value == null && props.defaultValue != null
286
+ ? props.defaultValue
287
+ : undefined
288
+ const inputCheckedAttr =
289
+ isInput && props.checked == null && props.defaultChecked != null
290
+ ? props.defaultChecked
291
+ : undefined
292
+
293
+ // <select value="..."> does NOT become an attribute on `<select>` — the
294
+ // HTML spec has no such attribute. React resolves the selection by stamping
295
+ // `selected` on the matching `<option>` children during render. Stash the
296
+ // target value(s) on the walk state and the child `<option>` walk reads it.
297
+ const isSelect = tag === 'select'
298
+ if (isSelect) {
299
+ const val = props.value != null ? props.value : props.defaultValue
300
+ pushSelectContext(val)
301
+ }
302
+ const isOption = tag === 'option'
303
+ try {
304
+
305
+ // Prepend the HTML5 doctype to the stream when rendering an <html> root.
306
+ // Without it the browser parses the document in quirks mode, which breaks
307
+ // CSS sizing (documentElement.clientHeight returns the content height, not
308
+ // the viewport) — and Floating-UI-based libraries (Radix dropdowns etc.)
309
+ // then compute off-screen positions for overlays.
310
+ if (tag === 'html') opts.emit('<!DOCTYPE html>')
311
+
312
+ opts.emit('<' + tag)
313
+ for (const k in props) {
314
+ if (isTextarea && (k === 'value' || k === 'defaultValue')) continue
315
+ if (isInput && (k === 'defaultValue' || k === 'defaultChecked')) continue
316
+ if (isSelect && (k === 'value' || k === 'defaultValue')) continue
317
+ if (isOption && k === 'selected') continue
318
+ opts.emit(attrToHtml(k, props[k], isSvg))
319
+ }
320
+ if (inputValueAttr !== undefined) {
321
+ opts.emit(attrToHtml('value', inputValueAttr, isSvg))
322
+ }
323
+ if (inputCheckedAttr !== undefined) {
324
+ opts.emit(attrToHtml('checked', inputCheckedAttr, isSvg))
325
+ }
326
+ if (isOption) {
327
+ const selectVal = currentSelectValue()
328
+ if (selectVal !== undefined) {
329
+ const optionValue =
330
+ props.value != null ? props.value : optionChildText(props.children)
331
+ const matches = Array.isArray(selectVal)
332
+ ? selectVal.some((v) => '' + v === '' + optionValue)
333
+ : '' + selectVal === '' + optionValue
334
+ if (matches) opts.emit(' selected=""')
335
+ } else if (props.selected) {
336
+ opts.emit(' selected=""')
337
+ }
338
+ }
339
+
340
+ if (VOID_ELEMENTS.has(tag)) {
341
+ opts.emit('/>')
342
+ opts.textState!.bits &= 1
343
+ return
344
+ }
345
+ opts.emit('>')
346
+ if (tag === 'head') opts.onHead?.()
347
+ // Opening a host element starts a fresh text flow context for its children.
348
+ // Children's text separator tracking is independent of the outer context.
349
+ const parentTextState = opts.textState
350
+
351
+ if (tag === 'html' && !hasHeadChild(props.children)) {
352
+ opts.emit('<head>')
353
+ opts.onHead?.()
354
+ opts.emit('</head>')
355
+ }
356
+
357
+ const dangerouslyHtml = props.dangerouslySetInnerHTML?.__html
358
+
359
+ if (isTextarea && textareaValue != null) {
360
+ opts.emit(escapeText(String(textareaValue)))
361
+ opts.emit(`</${tag}>`)
362
+ parentTextState!.bits &= 1
363
+ return
364
+ }
365
+
366
+ if (RAW_TEXT_ELEMENTS.has(tag)) {
367
+ // script/style: raw-text. React allows either a string/number child or
368
+ // dangerouslySetInnerHTML — some libs (Start's Scripts) use the latter.
369
+ if (dangerouslyHtml != null) {
370
+ opts.emit(escapeScript(String(dangerouslyHtml)))
371
+ } else {
372
+ const children = props.children
373
+ if (typeof children === 'string' || typeof children === 'number') {
374
+ opts.emit(escapeScript(String(children)))
375
+ } else if (Array.isArray(children)) {
376
+ opts.emit(escapeScript(children.filter((c) => c != null).join('')))
377
+ }
378
+ }
379
+ opts.emit(`</${tag}>`)
380
+ parentTextState!.bits &= 1
381
+ return
382
+ }
383
+
384
+ if (dangerouslyHtml != null) {
385
+ opts.emit(String(dangerouslyHtml))
386
+ } else {
387
+ const previousState = parentTextState!.bits
388
+ parentTextState!.bits = +(isSvg && tag !== 'foreignObject')
389
+ try {
390
+ walkNode(props.children, { ...opts, insertionContext: childInsertionContext(tag, props, opts.insertionContext ?? 'html') })
391
+ } finally {
392
+ parentTextState!.bits = previousState
393
+ }
394
+ }
395
+ opts.emit(`</${tag}>`)
396
+ // Host element closing resets outer flow — next sibling text starts fresh.
397
+ parentTextState!.bits &= 1
398
+ } finally {
399
+ if (isSelect) popSelectContext()
400
+ }
401
+ }
402
+
403
+ function hasHeadChild(children: unknown): boolean {
404
+ if (children == null || typeof children === 'boolean') return false
405
+ if (Array.isArray(children)) return children.some(hasHeadChild)
406
+ if (typeof children !== 'string' && isIterable(children)) {
407
+ for (const child of children as Iterable<unknown>) {
408
+ if (hasHeadChild(child)) return true
409
+ }
410
+ return false
411
+ }
412
+ return isElementOfType(children, 'head')
413
+ }
414
+
415
+ function isElementOfType(value: unknown, type: string): value is ReactElement {
416
+ const marker = (value as ReactElement | null)?.$$typeof as unknown
417
+ return (
418
+ !!value &&
419
+ typeof value === 'object' &&
420
+ (marker === REACT_ELEMENT_TYPE || marker === REACT_LEGACY_ELEMENT_TYPE) &&
421
+ (value as ReactElement).type === type
422
+ )
423
+ }
424
+
425
+ function isIterable(value: unknown): value is Iterable<unknown> {
426
+ return !!value && isFunction((value as { [Symbol.iterator]?: unknown })[Symbol.iterator])
427
+ }
428
+
429
+ function walkComponent(
430
+ fn: Function,
431
+ props: Record<string, any>,
432
+ opts: WalkOptions,
433
+ ref?: unknown,
434
+ ): void {
435
+ if (opts.onBrowserBailout) {
436
+ opts = { ...opts, componentStack: `\n at ${(fn as any).displayName || fn.name || 'Anonymous'}${opts.componentStack || ''}` }
437
+ }
438
+ const frame = currentSSRFrame()
439
+ const previousTree = frame.treeId, previousLocal = frame.localId
440
+ frame.treeId = opts.treeId ?? 1n
441
+ frame.localId = 0
442
+ try {
443
+ if ((fn as any).prototype?.isReactComponent) {
444
+ props = resolveClassProps(fn, props)
445
+ const ctxType = (fn as any).contextType
446
+ const ctxValue = ctxType ? ctxType._currentValue : undefined
447
+ const instance = new (fn as any)(props, ctxValue)
448
+ instance.props = props
449
+ instance.context = ctxValue
450
+ if ((fn as any).getDerivedStateFromProps) {
451
+ const d = (fn as any).getDerivedStateFromProps(props, instance.state)
452
+ if (d) instance.state = { ...instance.state, ...d }
453
+ }
454
+ walkNode(instance.render(), opts)
455
+ return
456
+ }
457
+ const rendered = (fn as any)(props, ref)
458
+ // A component which materialized IDs owns one extra tree slot for its children.
459
+ walkNode(rendered, frame.localId ? { ...opts, treeId: forkId(frame.treeId, 1, 0) } : opts)
460
+ } catch (error) {
461
+ if (opts.thrownInfo && !opts.thrownInfo.componentStack) opts.thrownInfo.componentStack = opts.componentStack
462
+ if (isBrowserError(error) && !(error as any).componentStack) {
463
+ Object.defineProperty(error, 'componentStack', { value: opts.componentStack })
464
+ }
465
+ throw error
466
+ } finally {
467
+ frame.treeId = previousTree
468
+ frame.localId = previousLocal
469
+ }
470
+ }
471
+
472
+ function walkSuspense(
473
+ props: Record<string, any>,
474
+ opts: WalkOptions,
475
+ ): void {
476
+ const id = opts.nextBoundaryId()
477
+ // Snapshot contexts BEFORE attempting children, so if a descendant suspends
478
+ // we can replay the same provider stack when re-rendering the boundary.
479
+ const contextSnapshot = snapshotContexts()
480
+
481
+ // Try to render the children synchronously. If a thenable is thrown,
482
+ // record the boundary and emit the fallback.
483
+ const childParts: HtmlPart[] = []
484
+ const nested: SuspendedBoundary[] = []
485
+ const thrownInfo: { componentStack?: string | undefined } = {}
486
+ const childEmit = (s: HtmlPart) => childParts.push(s)
487
+ const resourceScope: ResourceScope | undefined = currentSSRFrame().shellFlushed ? {} : undefined
488
+ try {
489
+ walkNode(props.children, {
490
+ ...opts,
491
+ resourceScope,
492
+ thrownInfo,
493
+ emit: childEmit,
494
+ onSuspend: opts.onSuspend ? (boundary) => nested.push(boundary) : undefined,
495
+ nextBoundaryId: opts.nextBoundaryId,
496
+ })
497
+ } catch (thenable: any) {
498
+ nested.length = 0
499
+ const suspended = isThenable(thenable)
500
+ if (!suspended) {
501
+ if (isBrowserError(thenable)) opts.onBrowserBailout?.(thenable, { componentStack: (thenable as any).componentStack || opts.componentStack || '' })
502
+ else opts.onError?.(thenable)
503
+ }
504
+ const fallbackParts: HtmlPart[] = []
505
+ walkNode(props.fallback, {
506
+ ...opts,
507
+ emit: (s) => fallbackParts.push(s),
508
+ onSuspend: opts.onSuspend ? (boundary) => nested.push(boundary) : undefined,
509
+ nextBoundaryId: opts.nextBoundaryId,
510
+ })
511
+ // A streamed suspension is emitted as itself, so the stream can still
512
+ // inline its content if it completes before these bytes are written.
513
+ const boundary: SuspendedBoundary | undefined = suspended && opts.onSuspend ? {
514
+ id, treeId: opts.treeId ?? 1n, insertionContext: opts.insertionContext ?? 'html', fallback: fallbackParts, children: props.children, thenable, contextSnapshot,
515
+ componentStack: thrownInfo.componentStack || opts.componentStack || '',
516
+ } : undefined
517
+ if (boundary) opts.emit(boundary)
518
+ else emitBoundary(opts, id, fallbackParts, suspended ? '$?' : isBrowserError(thenable) ? '$!' : '$E')
519
+ for (const inner of nested) opts.onSuspend?.(inner)
520
+ if (boundary) opts.onSuspend!(boundary)
521
+ return
522
+ }
523
+
524
+ if (resourceScope) currentSSRFrame().resources?.mergeScope(resourceScope, opts.resourceScope)
525
+
526
+ // Children rendered fully — emit them wrapped in resolved-boundary markers
527
+ // (`<!--$N-->` / `<!--/$-->`). Without markers, the client hydrator has no
528
+ // way to know this subtree is inside a Suspense, so if the client version
529
+ // of a descendant (e.g. `React.lazy`) suspends it can't pinpoint which DOM
530
+ // range to adopt on resolve — it creates fresh DOM next to the SSR content,
531
+ // producing visible duplicates (e.g. double navbar logos). Markers let the
532
+ // client treat this as a resolved boundary and hydrate in-place.
533
+ emitBoundary(opts, id, childParts, '$')
534
+ for (const boundary of nested) opts.onSuspend?.(boundary)
535
+ }
536
+
537
+ function emitBoundary(opts: WalkOptions, id: number, parts: HtmlPart[], marker: string): void {
538
+ const [open, close] = boundaryEdges(id, marker, opts.insertionContext, currentSSRFrame().identifierPrefix)
539
+ opts.emit(open)
540
+ for (const part of parts) opts.emit(part)
541
+ opts.emit(close)
542
+ }
543
+
544
+ /**
545
+ * Boundary markers: `$` completed, `$E`/`$!` client-rendered, `$?` pending.
546
+ * A pending template is allowed in table insertion modes and does not break
547
+ * out of SVG/MathML. The visible fallback is a sibling, not an HTML div wrapper.
548
+ * Bare rows/columns create implicit containers. Close them on both sides so
549
+ * neither preceding rows nor the fallback can move a marker inside one.
550
+ * These end tags are ignored when no such container is open.
551
+ */
552
+ export function boundaryEdges(id: number, marker: string, context: InsertionContext | undefined, prefix: string): [string, string] {
553
+ const close = context === 'table' ? '</tbody></colgroup>' : ''
554
+ return [`${close}<!--${marker}${id}-->${marker === '$?' ? `<template id="${escapeAttr(boundaryId(id, prefix))}"></template>` : ''}`, `${close}<!--/$-->`]
555
+ }
@@ -0,0 +1,122 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { createRequire, findPackageJSON } from 'node:module'
3
+ import { dirname, resolve } from 'node:path'
4
+ import { pathToFileURL } from 'node:url'
5
+ import { correctFlightTimings } from './flight-timing'
6
+
7
+ const shimPackages = ['next', 'vinext', 'server-only', 'client-only', 'private-next-instrumentation-client']
8
+ const requestHandlers = ['vinext/server/app-rsc-handler', 'vinext/server/app-rsc-combined-handler']
9
+ const clientDependencies = ['vinext > @unpic/react', 'vinext > ipaddr.js', 'vinext > web-vitals']
10
+
11
+ // These modules carry framework state or request semantics. Both Vite's main
12
+ // graph and its separate dependency optimizer must see the same correction.
13
+ export function correctVinextModule(code: string, id: string, directory: string): string | null {
14
+ id = id.split('?')[0]!.replace(/\\/g, '/')
15
+ directory = directory.replace(/\\/g, '/')
16
+ if (id === directory + '/server/app-rsc-handler.js') {
17
+ const original = 'if (!options.skipTrailingSlashRedirect) {'
18
+ if (code.includes('if (!isDataRequest && !options.skipTrailingSlashRedirect) {')) return null
19
+ if (code.split(original).length !== 2) throw new Error('Unsupported Vinext Pages data handler. Update the Redact integration for this Vinext build.')
20
+ return code.replace(original, 'if (!isDataRequest && !options.skipTrailingSlashRedirect) {')
21
+ }
22
+ if (id === directory + '/client/instrumentation-client-state.js') {
23
+ if (code.includes('Symbol.for("vinext.client.instrumentationHooks")')) return null
24
+ const replacements = [
25
+ ['let clientInstrumentationHooks = null;', 'const clientInstrumentationKey = Symbol.for("vinext.client.instrumentationHooks");'],
26
+ ['clientInstrumentationHooks = hooks;', 'Reflect.set(globalThis, clientInstrumentationKey, hooks);'],
27
+ ['return clientInstrumentationHooks;', 'return Reflect.get(globalThis, clientInstrumentationKey) ?? null;'],
28
+ ['clientInstrumentationHooks?.onRouterTransitionStart?.(href, navigationType);', 'getClientInstrumentationHooks()?.onRouterTransitionStart?.(href, navigationType);'],
29
+ ]
30
+ for (const [original, corrected] of replacements) {
31
+ const expected = original === 'return clientInstrumentationHooks;' ? 3 : 2
32
+ if (code.split(original!).length !== expected) throw new Error('Unsupported Vinext instrumentation state. Update the Redact integration for this Vinext build.')
33
+ code = code.split(original!).join(corrected!)
34
+ }
35
+ return code
36
+ }
37
+ return null
38
+ }
39
+
40
+ function isShimInclude(id: string, excludes: string[]) {
41
+ const target = id.slice(id.lastIndexOf('>') + 1).trim()
42
+ // A package root covers its explicit, nested, .js, and glob entrypoints.
43
+ return excludes.some(excluded => target === excluded || target.startsWith(excluded + '/'))
44
+ }
45
+
46
+ export function vinextCompatibility() {
47
+ let directory = '', hasApp = false, excludes: string[] = [], externalRequire: any
48
+ const transform = function(this: any, code: string, id: string) {
49
+ const corrected = directory && (correctVinextModule(code, id, directory) || correctFlightTimings(code, id, source => this.parse(source)))
50
+ return corrected ? { code: corrected, map: null } : null
51
+ }
52
+ const modulePlugin = { name: 'redact:vinext-modules', transform }
53
+ const requirePlugins = new WeakSet<object>()
54
+ function configure(name: string, config: any) {
55
+ if (!directory) return
56
+ const client = name === 'client' || config.consumer === 'client'
57
+ if (!client) {
58
+ config.resolve ||= {}
59
+ if (Array.isArray(config.resolve.external)) config.resolve.external = config.resolve.external.filter((id: string) => !requestHandlers.includes(id))
60
+ if (config.resolve.noExternal !== true) {
61
+ const existing = config.resolve.noExternal
62
+ config.resolve.noExternal = [...(Array.isArray(existing) ? existing : existing ? [existing] : []), 'vinext']
63
+ }
64
+ }
65
+ const optimizer = config.optimizeDeps ||= {}
66
+ const optimizerActive = !optimizer.noDiscovery || !!optimizer.include?.length
67
+ const options = optimizer.rolldownOptions ||= {}
68
+ let plugins = [options.plugins || []].flat(Infinity)
69
+ plugins = plugins.filter((plugin: any) => plugin?.name !== modulePlugin.name)
70
+ if (!client || hasApp) {
71
+ optimizer.exclude = [...new Set([...(optimizer.exclude || []), ...excludes])]
72
+ optimizer.include = optimizer.include?.filter((id: string) => !isShimInclude(id, excludes))
73
+ plugins = plugins.filter((plugin: any) => plugin?.name !== 'vinext:dep-optimize-alias')
74
+ if (!client && !plugins.some((plugin: any) => plugin && typeof plugin === 'object' && requirePlugins.has(plugin))) {
75
+ // Rolldown's built-in plugins are class instances. Preserve the instance
76
+ // so its native implementation and options reach the optimizer.
77
+ const plugin = externalRequire({ external: excludes })
78
+ requirePlugins.add(plugin)
79
+ plugins.push(plugin)
80
+ }
81
+ if (client && optimizerActive) {
82
+ optimizer.include = [...new Set([...(optimizer.include || []), ...clientDependencies.filter(id => !isShimInclude(id, optimizer.exclude.filter((entry: string) => !shimPackages.includes(entry))))])]
83
+ }
84
+ }
85
+ options.plugins = [...plugins, modulePlugin]
86
+ }
87
+ return {
88
+ config: {
89
+ order: 'post',
90
+ async handler(config: any) {
91
+ const require = createRequire(resolve(config.root || '.', 'package.json'))
92
+ // Vinext is ESM-only, so resolve its public package manifest through its
93
+ // import condition without loading a second copy of the plugin.
94
+ const packagePath = findPackageJSON('vinext', pathToFileURL(resolve(config.root || '.', 'package.json')))
95
+ if (!packagePath) throw new Error('Install vinext 1.3.0 before using the Redact Vinext integration.')
96
+ directory = resolve(dirname(packagePath), 'dist')
97
+ const pkg = JSON.parse(readFileSync(packagePath, 'utf8'))
98
+ if (pkg.version !== '1.3.0') throw new Error(`Redact Vinext integration supports vinext 1.3.0; found ${pkg.version}.`)
99
+ hasApp = !!config.environments?.rsc
100
+ const aliases = Array.isArray(config.resolve?.alias) ? config.resolve.alias : Object.entries(config.resolve?.alias || {}).map(([find, replacement]) => ({ find, replacement }))
101
+ const publicShims = Object.keys((await import(pathToFileURL(resolve(directory, 'shims/public-shim-map.json.js')).href)).default)
102
+ const shimEntries = [...publicShims, 'next/dist/client/components/navigation'].flatMap(id => [id, id + '.js'])
103
+ excludes = [...new Set([...shimPackages, ...shimEntries, ...aliases.filter((alias: any) => typeof alias.find === 'string' && (alias.find.startsWith('next/') || alias.replacement?.replace(/\\/g, '/').startsWith(directory.replace(/\\/g, '/') + '/'))).map((alias: any) => alias.find)])] as string[]
104
+ const vite = await import(pathToFileURL(require.resolve('vite')).href)
105
+ externalRequire = vite.esmExternalRequirePlugin
106
+ if (typeof externalRequire !== 'function') throw new Error('Redact Vinext integration requires Vite 8 with esmExternalRequirePlugin support.')
107
+ },
108
+ },
109
+ configEnvironment: { order: 'post', handler: configure },
110
+ configResolved: {
111
+ order: 'post',
112
+ handler(config: any) {
113
+ for (const [name, environment] of Object.entries(config.environments)) configure(name, environment)
114
+ },
115
+ },
116
+ resolveHandler(id: string) {
117
+ if (directory && requestHandlers.includes(id)) return { id: resolve(directory, id.slice('vinext/'.length) + '.js'), external: false }
118
+ return null
119
+ },
120
+ transform,
121
+ }
122
+ }