@tanstack/redact 0.0.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.
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +7 -0
- package/dist/core/internal.d.ts +76 -0
- package/dist/core/internal.js +59 -0
- package/dist/core/internal.js.map +7 -0
- package/dist/core/types.d.ts +21 -0
- package/dist/core/types.js +10 -0
- package/dist/core/types.js.map +7 -0
- package/dist/dom/_all.d.ts +17 -0
- package/dist/dom/_all.js +51 -0
- package/dist/dom/_all.js.map +7 -0
- package/dist/dom/client.d.ts +3 -0
- package/dist/dom/client.js +8 -0
- package/dist/dom/client.js.map +7 -0
- package/dist/dom/dispatcher.d.ts +20 -0
- package/dist/dom/dispatcher.js +267 -0
- package/dist/dom/dispatcher.js.map +7 -0
- package/dist/dom/dom.d.ts +10 -0
- package/dist/dom/dom.js +262 -0
- package/dist/dom/dom.js.map +7 -0
- package/dist/dom/event-replay.d.ts +13 -0
- package/dist/dom/event-replay.js +46 -0
- package/dist/dom/event-replay.js.map +7 -0
- package/dist/dom/features/class/full.d.ts +1 -0
- package/dist/dom/features/class/full.js +91 -0
- package/dist/dom/features/class/full.js.map +7 -0
- package/dist/dom/features/class/index.d.ts +1 -0
- package/dist/dom/features/class/index.js +3 -0
- package/dist/dom/features/class/index.js.map +7 -0
- package/dist/dom/features/class/stub.d.ts +1 -0
- package/dist/dom/features/class/stub.js +50 -0
- package/dist/dom/features/class/stub.js.map +7 -0
- package/dist/dom/features/context/full.d.ts +1 -0
- package/dist/dom/features/context/full.js +49 -0
- package/dist/dom/features/context/full.js.map +7 -0
- package/dist/dom/features/context/index.d.ts +1 -0
- package/dist/dom/features/context/index.js +3 -0
- package/dist/dom/features/context/index.js.map +7 -0
- package/dist/dom/features/context/stub.d.ts +1 -0
- package/dist/dom/features/context/stub.js +22 -0
- package/dist/dom/features/context/stub.js.map +7 -0
- package/dist/dom/features/forward-ref/full.d.ts +1 -0
- package/dist/dom/features/forward-ref/full.js +51 -0
- package/dist/dom/features/forward-ref/full.js.map +7 -0
- package/dist/dom/features/forward-ref/index.d.ts +1 -0
- package/dist/dom/features/forward-ref/index.js +3 -0
- package/dist/dom/features/forward-ref/index.js.map +7 -0
- package/dist/dom/features/forward-ref/stub.d.ts +1 -0
- package/dist/dom/features/forward-ref/stub.js +22 -0
- package/dist/dom/features/forward-ref/stub.js.map +7 -0
- package/dist/dom/features/hydration/full.d.ts +61 -0
- package/dist/dom/features/hydration/full.js +264 -0
- package/dist/dom/features/hydration/full.js.map +7 -0
- package/dist/dom/features/hydration/index.d.ts +1 -0
- package/dist/dom/features/hydration/index.js +3 -0
- package/dist/dom/features/hydration/index.js.map +7 -0
- package/dist/dom/features/hydration/stub.d.ts +28 -0
- package/dist/dom/features/hydration/stub.js +66 -0
- package/dist/dom/features/hydration/stub.js.map +7 -0
- package/dist/dom/features/index.d.ts +7 -0
- package/dist/dom/features/index.js +9 -0
- package/dist/dom/features/index.js.map +7 -0
- package/dist/dom/features/lazy/full.d.ts +1 -0
- package/dist/dom/features/lazy/full.js +78 -0
- package/dist/dom/features/lazy/full.js.map +7 -0
- package/dist/dom/features/lazy/index.d.ts +1 -0
- package/dist/dom/features/lazy/index.js +3 -0
- package/dist/dom/features/lazy/index.js.map +7 -0
- package/dist/dom/features/lazy/stub.d.ts +1 -0
- package/dist/dom/features/lazy/stub.js +36 -0
- package/dist/dom/features/lazy/stub.js.map +7 -0
- package/dist/dom/features/memo/full.d.ts +1 -0
- package/dist/dom/features/memo/full.js +59 -0
- package/dist/dom/features/memo/full.js.map +7 -0
- package/dist/dom/features/memo/index.d.ts +1 -0
- package/dist/dom/features/memo/index.js +3 -0
- package/dist/dom/features/memo/index.js.map +7 -0
- package/dist/dom/features/memo/stub.d.ts +1 -0
- package/dist/dom/features/memo/stub.js +36 -0
- package/dist/dom/features/memo/stub.js.map +7 -0
- package/dist/dom/features/portal/full.d.ts +1 -0
- package/dist/dom/features/portal/full.js +19 -0
- package/dist/dom/features/portal/full.js.map +7 -0
- package/dist/dom/features/portal/index.d.ts +1 -0
- package/dist/dom/features/portal/index.js +3 -0
- package/dist/dom/features/portal/index.js.map +7 -0
- package/dist/dom/features/portal/stub.d.ts +1 -0
- package/dist/dom/features/portal/stub.js +7 -0
- package/dist/dom/features/portal/stub.js.map +7 -0
- package/dist/dom/features/suspense/full.d.ts +1 -0
- package/dist/dom/features/suspense/full.js +146 -0
- package/dist/dom/features/suspense/full.js.map +7 -0
- package/dist/dom/features/suspense/index.d.ts +1 -0
- package/dist/dom/features/suspense/index.js +3 -0
- package/dist/dom/features/suspense/index.js.map +7 -0
- package/dist/dom/features/suspense/stub.d.ts +1 -0
- package/dist/dom/features/suspense/stub.js +6 -0
- package/dist/dom/features/suspense/stub.js.map +7 -0
- package/dist/dom/index.d.ts +25 -0
- package/dist/dom/index.js +45 -0
- package/dist/dom/index.js.map +7 -0
- package/dist/dom/portal.d.ts +2 -0
- package/dist/dom/portal.js +15 -0
- package/dist/dom/portal.js.map +7 -0
- package/dist/dom/reconcile.d.ts +40 -0
- package/dist/dom/reconcile.js +795 -0
- package/dist/dom/reconcile.js.map +7 -0
- package/dist/dom/root.d.ts +15 -0
- package/dist/dom/root.js +85 -0
- package/dist/dom/root.js.map +7 -0
- package/dist/dom/test-utils.d.ts +1 -0
- package/dist/dom/test-utils.js +10 -0
- package/dist/dom/test-utils.js.map +7 -0
- package/dist/react/children.d.ts +8 -0
- package/dist/react/children.js +75 -0
- package/dist/react/children.js.map +7 -0
- package/dist/react/class.d.ts +31 -0
- package/dist/react/class.js +40 -0
- package/dist/react/class.js.map +7 -0
- package/dist/react/context.d.ts +27 -0
- package/dist/react/context.js +31 -0
- package/dist/react/context.js.map +7 -0
- package/dist/react/element.d.ts +10 -0
- package/dist/react/element.js +64 -0
- package/dist/react/element.js.map +7 -0
- package/dist/react/hooks.d.ts +37 -0
- package/dist/react/hooks.js +146 -0
- package/dist/react/hooks.js.map +7 -0
- package/dist/react/index.d.ts +76 -0
- package/dist/react/index.js +187 -0
- package/dist/react/index.js.map +7 -0
- package/dist/react/jsx-runtime.d.ts +5 -0
- package/dist/react/jsx-runtime.js +21 -0
- package/dist/react/jsx-runtime.js.map +7 -0
- package/dist/react/memo.d.ts +29 -0
- package/dist/react/memo.js +47 -0
- package/dist/react/memo.js.map +7 -0
- package/dist/react/portal.d.ts +1 -0
- package/dist/react/portal.js +6 -0
- package/dist/react/portal.js.map +7 -0
- package/dist/react/shared-internals.d.ts +33 -0
- package/dist/react/shared-internals.js +29 -0
- package/dist/react/shared-internals.js.map +7 -0
- package/dist/react/suspense.d.ts +15 -0
- package/dist/react/suspense.js +16 -0
- package/dist/react/suspense.js.map +7 -0
- package/dist/scheduler/index.d.ts +44 -0
- package/dist/scheduler/index.js +109 -0
- package/dist/scheduler/index.js.map +7 -0
- package/dist/server/bootstrap-script.d.ts +22 -0
- package/dist/server/bootstrap-script.js +16 -0
- package/dist/server/bootstrap-script.js.map +7 -0
- package/dist/server/dispatcher.d.ts +37 -0
- package/dist/server/dispatcher.js +140 -0
- package/dist/server/dispatcher.js.map +7 -0
- package/dist/server/escape.d.ts +7 -0
- package/dist/server/escape.js +159 -0
- package/dist/server/escape.js.map +7 -0
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.js +26 -0
- package/dist/server/index.js.map +7 -0
- package/dist/server/renderToString.d.ts +7 -0
- package/dist/server/renderToString.js +29 -0
- package/dist/server/renderToString.js.map +7 -0
- package/dist/server/stream.d.ts +40 -0
- package/dist/server/stream.js +200 -0
- package/dist/server/stream.js.map +7 -0
- package/dist/server/walk.d.ts +33 -0
- package/dist/server/walk.js +298 -0
- package/dist/server/walk.js.map +7 -0
- package/dist/vite/index.d.ts +96 -0
- package/dist/vite/index.js +217 -0
- package/dist/vite/index.js.map +7 -0
- package/package.json +83 -0
- package/src/core/index.ts +2 -0
- package/src/core/internal.ts +107 -0
- package/src/core/types.ts +36 -0
- package/src/dom/_all.ts +54 -0
- package/src/dom/client.ts +4 -0
- package/src/dom/dispatcher.ts +318 -0
- package/src/dom/dom.ts +316 -0
- package/src/dom/event-replay.ts +55 -0
- package/src/dom/features/class/full.ts +104 -0
- package/src/dom/features/class/index.ts +1 -0
- package/src/dom/features/class/stub.ts +65 -0
- package/src/dom/features/context/full.ts +57 -0
- package/src/dom/features/context/index.ts +1 -0
- package/src/dom/features/context/stub.ts +32 -0
- package/src/dom/features/forward-ref/full.ts +54 -0
- package/src/dom/features/forward-ref/index.ts +1 -0
- package/src/dom/features/forward-ref/stub.ts +28 -0
- package/src/dom/features/hydration/full.ts +345 -0
- package/src/dom/features/hydration/index.ts +1 -0
- package/src/dom/features/hydration/stub.ts +72 -0
- package/src/dom/features/index.ts +11 -0
- package/src/dom/features/lazy/full.ts +98 -0
- package/src/dom/features/lazy/index.ts +1 -0
- package/src/dom/features/lazy/stub.ts +45 -0
- package/src/dom/features/memo/full.ts +74 -0
- package/src/dom/features/memo/index.ts +1 -0
- package/src/dom/features/memo/stub.ts +42 -0
- package/src/dom/features/portal/full.ts +22 -0
- package/src/dom/features/portal/index.ts +1 -0
- package/src/dom/features/portal/stub.ts +11 -0
- package/src/dom/features/suspense/full.ts +191 -0
- package/src/dom/features/suspense/index.ts +1 -0
- package/src/dom/features/suspense/stub.ts +12 -0
- package/src/dom/index.ts +33 -0
- package/src/dom/portal.ts +16 -0
- package/src/dom/reconcile.ts +1169 -0
- package/src/dom/root.ts +107 -0
- package/src/dom/test-utils.ts +6 -0
- package/src/react/children.ts +85 -0
- package/src/react/class.ts +56 -0
- package/src/react/context.ts +50 -0
- package/src/react/element.ts +80 -0
- package/src/react/hooks.ts +190 -0
- package/src/react/index.ts +132 -0
- package/src/react/jsx-runtime.ts +16 -0
- package/src/react/memo.ts +45 -0
- package/src/react/portal.ts +1 -0
- package/src/react/shared-internals.ts +79 -0
- package/src/react/suspense.ts +18 -0
- package/src/scheduler/index.ts +124 -0
- package/src/server/bootstrap-script.ts +52 -0
- package/src/server/dispatcher.ts +158 -0
- package/src/server/escape.ts +187 -0
- package/src/server/index.ts +26 -0
- package/src/server/renderToString.ts +33 -0
- package/src/server/stream.ts +302 -0
- package/src/server/walk.ts +448 -0
- package/src/vite/index.ts +401 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FiberTag, type Fiber } from '../../../core'
|
|
2
|
+
import {
|
|
3
|
+
REACT_FORWARD_REF_TYPE,
|
|
4
|
+
REACT_MEMO_TYPE,
|
|
5
|
+
REACT_LAZY_TYPE,
|
|
6
|
+
} from '../../../react'
|
|
7
|
+
import { registerRenderer, registerTypeMatcher, renderFiber } from '../../reconcile'
|
|
8
|
+
|
|
9
|
+
// Stub: Memo feature disabled. `memo(Component)` still works — the element
|
|
10
|
+
// renders — but without the prop-equality gate, so every parent rerender
|
|
11
|
+
// passes through to the inner component. `shallowEqual` and the
|
|
12
|
+
// forceRerenderingFiber read are stripped.
|
|
13
|
+
function renderMemoStub(fiber: Fiber, domParent: Node, anchor: Node | null): void {
|
|
14
|
+
const { type } = fiber.type as any
|
|
15
|
+
|
|
16
|
+
let innerTag: FiberTag
|
|
17
|
+
if (typeof type === 'function') {
|
|
18
|
+
innerTag = type.prototype?.isReactComponent ? FiberTag.Class : FiberTag.Function
|
|
19
|
+
} else if (type && typeof type === 'object') {
|
|
20
|
+
const m = (type as any).$$typeof
|
|
21
|
+
if (m === REACT_FORWARD_REF_TYPE) innerTag = FiberTag.ForwardRef
|
|
22
|
+
else if (m === REACT_MEMO_TYPE) innerTag = FiberTag.Memo
|
|
23
|
+
else if (m === REACT_LAZY_TYPE) innerTag = FiberTag.Lazy
|
|
24
|
+
else innerTag = FiberTag.Fragment
|
|
25
|
+
} else {
|
|
26
|
+
innerTag = FiberTag.Fragment
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const savedTag = fiber.tag
|
|
30
|
+
const savedType = fiber.type
|
|
31
|
+
fiber.tag = innerTag
|
|
32
|
+
fiber.type = type
|
|
33
|
+
try {
|
|
34
|
+
renderFiber(fiber, domParent, anchor)
|
|
35
|
+
} finally {
|
|
36
|
+
fiber.tag = savedTag
|
|
37
|
+
fiber.type = savedType
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
registerTypeMatcher((_type, marker) => (marker === REACT_MEMO_TYPE ? FiberTag.Memo : null))
|
|
42
|
+
registerRenderer(FiberTag.Memo, renderMemoStub)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FiberTag, type Fiber, type ReactNode } from '../../../core'
|
|
2
|
+
import { REACT_PORTAL_TYPE } from '../../../react'
|
|
3
|
+
import {
|
|
4
|
+
registerRenderer,
|
|
5
|
+
registerTypeMatcher,
|
|
6
|
+
registerElementMarker,
|
|
7
|
+
reconcileChildren,
|
|
8
|
+
childrenToArray,
|
|
9
|
+
} from '../../reconcile'
|
|
10
|
+
|
|
11
|
+
function renderPortal(fiber: Fiber, _domParent: Node, _anchor: Node | null): void {
|
|
12
|
+
const { children, container } = fiber.pendingProps as {
|
|
13
|
+
children: ReactNode
|
|
14
|
+
container: Element
|
|
15
|
+
}
|
|
16
|
+
reconcileChildren(fiber, childrenToArray(children), container, null)
|
|
17
|
+
fiber.memoizedProps = fiber.pendingProps
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
registerElementMarker(REACT_PORTAL_TYPE)
|
|
21
|
+
registerTypeMatcher((type) => (type === REACT_PORTAL_TYPE ? FiberTag.Portal : null))
|
|
22
|
+
registerRenderer(FiberTag.Portal, renderPortal)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './full'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FiberTag } from '../../../core'
|
|
2
|
+
import { REACT_PORTAL_TYPE } from '../../../react'
|
|
3
|
+
import { registerTypeMatcher, registerElementMarker } from '../../reconcile'
|
|
4
|
+
|
|
5
|
+
// Stub: Portal feature disabled. Portal elements still flow through JSX
|
|
6
|
+
// (otherwise they'd be silently dropped by child normalization), but render
|
|
7
|
+
// in place as a Fragment — the `container` prop is ignored. No Portal
|
|
8
|
+
// renderer is registered, so the `renderPortal` function and its deps don't
|
|
9
|
+
// ship in builds that select this stub.
|
|
10
|
+
registerElementMarker(REACT_PORTAL_TYPE)
|
|
11
|
+
registerTypeMatcher((type) => (type === REACT_PORTAL_TYPE ? FiberTag.Fragment : null))
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { FiberTag, type Fiber } from '../../../core'
|
|
2
|
+
import { REACT_SUSPENSE_TYPE } from '../../../react'
|
|
3
|
+
import {
|
|
4
|
+
registerRenderer,
|
|
5
|
+
registerTypeMatcher,
|
|
6
|
+
installCapability,
|
|
7
|
+
reconcileChildren,
|
|
8
|
+
childrenToArray,
|
|
9
|
+
scheduleUpdate,
|
|
10
|
+
unmountAllChildren,
|
|
11
|
+
findRoot,
|
|
12
|
+
runEffects,
|
|
13
|
+
getCurrentRoot,
|
|
14
|
+
withCurrentRoot,
|
|
15
|
+
} from '../../reconcile'
|
|
16
|
+
import {
|
|
17
|
+
HydrationCursor,
|
|
18
|
+
setHydrationCursor,
|
|
19
|
+
clearHydrationCursor,
|
|
20
|
+
advanceCursorPast,
|
|
21
|
+
tryConsumeBoundary,
|
|
22
|
+
} from '../hydration'
|
|
23
|
+
|
|
24
|
+
const suspendHandlerStack: Array<(t: Promise<any>) => void> = []
|
|
25
|
+
|
|
26
|
+
function realHandleSuspended(fiber: Fiber, thenable: Promise<any>): void {
|
|
27
|
+
const handler = suspendHandlerStack[suspendHandlerStack.length - 1]
|
|
28
|
+
if (handler) {
|
|
29
|
+
handler(thenable)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
// Fallback: schedule re-render when promise settles
|
|
33
|
+
thenable.then(
|
|
34
|
+
() => scheduleUpdate(fiber),
|
|
35
|
+
() => scheduleUpdate(fiber),
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function renderSuspense(fiber: Fiber, domParent: Node, anchor: Node | null): void {
|
|
40
|
+
const props = fiber.pendingProps ?? {}
|
|
41
|
+
const state = (fiber.memoizedState ??= { suspended: false, pending: null as Promise<any> | null })
|
|
42
|
+
|
|
43
|
+
// Streaming hydration: if the next DOM node is a server-emitted boundary
|
|
44
|
+
// marker, route through the boundary-aware hydration path.
|
|
45
|
+
const root = getCurrentRoot()
|
|
46
|
+
if (root?.hydrating && fiber.parent && !state.hydrated) {
|
|
47
|
+
const boundary = tryConsumeBoundary(fiber.parent)
|
|
48
|
+
if (boundary) {
|
|
49
|
+
hydrateSuspenseBoundary(fiber, props, boundary, domParent, anchor)
|
|
50
|
+
state.hydrated = true
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// A descendant Lazy deferred its hydration (see renderLazy's hydrating
|
|
56
|
+
// branch). Its SSR-rendered content is still in the DOM and cursor-bound
|
|
57
|
+
// via the Lazy fiber — we just haven't swapped it into a fiber subtree
|
|
58
|
+
// yet. Until the Lazy's resume fires, skip our own tryChildren pass so
|
|
59
|
+
// an unrelated re-render can't accidentally flip us into the suspended
|
|
60
|
+
// path and mount a duplicate fallback on top of the SSR content.
|
|
61
|
+
if ((state as any)._awaitingLazyHydration) {
|
|
62
|
+
fiber.memoizedProps = props
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const tryChildren = () => {
|
|
67
|
+
reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (state.suspended && state.pending) {
|
|
71
|
+
// Render fallback while waiting; pending promise will reschedule
|
|
72
|
+
reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)
|
|
73
|
+
fiber.memoizedProps = props
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Attempt children — suspension is handled by the pushed handler below
|
|
78
|
+
const savedHandler = suspendHandlerStack[suspendHandlerStack.length - 1]
|
|
79
|
+
suspendHandlerStack.push((thenable) => {
|
|
80
|
+
state.suspended = true
|
|
81
|
+
state.pending = thenable
|
|
82
|
+
thenable.then(
|
|
83
|
+
() => {
|
|
84
|
+
state.suspended = false
|
|
85
|
+
state.pending = null
|
|
86
|
+
scheduleUpdate(fiber)
|
|
87
|
+
},
|
|
88
|
+
() => {
|
|
89
|
+
state.suspended = false
|
|
90
|
+
state.pending = null
|
|
91
|
+
scheduleUpdate(fiber)
|
|
92
|
+
},
|
|
93
|
+
)
|
|
94
|
+
})
|
|
95
|
+
try {
|
|
96
|
+
tryChildren()
|
|
97
|
+
} finally {
|
|
98
|
+
suspendHandlerStack.pop()
|
|
99
|
+
void savedHandler
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (state.suspended) {
|
|
103
|
+
// Replace children with fallback
|
|
104
|
+
unmountAllChildren(fiber, domParent)
|
|
105
|
+
reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)
|
|
106
|
+
}
|
|
107
|
+
fiber.memoizedProps = props
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function hydrateSuspenseBoundary(
|
|
111
|
+
fiber: Fiber,
|
|
112
|
+
props: any,
|
|
113
|
+
boundary: { kind: 'pending' | 'resolved'; id: number; startMark: Comment; endMark: Comment },
|
|
114
|
+
domParent: Node,
|
|
115
|
+
anchor: Node | null,
|
|
116
|
+
): void {
|
|
117
|
+
const { kind, id, startMark, endMark } = boundary
|
|
118
|
+
// Record the boundary shape so we can re-hydrate on reveal.
|
|
119
|
+
fiber.memoizedState = {
|
|
120
|
+
suspended: false,
|
|
121
|
+
pending: null,
|
|
122
|
+
hydrated: true,
|
|
123
|
+
boundaryId: id,
|
|
124
|
+
startMark,
|
|
125
|
+
endMark,
|
|
126
|
+
realChildren: props.children,
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (kind === 'resolved') {
|
|
130
|
+
// Real DOM is inline between startMark and endMark. Hydrate into it.
|
|
131
|
+
const cursor = new HydrationCursor(startMark.parentNode!, startMark.nextSibling, endMark)
|
|
132
|
+
setHydrationCursor(fiber, cursor)
|
|
133
|
+
reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)
|
|
134
|
+
clearHydrationCursor(fiber)
|
|
135
|
+
advanceCursorPast(fiber.parent!, endMark)
|
|
136
|
+
fiber.memoizedProps = props
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Pending: fallback DOM lives inside <div id="B:ID">. Hydrate the fallback
|
|
141
|
+
// React subtree against that div's children.
|
|
142
|
+
const bDiv = (document as Document).getElementById(`B:${id}`)
|
|
143
|
+
if (bDiv) {
|
|
144
|
+
const cursor = new HydrationCursor(bDiv)
|
|
145
|
+
setHydrationCursor(fiber, cursor)
|
|
146
|
+
reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)
|
|
147
|
+
clearHydrationCursor(fiber)
|
|
148
|
+
} else {
|
|
149
|
+
// Couldn't find fallback container — render fresh (non-adopting)
|
|
150
|
+
reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)
|
|
151
|
+
}
|
|
152
|
+
advanceCursorPast(fiber.parent!, endMark)
|
|
153
|
+
|
|
154
|
+
// Register for server-streamed reveal (HTML chunks + $RC calls).
|
|
155
|
+
const win = globalThis as any
|
|
156
|
+
if (typeof win.$RH === 'function') {
|
|
157
|
+
win.$RH(id, () => rehydrateBoundary(fiber))
|
|
158
|
+
}
|
|
159
|
+
// If the inline runtime isn't present, nothing external will mark us dirty.
|
|
160
|
+
|
|
161
|
+
fiber.memoizedProps = props
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function rehydrateBoundary(fiber: Fiber): void {
|
|
165
|
+
const state = fiber.memoizedState
|
|
166
|
+
if (!state || !state.startMark || !state.endMark) return
|
|
167
|
+
|
|
168
|
+
const root = findRoot(fiber)
|
|
169
|
+
if (!root) return
|
|
170
|
+
const parent = state.startMark.parentNode as Node
|
|
171
|
+
if (!parent) return
|
|
172
|
+
|
|
173
|
+
// Unmount existing fallback subtree. Its DOM has already been removed by $RC
|
|
174
|
+
// (or at least its container); unmounting here cleans up fibers + effects.
|
|
175
|
+
withCurrentRoot(root, () => {
|
|
176
|
+
unmountAllChildren(fiber, parent)
|
|
177
|
+
|
|
178
|
+
// Re-hydrate with real children against the now-real DOM range.
|
|
179
|
+
root.hydrating = true
|
|
180
|
+
const cursor = new HydrationCursor(parent, state.startMark.nextSibling, state.endMark)
|
|
181
|
+
setHydrationCursor(fiber, cursor)
|
|
182
|
+
reconcileChildren(fiber, childrenToArray(state.realChildren), parent, null)
|
|
183
|
+
clearHydrationCursor(fiber)
|
|
184
|
+
root.hydrating = false
|
|
185
|
+
runEffects(root)
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
registerTypeMatcher((type) => (type === REACT_SUSPENSE_TYPE ? FiberTag.Suspense : null))
|
|
190
|
+
registerRenderer(FiberTag.Suspense, renderSuspense)
|
|
191
|
+
installCapability('handleSuspended', realHandleSuspended)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './full'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FiberTag } from '../../../core'
|
|
2
|
+
import { REACT_SUSPENSE_TYPE } from '../../../react'
|
|
3
|
+
import { registerTypeMatcher } from '../../reconcile'
|
|
4
|
+
|
|
5
|
+
// Stub: Suspense feature disabled. `<Suspense>` elements render as Fragments
|
|
6
|
+
// — children mount inline and `fallback` is ignored. Thrown thenables in
|
|
7
|
+
// descendants fall through to the default `handleSuspended` capability
|
|
8
|
+
// (in reconcile.ts), which schedules a re-render when the promise settles.
|
|
9
|
+
// Eventual consistency still works; there's just no fallback UI during the
|
|
10
|
+
// pending window. Boundary-handler stack, streaming hydration integration,
|
|
11
|
+
// and fallback-swap logic are all stripped.
|
|
12
|
+
registerTypeMatcher((type) => (type === REACT_SUSPENSE_TYPE ? FiberTag.Fragment : null))
|
package/src/dom/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Side-effect import: registers opt-in features (Portal, etc.) with the
|
|
2
|
+
// reconciler. A vite plugin may alias individual feature modules to their
|
|
3
|
+
// stub variants to strip them from the bundle.
|
|
4
|
+
import './features'
|
|
5
|
+
|
|
6
|
+
export { flushSync, batchedUpdates as unstable_batchedUpdates } from './root'
|
|
7
|
+
export { createPortal } from './portal'
|
|
8
|
+
|
|
9
|
+
// Resource hints — stubs
|
|
10
|
+
export function preconnect(_href: string, _opts?: any): void {}
|
|
11
|
+
export function prefetchDNS(_href: string): void {}
|
|
12
|
+
export function preload(_href: string, _opts?: any): void {}
|
|
13
|
+
export function preinit(_href: string, _opts?: any): void {}
|
|
14
|
+
export function preloadModule(_href: string, _opts?: any): void {}
|
|
15
|
+
export function preinitModule(_href: string, _opts?: any): void {}
|
|
16
|
+
|
|
17
|
+
export const version = '19.2.3'
|
|
18
|
+
|
|
19
|
+
// Required by React's default export consumers
|
|
20
|
+
import { flushSync, batchedUpdates } from './root'
|
|
21
|
+
import { createPortal } from './portal'
|
|
22
|
+
export default {
|
|
23
|
+
flushSync,
|
|
24
|
+
unstable_batchedUpdates: batchedUpdates,
|
|
25
|
+
createPortal,
|
|
26
|
+
preconnect,
|
|
27
|
+
prefetchDNS,
|
|
28
|
+
preload,
|
|
29
|
+
preinit,
|
|
30
|
+
preloadModule,
|
|
31
|
+
preinitModule,
|
|
32
|
+
version: '19.2.3',
|
|
33
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode, ReactElement } from '../core'
|
|
2
|
+
import { REACT_PORTAL_TYPE } from '../react'
|
|
3
|
+
|
|
4
|
+
export function createPortal(
|
|
5
|
+
children: ReactNode,
|
|
6
|
+
container: Element,
|
|
7
|
+
key: string | null = null,
|
|
8
|
+
): ReactElement {
|
|
9
|
+
return {
|
|
10
|
+
$$typeof: REACT_PORTAL_TYPE as any,
|
|
11
|
+
type: REACT_PORTAL_TYPE as any,
|
|
12
|
+
key: key == null ? null : '' + key,
|
|
13
|
+
ref: null,
|
|
14
|
+
props: { children, container },
|
|
15
|
+
}
|
|
16
|
+
}
|