@bleedingdev/tanstack-redact 0.2.1 → 0.3.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 (120) hide show
  1. package/dist/bundler-core/resolution.d.ts +31 -0
  2. package/dist/bundler-core/resolution.js +80 -0
  3. package/dist/bundler-core/resolution.js.map +7 -0
  4. package/dist/bundler-core/selection.d.ts +89 -0
  5. package/dist/bundler-core/selection.js +103 -0
  6. package/dist/bundler-core/selection.js.map +7 -0
  7. package/dist/core/devtools.d.ts +1 -1
  8. package/dist/core/devtools.js +1 -0
  9. package/dist/core/devtools.js.map +2 -2
  10. package/dist/core/functions.js +1 -0
  11. package/dist/core/functions.js.map +2 -2
  12. package/dist/core/internal.d.ts +5 -4
  13. package/dist/core/internal.js +4 -3
  14. package/dist/core/internal.js.map +2 -2
  15. package/dist/core/types.d.ts +2 -2
  16. package/dist/core/types.js +1 -0
  17. package/dist/core/types.js.map +1 -1
  18. package/dist/dom/devtools.d.ts +5 -5
  19. package/dist/dom/devtools.js +1 -0
  20. package/dist/dom/devtools.js.map +2 -2
  21. package/dist/dom/dispatcher.d.ts +1 -1
  22. package/dist/dom/dispatcher.js +1 -0
  23. package/dist/dom/dispatcher.js.map +3 -3
  24. package/dist/dom/document-metadata.d.ts +1 -1
  25. package/dist/dom/document-metadata.js +3 -1
  26. package/dist/dom/document-metadata.js.map +2 -2
  27. package/dist/dom/dom.js +1 -1
  28. package/dist/dom/dom.js.map +2 -2
  29. package/dist/dom/features/class/full.js +25 -32
  30. package/dist/dom/features/class/full.js.map +2 -2
  31. package/dist/dom/features/class/stub.js +1 -0
  32. package/dist/dom/features/class/stub.js.map +2 -2
  33. package/dist/dom/features/hydration/full.d.ts +6 -6
  34. package/dist/dom/features/hydration/full.js +20 -29
  35. package/dist/dom/features/hydration/full.js.map +2 -2
  36. package/dist/dom/features/hydration/stub.d.ts +7 -2
  37. package/dist/dom/features/hydration/stub.js +1 -0
  38. package/dist/dom/features/hydration/stub.js.map +2 -2
  39. package/dist/dom/features/lazy/full.js +1 -0
  40. package/dist/dom/features/lazy/full.js.map +2 -2
  41. package/dist/dom/features/suspense/full.d.ts +4 -1
  42. package/dist/dom/features/suspense/full.js +22 -161
  43. package/dist/dom/features/suspense/full.js.map +2 -2
  44. package/dist/dom/features/suspense-hydration/full.d.ts +8 -0
  45. package/dist/dom/features/suspense-hydration/full.js +147 -0
  46. package/dist/dom/features/suspense-hydration/full.js.map +7 -0
  47. package/dist/dom/features/suspense-hydration/index.d.ts +1 -0
  48. package/dist/dom/features/suspense-hydration/index.js +2 -0
  49. package/dist/dom/features/suspense-hydration/index.js.map +7 -0
  50. package/dist/dom/features/suspense-hydration/stub.d.ts +2 -0
  51. package/dist/dom/features/suspense-hydration/stub.js +9 -0
  52. package/dist/dom/features/suspense-hydration/stub.js.map +7 -0
  53. package/dist/dom/features/suspense-runtime/stub.js +1 -0
  54. package/dist/dom/features/suspense-runtime/stub.js.map +2 -2
  55. package/dist/dom/profiling.d.ts +36 -0
  56. package/dist/dom/profiling.js +9 -0
  57. package/dist/dom/profiling.js.map +7 -0
  58. package/dist/dom/react-ids.js +1 -0
  59. package/dist/dom/react-ids.js.map +2 -2
  60. package/dist/dom/reconcile.d.ts +4 -5
  61. package/dist/dom/reconcile.js +102 -144
  62. package/dist/dom/reconcile.js.map +2 -2
  63. package/dist/dom/resources.js +1 -0
  64. package/dist/dom/resources.js.map +2 -2
  65. package/dist/dom/root-internal.d.ts +1 -1
  66. package/dist/dom/root-internal.js +4 -3
  67. package/dist/dom/root-internal.js.map +2 -2
  68. package/dist/dom/root.d.ts +2 -2
  69. package/dist/dom/root.js +1 -0
  70. package/dist/dom/root.js.map +2 -2
  71. package/dist/dom/synthetic-event.js +6 -4
  72. package/dist/dom/synthetic-event.js.map +2 -2
  73. package/dist/dom/transitions.d.ts +1 -1
  74. package/dist/dom/transitions.js +1 -0
  75. package/dist/dom/transitions.js.map +2 -2
  76. package/dist/react/action-scope.d.ts +1 -1
  77. package/dist/react/action-scope.js +1 -0
  78. package/dist/react/action-scope.js.map +2 -2
  79. package/dist/rspack/index.d.ts +2 -0
  80. package/dist/rspack/index.js +6 -0
  81. package/dist/rspack/index.js.map +7 -0
  82. package/dist/server/bootstrap-script.js +1 -0
  83. package/dist/server/bootstrap-script.js.map +2 -2
  84. package/dist/server/dispatcher.js +11 -20
  85. package/dist/server/dispatcher.js.map +2 -2
  86. package/dist/server/insertion-context.js +9 -16
  87. package/dist/server/insertion-context.js.map +7 -0
  88. package/dist/server/stream-ids.js +1 -0
  89. package/dist/server/stream-ids.js.map +7 -0
  90. package/dist/server/stream.d.ts +1 -2
  91. package/dist/server/stream.js +106 -122
  92. package/dist/server/stream.js.map +2 -2
  93. package/dist/server/walk.js +69 -72
  94. package/dist/server/walk.js.map +3 -3
  95. package/dist/vite/index.d.ts +5 -99
  96. package/dist/vite/index.js +56 -179
  97. package/dist/vite/index.js.map +2 -2
  98. package/dist/webpack/index.d.ts +46 -0
  99. package/dist/webpack/index.js +102 -0
  100. package/dist/webpack/index.js.map +7 -0
  101. package/dist/webpack/react18-loader.cjs +25 -0
  102. package/package.json +17 -3
  103. package/src/bundler-core/resolution.ts +131 -0
  104. package/src/bundler-core/selection.ts +192 -0
  105. package/src/core/internal.ts +2 -1
  106. package/src/core/types.ts +3 -2
  107. package/src/dom/dom.ts +1 -1
  108. package/src/dom/features/class/full.ts +26 -34
  109. package/src/dom/features/suspense/full.ts +7 -165
  110. package/src/dom/features/suspense-hydration/full.ts +166 -0
  111. package/src/dom/features/suspense-hydration/index.ts +1 -0
  112. package/src/dom/features/suspense-hydration/stub.ts +2 -0
  113. package/src/dom/profiling.ts +6 -0
  114. package/src/dom/reconcile.ts +16 -6
  115. package/src/dom/synthetic-event.ts +9 -4
  116. package/src/rspack/index.ts +2 -0
  117. package/src/server/stream.ts +15 -14
  118. package/src/vite/index.ts +55 -317
  119. package/src/webpack/index.ts +108 -0
  120. package/src/webpack/react18-loader.cjs +25 -0
@@ -1,49 +1,15 @@
1
- import { readOwnerStack, runWithOwnerStack } from '../../../core/devtools';
2
1
  import { a as transitionRender } from '../suspense-runtime';
3
2
  import { cleanupEffect } from '../../dispatcher';
4
- import { checkpointCommit, rewindCommit, queueMutation, onCommitFailure, onCommitRollback, commitSynchronously } from '../../commit';
3
+ import { checkpointCommit, rewindCommit, queueMutation, onCommitFailure, onCommitRollback } from '../../commit';
5
4
  import { REACT_SUSPENSE_TYPE, ReactSharedInternals, startTransition } from '../../../react';
6
5
  import { FiberTag, createFiber, type Fiber } from '../../../core';
7
6
  import { disconnectClass, inSuspensePrimary, setRetainedFlag, walkRetained } from '../../retained-effects';
8
7
  import { hasContextChanged, renderContextConsumers } from '../context';
9
8
  import { installRenderer, registerTypeMatcher, installCapability, reconcileRaw, childrenToArray, renderNode, scheduleUpdate, unmountAllChildren, removeFiber, findRoot, runEffects, getCurrentRoot, withCurrentRoot, discardPendingWork, findSuspenseBoundary, RenderSuspenseCapture, activityIsDisconnected, isActivityHidden, attachRef, detachRef, enqueueEffect, flushFiberCommits, scheduleLifecycle, handleCommitError, disposeCleanup, isThenable, defaultHandleSuspended, } from '../../reconcile';
10
- import { HydrationCursor, setHydrationCursor, clearHydrationCursor, advanceCursorPast, tryConsumeBoundary, isHydrationBailout, } from '../hydration';
9
+ import { tryConsumeBoundary, isHydrationBailout, } from '../hydration';
10
+ import { hydrateSuspenseBoundary, recoverBoundaryHydration } from '../suspense-hydration';
11
11
  import { devToolsSuspension } from '../../devtools';
12
12
  let suspendHandler: ((t: Promise<any>) => void) | null = null;
13
- function clearBoundaryRange(startMark: Comment, endMark: Comment): void {
14
- queueMutation(() => {
15
- let node = startMark.nextSibling;
16
- while (node && node !== endMark) {
17
- const next = node.nextSibling;
18
- (node as ChildNode).remove();
19
- node = next;
20
- }
21
- });
22
- }
23
- function rehydrateBoundary(fiber: Fiber): void {
24
- const state = fiber.b;
25
- if (!state?.b || !state.e)
26
- return;
27
- const root = findRoot(fiber);
28
- const parent = state.b.parentNode as Node;
29
- if (!(root && parent))
30
- return;
31
- // Both initial hydration and a streamed reveal adopt the same marked range.
32
- commitSynchronously(() => withCurrentRoot(root, () => {
33
- const previous = root.h;
34
- try {
35
- const kind = state.b.data.startsWith('$E') ? 3 : state.b.data.startsWith('$!') ? 2 : 0;
36
- if (!kind)
37
- unmountAllChildren(fiber);
38
- root.h = true;
39
- hydrateSuspenseBoundary(fiber, { ...fiber.v, children: state.r }, [kind, 0, state.b, state.e], true);
40
- }
41
- finally {
42
- root.h = previous;
43
- }
44
- runEffects(root);
45
- }));
46
- }
47
13
  // React's Suspense semantics: when a re-render of an already-committed
48
14
  // boundary suspends, the previously-committed children are kept in the DOM
49
15
  // (hidden) so their scroll position, focus, selection, native form state,
@@ -71,54 +37,7 @@ interface SuspenseState {
71
37
  ]> | null;
72
38
  f?: Fiber | null;
73
39
  }
74
- function reportServerFailure(fiber: Fiber): void {
75
- const error = new Error(process.env.NODE_ENV !== 'production' ? 'Switched to client rendering because the server render did not complete.' : '');
76
- const handler = findRoot(fiber)?.re;
77
- if (handler) {
78
- if (process.env.NODE_ENV !== 'production') runWithOwnerStack(readOwnerStack(fiber), () => handler(error, { componentStack: null }));
79
- else handler(error, { componentStack: null });
80
- }
81
- else
82
- console.error(error);
83
- }
84
- function recoverBoundaryHydration(fiber: Fiber, children: any, parent: Node, startMark: Comment | null, endMark: Comment | null, retryBoundary?: boolean): void {
85
- const clear = () => {
86
- const dispose = fiber.b?.x;
87
- if (dispose) queueMutation(dispose);
88
- if (startMark && endMark)
89
- clearBoundaryRange(startMark, endMark);
90
- else
91
- queueMutation(() => { parent.textContent = ''; });
92
- };
93
- const root = findRoot(fiber)!;
94
- const prevHydrating = root.h;
95
- if (!retryBoundary)
96
- discardPendingWork(root);
97
- clear();
98
- unmountAllChildren(fiber);
99
- root.h = false;
100
- try {
101
- if (retryBoundary) {
102
- fiber.b = { b: startMark, e: endMark };
103
- renderSuspense(fiber);
104
- }
105
- else
106
- reconcileRaw(fiber, children);
107
- if (endMark)
108
- advanceCursorPast(fiber.p!, endMark);
109
- }
110
- catch (clientError) {
111
- onCommitFailure(() => {
112
- clear();
113
- unmountAllChildren(fiber);
114
- });
115
- throw clientError;
116
- }
117
- finally {
118
- root.h = prevHydrating;
119
- }
120
- }
121
- function scheduleRetry(fiber: Fiber): void {
40
+ export function scheduleRetry(fiber: Fiber): void {
122
41
  const previous = ReactSharedInternals.T;
123
42
  ReactSharedInternals.T = null;
124
43
  try {
@@ -128,88 +47,11 @@ function scheduleRetry(fiber: Fiber): void {
128
47
  ReactSharedInternals.T = previous;
129
48
  }
130
49
  }
131
- function retryHydration(fiber: Fiber, thenable: Promise<any>): void {
50
+ export function retryHydration(fiber: Fiber, thenable: Promise<any>): void {
132
51
  const retry = () => { if (!fiber.u) scheduleRetry(fiber); };
133
52
  thenable.then(retry, retry);
134
53
  }
135
- function hydrateSuspenseBoundary(fiber: Fiber, props: any, boundary: [
136
- 0 | 1 | 2 | 3,
137
- number,
138
- Comment,
139
- Comment
140
- ], reveal?: boolean): void {
141
- const [pendingBoundary, id, startMark, endMark] = boundary;
142
- // Record the boundary shape so we can re-hydrate on reveal.
143
- fiber.b = {
144
- b: startMark,
145
- e: endMark,
146
- r: props.children,
147
- };
148
- if (pendingBoundary >= 2) {
149
- if (pendingBoundary === 3)
150
- reportServerFailure(fiber);
151
- recoverBoundaryHydration(fiber, props.children, startMark.parentNode!, startMark, endMark, true);
152
- fiber.m = props;
153
- return;
154
- }
155
- if (!pendingBoundary) {
156
- // Real DOM is inline between startMark and endMark. Hydrate into it.
157
- const checkpoint = checkpointCommit(fiber);
158
- const parent = startMark.parentNode!;
159
- try {
160
- setHydrationCursor(fiber, new HydrationCursor(parent, startMark.nextSibling, endMark));
161
- reconcileRaw(fiber, props.children);
162
- advanceCursorPast(fiber.p!, endMark);
163
- }
164
- catch (e) {
165
- // A marked boundary owns a known server range. Roll back only its
166
- // unfinished preparation so siblings can hydrate while it waits.
167
- if (isThenable(e)) {
168
- rewindCommit(checkpoint);
169
- fiber.b.w = true;
170
- retryHydration(fiber, e);
171
- advanceCursorPast(fiber.p!, endMark);
172
- }
173
- else if (!isHydrationBailout(e)) {
174
- onCommitFailure(() => {
175
- clearBoundaryRange(startMark, endMark);
176
- unmountAllChildren(fiber);
177
- });
178
- throw e;
179
- }
180
- else recoverBoundaryHydration(fiber, props.children, parent, startMark, endMark);
181
- }
182
- finally {
183
- clearHydrationCursor(fiber);
184
- }
185
- fiber.m = props;
186
- return;
187
- }
188
- if (startMark.data === '$?' || startMark.data === '$~') {
189
- // React owns this pending server range until its reveal script runs.
190
- // Hydrating the fallback would consume the transport template as a host.
191
- fiber.b.w = true;
192
- (startMark as any)._reactRetry = () => {
193
- if (!fiber.u)
194
- scheduleRetry(fiber);
195
- };
196
- advanceCursorPast(fiber.p!, endMark);
197
- fiber.m = props;
198
- return;
199
- }
200
- // Pending transport owns this range until reveal. Keep the opaque server
201
- // range owned by this fiber so deletion also retires its template/fallback.
202
- fiber.b.w = true;
203
- advanceCursorPast(fiber.p!, endMark);
204
- const boundaryId = (findRoot(fiber)?.i ?? '') + 'B:' + id.toString(16);
205
- const dispose = (globalThis as any).$RH?.(boundaryId, () => {
206
- if (!fiber.u && !fiber.pd) rehydrateBoundary(fiber);
207
- });
208
- fiber.b.x = dispose;
209
- if (dispose) onCommitRollback(dispose);
210
- // If the inline runtime isn't present, nothing external will mark us dy.
211
- fiber.m = props;
212
- }
54
+
213
55
  function reconnectLayout(fiber: Fiber): void {
214
56
  if (!fiber.ld || isActivityHidden(fiber) || activityIsDisconnected(fiber))
215
57
  return;
@@ -287,7 +129,7 @@ function setUpdateBoundary(fiber: Fiber, boundary: Fiber | null | undefined): vo
287
129
  if (fiber.t === FiberTag.Suspense && fiber.b?.f)
288
130
  setUpdateBoundary(fiber.b.f, boundary);
289
131
  }
290
- function renderSuspense(fiber: Fiber): void {
132
+ export function renderSuspense(fiber: Fiber): void {
291
133
  const props = fiber.v ?? {};
292
134
  let state = (fiber.b ??= {}) as SuspenseState;
293
135
  // Streaming hydration: if the next DOM node is a server-emitted boundary
@@ -0,0 +1,166 @@
1
+ import { readOwnerStack, runWithOwnerStack } from '../../../core/devtools';
2
+ import type { Fiber } from '../../../core';
3
+ import { checkpointCommit, rewindCommit, queueMutation, onCommitFailure, onCommitRollback, commitSynchronously } from '../../commit';
4
+ import { findRoot, unmountAllChildren, withCurrentRoot, runEffects, discardPendingWork, reconcileRaw, isThenable } from '../../reconcile';
5
+ import { HydrationCursor, setHydrationCursor, clearHydrationCursor, advanceCursorPast, isHydrationBailout } from '../hydration';
6
+ import { renderSuspense, scheduleRetry, retryHydration } from '../suspense/full';
7
+
8
+ function clearBoundaryRange(startMark: Comment, endMark: Comment): void {
9
+ queueMutation(() => {
10
+ let node = startMark.nextSibling;
11
+ while (node && node !== endMark) {
12
+ const next = node.nextSibling;
13
+ (node as ChildNode).remove();
14
+ node = next;
15
+ }
16
+ });
17
+ }
18
+ function rehydrateBoundary(fiber: Fiber): void {
19
+ const state = fiber.b;
20
+ if (!state?.b || !state.e)
21
+ return;
22
+ const root = findRoot(fiber);
23
+ const parent = state.b.parentNode as Node;
24
+ if (!(root && parent))
25
+ return;
26
+ // Both initial hydration and a streamed reveal adopt the same marked range.
27
+ commitSynchronously(() => withCurrentRoot(root, () => {
28
+ const previous = root.h;
29
+ try {
30
+ const kind = state.b.data.startsWith('$E') ? 3 : state.b.data.startsWith('$!') ? 2 : 0;
31
+ if (!kind)
32
+ unmountAllChildren(fiber);
33
+ root.h = true;
34
+ hydrateSuspenseBoundary(fiber, { ...fiber.v, children: state.r }, [kind, 0, state.b, state.e], true);
35
+ }
36
+ finally {
37
+ root.h = previous;
38
+ }
39
+ runEffects(root);
40
+ }));
41
+ }
42
+ function reportServerFailure(fiber: Fiber): void {
43
+ const error = new Error(process.env.NODE_ENV !== 'production' ? 'Switched to client rendering because the server render did not complete.' : '');
44
+ const handler = findRoot(fiber)?.re;
45
+ if (handler) {
46
+ if (process.env.NODE_ENV !== 'production') runWithOwnerStack(readOwnerStack(fiber), () => handler(error, { componentStack: null }));
47
+ else handler(error, { componentStack: null });
48
+ }
49
+ else
50
+ console.error(error);
51
+ }
52
+ export function recoverBoundaryHydration(fiber: Fiber, children: any, parent: Node, startMark: Comment | null, endMark: Comment | null, retryBoundary?: boolean): void {
53
+ const clear = () => {
54
+ const dispose = fiber.b?.x;
55
+ if (dispose) queueMutation(dispose);
56
+ if (startMark && endMark)
57
+ clearBoundaryRange(startMark, endMark);
58
+ else
59
+ queueMutation(() => { parent.textContent = ''; });
60
+ };
61
+ const root = findRoot(fiber)!;
62
+ const prevHydrating = root.h;
63
+ if (!retryBoundary)
64
+ discardPendingWork(root);
65
+ clear();
66
+ unmountAllChildren(fiber);
67
+ root.h = false;
68
+ try {
69
+ if (retryBoundary) {
70
+ fiber.b = { b: startMark, e: endMark };
71
+ renderSuspense(fiber);
72
+ }
73
+ else
74
+ reconcileRaw(fiber, children);
75
+ if (endMark)
76
+ advanceCursorPast(fiber.p!, endMark);
77
+ }
78
+ catch (clientError) {
79
+ onCommitFailure(() => {
80
+ clear();
81
+ unmountAllChildren(fiber);
82
+ });
83
+ throw clientError;
84
+ }
85
+ finally {
86
+ root.h = prevHydrating;
87
+ }
88
+ }
89
+ export function hydrateSuspenseBoundary(fiber: Fiber, props: any, boundary: [
90
+ 0 | 1 | 2 | 3,
91
+ number,
92
+ Comment,
93
+ Comment
94
+ ], reveal?: boolean): void {
95
+ const [pendingBoundary, id, startMark, endMark] = boundary;
96
+ // Record the boundary shape so we can re-hydrate on reveal.
97
+ fiber.b = {
98
+ b: startMark,
99
+ e: endMark,
100
+ r: props.children,
101
+ };
102
+ if (pendingBoundary >= 2) {
103
+ if (pendingBoundary === 3)
104
+ reportServerFailure(fiber);
105
+ recoverBoundaryHydration(fiber, props.children, startMark.parentNode!, startMark, endMark, true);
106
+ fiber.m = props;
107
+ return;
108
+ }
109
+ if (!pendingBoundary) {
110
+ // Real DOM is inline between startMark and endMark. Hydrate into it.
111
+ const checkpoint = checkpointCommit(fiber);
112
+ const parent = startMark.parentNode!;
113
+ try {
114
+ setHydrationCursor(fiber, new HydrationCursor(parent, startMark.nextSibling, endMark));
115
+ reconcileRaw(fiber, props.children);
116
+ advanceCursorPast(fiber.p!, endMark);
117
+ }
118
+ catch (e) {
119
+ // A marked boundary owns a known server range. Roll back only its
120
+ // unfinished preparation so siblings can hydrate while it waits.
121
+ if (isThenable(e)) {
122
+ rewindCommit(checkpoint);
123
+ fiber.b.w = true;
124
+ retryHydration(fiber, e);
125
+ advanceCursorPast(fiber.p!, endMark);
126
+ }
127
+ else if (!isHydrationBailout(e)) {
128
+ onCommitFailure(() => {
129
+ clearBoundaryRange(startMark, endMark);
130
+ unmountAllChildren(fiber);
131
+ });
132
+ throw e;
133
+ }
134
+ else recoverBoundaryHydration(fiber, props.children, parent, startMark, endMark);
135
+ }
136
+ finally {
137
+ clearHydrationCursor(fiber);
138
+ }
139
+ fiber.m = props;
140
+ return;
141
+ }
142
+ if (startMark.data === '$?' || startMark.data === '$~') {
143
+ // React owns this pending server range until its reveal script runs.
144
+ // Hydrating the fallback would consume the transport template as a host.
145
+ fiber.b.w = true;
146
+ (startMark as any)._reactRetry = () => {
147
+ if (!fiber.u)
148
+ scheduleRetry(fiber);
149
+ };
150
+ advanceCursorPast(fiber.p!, endMark);
151
+ fiber.m = props;
152
+ return;
153
+ }
154
+ // Pending transport owns this range until reveal. Keep the opaque server
155
+ // range owned by this fiber so deletion also retires its template/fallback.
156
+ fiber.b.w = true;
157
+ advanceCursorPast(fiber.p!, endMark);
158
+ const boundaryId = (findRoot(fiber)?.i ?? '') + 'B:' + id.toString(16);
159
+ const dispose = (globalThis as any).$RH?.(boundaryId, () => {
160
+ if (!fiber.u && !fiber.pd) rehydrateBoundary(fiber);
161
+ });
162
+ fiber.b.x = dispose;
163
+ if (dispose) onCommitRollback(dispose);
164
+ // If the inline runtime isn't present, nothing external will mark us dy.
165
+ fiber.m = props;
166
+ }
@@ -0,0 +1 @@
1
+ export * from './full'
@@ -0,0 +1,2 @@
1
+ export const hydrateSuspenseBoundary: typeof import('./full').hydrateSuspenseBoundary = () => {}
2
+ export const recoverBoundaryHydration: typeof import('./full').recoverBoundaryHydration = () => {}
@@ -0,0 +1,6 @@
1
+ // Compatibility entrypoint, React profiling instrumentation is not provided.
2
+ import dom from './index'
3
+ import client from './client'
4
+ export * from './index'
5
+ export * from './client'
6
+ export default { ...dom, ...client }
@@ -764,10 +764,9 @@ export function reconcileChildren(parent: Fiber, nodes: Parameters<typeof reconc
764
764
  export function installRenderer(tag: FiberTag, fn: RenderFn): void {
765
765
  RENDERERS[tag] = fn;
766
766
  }
767
- export const recoveringBoundaries = new Set<Fiber>();
768
767
  function findErrorBoundary(fiber: Fiber): Fiber | null {
769
768
  for (let parent = fiber.p; parent; parent = parent.p) {
770
- if (parent.u || parent.pd || recoveringBoundaries.has(parent))
769
+ if (parent.u || parent.pd || parent.br)
771
770
  continue;
772
771
  const instance = parent.i;
773
772
  if (instance?._f === parent && (parent.b?.b?.getDerivedStateFromError || instance.componentDidCatch))
@@ -1006,6 +1005,8 @@ function renderHost(fiber: Fiber): void {
1006
1005
  applyHostProps(fiber.n as Element, props, undefined, isSvg, isInput, isTextarea, deferValue);
1007
1006
  }
1008
1007
  updateFragmentHost(fiber, true);
1008
+ if (!hydrated && props.autoFocus && !isSvg && (deferValue || type === 'button'))
1009
+ scheduleLifecycle(fiber, () => (fiber.n as HTMLElement).focus());
1009
1010
  attachRef(fiber, fiber.n);
1010
1011
  }
1011
1012
  else if (prev !== props) {
@@ -1330,12 +1331,21 @@ export function scheduleUpdate(fiber: Fiber): void {
1330
1331
  pendingRoots.add(root);
1331
1332
  if (isBatching)
1332
1333
  return;
1334
+ // Act owns in-scope work even when a normal microtask is already pending.
1335
+ if (process.env.NODE_ENV !== 'production' && ReactSharedInternals.A) {
1336
+ ReactSharedInternals.A.push(flushPending);
1337
+ return;
1338
+ }
1333
1339
  if (!root.s) {
1334
1340
  root.s = true;
1335
- if (process.env.NODE_ENV !== 'production' && ReactSharedInternals.A)
1336
- ReactSharedInternals.A.push(flushPending);
1337
- else
1338
- queueMicrotask(flushPending);
1341
+ if (process.env.NODE_ENV !== 'production') {
1342
+ const scheduled = () => {
1343
+ if (root.s === scheduled) flushPending();
1344
+ };
1345
+ root.s = scheduled;
1346
+ queueMicrotask(scheduled);
1347
+ }
1348
+ else queueMicrotask(flushPending);
1339
1349
  }
1340
1350
  }
1341
1351
  setCommitCheckpointHook(() => {
@@ -12,10 +12,15 @@ export function createSyntheticEvent(native: Event) {
12
12
  stopImmediatePropagation() { stopped = true; native.stopImmediatePropagation() },
13
13
  persist() {},
14
14
  }
15
- for (const key in native) {
16
- if (!(key in event)) {
17
- const value = (native as any)[key]
18
- event[key] = isFunction(value) ? value.bind(native) : value
15
+ // Walk the prototype chain instead of `for…in`: DOM implementations such as
16
+ // happy-dom define `type`, `target` and other Event fields as non-enumerable
17
+ // accessors. Object.prototype names are already `in event`, so they are skipped.
18
+ for (let o: object | null = native; o; o = Object.getPrototypeOf(o)) {
19
+ for (const key of Object.getOwnPropertyNames(o)) {
20
+ if (!(key in event)) {
21
+ const value = (native as any)[key]
22
+ event[key] = isFunction(value) ? value.bind(native) : value
23
+ }
19
24
  }
20
25
  }
21
26
  return event
@@ -0,0 +1,2 @@
1
+ export { redact, default } from '../webpack/index'
2
+ export type { RedactOptions, RedactPreset, RedactFeatures } from '../webpack/index'
@@ -40,9 +40,8 @@ export interface PipeableWritable {
40
40
 
41
41
  export interface OrchestratorState {
42
42
  nextId: number
43
- pending: Set<Promise<void>>
43
+ pending: (task?: Promise<void>) => Promise<void> | undefined
44
44
  closed: boolean
45
- errored: unknown | null
46
45
  aborted: boolean
47
46
  reason: unknown
48
47
  abort: (reason?: unknown) => void
@@ -58,8 +57,17 @@ export interface OrchestratorState {
58
57
 
59
58
  function createState(): OrchestratorState {
60
59
  let wake!: () => void
60
+ let count = 0, notify: (() => void) | undefined, failed: unknown[] | undefined
61
61
  const state: OrchestratorState = {
62
- nextId: 0, pending: new Set(), closed: false, errored: null,
62
+ nextId: 0, pending(task) {
63
+ if (task) {
64
+ count++
65
+ const done = () => { count--; notify?.() }
66
+ // The empty box marks a consumed failure without retaining it or accepting later failures.
67
+ task.then(done, error => { failed ||= [error]; done() })
68
+ } else if (failed?.length) return Promise.reject(failed.pop())
69
+ else if (count) return new Promise<void>(resolve => { notify = resolve })
70
+ }, closed: false,
63
71
  aborted: false, reason: undefined,
64
72
  cancelled: new Promise<void>((resolve) => { wake = resolve }),
65
73
  abort(reason) {
@@ -154,6 +162,7 @@ export async function streamHtml(
154
162
  if (hints) shellChunks.splice(head, 0, hints)
155
163
  if (state.frame) state.frame.shellFlushed = true
156
164
  let html = partsHtml(shellChunks, state, options)
165
+ shellChunks.length = 0
157
166
 
158
167
  // Inject runtime + bootstrap scripts (once, after shell). Skip the
159
168
  // reveal/event-replay runtime when nothing needs it — no pending
@@ -184,13 +193,12 @@ export async function streamHtml(
184
193
 
185
194
  // 3. Stream suspended boundaries as they resolve
186
195
  for (const b of boundaries) streamBoundary(b, emit, options, state)
187
- await drain(state)
196
+ for (let next; (next = state.pending());) await next
188
197
  } catch (err) {
189
198
  if (isBrowserError(err)) {
190
199
  err = new Error('The server render could not complete because client rendering was requested outside a Suspense boundary.',
191
200
  Object.hasOwn(err, 'cause') ? { cause: err.cause } : undefined)
192
201
  }
193
- state.errored = err
194
202
  if (options.onError) options.onError(err)
195
203
  throw err
196
204
  } finally {
@@ -266,8 +274,7 @@ function streamBoundary(
266
274
  // Recurse: any nested suspensions inside the now-revealed content
267
275
  for (const s of sub) streamBoundary(s, emit, options, state)
268
276
  })()
269
- state.pending.add(task)
270
- task.then(() => state.pending.delete(task), () => state.pending.delete(task))
277
+ state.pending(task)
271
278
  }
272
279
 
273
280
  // Serialize buffered output. Boundaries that completed or failed before this
@@ -288,12 +295,6 @@ function partsHtml(parts: HtmlPart[], state: OrchestratorState, options: StreamO
288
295
  return html
289
296
  }
290
297
 
291
- async function drain(state: OrchestratorState): Promise<void> {
292
- while (state.pending.size > 0) {
293
- await Promise.race(state.pending)
294
- }
295
- }
296
-
297
298
  function scriptNonce(options: StreamOptions): string | undefined {
298
299
  return typeof options.nonce === 'string' ? options.nonce : options.nonce?.script
299
300
  }
@@ -435,7 +436,7 @@ export function renderToReadableStream(
435
436
  pull(controller) {
436
437
  state.flowing = true
437
438
  state.flush?.()
438
- if (state.closed && !state.errored) close(controller)
439
+ if (state.closed) close(controller)
439
440
  },
440
441
  cancel(reason) {
441
442
  state.abort(reason)