@bleedingdev/tanstack-redact 0.0.0-stage → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cloudflare/index.d.ts +6 -0
  3. package/dist/cloudflare/index.js +39 -0
  4. package/dist/cloudflare/index.js.map +7 -0
  5. package/dist/core/attributes.d.ts +4 -0
  6. package/dist/core/attributes.js +30 -0
  7. package/dist/core/attributes.js.map +7 -0
  8. package/dist/core/browser.d.ts +9 -0
  9. package/dist/core/browser.js +32 -0
  10. package/dist/core/browser.js.map +7 -0
  11. package/dist/core/class-props.d.ts +1 -0
  12. package/dist/core/class-props.js +15 -0
  13. package/dist/core/class-props.js.map +7 -0
  14. package/dist/core/devtools.d.ts +26 -0
  15. package/dist/core/devtools.js +70 -0
  16. package/dist/core/devtools.js.map +7 -0
  17. package/dist/core/functions.d.ts +6 -0
  18. package/dist/core/functions.js +14 -0
  19. package/dist/core/functions.js.map +7 -0
  20. package/dist/core/index.d.ts +2 -0
  21. package/dist/core/index.js +3 -0
  22. package/dist/core/index.js.map +7 -0
  23. package/dist/core/internal.d.ts +103 -0
  24. package/dist/core/internal.js +43 -0
  25. package/dist/core/internal.js.map +7 -0
  26. package/dist/core/resource-hints.d.ts +7 -0
  27. package/dist/core/resource-hints.js +20 -0
  28. package/dist/core/resource-hints.js.map +7 -0
  29. package/dist/core/types.d.ts +23 -0
  30. package/dist/core/types.js +8 -0
  31. package/dist/core/types.js.map +7 -0
  32. package/dist/core/unitless-style.d.ts +1 -0
  33. package/dist/core/unitless-style.js +5 -0
  34. package/dist/core/unitless-style.js.map +7 -0
  35. package/dist/dom/_all.d.ts +27 -0
  36. package/dist/dom/_all.js +51 -0
  37. package/dist/dom/_all.js.map +7 -0
  38. package/dist/dom/client.d.ts +9 -0
  39. package/dist/dom/client.js +13 -0
  40. package/dist/dom/client.js.map +7 -0
  41. package/dist/dom/commit.d.ts +27 -0
  42. package/dist/dom/commit.js +237 -0
  43. package/dist/dom/commit.js.map +7 -0
  44. package/dist/dom/devtools-effects.d.ts +8 -0
  45. package/dist/dom/devtools-effects.js +80 -0
  46. package/dist/dom/devtools-effects.js.map +7 -0
  47. package/dist/dom/devtools.d.ts +33 -0
  48. package/dist/dom/devtools.js +635 -0
  49. package/dist/dom/devtools.js.map +7 -0
  50. package/dist/dom/dispatcher.d.ts +4 -0
  51. package/dist/dom/dispatcher.js +437 -0
  52. package/dist/dom/dispatcher.js.map +7 -0
  53. package/dist/dom/document-metadata.d.ts +7 -0
  54. package/dist/dom/document-metadata.js +44 -0
  55. package/dist/dom/document-metadata.js.map +7 -0
  56. package/dist/dom/dom.d.ts +11 -0
  57. package/dist/dom/dom.js +165 -0
  58. package/dist/dom/dom.js.map +7 -0
  59. package/dist/dom/error-info.d.ts +2 -0
  60. package/dist/dom/error-info.js +19 -0
  61. package/dist/dom/error-info.js.map +7 -0
  62. package/dist/dom/event-replay.d.ts +13 -0
  63. package/dist/dom/event-replay.js +24 -0
  64. package/dist/dom/event-replay.js.map +7 -0
  65. package/dist/dom/features/activity/full.d.ts +1 -0
  66. package/dist/dom/features/activity/full.js +140 -0
  67. package/dist/dom/features/activity/full.js.map +7 -0
  68. package/dist/dom/features/activity/index.d.ts +1 -0
  69. package/dist/dom/features/activity/index.js +2 -0
  70. package/dist/dom/features/activity/index.js.map +7 -0
  71. package/dist/dom/features/activity/stub.d.ts +1 -0
  72. package/dist/dom/features/activity/stub.js +10 -0
  73. package/dist/dom/features/activity/stub.js.map +7 -0
  74. package/dist/dom/features/class/full.d.ts +1 -0
  75. package/dist/dom/features/class/full.js +208 -0
  76. package/dist/dom/features/class/full.js.map +7 -0
  77. package/dist/dom/features/class/index.d.ts +1 -0
  78. package/dist/dom/features/class/index.js +2 -0
  79. package/dist/dom/features/class/index.js.map +7 -0
  80. package/dist/dom/features/class/stub.d.ts +1 -0
  81. package/dist/dom/features/class/stub.js +46 -0
  82. package/dist/dom/features/class/stub.js.map +7 -0
  83. package/dist/dom/features/context/full.d.ts +4 -0
  84. package/dist/dom/features/context/full.js +103 -0
  85. package/dist/dom/features/context/full.js.map +7 -0
  86. package/dist/dom/features/context/index.d.ts +1 -0
  87. package/dist/dom/features/context/index.js +2 -0
  88. package/dist/dom/features/context/index.js.map +7 -0
  89. package/dist/dom/features/context/stub.d.ts +4 -0
  90. package/dist/dom/features/context/stub.js +21 -0
  91. package/dist/dom/features/context/stub.js.map +7 -0
  92. package/dist/dom/features/forward-ref/full.d.ts +1 -0
  93. package/dist/dom/features/forward-ref/full.js +9 -0
  94. package/dist/dom/features/forward-ref/full.js.map +7 -0
  95. package/dist/dom/features/forward-ref/index.d.ts +1 -0
  96. package/dist/dom/features/forward-ref/index.js +2 -0
  97. package/dist/dom/features/forward-ref/index.js.map +7 -0
  98. package/dist/dom/features/forward-ref/stub.d.ts +1 -0
  99. package/dist/dom/features/forward-ref/stub.js +9 -0
  100. package/dist/dom/features/forward-ref/stub.js.map +7 -0
  101. package/dist/dom/features/fragment-refs/index.d.ts +1 -0
  102. package/dist/dom/features/fragment-refs/index.js +9 -0
  103. package/dist/dom/features/fragment-refs/index.js.map +7 -0
  104. package/dist/dom/features/fragment-refs/stub.d.ts +5 -0
  105. package/dist/dom/features/fragment-refs/stub.js +17 -0
  106. package/dist/dom/features/fragment-refs/stub.js.map +7 -0
  107. package/dist/dom/features/hydration/full.d.ts +68 -0
  108. package/dist/dom/features/hydration/full.js +493 -0
  109. package/dist/dom/features/hydration/full.js.map +7 -0
  110. package/dist/dom/features/hydration/index.d.ts +1 -0
  111. package/dist/dom/features/hydration/index.js +2 -0
  112. package/dist/dom/features/hydration/index.js.map +7 -0
  113. package/dist/dom/features/hydration/stub.d.ts +36 -0
  114. package/dist/dom/features/hydration/stub.js +80 -0
  115. package/dist/dom/features/hydration/stub.js.map +7 -0
  116. package/dist/dom/features/index.d.ts +8 -0
  117. package/dist/dom/features/index.js +9 -0
  118. package/dist/dom/features/index.js.map +7 -0
  119. package/dist/dom/features/lazy/full.d.ts +1 -0
  120. package/dist/dom/features/lazy/full.js +23 -0
  121. package/dist/dom/features/lazy/full.js.map +7 -0
  122. package/dist/dom/features/lazy/index.d.ts +1 -0
  123. package/dist/dom/features/lazy/index.js +2 -0
  124. package/dist/dom/features/lazy/index.js.map +7 -0
  125. package/dist/dom/features/lazy/stub.d.ts +1 -0
  126. package/dist/dom/features/lazy/stub.js +19 -0
  127. package/dist/dom/features/lazy/stub.js.map +7 -0
  128. package/dist/dom/features/memo/full.d.ts +1 -0
  129. package/dist/dom/features/memo/full.js +34 -0
  130. package/dist/dom/features/memo/full.js.map +7 -0
  131. package/dist/dom/features/memo/index.d.ts +1 -0
  132. package/dist/dom/features/memo/index.js +2 -0
  133. package/dist/dom/features/memo/index.js.map +7 -0
  134. package/dist/dom/features/memo/stub.d.ts +1 -0
  135. package/dist/dom/features/memo/stub.js +9 -0
  136. package/dist/dom/features/memo/stub.js.map +7 -0
  137. package/dist/dom/features/portal/full.d.ts +1 -0
  138. package/dist/dom/features/portal/full.js +11 -0
  139. package/dist/dom/features/portal/full.js.map +7 -0
  140. package/dist/dom/features/portal/index.d.ts +1 -0
  141. package/dist/dom/features/portal/index.js +2 -0
  142. package/dist/dom/features/portal/index.js.map +7 -0
  143. package/dist/dom/features/portal/stub.d.ts +1 -0
  144. package/dist/dom/features/portal/stub.js +5 -0
  145. package/dist/dom/features/portal/stub.js.map +7 -0
  146. package/dist/dom/features/suspense/full.d.ts +1 -0
  147. package/dist/dom/features/suspense/full.js +389 -0
  148. package/dist/dom/features/suspense/full.js.map +7 -0
  149. package/dist/dom/features/suspense/index.d.ts +1 -0
  150. package/dist/dom/features/suspense/index.js +2 -0
  151. package/dist/dom/features/suspense/index.js.map +7 -0
  152. package/dist/dom/features/suspense/stub.d.ts +1 -0
  153. package/dist/dom/features/suspense/stub.js +4 -0
  154. package/dist/dom/features/suspense/stub.js.map +7 -0
  155. package/dist/dom/features/suspense-runtime/index.d.ts +1 -0
  156. package/dist/dom/features/suspense-runtime/index.js +2 -0
  157. package/dist/dom/features/suspense-runtime/index.js.map +7 -0
  158. package/dist/dom/features/suspense-runtime/stub.d.ts +1 -0
  159. package/dist/dom/features/suspense-runtime/stub.js +11 -0
  160. package/dist/dom/features/suspense-runtime/stub.js.map +7 -0
  161. package/dist/dom/features/view-transition/full.d.ts +7 -0
  162. package/dist/dom/features/view-transition/full.js +324 -0
  163. package/dist/dom/features/view-transition/full.js.map +7 -0
  164. package/dist/dom/features/view-transition/index.d.ts +1 -0
  165. package/dist/dom/features/view-transition/index.js +2 -0
  166. package/dist/dom/features/view-transition/index.js.map +7 -0
  167. package/dist/dom/features/view-transition/resources.d.ts +11 -0
  168. package/dist/dom/features/view-transition/resources.js +117 -0
  169. package/dist/dom/features/view-transition/resources.js.map +7 -0
  170. package/dist/dom/features/view-transition/stub.d.ts +7 -0
  171. package/dist/dom/features/view-transition/stub.js +21 -0
  172. package/dist/dom/features/view-transition/stub.js.map +7 -0
  173. package/dist/dom/features/view-transition/visual.d.ts +14 -0
  174. package/dist/dom/features/view-transition/visual.js +404 -0
  175. package/dist/dom/features/view-transition/visual.js.map +7 -0
  176. package/dist/dom/form-actions.d.ts +4 -0
  177. package/dist/dom/form-actions.js +74 -0
  178. package/dist/dom/form-actions.js.map +7 -0
  179. package/dist/dom/form-controls.d.ts +3 -0
  180. package/dist/dom/form-controls.js +91 -0
  181. package/dist/dom/form-controls.js.map +7 -0
  182. package/dist/dom/fragment-instance.d.ts +33 -0
  183. package/dist/dom/fragment-instance.js +449 -0
  184. package/dist/dom/fragment-instance.js.map +7 -0
  185. package/dist/dom/index.d.ts +61 -0
  186. package/dist/dom/index.js +71 -0
  187. package/dist/dom/index.js.map +7 -0
  188. package/dist/dom/portal.d.ts +2 -0
  189. package/dist/dom/portal.js +14 -0
  190. package/dist/dom/portal.js.map +7 -0
  191. package/dist/dom/react-ids.d.ts +6 -0
  192. package/dist/dom/react-ids.js +38 -0
  193. package/dist/dom/react-ids.js.map +7 -0
  194. package/dist/dom/reconcile.d.ts +86 -0
  195. package/dist/dom/reconcile.js +1305 -0
  196. package/dist/dom/reconcile.js.map +7 -0
  197. package/dist/dom/refresh.d.ts +12 -0
  198. package/dist/dom/refresh.js +174 -0
  199. package/dist/dom/refresh.js.map +7 -0
  200. package/dist/dom/resource-hints.d.ts +6 -0
  201. package/dist/dom/resource-hints.js +107 -0
  202. package/dist/dom/resource-hints.js.map +7 -0
  203. package/dist/dom/resource-store.d.ts +13 -0
  204. package/dist/dom/resource-store.js +47 -0
  205. package/dist/dom/resource-store.js.map +7 -0
  206. package/dist/dom/resources.d.ts +1 -0
  207. package/dist/dom/resources.js +46 -0
  208. package/dist/dom/resources.js.map +7 -0
  209. package/dist/dom/retained-effects.d.ts +6 -0
  210. package/dist/dom/retained-effects.js +67 -0
  211. package/dist/dom/retained-effects.js.map +7 -0
  212. package/dist/dom/root-internal.d.ts +11 -0
  213. package/dist/dom/root-internal.js +35 -0
  214. package/dist/dom/root-internal.js.map +7 -0
  215. package/dist/dom/root.d.ts +17 -0
  216. package/dist/dom/root.js +38 -0
  217. package/dist/dom/root.js.map +7 -0
  218. package/dist/dom/synthetic-event.d.ts +1 -0
  219. package/dist/dom/synthetic-event.js +35 -0
  220. package/dist/dom/synthetic-event.js.map +7 -0
  221. package/dist/dom/test-utils.d.ts +1 -0
  222. package/dist/dom/test-utils.js +5 -0
  223. package/dist/dom/test-utils.js.map +7 -0
  224. package/dist/dom/transitions.d.ts +9 -0
  225. package/dist/dom/transitions.js +147 -0
  226. package/dist/dom/transitions.js.map +7 -0
  227. package/dist/dom/tree.d.ts +5 -0
  228. package/dist/dom/tree.js +62 -0
  229. package/dist/dom/tree.js.map +7 -0
  230. package/dist/dom/walk.d.ts +2 -0
  231. package/dist/dom/walk.js +14 -0
  232. package/dist/dom/walk.js.map +7 -0
  233. package/dist/next/client.d.ts +9 -0
  234. package/dist/next/client.js +14 -0
  235. package/dist/next/client.js.map +7 -0
  236. package/dist/next/dev-cache-loader.cjs +13 -0
  237. package/dist/next/index.d.ts +2 -0
  238. package/dist/next/index.js +97 -0
  239. package/dist/next/index.js.map +7 -0
  240. package/dist/next/loader.cjs +10 -0
  241. package/dist/next/react.d.ts +71 -0
  242. package/dist/next/react.js +9 -0
  243. package/dist/next/react.js.map +7 -0
  244. package/dist/react/act.d.ts +3 -0
  245. package/dist/react/act.js +124 -0
  246. package/dist/react/act.js.map +7 -0
  247. package/dist/react/action-scope.d.ts +17 -0
  248. package/dist/react/action-scope.js +60 -0
  249. package/dist/react/action-scope.js.map +7 -0
  250. package/dist/react/activity.d.ts +7 -0
  251. package/dist/react/activity.js +7 -0
  252. package/dist/react/activity.js.map +7 -0
  253. package/dist/react/children.d.ts +8 -0
  254. package/dist/react/children.js +76 -0
  255. package/dist/react/children.js.map +7 -0
  256. package/dist/react/class.d.ts +36 -0
  257. package/dist/react/class.js +39 -0
  258. package/dist/react/class.js.map +7 -0
  259. package/dist/react/compiler-runtime.d.ts +1 -0
  260. package/dist/react/compiler-runtime.js +9 -0
  261. package/dist/react/compiler-runtime.js.map +7 -0
  262. package/dist/react/context.d.ts +32 -0
  263. package/dist/react/context.js +25 -0
  264. package/dist/react/context.js.map +7 -0
  265. package/dist/react/element.d.ts +13 -0
  266. package/dist/react/element.js +70 -0
  267. package/dist/react/element.js.map +7 -0
  268. package/dist/react/form-state.d.ts +26 -0
  269. package/dist/react/form-state.js +30 -0
  270. package/dist/react/form-state.js.map +7 -0
  271. package/dist/react/hooks.d.ts +67 -0
  272. package/dist/react/hooks.js +165 -0
  273. package/dist/react/hooks.js.map +7 -0
  274. package/dist/react/index.d.ts +99 -0
  275. package/dist/react/index.js +143 -0
  276. package/dist/react/index.js.map +7 -0
  277. package/dist/react/jsx-runtime.d.ts +24 -0
  278. package/dist/react/jsx-runtime.js +37 -0
  279. package/dist/react/jsx-runtime.js.map +7 -0
  280. package/dist/react/memo.d.ts +20 -0
  281. package/dist/react/memo.js +27 -0
  282. package/dist/react/memo.js.map +7 -0
  283. package/dist/react/portal.d.ts +1 -0
  284. package/dist/react/portal.js +5 -0
  285. package/dist/react/portal.js.map +7 -0
  286. package/dist/react/shared-internals.d.ts +52 -0
  287. package/dist/react/shared-internals.js +22 -0
  288. package/dist/react/shared-internals.js.map +7 -0
  289. package/dist/react/suspense.d.ts +15 -0
  290. package/dist/react/suspense.js +15 -0
  291. package/dist/react/suspense.js.map +7 -0
  292. package/dist/react/thenable.d.ts +1 -0
  293. package/dist/react/thenable.js +25 -0
  294. package/dist/react/thenable.js.map +7 -0
  295. package/dist/react/view-transition.d.ts +32 -0
  296. package/dist/react/view-transition.js +12 -0
  297. package/dist/react/view-transition.js.map +7 -0
  298. package/dist/scheduler/index.d.ts +44 -0
  299. package/dist/scheduler/index.js +109 -0
  300. package/dist/scheduler/index.js.map +7 -0
  301. package/dist/server/bootstrap-script.d.ts +3 -0
  302. package/dist/server/bootstrap-script.js +17 -0
  303. package/dist/server/bootstrap-script.js.map +7 -0
  304. package/dist/server/dispatcher.d.ts +57 -0
  305. package/dist/server/dispatcher.js +157 -0
  306. package/dist/server/dispatcher.js.map +7 -0
  307. package/dist/server/escape.d.ts +6 -0
  308. package/dist/server/escape.js +75 -0
  309. package/dist/server/escape.js.map +7 -0
  310. package/dist/server/index.d.ts +16 -0
  311. package/dist/server/index.js +25 -0
  312. package/dist/server/index.js.map +7 -0
  313. package/dist/server/insertion-context.d.ts +3 -0
  314. package/dist/server/insertion-context.js +32 -0
  315. package/dist/server/renderToString.d.ts +7 -0
  316. package/dist/server/renderToString.js +33 -0
  317. package/dist/server/renderToString.js.map +7 -0
  318. package/dist/server/resource-hints.d.ts +22 -0
  319. package/dist/server/resource-hints.js +168 -0
  320. package/dist/server/resource-hints.js.map +7 -0
  321. package/dist/server/stream-ids.d.ts +3 -0
  322. package/dist/server/stream-ids.js +8 -0
  323. package/dist/server/stream.d.ts +61 -0
  324. package/dist/server/stream.js +418 -0
  325. package/dist/server/stream.js.map +7 -0
  326. package/dist/server/walk.d.ts +58 -0
  327. package/dist/server/walk.js +378 -0
  328. package/dist/server/walk.js.map +7 -0
  329. package/dist/vinext/compatibility.d.ts +23 -0
  330. package/dist/vinext/compatibility.js +127 -0
  331. package/dist/vinext/compatibility.js.map +7 -0
  332. package/dist/vinext/flight-timing.d.ts +1 -0
  333. package/dist/vinext/flight-timing.js +46 -0
  334. package/dist/vinext/flight-timing.js.map +7 -0
  335. package/dist/vinext/index.d.ts +5 -0
  336. package/dist/vinext/index.js +50 -0
  337. package/dist/vinext/index.js.map +7 -0
  338. package/dist/vite/index.d.ts +102 -0
  339. package/dist/vite/index.js +291 -0
  340. package/dist/vite/index.js.map +7 -0
  341. package/dist/vite/react18.d.ts +4 -0
  342. package/dist/vite/react18.js +74 -0
  343. package/dist/vite/react18.js.map +7 -0
  344. package/package.json +121 -4
  345. package/src/cloudflare/index.ts +44 -0
  346. package/src/core/attributes.ts +20 -0
  347. package/src/core/browser.ts +34 -0
  348. package/src/core/class-props.ts +12 -0
  349. package/src/core/devtools.ts +69 -0
  350. package/src/core/functions.ts +11 -0
  351. package/src/core/index.ts +2 -0
  352. package/src/core/internal.ts +123 -0
  353. package/src/core/resource-hints.ts +39 -0
  354. package/src/core/types.ts +39 -0
  355. package/src/core/unitless-style.ts +1 -0
  356. package/src/dom/_all.ts +46 -0
  357. package/src/dom/client.ts +17 -0
  358. package/src/dom/commit.ts +223 -0
  359. package/src/dom/devtools-effects.ts +78 -0
  360. package/src/dom/devtools.ts +527 -0
  361. package/src/dom/dispatcher.ts +476 -0
  362. package/src/dom/document-metadata.ts +41 -0
  363. package/src/dom/dom.ts +181 -0
  364. package/src/dom/error-info.ts +20 -0
  365. package/src/dom/event-replay.ts +39 -0
  366. package/src/dom/features/activity/full.ts +150 -0
  367. package/src/dom/features/activity/index.ts +1 -0
  368. package/src/dom/features/activity/stub.ts +12 -0
  369. package/src/dom/features/class/full.ts +202 -0
  370. package/src/dom/features/class/index.ts +1 -0
  371. package/src/dom/features/class/stub.ts +58 -0
  372. package/src/dom/features/context/full.ts +107 -0
  373. package/src/dom/features/context/index.ts +1 -0
  374. package/src/dom/features/context/stub.ts +26 -0
  375. package/src/dom/features/forward-ref/full.ts +9 -0
  376. package/src/dom/features/forward-ref/index.ts +1 -0
  377. package/src/dom/features/forward-ref/stub.ts +15 -0
  378. package/src/dom/features/fragment-refs/index.ts +1 -0
  379. package/src/dom/features/fragment-refs/stub.ts +6 -0
  380. package/src/dom/features/hydration/full.ts +563 -0
  381. package/src/dom/features/hydration/index.ts +1 -0
  382. package/src/dom/features/hydration/stub.ts +86 -0
  383. package/src/dom/features/index.ts +12 -0
  384. package/src/dom/features/lazy/full.ts +27 -0
  385. package/src/dom/features/lazy/index.ts +1 -0
  386. package/src/dom/features/lazy/stub.ts +24 -0
  387. package/src/dom/features/memo/full.ts +39 -0
  388. package/src/dom/features/memo/index.ts +1 -0
  389. package/src/dom/features/memo/stub.ts +13 -0
  390. package/src/dom/features/portal/full.ts +14 -0
  391. package/src/dom/features/portal/index.ts +1 -0
  392. package/src/dom/features/portal/stub.ts +11 -0
  393. package/src/dom/features/suspense/full.ts +469 -0
  394. package/src/dom/features/suspense/index.ts +1 -0
  395. package/src/dom/features/suspense/stub.ts +13 -0
  396. package/src/dom/features/suspense-runtime/index.ts +1 -0
  397. package/src/dom/features/suspense-runtime/stub.ts +1 -0
  398. package/src/dom/features/view-transition/full.ts +292 -0
  399. package/src/dom/features/view-transition/index.ts +1 -0
  400. package/src/dom/features/view-transition/resources.ts +123 -0
  401. package/src/dom/features/view-transition/stub.ts +8 -0
  402. package/src/dom/features/view-transition/visual.ts +454 -0
  403. package/src/dom/form-actions.ts +69 -0
  404. package/src/dom/form-controls.ts +91 -0
  405. package/src/dom/fragment-instance.ts +462 -0
  406. package/src/dom/index.ts +49 -0
  407. package/src/dom/portal.ts +16 -0
  408. package/src/dom/react-ids.ts +36 -0
  409. package/src/dom/reconcile.ts +1423 -0
  410. package/src/dom/refresh.ts +171 -0
  411. package/src/dom/resource-hints.ts +104 -0
  412. package/src/dom/resource-store.ts +50 -0
  413. package/src/dom/resources.ts +47 -0
  414. package/src/dom/retained-effects.ts +57 -0
  415. package/src/dom/root-internal.ts +37 -0
  416. package/src/dom/root.ts +59 -0
  417. package/src/dom/synthetic-event.ts +22 -0
  418. package/src/dom/test-utils.ts +1 -0
  419. package/src/dom/transitions.ts +141 -0
  420. package/src/dom/tree.ts +56 -0
  421. package/src/dom/walk.ts +8 -0
  422. package/src/next/client.ts +10 -0
  423. package/src/next/dev-cache-loader.cjs +13 -0
  424. package/src/next/index.ts +95 -0
  425. package/src/next/loader.cjs +10 -0
  426. package/src/next/react.ts +7 -0
  427. package/src/react/act.ts +105 -0
  428. package/src/react/action-scope.ts +57 -0
  429. package/src/react/activity.ts +10 -0
  430. package/src/react/children.ts +86 -0
  431. package/src/react/class.ts +66 -0
  432. package/src/react/compiler-runtime.ts +8 -0
  433. package/src/react/context.ts +46 -0
  434. package/src/react/element.ts +82 -0
  435. package/src/react/form-state.ts +35 -0
  436. package/src/react/hooks.ts +214 -0
  437. package/src/react/index.ts +91 -0
  438. package/src/react/jsx-runtime.ts +50 -0
  439. package/src/react/memo.ts +42 -0
  440. package/src/react/portal.ts +1 -0
  441. package/src/react/shared-internals.ts +80 -0
  442. package/src/react/suspense.ts +18 -0
  443. package/src/react/thenable.ts +21 -0
  444. package/src/react/view-transition.ts +41 -0
  445. package/src/scheduler/index.ts +124 -0
  446. package/src/server/bootstrap-script.ts +92 -0
  447. package/src/server/dispatcher.ts +168 -0
  448. package/src/server/escape.ts +102 -0
  449. package/src/server/index.ts +26 -0
  450. package/src/server/insertion-context.ts +28 -0
  451. package/src/server/renderToString.ts +35 -0
  452. package/src/server/resource-hints.ts +166 -0
  453. package/src/server/stream-ids.ts +5 -0
  454. package/src/server/stream.ts +525 -0
  455. package/src/server/walk.ts +555 -0
  456. package/src/vinext/compatibility.ts +122 -0
  457. package/src/vinext/flight-timing.ts +37 -0
  458. package/src/vinext/index.ts +47 -0
  459. package/src/vite/index.ts +476 -0
  460. package/src/vite/react18.ts +74 -0
  461. package/vendor/cloudflare-vite-plugin/LICENSE +25 -0
  462. package/vendor/cloudflare-vite-plugin/README.md +9 -0
  463. package/vendor/cloudflare-vite-plugin/dist/chunk-U6NEESU5-BmLHqeIt.mjs +43 -0
  464. package/vendor/cloudflare-vite-plugin/dist/index.d.mts +155 -0
  465. package/vendor/cloudflare-vite-plugin/dist/index.mjs +94700 -0
  466. package/vendor/cloudflare-vite-plugin/dist/open-PCXX3ZDZ-DYH87NhH.mjs +530 -0
  467. package/vendor/cloudflare-vite-plugin/dist/package-4cnqy5mM.mjs +84 -0
  468. package/vendor/cloudflare-vite-plugin/dist/workers/asset-worker/index.js +5996 -0
  469. package/vendor/cloudflare-vite-plugin/dist/workers/router-worker/index.js +6414 -0
  470. package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/index.js +457 -0
  471. package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/module-runner-legacy.js +1129 -0
  472. package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/module-runner.js +1259 -0
  473. package/vendor/cloudflare-vite-plugin/dist/workers/vite-proxy-worker/index.js +31 -0
  474. package/vendor/cloudflare-vite-plugin/package.json +90 -0
  475. package/vendor/cloudflare-vite-plugin/provenance.json +26 -0
  476. package/README.md +0 -3
@@ -0,0 +1,37 @@
1
+ // React's completed-component track already checks these bounds. Error and
2
+ // cancellation tracks in React 19.3.1 omit them and can pass a negative end to
3
+ // Performance.measure. Keep the correction in development Flight modules.
4
+ // https://github.com/react/react/pull/37572
5
+ function walk(node: any, visit: (node: any) => void): void {
6
+ if (!node || typeof node !== 'object') return
7
+ if (Array.isArray(node)) { for (const item of node) walk(item, visit); return }
8
+ if (typeof node.type !== 'string') return
9
+ visit(node)
10
+ for (const [key, value] of Object.entries(node)) if (key !== 'parent' && value && typeof value === 'object') walk(value, visit)
11
+ }
12
+ function property(node: any, name: string): any {
13
+ return node?.type === 'ObjectExpression'
14
+ ? node.properties.find((entry: any) => (entry.key?.name ?? entry.key?.value) === name)?.value
15
+ : undefined
16
+ }
17
+ export function correctFlightTimings(code: string, id: string, parse: (code: string) => any): string | null {
18
+ if (!/(?:^|[/\\])react-server-dom-webpack-client\.(?:browser|edge|node)\.development\.js$/.test(id.split('?')[0]!)) return null
19
+ const edits: { start: number; end: number; text: string }[] = []
20
+ walk(parse(code), node => {
21
+ if (node.type !== 'IfStatement' || node.test.type !== 'Identifier' || node.test.name !== 'supportsUserTiming') return
22
+ walk(node.consequent, call => {
23
+ if (call.type !== 'CallExpression' || call.callee.type !== 'MemberExpression' ||
24
+ call.callee.object.name !== 'performance' || call.callee.property.name !== 'measure') return
25
+ const options = call.arguments[1]
26
+ const end = property(options, 'end')
27
+ const track = property(property(property(options, 'detail'), 'devtools'), 'track')
28
+ if (end?.type !== 'Identifier' || !/^childrenEndTime(?:\$jscomp\$\d+)?$/.test(end.name) ||
29
+ track?.type !== 'MemberExpression' || track.object.name !== 'trackNames' ||
30
+ track.property.type !== 'Identifier' || !/^trackIdx(?:\$jscomp\$\d+)?$/.test(track.property.name)) return
31
+ edits.push({ start: node.test.start, end: node.test.end, text: `supportsUserTiming && ${end.name} >= 0 && ${track.property.name} < 10` })
32
+ })
33
+ })
34
+ if (!edits.length) return null
35
+ for (const edit of edits.sort((a, b) => b.start - a.start)) code = code.slice(0, edit.start) + edit.text + code.slice(edit.end)
36
+ return code
37
+ }
@@ -0,0 +1,47 @@
1
+ import { fileURLToPath } from 'node:url'
2
+ import { vinextCompatibility } from './compatibility'
3
+
4
+ /** Use Redact in Vinext's browser environment, with native React for SSR and RSC. */
5
+ export function redact(options: { renderer?: 'redact' | 'react' } = {}): any {
6
+ const compatibility = vinextCompatibility()
7
+ const entries: Record<string, string> = {
8
+ react: '../next/react.js',
9
+ 'react/jsx-runtime': '../react/jsx-runtime.js',
10
+ 'react/jsx-dev-runtime': '../react/jsx-runtime.js',
11
+ 'react/compiler-runtime': '../react/compiler-runtime.js',
12
+ 'react-dom': '../dom/index.js',
13
+ 'react-dom/client': '../next/client.js',
14
+ 'react-dom/test-utils': '../dom/test-utils.js',
15
+ scheduler: '../scheduler/index.js',
16
+ }
17
+ const resolved = Object.fromEntries(Object.entries(entries).map(([name, target]) => [name, fileURLToPath(new URL(target, import.meta.url))]))
18
+ return {
19
+ ...compatibility,
20
+ name: 'redact:vinext',
21
+ enforce: 'pre',
22
+ configEnvironment: {
23
+ order: 'post',
24
+ handler(name: string, config: any) {
25
+ compatibility.configEnvironment.handler(name, config)
26
+ if (options.renderer === 'react' || (name !== 'client' && config.consumer !== 'client')) return
27
+ config.optimizeDeps = {
28
+ ...config.optimizeDeps,
29
+ exclude: [...new Set([...(config.optimizeDeps?.exclude || []), ...Object.keys(entries), '@tanstack/redact'])],
30
+ include: config.optimizeDeps?.include?.filter((id: string) => !entries[id.split('>').pop()!.trim()]),
31
+ }
32
+ },
33
+ },
34
+ resolveId: {
35
+ order: 'pre',
36
+ handler(this: any, id: string) {
37
+ if (this.environment?.config.consumer !== 'client') return compatibility.resolveHandler(id)
38
+ // Vite aliases are global. Browser React must resolve here so SSR and
39
+ // Flight retain their native React module and export conditions.
40
+ if (options.renderer === 'react') return null
41
+ return resolved[id] ?? null
42
+ },
43
+ },
44
+ }
45
+ }
46
+
47
+ export default redact
@@ -0,0 +1,476 @@
1
+ import { existsSync, readFileSync, realpathSync } from 'node:fs'
2
+ import { dirname, resolve as resolvePath } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+ import { adaptReact18 } from './react18'
5
+
6
+ export type RedactPreset = 'nano' | 'full'
7
+
8
+ /**
9
+ * Opt-in feature set. Each flag toggles whether the feature's real
10
+ * implementation ships (`true`) or is swapped with a stub module that
11
+ * degrades gracefully (`false`). Missing keys fall back to the preset's
12
+ * default. Adding a feature to this interface propagates to consumer
13
+ * configs as autocompleted options.
14
+ */
15
+ export interface RedactFeatures {
16
+ /** Activity visibility, retained state and disconnected effects. */
17
+ activity?: boolean
18
+ /** DOM instances, events, focus, layout and observers for Fragment refs. */
19
+ fragmentRefs?: boolean
20
+ /** Experimental native ViewTransition animations. Opt-in until snapshot parity is complete. */
21
+ viewTransitions?: boolean
22
+ /**
23
+ * `createPortal`. When `false`, portal elements render in place as a
24
+ * Fragment (the `container` prop is ignored). `renderPortal` and its
25
+ * deps are stripped from the bundle.
26
+ */
27
+ portal?: boolean
28
+ /**
29
+ * `createContext` / `useContext` / `<Provider>` / `<Consumer>`. When
30
+ * `false`, Providers render as Fragments (value never propagates),
31
+ * Consumers invoke their function-children with the context's default
32
+ * value, and `useContext` returns the default. Provider-walk logic and
33
+ * `renderProvider` are stripped.
34
+ */
35
+ context?: boolean
36
+ /**
37
+ * `<Suspense>` boundaries + streaming hydration. When `false`, Suspense
38
+ * elements render as Fragments (children mount inline, `fallback` is
39
+ * ignored). Thrown thenables still schedule a re-render on settle, so
40
+ * eventual consistency works — just no fallback UI during the pending
41
+ * window. Boundary-handler stack and hydration integration are stripped.
42
+ */
43
+ suspense?: boolean
44
+ /**
45
+ * `React.memo`. When `false`, memoized components still render but without
46
+ * the prop-equality gate — every parent rerender passes through.
47
+ * `shallowEqual` and the force-rerender bypass are stripped.
48
+ */
49
+ memo?: boolean
50
+ /**
51
+ * `React.forwardRef`. When `false`, forwardRef components still render but
52
+ * the ref prop isn't forwarded to the inner function. React 19+ treats
53
+ * refs as normal props on function components anyway, so most apps can
54
+ * drop this. The dispatcher save/restore machinery is stripped.
55
+ */
56
+ forwardRef?: boolean
57
+ /**
58
+ * `React.lazy`. When `false`, lazy elements still resolve if their payload
59
+ * is already available synchronously (e.g. pre-awaited RSC Flight); async
60
+ * resolution throws a clear error. The hydration-deferred-reveal path and
61
+ * Suspense coordination are stripped.
62
+ */
63
+ lazy?: boolean
64
+ /**
65
+ * Class components (`extends Component`). When `false`, class components
66
+ * still render but only honor the core contract: constructor + `render()`
67
+ * + `setState`. Dropped: `contextType`, `getDerivedStateFromProps`,
68
+ * `shouldComponentUpdate`, `componentDidMount`/`Update`/`WillUnmount`,
69
+ * `getDerivedStateFromError`/`componentDidCatch` (error boundaries).
70
+ */
71
+ classComponents?: boolean
72
+ /**
73
+ * SSR hydration (`hydrateRoot`). When `false`, `hydrateRoot` throws
74
+ * (use `createRoot` for SPAs). The HydrationCursor / DOM adoption /
75
+ * streaming-boundary coordination / event-replay / scroll-guard
76
+ * machinery is stripped — the biggest single chunk of reducible code.
77
+ */
78
+ hydration?: boolean
79
+ }
80
+
81
+ interface ResolvedFeatures {
82
+ activity: boolean
83
+ fragmentRefs: boolean
84
+ viewTransitions: boolean
85
+ portal: boolean
86
+ context: boolean
87
+ suspense: boolean
88
+ memo: boolean
89
+ forwardRef: boolean
90
+ lazy: boolean
91
+ classComponents: boolean
92
+ hydration: boolean
93
+ }
94
+
95
+ const PRESET_DEFAULTS: Record<RedactPreset, ResolvedFeatures> = {
96
+ // Opt-in: everything off. Turn individual features on via `features`.
97
+ nano: {
98
+ activity: false, fragmentRefs: false, viewTransitions: false,
99
+ portal: false, context: false, suspense: false, memo: false,
100
+ forwardRef: false, lazy: false, classComponents: false, hydration: false,
101
+ },
102
+ // Opt-out: everything on (drop-in React parity). Turn features off via `features`.
103
+ full: {
104
+ activity: true, fragmentRefs: true, viewTransitions: false,
105
+ portal: true, context: true, suspense: true, memo: true,
106
+ forwardRef: true, lazy: true, classComponents: true, hydration: true,
107
+ },
108
+ }
109
+
110
+ function resolveFeatures(
111
+ preset: RedactPreset,
112
+ overrides: RedactFeatures,
113
+ ): ResolvedFeatures {
114
+ const p = PRESET_DEFAULTS[preset]
115
+ return {
116
+ activity: overrides.activity ?? p.activity,
117
+ fragmentRefs: overrides.fragmentRefs ?? p.fragmentRefs,
118
+ viewTransitions: overrides.viewTransitions ?? p.viewTransitions,
119
+ portal: overrides.portal ?? p.portal,
120
+ context: overrides.context ?? p.context,
121
+ suspense: overrides.suspense ?? p.suspense,
122
+ memo: overrides.memo ?? p.memo,
123
+ forwardRef: overrides.forwardRef ?? p.forwardRef,
124
+ lazy: overrides.lazy ?? p.lazy,
125
+ classComponents: overrides.classComponents ?? p.classComponents,
126
+ hydration: overrides.hydration ?? p.hydration,
127
+ }
128
+ }
129
+
130
+ export interface RedactOptions {
131
+ /** Skip aliasing specific specifiers, e.g. if a consumer wants real React somewhere. */
132
+ skip?: ReadonlyArray<string>
133
+ /**
134
+ * Override package resolution root. Defaults to the Vite config root. Useful
135
+ * for monorepos where the plugin lives in a different workspace than the
136
+ * consumer app.
137
+ */
138
+ resolveFrom?: string
139
+ /**
140
+ * Explicit package roots, bypassing node_modules lookup. Keys are package
141
+ * names (e.g. `@tanstack/redact`), values are absolute paths to the package
142
+ * directory. Handy for cross-workspace testing / bring-your-own-build setups.
143
+ */
144
+ packageRoots?: Record<string, string>
145
+ /**
146
+ * Starting point for feature selection. `'full'` (default) turns every
147
+ * feature on — drop-in React parity, opt-out individual features via
148
+ * `features`. `'nano'` turns everything off — opt in to what you need.
149
+ */
150
+ preset?: RedactPreset
151
+ /**
152
+ * Per-feature overrides merged on top of the preset's defaults. Enables
153
+ * fine-grained "preset minus X" or "preset plus Y" configurations.
154
+ */
155
+ features?: RedactFeatures
156
+ }
157
+
158
+ // Alias map. ORDER MATTERS — Vite's alias matcher uses first-match against
159
+ // prefix, so more-specific specifiers MUST come before less-specific ones.
160
+ // Without this, `react-dom/server` would prefix-match `react-dom` first and
161
+ // resolve to `@tanstack/redact/dom/server` (wrong) instead of
162
+ // `@tanstack/redact/server`.
163
+ //
164
+ // `use-sync-external-store` aliases are here because its CJS-only React 17
165
+ // compat shim does `var React = require('react')`. That survives Vite's
166
+ // pre-bundling intact and explodes in Cloudflare Workers (no `require`).
167
+ // Modern React has `useSyncExternalStore` built-in, and `@tanstack/redact`
168
+ // additionally exports `useSyncExternalStoreWithSelector` so this alias
169
+ // is safe everywhere.
170
+ const ALIASES: Record<string, string> = {
171
+ // ---- most-specific first ----
172
+ 'use-sync-external-store/shim/with-selector': '@tanstack/redact',
173
+ 'use-sync-external-store/shim/with-selector.js': '@tanstack/redact',
174
+ 'use-sync-external-store/with-selector': '@tanstack/redact',
175
+ 'use-sync-external-store/with-selector.js': '@tanstack/redact',
176
+ // Explicit file subpaths (react-aria imports `shim/index.js`). Without these,
177
+ // dev resolves the raw CJS shim and its named ESM import fails.
178
+ 'use-sync-external-store/shim/index.js': '@tanstack/redact',
179
+ 'use-sync-external-store/index.js': '@tanstack/redact',
180
+ 'use-sync-external-store/shim': '@tanstack/redact',
181
+ 'use-sync-external-store': '@tanstack/redact',
182
+
183
+ // React drop-in shim targets. Subpaths first.
184
+ 'react/jsx-runtime': '@tanstack/redact/jsx-runtime',
185
+ 'react/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
186
+ 'react/compiler-runtime': '@tanstack/redact/compiler-runtime',
187
+ 'react-dom/client': '@tanstack/redact/dom-client',
188
+ 'react-dom/server.browser': '@tanstack/redact/server',
189
+ 'react-dom/server.bun': '@tanstack/redact/server',
190
+ 'react-dom/server.edge': '@tanstack/redact/server',
191
+ 'react-dom/server.node': '@tanstack/redact/server',
192
+ 'react-dom/static.edge': '@tanstack/redact/server',
193
+ 'react-dom/server': '@tanstack/redact/server',
194
+ 'react-dom/test-utils': '@tanstack/redact/dom-test-utils',
195
+ 'react-dom': '@tanstack/redact/dom',
196
+ react: '@tanstack/redact',
197
+ scheduler: '@tanstack/redact/scheduler',
198
+
199
+ // Self-aliases so Vite resolves `@tanstack/redact/*` imports to the same
200
+ // canonical file path no matter where they originate (worker bundle vs
201
+ // deps_ssr pre-bundle vs source). Without these, Cloudflare's
202
+ // `noExternal: true` worker config inlines one copy while Vite's
203
+ // optimizeDeps pre-bundles another, ending up with two separate
204
+ // ReactSharedInternals instances and a null dispatcher in user hooks.
205
+ // Subpaths first here too.
206
+ '@tanstack/redact/jsx-runtime': '@tanstack/redact/jsx-runtime',
207
+ '@tanstack/redact/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
208
+ '@tanstack/redact/compiler-runtime': '@tanstack/redact/compiler-runtime',
209
+ '@tanstack/redact/dom-client': '@tanstack/redact/dom-client',
210
+ '@tanstack/redact/dom-test-utils': '@tanstack/redact/dom-test-utils',
211
+ '@tanstack/redact/server': '@tanstack/redact/server',
212
+ '@tanstack/redact/scheduler': '@tanstack/redact/scheduler',
213
+ '@tanstack/redact/dom': '@tanstack/redact/dom',
214
+ '@tanstack/redact': '@tanstack/redact',
215
+ }
216
+
217
+ function splitSpecifier(specifier: string): { pkg: string; sub: string } {
218
+ if (specifier.startsWith('@')) {
219
+ const slash1 = specifier.indexOf('/')
220
+ const slash2 = specifier.indexOf('/', slash1 + 1)
221
+ if (slash2 < 0) return { pkg: specifier, sub: '' }
222
+ return { pkg: specifier.slice(0, slash2), sub: specifier.slice(slash2 + 1) }
223
+ }
224
+ const slash = specifier.indexOf('/')
225
+ if (slash < 0) return { pkg: specifier, sub: '' }
226
+ return { pkg: specifier.slice(0, slash), sub: specifier.slice(slash + 1) }
227
+ }
228
+
229
+ function findPackageDir(pkg: string, fromDir: string): string | null {
230
+ let dir = fromDir
231
+ while (true) {
232
+ const candidate = resolvePath(dir, 'node_modules', pkg)
233
+ if (existsSync(resolvePath(candidate, 'package.json'))) return candidate
234
+ const parent = dirname(dir)
235
+ if (parent === dir) return null
236
+ dir = parent
237
+ }
238
+ }
239
+
240
+ function resolveExport(packageDir: string, sub: string): string | null {
241
+ const pkgJsonPath = resolvePath(packageDir, 'package.json')
242
+ let pkg: any
243
+ try {
244
+ pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf8'))
245
+ } catch {
246
+ return null
247
+ }
248
+ const key = sub ? './' + sub : '.'
249
+ const exp = pkg.exports?.[key]
250
+ // Prefer published JavaScript over TypeScript sources. Dist preserves one
251
+ // file per module, so subpath imports share state and feature boundaries.
252
+ const pick = (v: any): string | null => {
253
+ if (typeof v === 'string') return v
254
+ if (v && typeof v === 'object') {
255
+ return pick(v.import ?? v.module ?? v.source ?? v.default ?? null)
256
+ }
257
+ return null
258
+ }
259
+ const target = pick(exp)
260
+ if (target) return resolvePath(packageDir, target)
261
+ if (!sub) {
262
+ const main = pkg.module ?? pkg.main
263
+ if (typeof main === 'string') return resolvePath(packageDir, main)
264
+ }
265
+ return null
266
+ }
267
+
268
+ // When installed from npm, `@tanstack/redact` is declared as a `dependency`
269
+ // of consumer apps. Under pnpm's strict mode it ends up nested under the
270
+ // plugin's own `.pnpm/@tanstack+redact@.../node_modules/` rather than
271
+ // hoisted to the consumer's root, so a `findPackageDir` walk starting at
272
+ // the Vite project root won't always find it. Search from the plugin's own
273
+ // directory first (which walks into its nested node_modules), then fall
274
+ // back to the consumer root for hoisted installs.
275
+ const pluginDir = dirname(fileURLToPath(import.meta.url))
276
+
277
+ function resolveSpecifier(
278
+ specifier: string,
279
+ fromDir: string,
280
+ packageRoots: Record<string, string>,
281
+ ): string | null {
282
+ const { pkg, sub } = splitSpecifier(specifier)
283
+ const packageDir =
284
+ packageRoots[pkg] ??
285
+ findPackageDir(pkg, pluginDir) ??
286
+ findPackageDir(pkg, fromDir)
287
+ if (!packageDir) return null
288
+ const target = resolveExport(packageDir, sub)
289
+ if (!target) return null
290
+ // Canonicalize through pnpm symlinks. Under strict pnpm, the package may
291
+ // live nested under `.pnpm/@tanstack+redact@.../node_modules/*`, but each
292
+ // of those is itself a symlink to the flat `.pnpm/@tanstack+redact@.../`
293
+ // entry. Vite's `fetchModule` (used by TanStack Start's server-fn
294
+ // compiler) follows the realpath, so the id seen by the capture-transform
295
+ // differs from the nested id we'd return. That leaves the compiler's
296
+ // moduleCache keyed on the realpath while `getModuleInfo` looks up the
297
+ // nested path → miss → "could not load module info". Returning the
298
+ // canonical realpath here keeps the two sides in agreement.
299
+ try {
300
+ return realpathSync(target)
301
+ } catch {
302
+ return target
303
+ }
304
+ }
305
+
306
+ interface OptimizeDepsWithInclude {
307
+ include?: Array<string>
308
+ }
309
+
310
+ function pruneOptimizeDepsInclude(
311
+ optimizeDeps: OptimizeDepsWithInclude | undefined,
312
+ blocked: ReadonlySet<string>,
313
+ ): void {
314
+ if (!optimizeDeps?.include) return
315
+
316
+ optimizeDeps.include = optimizeDeps.include.filter((id) => {
317
+ const tailSpecifier = id.split('>').pop()?.trim() ?? id
318
+ return !blocked.has(id) && !blocked.has(tailSpecifier)
319
+ })
320
+ }
321
+
322
+ export function redact(options: RedactOptions = {}): any {
323
+ const skip = new Set(options.skip ?? [])
324
+ const entries = Object.entries(ALIASES).filter(([k]) => !skip.has(k))
325
+ const excludeList = entries.map(([k]) => k)
326
+ const optimizeDepsBlocked = new Set(excludeList)
327
+ const features = resolveFeatures(options.preset ?? 'full', options.features ?? {})
328
+
329
+ const resolvedMap: Record<string, string> = {}
330
+ let done = false
331
+ let react18Version: string | undefined
332
+ let runtimeRoot: string | undefined
333
+
334
+ function resolveAll(root: string): void {
335
+ if (done) return
336
+ const fromDir = options.resolveFrom ?? root
337
+ const packageRoots = options.packageRoots ?? {}
338
+ for (const [from, to] of entries) {
339
+ const resolved = resolveSpecifier(to, fromDir, packageRoots)
340
+ if (resolved) resolvedMap[from] = resolved
341
+ }
342
+ done = true
343
+ }
344
+
345
+ return [{
346
+ name: 'redact',
347
+ enforce: 'pre',
348
+
349
+ config() {
350
+ // Single package — only one name to dedupe / no-external.
351
+ const noExt = ['@tanstack/redact']
352
+ const aliasMap = Object.fromEntries(entries.filter(([from, to]) => from !== to))
353
+ // Dedupe `@tanstack/redact` so Vite resolves it to a single instance
354
+ // even when multiple packages (e.g. @tanstack/react-router and user
355
+ // code) drag it into different parts of the module graph.
356
+ const dedupe = noExt
357
+ // Scope `resolve.alias` to client + ssr environments ONLY. Do NOT set
358
+ // a top-level alias: it would apply to the `rsc` environment too,
359
+ // where `@vitejs/plugin-rsc`'s vendored `react-server-dom-server`
360
+ // imports `react` and needs the *real* React (with the `.d` field on
361
+ // ReactSharedInternals that our shim deliberately doesn't have).
362
+ // Aliasing `react` → `@tanstack/redact` in the RSC env crashes Flight
363
+ // serialization. The Cloudflare vite-plugin's rolldown worker-runner
364
+ // also pre-scans bare specifiers via Vite's alias map (not plugin
365
+ // hooks), but it scans within the *ssr* environment specifically —
366
+ // so per-env `environments.ssr.resolve.alias` covers it. The
367
+ // `enforce: 'pre'` resolveId hook below already skips RSC, so the
368
+ // remaining concern is alias placement. Object form is required —
369
+ // array form is silently ignored by rolldown's worker-runner.
370
+ return {
371
+ environments: {
372
+ client: {
373
+ optimizeDeps: { exclude: excludeList },
374
+ resolve: { alias: aliasMap, dedupe },
375
+ },
376
+ ssr: {
377
+ optimizeDeps: { exclude: excludeList },
378
+ resolve: { alias: aliasMap, dedupe, noExternal: noExt },
379
+ },
380
+ },
381
+ ssr: { noExternal: noExt },
382
+ }
383
+ },
384
+
385
+ configResolved(config: any) {
386
+ resolveAll(config.root)
387
+ const reactDir = findPackageDir('react', options.resolveFrom ?? config.root)
388
+ if (reactDir) {
389
+ const installedVersion = JSON.parse(readFileSync(resolvePath(reactDir, 'package.json'), 'utf8')).version
390
+ if (/^18\./.test(installedVersion)) react18Version = installedVersion
391
+ }
392
+ if (resolvedMap.react) {
393
+ runtimeRoot = resolvePath(dirname(resolvedMap.react), '..').replaceAll('\\', '/') + '/'
394
+ }
395
+ // With `packageRoots`, package sources live outside the consumer's Vite
396
+ // project root, so the default server.fs.allow list blocks them. Append
397
+ // to the resolved allow list rather than replacing via `config()`, so we
398
+ // keep Vite's defaults (root + node_modules + client runtime).
399
+ const fsAllow = Object.values(options.packageRoots ?? {})
400
+ if (fsAllow.length && config.server?.fs?.allow) {
401
+ for (const p of fsAllow) {
402
+ if (!config.server.fs.allow.includes(p)) {
403
+ config.server.fs.allow.push(p)
404
+ }
405
+ }
406
+ }
407
+ },
408
+
409
+ async resolveId(this: any, id: string, importer?: string, opts?: any) {
410
+ // Skip the RSC environment — it relies on real React internals via
411
+ // @vitejs/plugin-rsc's vendored react-server-dom. Substituting our
412
+ // shim there breaks Flight serialization. Client + SSR envs still swap.
413
+ const envName = this?.environment?.name
414
+ if (envName === 'rsc') return null
415
+
416
+ // Feature-flag swap: when the reconciler's `features/index` module
417
+ // imports a feature by relative path, redirect to that feature's stub
418
+ // if the flag is off. The stub registers a graceful-degradation
419
+ // matcher (e.g. Portal → Fragment) so user code keeps working.
420
+ if (importer && /[\\/]features[\\/]index\.[jt]sx?$/.test(importer)) {
421
+ const m = id.match(/^\.\/([a-z-]+)(\/index\.js)?$/)
422
+ if (m) {
423
+ const dir = m[1]!
424
+ const name = (dir === 'forward-ref' ? 'forwardRef' : dir === 'fragment-refs' ? 'fragmentRefs' : dir === 'view-transition' ? 'viewTransitions' : dir === 'class' ? 'classComponents' : dir) as keyof ResolvedFeatures
425
+ if (name in features && !features[name]) {
426
+ const r = await this.resolve(`./${dir}/stub${m[2] ? '.js' : ''}`, importer, {
427
+ ...opts,
428
+ skipSelf: true,
429
+ })
430
+ if (r) return r.id
431
+ }
432
+ }
433
+ }
434
+
435
+ // Peer imports must use the same feature selection as the registration
436
+ // entrypoint, or an enabled feature can bring a disabled one back in.
437
+ const peer = id.match(/[\\/](context|hydration|fragment-refs|view-transition|class|suspense-runtime)(?:[\\/]index\.js)?$/)
438
+ const peerKey = peer?.[1] === 'suspense-runtime' ? 'suspense' : peer?.[1] === 'fragment-refs' ? 'fragmentRefs' : peer?.[1] === 'view-transition' ? 'viewTransitions' : peer?.[1] === 'class' ? 'classComponents' : peer?.[1] as 'context' | 'hydration' | undefined
439
+ if (importer && peer && peerKey && !features[peerKey]) {
440
+ const r = await this.resolve(id, importer, { ...opts, skipSelf: true })
441
+ const resolvedFeature = r?.id.match(/features[\\/](context|hydration|fragment-refs|view-transition|class|suspense-runtime)[\\/]index\.(ts|js)$/)
442
+ if (resolvedFeature?.[1] === peer[1]) {
443
+ return r.id.replace(/index\.(ts|js)$/, 'stub.$1')
444
+ }
445
+ }
446
+
447
+ return resolvedMap[id] ?? null
448
+ },
449
+ }, {
450
+ name: 'redact:react18',
451
+ enforce: 'post',
452
+ transform(this: any, code: string, id: string) {
453
+ if (!react18Version || !runtimeRoot || this?.environment?.name === 'rsc') return null
454
+ const path = id.split('?')[0]!.replaceAll('\\', '/')
455
+ if (!path.startsWith(runtimeRoot)) return null
456
+ const module = path.slice(runtimeRoot.length).replace(/\.[jt]s$/, '')
457
+ return adaptReact18(code, id, module, react18Version, (source) => this.parse(source))
458
+ },
459
+ }, {
460
+ name: 'redact:optimize-deps-guard',
461
+ enforce: 'post',
462
+
463
+ configResolved(config: any) {
464
+ // `optimizeDeps.exclude` loses when another plugin force-adds the same
465
+ // ids to `include`. That lets Vite pre-bundle real React next to Redact,
466
+ // producing duplicate dispatcher state. Prune after config settles so
467
+ // Redact's client/SSR shims stay canonical.
468
+ pruneOptimizeDepsInclude(config.optimizeDeps, optimizeDepsBlocked)
469
+ pruneOptimizeDepsInclude(config.environments?.client?.optimizeDeps, optimizeDepsBlocked)
470
+ pruneOptimizeDepsInclude(config.environments?.ssr?.optimizeDeps, optimizeDepsBlocked)
471
+ // Leave `environments.rsc` untouched. RSC depends on real React internals.
472
+ },
473
+ }]
474
+ }
475
+
476
+ export default redact
@@ -0,0 +1,74 @@
1
+ import MagicString from 'magic-string'
2
+
3
+ // Only these owned modules differ between React's public element protocols.
4
+ // Run after Vite's TypeScript transform, before bundling and minification.
5
+ const editsPerModule: Record<string, number> = {
6
+ 'core/types': 1,
7
+ 'react/context': 2,
8
+ 'react/index': 2,
9
+ 'dom/index': 2,
10
+ 'dom/features/context/full': 1,
11
+ 'dom/features/context/stub': 1,
12
+ 'server/walk': 1,
13
+ }
14
+
15
+ export function adaptReact18(code: string, id: string, module: string, version: string, parse: (code: string) => any) {
16
+ const expected = editsPerModule[module]
17
+ if (!expected) return null
18
+ const output = new MagicString(code)
19
+ let edits = 0
20
+ function visit(node: any): void {
21
+ if (!node || typeof node !== 'object') return
22
+ let replacement: string | undefined
23
+ if (node.type === 'Literal') {
24
+ if (module === 'core/types' && node.value === 'react.transitional.element') replacement = JSON.stringify('react.element')
25
+ }
26
+ if ((module === 'react/index' || module === 'dom/index')
27
+ && ((node.type === 'VariableDeclarator' && node.id?.name === 'version')
28
+ || (node.type === 'Property' && node.key?.name === 'version'))) {
29
+ const value = node.init ?? node.value
30
+ if (value?.type === 'Literal' && typeof value.value === 'string') {
31
+ output.overwrite(value.start, value.end, JSON.stringify(version))
32
+ edits++
33
+ return
34
+ }
35
+ }
36
+ if (module === 'react/context' && node.type === 'CallExpression'
37
+ && node.callee?.object?.name === 'Symbol' && node.callee?.property?.name === 'for'
38
+ && node.arguments?.[0]?.value === 'react.consumer') replacement = 'REACT_CONTEXT_TYPE'
39
+ if (module === 'react/context' && node.type === 'FunctionDeclaration' && node.id?.name === 'createContext') {
40
+ if (node.params?.[0]?.name !== 'defaultValue') throw new Error('React 18 adaptation failed: createContext signature changed')
41
+ // React 18 consumers are context objects, not callable components.
42
+ output.overwrite(node.body.start, node.body.end, `{
43
+ const context = { $$typeof: REACT_CONTEXT_TYPE, _currentValue: defaultValue };
44
+ context.Provider = { $$typeof: REACT_PROVIDER_TYPE, _context: context };
45
+ context.Consumer = context._context = context;
46
+ return context;
47
+ }`)
48
+ edits++
49
+ return
50
+ }
51
+ // React 18 uses react.context for consumers, not providers.
52
+ if ((module.startsWith('dom/features/context/') || module === 'server/walk')
53
+ && node.type === 'BinaryExpression' && node.operator === '==='
54
+ && node.left?.name === 'marker' && node.right?.name === 'REACT_CONTEXT_TYPE') {
55
+ replacement = 'false'
56
+ }
57
+ if (replacement !== undefined) {
58
+ // A pure-call annotation no longer applies when a call becomes a symbol.
59
+ for (const annotation of node._rollupAnnotations ?? []) {
60
+ if (annotation.type === 'pure') output.remove(annotation.start, annotation.end)
61
+ }
62
+ output.overwrite(node.start, node.end, replacement)
63
+ edits++
64
+ return
65
+ }
66
+ for (const value of Object.values(node)) {
67
+ if (Array.isArray(value)) value.forEach(visit)
68
+ else if (value && typeof value === 'object') visit(value)
69
+ }
70
+ }
71
+ visit(parse(code))
72
+ if (edits !== expected) throw new Error(`React 18 adaptation failed for ${module}: expected ${expected} protocol edits, found ${edits}`)
73
+ return { code: output.toString(), map: output.generateMap({ source: id, includeContent: true, hires: true }) }
74
+ }
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2020 Cloudflare, Inc. <wrangler@cloudflare.com>
2
+
3
+ Permission is hereby granted, free of charge, to any
4
+ person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the
6
+ Software without restriction, including without
7
+ limitation the rights to use, copy, modify, merge,
8
+ publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software
10
+ is furnished to do so, subject to the following
11
+ conditions:
12
+
13
+ The above copyright notice and this permission notice
14
+ shall be included in all copies or substantial portions
15
+ of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
+ DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,9 @@
1
+ # Cloudflare Vite integration
2
+
3
+ This directory contains the published `@cloudflare/vite-plugin@1.65.0` distribution, with one maintained correction to the development module runner. Indirect `eval` uses the evaluator already provided to that runner, before application modules initialize. Production Workers retain their original evaluation restriction.
4
+
5
+ The original MIT license is in `LICENSE`. `provenance.json` records every source file hash and the upstream fix. `scripts/vendor-cloudflare.mjs` reproduces this distribution from the pinned npm tarball. The build verifies its contents before packaging.
6
+
7
+ `@tanstack/redact/cloudflare` loads this copy using the installed Cloudflare plugin's dependency graph. It requires that exact peer version and scopes dependency resolution to this directory. Other modules use their original resolution. The application must resolve Miniflare's Undici dependency to the fixed version, currently `7.30.1`.
8
+
9
+ This is Node and Worker tooling. It is not imported by any Redact browser runtime entry.