@tanstack/redact 0.0.8 → 0.0.10

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.
@@ -39,7 +39,11 @@ function depsEqual(a, b) {
39
39
  }
40
40
  return true;
41
41
  }
42
+ var DISPATCHER = makeDispatcherImpl();
42
43
  function makeDispatcher() {
44
+ return DISPATCHER;
45
+ }
46
+ function makeDispatcherImpl() {
43
47
  return {
44
48
  useState(initial) {
45
49
  return this.useReducer(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/dispatcher.ts"],
4
- "sourcesContent": ["import type { Hook, Fiber, FiberRoot, Effect } from '../core'\nimport { ReactSharedInternals, REACT_CONTEXT_TYPE } from '../react'\nimport { scheduleUpdate, enqueueEffect, readContext } from './reconcile'\n\nfunction getCurrentFiber(): Fiber {\n const f = ReactSharedInternals.currentFiber\n if (!f) throw new Error('Hook called outside a function component render.')\n return f\n}\n\nfunction nextHook(): Hook {\n const fiber = getCurrentFiber()\n const idx = ReactSharedInternals.hookIndex++\n\n let prev = ReactSharedInternals.currentHook\n\n if (idx === 0) {\n if (fiber.hooks) {\n ReactSharedInternals.currentHook = fiber.hooks\n return fiber.hooks\n }\n const h: Hook = { state: undefined, queue: undefined, deps: undefined, cleanup: undefined, next: null }\n fiber.hooks = h\n ReactSharedInternals.currentHook = h\n return h\n }\n\n if (prev && prev.next) {\n ReactSharedInternals.currentHook = prev.next\n return prev.next\n }\n\n const h: Hook = { state: undefined, queue: undefined, deps: undefined, cleanup: undefined, next: null }\n if (prev) prev.next = h\n else fiber.hooks = h\n ReactSharedInternals.currentHook = h\n return h\n}\n\nfunction depsEqual(\n a: ReadonlyArray<unknown> | undefined,\n b: ReadonlyArray<unknown> | undefined,\n): boolean {\n if (a === b) return true\n if (!a || !b) return false\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!Object.is(a[i], b[i])) return false\n }\n return true\n}\n\nexport function makeDispatcher() {\n return {\n useState<S>(initial: S | (() => S)) {\n return this.useReducer<S, S | ((p: S) => S)>(\n basicReducer as any,\n typeof initial === 'function' ? (initial as () => S)() : initial,\n )\n },\n\n useReducer<S, A>(reducer: (s: S, a: A) => S, initialArg: any, init?: (a: any) => S) {\n const hook = nextHook()\n const fiber = getCurrentFiber()\n if (hook.queue === undefined) {\n hook.state = init ? init(initialArg) : initialArg\n const queue: any = { reducer }\n const dispatch = (action: A) => {\n const currentState = hook.state as S\n const next = queue.reducer(currentState, action)\n if (!Object.is(next, currentState)) {\n hook.state = next\n scheduleUpdate(fiber)\n }\n }\n queue.dispatch = dispatch\n hook.queue = queue\n } else {\n hook.queue.reducer = reducer\n }\n return [hook.state, hook.queue.dispatch] as [S, (a: A) => void]\n },\n\n useEffect(create: () => any, deps?: ReadonlyArray<unknown>) {\n const hook = nextHook()\n const fiber = getCurrentFiber()\n const prevDeps = hook.deps\n if (prevDeps !== undefined && depsEqual(prevDeps, deps)) return\n hook.deps = deps\n const effect: Effect = {\n tag: 'effect',\n create: () => {\n // Run the prior cleanup INSIDE the effect run, not during the\n // dispatch/render phase. If render A \u2192 B \u2192 C all happen back-to-\n // back before the passive microtask drains, dispatch-time cleanup\n // only fires once (between A\u2192B) and effects B + C both run fresh,\n // leaving two side-effects (e.g. two plot SVGs) in the DOM. Doing\n // it here, at effect-run time, means every new create first tears\n // down whatever cleanup is currently live on the hook.\n if (hook.cleanup) {\n try { hook.cleanup() } catch {}\n // The prior cleanup was also pushed onto fiber.cleanups; remove\n // it so unmount doesn't double-call it.\n if (fiber.cleanups) {\n const i = fiber.cleanups.indexOf(hook.cleanup)\n if (i >= 0) fiber.cleanups.splice(i, 1)\n }\n hook.cleanup = null\n }\n const c = create()\n hook.cleanup = typeof c === 'function' ? c : null\n return hook.cleanup\n },\n destroy: undefined,\n deps,\n }\n enqueueEffect(fiber, effect)\n },\n\n useLayoutEffect(create: () => any, deps?: ReadonlyArray<unknown>) {\n const hook = nextHook()\n const fiber = getCurrentFiber()\n const prevDeps = hook.deps\n if (prevDeps !== undefined && depsEqual(prevDeps, deps)) return\n hook.deps = deps\n const effect: Effect = {\n tag: 'layout',\n create: () => {\n // Mirror useEffect: tear down the prior cleanup at run time so\n // coalesced renders don't leak side-effects.\n if (hook.cleanup) {\n try { hook.cleanup() } catch {}\n if (fiber.cleanups) {\n const i = fiber.cleanups.indexOf(hook.cleanup)\n if (i >= 0) fiber.cleanups.splice(i, 1)\n }\n hook.cleanup = null\n }\n const c = create()\n hook.cleanup = typeof c === 'function' ? c : null\n return hook.cleanup\n },\n destroy: undefined,\n deps,\n }\n enqueueEffect(fiber, effect)\n },\n\n useInsertionEffect(create: () => any, deps?: ReadonlyArray<unknown>) {\n return this.useLayoutEffect(create, deps)\n },\n\n useRef<T>(initial: T) {\n const hook = nextHook()\n if (hook.state === undefined) hook.state = { current: initial }\n return hook.state as { current: T }\n },\n\n useMemo<T>(factory: () => T, deps?: ReadonlyArray<unknown>) {\n const hook = nextHook()\n if (hook.deps !== undefined && depsEqual(hook.deps, deps)) {\n return hook.state as T\n }\n const value = factory()\n hook.state = value\n hook.deps = deps\n return value\n },\n\n useCallback<T extends Function>(fn: T, deps?: ReadonlyArray<unknown>): T {\n return this.useMemo(() => fn, deps) as T\n },\n\n useContext<T>(ctx: any): T {\n const fiber = getCurrentFiber()\n return readContext(fiber, ctx)\n },\n\n useImperativeHandle<T>(ref: any, factory: () => T, deps?: ReadonlyArray<unknown>) {\n const hook = nextHook()\n if (hook.deps !== undefined && depsEqual(hook.deps, deps)) return\n hook.deps = deps\n const value = factory()\n if (ref) {\n if (typeof ref === 'function') ref(value)\n else ref.current = value\n }\n },\n\n useDebugValue<T>(_value: T, _formatter?: (v: T) => any): void {\n // noop\n },\n\n useId(): string {\n const hook = nextHook()\n if (hook.state === undefined) {\n const fiber = getCurrentFiber()\n const root = findRootFromFiber(fiber)\n hook.state = (root?.identifierPrefix ?? ':r') + (idCounter++).toString(36)\n }\n return hook.state as string\n },\n\n useTransition(): [boolean, (fn: () => void) => void] {\n return [false, (fn: () => void) => fn()]\n },\n\n useDeferredValue<T>(v: T): T {\n return v\n },\n\n useSyncExternalStore<T>(\n subscribe: (cb: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n ): T {\n const fiber = getCurrentFiber()\n const hook = nextHook()\n\n // During hydration, use the server snapshot (if provided) so the tree\n // matches the SSR output. Components like TanStack Router's ClientOnly\n // rely on this: they render `false` on server, `true` on client \u2014 and\n // if we return `true` during hydration, client and server diverge and\n // the tree mounts fresh next to the SSR fallback DOM.\n const root = fiber.root ?? findRootFromFiber(fiber)\n const isHydrating = Boolean(root?.hydrating)\n const value =\n isHydrating && getServerSnapshot ? getServerSnapshot() : getSnapshot()\n hook.state = value\n\n if (hook.cleanup == null) {\n const forceUpdate = () => {\n let next: T\n try {\n next = getSnapshot()\n } catch {\n scheduleUpdate(fiber)\n return\n }\n if (!Object.is(hook.state, next)) {\n hook.state = next\n scheduleUpdate(fiber)\n }\n }\n const unsubscribe = subscribe(forceUpdate)\n hook.cleanup = unsubscribe\n // Register with fiber so unmountFiber runs it. Without this, the store\n // keeps holding forceUpdate and every store update schedules an already-\n // unmounted fiber \u2014 its rerender walks stale .parent pointers and mounts\n // zombie DOM into the old parent.\n if (typeof unsubscribe === 'function') {\n fiber.cleanups ||= []\n fiber.cleanups.push(unsubscribe)\n }\n\n // If we served the server snapshot, run a post-hydration check so\n // components like `useHydrated()` flip from false \u2192 true after the\n // initial render commits. Queued late so hydration finishes first.\n if (isHydrating && getServerSnapshot) {\n queueMicrotask(() => queueMicrotask(forceUpdate))\n }\n }\n return value\n },\n\n use<T>(resource: any): T {\n if (resource == null) throw new Error('use() received null or undefined')\n if (resource.$$typeof === REACT_CONTEXT_TYPE) {\n return readContext(getCurrentFiber(), resource)\n }\n if (typeof resource.then === 'function') {\n const thenable = resource\n switch (thenable.status) {\n case 'fulfilled':\n return thenable.value\n case 'rejected':\n throw thenable.reason\n default: {\n if (thenable.status === undefined) {\n thenable.status = 'pending'\n thenable.then(\n (v: any) => {\n if (thenable.status === 'pending') {\n thenable.status = 'fulfilled'\n thenable.value = v\n }\n },\n (e: any) => {\n if (thenable.status === 'pending') {\n thenable.status = 'rejected'\n thenable.reason = e\n }\n },\n )\n }\n throw thenable\n }\n }\n }\n throw new Error('use() expected a Promise or Context')\n },\n }\n}\n\nfunction basicReducer<S>(state: S, action: S | ((p: S) => S)): S {\n return typeof action === 'function' ? (action as (p: S) => S)(state) : action\n}\n\nlet idCounter = 0\n\nfunction findRootFromFiber(fiber: Fiber): FiberRoot | null {\n let f: Fiber | null = fiber\n while (f) {\n if (f.root) return f.root\n f = f.parent\n }\n return null\n}\n"],
5
- "mappings": ";AACA,SAAS,sBAAsB,0BAA0B;AACzD,SAAS,gBAAgB,eAAe,mBAAmB;AAE3D,SAAS,kBAAyB;AAChC,QAAM,IAAI,qBAAqB;AAC/B,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,kDAAkD;AAC1E,SAAO;AACT;AAEA,SAAS,WAAiB;AACxB,QAAM,QAAQ,gBAAgB;AAC9B,QAAM,MAAM,qBAAqB;AAEjC,MAAI,OAAO,qBAAqB;AAEhC,MAAI,QAAQ,GAAG;AACb,QAAI,MAAM,OAAO;AACf,2BAAqB,cAAc,MAAM;AACzC,aAAO,MAAM;AAAA,IACf;AACA,UAAMA,KAAU,EAAE,OAAO,QAAW,OAAO,QAAW,MAAM,QAAW,SAAS,QAAW,MAAM,KAAK;AACtG,UAAM,QAAQA;AACd,yBAAqB,cAAcA;AACnC,WAAOA;AAAA,EACT;AAEA,MAAI,QAAQ,KAAK,MAAM;AACrB,yBAAqB,cAAc,KAAK;AACxC,WAAO,KAAK;AAAA,EACd;AAEA,QAAM,IAAU,EAAE,OAAO,QAAW,OAAO,QAAW,MAAM,QAAW,SAAS,QAAW,MAAM,KAAK;AACtG,MAAI,KAAM,MAAK,OAAO;AAAA,MACjB,OAAM,QAAQ;AACnB,uBAAqB,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WAAW;AACjC,6BAAS,SAAS;AAClB,6BAAS,QAAQ;AAAA,kBACnB;AAAA,gBACF;AAAA,gBACA,CAAC,MAAW;AACV,sBAAI,SAAS,WAAW,WAAW;AACjC,6BAAS,SAAS;AAClB,6BAAS,SAAS;AAAA,kBACpB;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AACA,kBAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF;AACA,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAAA,EACF;AACF;AAEA,SAAS,aAAgB,OAAU,QAA8B;AAC/D,SAAO,OAAO,WAAW,aAAc,OAAuB,KAAK,IAAI;AACzE;AAEA,IAAI,YAAY;AAEhB,SAAS,kBAAkB,OAAgC;AACzD,MAAI,IAAkB;AACtB,SAAO,GAAG;AACR,QAAI,EAAE,KAAM,QAAO,EAAE;AACrB,QAAI,EAAE;AAAA,EACR;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { Hook, Fiber, FiberRoot, Effect } from '../core'\nimport { ReactSharedInternals, REACT_CONTEXT_TYPE } from '../react'\nimport { scheduleUpdate, enqueueEffect, readContext } from './reconcile'\n\nfunction getCurrentFiber(): Fiber {\n const f = ReactSharedInternals.currentFiber\n if (!f) throw new Error('Hook called outside a function component render.')\n return f\n}\n\nfunction nextHook(): Hook {\n const fiber = getCurrentFiber()\n const idx = ReactSharedInternals.hookIndex++\n\n let prev = ReactSharedInternals.currentHook\n\n if (idx === 0) {\n if (fiber.hooks) {\n ReactSharedInternals.currentHook = fiber.hooks\n return fiber.hooks\n }\n const h: Hook = { state: undefined, queue: undefined, deps: undefined, cleanup: undefined, next: null }\n fiber.hooks = h\n ReactSharedInternals.currentHook = h\n return h\n }\n\n if (prev && prev.next) {\n ReactSharedInternals.currentHook = prev.next\n return prev.next\n }\n\n const h: Hook = { state: undefined, queue: undefined, deps: undefined, cleanup: undefined, next: null }\n if (prev) prev.next = h\n else fiber.hooks = h\n ReactSharedInternals.currentHook = h\n return h\n}\n\nfunction depsEqual(\n a: ReadonlyArray<unknown> | undefined,\n b: ReadonlyArray<unknown> | undefined,\n): boolean {\n if (a === b) return true\n if (!a || !b) return false\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!Object.is(a[i], b[i])) return false\n }\n return true\n}\n\n// Singleton \u2014 every method reads render context via ReactSharedInternals,\n// and per-hook closures live on the hook itself, so nothing is render-local\n// to capture. Allocating a fresh wrapper + 17 method closures per function-\n// component render was pure GC pressure.\nconst DISPATCHER = makeDispatcherImpl()\n\nexport function makeDispatcher() {\n return DISPATCHER\n}\n\nfunction makeDispatcherImpl() {\n return {\n useState<S>(initial: S | (() => S)) {\n return this.useReducer<S, S | ((p: S) => S)>(\n basicReducer as any,\n typeof initial === 'function' ? (initial as () => S)() : initial,\n )\n },\n\n useReducer<S, A>(reducer: (s: S, a: A) => S, initialArg: any, init?: (a: any) => S) {\n const hook = nextHook()\n const fiber = getCurrentFiber()\n if (hook.queue === undefined) {\n hook.state = init ? init(initialArg) : initialArg\n const queue: any = { reducer }\n const dispatch = (action: A) => {\n const currentState = hook.state as S\n const next = queue.reducer(currentState, action)\n if (!Object.is(next, currentState)) {\n hook.state = next\n scheduleUpdate(fiber)\n }\n }\n queue.dispatch = dispatch\n hook.queue = queue\n } else {\n hook.queue.reducer = reducer\n }\n return [hook.state, hook.queue.dispatch] as [S, (a: A) => void]\n },\n\n useEffect(create: () => any, deps?: ReadonlyArray<unknown>) {\n const hook = nextHook()\n const fiber = getCurrentFiber()\n const prevDeps = hook.deps\n if (prevDeps !== undefined && depsEqual(prevDeps, deps)) return\n hook.deps = deps\n const effect: Effect = {\n tag: 'effect',\n create: () => {\n // Run the prior cleanup INSIDE the effect run, not during the\n // dispatch/render phase. If render A \u2192 B \u2192 C all happen back-to-\n // back before the passive microtask drains, dispatch-time cleanup\n // only fires once (between A\u2192B) and effects B + C both run fresh,\n // leaving two side-effects (e.g. two plot SVGs) in the DOM. Doing\n // it here, at effect-run time, means every new create first tears\n // down whatever cleanup is currently live on the hook.\n if (hook.cleanup) {\n try { hook.cleanup() } catch {}\n // The prior cleanup was also pushed onto fiber.cleanups; remove\n // it so unmount doesn't double-call it.\n if (fiber.cleanups) {\n const i = fiber.cleanups.indexOf(hook.cleanup)\n if (i >= 0) fiber.cleanups.splice(i, 1)\n }\n hook.cleanup = null\n }\n const c = create()\n hook.cleanup = typeof c === 'function' ? c : null\n return hook.cleanup\n },\n destroy: undefined,\n deps,\n }\n enqueueEffect(fiber, effect)\n },\n\n useLayoutEffect(create: () => any, deps?: ReadonlyArray<unknown>) {\n const hook = nextHook()\n const fiber = getCurrentFiber()\n const prevDeps = hook.deps\n if (prevDeps !== undefined && depsEqual(prevDeps, deps)) return\n hook.deps = deps\n const effect: Effect = {\n tag: 'layout',\n create: () => {\n // Mirror useEffect: tear down the prior cleanup at run time so\n // coalesced renders don't leak side-effects.\n if (hook.cleanup) {\n try { hook.cleanup() } catch {}\n if (fiber.cleanups) {\n const i = fiber.cleanups.indexOf(hook.cleanup)\n if (i >= 0) fiber.cleanups.splice(i, 1)\n }\n hook.cleanup = null\n }\n const c = create()\n hook.cleanup = typeof c === 'function' ? c : null\n return hook.cleanup\n },\n destroy: undefined,\n deps,\n }\n enqueueEffect(fiber, effect)\n },\n\n useInsertionEffect(create: () => any, deps?: ReadonlyArray<unknown>) {\n return this.useLayoutEffect(create, deps)\n },\n\n useRef<T>(initial: T) {\n const hook = nextHook()\n if (hook.state === undefined) hook.state = { current: initial }\n return hook.state as { current: T }\n },\n\n useMemo<T>(factory: () => T, deps?: ReadonlyArray<unknown>) {\n const hook = nextHook()\n if (hook.deps !== undefined && depsEqual(hook.deps, deps)) {\n return hook.state as T\n }\n const value = factory()\n hook.state = value\n hook.deps = deps\n return value\n },\n\n useCallback<T extends Function>(fn: T, deps?: ReadonlyArray<unknown>): T {\n return this.useMemo(() => fn, deps) as T\n },\n\n useContext<T>(ctx: any): T {\n const fiber = getCurrentFiber()\n return readContext(fiber, ctx)\n },\n\n useImperativeHandle<T>(ref: any, factory: () => T, deps?: ReadonlyArray<unknown>) {\n const hook = nextHook()\n if (hook.deps !== undefined && depsEqual(hook.deps, deps)) return\n hook.deps = deps\n const value = factory()\n if (ref) {\n if (typeof ref === 'function') ref(value)\n else ref.current = value\n }\n },\n\n useDebugValue<T>(_value: T, _formatter?: (v: T) => any): void {\n // noop\n },\n\n useId(): string {\n const hook = nextHook()\n if (hook.state === undefined) {\n const fiber = getCurrentFiber()\n const root = findRootFromFiber(fiber)\n hook.state = (root?.identifierPrefix ?? ':r') + (idCounter++).toString(36)\n }\n return hook.state as string\n },\n\n useTransition(): [boolean, (fn: () => void) => void] {\n return [false, (fn: () => void) => fn()]\n },\n\n useDeferredValue<T>(v: T): T {\n return v\n },\n\n useSyncExternalStore<T>(\n subscribe: (cb: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n ): T {\n const fiber = getCurrentFiber()\n const hook = nextHook()\n\n // During hydration, use the server snapshot (if provided) so the tree\n // matches the SSR output. Components like TanStack Router's ClientOnly\n // rely on this: they render `false` on server, `true` on client \u2014 and\n // if we return `true` during hydration, client and server diverge and\n // the tree mounts fresh next to the SSR fallback DOM.\n const root = fiber.root ?? findRootFromFiber(fiber)\n const isHydrating = Boolean(root?.hydrating)\n const value =\n isHydrating && getServerSnapshot ? getServerSnapshot() : getSnapshot()\n hook.state = value\n\n if (hook.cleanup == null) {\n const forceUpdate = () => {\n let next: T\n try {\n next = getSnapshot()\n } catch {\n scheduleUpdate(fiber)\n return\n }\n if (!Object.is(hook.state, next)) {\n hook.state = next\n scheduleUpdate(fiber)\n }\n }\n const unsubscribe = subscribe(forceUpdate)\n hook.cleanup = unsubscribe\n // Register with fiber so unmountFiber runs it. Without this, the store\n // keeps holding forceUpdate and every store update schedules an already-\n // unmounted fiber \u2014 its rerender walks stale .parent pointers and mounts\n // zombie DOM into the old parent.\n if (typeof unsubscribe === 'function') {\n fiber.cleanups ||= []\n fiber.cleanups.push(unsubscribe)\n }\n\n // If we served the server snapshot, run a post-hydration check so\n // components like `useHydrated()` flip from false \u2192 true after the\n // initial render commits. Queued late so hydration finishes first.\n if (isHydrating && getServerSnapshot) {\n queueMicrotask(() => queueMicrotask(forceUpdate))\n }\n }\n return value\n },\n\n use<T>(resource: any): T {\n if (resource == null) throw new Error('use() received null or undefined')\n if (resource.$$typeof === REACT_CONTEXT_TYPE) {\n return readContext(getCurrentFiber(), resource)\n }\n if (typeof resource.then === 'function') {\n const thenable = resource\n switch (thenable.status) {\n case 'fulfilled':\n return thenable.value\n case 'rejected':\n throw thenable.reason\n default: {\n if (thenable.status === undefined) {\n thenable.status = 'pending'\n thenable.then(\n (v: any) => {\n if (thenable.status === 'pending') {\n thenable.status = 'fulfilled'\n thenable.value = v\n }\n },\n (e: any) => {\n if (thenable.status === 'pending') {\n thenable.status = 'rejected'\n thenable.reason = e\n }\n },\n )\n }\n throw thenable\n }\n }\n }\n throw new Error('use() expected a Promise or Context')\n },\n }\n}\n\nfunction basicReducer<S>(state: S, action: S | ((p: S) => S)): S {\n return typeof action === 'function' ? (action as (p: S) => S)(state) : action\n}\n\nlet idCounter = 0\n\nfunction findRootFromFiber(fiber: Fiber): FiberRoot | null {\n let f: Fiber | null = fiber\n while (f) {\n if (f.root) return f.root\n f = f.parent\n }\n return null\n}\n"],
5
+ "mappings": ";AACA,SAAS,sBAAsB,0BAA0B;AACzD,SAAS,gBAAgB,eAAe,mBAAmB;AAE3D,SAAS,kBAAyB;AAChC,QAAM,IAAI,qBAAqB;AAC/B,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,kDAAkD;AAC1E,SAAO;AACT;AAEA,SAAS,WAAiB;AACxB,QAAM,QAAQ,gBAAgB;AAC9B,QAAM,MAAM,qBAAqB;AAEjC,MAAI,OAAO,qBAAqB;AAEhC,MAAI,QAAQ,GAAG;AACb,QAAI,MAAM,OAAO;AACf,2BAAqB,cAAc,MAAM;AACzC,aAAO,MAAM;AAAA,IACf;AACA,UAAMA,KAAU,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IAEA,IAAO,UAAkB;AACvB,UAAI,YAAY,KAAM,OAAM,IAAI,MAAM,kCAAkC;AACxE,UAAI,SAAS,aAAa,oBAAoB;AAC5C,eAAO,YAAY,gBAAgB,GAAG,QAAQ;AAAA,MAChD;AACA,UAAI,OAAO,SAAS,SAAS,YAAY;AACvC,cAAM,WAAW;AACjB,gBAAQ,SAAS,QAAQ;AAAA,UACvB,KAAK;AACH,mBAAO,SAAS;AAAA,UAClB,KAAK;AACH,kBAAM,SAAS;AAAA,UACjB,SAAS;AACP,gBAAI,SAAS,WAAW,QAAW;AACjC,uBAAS,SAAS;AAClB,uBAAS;AAAA,gBACP,CAAC,MAAW;AACV,sBAAI,SAAS,WAAW,WAAW;AACjC,6BAAS,SAAS;AAClB,6BAAS,QAAQ;AAAA,kBACnB;AAAA,gBACF;AAAA,gBACA,CAAC,MAAW;AACV,sBAAI,SAAS,WAAW,WAAW;AACjC,6BAAS,SAAS;AAClB,6BAAS,SAAS;AAAA,kBACpB;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AACA,kBAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF;AACA,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAAA,EACF;AACF;AAEA,SAAS,aAAgB,OAAU,QAA8B;AAC/D,SAAO,OAAO,WAAW,aAAc,OAAuB,KAAK,IAAI;AACzE;AAEA,IAAI,YAAY;AAEhB,SAAS,kBAAkB,OAAgC;AACzD,MAAI,IAAkB;AACtB,SAAO,GAAG;AACR,QAAI,EAAE,KAAM,QAAO,EAAE;AACrB,QAAI,EAAE;AAAA,EACR;AACA,SAAO;AACT;",
6
6
  "names": ["h"]
7
7
  }
@@ -4,10 +4,7 @@ export declare function flushSyncWork(fn: () => void): void;
4
4
  export declare function batchedUpdates<T>(fn: () => T): T;
5
5
  export declare function findRoot(fiber: Fiber): FiberRoot | null;
6
6
  export declare function renderRoot(root: FiberRoot, children: ReactNode): void;
7
- type TextChild = {
8
- _text: string;
9
- };
10
- type NormalizedChild = ReactElement | TextChild | null;
7
+ type NormalizedChild = ReactElement | string | null;
11
8
  export declare function childrenToArray(children: ReactNode): NormalizedChild[];
12
9
  /**
13
10
  * Reconcile a parent fiber's child list against new normalized children.
@@ -141,7 +141,7 @@ function rerenderFiber(fiber, root) {
141
141
  }
142
142
  }
143
143
  function isTextChild(child) {
144
- return child.$$typeof === void 0;
144
+ return typeof child === "string";
145
145
  }
146
146
  function childrenToArray(children) {
147
147
  const out = [];
@@ -150,9 +150,13 @@ function childrenToArray(children) {
150
150
  }
151
151
  function pushChildren(node, out) {
152
152
  if (node == null || typeof node === "boolean") return;
153
- if (typeof node === "string" || typeof node === "number") {
153
+ if (typeof node === "string") {
154
154
  if (node === "") return;
155
- out.push({ _text: "" + node });
155
+ out.push(node);
156
+ return;
157
+ }
158
+ if (typeof node === "number") {
159
+ out.push("" + node);
156
160
  return;
157
161
  }
158
162
  if (Array.isArray(node)) {
@@ -192,7 +196,7 @@ function fiberFromChild(child, parent) {
192
196
  if (!child) return createFiber(FiberTag.Fragment, null, null);
193
197
  if (isTextChild(child)) {
194
198
  const f2 = createFiber(FiberTag.Text, null, null);
195
- f2.pendingProps = child._text;
199
+ f2.pendingProps = child;
196
200
  f2.parent = parent;
197
201
  return f2;
198
202
  }
@@ -220,6 +224,50 @@ function fiberFromChild(child, parent) {
220
224
  return f;
221
225
  }
222
226
  function reconcileChildren(parent, newChildren, domParent, anchor) {
227
+ if (!currentRoot?.hydrating) {
228
+ let f = parent.child;
229
+ let ok = true;
230
+ for (let i = 0; i < newChildren.length; i++) {
231
+ const child = newChildren[i];
232
+ if (child == null || !f || f.key != null) {
233
+ ok = false;
234
+ break;
235
+ }
236
+ if (typeof child === "string") {
237
+ if (f.tag !== FiberTag.Text) {
238
+ ok = false;
239
+ break;
240
+ }
241
+ f.pendingProps = child;
242
+ } else {
243
+ if (child.key != null) {
244
+ ok = false;
245
+ break;
246
+ }
247
+ if (f.type !== child.type) {
248
+ ok = false;
249
+ break;
250
+ }
251
+ f.pendingProps = child.props;
252
+ f.ref = child.ref ?? null;
253
+ }
254
+ f = f.sibling;
255
+ }
256
+ if (ok && f === null) {
257
+ for (let r = parent.child; r; r = r.sibling) {
258
+ let a = anchor;
259
+ for (let s = r.sibling; s; s = s.sibling) {
260
+ const d = firstDomNode(s);
261
+ if (d && d.parentNode === domParent) {
262
+ a = d;
263
+ break;
264
+ }
265
+ }
266
+ renderFiber(r, domParent, a);
267
+ }
268
+ return;
269
+ }
270
+ }
223
271
  const existing = collectChildren(parent);
224
272
  const keyed = /* @__PURE__ */ new Map();
225
273
  for (const f of existing) {
@@ -271,7 +319,7 @@ function reconcileChildren(parent, newChildren, domParent, anchor) {
271
319
  claimed.add(match);
272
320
  fiber = match;
273
321
  if (isTextChild(child)) {
274
- fiber.pendingProps = child._text;
322
+ fiber.pendingProps = child;
275
323
  } else {
276
324
  fiber.type = child.type;
277
325
  fiber.pendingProps = child.props;
@@ -419,13 +467,14 @@ function renderFiber(fiber, domParent, anchor) {
419
467
  }
420
468
  function renderText(fiber, domParent, anchor) {
421
469
  const text = fiber.pendingProps;
470
+ if (fiber.dom && fiber.memoizedProps === text) return;
422
471
  if (!fiber.dom) {
423
472
  const hydrated = currentRoot?.hydrating ? adoptTextDom(fiber, fiber.parent, text) : false;
424
473
  if (!hydrated) {
425
474
  fiber.dom = document.createTextNode(text);
426
475
  insertInto(domParent, fiber.dom, anchor);
427
476
  }
428
- } else if (fiber.dom.data !== text) {
477
+ } else {
429
478
  ;
430
479
  fiber.dom.data = text;
431
480
  }
@@ -454,21 +503,30 @@ function renderHost(fiber, domParent, anchor) {
454
503
  insertInto(domParent, fiber.dom, anchor);
455
504
  }
456
505
  attachRef(fiber, fiber.dom);
457
- } else {
506
+ } else if (prev !== props) {
458
507
  const el = fiber.dom;
459
- for (const k in prev) {
460
- if (!(k in props)) setProp(el, k, void 0, prev[k], isSvg);
461
- }
508
+ let deferredEvents = null;
462
509
  for (const k in props) {
463
510
  if (isSelect && (k === "value" || k === "defaultValue")) continue;
464
- if (isEventProp(k)) continue;
511
+ if (isEventProp(k)) {
512
+ if (prev[k] !== props[k]) {
513
+ deferredEvents ||= [];
514
+ deferredEvents.push(k);
515
+ }
516
+ continue;
517
+ }
465
518
  if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg);
466
519
  }
467
- for (const k in props) {
468
- if (!isEventProp(k)) continue;
469
- if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg);
520
+ for (const k in prev) {
521
+ if (!(k in props)) setProp(el, k, void 0, prev[k], isSvg);
522
+ }
523
+ if (deferredEvents) {
524
+ for (let i = 0; i < deferredEvents.length; i++) {
525
+ const k = deferredEvents[i];
526
+ setProp(el, k, props[k], prev[k], isSvg);
527
+ }
470
528
  }
471
- if (prev !== props) syncRefIfChanged(fiber, fiber.dom);
529
+ syncRefIfChanged(fiber, fiber.dom);
472
530
  }
473
531
  reconcileChildren(fiber, childrenToArray(props.children), fiber.dom, null);
474
532
  if (currentRoot?.hydrating) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/reconcile.ts"],
4
- "sourcesContent": ["import {\n FiberTag,\n FiberFlag,\n createFiber,\n REACT_ELEMENT_TYPE,\n REACT_LEGACY_ELEMENT_TYPE,\n REACT_FRAGMENT_TYPE,\n type Fiber,\n type FiberRoot,\n type ReactElement,\n type ReactNode,\n type Hook,\n type Effect,\n} from '../core'\nimport {\n ReactSharedInternals,\n REACT_LAZY_TYPE,\n REACT_STRICT_MODE_TYPE,\n REACT_PROFILER_TYPE,\n} from '../react'\nimport { createHostNode, setProp } from './dom'\nimport { makeDispatcher } from './dispatcher'\nimport {\n adoptHostDom,\n adoptTextDom,\n tryConsumeBoundary,\n advanceCursorPast,\n setHydrationCursor,\n getHydrationCursor,\n clearHydrationCursor,\n HydrationCursor,\n findHostParent as findHydrationHost,\n} from './features/hydration'\n\n// ---------------------------------------------------------------------------\n// Render scheduling\n// ---------------------------------------------------------------------------\n\nlet currentRoot: FiberRoot | null = null\nlet flushing = false\nlet isBatching = false\nconst pendingRoots = new Set<FiberRoot>()\n\n// Set by rerenderFiber to identify the exact memo-tagged fiber whose INTERNAL\n// state (hook update, useSyncExternalStore notification) triggered this render\n// pass. renderMemo checks this to bypass its prop-equality gate for that fiber.\n// Without the bypass, a memo bail would swallow state changes: React's memo is\n// only a parent-triggered gate \u2014 state-driven rerenders must always run the\n// inner function. Router-adjacent components (Outlet, Match, MatchInner) are\n// all memo-wrapped and subscribe to stores; missing this bypass breaks nav\n// content updates even though the URL changes.\nlet forceRerenderingFiber: Fiber | null = null\n\nexport function scheduleUpdate(fiber: Fiber): void {\n // Drop updates scheduled on already-unmounted fibers. Subscribers (router,\n // query, any external store) can fire after unmount if their cleanup was\n // missed, and letting those reach rerenderFiber mounts zombie DOM into the\n // old .parent's DOM (which stays reachable via the stale pointer).\n if (fiber.unmounted) return\n const root = findRoot(fiber)\n if (!root) return\n root.pending.add(fiber)\n fiber.dirty = true\n pendingRoots.add(root)\n if (isBatching) return\n if (!root.scheduled) {\n root.scheduled = true\n queueMicrotask(flushPending)\n }\n}\n\nexport function flushSyncWork(fn: () => void): void {\n const wasBatching = isBatching\n isBatching = true\n try {\n fn()\n } finally {\n isBatching = wasBatching\n }\n flushPending()\n}\n\nexport function batchedUpdates<T>(fn: () => T): T {\n const wasBatching = isBatching\n isBatching = true\n try {\n return fn()\n } finally {\n isBatching = wasBatching\n if (!wasBatching) flushPending()\n }\n}\n\nfunction flushPending(): void {\n if (flushing) return\n flushing = true\n try {\n let guard = 0\n while (pendingRoots.size > 0) {\n if (++guard > 50) {\n throw new Error('flushPending exceeded 50 iterations \u2014 suspected infinite update loop.')\n }\n const roots = [...pendingRoots]\n pendingRoots.clear()\n for (const root of roots) {\n root.scheduled = false\n // Render each pending fiber from shallowest first so an ancestor's\n // cascade reaches descendants before we try to render them directly.\n // Descendants rendered via cascade still have `dirty=true` (only\n // rerenderFiber clears it); when we later reach them in this loop,\n // rerenderFiber's own `if (!dirty) return` is our short-circuit. We\n // previously filtered descendants of dirty ancestors here, but that\n // loses updates whenever an ancestor's render doesn't actually reach\n // the descendant \u2014 e.g. React.memo bailing on equal props. Keep all\n // dirty fibers and let rerenderFiber de-dupe via its dirty check.\n const pending = [...root.pending]\n root.pending.clear()\n pending.sort((a, b) => fiberDepth(a) - fiberDepth(b))\n for (const fiber of pending) {\n rerenderFiber(fiber, root)\n }\n runEffects(root)\n }\n }\n } finally {\n flushing = false\n }\n}\n\nfunction fiberDepth(fiber: Fiber): number {\n let d = 0\n let p: Fiber | null = fiber.parent\n while (p) {\n d++\n p = p.parent\n }\n return d\n}\n\nexport function findRoot(fiber: Fiber): FiberRoot | null {\n let f: Fiber | null = fiber\n while (f) {\n if (f.root) return f.root\n f = f.parent\n }\n return null\n}\n\n// ---------------------------------------------------------------------------\n// Entry points (called by createRoot)\n// ---------------------------------------------------------------------------\n\nexport function renderRoot(root: FiberRoot, children: ReactNode): void {\n const rootFiber = root.current\n rootFiber.pendingProps = { children }\n currentRoot = root\n try {\n reconcileChildren(rootFiber, childrenToArray(children), root.container as Node, null)\n rootFiber.memoizedProps = rootFiber.pendingProps\n rootFiber.dirty = false\n } finally {\n currentRoot = null\n }\n runEffects(root)\n}\n\nfunction rerenderFiber(fiber: Fiber, root: FiberRoot): void {\n if (!fiber.dirty) return\n // Skip fibers that were unmounted between scheduling and flush. Without this,\n // the flush loop re-enters a zombie fiber whose .parent is still set; its\n // render mounts fresh DOM into the old parent's still-attached DOM (since\n // unmountFiber only clears fiber.child, not fiber.parent). Visible as route\n // content from a previous location staying on screen after nav, because a\n // pending rerender on the old route's LibraryLandingPage (unmounted during\n // Outlet's shallow-first render) still fires from root.pending.\n if (fiber.unmounted) return\n // Clear BEFORE rendering so a scheduleUpdate() triggered mid-render (e.g.\n // error boundary catching a descendant throw) marks us dirty for the next\n // flush iteration instead of being wiped out when render() completes.\n fiber.dirty = false\n currentRoot = root\n // If this rerender is resuming a hydration that was deferred by a suspension,\n // re-activate hydration mode for its duration so descendants adopt DOM\n // instead of re-creating it.\n const resumeHydration =\n fiber.memoizedState && (fiber.memoizedState as any)._pendingHydration === true\n const prevHydrating = root.hydrating\n if (resumeHydration) {\n delete (fiber.memoizedState as any)._pendingHydration\n root.hydrating = true\n }\n const prevForcing = forceRerenderingFiber\n forceRerenderingFiber = fiber\n try {\n renderFiber(fiber, getHostParent(fiber), getAnchor(fiber))\n } finally {\n forceRerenderingFiber = prevForcing\n if (resumeHydration) {\n root.hydrating = prevHydrating\n // Deferred hydration completed \u2014 detach the preserved cursor so future\n // updates (post-hydration state changes) don't try to adopt stale DOM.\n clearHydrationCursor(fiber)\n }\n currentRoot = null\n }\n}\n\n// ---------------------------------------------------------------------------\n// Element \u2192 children normalization\n// ---------------------------------------------------------------------------\n\ntype TextChild = { _text: string }\ntype NormalizedChild = ReactElement | TextChild | null\n\n// NEVER use `'_text' in child` to distinguish text wrappers from elements.\n// TanStack's RSC renderable proxies (createRscProxy with renderable: true) are\n// Proxy wrappers around real React elements whose `has` trap returns `true`\n// for ANY string key \u2014 so `'_text' in rscProxy` is TRUE even though the proxy\n// is an element. That misidentification set a Text fiber's `pendingProps` to\n// `child._text` (another chained RSC proxy), which then rendered as\n// `[object Object]` when createTextNode stringified the element. React\n// elements always carry `$$typeof`; our text wrapper never does \u2014 so the\n// presence of `$$typeof` is the invariant we rely on.\nfunction isTextChild(child: Exclude<NormalizedChild, null>): child is TextChild {\n return (child as any).$$typeof === undefined\n}\n\nexport function childrenToArray(children: ReactNode): NormalizedChild[] {\n const out: NormalizedChild[] = []\n pushChildren(children, out)\n return out\n}\n\nfunction pushChildren(node: ReactNode, out: NormalizedChild[]): void {\n if (node == null || typeof node === 'boolean') return\n if (typeof node === 'string' || typeof node === 'number') {\n // Empty strings render no text node (matches React + the `<!-- -->`\n // separator elision on the SSR side so server/client agree).\n if (node === '') return\n out.push({ _text: '' + node })\n return\n }\n if (Array.isArray(node)) {\n for (let i = 0; i < node.length; i++) pushChildren(node[i], out)\n return\n }\n if (isIterable(node)) {\n for (const item of node as Iterable<ReactNode>) pushChildren(item, out)\n return\n }\n if (typeof node === 'object') {\n const t = (node as any).$$typeof\n if (ACCEPTED_ELEMENT_MARKERS.has(t)) {\n out.push(node as ReactElement)\n return\n }\n // Raw React.lazy as a child. RSC Flight encodes 'use client' components\n // (CodeBlock, CodeExplorer, etc.) as bare Lazy objects in the tree, not\n // wrapped in REACT_ELEMENT_TYPE. Dropping them made code snippets\n // disappear from docs pages. The RSC decoder pre-awaits payloads via\n // `awaitLazyElements`, so by render time the status is 'fulfilled' and\n // `_init()` returns the resolved element synchronously.\n if (t === REACT_LAZY_TYPE) {\n const lazy = node as any\n const resolved = lazy._init(lazy._payload)\n pushChildren(resolved, out)\n return\n }\n }\n}\n\nfunction isIterable(obj: any): boolean {\n return obj != null && typeof obj !== 'string' && typeof obj[Symbol.iterator] === 'function'\n}\n\nfunction getKeyOf(child: NormalizedChild, index: number): string {\n if (!child) return 'n' + index\n if (isTextChild(child)) return '$t' + index\n if (child.key != null) return 'k' + child.key\n return 'i' + index\n}\n\nfunction sameType(fiber: Fiber, child: NormalizedChild): boolean {\n if (!child) return false\n if (isTextChild(child)) return fiber.tag === FiberTag.Text\n return fiber.type === child.type && sameKey(fiber.key, child.key)\n}\n\nfunction sameKey(a: string | null, b: string | null | undefined): boolean {\n return (a ?? null) === (b ?? null)\n}\n\n// ---------------------------------------------------------------------------\n// Fiber creation\n// ---------------------------------------------------------------------------\n\nfunction fiberFromChild(child: NormalizedChild, parent: Fiber): Fiber {\n if (!child) return createFiber(FiberTag.Fragment, null, null)\n if (isTextChild(child)) {\n const f = createFiber(FiberTag.Text, null, null)\n f.pendingProps = child._text\n f.parent = parent\n return f\n }\n const type = child.type\n let tag: FiberTag = FiberTag.Host\n const marker = type && (type as any).$$typeof\n if (typeof type === 'string') tag = FiberTag.Host\n else if (type === REACT_FRAGMENT_TYPE) tag = FiberTag.Fragment\n else if (type === REACT_STRICT_MODE_TYPE || type === REACT_PROFILER_TYPE) tag = FiberTag.Fragment\n else {\n // Feature-registered type matchers (Portal, future extractions). Features\n // that carry the symbol as element.type directly (rather than wrapping in\n // REACT_ELEMENT_TYPE) match here by type identity.\n let matched: FiberTag | null = null\n for (const m of TYPE_MATCHERS) {\n matched = m(type, marker)\n if (matched !== null) break\n }\n if (matched !== null) tag = matched\n else if (typeof type === 'function') {\n tag = type.prototype && type.prototype.isReactComponent ? FiberTag.Class : FiberTag.Function\n }\n }\n const f = createFiber(tag, type, child.key ?? null)\n f.ref = (child as any).ref ?? null\n f.pendingProps = child.props\n f.parent = parent\n return f\n}\n\n// ---------------------------------------------------------------------------\n// Reconciliation\n// ---------------------------------------------------------------------------\n\n/**\n * Reconcile a parent fiber's child list against new normalized children.\n * Mutates parent.child and the sibling chain.\n * Mounts new host DOM into `domParent` before `anchor` (or appends if anchor === null).\n */\nexport function reconcileChildren(\n parent: Fiber,\n newChildren: NormalizedChild[],\n domParent: Node,\n anchor: Node | null,\n): void {\n const existing = collectChildren(parent)\n const keyed = new Map<string, Fiber>()\n for (const f of existing) {\n if (f.key != null) keyed.set('k' + f.key, f)\n }\n\n let prevNewFiber: Fiber | null = null\n const claimed = new Set<Fiber>()\n let structurallyChanged = false\n // Budget-guided positional matching. We walk `existing` (unkeyed only) with a\n // single cursor `existingIdx` and, on a type mismatch, choose insert vs delete\n // based on the remaining length delta (`budget`):\n // budget > 0: more new than old remain \u2192 treat slot as an INSERTION: keep\n // the old cursor and create a fresh fiber for new[i].\n // budget < 0: more old than new remain \u2192 treat slot as a DELETION: advance\n // the old cursor past the mismatched fiber (it'll be unmounted\n // in the unclaimed pass) and retry.\n // budget == 0: equal remaining \u2192 treat as REPLACE by preferring delete\n // until budget flips positive or we hit a match.\n // This avoids greedy forward scans that steal a later same-type fiber for a\n // newly inserted leading sibling (e.g. smallMenu flipping null \u2192 <div>\n // stealing the content <div>'s fiber and tearing down the drawer fragment).\n let existingIdx = 0\n let unkeyedOld = 0\n for (const f of existing) if (f.key == null) unkeyedOld++\n let unkeyedNew = 0\n for (const c of newChildren) if (c != null) unkeyedNew++\n let budget = unkeyedNew - unkeyedOld\n\n // Pass 1 (this loop): match against existing fibers and build the sibling\n // chain. Pass 2 (after the loop) renders each fiber with the correct\n // per-child anchor \u2014 the firstDomNode of its next still-mounted sibling,\n // or the parent's own anchor for the rightmost. Without per-child anchors\n // a child whose render output type changes from no-DOM (Portal, null) to\n // an in-flow host gets appended to the end of domParent (every child\n // would otherwise share the parent's anchor) and never moves before its\n // later siblings. Hit by the t3code Sidebar swap from a portal-rendering\n // <Sheet> to a <div data-slot=sidebar> when isMobile flips during a\n // Provider re-render.\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i]\n if (child == null) continue\n\n let match: Fiber | null = null\n\n // key-based match\n if (child && typeof child === 'object' && !isTextChild(child) && (child as ReactElement).key != null) {\n const k = 'k' + (child as ReactElement).key\n const m = keyed.get(k)\n if (m && m.type === (child as ReactElement).type) {\n match = m\n keyed.delete(k)\n }\n }\n\n if (!match) {\n while (existingIdx < existing.length) {\n const cand = existing[existingIdx]!\n if (claimed.has(cand) || cand.key != null) {\n existingIdx++\n continue\n }\n if (sameType(cand, child)) {\n match = cand\n existingIdx++\n break\n }\n // Type mismatch at the cursor. Resolve via budget.\n if (budget > 0) {\n // Insertion: leave cand in place, create new for child.\n break\n }\n // Deletion (or replace-as-delete-first): advance past cand. It remains\n // unclaimed and will be unmounted at the end.\n existingIdx++\n budget++\n }\n }\n\n // Detect reorder: matched fiber is not at its original position\n if (match && existing[i] !== match) structurallyChanged = true\n\n let fiber: Fiber\n if (match) {\n claimed.add(match)\n fiber = match\n if (isTextChild(child!)) {\n fiber.pendingProps = child._text\n } else {\n fiber.type = (child as ReactElement).type\n fiber.pendingProps = (child as ReactElement).props\n fiber.ref = (child as any).ref ?? null\n }\n } else {\n fiber = fiberFromChild(child, parent)\n structurallyChanged = true\n if (budget > 0) budget--\n }\n\n fiber.parent = parent\n fiber.sibling = null\n if (prevNewFiber) prevNewFiber.sibling = fiber\n else parent.child = fiber\n prevNewFiber = fiber\n }\n\n // Pass 2: walk the sibling chain we just built and render each fiber\n // forward with the correct per-child anchor. During hydration the cursor\n // walks DOM forward and each renderFiber adopts the next existing node,\n // so per-child anchors are moot \u2014 fall back to the parent's anchor.\n const hydrating = !!currentRoot?.hydrating\n for (let f: Fiber | null = parent.child; f; f = f.sibling) {\n let a = anchor\n if (!hydrating) {\n // Find the firstDomNode of the next still-mounted sibling, if any.\n for (let s: Fiber | null = f.sibling; s; s = s.sibling) {\n const d = firstDomNode(s)\n if (d && d.parentNode === domParent) { a = d; break }\n }\n }\n renderFiber(f, domParent, a)\n }\n\n if (!prevNewFiber) parent.child = null\n else prevNewFiber.sibling = null\n\n // Head content is additive \u2014 server may inject metadata/stylesheets (Vite\n // dev styles, Sentry, analytics) that aren't in the React tree. Unmounting\n // them on every reconcile thrashes styles and causes flash of unstyled\n // content. Keep existing head children that weren't matched this pass.\n const parentIsHeadHost =\n parent.tag === FiberTag.Host &&\n typeof parent.type === 'string' &&\n (parent.type as string).toLowerCase() === 'head'\n\n if (!parentIsHeadHost) {\n // Unmount unclaimed\n for (const f of existing) {\n if (!claimed.has(f)) {\n unmountFiber(f, domParent)\n structurallyChanged = true\n }\n }\n // Leftover keyed\n for (const f of keyed.values()) {\n if (!claimed.has(f)) {\n unmountFiber(f, domParent)\n structurallyChanged = true\n }\n }\n }\n\n // During hydration, DOM is already in document order from the cursor-driven\n // adoption walk. Running placeChildrenInOrder here would reappend nodes to\n // the end of domParent when the true anchor (often an end marker comment)\n // isn't reflected in `anchor`. Skip it in hydration mode.\n //\n // For <head>, skip always \u2014 HeadContent re-renders routinely (route match\n // changes, providers updating), and reordering every <link>/<style>/<meta>\n // on each re-render causes stylesheet flash and re-download. Head element\n // ordering is semantically fluid; the browser doesn't care about exact\n // order within <head>.\n const parentIsHead =\n (domParent as Element).nodeType === 1 &&\n (domParent as Element).tagName.toLowerCase() === 'head'\n if (structurallyChanged && !currentRoot?.hydrating && !parentIsHead) {\n placeChildrenInOrder(parent, domParent, anchor)\n }\n}\n\nfunction placeChildrenInOrder(parent: Fiber, domParent: Node, anchor: Node | null): void {\n const doms: Node[] = []\n let c = parent.child\n while (c) {\n collectHostDoms(c, doms)\n c = c.sibling\n }\n\n // Pre-check: if our fiber-owned DOM is already in document order within\n // domParent AND the trailing anchor matches, no reorder is needed. This is\n // the common case on stable re-renders, and avoids detaching/re-attaching\n // subtrees (which cancels CSS animations and triggers layout).\n if (doms.length > 0) {\n let current: Node | null = doms[0]!\n let inOrder = current.parentNode === domParent\n for (let i = 1; inOrder && i < doms.length; i++) {\n current = current!.nextSibling\n // Skip foreign nodes (SSR-injected scripts, dev-styles) between owned\n // fiber DOMs \u2014 they should stay where they are.\n while (current && !doms.includes(current as Node)) {\n current = current.nextSibling\n }\n if (current !== doms[i]) inOrder = false\n }\n // Also verify the LAST dom's next sibling lines up with `anchor`. A\n // single-dom collection (or correctly-internally-ordered doms) can sit\n // at the WRONG absolute position in domParent and still pass the\n // relative-order check above. This happens when a fiber's render output\n // changes from no-DOM (e.g. a Portal-using <Sheet>, or null) to an\n // in-flow host element: the new host is appended to the end of\n // domParent (because the parent reconcileChildren loop hands every\n // child the same anchor \u2014 typically null), and without this trailing\n // check it would never get moved before its later siblings.\n if (inOrder) {\n let last: Node | null = doms[doms.length - 1]!.nextSibling\n while (last && !doms.includes(last as Node) && last !== anchor) {\n last = last.nextSibling\n }\n if (last !== anchor) inOrder = false\n }\n if (inOrder) return\n }\n\n // Reverse-iterate, anchoring each node before the one that should follow it.\n // This works because by the time we're placing doms[i], doms[i+1] is already\n // in its final slot. Forward iteration is buggy: insertBefore(doms[i],\n // doms[i+1]) pulls doms[i] forward past any nodes that SHOULD move behind\n // it, leaving those nodes mis-anchored (app-starter Analyze/Lucky swap, npm\n // stats library dropdown reorder \u2014 both reported by users).\n //\n // Concrete example: start=[A, R, L], target=[A, L, R]. Forward pass gives\n // [L, A, R] (wrong). Reverse pass moves R to end, then L and A are already\n // correct \u2014 1 move, matches target.\n //\n // Skip nodes already in their target position so CSS transitions on stable\n // siblings aren't cancelled (e.g. drawer slide animation).\n for (let i = doms.length - 1; i >= 0; i--) {\n const d = doms[i]!\n const targetNext: Node | null = i + 1 < doms.length ? doms[i + 1]! : anchor\n if (d.parentNode !== domParent || d.nextSibling !== targetNext) {\n domParent.insertBefore(d, targetNext)\n }\n }\n}\n\nfunction collectHostDoms(fiber: Fiber, out: Node[]): void {\n if (fiber.tag === FiberTag.Host || fiber.tag === FiberTag.Text) {\n if (fiber.dom) out.push(fiber.dom)\n return\n }\n if (fiber.tag === FiberTag.Portal) return\n let c = fiber.child\n while (c) {\n collectHostDoms(c, out)\n c = c.sibling\n }\n}\n\nfunction collectChildren(parent: Fiber): Fiber[] {\n const out: Fiber[] = []\n let c = parent.child\n while (c) {\n out.push(c)\n c = c.sibling\n }\n return out\n}\n\n// ---------------------------------------------------------------------------\n// Rendering per fiber tag\n// ---------------------------------------------------------------------------\n\nexport type RenderFn = (fiber: Fiber, domParent: Node, anchor: Node | null) => void\nexport type TypeMatcher = (type: any, marker: any) => FiberTag | null\n\n// Mutable renderer registry indexed by FiberTag. Feature modules install their\n// renderer via registerRenderer(); unregistered features render as no-ops. The\n// initial registrations below rely on function-declaration hoisting \u2014 every\n// render* function is declared with `function` later in this file.\nconst RENDERERS: Array<RenderFn | undefined> = new Array(13)\n\n// Element-marker allowlist for child normalization (pushChildren). Core-always\n// markers are seeded here; features add their own via registerElementMarker.\nconst ACCEPTED_ELEMENT_MARKERS = new Set<symbol>([\n REACT_ELEMENT_TYPE as symbol,\n REACT_LEGACY_ELEMENT_TYPE as symbol,\n])\n\n// Type-to-tag matchers tried in registration order from fiberFromChild's\n// fallback branch. Features register here for element types that aren't\n// marker-based (e.g. Portal, where element.type IS the symbol).\nconst TYPE_MATCHERS: TypeMatcher[] = []\n\nexport function registerRenderer(tag: FiberTag, fn: RenderFn): void {\n RENDERERS[tag] = fn\n}\n\nexport function registerTypeMatcher(m: TypeMatcher): void {\n TYPE_MATCHERS.push(m)\n}\n\nexport function registerElementMarker(sym: symbol): void {\n ACCEPTED_ELEMENT_MARKERS.add(sym)\n}\n\n// Accessor + scoped setter for the module-level `currentRoot`. Feature modules\n// need these to participate in the render loop (e.g. Suspense re-hydration\n// must temporarily set the root while rebuilding a boundary subtree).\nexport function getCurrentRoot(): FiberRoot | null {\n return currentRoot\n}\n\nexport function withCurrentRoot<T>(root: FiberRoot | null, fn: () => T): T {\n const prev = currentRoot\n currentRoot = root\n try {\n return fn()\n } finally {\n currentRoot = prev\n }\n}\n\n// The memo feature uses this to bypass its prop-equality gate on state-driven\n// rerenders of the memoized fiber itself (hook update / subscribed store),\n// where props haven't changed by definition.\nexport function getForceRerenderingFiber(): Fiber | null {\n return forceRerenderingFiber\n}\n\nregisterRenderer(FiberTag.Text, renderText)\nregisterRenderer(FiberTag.Host, renderHost)\nregisterRenderer(FiberTag.Function, renderFunction)\nregisterRenderer(FiberTag.Fragment, renderFragment)\n\nexport function renderFiber(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const fn = RENDERERS[fiber.tag]\n if (fn) fn(fiber, domParent, anchor)\n}\n\nfunction renderText(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const text = fiber.pendingProps as string\n if (!fiber.dom) {\n const hydrated = currentRoot?.hydrating ? adoptTextDom(fiber, fiber.parent!, text) : false\n if (!hydrated) {\n fiber.dom = document.createTextNode(text)\n insertInto(domParent, fiber.dom, anchor)\n }\n } else if ((fiber.dom as Text).data !== text) {\n ;(fiber.dom as Text).data = text\n }\n fiber.memoizedProps = text\n // dirty cleared at rerender start; leaving true lets mid-render schedule persist\n}\n\nfunction renderHost(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const props = fiber.pendingProps ?? {}\n const prev = fiber.memoizedProps ?? {}\n const type = fiber.type as string\n const isSvg = type === 'svg' || (domParent as Element).namespaceURI === 'http://www.w3.org/2000/svg'\n\n // <select value> must be applied AFTER children mount \u2014 setting `.value`\n // on a `<select>` with no matching `<option>` yet resets it to empty. Same\n // for `defaultValue` on first mount. Stash and replay.\n const isSelect = type === 'select'\n const deferredSelectValue =\n isSelect && (props.value !== undefined || props.defaultValue !== undefined)\n ? props.value !== undefined ? props.value : props.defaultValue\n : undefined\n\n if (!fiber.dom) {\n const hydrated = currentRoot?.hydrating ? adoptHostDom(fiber, fiber.parent!) : false\n if (!hydrated) {\n fiber.dom = createHostNode(type, isSvg)\n // Two passes so form-control attributes (notably <input type>) are in\n // place before event handlers attach. setEventHandler reads the\n // element's runtime state to decide the DOM event name (e.g. onChange\n // \u2192 `input` vs `change`); binding before `type` is applied would\n // attach to the wrong event for checkbox/radio/file inputs.\n for (const k in props) {\n if (isSelect && (k === 'value' || k === 'defaultValue')) continue\n if (isEventProp(k)) continue\n setProp(fiber.dom as Element, k, props[k], undefined, isSvg)\n }\n for (const k in props) {\n if (!isEventProp(k)) continue\n setProp(fiber.dom as Element, k, props[k], undefined, isSvg)\n }\n insertInto(domParent, fiber.dom, anchor)\n }\n attachRef(fiber, fiber.dom)\n } else {\n const el = fiber.dom as Element\n for (const k in prev) {\n if (!(k in props)) setProp(el, k, undefined, prev[k], isSvg)\n }\n // Non-event props first for the same reason as above: a `type` change\n // must land before we ask setEventHandler to resolve the DOM event for\n // `onChange`.\n for (const k in props) {\n if (isSelect && (k === 'value' || k === 'defaultValue')) continue\n if (isEventProp(k)) continue\n if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg)\n }\n for (const k in props) {\n if (!isEventProp(k)) continue\n if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg)\n }\n if (prev !== props) syncRefIfChanged(fiber, fiber.dom)\n }\n\n // Children go into this DOM node\n reconcileChildren(fiber, childrenToArray(props.children), fiber.dom!, null)\n\n // During hydration, if after reconciling all client-expected children we\n // still have server DOM left in the cursor for this host, that's a\n // structural mismatch (server produced more than client wants). Report.\n // <head>/<html> are position-insensitive \u2014 leftover here is normal\n // (Vite dev-style injections, SSR-only scripts, etc.).\n if (currentRoot?.hydrating) {\n const parentTag = (fiber.type as string).toLowerCase()\n if (parentTag !== 'head' && parentTag !== 'html') {\n const cursor = getHydrationCursor(fiber)\n if (cursor) {\n const leftover = cursor.remaining().filter(\n (n) => n.nodeType === 1 || n.nodeType === 3,\n )\n if (leftover.length > 0 && currentRoot.onRecoverableError) {\n currentRoot.onRecoverableError(\n new Error(\n `Hydration mismatch: server rendered ${leftover.length} extra ` +\n `${leftover.length === 1 ? 'node' : 'nodes'} inside <${parentTag}> ` +\n `that the client tree did not.`,\n ),\n )\n for (const n of leftover) n.parentNode?.removeChild(n)\n }\n }\n }\n }\n\n // Apply <select> value after options are mounted.\n if (isSelect && deferredSelectValue !== undefined) {\n const select = fiber.dom as HTMLSelectElement\n if (Array.isArray(deferredSelectValue)) {\n const asStrings = deferredSelectValue.map((v) => '' + v)\n for (const opt of Array.from(select.options)) {\n opt.selected = asStrings.includes(opt.value)\n }\n } else {\n select.value = '' + deferredSelectValue\n }\n }\n\n fiber.memoizedProps = props\n // dirty cleared at rerender start; leaving true lets mid-render schedule persist\n}\n\nfunction renderFunction(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const prevDispatcher = ReactSharedInternals.H\n const prevFiber = ReactSharedInternals.currentFiber\n const prevHook = ReactSharedInternals.currentHook\n const prevIndex = ReactSharedInternals.hookIndex\n\n ReactSharedInternals.H = makeDispatcher()\n ReactSharedInternals.currentFiber = fiber\n ReactSharedInternals.currentHook = null\n ReactSharedInternals.hookIndex = 0\n\n let rendered: ReactNode\n let deferredForHydration = false\n try {\n rendered = (fiber.type as Function)(fiber.pendingProps ?? {})\n } catch (e: any) {\n if (isThenable(e)) {\n if (currentRoot?.hydrating) {\n // Suspension during initial hydration. Leave the existing DOM alone\n // and preserve the in-scope hydration cursor on THIS fiber so it\n // survives the synchronous endHydration() that fires when the initial\n // hydrateRoot() call returns. When the promise settles, the fiber\n // re-renders (see rerenderFiber) with hydration re-activated and its\n // descendants adopt DOM instead of creating new nodes.\n const hostParent = findHydrationHost(fiber)\n const inheritedCursor = getHydrationCursor(hostParent)\n if (inheritedCursor) {\n setHydrationCursor(fiber, inheritedCursor)\n }\n fiber.memoizedState = {\n ...(fiber.memoizedState ?? {}),\n _pendingHydration: true,\n }\n // Mirror renderLazy's guard: mark the nearest Suspense ancestor as\n // awaiting hydration-resume, so any re-render of that Suspense (e.g.\n // rehydrateBoundary fired by $RC, or an unrelated state update from a\n // sibling) doesn't re-enter `tryChildren`, re-throw, and flip Suspense\n // into its suspended+pending path \u2014 which would unmount our deferred\n // subtree and remount a fallback on top of the SSR content. By\n // pinning the Suspense to a \"hydration-suspended\" no-op until our\n // resume fires, the deferred re-render owns the adoption pass.\n let sus: Fiber | null = fiber.parent\n while (sus && sus.tag !== FiberTag.Suspense) sus = sus.parent\n if (sus && sus.memoizedState) {\n ;(sus.memoizedState as any)._awaitingLazyHydration = true\n }\n const clearAwait = () => {\n if (sus && sus.memoizedState) {\n ;(sus.memoizedState as any)._awaitingLazyHydration = false\n }\n scheduleUpdate(fiber)\n }\n e.then(clearAwait, clearAwait)\n deferredForHydration = true\n } else {\n CAPABILITIES.handleSuspended(fiber, e)\n rendered = null\n }\n } else {\n handleErrorInRender(fiber, e)\n return\n }\n } finally {\n ReactSharedInternals.H = prevDispatcher\n ReactSharedInternals.currentFiber = prevFiber\n ReactSharedInternals.currentHook = prevHook\n ReactSharedInternals.hookIndex = prevIndex\n }\n\n if (deferredForHydration) return\n\n reconcileChildren(fiber, childrenToArray(rendered), domParent, anchor)\n fiber.memoizedProps = fiber.pendingProps\n // dirty cleared at rerender start; leaving true lets mid-render schedule persist\n}\n\nfunction hasAncestorHydrationCursor(_fiber: Fiber): boolean {\n // Reserved for future per-Suspense-boundary hydration deferral. For now the\n // top-level hydration path is all we need to special-case.\n return false\n}\n\nfunction renderFragment(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const props = fiber.pendingProps ?? {}\n reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)\n fiber.memoizedProps = props\n // dirty cleared at rerender start; leaving true lets mid-render schedule persist\n}\n\n// ---------------------------------------------------------------------------\n// Error handling + default Suspense capability\n// ---------------------------------------------------------------------------\n\n// Default handler when the Suspense feature isn't installed: just schedule\n// a re-render when the thrown thenable settles. No boundary walk, no\n// fallback swap \u2014 children render empty during the pending window.\nfunction defaultHandleSuspended(fiber: Fiber, thenable: Promise<any>): void {\n thenable.then(\n () => scheduleUpdate(fiber),\n () => scheduleUpdate(fiber),\n )\n}\n\n// ---------------------------------------------------------------------------\n// Capability hooks \u2014 cross-cutting behaviors that features override.\n// Defaults here preserve today's behavior so the indirection is transparent\n// when all features are loaded. A feature's full-module can install its own\n// implementation via installCapability(); stubs leave the default in place,\n// where the default may intentionally degrade (e.g. a no-Context build's\n// readContext never walks the tree because no Provider fibers exist).\n// ---------------------------------------------------------------------------\n\nexport interface Capabilities {\n handleSuspended: (fiber: Fiber, thenable: Promise<any>) => void\n readContext: (fiber: Fiber, ctx: any) => any\n}\n\nconst CAPABILITIES: Capabilities = {\n handleSuspended: defaultHandleSuspended,\n readContext: defaultReadContext,\n}\n\nexport function installCapability<K extends keyof Capabilities>(\n name: K,\n fn: Capabilities[K],\n): void {\n CAPABILITIES[name] = fn\n}\n\n// Wrapper for features that catch thrown thenables inside their render\n// functions. Delegates to the installed Suspense capability.\nexport function handleSuspended(fiber: Fiber, thenable: Promise<any>): void {\n CAPABILITIES.handleSuspended(fiber, thenable)\n}\n\nexport function handleErrorInRender(fiber: Fiber, err: any): void {\n // Bubble to nearest class boundary with getDerivedStateFromError / componentDidCatch\n let f: Fiber | null = fiber.parent\n while (f) {\n if (f.tag === FiberTag.Class) {\n const Ctor = f.type as any\n const instance = f.stateNode\n if (Ctor.getDerivedStateFromError) {\n const update = Ctor.getDerivedStateFromError(err)\n instance.state = { ...instance.state, ...update }\n }\n if (instance.componentDidCatch) {\n try {\n instance.componentDidCatch(err, { componentStack: '' })\n } catch {}\n }\n scheduleUpdate(f)\n return\n }\n f = f.parent\n }\n // No boundary \u2014 report to root\n if (currentRoot?.onUncaughtError) currentRoot.onUncaughtError(err)\n else throw err\n}\n\nexport function isThenable(x: any): x is Promise<any> {\n return x != null && typeof x.then === 'function'\n}\n\n// ---------------------------------------------------------------------------\n// Unmount\n// ---------------------------------------------------------------------------\n\nfunction unmountFiber(fiber: Fiber, domParent: Node): void {\n fiber.unmounted = true\n // Recurse first\n let c = fiber.child\n while (c) {\n const next = c.sibling\n unmountFiber(c, fiber.tag === FiberTag.Host ? fiber.dom! : domParent)\n c = next\n }\n fiber.child = null\n\n // Run cleanups (effects + layout effects)\n if (fiber.cleanups) {\n for (const cleanup of fiber.cleanups) {\n try {\n cleanup()\n } catch (e) {\n if (currentRoot?.onRecoverableError) currentRoot.onRecoverableError(e)\n }\n }\n fiber.cleanups = null\n }\n\n if (fiber.tag === FiberTag.Class && fiber.stateNode?.componentWillUnmount) {\n try {\n fiber.stateNode.componentWillUnmount()\n } catch (e) {\n if (currentRoot?.onRecoverableError) currentRoot.onRecoverableError(e)\n }\n fiber.stateNode._fiber = null\n fiber.stateNode._enqueueUpdate = null\n fiber.stateNode._forceUpdate = null\n }\n\n // Detach ref\n if (fiber.ref) detachRef(fiber.ref)\n\n // Remove DOM if host\n if (fiber.tag === FiberTag.Host && fiber.dom && fiber.dom.parentNode) {\n fiber.dom.parentNode.removeChild(fiber.dom)\n } else if (fiber.tag === FiberTag.Text && fiber.dom && fiber.dom.parentNode) {\n fiber.dom.parentNode.removeChild(fiber.dom)\n }\n}\n\nexport function unmountAllChildren(parent: Fiber, domParent: Node): void {\n let c = parent.child\n while (c) {\n const next = c.sibling\n unmountFiber(c, domParent)\n c = next\n }\n parent.child = null\n}\n\n// ---------------------------------------------------------------------------\n// DOM navigation helpers\n// ---------------------------------------------------------------------------\n\nfunction insertInto(parent: Node, node: Node, anchor: Node | null): void {\n // Anchor may have been removed or moved since it was computed (mutations\n // from unmount, boundary reveal, user code, HMR). If it's no longer a child\n // of `parent`, fall back to append \u2014 trying to insertBefore a non-child\n // throws NotFoundError and dev-loops the reconciler.\n if (anchor && anchor.parentNode === parent) {\n parent.insertBefore(node, anchor)\n } else {\n parent.appendChild(node)\n }\n}\n\nfunction getHostParent(fiber: Fiber): Node {\n let p = fiber.parent\n while (p) {\n if (p.tag === FiberTag.Host) return p.dom!\n if (p.tag === FiberTag.Root)\n return (p.stateNode as Node) || (p.dom as Node) || (p.root?.container as Node)\n if (p.tag === FiberTag.Portal) {\n // Portal renders its children into the `container` prop, not into any\n // DOM element the portal fiber \"owns\". Read the container from the\n // portal's own props so a rerenderFiber triggered on a descendant\n // (e.g. a Floating-UI-positioned popper in a Radix Portal) finds its\n // host parent \u2014 otherwise getHostParent returns undefined and the\n // next renderHost crashes reading `.namespaceURI` on undefined.\n const props = (p.pendingProps ?? p.memoizedProps) as { container?: Element } | null\n return (props?.container as Node) || (p.stateNode as Node) || (p.dom as Node) || (p.root?.container as Node)\n }\n p = p.parent\n }\n throw new Error('No host parent found.')\n}\n\nfunction getAnchor(fiber: Fiber): Node | null {\n // Return the first DOM node that comes after this fiber within the host parent\n let f: Fiber | null = fiber.sibling\n while (f) {\n const d = firstDomNode(f)\n if (d) return d\n f = f.sibling\n }\n // Ascend\n let p = fiber.parent\n while (p && p.tag !== FiberTag.Host && p.tag !== FiberTag.Root && p.tag !== FiberTag.Portal) {\n if (p.sibling) {\n const d = firstDomNode(p.sibling)\n if (d) return d\n }\n p = p.parent\n }\n return null\n}\n\nfunction firstDomNode(fiber: Fiber): Node | null {\n if (fiber.tag === FiberTag.Host || fiber.tag === FiberTag.Text) return fiber.dom\n let c = fiber.child\n while (c) {\n const d = firstDomNode(c)\n if (d) return d\n c = c.sibling\n }\n return null\n}\n\n// ---------------------------------------------------------------------------\n// Context read \u2014 exported for dispatcher.ts (useContext, use()). Delegates to\n// the installed capability so the Context feature can override with a walking\n// implementation that finds the nearest Provider fiber. When the feature is\n// stubbed, the default here returns ctx._currentValue \u2014 correct because no\n// Provider fibers exist in the tree (Provider element \u2192 Fragment via the\n// stub's type matcher).\n// ---------------------------------------------------------------------------\n\nexport function readContext(fiber: Fiber, ctx: any): any {\n return CAPABILITIES.readContext(fiber, ctx)\n}\n\nfunction defaultReadContext(_fiber: Fiber, ctx: any): any {\n return ctx._currentValue\n}\n\n// ---------------------------------------------------------------------------\n// Refs\n// ---------------------------------------------------------------------------\n\nfunction attachRef(fiber: Fiber, value: any): void {\n const ref = fiber.ref ?? (fiber.pendingProps?.ref ?? null)\n if (!ref) return\n if (typeof ref === 'function') {\n // Match React's commit-phase semantics: callback refs run after render\n // (during the layout/commit phase), not during render. Calling them\n // synchronously here breaks libraries that assert no event handlers run\n // during render (e.g. base-ui's useStableCallback trampoline).\n scheduleLifecycle(fiber, () => {\n const cleanup = ref(value)\n fiber.cleanups ||= []\n fiber.cleanups.push(typeof cleanup === 'function' ? cleanup : () => ref(null))\n })\n } else {\n ref.current = value\n }\n}\n\nfunction syncRefIfChanged(fiber: Fiber, value: any): void {\n const ref = fiber.ref ?? (fiber.pendingProps?.ref ?? null)\n if (!ref) return\n if (typeof ref === 'object' && ref.current !== value) ref.current = value\n}\n\nfunction detachRef(ref: any): void {\n // Function refs are handled via fiber.cleanups (queued in attachRef during\n // the commit phase): the cleanup either invokes the user-returned cleanup\n // fn or calls ref(null). Calling ref(null) here would double-fire it.\n if (ref && typeof ref === 'object') {\n ref.current = null\n }\n}\n\n// ---------------------------------------------------------------------------\n// Effects\n// ---------------------------------------------------------------------------\n\nconst pendingEffects: Array<{ fiber: Fiber; effect: Effect }> = []\nconst pendingLayoutEffects: Array<{ fiber: Fiber; effect: Effect }> = []\nconst pendingLifecycles: Array<{ fiber: Fiber; fn: () => void }> = []\n\nexport function enqueueEffect(fiber: Fiber, effect: Effect): void {\n if (effect.tag === 'layout' || effect.tag === 'insertion') {\n pendingLayoutEffects.push({ fiber, effect })\n } else {\n pendingEffects.push({ fiber, effect })\n }\n}\n\nexport function scheduleLifecycle(fiber: Fiber, fn: () => void): void {\n pendingLifecycles.push({ fiber, fn })\n}\n\nexport function runEffects(root: FiberRoot): void {\n // Layout effects synchronously\n while (pendingLayoutEffects.length) {\n const { fiber, effect } = pendingLayoutEffects.shift()!\n runEffect(fiber, effect, root)\n }\n // Then lifecycles\n while (pendingLifecycles.length) {\n const { fn } = pendingLifecycles.shift()!\n try {\n fn()\n } catch (e) {\n if (root.onCaughtError) root.onCaughtError(e)\n }\n }\n // Passive effects on microtask\n if (pendingEffects.length) {\n const batch = pendingEffects.splice(0)\n queueMicrotask(() => {\n for (const { fiber, effect } of batch) runEffect(fiber, effect, root)\n })\n }\n}\n\nfunction runEffect(fiber: Fiber, effect: Effect, root: FiberRoot): void {\n try {\n const cleanup = effect.create()\n effect.destroy = typeof cleanup === 'function' ? cleanup : undefined\n if (effect.destroy) {\n fiber.cleanups ||= []\n fiber.cleanups.push(effect.destroy)\n }\n } catch (e) {\n if (root.onCaughtError) root.onCaughtError(e)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Utilities\n// ---------------------------------------------------------------------------\n\nfunction isEventProp(name: string): boolean {\n return (\n name.length > 2 &&\n name.charCodeAt(0) === 111 /* o */ &&\n name.charCodeAt(1) === 110 /* n */ &&\n name.charCodeAt(2) >= 65 /* 'A'-ish: any uppercase start (onClick, onChange, \u2026) */\n )\n}\n\n"],
5
- "mappings": ";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,eAAe;AACxC,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,kBAAkB;AAAA,OACb;AAMP,IAAI,cAAgC;AACpC,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAM,eAAe,oBAAI,IA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EACH;AACF;AAEA,SAAS,UAAU,OAAc,QAAgB,MAAuB;AACtE,MAAI;AACF,UAAM,UAAU,OAAO,OAAO;AAC9B,WAAO,UAAU,OAAO,YAAY,aAAa,UAAU;AAC3D,QAAI,OAAO,SAAS;AAClB,YAAM,aAAa,CAAC;AACpB,YAAM,SAAS,KAAK,OAAO,OAAO;AAAA,IACpC;AAAA,EACF,SAAS,GAAG;AACV,QAAI,KAAK,cAAe,MAAK,cAAc,CAAC;AAAA,EAC9C;AACF;AAMA,SAAS,YAAY,MAAuB;AAC1C,SACE,KAAK,SAAS,KACd,KAAK,WAAW,CAAC,MAAM,OACvB,KAAK,WAAW,CAAC,MAAM,OACvB,KAAK,WAAW,CAAC,KAAK;AAE1B;",
4
+ "sourcesContent": ["import {\n FiberTag,\n FiberFlag,\n createFiber,\n REACT_ELEMENT_TYPE,\n REACT_LEGACY_ELEMENT_TYPE,\n REACT_FRAGMENT_TYPE,\n type Fiber,\n type FiberRoot,\n type ReactElement,\n type ReactNode,\n type Hook,\n type Effect,\n} from '../core'\nimport {\n ReactSharedInternals,\n REACT_LAZY_TYPE,\n REACT_STRICT_MODE_TYPE,\n REACT_PROFILER_TYPE,\n} from '../react'\nimport { createHostNode, setProp } from './dom'\nimport { makeDispatcher } from './dispatcher'\nimport {\n adoptHostDom,\n adoptTextDom,\n tryConsumeBoundary,\n advanceCursorPast,\n setHydrationCursor,\n getHydrationCursor,\n clearHydrationCursor,\n HydrationCursor,\n findHostParent as findHydrationHost,\n} from './features/hydration'\n\n// ---------------------------------------------------------------------------\n// Render scheduling\n// ---------------------------------------------------------------------------\n\nlet currentRoot: FiberRoot | null = null\nlet flushing = false\nlet isBatching = false\nconst pendingRoots = new Set<FiberRoot>()\n\n// Set by rerenderFiber to identify the exact memo-tagged fiber whose INTERNAL\n// state (hook update, useSyncExternalStore notification) triggered this render\n// pass. renderMemo checks this to bypass its prop-equality gate for that fiber.\n// Without the bypass, a memo bail would swallow state changes: React's memo is\n// only a parent-triggered gate \u2014 state-driven rerenders must always run the\n// inner function. Router-adjacent components (Outlet, Match, MatchInner) are\n// all memo-wrapped and subscribe to stores; missing this bypass breaks nav\n// content updates even though the URL changes.\nlet forceRerenderingFiber: Fiber | null = null\n\nexport function scheduleUpdate(fiber: Fiber): void {\n // Drop updates scheduled on already-unmounted fibers. Subscribers (router,\n // query, any external store) can fire after unmount if their cleanup was\n // missed, and letting those reach rerenderFiber mounts zombie DOM into the\n // old .parent's DOM (which stays reachable via the stale pointer).\n if (fiber.unmounted) return\n const root = findRoot(fiber)\n if (!root) return\n root.pending.add(fiber)\n fiber.dirty = true\n pendingRoots.add(root)\n if (isBatching) return\n if (!root.scheduled) {\n root.scheduled = true\n queueMicrotask(flushPending)\n }\n}\n\nexport function flushSyncWork(fn: () => void): void {\n const wasBatching = isBatching\n isBatching = true\n try {\n fn()\n } finally {\n isBatching = wasBatching\n }\n flushPending()\n}\n\nexport function batchedUpdates<T>(fn: () => T): T {\n const wasBatching = isBatching\n isBatching = true\n try {\n return fn()\n } finally {\n isBatching = wasBatching\n if (!wasBatching) flushPending()\n }\n}\n\nfunction flushPending(): void {\n if (flushing) return\n flushing = true\n try {\n let guard = 0\n while (pendingRoots.size > 0) {\n if (++guard > 50) {\n throw new Error('flushPending exceeded 50 iterations \u2014 suspected infinite update loop.')\n }\n const roots = [...pendingRoots]\n pendingRoots.clear()\n for (const root of roots) {\n root.scheduled = false\n // Render each pending fiber from shallowest first so an ancestor's\n // cascade reaches descendants before we try to render them directly.\n // Descendants rendered via cascade still have `dirty=true` (only\n // rerenderFiber clears it); when we later reach them in this loop,\n // rerenderFiber's own `if (!dirty) return` is our short-circuit. We\n // previously filtered descendants of dirty ancestors here, but that\n // loses updates whenever an ancestor's render doesn't actually reach\n // the descendant \u2014 e.g. React.memo bailing on equal props. Keep all\n // dirty fibers and let rerenderFiber de-dupe via its dirty check.\n const pending = [...root.pending]\n root.pending.clear()\n pending.sort((a, b) => fiberDepth(a) - fiberDepth(b))\n for (const fiber of pending) {\n rerenderFiber(fiber, root)\n }\n runEffects(root)\n }\n }\n } finally {\n flushing = false\n }\n}\n\nfunction fiberDepth(fiber: Fiber): number {\n let d = 0\n let p: Fiber | null = fiber.parent\n while (p) {\n d++\n p = p.parent\n }\n return d\n}\n\nexport function findRoot(fiber: Fiber): FiberRoot | null {\n let f: Fiber | null = fiber\n while (f) {\n if (f.root) return f.root\n f = f.parent\n }\n return null\n}\n\n// ---------------------------------------------------------------------------\n// Entry points (called by createRoot)\n// ---------------------------------------------------------------------------\n\nexport function renderRoot(root: FiberRoot, children: ReactNode): void {\n const rootFiber = root.current\n rootFiber.pendingProps = { children }\n currentRoot = root\n try {\n reconcileChildren(rootFiber, childrenToArray(children), root.container as Node, null)\n rootFiber.memoizedProps = rootFiber.pendingProps\n rootFiber.dirty = false\n } finally {\n currentRoot = null\n }\n runEffects(root)\n}\n\nfunction rerenderFiber(fiber: Fiber, root: FiberRoot): void {\n if (!fiber.dirty) return\n // Skip fibers that were unmounted between scheduling and flush. Without this,\n // the flush loop re-enters a zombie fiber whose .parent is still set; its\n // render mounts fresh DOM into the old parent's still-attached DOM (since\n // unmountFiber only clears fiber.child, not fiber.parent). Visible as route\n // content from a previous location staying on screen after nav, because a\n // pending rerender on the old route's LibraryLandingPage (unmounted during\n // Outlet's shallow-first render) still fires from root.pending.\n if (fiber.unmounted) return\n // Clear BEFORE rendering so a scheduleUpdate() triggered mid-render (e.g.\n // error boundary catching a descendant throw) marks us dirty for the next\n // flush iteration instead of being wiped out when render() completes.\n fiber.dirty = false\n currentRoot = root\n // If this rerender is resuming a hydration that was deferred by a suspension,\n // re-activate hydration mode for its duration so descendants adopt DOM\n // instead of re-creating it.\n const resumeHydration =\n fiber.memoizedState && (fiber.memoizedState as any)._pendingHydration === true\n const prevHydrating = root.hydrating\n if (resumeHydration) {\n delete (fiber.memoizedState as any)._pendingHydration\n root.hydrating = true\n }\n const prevForcing = forceRerenderingFiber\n forceRerenderingFiber = fiber\n try {\n renderFiber(fiber, getHostParent(fiber), getAnchor(fiber))\n } finally {\n forceRerenderingFiber = prevForcing\n if (resumeHydration) {\n root.hydrating = prevHydrating\n // Deferred hydration completed \u2014 detach the preserved cursor so future\n // updates (post-hydration state changes) don't try to adopt stale DOM.\n clearHydrationCursor(fiber)\n }\n currentRoot = null\n }\n}\n\n// ---------------------------------------------------------------------------\n// Element \u2192 children normalization\n// ---------------------------------------------------------------------------\n\n// Text children pass through as raw strings \u2014 no wrapper. The previous\n// `{_text: string}` shape allocated tens of thousands of objects per\n// stable-list re-render and dominated minor-GC pressure. `typeof === 'string'`\n// is also robust to RSC renderable proxies (which have `has` traps that\n// would fool a `'_text' in child` predicate but can't fool `typeof`).\ntype NormalizedChild = ReactElement | string | null\n\nfunction isTextChild(child: Exclude<NormalizedChild, null>): child is string {\n return typeof child === 'string'\n}\n\nexport function childrenToArray(children: ReactNode): NormalizedChild[] {\n const out: NormalizedChild[] = []\n pushChildren(children, out)\n return out\n}\n\nfunction pushChildren(node: ReactNode, out: NormalizedChild[]): void {\n if (node == null || typeof node === 'boolean') return\n if (typeof node === 'string') {\n // Empty strings render no text node (matches React + the `<!-- -->`\n // separator elision on the SSR side so server/client agree).\n if (node === '') return\n out.push(node)\n return\n }\n if (typeof node === 'number') {\n out.push('' + node)\n return\n }\n if (Array.isArray(node)) {\n for (let i = 0; i < node.length; i++) pushChildren(node[i], out)\n return\n }\n if (isIterable(node)) {\n for (const item of node as Iterable<ReactNode>) pushChildren(item, out)\n return\n }\n if (typeof node === 'object') {\n const t = (node as any).$$typeof\n if (ACCEPTED_ELEMENT_MARKERS.has(t)) {\n out.push(node as ReactElement)\n return\n }\n // Raw React.lazy as a child. RSC Flight encodes 'use client' components\n // (CodeBlock, CodeExplorer, etc.) as bare Lazy objects in the tree, not\n // wrapped in REACT_ELEMENT_TYPE. Dropping them made code snippets\n // disappear from docs pages. The RSC decoder pre-awaits payloads via\n // `awaitLazyElements`, so by render time the status is 'fulfilled' and\n // `_init()` returns the resolved element synchronously.\n if (t === REACT_LAZY_TYPE) {\n const lazy = node as any\n const resolved = lazy._init(lazy._payload)\n pushChildren(resolved, out)\n return\n }\n }\n}\n\nfunction isIterable(obj: any): boolean {\n return obj != null && typeof obj !== 'string' && typeof obj[Symbol.iterator] === 'function'\n}\n\nfunction getKeyOf(child: NormalizedChild, index: number): string {\n if (!child) return 'n' + index\n if (isTextChild(child)) return '$t' + index\n if (child.key != null) return 'k' + child.key\n return 'i' + index\n}\n\nfunction sameType(fiber: Fiber, child: NormalizedChild): boolean {\n if (!child) return false\n if (isTextChild(child)) return fiber.tag === FiberTag.Text\n return fiber.type === child.type && sameKey(fiber.key, child.key)\n}\n\nfunction sameKey(a: string | null, b: string | null | undefined): boolean {\n return (a ?? null) === (b ?? null)\n}\n\n// ---------------------------------------------------------------------------\n// Fiber creation\n// ---------------------------------------------------------------------------\n\nfunction fiberFromChild(child: NormalizedChild, parent: Fiber): Fiber {\n if (!child) return createFiber(FiberTag.Fragment, null, null)\n if (isTextChild(child)) {\n const f = createFiber(FiberTag.Text, null, null)\n f.pendingProps = child\n f.parent = parent\n return f\n }\n const type = child.type\n let tag: FiberTag = FiberTag.Host\n const marker = type && (type as any).$$typeof\n if (typeof type === 'string') tag = FiberTag.Host\n else if (type === REACT_FRAGMENT_TYPE) tag = FiberTag.Fragment\n else if (type === REACT_STRICT_MODE_TYPE || type === REACT_PROFILER_TYPE) tag = FiberTag.Fragment\n else {\n // Feature-registered type matchers (Portal, future extractions). Features\n // that carry the symbol as element.type directly (rather than wrapping in\n // REACT_ELEMENT_TYPE) match here by type identity.\n let matched: FiberTag | null = null\n for (const m of TYPE_MATCHERS) {\n matched = m(type, marker)\n if (matched !== null) break\n }\n if (matched !== null) tag = matched\n else if (typeof type === 'function') {\n tag = type.prototype && type.prototype.isReactComponent ? FiberTag.Class : FiberTag.Function\n }\n }\n const f = createFiber(tag, type, child.key ?? null)\n f.ref = (child as any).ref ?? null\n f.pendingProps = child.props\n f.parent = parent\n return f\n}\n\n// ---------------------------------------------------------------------------\n// Reconciliation\n// ---------------------------------------------------------------------------\n\n/**\n * Reconcile a parent fiber's child list against new normalized children.\n * Mutates parent.child and the sibling chain.\n * Mounts new host DOM into `domParent` before `anchor` (or appends if anchor === null).\n */\nexport function reconcileChildren(\n parent: Fiber,\n newChildren: NormalizedChild[],\n domParent: Node,\n anchor: Node | null,\n): void {\n // Fast path: unkeyed positional steady-state. Walk the existing sibling\n // chain and newChildren in lockstep, validating AND committing in one pass.\n // On any divergence we fall back to the slow path, which rebuilds the\n // sibling chain anyway \u2014 partial pendingProps writes are idempotent.\n // Skips the Map / Set / existing-array allocation entirely.\n if (!currentRoot?.hydrating) {\n let f: Fiber | null = parent.child\n let ok = true\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i]\n if (child == null || !f || f.key != null) { ok = false; break }\n if (typeof child === 'string') {\n if (f.tag !== FiberTag.Text) { ok = false; break }\n f.pendingProps = child\n } else {\n if ((child as ReactElement).key != null) { ok = false; break }\n if (f.type !== (child as ReactElement).type) { ok = false; break }\n f.pendingProps = (child as ReactElement).props\n f.ref = (child as any).ref ?? null\n }\n f = f.sibling\n }\n if (ok && f === null) {\n // Pass 2: render forward with per-child anchors. Identical to the slow\n // path's pass 2.\n for (let r: Fiber | null = parent.child; r; r = r.sibling) {\n let a = anchor\n for (let s: Fiber | null = r.sibling; s; s = s.sibling) {\n const d = firstDomNode(s)\n if (d && d.parentNode === domParent) { a = d; break }\n }\n renderFiber(r, domParent, a)\n }\n return\n }\n }\n\n const existing = collectChildren(parent)\n const keyed = new Map<string, Fiber>()\n for (const f of existing) {\n if (f.key != null) keyed.set('k' + f.key, f)\n }\n\n let prevNewFiber: Fiber | null = null\n const claimed = new Set<Fiber>()\n let structurallyChanged = false\n // Budget-guided positional matching. We walk `existing` (unkeyed only) with a\n // single cursor `existingIdx` and, on a type mismatch, choose insert vs delete\n // based on the remaining length delta (`budget`):\n // budget > 0: more new than old remain \u2192 treat slot as an INSERTION: keep\n // the old cursor and create a fresh fiber for new[i].\n // budget < 0: more old than new remain \u2192 treat slot as a DELETION: advance\n // the old cursor past the mismatched fiber (it'll be unmounted\n // in the unclaimed pass) and retry.\n // budget == 0: equal remaining \u2192 treat as REPLACE by preferring delete\n // until budget flips positive or we hit a match.\n // This avoids greedy forward scans that steal a later same-type fiber for a\n // newly inserted leading sibling (e.g. smallMenu flipping null \u2192 <div>\n // stealing the content <div>'s fiber and tearing down the drawer fragment).\n let existingIdx = 0\n let unkeyedOld = 0\n for (const f of existing) if (f.key == null) unkeyedOld++\n let unkeyedNew = 0\n for (const c of newChildren) if (c != null) unkeyedNew++\n let budget = unkeyedNew - unkeyedOld\n\n // Pass 1 (this loop): match against existing fibers and build the sibling\n // chain. Pass 2 (after the loop) renders each fiber with the correct\n // per-child anchor \u2014 the firstDomNode of its next still-mounted sibling,\n // or the parent's own anchor for the rightmost. Without per-child anchors\n // a child whose render output type changes from no-DOM (Portal, null) to\n // an in-flow host gets appended to the end of domParent (every child\n // would otherwise share the parent's anchor) and never moves before its\n // later siblings. Hit by the t3code Sidebar swap from a portal-rendering\n // <Sheet> to a <div data-slot=sidebar> when isMobile flips during a\n // Provider re-render.\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i]\n if (child == null) continue\n\n let match: Fiber | null = null\n\n // key-based match\n if (child && typeof child === 'object' && !isTextChild(child) && (child as ReactElement).key != null) {\n const k = 'k' + (child as ReactElement).key\n const m = keyed.get(k)\n if (m && m.type === (child as ReactElement).type) {\n match = m\n keyed.delete(k)\n }\n }\n\n if (!match) {\n while (existingIdx < existing.length) {\n const cand = existing[existingIdx]!\n if (claimed.has(cand) || cand.key != null) {\n existingIdx++\n continue\n }\n if (sameType(cand, child)) {\n match = cand\n existingIdx++\n break\n }\n // Type mismatch at the cursor. Resolve via budget.\n if (budget > 0) {\n // Insertion: leave cand in place, create new for child.\n break\n }\n // Deletion (or replace-as-delete-first): advance past cand. It remains\n // unclaimed and will be unmounted at the end.\n existingIdx++\n budget++\n }\n }\n\n // Detect reorder: matched fiber is not at its original position\n if (match && existing[i] !== match) structurallyChanged = true\n\n let fiber: Fiber\n if (match) {\n claimed.add(match)\n fiber = match\n if (isTextChild(child!)) {\n fiber.pendingProps = child\n } else {\n fiber.type = (child as ReactElement).type\n fiber.pendingProps = (child as ReactElement).props\n fiber.ref = (child as any).ref ?? null\n }\n } else {\n fiber = fiberFromChild(child, parent)\n structurallyChanged = true\n if (budget > 0) budget--\n }\n\n fiber.parent = parent\n fiber.sibling = null\n if (prevNewFiber) prevNewFiber.sibling = fiber\n else parent.child = fiber\n prevNewFiber = fiber\n }\n\n // Pass 2: walk the sibling chain we just built and render each fiber\n // forward with the correct per-child anchor. During hydration the cursor\n // walks DOM forward and each renderFiber adopts the next existing node,\n // so per-child anchors are moot \u2014 fall back to the parent's anchor.\n const hydrating = !!currentRoot?.hydrating\n for (let f: Fiber | null = parent.child; f; f = f.sibling) {\n let a = anchor\n if (!hydrating) {\n // Find the firstDomNode of the next still-mounted sibling, if any.\n for (let s: Fiber | null = f.sibling; s; s = s.sibling) {\n const d = firstDomNode(s)\n if (d && d.parentNode === domParent) { a = d; break }\n }\n }\n renderFiber(f, domParent, a)\n }\n\n if (!prevNewFiber) parent.child = null\n else prevNewFiber.sibling = null\n\n // Head content is additive \u2014 server may inject metadata/stylesheets (Vite\n // dev styles, Sentry, analytics) that aren't in the React tree. Unmounting\n // them on every reconcile thrashes styles and causes flash of unstyled\n // content. Keep existing head children that weren't matched this pass.\n const parentIsHeadHost =\n parent.tag === FiberTag.Host &&\n typeof parent.type === 'string' &&\n (parent.type as string).toLowerCase() === 'head'\n\n if (!parentIsHeadHost) {\n // Unmount unclaimed\n for (const f of existing) {\n if (!claimed.has(f)) {\n unmountFiber(f, domParent)\n structurallyChanged = true\n }\n }\n // Leftover keyed\n for (const f of keyed.values()) {\n if (!claimed.has(f)) {\n unmountFiber(f, domParent)\n structurallyChanged = true\n }\n }\n }\n\n // During hydration, DOM is already in document order from the cursor-driven\n // adoption walk. Running placeChildrenInOrder here would reappend nodes to\n // the end of domParent when the true anchor (often an end marker comment)\n // isn't reflected in `anchor`. Skip it in hydration mode.\n //\n // For <head>, skip always \u2014 HeadContent re-renders routinely (route match\n // changes, providers updating), and reordering every <link>/<style>/<meta>\n // on each re-render causes stylesheet flash and re-download. Head element\n // ordering is semantically fluid; the browser doesn't care about exact\n // order within <head>.\n const parentIsHead =\n (domParent as Element).nodeType === 1 &&\n (domParent as Element).tagName.toLowerCase() === 'head'\n if (structurallyChanged && !currentRoot?.hydrating && !parentIsHead) {\n placeChildrenInOrder(parent, domParent, anchor)\n }\n}\n\nfunction placeChildrenInOrder(parent: Fiber, domParent: Node, anchor: Node | null): void {\n const doms: Node[] = []\n let c = parent.child\n while (c) {\n collectHostDoms(c, doms)\n c = c.sibling\n }\n\n // Pre-check: if our fiber-owned DOM is already in document order within\n // domParent AND the trailing anchor matches, no reorder is needed. This is\n // the common case on stable re-renders, and avoids detaching/re-attaching\n // subtrees (which cancels CSS animations and triggers layout).\n if (doms.length > 0) {\n let current: Node | null = doms[0]!\n let inOrder = current.parentNode === domParent\n for (let i = 1; inOrder && i < doms.length; i++) {\n current = current!.nextSibling\n // Skip foreign nodes (SSR-injected scripts, dev-styles) between owned\n // fiber DOMs \u2014 they should stay where they are.\n while (current && !doms.includes(current as Node)) {\n current = current.nextSibling\n }\n if (current !== doms[i]) inOrder = false\n }\n // Also verify the LAST dom's next sibling lines up with `anchor`. A\n // single-dom collection (or correctly-internally-ordered doms) can sit\n // at the WRONG absolute position in domParent and still pass the\n // relative-order check above. This happens when a fiber's render output\n // changes from no-DOM (e.g. a Portal-using <Sheet>, or null) to an\n // in-flow host element: the new host is appended to the end of\n // domParent (because the parent reconcileChildren loop hands every\n // child the same anchor \u2014 typically null), and without this trailing\n // check it would never get moved before its later siblings.\n if (inOrder) {\n let last: Node | null = doms[doms.length - 1]!.nextSibling\n while (last && !doms.includes(last as Node) && last !== anchor) {\n last = last.nextSibling\n }\n if (last !== anchor) inOrder = false\n }\n if (inOrder) return\n }\n\n // Reverse-iterate, anchoring each node before the one that should follow it.\n // This works because by the time we're placing doms[i], doms[i+1] is already\n // in its final slot. Forward iteration is buggy: insertBefore(doms[i],\n // doms[i+1]) pulls doms[i] forward past any nodes that SHOULD move behind\n // it, leaving those nodes mis-anchored (app-starter Analyze/Lucky swap, npm\n // stats library dropdown reorder \u2014 both reported by users).\n //\n // Concrete example: start=[A, R, L], target=[A, L, R]. Forward pass gives\n // [L, A, R] (wrong). Reverse pass moves R to end, then L and A are already\n // correct \u2014 1 move, matches target.\n //\n // Skip nodes already in their target position so CSS transitions on stable\n // siblings aren't cancelled (e.g. drawer slide animation).\n for (let i = doms.length - 1; i >= 0; i--) {\n const d = doms[i]!\n const targetNext: Node | null = i + 1 < doms.length ? doms[i + 1]! : anchor\n if (d.parentNode !== domParent || d.nextSibling !== targetNext) {\n domParent.insertBefore(d, targetNext)\n }\n }\n}\n\nfunction collectHostDoms(fiber: Fiber, out: Node[]): void {\n if (fiber.tag === FiberTag.Host || fiber.tag === FiberTag.Text) {\n if (fiber.dom) out.push(fiber.dom)\n return\n }\n if (fiber.tag === FiberTag.Portal) return\n let c = fiber.child\n while (c) {\n collectHostDoms(c, out)\n c = c.sibling\n }\n}\n\nfunction collectChildren(parent: Fiber): Fiber[] {\n const out: Fiber[] = []\n let c = parent.child\n while (c) {\n out.push(c)\n c = c.sibling\n }\n return out\n}\n\n// ---------------------------------------------------------------------------\n// Rendering per fiber tag\n// ---------------------------------------------------------------------------\n\nexport type RenderFn = (fiber: Fiber, domParent: Node, anchor: Node | null) => void\nexport type TypeMatcher = (type: any, marker: any) => FiberTag | null\n\n// Mutable renderer registry indexed by FiberTag. Feature modules install their\n// renderer via registerRenderer(); unregistered features render as no-ops. The\n// initial registrations below rely on function-declaration hoisting \u2014 every\n// render* function is declared with `function` later in this file.\nconst RENDERERS: Array<RenderFn | undefined> = new Array(13)\n\n// Element-marker allowlist for child normalization (pushChildren). Core-always\n// markers are seeded here; features add their own via registerElementMarker.\nconst ACCEPTED_ELEMENT_MARKERS = new Set<symbol>([\n REACT_ELEMENT_TYPE as symbol,\n REACT_LEGACY_ELEMENT_TYPE as symbol,\n])\n\n// Type-to-tag matchers tried in registration order from fiberFromChild's\n// fallback branch. Features register here for element types that aren't\n// marker-based (e.g. Portal, where element.type IS the symbol).\nconst TYPE_MATCHERS: TypeMatcher[] = []\n\nexport function registerRenderer(tag: FiberTag, fn: RenderFn): void {\n RENDERERS[tag] = fn\n}\n\nexport function registerTypeMatcher(m: TypeMatcher): void {\n TYPE_MATCHERS.push(m)\n}\n\nexport function registerElementMarker(sym: symbol): void {\n ACCEPTED_ELEMENT_MARKERS.add(sym)\n}\n\n// Accessor + scoped setter for the module-level `currentRoot`. Feature modules\n// need these to participate in the render loop (e.g. Suspense re-hydration\n// must temporarily set the root while rebuilding a boundary subtree).\nexport function getCurrentRoot(): FiberRoot | null {\n return currentRoot\n}\n\nexport function withCurrentRoot<T>(root: FiberRoot | null, fn: () => T): T {\n const prev = currentRoot\n currentRoot = root\n try {\n return fn()\n } finally {\n currentRoot = prev\n }\n}\n\n// The memo feature uses this to bypass its prop-equality gate on state-driven\n// rerenders of the memoized fiber itself (hook update / subscribed store),\n// where props haven't changed by definition.\nexport function getForceRerenderingFiber(): Fiber | null {\n return forceRerenderingFiber\n}\n\nregisterRenderer(FiberTag.Text, renderText)\nregisterRenderer(FiberTag.Host, renderHost)\nregisterRenderer(FiberTag.Function, renderFunction)\nregisterRenderer(FiberTag.Fragment, renderFragment)\n\nexport function renderFiber(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const fn = RENDERERS[fiber.tag]\n if (fn) fn(fiber, domParent, anchor)\n}\n\nfunction renderText(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const text = fiber.pendingProps as string\n // Identity-unchanged fast path: skip the native Text.data write entirely.\n if (fiber.dom && fiber.memoizedProps === text) return\n if (!fiber.dom) {\n const hydrated = currentRoot?.hydrating ? adoptTextDom(fiber, fiber.parent!, text) : false\n if (!hydrated) {\n fiber.dom = document.createTextNode(text)\n insertInto(domParent, fiber.dom, anchor)\n }\n } else {\n // Past the fast path, and adoptTextDom already realigned `.data` on\n // hydration \u2014 `.data !== text` here is guaranteed, so write directly.\n ;(fiber.dom as Text).data = text\n }\n fiber.memoizedProps = text\n // dirty cleared at rerender start; leaving true lets mid-render schedule persist\n}\n\nfunction renderHost(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const props = fiber.pendingProps ?? {}\n const prev = fiber.memoizedProps ?? {}\n const type = fiber.type as string\n const isSvg = type === 'svg' || (domParent as Element).namespaceURI === 'http://www.w3.org/2000/svg'\n\n // <select value> must be applied AFTER children mount \u2014 setting `.value`\n // on a `<select>` with no matching `<option>` yet resets it to empty. Same\n // for `defaultValue` on first mount. Stash and replay.\n const isSelect = type === 'select'\n const deferredSelectValue =\n isSelect && (props.value !== undefined || props.defaultValue !== undefined)\n ? props.value !== undefined ? props.value : props.defaultValue\n : undefined\n\n if (!fiber.dom) {\n const hydrated = currentRoot?.hydrating ? adoptHostDom(fiber, fiber.parent!) : false\n if (!hydrated) {\n fiber.dom = createHostNode(type, isSvg)\n // Two passes so form-control attributes (notably <input type>) are in\n // place before event handlers attach. setEventHandler reads the\n // element's runtime state to decide the DOM event name (e.g. onChange\n // \u2192 `input` vs `change`); binding before `type` is applied would\n // attach to the wrong event for checkbox/radio/file inputs.\n for (const k in props) {\n if (isSelect && (k === 'value' || k === 'defaultValue')) continue\n if (isEventProp(k)) continue\n setProp(fiber.dom as Element, k, props[k], undefined, isSvg)\n }\n for (const k in props) {\n if (!isEventProp(k)) continue\n setProp(fiber.dom as Element, k, props[k], undefined, isSvg)\n }\n insertInto(domParent, fiber.dom, anchor)\n }\n attachRef(fiber, fiber.dom)\n } else if (prev !== props) {\n const el = fiber.dom as Element\n // Single-pass diff. Defer changed event props into a small array so the\n // `type-before-events` invariant the mount path needs (setEventHandler\n // reads `el.type` to resolve onChange\u2192input vs change) still holds when\n // a render flips both `type` and an event handler in the same pass.\n // The vast majority of host updates have no events at all (e.g. data-*\n // attributes flipping on a stable list), so the deferred array stays\n // null and we collapse to one for-in over `props`.\n let deferredEvents: string[] | null = null\n for (const k in props) {\n if (isSelect && (k === 'value' || k === 'defaultValue')) continue\n if (isEventProp(k)) {\n if (prev[k] !== props[k]) {\n deferredEvents ||= []\n deferredEvents.push(k)\n }\n continue\n }\n if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg)\n }\n // Removals \u2014 keys present in prev but not in props.\n for (const k in prev) {\n if (!(k in props)) setProp(el, k, undefined, prev[k], isSvg)\n }\n if (deferredEvents) {\n for (let i = 0; i < deferredEvents.length; i++) {\n const k = deferredEvents[i]!\n setProp(el, k, props[k], prev[k], isSvg)\n }\n }\n syncRefIfChanged(fiber, fiber.dom)\n }\n\n // Children go into this DOM node\n reconcileChildren(fiber, childrenToArray(props.children), fiber.dom!, null)\n\n // During hydration, if after reconciling all client-expected children we\n // still have server DOM left in the cursor for this host, that's a\n // structural mismatch (server produced more than client wants). Report.\n // <head>/<html> are position-insensitive \u2014 leftover here is normal\n // (Vite dev-style injections, SSR-only scripts, etc.).\n if (currentRoot?.hydrating) {\n const parentTag = (fiber.type as string).toLowerCase()\n if (parentTag !== 'head' && parentTag !== 'html') {\n const cursor = getHydrationCursor(fiber)\n if (cursor) {\n const leftover = cursor.remaining().filter(\n (n) => n.nodeType === 1 || n.nodeType === 3,\n )\n if (leftover.length > 0 && currentRoot.onRecoverableError) {\n currentRoot.onRecoverableError(\n new Error(\n `Hydration mismatch: server rendered ${leftover.length} extra ` +\n `${leftover.length === 1 ? 'node' : 'nodes'} inside <${parentTag}> ` +\n `that the client tree did not.`,\n ),\n )\n for (const n of leftover) n.parentNode?.removeChild(n)\n }\n }\n }\n }\n\n // Apply <select> value after options are mounted.\n if (isSelect && deferredSelectValue !== undefined) {\n const select = fiber.dom as HTMLSelectElement\n if (Array.isArray(deferredSelectValue)) {\n const asStrings = deferredSelectValue.map((v) => '' + v)\n for (const opt of Array.from(select.options)) {\n opt.selected = asStrings.includes(opt.value)\n }\n } else {\n select.value = '' + deferredSelectValue\n }\n }\n\n fiber.memoizedProps = props\n // dirty cleared at rerender start; leaving true lets mid-render schedule persist\n}\n\nfunction renderFunction(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const prevDispatcher = ReactSharedInternals.H\n const prevFiber = ReactSharedInternals.currentFiber\n const prevHook = ReactSharedInternals.currentHook\n const prevIndex = ReactSharedInternals.hookIndex\n\n ReactSharedInternals.H = makeDispatcher()\n ReactSharedInternals.currentFiber = fiber\n ReactSharedInternals.currentHook = null\n ReactSharedInternals.hookIndex = 0\n\n let rendered: ReactNode\n let deferredForHydration = false\n try {\n rendered = (fiber.type as Function)(fiber.pendingProps ?? {})\n } catch (e: any) {\n if (isThenable(e)) {\n if (currentRoot?.hydrating) {\n // Suspension during initial hydration. Leave the existing DOM alone\n // and preserve the in-scope hydration cursor on THIS fiber so it\n // survives the synchronous endHydration() that fires when the initial\n // hydrateRoot() call returns. When the promise settles, the fiber\n // re-renders (see rerenderFiber) with hydration re-activated and its\n // descendants adopt DOM instead of creating new nodes.\n const hostParent = findHydrationHost(fiber)\n const inheritedCursor = getHydrationCursor(hostParent)\n if (inheritedCursor) {\n setHydrationCursor(fiber, inheritedCursor)\n }\n fiber.memoizedState = {\n ...(fiber.memoizedState ?? {}),\n _pendingHydration: true,\n }\n // Mirror renderLazy's guard: mark the nearest Suspense ancestor as\n // awaiting hydration-resume, so any re-render of that Suspense (e.g.\n // rehydrateBoundary fired by $RC, or an unrelated state update from a\n // sibling) doesn't re-enter `tryChildren`, re-throw, and flip Suspense\n // into its suspended+pending path \u2014 which would unmount our deferred\n // subtree and remount a fallback on top of the SSR content. By\n // pinning the Suspense to a \"hydration-suspended\" no-op until our\n // resume fires, the deferred re-render owns the adoption pass.\n let sus: Fiber | null = fiber.parent\n while (sus && sus.tag !== FiberTag.Suspense) sus = sus.parent\n if (sus && sus.memoizedState) {\n ;(sus.memoizedState as any)._awaitingLazyHydration = true\n }\n const clearAwait = () => {\n if (sus && sus.memoizedState) {\n ;(sus.memoizedState as any)._awaitingLazyHydration = false\n }\n scheduleUpdate(fiber)\n }\n e.then(clearAwait, clearAwait)\n deferredForHydration = true\n } else {\n CAPABILITIES.handleSuspended(fiber, e)\n rendered = null\n }\n } else {\n handleErrorInRender(fiber, e)\n return\n }\n } finally {\n ReactSharedInternals.H = prevDispatcher\n ReactSharedInternals.currentFiber = prevFiber\n ReactSharedInternals.currentHook = prevHook\n ReactSharedInternals.hookIndex = prevIndex\n }\n\n if (deferredForHydration) return\n\n reconcileChildren(fiber, childrenToArray(rendered), domParent, anchor)\n fiber.memoizedProps = fiber.pendingProps\n // dirty cleared at rerender start; leaving true lets mid-render schedule persist\n}\n\nfunction hasAncestorHydrationCursor(_fiber: Fiber): boolean {\n // Reserved for future per-Suspense-boundary hydration deferral. For now the\n // top-level hydration path is all we need to special-case.\n return false\n}\n\nfunction renderFragment(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const props = fiber.pendingProps ?? {}\n reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)\n fiber.memoizedProps = props\n // dirty cleared at rerender start; leaving true lets mid-render schedule persist\n}\n\n// ---------------------------------------------------------------------------\n// Error handling + default Suspense capability\n// ---------------------------------------------------------------------------\n\n// Default handler when the Suspense feature isn't installed: just schedule\n// a re-render when the thrown thenable settles. No boundary walk, no\n// fallback swap \u2014 children render empty during the pending window.\nfunction defaultHandleSuspended(fiber: Fiber, thenable: Promise<any>): void {\n thenable.then(\n () => scheduleUpdate(fiber),\n () => scheduleUpdate(fiber),\n )\n}\n\n// ---------------------------------------------------------------------------\n// Capability hooks \u2014 cross-cutting behaviors that features override.\n// Defaults here preserve today's behavior so the indirection is transparent\n// when all features are loaded. A feature's full-module can install its own\n// implementation via installCapability(); stubs leave the default in place,\n// where the default may intentionally degrade (e.g. a no-Context build's\n// readContext never walks the tree because no Provider fibers exist).\n// ---------------------------------------------------------------------------\n\nexport interface Capabilities {\n handleSuspended: (fiber: Fiber, thenable: Promise<any>) => void\n readContext: (fiber: Fiber, ctx: any) => any\n}\n\nconst CAPABILITIES: Capabilities = {\n handleSuspended: defaultHandleSuspended,\n readContext: defaultReadContext,\n}\n\nexport function installCapability<K extends keyof Capabilities>(\n name: K,\n fn: Capabilities[K],\n): void {\n CAPABILITIES[name] = fn\n}\n\n// Wrapper for features that catch thrown thenables inside their render\n// functions. Delegates to the installed Suspense capability.\nexport function handleSuspended(fiber: Fiber, thenable: Promise<any>): void {\n CAPABILITIES.handleSuspended(fiber, thenable)\n}\n\nexport function handleErrorInRender(fiber: Fiber, err: any): void {\n // Bubble to nearest class boundary with getDerivedStateFromError / componentDidCatch\n let f: Fiber | null = fiber.parent\n while (f) {\n if (f.tag === FiberTag.Class) {\n const Ctor = f.type as any\n const instance = f.stateNode\n if (Ctor.getDerivedStateFromError) {\n const update = Ctor.getDerivedStateFromError(err)\n instance.state = { ...instance.state, ...update }\n }\n if (instance.componentDidCatch) {\n try {\n instance.componentDidCatch(err, { componentStack: '' })\n } catch {}\n }\n scheduleUpdate(f)\n return\n }\n f = f.parent\n }\n // No boundary \u2014 report to root\n if (currentRoot?.onUncaughtError) currentRoot.onUncaughtError(err)\n else throw err\n}\n\nexport function isThenable(x: any): x is Promise<any> {\n return x != null && typeof x.then === 'function'\n}\n\n// ---------------------------------------------------------------------------\n// Unmount\n// ---------------------------------------------------------------------------\n\nfunction unmountFiber(fiber: Fiber, domParent: Node): void {\n fiber.unmounted = true\n // Recurse first\n let c = fiber.child\n while (c) {\n const next = c.sibling\n unmountFiber(c, fiber.tag === FiberTag.Host ? fiber.dom! : domParent)\n c = next\n }\n fiber.child = null\n\n // Run cleanups (effects + layout effects)\n if (fiber.cleanups) {\n for (const cleanup of fiber.cleanups) {\n try {\n cleanup()\n } catch (e) {\n if (currentRoot?.onRecoverableError) currentRoot.onRecoverableError(e)\n }\n }\n fiber.cleanups = null\n }\n\n if (fiber.tag === FiberTag.Class && fiber.stateNode?.componentWillUnmount) {\n try {\n fiber.stateNode.componentWillUnmount()\n } catch (e) {\n if (currentRoot?.onRecoverableError) currentRoot.onRecoverableError(e)\n }\n fiber.stateNode._fiber = null\n fiber.stateNode._enqueueUpdate = null\n fiber.stateNode._forceUpdate = null\n }\n\n // Detach ref\n if (fiber.ref) detachRef(fiber.ref)\n\n // Remove DOM if host\n if (fiber.tag === FiberTag.Host && fiber.dom && fiber.dom.parentNode) {\n fiber.dom.parentNode.removeChild(fiber.dom)\n } else if (fiber.tag === FiberTag.Text && fiber.dom && fiber.dom.parentNode) {\n fiber.dom.parentNode.removeChild(fiber.dom)\n }\n}\n\nexport function unmountAllChildren(parent: Fiber, domParent: Node): void {\n let c = parent.child\n while (c) {\n const next = c.sibling\n unmountFiber(c, domParent)\n c = next\n }\n parent.child = null\n}\n\n// ---------------------------------------------------------------------------\n// DOM navigation helpers\n// ---------------------------------------------------------------------------\n\nfunction insertInto(parent: Node, node: Node, anchor: Node | null): void {\n // Anchor may have been removed or moved since it was computed (mutations\n // from unmount, boundary reveal, user code, HMR). If it's no longer a child\n // of `parent`, fall back to append \u2014 trying to insertBefore a non-child\n // throws NotFoundError and dev-loops the reconciler.\n if (anchor && anchor.parentNode === parent) {\n parent.insertBefore(node, anchor)\n } else {\n parent.appendChild(node)\n }\n}\n\nfunction getHostParent(fiber: Fiber): Node {\n let p = fiber.parent\n while (p) {\n if (p.tag === FiberTag.Host) return p.dom!\n if (p.tag === FiberTag.Root)\n return (p.stateNode as Node) || (p.dom as Node) || (p.root?.container as Node)\n if (p.tag === FiberTag.Portal) {\n // Portal renders its children into the `container` prop, not into any\n // DOM element the portal fiber \"owns\". Read the container from the\n // portal's own props so a rerenderFiber triggered on a descendant\n // (e.g. a Floating-UI-positioned popper in a Radix Portal) finds its\n // host parent \u2014 otherwise getHostParent returns undefined and the\n // next renderHost crashes reading `.namespaceURI` on undefined.\n const props = (p.pendingProps ?? p.memoizedProps) as { container?: Element } | null\n return (props?.container as Node) || (p.stateNode as Node) || (p.dom as Node) || (p.root?.container as Node)\n }\n p = p.parent\n }\n throw new Error('No host parent found.')\n}\n\nfunction getAnchor(fiber: Fiber): Node | null {\n // Return the first DOM node that comes after this fiber within the host parent\n let f: Fiber | null = fiber.sibling\n while (f) {\n const d = firstDomNode(f)\n if (d) return d\n f = f.sibling\n }\n // Ascend\n let p = fiber.parent\n while (p && p.tag !== FiberTag.Host && p.tag !== FiberTag.Root && p.tag !== FiberTag.Portal) {\n if (p.sibling) {\n const d = firstDomNode(p.sibling)\n if (d) return d\n }\n p = p.parent\n }\n return null\n}\n\nfunction firstDomNode(fiber: Fiber): Node | null {\n if (fiber.tag === FiberTag.Host || fiber.tag === FiberTag.Text) return fiber.dom\n let c = fiber.child\n while (c) {\n const d = firstDomNode(c)\n if (d) return d\n c = c.sibling\n }\n return null\n}\n\n// ---------------------------------------------------------------------------\n// Context read \u2014 exported for dispatcher.ts (useContext, use()). Delegates to\n// the installed capability so the Context feature can override with a walking\n// implementation that finds the nearest Provider fiber. When the feature is\n// stubbed, the default here returns ctx._currentValue \u2014 correct because no\n// Provider fibers exist in the tree (Provider element \u2192 Fragment via the\n// stub's type matcher).\n// ---------------------------------------------------------------------------\n\nexport function readContext(fiber: Fiber, ctx: any): any {\n return CAPABILITIES.readContext(fiber, ctx)\n}\n\nfunction defaultReadContext(_fiber: Fiber, ctx: any): any {\n return ctx._currentValue\n}\n\n// ---------------------------------------------------------------------------\n// Refs\n// ---------------------------------------------------------------------------\n\nfunction attachRef(fiber: Fiber, value: any): void {\n const ref = fiber.ref ?? (fiber.pendingProps?.ref ?? null)\n if (!ref) return\n if (typeof ref === 'function') {\n // Match React's commit-phase semantics: callback refs run after render\n // (during the layout/commit phase), not during render. Calling them\n // synchronously here breaks libraries that assert no event handlers run\n // during render (e.g. base-ui's useStableCallback trampoline).\n scheduleLifecycle(fiber, () => {\n const cleanup = ref(value)\n fiber.cleanups ||= []\n fiber.cleanups.push(typeof cleanup === 'function' ? cleanup : () => ref(null))\n })\n } else {\n ref.current = value\n }\n}\n\nfunction syncRefIfChanged(fiber: Fiber, value: any): void {\n const ref = fiber.ref ?? (fiber.pendingProps?.ref ?? null)\n if (!ref) return\n if (typeof ref === 'object' && ref.current !== value) ref.current = value\n}\n\nfunction detachRef(ref: any): void {\n // Function refs are handled via fiber.cleanups (queued in attachRef during\n // the commit phase): the cleanup either invokes the user-returned cleanup\n // fn or calls ref(null). Calling ref(null) here would double-fire it.\n if (ref && typeof ref === 'object') {\n ref.current = null\n }\n}\n\n// ---------------------------------------------------------------------------\n// Effects\n// ---------------------------------------------------------------------------\n\nconst pendingEffects: Array<{ fiber: Fiber; effect: Effect }> = []\nconst pendingLayoutEffects: Array<{ fiber: Fiber; effect: Effect }> = []\nconst pendingLifecycles: Array<{ fiber: Fiber; fn: () => void }> = []\n\nexport function enqueueEffect(fiber: Fiber, effect: Effect): void {\n if (effect.tag === 'layout' || effect.tag === 'insertion') {\n pendingLayoutEffects.push({ fiber, effect })\n } else {\n pendingEffects.push({ fiber, effect })\n }\n}\n\nexport function scheduleLifecycle(fiber: Fiber, fn: () => void): void {\n pendingLifecycles.push({ fiber, fn })\n}\n\nexport function runEffects(root: FiberRoot): void {\n // Layout effects synchronously\n while (pendingLayoutEffects.length) {\n const { fiber, effect } = pendingLayoutEffects.shift()!\n runEffect(fiber, effect, root)\n }\n // Then lifecycles\n while (pendingLifecycles.length) {\n const { fn } = pendingLifecycles.shift()!\n try {\n fn()\n } catch (e) {\n if (root.onCaughtError) root.onCaughtError(e)\n }\n }\n // Passive effects on microtask\n if (pendingEffects.length) {\n const batch = pendingEffects.splice(0)\n queueMicrotask(() => {\n for (const { fiber, effect } of batch) runEffect(fiber, effect, root)\n })\n }\n}\n\nfunction runEffect(fiber: Fiber, effect: Effect, root: FiberRoot): void {\n try {\n const cleanup = effect.create()\n effect.destroy = typeof cleanup === 'function' ? cleanup : undefined\n if (effect.destroy) {\n fiber.cleanups ||= []\n fiber.cleanups.push(effect.destroy)\n }\n } catch (e) {\n if (root.onCaughtError) root.onCaughtError(e)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Utilities\n// ---------------------------------------------------------------------------\n\nfunction isEventProp(name: string): boolean {\n return (\n name.length > 2 &&\n name.charCodeAt(0) === 111 /* o */ &&\n name.charCodeAt(1) === 110 /* n */ &&\n name.charCodeAt(2) >= 65 /* 'A'-ish: any uppercase start (onClick, onChange, \u2026) */\n )\n}\n\n"],
5
+ "mappings": ";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,eAAe;AACxC,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,kBAAkB;AAAA,OACb;AAMP,IAAI,cAAgC;AACpC,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAM,eAAe,oBAAI,IAAe;AAUxC,IAAI,wBAAsC;AAEnC,SAAS,eAAe,OAAoB;AAKjD,MAAI,MAAM,UAAW;AACrB,QAAM,OAAO,SAAS,KAAK;AAC3B,MAAI,CAAC,KAAM;AACX,OAAK,QAAQ,IAAI,KAAK;AACtB,QAAM,QAAQ;AACd,eAAa,IAAI,IAAI;AACrB,MAAI,WAAY;AAChB,MAAI,CAAC,KAAK,WAAW;AACnB,SAAK,YAAY;AACjB,mBAAe,YAAY;AAAA,EAC7B;AACF;AAEO,SAAS,cAAc,IAAsB;AAClD,QAAM,cAAc;AACpB,eAAa;AACb,MAAI;AACF,OAAG;AAAA,EACL,UAAE;AACA,iBAAa;AAAA,EACf;AACA,eAAa;AACf;AAEO,SAAS,eAAkB,IAAgB;AAChD,QAAM,cAAc;AACpB,eAAa;AACb,MAAI;AACF,WAAO,GAAG;AAAA,EACZ,UAAE;AACA,iBAA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,kBAAkB,OAAc,IAAsB;AACpE,oBAAkB,KAAK,EAAE,OAAO,GAAG,CAAC;AACtC;AAEO,SAAS,WAAW,MAAuB;AAEhD,SAAO,qBAAqB,QAAQ;AAClC,UAAM,EAAE,OAAO,OAAO,IAAI,qBAAqB,MAAM;AACrD,cAAU,OAAO,QAAQ,IAAI;AAAA,EAC/B;AAEA,SAAO,kBAAkB,QAAQ;AAC/B,UAAM,EAAE,GAAG,IAAI,kBAAkB,MAAM;AACvC,QAAI;AACF,SAAG;AAAA,IACL,SAAS,GAAG;AACV,UAAI,KAAK,cAAe,MAAK,cAAc,CAAC;AAAA,IAC9C;AAAA,EACF;AAEA,MAAI,eAAe,QAAQ;AACzB,UAAM,QAAQ,eAAe,OAAO,CAAC;AACrC,mBAAe,MAAM;AACnB,iBAAW,EAAE,OAAO,OAAO,KAAK,MAAO,WAAU,OAAO,QAAQ,IAAI;AAAA,IACtE,CAAC;AAAA,EACH;AACF;AAEA,SAAS,UAAU,OAAc,QAAgB,MAAuB;AACtE,MAAI;AACF,UAAM,UAAU,OAAO,OAAO;AAC9B,WAAO,UAAU,OAAO,YAAY,aAAa,UAAU;AAC3D,QAAI,OAAO,SAAS;AAClB,YAAM,aAAa,CAAC;AACpB,YAAM,SAAS,KAAK,OAAO,OAAO;AAAA,IACpC;AAAA,EACF,SAAS,GAAG;AACV,QAAI,KAAK,cAAe,MAAK,cAAc,CAAC;AAAA,EAC9C;AACF;AAMA,SAAS,YAAY,MAAuB;AAC1C,SACE,KAAK,SAAS,KACd,KAAK,WAAW,CAAC,MAAM,OACvB,KAAK,WAAW,CAAC,MAAM,OACvB,KAAK,WAAW,CAAC,KAAK;AAE1B;",
6
6
  "names": ["f"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/redact",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "React, redacted. A minimal React-API-compatible drop-in replacement.",
5
5
  "type": "module",
6
6
  "main": "./dist/react/index.js",
@@ -78,10 +78,10 @@
78
78
  "optional": true
79
79
  }
80
80
  },
81
- "publishConfig": {
82
- "access": "public"
83
- },
84
81
  "scripts": {
85
82
  "build": "echo done-by-root-build"
83
+ },
84
+ "publishConfig": {
85
+ "access": "public"
86
86
  }
87
- }
87
+ }
@@ -50,7 +50,17 @@ function depsEqual(
50
50
  return true
51
51
  }
52
52
 
53
+ // Singleton — every method reads render context via ReactSharedInternals,
54
+ // and per-hook closures live on the hook itself, so nothing is render-local
55
+ // to capture. Allocating a fresh wrapper + 17 method closures per function-
56
+ // component render was pure GC pressure.
57
+ const DISPATCHER = makeDispatcherImpl()
58
+
53
59
  export function makeDispatcher() {
60
+ return DISPATCHER
61
+ }
62
+
63
+ function makeDispatcherImpl() {
54
64
  return {
55
65
  useState<S>(initial: S | (() => S)) {
56
66
  return this.useReducer<S, S | ((p: S) => S)>(
@@ -209,20 +209,15 @@ function rerenderFiber(fiber: Fiber, root: FiberRoot): void {
209
209
  // Element → children normalization
210
210
  // ---------------------------------------------------------------------------
211
211
 
212
- type TextChild = { _text: string }
213
- type NormalizedChild = ReactElement | TextChild | null
214
-
215
- // NEVER use `'_text' in child` to distinguish text wrappers from elements.
216
- // TanStack's RSC renderable proxies (createRscProxy with renderable: true) are
217
- // Proxy wrappers around real React elements whose `has` trap returns `true`
218
- // for ANY string key — so `'_text' in rscProxy` is TRUE even though the proxy
219
- // is an element. That misidentification set a Text fiber's `pendingProps` to
220
- // `child._text` (another chained RSC proxy), which then rendered as
221
- // `[object Object]` when createTextNode stringified the element. React
222
- // elements always carry `$$typeof`; our text wrapper never does — so the
223
- // presence of `$$typeof` is the invariant we rely on.
224
- function isTextChild(child: Exclude<NormalizedChild, null>): child is TextChild {
225
- return (child as any).$$typeof === undefined
212
+ // Text children pass through as raw strings — no wrapper. The previous
213
+ // `{_text: string}` shape allocated tens of thousands of objects per
214
+ // stable-list re-render and dominated minor-GC pressure. `typeof === 'string'`
215
+ // is also robust to RSC renderable proxies (which have `has` traps that
216
+ // would fool a `'_text' in child` predicate but can't fool `typeof`).
217
+ type NormalizedChild = ReactElement | string | null
218
+
219
+ function isTextChild(child: Exclude<NormalizedChild, null>): child is string {
220
+ return typeof child === 'string'
226
221
  }
227
222
 
228
223
  export function childrenToArray(children: ReactNode): NormalizedChild[] {
@@ -233,11 +228,15 @@ export function childrenToArray(children: ReactNode): NormalizedChild[] {
233
228
 
234
229
  function pushChildren(node: ReactNode, out: NormalizedChild[]): void {
235
230
  if (node == null || typeof node === 'boolean') return
236
- if (typeof node === 'string' || typeof node === 'number') {
231
+ if (typeof node === 'string') {
237
232
  // Empty strings render no text node (matches React + the `<!-- -->`
238
233
  // separator elision on the SSR side so server/client agree).
239
234
  if (node === '') return
240
- out.push({ _text: '' + node })
235
+ out.push(node)
236
+ return
237
+ }
238
+ if (typeof node === 'number') {
239
+ out.push('' + node)
241
240
  return
242
241
  }
243
242
  if (Array.isArray(node)) {
@@ -298,7 +297,7 @@ function fiberFromChild(child: NormalizedChild, parent: Fiber): Fiber {
298
297
  if (!child) return createFiber(FiberTag.Fragment, null, null)
299
298
  if (isTextChild(child)) {
300
299
  const f = createFiber(FiberTag.Text, null, null)
301
- f.pendingProps = child._text
300
+ f.pendingProps = child
302
301
  f.parent = parent
303
302
  return f
304
303
  }
@@ -344,6 +343,43 @@ export function reconcileChildren(
344
343
  domParent: Node,
345
344
  anchor: Node | null,
346
345
  ): void {
346
+ // Fast path: unkeyed positional steady-state. Walk the existing sibling
347
+ // chain and newChildren in lockstep, validating AND committing in one pass.
348
+ // On any divergence we fall back to the slow path, which rebuilds the
349
+ // sibling chain anyway — partial pendingProps writes are idempotent.
350
+ // Skips the Map / Set / existing-array allocation entirely.
351
+ if (!currentRoot?.hydrating) {
352
+ let f: Fiber | null = parent.child
353
+ let ok = true
354
+ for (let i = 0; i < newChildren.length; i++) {
355
+ const child = newChildren[i]
356
+ if (child == null || !f || f.key != null) { ok = false; break }
357
+ if (typeof child === 'string') {
358
+ if (f.tag !== FiberTag.Text) { ok = false; break }
359
+ f.pendingProps = child
360
+ } else {
361
+ if ((child as ReactElement).key != null) { ok = false; break }
362
+ if (f.type !== (child as ReactElement).type) { ok = false; break }
363
+ f.pendingProps = (child as ReactElement).props
364
+ f.ref = (child as any).ref ?? null
365
+ }
366
+ f = f.sibling
367
+ }
368
+ if (ok && f === null) {
369
+ // Pass 2: render forward with per-child anchors. Identical to the slow
370
+ // path's pass 2.
371
+ for (let r: Fiber | null = parent.child; r; r = r.sibling) {
372
+ let a = anchor
373
+ for (let s: Fiber | null = r.sibling; s; s = s.sibling) {
374
+ const d = firstDomNode(s)
375
+ if (d && d.parentNode === domParent) { a = d; break }
376
+ }
377
+ renderFiber(r, domParent, a)
378
+ }
379
+ return
380
+ }
381
+ }
382
+
347
383
  const existing = collectChildren(parent)
348
384
  const keyed = new Map<string, Fiber>()
349
385
  for (const f of existing) {
@@ -431,7 +467,7 @@ export function reconcileChildren(
431
467
  claimed.add(match)
432
468
  fiber = match
433
469
  if (isTextChild(child!)) {
434
- fiber.pendingProps = child._text
470
+ fiber.pendingProps = child
435
471
  } else {
436
472
  fiber.type = (child as ReactElement).type
437
473
  fiber.pendingProps = (child as ReactElement).props
@@ -675,13 +711,17 @@ export function renderFiber(fiber: Fiber, domParent: Node, anchor: Node | null):
675
711
 
676
712
  function renderText(fiber: Fiber, domParent: Node, anchor: Node | null): void {
677
713
  const text = fiber.pendingProps as string
714
+ // Identity-unchanged fast path: skip the native Text.data write entirely.
715
+ if (fiber.dom && fiber.memoizedProps === text) return
678
716
  if (!fiber.dom) {
679
717
  const hydrated = currentRoot?.hydrating ? adoptTextDom(fiber, fiber.parent!, text) : false
680
718
  if (!hydrated) {
681
719
  fiber.dom = document.createTextNode(text)
682
720
  insertInto(domParent, fiber.dom, anchor)
683
721
  }
684
- } else if ((fiber.dom as Text).data !== text) {
722
+ } else {
723
+ // Past the fast path, and adoptTextDom already realigned `.data` on
724
+ // hydration — `.data !== text` here is guaranteed, so write directly.
685
725
  ;(fiber.dom as Text).data = text
686
726
  }
687
727
  fiber.memoizedProps = text
@@ -724,24 +764,38 @@ function renderHost(fiber: Fiber, domParent: Node, anchor: Node | null): void {
724
764
  insertInto(domParent, fiber.dom, anchor)
725
765
  }
726
766
  attachRef(fiber, fiber.dom)
727
- } else {
767
+ } else if (prev !== props) {
728
768
  const el = fiber.dom as Element
729
- for (const k in prev) {
730
- if (!(k in props)) setProp(el, k, undefined, prev[k], isSvg)
731
- }
732
- // Non-event props first for the same reason as above: a `type` change
733
- // must land before we ask setEventHandler to resolve the DOM event for
734
- // `onChange`.
769
+ // Single-pass diff. Defer changed event props into a small array so the
770
+ // `type-before-events` invariant the mount path needs (setEventHandler
771
+ // reads `el.type` to resolve onChange→input vs change) still holds when
772
+ // a render flips both `type` and an event handler in the same pass.
773
+ // The vast majority of host updates have no events at all (e.g. data-*
774
+ // attributes flipping on a stable list), so the deferred array stays
775
+ // null and we collapse to one for-in over `props`.
776
+ let deferredEvents: string[] | null = null
735
777
  for (const k in props) {
736
778
  if (isSelect && (k === 'value' || k === 'defaultValue')) continue
737
- if (isEventProp(k)) continue
779
+ if (isEventProp(k)) {
780
+ if (prev[k] !== props[k]) {
781
+ deferredEvents ||= []
782
+ deferredEvents.push(k)
783
+ }
784
+ continue
785
+ }
738
786
  if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg)
739
787
  }
740
- for (const k in props) {
741
- if (!isEventProp(k)) continue
742
- if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg)
788
+ // Removals keys present in prev but not in props.
789
+ for (const k in prev) {
790
+ if (!(k in props)) setProp(el, k, undefined, prev[k], isSvg)
791
+ }
792
+ if (deferredEvents) {
793
+ for (let i = 0; i < deferredEvents.length; i++) {
794
+ const k = deferredEvents[i]!
795
+ setProp(el, k, props[k], prev[k], isSvg)
796
+ }
743
797
  }
744
- if (prev !== props) syncRefIfChanged(fiber, fiber.dom)
798
+ syncRefIfChanged(fiber, fiber.dom)
745
799
  }
746
800
 
747
801
  // Children go into this DOM node