@tanstack/redact 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/core/internal.d.ts +23 -39
  2. package/dist/core/internal.js +7 -23
  3. package/dist/core/internal.js.map +3 -3
  4. package/dist/dom/dispatcher.d.ts +3 -1
  5. package/dist/dom/dispatcher.js +104 -97
  6. package/dist/dom/dispatcher.js.map +2 -2
  7. package/dist/dom/dom.js +1 -1
  8. package/dist/dom/dom.js.map +2 -2
  9. package/dist/dom/event-replay.js +7 -29
  10. package/dist/dom/event-replay.js.map +2 -2
  11. package/dist/dom/features/class/full.js +16 -16
  12. package/dist/dom/features/class/full.js.map +2 -2
  13. package/dist/dom/features/class/stub.js +7 -7
  14. package/dist/dom/features/class/stub.js.map +2 -2
  15. package/dist/dom/features/context/full.js +7 -7
  16. package/dist/dom/features/context/full.js.map +2 -2
  17. package/dist/dom/features/context/stub.js +3 -3
  18. package/dist/dom/features/context/stub.js.map +2 -2
  19. package/dist/dom/features/forward-ref/full.js +11 -11
  20. package/dist/dom/features/forward-ref/full.js.map +2 -2
  21. package/dist/dom/features/hydration/full.d.ts +26 -14
  22. package/dist/dom/features/hydration/full.js +412 -92
  23. package/dist/dom/features/hydration/full.js.map +2 -2
  24. package/dist/dom/features/hydration/stub.d.ts +13 -12
  25. package/dist/dom/features/hydration/stub.js +23 -8
  26. package/dist/dom/features/hydration/stub.js.map +2 -2
  27. package/dist/dom/features/lazy/full.js +3 -43
  28. package/dist/dom/features/lazy/full.js.map +2 -2
  29. package/dist/dom/features/lazy/stub.js +1 -1
  30. package/dist/dom/features/lazy/stub.js.map +2 -2
  31. package/dist/dom/features/memo/full.js +3 -3
  32. package/dist/dom/features/memo/full.js.map +2 -2
  33. package/dist/dom/features/memo/stub.js +1 -1
  34. package/dist/dom/features/memo/stub.js.map +2 -2
  35. package/dist/dom/features/portal/full.js +2 -2
  36. package/dist/dom/features/portal/full.js.map +2 -2
  37. package/dist/dom/features/suspense/full.js +151 -109
  38. package/dist/dom/features/suspense/full.js.map +2 -2
  39. package/dist/dom/reconcile.d.ts +3 -1
  40. package/dist/dom/reconcile.js +141 -129
  41. package/dist/dom/reconcile.js.map +2 -2
  42. package/dist/dom/root-internal.d.ts +9 -0
  43. package/dist/dom/root-internal.js +31 -0
  44. package/dist/dom/root-internal.js.map +7 -0
  45. package/dist/dom/root.d.ts +1 -1
  46. package/dist/dom/root.js +4 -136
  47. package/dist/dom/root.js.map +2 -2
  48. package/dist/dom/test-utils.js +1 -1
  49. package/dist/dom/test-utils.js.map +2 -2
  50. package/dist/react/children.js +4 -1
  51. package/dist/react/children.js.map +2 -2
  52. package/dist/react/class.js +8 -2
  53. package/dist/react/class.js.map +2 -2
  54. package/dist/react/context.js +4 -1
  55. package/dist/react/context.js.map +2 -2
  56. package/dist/react/index.js +1 -1
  57. package/dist/react/index.js.map +2 -2
  58. package/dist/react/shared-internals.d.ts +4 -7
  59. package/dist/react/shared-internals.js +4 -7
  60. package/dist/react/shared-internals.js.map +2 -2
  61. package/dist/server/stream.d.ts +5 -1
  62. package/dist/server/stream.js.map +2 -2
  63. package/package.json +1 -1
  64. package/src/core/internal.ts +30 -50
  65. package/src/dom/dispatcher.ts +114 -105
  66. package/src/dom/dom.ts +1 -1
  67. package/src/dom/event-replay.ts +14 -30
  68. package/src/dom/features/class/full.ts +16 -16
  69. package/src/dom/features/class/stub.ts +7 -7
  70. package/src/dom/features/context/full.ts +7 -7
  71. package/src/dom/features/context/stub.ts +3 -3
  72. package/src/dom/features/forward-ref/full.ts +11 -11
  73. package/src/dom/features/hydration/full.ts +516 -104
  74. package/src/dom/features/hydration/stub.ts +28 -14
  75. package/src/dom/features/lazy/full.ts +3 -56
  76. package/src/dom/features/lazy/stub.ts +1 -1
  77. package/src/dom/features/memo/full.ts +3 -3
  78. package/src/dom/features/memo/stub.ts +1 -1
  79. package/src/dom/features/portal/full.ts +2 -2
  80. package/src/dom/features/suspense/full.ts +176 -129
  81. package/src/dom/reconcile.ts +164 -170
  82. package/src/dom/root-internal.ts +40 -0
  83. package/src/dom/root.ts +5 -165
  84. package/src/dom/test-utils.ts +1 -1
  85. package/src/react/children.ts +4 -1
  86. package/src/react/class.ts +8 -2
  87. package/src/react/context.ts +4 -1
  88. package/src/react/index.ts +1 -1
  89. package/src/react/shared-internals.ts +8 -14
  90. package/src/server/stream.ts +9 -4
@@ -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\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\nexport function 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 const projectedHeadParent = getDocumentHeadInsertionParent(parent, node)\n if (projectedHeadParent) {\n projectedHeadParent.appendChild(node)\n return\n }\n\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\nconst DOCUMENT_HEAD_TAGS = new Set(['base', 'link', 'meta', 'script', 'style', 'title'])\n\nfunction getDocumentHeadInsertionParent(parent: Node, node: Node): HTMLHeadElement | null {\n if (parent.nodeType !== 9 || node.nodeType !== 1) return null\n const tag = (node as Element).tagName.toLowerCase()\n if (!DOCUMENT_HEAD_TAGS.has(tag)) return null\n return (parent as Document).head\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"],
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,c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ACtE,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 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 setHydrationCursor,\n getHydrationCursor,\n clearHydrationCursor,\n findHostParent as findHydrationHost,\n abortHydration,\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-um 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.um) return\n const root = findRoot(fiber)\n if (!root) return\n root.p.add(fiber)\n fiber.dy = true\n pendingRoots.add(root)\n if (isBatching) return\n if (!root.s) {\n root.s = 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 if (process.env.NODE_ENV !== 'production') {\n throw new Error('flushPending exceeded 50 iterations \u2014 suspected infinite update loop.')\n }\n throw new Error()\n }\n const roots = [...pendingRoots]\n pendingRoots.clear()\n for (const root of roots) {\n root.s = 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 `dy=true` (only\n // rerenderFiber clears it); when we later reach them in this loop,\n // rerenderFiber's own `if (!dy) return` is our short-circuit. We\n // previously filtered descendants of dy 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 // dy fibers and let rerenderFiber de-dupe via its dy check.\n const pending = [...root.p]\n root.p.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\nexport function discardPendingWork(root: FiberRoot): void {\n root.p.clear()\n root.s = false\n pendingRoots.delete(root)\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.r\n rootFiber.pp = { children }\n currentRoot = root\n try {\n reconcileChildren(rootFiber, childrenToArray(children), root.c as Node, null)\n rootFiber.mp = rootFiber.pp\n rootFiber.dy = false\n } finally {\n currentRoot = null\n }\n runEffects(root)\n}\n\nfunction rerenderFiber(fiber: Fiber, root: FiberRoot): void {\n if (!fiber.dy) return\n // Skip fibers that were um 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 (um during\n // Outlet's shallow-first render) still fires from root.pending.\n if (fiber.um) return\n // Clear BEFORE rendering so a scheduleUpdate() triggered mid-render (e.g.\n // error boundary catching a descendant throw) marks us dy for the next\n // flush iteration instead of being wiped out when render() completes.\n fiber.dy = 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.ms && (fiber.ms as any).p === true\n const prevHydrating = root.h\n if (resumeHydration) {\n delete (fiber.ms as any).p\n root.h = 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.h = 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[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.pp = 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.pp = 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 pp writes are idempotent.\n // Skips the Map / Set / existing-array allocation entirely.\n if (!currentRoot?.h) {\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.pp = 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.pp = (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 um\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 um 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.pp = child\n } else {\n fiber.type = (child as ReactElement).type\n fiber.pp = (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?.h\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 = (domParent as Element).nodeName === 'HEAD'\n if (structurallyChanged && !currentRoot?.h && !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.pp as string\n // Identity-unchanged fast path: skip the native Text.data write entirely.\n if (fiber.dom && fiber.mp === text) return\n if (!fiber.dom) {\n const hydrated = currentRoot?.h ? 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.mp = text\n // dy 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.pp ?? {}\n const prev = fiber.mp ?? {}\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?.h ? 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?.h) {\n const parentTag = (fiber.type as string).toLowerCase()\n const hasOpaqueHydrationChildren =\n props.dangerouslySetInnerHTML != null ||\n (parentTag === 'textarea' && (props.value != null || props.defaultValue != null))\n if (parentTag !== 'head' && parentTag !== 'html' && !hasOpaqueHydrationChildren) {\n const cursor = getHydrationCursor(fiber)\n if (cursor) {\n if (cursor.has()) {\n const error = new Error(\n process.env.NODE_ENV !== 'production'\n ? `Hydration mismatch: server rendered extra nodes inside <${parentTag}>.`\n : 'Hydration mismatch.',\n )\n if (currentRoot.re) currentRoot.re(error)\n abortHydration(error, fiber)\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.mp = props\n // dy 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.F\n const prevHook = ReactSharedInternals.K\n const prevIndex = ReactSharedInternals.I\n\n ReactSharedInternals.H = makeDispatcher()\n ReactSharedInternals.F = fiber\n ReactSharedInternals.K = null\n ReactSharedInternals.I = 0\n\n let rendered: ReactNode\n let deferredForHydration = false\n try {\n rendered = (fiber.type as Function)(fiber.pp ?? {})\n } catch (e: any) {\n if (isThenable(e)) {\n if (deferHydration(fiber, e)) {\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.F = prevFiber\n ReactSharedInternals.K = prevHook\n ReactSharedInternals.I = prevIndex\n }\n\n if (deferredForHydration) return\n\n reconcileChildren(fiber, childrenToArray(rendered), domParent, anchor)\n fiber.mp = fiber.pp\n // dy 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\nexport function deferHydration(fiber: Fiber, thenable: Promise<any>): boolean {\n if (!currentRoot?.h) return false\n const hostParent = findHydrationHost(fiber)\n const inheritedCursor = getHydrationCursor(hostParent)\n if (inheritedCursor) setHydrationCursor(fiber, inheritedCursor)\n ;((fiber.ms ??= {}) as any).p = true\n let sus: Fiber | null = fiber.parent\n while (sus && sus.tag !== FiberTag.Suspense) sus = sus.parent\n if (sus && sus.ms) {\n ;(sus.ms as any).a = true\n }\n const clearAwait = () => {\n if (sus && sus.ms) {\n ;(sus.ms as any).a = false\n }\n scheduleUpdate(fiber)\n }\n thenable.then(clearAwait, clearAwait)\n return true\n}\n\nfunction renderFragment(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const props = fiber.pp ?? {}\n reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)\n fiber.mp = props\n // dy 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 if (currentRoot?.h) {\n abortHydration(err, fiber)\n }\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.sn\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?.ue) currentRoot.ue(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\nexport function unmountFiber(fiber: Fiber, domParent: Node): void {\n fiber.um = 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 cu (fx + layout fx)\n if (fiber.cu) {\n for (const cleanup of fiber.cu) {\n try {\n cleanup()\n } catch (e) {\n if (currentRoot?.re) currentRoot.re(e)\n }\n }\n fiber.cu = null\n }\n\n if (fiber.tag === FiberTag.Class && fiber.sn?.componentWillUnmount) {\n try {\n fiber.sn.componentWillUnmount()\n } catch (e) {\n if (currentRoot?.re) currentRoot.re(e)\n }\n fiber.sn._fiber = null\n fiber.sn._enqueueUpdate = null\n fiber.sn._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 const projectedHeadParent = getDocumentHeadInsertionParent(parent, node)\n if (projectedHeadParent) {\n projectedHeadParent.appendChild(node)\n return\n }\n\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\nconst DOCUMENT_HEAD_TAGS = new Set(['base', 'link', 'meta', 'script', 'style', 'title'])\n\nfunction getDocumentHeadInsertionParent(parent: Node, node: Node): HTMLHeadElement | null {\n if (parent.nodeType !== 9 || node.nodeType !== 1) return null\n const tag = (node as Element).tagName.toLowerCase()\n if (!DOCUMENT_HEAD_TAGS.has(tag)) return null\n return (parent as Document).head\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.sn as Node) || (p.dom as Node) || (p.root?.c 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.pp ?? p.mp) as { container?: Element } | null\n return (props?.container as Node) || (p.sn as Node) || (p.dom as Node) || (p.root?.c as Node)\n }\n p = p.parent\n }\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('No host parent found.')\n }\n throw new Error()\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.pp?.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.cu ||= []\n fiber.cu.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.pp?.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.cu (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, Effect]> = []\nconst pendingLayoutEffects: Array<[Fiber, Effect]> = []\nconst pendingLifecycles: Array<() => void> = []\n\nexport function enqueueEffect(fiber: Fiber, effect: Effect): void {\n if (effect.t) {\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(fn)\n}\n\nexport function runEffects(root: FiberRoot): void {\n // Layout fx 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.ce) root.ce(e)\n }\n }\n // Passive fx 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.c()\n if (typeof cleanup == 'function') {\n fiber.cu ||= []\n fiber.cu.push(cleanup)\n }\n } catch (e) {\n if (root.ce) root.ce(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"],
5
+ "mappings": ";AAAA;AAAA,EACE;AAAA,EACA;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,EAC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E;AAC3B;AAEO,SAAS,WAAW,MAAuB;AAEhD,SAAO,qBAAqB,QAAQ;AAClC,UAAM,CAAC,OAAO,MAAM,IAAI,qBAAqB,MAAM;AACnD,cAAU,OAAO,QAAQ,IAAI;AAAA,EAC/B;AAEA,SAAO,kBAAkB,QAAQ;AAC/B,UAAM,KAAK,kBAAkB,MAAM;AACnC,QAAI;AACF,SAAG;AAAA,IACL,SAAS,GAAG;AACV,UAAI,KAAK,GAAI,MAAK,GAAG,CAAC;AAAA,IACxB;AAAA,EACF;AAEA,MAAI,eAAe,QAAQ;AACzB,UAAM,QAAQ,eAAe,OAAO,CAAC;AACrC,mBAAe,MAAM;AACnB,iBAAW,CAAC,OAAO,MAAM,KAAK,MAAO,WAAU,OAAO,QAAQ,IAAI;AAAA,IACpE,CAAC;AAAA,EACH;AACF;AAEA,SAAS,UAAU,OAAc,QAAgB,MAAuB;AACtE,MAAI;AACF,UAAM,UAAU,OAAO,EAAE;AACzB,QAAI,OAAO,WAAW,YAAY;AAChC,YAAM,OAAO,CAAC;AACd,YAAM,GAAG,KAAK,OAAO;AAAA,IACvB;AAAA,EACF,SAAS,GAAG;AACV,QAAI,KAAK,GAAI,MAAK,GAAG,CAAC;AAAA,EACxB;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
  }
@@ -0,0 +1,9 @@
1
+ import { type FiberRoot } from '../core';
2
+ export interface RootOptionsInternal {
3
+ identifierPrefix?: string;
4
+ onRecoverableError?: (error: unknown) => void;
5
+ onCaughtError?: (error: unknown) => void;
6
+ onUncaughtError?: (error: unknown) => void;
7
+ }
8
+ export declare function createFiberRoot(container: Element | Document | DocumentFragment, options: RootOptionsInternal): FiberRoot;
9
+ export declare function attachRootFiber(root: FiberRoot, container: Element | Document | DocumentFragment): void;
@@ -0,0 +1,31 @@
1
+ // packages/redact/src/dom/root-internal.ts
2
+ import { FiberTag, createFiber } from "../core";
3
+ function createFiberRoot(container, options) {
4
+ const rootFiber = createFiber(FiberTag.Root, null, null);
5
+ const root = {
6
+ c: container,
7
+ r: rootFiber,
8
+ p: /* @__PURE__ */ new Set(),
9
+ s: false,
10
+ re: options.onRecoverableError,
11
+ ce: options.onCaughtError,
12
+ ue: options.onUncaughtError,
13
+ i: options.identifierPrefix ?? ":r",
14
+ h: false
15
+ };
16
+ rootFiber.root = root;
17
+ rootFiber.sn = container;
18
+ return root;
19
+ }
20
+ function attachRootFiber(root, container) {
21
+ const rootFiber = createFiber(FiberTag.Root, null, null);
22
+ root.c = container;
23
+ rootFiber.root = root;
24
+ rootFiber.sn = container;
25
+ root.r = rootFiber;
26
+ }
27
+ export {
28
+ attachRootFiber,
29
+ createFiberRoot
30
+ };
31
+ //# sourceMappingURL=root-internal.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/root-internal.ts"],
4
+ "sourcesContent": ["import { FiberTag, createFiber, type Fiber, type FiberRoot } from '../core'\n\nexport interface RootOptionsInternal {\n identifierPrefix?: string\n onRecoverableError?: (error: unknown) => void\n onCaughtError?: (error: unknown) => void\n onUncaughtError?: (error: unknown) => void\n}\n\nexport function createFiberRoot(\n container: Element | Document | DocumentFragment,\n options: RootOptionsInternal,\n): FiberRoot {\n const rootFiber = createFiber(FiberTag.Root, null, null)\n const root: FiberRoot = {\n c: container as any,\n r: rootFiber,\n p: new Set(),\n s: false,\n re: options.onRecoverableError,\n ce: options.onCaughtError,\n ue: options.onUncaughtError,\n i: options.identifierPrefix ?? ':r',\n h: false,\n }\n rootFiber.root = root\n rootFiber.sn = container\n return root\n}\n\nexport function attachRootFiber(\n root: FiberRoot,\n container: Element | Document | DocumentFragment,\n): void {\n const rootFiber = createFiber(FiberTag.Root, null, null)\n root.c = container as any\n rootFiber.root = root\n rootFiber.sn = container\n root.r = rootFiber\n}\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU,mBAA+C;AAS3D,SAAS,gBACd,WACA,SACW;AACX,QAAM,YAAY,YAAY,SAAS,MAAM,MAAM,IAAI;AACvD,QAAM,OAAkB;AAAA,IACtB,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG,oBAAI,IAAI;AAAA,IACX,GAAG;AAAA,IACH,IAAI,QAAQ;AAAA,IACZ,IAAI,QAAQ;AAAA,IACZ,IAAI,QAAQ;AAAA,IACZ,GAAG,QAAQ,oBAAoB;AAAA,IAC/B,GAAG;AAAA,EACL;AACA,YAAU,OAAO;AACjB,YAAU,KAAK;AACf,SAAO;AACT;AAEO,SAAS,gBACd,MACA,WACM;AACN,QAAM,YAAY,YAAY,SAAS,MAAM,MAAM,IAAI;AACvD,OAAK,IAAI;AACT,YAAU,OAAO;AACjB,YAAU,KAAK;AACf,OAAK,IAAI;AACX;",
6
+ "names": []
7
+ }
@@ -1,4 +1,4 @@
1
- import { type ReactNode } from '../core';
1
+ import type { ReactNode } from '../core';
2
2
  import { flushSyncWork, batchedUpdates } from './reconcile';
3
3
  export interface RootOptions {
4
4
  identifierPrefix?: string;
package/dist/dom/root.js CHANGED
@@ -1,32 +1,9 @@
1
1
  // packages/redact/src/dom/root.ts
2
- import {
3
- FiberTag,
4
- REACT_ELEMENT_TYPE,
5
- createFiber
6
- } from "../core";
7
2
  import { renderRoot, flushSyncWork, batchedUpdates } from "./reconcile";
8
- import {
9
- beginHydration,
10
- endHydration,
11
- drainReplayQueue,
12
- installHydrationScrollGuard
13
- } from "./features/hydration";
3
+ import { hydrateRootImpl } from "./features/hydration";
4
+ import { createFiberRoot } from "./root-internal";
14
5
  function createRoot(container, options = {}) {
15
- const rootFiber = createFiber(FiberTag.Root, null, null);
16
- rootFiber.dom = container;
17
- const root = {
18
- container,
19
- current: rootFiber,
20
- pending: /* @__PURE__ */ new Set(),
21
- scheduled: false,
22
- onRecoverableError: options.onRecoverableError,
23
- onCaughtError: options.onCaughtError,
24
- onUncaughtError: options.onUncaughtError,
25
- identifierPrefix: options.identifierPrefix ?? ":r",
26
- hydrating: false
27
- };
28
- rootFiber.root = root;
29
- rootFiber.stateNode = container;
6
+ const root = createFiberRoot(container, options);
30
7
  let firstRender = true;
31
8
  return {
32
9
  render(children) {
@@ -49,116 +26,7 @@ function createRoot(container, options = {}) {
49
26
  };
50
27
  }
51
28
  function hydrateRoot(container, initialChildren, options = {}) {
52
- const target = container;
53
- const rootFiber = createFiber(FiberTag.Root, null, null);
54
- rootFiber.dom = target;
55
- const root = {
56
- container: target,
57
- current: rootFiber,
58
- pending: /* @__PURE__ */ new Set(),
59
- scheduled: false,
60
- onRecoverableError: options.onRecoverableError,
61
- onCaughtError: options.onCaughtError,
62
- onUncaughtError: options.onUncaughtError,
63
- identifierPrefix: options.identifierPrefix ?? ":r",
64
- hydrating: false
65
- };
66
- rootFiber.root = root;
67
- rootFiber.stateNode = target;
68
- installHydrationScrollGuard();
69
- beginHydration(root);
70
- try {
71
- const normalizedInitialChildren = isDocumentContainer(container) ? normalizeDocumentChildren(initialChildren) : initialChildren;
72
- flushSyncWork(() => {
73
- renderRoot(root, normalizedInitialChildren);
74
- });
75
- } finally {
76
- endHydration(root);
77
- }
78
- drainReplayQueue();
79
- return {
80
- render(children) {
81
- flushSyncWork(() => {
82
- renderRoot(root, isDocumentContainer(container) ? normalizeDocumentChildren(children) : children);
83
- });
84
- },
85
- unmount() {
86
- flushSyncWork(() => {
87
- renderRoot(root, null);
88
- });
89
- }
90
- };
91
- }
92
- var HEAD_TAGS = /* @__PURE__ */ new Set(["base", "link", "meta", "script", "style", "title"]);
93
- function isDocumentContainer(container) {
94
- return !!container && container.nodeType === 9;
95
- }
96
- function normalizeDocumentChildren(children) {
97
- const list = toChildArray(children);
98
- const htmlIndex = list.findIndex((child) => isHostElement(child, "html"));
99
- if (htmlIndex === -1) return children;
100
- const headNodes = list.filter(isHeadElement);
101
- if (headNodes.length === 0) return children;
102
- const htmlElement = list[htmlIndex];
103
- const normalizedHtml = hoistIntoHtmlHead(htmlElement, headNodes);
104
- return list.filter((child, index) => index === htmlIndex || !isHeadElement(child)).map((child) => child === htmlElement ? normalizedHtml : child);
105
- }
106
- function hoistIntoHtmlHead(htmlElement, headNodes) {
107
- const htmlChildren = toChildArray(htmlElement.props?.children);
108
- const headIndex = htmlChildren.findIndex((child) => isHostElement(child, "head"));
109
- let nextChildren;
110
- if (headIndex === -1) {
111
- nextChildren = [
112
- createHostElement("head", { children: headNodes }),
113
- ...htmlChildren
114
- ];
115
- } else {
116
- const headElement = htmlChildren[headIndex];
117
- const existingHeadChildren = toChildArray(headElement.props?.children);
118
- const nextHead = {
119
- ...headElement,
120
- props: {
121
- ...headElement.props,
122
- children: [...headNodes, ...existingHeadChildren]
123
- }
124
- };
125
- nextChildren = htmlChildren.map((child, index) => index === headIndex ? nextHead : child);
126
- }
127
- return {
128
- ...htmlElement,
129
- props: {
130
- ...htmlElement.props,
131
- children: nextChildren
132
- }
133
- };
134
- }
135
- function toChildArray(children) {
136
- if (children == null || typeof children === "boolean") return [];
137
- if (Array.isArray(children)) return children;
138
- if (isReactElement(children)) return [children];
139
- if (typeof children !== "string" && isIterable(children)) return Array.from(children);
140
- return [children];
141
- }
142
- function isHeadElement(value) {
143
- return isReactElement(value) && typeof value.type === "string" && HEAD_TAGS.has(value.type);
144
- }
145
- function isHostElement(value, tag) {
146
- return isReactElement(value) && value.type === tag;
147
- }
148
- function isReactElement(value) {
149
- return !!value && typeof value === "object" && value.$$typeof === REACT_ELEMENT_TYPE;
150
- }
151
- function isIterable(value) {
152
- return !!value && typeof value[Symbol.iterator] === "function";
153
- }
154
- function createHostElement(type, props) {
155
- return {
156
- $$typeof: REACT_ELEMENT_TYPE,
157
- type,
158
- key: null,
159
- ref: null,
160
- props
161
- };
29
+ return hydrateRootImpl(container, initialChildren, options);
162
30
  }
163
31
  export {
164
32
  batchedUpdates,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/root.ts"],
4
- "sourcesContent": ["import {\n FiberTag,\n REACT_ELEMENT_TYPE,\n createFiber,\n type FiberRoot,\n type ReactElement,\n type ReactNode,\n} from '../core'\nimport { renderRoot, flushSyncWork, batchedUpdates } from './reconcile'\nimport {\n beginHydration,\n endHydration,\n drainReplayQueue,\n installHydrationScrollGuard,\n} from './features/hydration'\n\nexport interface RootOptions {\n identifierPrefix?: string\n onRecoverableError?: (error: unknown) => void\n onCaughtError?: (error: unknown) => void\n onUncaughtError?: (error: unknown) => void\n}\n\nexport interface Root {\n render(children: ReactNode): void\n unmount(): void\n}\n\nexport function createRoot(container: Element | DocumentFragment, options: RootOptions = {}): Root {\n const rootFiber = createFiber(FiberTag.Root, null, null)\n rootFiber.dom = container\n const root: FiberRoot = {\n container,\n current: rootFiber,\n pending: new Set(),\n scheduled: false,\n onRecoverableError: options.onRecoverableError,\n onCaughtError: options.onCaughtError,\n onUncaughtError: options.onUncaughtError,\n identifierPrefix: options.identifierPrefix ?? ':r',\n hydrating: false,\n }\n rootFiber.root = root\n rootFiber.stateNode = container\n\n let firstRender = true\n return {\n render(children) {\n if (firstRender) {\n firstRender = false\n // Match real React's `clearContainer` semantics: blow away any pre-render\n // markup (server-rendered placeholder, splash shells, etc.) on the\n // initial commit so it doesn't stack with the React tree.\n if ((container as Node).nodeType === 1 /* ELEMENT_NODE */) {\n ;(container as Element).textContent = ''\n }\n }\n flushSyncWork(() => {\n renderRoot(root, children)\n })\n },\n unmount() {\n flushSyncWork(() => {\n renderRoot(root, null)\n })\n },\n }\n}\n\nexport function hydrateRoot(\n container: Element | Document,\n initialChildren: ReactNode,\n options: RootOptions = {},\n): Root {\n // `container` may be the Document when the React tree renders <html>...</html>\n // (e.g. TanStack Start's default client entry). In that case we adopt\n // documentElement as a CHILD of the root, not as the root itself \u2014 otherwise\n // we'd try to render <html> inside <html>.\n const target = container as any as Element | Document\n const rootFiber = createFiber(FiberTag.Root, null, null)\n rootFiber.dom = target as unknown as Node\n const root: FiberRoot = {\n container: target as any,\n current: rootFiber,\n pending: new Set(),\n scheduled: false,\n onRecoverableError: options.onRecoverableError,\n onCaughtError: options.onCaughtError,\n onUncaughtError: options.onUncaughtError,\n identifierPrefix: options.identifierPrefix ?? ':r',\n hydrating: false,\n }\n rootFiber.root = root\n rootFiber.stateNode = target\n\n // Preserve the user's scroll position across hydration (see feature impl\n // for the details). No-op in SSR; no-op in the stub.\n installHydrationScrollGuard()\n\n beginHydration(root)\n try {\n const normalizedInitialChildren =\n isDocumentContainer(container) ? normalizeDocumentChildren(initialChildren) : initialChildren\n flushSyncWork(() => {\n renderRoot(root, normalizedInitialChildren)\n })\n } finally {\n endHydration(root)\n }\n drainReplayQueue()\n\n return {\n render(children) {\n flushSyncWork(() => {\n renderRoot(root, isDocumentContainer(container) ? normalizeDocumentChildren(children) : children)\n })\n },\n unmount() {\n flushSyncWork(() => {\n renderRoot(root, null)\n })\n },\n }\n}\n\nconst HEAD_TAGS = new Set(['base', 'link', 'meta', 'script', 'style', 'title'])\n\nfunction isDocumentContainer(container: unknown): container is Document {\n return !!container && (container as Node).nodeType === 9\n}\n\nfunction normalizeDocumentChildren(children: ReactNode): ReactNode {\n const list = toChildArray(children)\n const htmlIndex = list.findIndex((child) => isHostElement(child, 'html'))\n if (htmlIndex === -1) return children\n\n const headNodes = list.filter(isHeadElement)\n if (headNodes.length === 0) return children\n\n const htmlElement = list[htmlIndex] as ReactElement\n const normalizedHtml = hoistIntoHtmlHead(htmlElement, headNodes)\n return list\n .filter((child, index) => index === htmlIndex || !isHeadElement(child))\n .map((child) => (child === htmlElement ? normalizedHtml : child))\n}\n\nfunction hoistIntoHtmlHead(htmlElement: ReactElement, headNodes: ReactNode[]): ReactElement {\n const htmlChildren = toChildArray(htmlElement.props?.children)\n const headIndex = htmlChildren.findIndex((child) => isHostElement(child, 'head'))\n let nextChildren: ReactNode[]\n\n if (headIndex === -1) {\n nextChildren = [\n createHostElement('head', { children: headNodes }),\n ...htmlChildren,\n ]\n } else {\n const headElement = htmlChildren[headIndex] as ReactElement\n const existingHeadChildren = toChildArray(headElement.props?.children)\n const nextHead = {\n ...headElement,\n props: {\n ...headElement.props,\n children: [...headNodes, ...existingHeadChildren],\n },\n }\n nextChildren = htmlChildren.map((child, index) => (index === headIndex ? nextHead : child))\n }\n\n return {\n ...htmlElement,\n props: {\n ...htmlElement.props,\n children: nextChildren,\n },\n }\n}\n\nfunction toChildArray(children: unknown): ReactNode[] {\n if (children == null || typeof children === 'boolean') return []\n if (Array.isArray(children)) return children as ReactNode[]\n if (isReactElement(children)) return [children]\n if (typeof children !== 'string' && isIterable(children)) return Array.from(children) as ReactNode[]\n return [children as ReactNode]\n}\n\nfunction isHeadElement(value: ReactNode): boolean {\n return isReactElement(value) && typeof value.type === 'string' && HEAD_TAGS.has(value.type)\n}\n\nfunction isHostElement(value: ReactNode, tag: string): boolean {\n return isReactElement(value) && value.type === tag\n}\n\nfunction isReactElement(value: unknown): value is ReactElement {\n return !!value && typeof value === 'object' && (value as ReactElement).$$typeof === REACT_ELEMENT_TYPE\n}\n\nfunction isIterable(value: unknown): value is Iterable<ReactNode> {\n return !!value && typeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] === 'function'\n}\n\nfunction createHostElement(type: string, props: Record<string, unknown>): ReactElement {\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type,\n key: null,\n ref: null,\n props,\n }\n}\n\nexport { flushSyncWork as flushSync, batchedUpdates }\n"],
5
- "mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,YAAY,eAAe,sBAAsB;AAC1D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAcA,SAAS,WAAW,WAAuC,UAAuB,CAAC,GAAS;AACjG,QAAM,YAAY,YAAY,SAAS,MAAM,MAAM,IAAI;AACvD,YAAU,MAAM;AAChB,QAAM,OAAkB;AAAA,IACtB;AAAA,I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UAAM,WAAW;AAAA,MACf,GAAG;AAAA,MACH,OAAO;AAAA,QACL,GAAG,YAAY;AAAA,QACf,UAAU,CAAC,GAAG,WAAW,GAAG,oBAAoB;AAAA,MAClD;AAAA,IACF;AACA,mBAAe,aAAa,IAAI,CAAC,OAAO,UAAW,UAAU,YAAY,WAAW,KAAM;AAAA,EAC5F;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,YAAY;AAAA,MACf,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAEA,SAAS,aAAa,UAAgC;AACpD,MAAI,YAAY,QAAQ,OAAO,aAAa,UAAW,QAAO,CAAC;AAC/D,MAAI,MAAM,QAAQ,QAAQ,EAAG,QAAO;AACpC,MAAI,eAAe,QAAQ,EAAG,QAAO,CAAC,QAAQ;AAC9C,MAAI,OAAO,aAAa,YAAY,WAAW,QAAQ,EAAG,QAAO,MAAM,KAAK,QAAQ;AACpF,SAAO,CAAC,QAAqB;AAC/B;AAEA,SAAS,cAAc,OAA2B;AAChD,SAAO,eAAe,KAAK,KAAK,OAAO,MAAM,SAAS,YAAY,UAAU,IAAI,MAAM,IAAI;AAC5F;AAEA,SAAS,cAAc,OAAkB,KAAsB;AAC7D,SAAO,eAAe,KAAK,KAAK,MAAM,SAAS;AACjD;AAEA,SAAS,eAAe,OAAuC;AAC7D,SAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAa,MAAuB,aAAa;AACtF;AAEA,SAAS,WAAW,OAA8C;AAChE,SAAO,CAAC,CAAC,SAAS,OAAQ,MAA0C,OAAO,QAAQ,MAAM;AAC3F;AAEA,SAAS,kBAAkB,MAAc,OAA8C;AACrF,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AAAA,IACL;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import type { ReactNode } from '../core'\nimport { renderRoot, flushSyncWork, batchedUpdates } from './reconcile'\nimport { hydrateRootImpl } from './features/hydration'\nimport { createFiberRoot } from './root-internal'\n\nexport interface RootOptions {\n identifierPrefix?: string\n onRecoverableError?: (error: unknown) => void\n onCaughtError?: (error: unknown) => void\n onUncaughtError?: (error: unknown) => void\n}\n\nexport interface Root {\n render(children: ReactNode): void\n unmount(): void\n}\n\nexport function createRoot(container: Element | DocumentFragment, options: RootOptions = {}): Root {\n const root = createFiberRoot(container, options)\n\n let firstRender = true\n return {\n render(children) {\n if (firstRender) {\n firstRender = false\n // Match real React's `clearContainer` semantics: blow away any pre-render\n // markup (server-rendered placeholder, splash shells, etc.) on the\n // initial commit so it doesn't stack with the React tree.\n if ((container as Node).nodeType === 1 /* ELEMENT_NODE */) {\n ;(container as Element).textContent = ''\n }\n }\n flushSyncWork(() => {\n renderRoot(root, children)\n })\n },\n unmount() {\n flushSyncWork(() => {\n renderRoot(root, null)\n })\n },\n }\n}\n\nexport function hydrateRoot(\n container: Element | Document,\n initialChildren: ReactNode,\n options: RootOptions = {},\n): Root {\n return hydrateRootImpl(container, initialChildren, options)\n}\n\nexport { flushSyncWork as flushSync, batchedUpdates }\n"],
5
+ "mappings": ";AACA,SAAS,YAAY,eAAe,sBAAsB;AAC1D,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAczB,SAAS,WAAW,WAAuC,UAAuB,CAAC,GAAS;AACjG,QAAM,OAAO,gBAAgB,WAAW,OAAO;AAE/C,MAAI,cAAc;AAClB,SAAO;AAAA,IACL,OAAO,UAAU;AACf,UAAI,aAAa;AACf,sBAAc;AAId,YAAK,UAAmB,aAAa,GAAsB;AACzD;AAAC,UAAC,UAAsB,cAAc;AAAA,QACxC;AAAA,MACF;AACA,oBAAc,MAAM;AAClB,mBAAW,MAAM,QAAQ;AAAA,MAC3B,CAAC;AAAA,IACH;AAAA,IACA,UAAU;AACR,oBAAc,MAAM;AAClB,mBAAW,MAAM,IAAI;AAAA,MACvB,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,YACd,WACA,iBACA,UAAuB,CAAC,GAClB;AACN,SAAO,gBAAgB,WAAW,iBAAiB,OAAO;AAC5D;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  // packages/redact/src/dom/test-utils.ts
2
2
  async function act(fn) {
3
3
  const r = fn();
4
- if (r && typeof r.then === "function") await r;
4
+ if (r && typeof r.then == "function") await r;
5
5
  for (let i = 0; i < 10; i++) await Promise.resolve();
6
6
  }
7
7
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/test-utils.ts"],
4
- "sourcesContent": ["export async function act(fn: () => any): Promise<void> {\n const r = fn()\n if (r && typeof r.then === 'function') await r\n // Drain pending microtasks\n for (let i = 0; i < 10; i++) await Promise.resolve()\n}\n"],
5
- "mappings": ";AAAA,eAAsB,IAAI,IAA8B;AACtD,QAAM,IAAI,GAAG;AACb,MAAI,KAAK,OAAO,EAAE,SAAS,WAAY,OAAM;AAE7C,WAAS,IAAI,GAAG,IAAI,IAAI,IAAK,OAAM,QAAQ,QAAQ;AACrD;",
4
+ "sourcesContent": ["export async function act(fn: () => any): Promise<void> {\n const r = fn()\n if (r && typeof r.then == 'function') await r\n // Drain pending microtasks\n for (let i = 0; i < 10; i++) await Promise.resolve()\n}\n"],
5
+ "mappings": ";AAAA,eAAsB,IAAI,IAA8B;AACtD,QAAM,IAAI,GAAG;AACb,MAAI,KAAK,OAAO,EAAE,QAAQ,WAAY,OAAM;AAE5C,WAAS,IAAI,GAAG,IAAI,IAAI,IAAK,OAAM,QAAQ,QAAQ;AACrD;",
6
6
  "names": []
7
7
  }
@@ -64,7 +64,10 @@ var Children = {
64
64
  },
65
65
  only(children) {
66
66
  if (!isValidElement(children)) {
67
- throw new Error("Children.only expected a single React element.");
67
+ if (true) {
68
+ throw new Error("Children.only expected a single React element.");
69
+ }
70
+ throw new Error();
68
71
  }
69
72
  return children;
70
73
  }