@tanstack/redact 0.0.17 → 0.0.18

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/reconcile.ts"],
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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,OACK;AAMP,IAAI,cAAgC;AACpC,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAM,eAAe,oBAAI,IAAe;AAUxC,IAAI,wBAAsC;AAEnC,SAAS,eAAe,OAAoB;AAKjD,MAAI,MAAM,GAAI;A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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;",
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 recoverHydration,\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 try {\n rerenderFiber(fiber, root)\n } catch (error) {\n if (!recoverHydration(root, error)) throw error\n break\n }\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 (\n parentTag !== 'head' &&\n parentTag !== 'html' &&\n parentTag !== 'body' &&\n !hasOpaqueHydrationChildren\n ) {\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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,OACK;AAMP,IAAI,cAAgC;AACpC,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAM,eAAe,oBAAI,IAAe;AAUxC,IAAI,wBAAsC;AAEnC,SAAS,eAAe,OAAoB;AAKjD,MAAI,MAAM,GAAI;AACd,QAAM,OAAO,SAAS,KAAK;AAC3B,MAAI,CAAC,KAAM;AACX,OAAK,EAAE,IAAI,KAAK;AAChB,QAAM,KAAK;AACX,eAAa,IAAI,IAAI;AACrB,MAAI,WAAY;AAChB,MAAI,CAAC,KAAK,GAAG;AACX,SAAK,IAAI;AACT,mBAAe,YAAY;AAAA,EAC7B;AACF;AAEO,SAAS,cAAc,IAAsB;AAClD,QAAM,cAAc;AACpB,eAAa;AACb,MAAI;AACF,OAAG;AAAA,EACL,UAAE;AACA,iBAAa;AAAA,EACf;AACA,eAAa;AACf;AAEO,SAAS,eAAkB,IAAgB;AAChD,QAAM,cAAc;AACpB,eAAa;AACb,MAAI;AACF,WAAO,GAAG;AAAA,EACZ,UAAE;AACA,iBAAa;AACb,QAAI,CAAC,YAAa,cAAa;AAAA,EACjC;AACF;AAEA,SAAS,eAAqB;AAC5B,MAAI,SAAU;AACd,aAAW;AACX,MAAI;AACF,QAAI,QAAQ;AACZ,WAAO,aAAa,OAAO,GAAG;AA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AC;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
  }
@@ -10,7 +10,7 @@ function createFiberRoot(container, options) {
10
10
  re: options.onRecoverableError,
11
11
  ce: options.onCaughtError,
12
12
  ue: options.onUncaughtError,
13
- i: options.identifierPrefix ?? ":r",
13
+ i: options.identifierPrefix,
14
14
  ic: 0,
15
15
  h: false
16
16
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 ic: 0,\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 root.ic = 0\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,IAAI;AAAA,IACJ,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,OAAK,KAAK;AACV,YAAU,OAAO;AACjB,YAAU,KAAK;AACf,OAAK,IAAI;AACX;",
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,\n ic: 0,\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 root.ic = 0\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;AAAA,IACX,IAAI;AAAA,IACJ,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,OAAK,KAAK;AACV,YAAU,OAAO;AACjB,YAAU,KAAK;AACf,OAAK,IAAI;AACX;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/redact",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "React, redacted. A minimal React-API-compatible drop-in replacement.",
5
5
  "type": "module",
6
6
  "main": "./dist/react/index.js",
@@ -78,10 +78,10 @@
78
78
  "optional": true
79
79
  }
80
80
  },
81
- "publishConfig": {
82
- "access": "public"
83
- },
84
81
  "scripts": {
85
82
  "build": "echo done-by-root-build"
83
+ },
84
+ "publishConfig": {
85
+ "access": "public"
86
86
  }
87
- }
87
+ }
@@ -57,7 +57,7 @@ export interface FiberRoot {
57
57
  re?: ((err: unknown) => void) | undefined
58
58
  ce?: ((err: unknown) => void) | undefined
59
59
  ue?: ((err: unknown) => void) | undefined
60
- i: string
60
+ i: string | undefined
61
61
  ic: number
62
62
  h: boolean
63
63
  }
@@ -209,9 +209,9 @@ function makeDispatcherImpl() {
209
209
  if (hook.s === undefined) {
210
210
  const fiber = getCurrentFiber()
211
211
  const root = findRootFromFiber(fiber)
212
- hook.s = root
213
- ? root.i + (root.ic++).toString(36)
214
- : ':r' + (idCounter++).toString(36)
212
+ const prefix = root?.i ?? (root?.h ? ':R' : ':r')
213
+ const id = root?.h ? root.ic++ : idCounter++
214
+ hook.s = prefix + id.toString(36)
215
215
  }
216
216
  return hook.s as string
217
217
  },
@@ -120,14 +120,7 @@ export class HydrationCursor {
120
120
  has(): boolean {
121
121
  let n = this.n
122
122
  while (n && n !== this.e) {
123
- if (n.nodeType === 1) {
124
- if ((n as Element).tagName === 'SCRIPT') {
125
- n = n.nextSibling
126
- continue
127
- }
128
- return true
129
- }
130
- if (n.nodeType === 3 && (n as Text).data.trim() !== '') return true
123
+ if (n.nodeType === 1 || n.nodeType === 3) return true
131
124
  n = n.nextSibling
132
125
  }
133
126
  return false
@@ -171,17 +164,12 @@ export function hydrateRootImpl(
171
164
  const target = container as any as Element | Document
172
165
  const isDocument = (container as Node).nodeType === 9
173
166
  const body = isDocument ? (target as Document).body : null
174
- const root = createFiberRoot(target, {
175
- ...options,
176
- identifierPrefix: options.identifierPrefix ?? ':R',
177
- })
167
+ const root = createFiberRoot(target, options)
178
168
 
179
169
  installHydrationScrollGuard()
180
170
 
181
171
  const normalizedInitialChildren =
182
172
  isDocument ? normalizeDocumentChildren(initialChildren) : initialChildren
183
- let documentBodyFallback = false
184
-
185
173
  let hydrationError: unknown = null
186
174
  beginHydration(root)
187
175
  try {
@@ -193,36 +181,7 @@ export function hydrateRootImpl(
193
181
  }
194
182
  endHydration(root)
195
183
 
196
- if (hydrationError) {
197
- if (!isHydrationBailout(hydrationError)) {
198
- throw hydrationError
199
- }
200
- let recoveryContainer: Element | Document = target
201
- let recoveryChildren = normalizedInitialChildren
202
- const hostRecovery = getRecoverableHostChildren(hydrationError)
203
- if (hostRecovery) {
204
- recoveryContainer = hostRecovery[0]
205
- recoveryChildren = hostRecovery[1]
206
- } else if (body) {
207
- const bodyChildren = getRecoverableDocumentBodyChildren(hydrationError)
208
- if (bodyChildren != null) {
209
- documentBodyFallback = true
210
- recoveryContainer = body
211
- recoveryChildren = bodyChildren
212
- }
213
- }
214
- resetAfterHydrationFailure(root, recoveryContainer)
215
- try {
216
- root.i = options.identifierPrefix ?? ':r'
217
- root.ic = 0
218
- flushSyncWork(() => {
219
- renderRoot(root, recoveryChildren)
220
- })
221
- } catch (clientError) {
222
- resetAfterHydrationFailure(root, recoveryContainer)
223
- throw clientError
224
- }
225
- }
184
+ if (hydrationError && !recoverHydration(root, hydrationError)) throw hydrationError
226
185
  drainReplayQueue()
227
186
 
228
187
  return {
@@ -231,7 +190,7 @@ export function hydrateRootImpl(
231
190
  const normalized = isDocument ? normalizeDocumentChildren(children) : children
232
191
  renderRoot(
233
192
  root,
234
- documentBodyFallback ? getStaticDocumentBodyChildren(normalized) ?? normalized : normalized,
193
+ root.c === body ? getStaticDocumentBodyChildren(normalized) ?? normalized : normalized,
235
194
  )
236
195
  })
237
196
  },
@@ -246,7 +205,7 @@ export function hydrateRootImpl(
246
205
  // Head elements that we match against server DOM by attribute signature.
247
206
  const HEAD_KEY_ATTRS: Record<string, ReadonlyArray<string>> = {
248
207
  link: ['rel', 'href', 'sizes', 'type'],
249
- meta: ['name', 'property', 'charset', 'http-equiv'],
208
+ meta: ['name', 'property', 'charSet', 'httpEquiv'],
250
209
  script: ['src', 'type'],
251
210
  }
252
211
 
@@ -262,21 +221,17 @@ function headAttrsMatch(
262
221
  ): boolean {
263
222
  if (CLAIMED.has(el)) return false
264
223
  if (!keys) return true
265
- let matched = false
266
224
  for (const k of keys) {
267
- const propVal = props[k] ?? (k === 'http-equiv' ? props.httpEquiv : undefined)
268
- const elVal = el.getAttribute(k)
269
- // If neither defines it, skip this key; if one defines it, they must match.
225
+ const propVal = props[k]
226
+ const elVal = el.getAttribute(attributeName(k))
270
227
  if (propVal == null && elVal == null) continue
271
- matched = true
272
- if (propVal == null || elVal == null) continue // tolerate missing on either side
273
- if (String(propVal) !== elVal) return false
228
+ if (propVal == null || elVal == null || String(propVal) !== elVal) return false
274
229
  }
275
- // At least one matching signal must be present.
276
- return matched
230
+ return true
277
231
  }
278
232
 
279
233
  export function beginHydration(root: FiberRoot): void {
234
+ root.ic = 0
280
235
  root.h = true
281
236
  hydrationCursors.set(root.r, new HydrationCursor(root.c))
282
237
  }
@@ -523,6 +478,33 @@ function isSafeHostRecoveryElement(fiber: Fiber): boolean {
523
478
  return tag !== 'html' && tag !== 'head' && tag !== 'body'
524
479
  }
525
480
 
481
+ export function recoverHydration(root: FiberRoot, error: unknown): boolean {
482
+ if (!isHydrationBailout(error)) return false
483
+
484
+ let container = root.c as Element | Document
485
+ let children = root.r.pp?.children ?? null
486
+ const hostRecovery = getRecoverableHostChildren(error)
487
+ if (hostRecovery) {
488
+ container = hostRecovery[0]
489
+ children = hostRecovery[1]
490
+ } else if (container.nodeType === 9) {
491
+ const bodyChildren = getRecoverableDocumentBodyChildren(error)
492
+ if (bodyChildren != null) {
493
+ container = (container as Document).body
494
+ children = bodyChildren
495
+ }
496
+ }
497
+
498
+ resetAfterHydrationFailure(root, container)
499
+ try {
500
+ flushSyncWork(() => renderRoot(root, children))
501
+ } catch (clientError) {
502
+ resetAfterHydrationFailure(root, container)
503
+ throw clientError
504
+ }
505
+ return true
506
+ }
507
+
526
508
  function resetAfterHydrationFailure(
527
509
  root: FiberRoot,
528
510
  container: Element | Document,
@@ -692,9 +674,13 @@ function validateHydrationProps(
692
674
  ) continue
693
675
 
694
676
  if (k === 'dangerouslySetInnerHTML') {
695
- const probe = document.createElement('div')
696
- probe.innerHTML = value?.__html ?? ''
697
- if ((el as HTMLElement).innerHTML !== probe.innerHTML) {
677
+ let html = '' + (value?.__html ?? '')
678
+ if (tag !== 'script' && tag !== 'style') {
679
+ const probe = document.createElement('div')
680
+ probe.innerHTML = html
681
+ html = probe.innerHTML
682
+ }
683
+ if ((el as HTMLElement).innerHTML !== html) {
698
684
  if (process.env.NODE_ENV !== 'production') {
699
685
  failHydration(
700
686
  fiber,
@@ -771,9 +757,6 @@ function validateHydrationProps(
771
757
  }
772
758
  const actualValue = el.getAttribute(attr)
773
759
  if (expectedValue !== actualValue) {
774
- if (attr === 'id' && expectedValue != null && actualValue != null) {
775
- continue
776
- }
777
760
  if (process.env.NODE_ENV !== 'production') {
778
761
  failHydration(
779
762
  fiber,
@@ -74,6 +74,10 @@ export function isHydrationBailout(_error: unknown): _error is HydrationBailoutE
74
74
  return false
75
75
  }
76
76
 
77
+ export function recoverHydration(_root: FiberRoot, _error: unknown): boolean {
78
+ return false
79
+ }
80
+
77
81
  export function abortHydration(cause: unknown, fiber: Fiber | null = null): never {
78
82
  const error = (cause instanceof Error ? cause : new Error('Hydration mismatch.')) as HydrationBailoutError
79
83
  ;(error as any).f = fiber
@@ -27,6 +27,7 @@ import {
27
27
  clearHydrationCursor,
28
28
  findHostParent as findHydrationHost,
29
29
  abortHydration,
30
+ recoverHydration,
30
31
  } from './features/hydration'
31
32
 
32
33
  // ---------------------------------------------------------------------------
@@ -117,7 +118,12 @@ function flushPending(): void {
117
118
  root.p.clear()
118
119
  pending.sort((a, b) => fiberDepth(a) - fiberDepth(b))
119
120
  for (const fiber of pending) {
120
- rerenderFiber(fiber, root)
121
+ try {
122
+ rerenderFiber(fiber, root)
123
+ } catch (error) {
124
+ if (!recoverHydration(root, error)) throw error
125
+ break
126
+ }
121
127
  }
122
128
  runEffects(root)
123
129
  }
@@ -815,7 +821,12 @@ function renderHost(fiber: Fiber, domParent: Node, anchor: Node | null): void {
815
821
  const hasOpaqueHydrationChildren =
816
822
  props.dangerouslySetInnerHTML != null ||
817
823
  (parentTag === 'textarea' && (props.value != null || props.defaultValue != null))
818
- if (parentTag !== 'head' && parentTag !== 'html' && !hasOpaqueHydrationChildren) {
824
+ if (
825
+ parentTag !== 'head' &&
826
+ parentTag !== 'html' &&
827
+ parentTag !== 'body' &&
828
+ !hasOpaqueHydrationChildren
829
+ ) {
819
830
  const cursor = getHydrationCursor(fiber)
820
831
  if (cursor) {
821
832
  if (cursor.has()) {