@tanstack/redact 0.0.15 → 0.0.16

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.
@@ -348,14 +348,19 @@ function findHostRecoveryParent(fiber) {
348
348
  return findNearestSafeHostAboveComposite(fiber.parent);
349
349
  }
350
350
  function findNearestSafeHostAboveComposite(fiber) {
351
+ let host = null;
351
352
  let f = fiber;
352
353
  while (f) {
353
354
  if (f.tag === FiberTag.Host && f.dom) {
354
- return isSafeHostRecoveryElement(f) ? f : null;
355
+ if (!isSafeHostRecoveryElement(f)) return null;
356
+ const parentTag = f.parent?.tag;
357
+ if (!host || parentTag > FiberTag.Text && parentTag < FiberTag.Suspense) {
358
+ host = f;
359
+ }
355
360
  }
356
361
  f = f.parent;
357
362
  }
358
- return null;
363
+ return host;
359
364
  }
360
365
  function isSafeHostRecoveryElement(fiber) {
361
366
  const tag = fiber.type.toLowerCase();
@@ -384,7 +389,7 @@ function clearHydrationContainer(container) {
384
389
  }
385
390
  function getRecoverableHostChildren(error) {
386
391
  const host = error.f;
387
- if (!host || host.tag !== FiberTag.Host || !host.dom || !isSafeHostRecoveryElement(host) || !findNearestSafeHostAboveComposite(host.parent)) {
392
+ if (host?.tag !== FiberTag.Host || !host.dom || !findNearestSafeHostAboveComposite(host.parent)) {
388
393
  return null;
389
394
  }
390
395
  return [host.dom, (host.pp ?? host.mp)?.children ?? null];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/dom/features/hydration/full.ts"],
4
- "sourcesContent": ["import {\n FiberTag,\n REACT_ELEMENT_TYPE,\n type Fiber,\n type FiberRoot,\n type ReactElement,\n type ReactNode,\n} from '../../../core'\nimport { createHostNode, setProp } from '../../dom'\nimport { drainReplayQueue } from '../../event-replay'\nimport { discardPendingWork, findRoot, flushSyncWork, renderRoot } from '../../reconcile'\nimport { attachRootFiber, createFiberRoot } from '../../root-internal'\n\n// Re-export from event-replay so all hydration concerns live behind one\n// feature boundary \u2014 the plugin's stub swap strips drainReplayQueue too.\nexport { drainReplayQueue }\n\n/**\n * Preserve the user's scroll position across hydration. If the user scrolled\n * between SSR paint and hydrate (common in dev where JS takes seconds to\n * load), libraries that wire scroll-restoration into a `useLayoutEffect`\n * near the root (e.g. TanStack Router) will run during our synchronous\n * hydrate and call `window.scrollTo(savedFromLastVisit)` \u2014 overwriting the\n * user's fresh scroll. We install a short-lived wrapper around scrollTo that\n * suppresses programmatic calls when a user-initiated scroll happened\n * recently. Only runs in the hydration feature \u2014 the stub skips it.\n */\nexport function installHydrationScrollGuard(): void {\n if (typeof window === 'undefined') return\n const w = window as any\n if (w._r) return\n const time = Date.now\n const guardStartedAt = w._r = time()\n let lastUserScrollAt = 0\n let programmatic = false\n w.addEventListener(\n 'scroll',\n () => {\n if (!programmatic) {\n lastUserScrollAt = time()\n }\n },\n { capture: true, passive: true },\n )\n const origScrollTo = w.scrollTo\n w.scrollTo = function (...args: any[]) {\n const now = time()\n if (\n now - guardStartedAt < 3000 &&\n now - lastUserScrollAt < 1500\n ) {\n return\n }\n programmatic = true\n try {\n return (origScrollTo as any).apply(w, args)\n } finally {\n queueMicrotask(() => {\n programmatic = false\n })\n }\n }\n}\n\n/**\n * Hydration cursor: walks existing DOM children in document order so we can\n * adopt them during fiber tree construction. One cursor per host parent.\n *\n * `endBefore` scopes the cursor to a subrange \u2014 used by rehydrateBoundary()\n * so we only adopt DOM up to the closing `/$` marker for that boundary.\n */\nexport class HydrationCursor {\n n: ChildNode | null\n p: Node\n e: ChildNode | null\n constructor(parent: Node, start: ChildNode | null = null, endBefore: ChildNode | null = null) {\n this.p = parent\n this.n = start ?? parent.firstChild\n this.e = endBefore\n }\n take(): ChildNode | null {\n while (this.n && this.n !== this.e) {\n const n = this.n\n // Skip anything that isn't an element (1) or text (3):\n // comments (8), doctype (10), processing instructions (7), cdata (4).\n if (n.nodeType !== 1 && n.nodeType !== 3) {\n this.n = n.nextSibling\n continue\n }\n this.n = n.nextSibling\n return n\n }\n return null\n }\n /**\n * Position-insensitive lookup for head/html adoption. Scans forward past\n * non-matching nodes without removing them, matching by tag AND the key\n * attributes that identify head elements uniquely (rel/href for links,\n * name/property for meta, src for script). Non-matching nodes stay in\n * place so the SSR'd stylesheet/script order is preserved.\n */\n head(tag: string, props: Record<string, any>): ChildNode | null {\n const target = tag.toLowerCase()\n const keyAttrs = HEAD_KEY_ATTRS[target]\n let scan = this.p.firstChild\n while (scan) {\n if (\n scan.nodeType === 1 &&\n (scan as Element).tagName.toLowerCase() === target &&\n headAttrsMatch(scan as Element, props, keyAttrs)\n ) {\n CLAIMED.add(scan)\n return scan\n }\n scan = scan.nextSibling\n }\n return null\n }\n has(): boolean {\n let n = this.n\n while (n && n !== this.e) {\n if (n.nodeType === 1 || n.nodeType === 3) return true\n n = n.nextSibling\n }\n return false\n }\n}\n\nconst hydrationCursors = new WeakMap<Fiber, HydrationCursor>()\nconst PROD_HYDRATION_ERROR = 'Hydration mismatch.'\n\nexport interface HydrationBailoutError extends Error {\n f: Fiber | null\n}\n\nexport function isHydrationBailout(error: unknown): error is HydrationBailoutError {\n return !!error && (error as any).f !== undefined\n}\n\nexport function abortHydration(cause: unknown, fiber: Fiber | null = null): never {\n const error = (cause instanceof Error ? cause : new Error(PROD_HYDRATION_ERROR)) as HydrationBailoutError\n ;(error as any).f = fiber\n throw error\n}\n\ninterface HydrateRootOptions {\n identifierPrefix?: string\n onRecoverableError?: (error: unknown) => void\n onCaughtError?: (error: unknown) => void\n onUncaughtError?: (error: unknown) => void\n}\n\ninterface HydratedRoot {\n render(children: ReactNode): void\n unmount(): void\n}\n\nexport function hydrateRootImpl(\n container: Element | Document,\n initialChildren: ReactNode,\n options: HydrateRootOptions,\n): HydratedRoot {\n const target = container as any as Element | Document\n const isDocument = (container as Node).nodeType === 9\n const body = isDocument ? (target as Document).body : null\n const root = createFiberRoot(target, options)\n\n installHydrationScrollGuard()\n\n const normalizedInitialChildren =\n isDocument ? normalizeDocumentChildren(initialChildren) : initialChildren\n let documentBodyFallback = false\n\n let hydrationError: unknown = null\n beginHydration(root)\n try {\n flushSyncWork(() => {\n renderRoot(root, normalizedInitialChildren)\n })\n } catch (e) {\n hydrationError = e\n }\n endHydration(root)\n\n if (hydrationError) {\n if (!isHydrationBailout(hydrationError)) {\n throw hydrationError\n }\n let recoveryContainer: Element | Document = target\n let recoveryChildren = normalizedInitialChildren\n const hostRecovery = getRecoverableHostChildren(hydrationError)\n if (hostRecovery) {\n recoveryContainer = hostRecovery[0]\n recoveryChildren = hostRecovery[1]\n } else if (body) {\n const bodyChildren = getRecoverableDocumentBodyChildren(hydrationError)\n if (bodyChildren != null) {\n documentBodyFallback = true\n recoveryContainer = body\n recoveryChildren = bodyChildren\n }\n }\n resetAfterHydrationFailure(root, recoveryContainer)\n try {\n flushSyncWork(() => {\n renderRoot(root, recoveryChildren)\n })\n } catch (clientError) {\n resetAfterHydrationFailure(root, recoveryContainer)\n throw clientError\n }\n }\n drainReplayQueue()\n\n return {\n render(children) {\n flushSyncWork(() => {\n const normalized = isDocument ? normalizeDocumentChildren(children) : children\n renderRoot(\n root,\n documentBodyFallback ? getStaticDocumentBodyChildren(normalized) ?? normalized : normalized,\n )\n })\n },\n unmount() {\n flushSyncWork(() => {\n renderRoot(root, null)\n })\n },\n }\n}\n\n// Head elements that we match against server DOM by attribute signature.\nconst HEAD_KEY_ATTRS: Record<string, ReadonlyArray<string>> = {\n link: ['rel', 'href', 'sizes', 'type'],\n meta: ['name', 'property', 'charset', 'http-equiv'],\n script: ['src', 'type'],\n}\n\nconst DOCUMENT_HEAD_TAGS = new Set(['base', 'link', 'meta', 'script', 'style', 'title'])\n\n// DOM elements already claimed by some fiber during this hydration pass.\nconst CLAIMED = new WeakSet<Node>()\n\nfunction headAttrsMatch(\n el: Element,\n props: Record<string, any>,\n keys: ReadonlyArray<string> | undefined,\n): boolean {\n if (CLAIMED.has(el)) return false\n if (!keys) return true\n let matched = false\n for (const k of keys) {\n const propVal = props[k] ?? (k === 'http-equiv' ? props.httpEquiv : undefined)\n const elVal = el.getAttribute(k)\n // If neither defines it, skip this key; if one defines it, they must match.\n if (propVal == null && elVal == null) continue\n matched = true\n if (propVal == null || elVal == null) continue // tolerate missing on either side\n if (String(propVal) !== elVal) return false\n }\n // At least one matching signal must be present.\n return matched\n}\n\nexport function beginHydration(root: FiberRoot): void {\n root.h = true\n hydrationCursors.set(root.r, new HydrationCursor(root.c))\n}\n\nexport function endHydration(root: FiberRoot): void {\n root.h = false\n hydrationCursors.delete(root.r)\n}\n\n/**\n * Inspect the current cursor position for a streaming-suspense boundary\n * marker emitted by the server. Returns info + advances the cursor past the\n * marker pair (start comment + fallback/real content + end comment).\n */\nexport type BoundaryInfo = [0 | 1, number, Comment, Comment]\n\nexport function tryConsumeBoundary(parent: Fiber): BoundaryInfo | null {\n const cursor = hydrationCursors.get(findHostParent(parent))\n if (!cursor) return null\n const peek = cursor.n\n if (!peek || peek.nodeType !== 8) return null\n const data = (peek as Comment).data\n const m = /^(\\$\\??)(\\d+)$/.exec(data)\n if (!m) return null\n const kind = m[1] === '$?' ? 1 : 0\n const id = Number(m[2])\n const startMark = peek as Comment\n // Advance past the start comment\n cursor.n = startMark.nextSibling\n // Locate end comment: closest <!--/$-->\n let endMark: Comment | null = null\n let scan = startMark.nextSibling\n while (scan) {\n if (scan.nodeType === 8 && (scan as Comment).data === '/$') {\n endMark = scan as Comment\n break\n }\n scan = scan.nextSibling\n }\n if (!endMark) return null\n return [kind, id, startMark, endMark]\n}\n\nexport function advanceCursorPast(parent: Fiber, node: Node): void {\n const cursor = hydrationCursors.get(findHostParent(parent))\n if (!cursor) return\n cursor.n = node.nextSibling\n}\n\nexport function getHydrationCursor(hostFiber: Fiber): HydrationCursor | undefined {\n return hydrationCursors.get(hostFiber)\n}\n\nexport function setHydrationCursor(hostFiber: Fiber, cursor: HydrationCursor): void {\n hydrationCursors.set(hostFiber, cursor)\n}\n\nexport function clearHydrationCursor(hostFiber: Fiber): void {\n hydrationCursors.delete(hostFiber)\n}\n\n/**\n * Try to adopt a DOM node for this host fiber. Returns true if adopted.\n * Attaches existing attrs/children via separate hydrate pass.\n */\nexport function adoptHostDom(fiber: Fiber, parent: Fiber): boolean {\n const hostParent = findHostParent(parent)\n const cursor = hydrationCursors.get(hostParent)\n if (!cursor) return false\n\n const tag = (fiber.type as string).toLowerCase()\n const documentHeadParent =\n cursor.p.nodeType === 9 && DOCUMENT_HEAD_TAGS.has(tag)\n ? (cursor.p as Document).head\n : null\n const parentEl = cursor.p as Element\n const parentTag =\n parentEl.nodeType === 1 ? (parentEl as Element).tagName.toLowerCase() : ''\n const isHeadish = parentTag === 'head' || parentTag === 'html' || !!documentHeadParent\n\n let candidate: ChildNode | null\n if (documentHeadParent) {\n // React 19 can project <meta>/<title>/<link> from anywhere in the tree into\n // document.head. Redact does not have that projection yet, so when a\n // document-root hydration pass sees a top-level head element, adopt it\n // from <head> rather than trying to append it beside <html>.\n candidate = new HydrationCursor(documentHeadParent).head(\n tag,\n fiber.pp ?? {},\n )\n } else if (isHeadish) {\n // Head/html children are position-insensitive \u2014 server may emit them in\n // a different order than the React tree (React 19 head hoisting, etc.).\n // Scan forward without removing non-matching nodes; match on attribute\n // signature so we don't adopt the wrong <link> and clobber its props.\n candidate = cursor.head(tag, fiber.pp ?? {})\n } else {\n candidate = cursor.take()\n }\n\n if (!candidate) {\n // Client expected a host here but the cursor is exhausted \u2014 server gave\n // fewer children than the client tree. Report the structural gap (React\n // fires `onRecoverableError` for this exact case) and let the reconciler\n // mount a fresh DOM for this fiber below.\n // Exception: <head> children are position-insensitive; a missing match\n // there means \"server didn't hoist this one yet\", which we silently mount.\n if (!isHeadish) onMismatch(fiber, null)\n return false\n }\n\n if (candidate.nodeType !== 1 || (candidate as Element).tagName.toLowerCase() !== tag) {\n // mismatch \u2014 log and re-render fresh from this point\n onMismatch(fiber, candidate)\n return false\n }\n fiber.dom = candidate\n // Apply props (attach events, sync IDL props). Don't re-set existing attrs.\n const props = fiber.pp ?? {}\n const isSvg =\n tag === 'svg' ||\n ((candidate as Element).namespaceURI === 'http://www.w3.org/2000/svg' &&\n tag !== 'foreignobject')\n validateHydrationProps(fiber, candidate as Element, props, tag, isSvg)\n for (const k in props) {\n if (k === 'children') continue\n if (k[0] === 'o' && k[1] === 'n' && typeof props[k] == 'function') {\n setProp(candidate as Element, k, props[k], undefined, isSvg)\n }\n // Non-event props: trust the server HTML, skip\n }\n // Set up child cursor for this host's children\n hydrationCursors.set(fiber, new HydrationCursor(candidate))\n return true\n}\n\nexport function adoptTextDom(fiber: Fiber, parent: Fiber, text: string): boolean {\n const cursor = hydrationCursors.get(findHostParent(parent))\n if (!cursor) return false\n const candidate = cursor.take()\n if (!candidate) onMismatch(fiber, null)\n if (candidate.nodeType === 3) {\n if ((candidate as Text).data !== text) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(`Hydration text mismatch: expected \"${text}\" but found \"${(candidate as Text).data}\".`),\n )\n }\n failHydration(fiber)\n }\n fiber.dom = candidate\n return true\n }\n onMismatch(fiber, candidate)\n return false\n}\n\nexport function findHostParent(fiber: Fiber): Fiber {\n let f: Fiber | null = fiber\n while (f) {\n // A fiber explicitly holding a cursor acts as a boundary for hydration\n // (e.g. Suspense with a scoped cursor during fallback/boundary hydration).\n if (hydrationCursors.has(f)) return f\n if (f.tag === FiberTag.Host || f.tag === FiberTag.Root || f.tag === FiberTag.Portal) {\n return f\n }\n f = f.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 onMismatch(fiber: Fiber, actualNode: ChildNode | null): never {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(\n `Hydration mismatch: expected <${(fiber.type as string) ?? 'text'}> but found ${\n actualNode ? (actualNode.nodeType === 1 ? (actualNode as Element).tagName : 'text') : 'nothing'\n }.`,\n ),\n )\n }\n failHydration(fiber)\n}\n\nfunction failHydration(fiber: Fiber, error: Error = new Error(PROD_HYDRATION_ERROR)): never {\n const root = findRoot(fiber)\n if (root?.re) {\n root.re(error)\n }\n abortHydration(error, findHostRecoveryParent(fiber) ?? fiber)\n}\n\nfunction findHostRecoveryParent(fiber: Fiber): Fiber | null {\n if (fiber.tag === FiberTag.Text) {\n let directHost = fiber.parent\n while (directHost && (directHost.tag !== FiberTag.Host || !directHost.dom)) {\n directHost = directHost.parent\n }\n if (!directHost) return null\n let hasEvent\n const props = directHost.pp ?? directHost.mp\n if (props) {\n for (const k in props) {\n if (k[0] === 'o' && k[1] === 'n' && typeof props[k] == 'function') {\n hasEvent = true\n }\n }\n }\n return findNearestSafeHostAboveComposite(\n hasEvent\n ? directHost.parent\n : directHost.parent?.tag === FiberTag.Host\n ? directHost.parent\n : directHost,\n )\n }\n\n return findNearestSafeHostAboveComposite(fiber.parent)\n}\n\nfunction findNearestSafeHostAboveComposite(fiber: Fiber | null): Fiber | null {\n let f = fiber\n while (f) {\n if (f.tag === FiberTag.Host && f.dom) {\n return isSafeHostRecoveryElement(f) ? f : null\n }\n f = f.parent\n }\n return null\n}\n\nfunction isSafeHostRecoveryElement(fiber: Fiber): boolean {\n const tag = fiber.type.toLowerCase()\n return tag !== 'html' && tag !== 'head' && tag !== 'body'\n}\n\nfunction resetAfterHydrationFailure(\n root: FiberRoot,\n container: Element | Document,\n): void {\n discardPendingWork(root)\n clearHydrationContainer(container)\n attachRootFiber(root, container)\n root.h = false\n}\n\nfunction clearHydrationContainer(container: Element | Document): void {\n if (container.nodeType === 9) {\n let node = container.firstChild\n while (node) {\n const next = node.nextSibling\n if (node.nodeType !== 10 /* DOCUMENT_TYPE_NODE */) {\n container.removeChild(node)\n }\n node = next\n }\n return\n }\n ;(container as Element).textContent = ''\n}\n\nfunction getRecoverableHostChildren(\n error: HydrationBailoutError,\n): [Element, ReactNode] | null {\n const host = error.f\n if (\n !host ||\n host.tag !== FiberTag.Host ||\n !host.dom ||\n !isSafeHostRecoveryElement(host) ||\n !findNearestSafeHostAboveComposite(host.parent)\n ) {\n return null\n }\n return [host.dom as Element, (host.pp ?? host.mp)?.children ?? null]\n}\n\nfunction getRecoverableDocumentBodyChildren(error: HydrationBailoutError): ReactNode | null {\n const bodyFiber = findBodyAncestor(error.f)\n if (!bodyFiber) return null\n return (bodyFiber.pp ?? bodyFiber.mp)?.children ?? null\n}\n\nfunction findBodyAncestor(fiber: Fiber | null): Fiber | null {\n let f = fiber\n while (f) {\n if (f.tag === FiberTag.Host && f.type === 'body') {\n return f === fiber ? null : f\n }\n f = f.parent\n }\n return null\n}\n\nfunction getStaticDocumentBodyChildren(children: ReactNode): ReactNode | null {\n const list = toChildArray(children)\n const html = list.find((child) => isHostElement(child, 'html')) as ReactElement | undefined\n if (!html) return null\n const htmlChildren = toChildArray(html.props?.children)\n const body = htmlChildren.find((child) => isHostElement(child, 'body')) as ReactElement | undefined\n return body ? body.props?.children ?? null : null\n}\n\nfunction normalizeDocumentChildren(children: ReactNode): ReactNode {\n const list = toChildArray(children)\n const htmlIndex = list.findIndex((child) => isHostElement(child, 'html'))\n if (htmlIndex === -1) return children\n\n const headNodes = list.filter(isHeadElement)\n if (headNodes.length === 0) return children\n\n const htmlElement = list[htmlIndex] as ReactElement\n const normalizedHtml = hoistIntoHtmlHead(htmlElement, headNodes)\n return list\n .filter((child, index) => index === htmlIndex || !isHeadElement(child))\n .map((child) => (child === htmlElement ? normalizedHtml : child))\n}\n\nfunction hoistIntoHtmlHead(htmlElement: ReactElement, headNodes: ReactNode[]): ReactElement {\n const htmlChildren = toChildArray(htmlElement.props?.children)\n const headIndex = htmlChildren.findIndex((child) => isHostElement(child, 'head'))\n let nextChildren: ReactNode[]\n\n if (headIndex === -1) {\n nextChildren = [\n createHostElement('head', { children: headNodes }),\n ...htmlChildren,\n ]\n } else {\n const headElement = htmlChildren[headIndex] as ReactElement\n const existingHeadChildren = toChildArray(headElement.props?.children)\n const nextHead = {\n ...headElement,\n props: {\n ...headElement.props,\n children: [...headNodes, ...existingHeadChildren],\n },\n }\n nextChildren = htmlChildren.map((child, index) => (index === headIndex ? nextHead : child))\n }\n\n return {\n ...htmlElement,\n props: {\n ...htmlElement.props,\n children: nextChildren,\n },\n }\n}\n\nfunction toChildArray(children: unknown): ReactNode[] {\n if (children == null || typeof children === 'boolean') return []\n if (Array.isArray(children)) return children as ReactNode[]\n if (isReactElement(children)) return [children]\n if (typeof children !== 'string' && isIterable(children)) return Array.from(children) as ReactNode[]\n return [children as ReactNode]\n}\n\nfunction isHeadElement(value: ReactNode): boolean {\n return isReactElement(value) && typeof value.type === 'string' && DOCUMENT_HEAD_TAGS.has(value.type)\n}\n\nfunction isHostElement(value: ReactNode, tag: string): boolean {\n return isReactElement(value) && value.type === tag\n}\n\nfunction isReactElement(value: unknown): value is ReactElement {\n return !!value && typeof value === 'object' && (value as ReactElement).$$typeof === REACT_ELEMENT_TYPE\n}\n\nfunction isIterable(value: unknown): value is Iterable<ReactNode> {\n return !!value && typeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] == 'function'\n}\n\nfunction createHostElement(type: string, props: Record<string, unknown>): ReactElement {\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type,\n key: null,\n ref: null,\n props,\n }\n}\n\nfunction validateHydrationProps(\n fiber: Fiber,\n el: Element,\n props: Record<string, any>,\n tag: string,\n isSvg: boolean,\n): void {\n if (props.suppressHydrationWarning) return\n\n let expected: Element | undefined\n\n for (const k in props) {\n const value = props[k]\n if (\n k === 'children' ||\n k === 'key' ||\n k === 'ref' ||\n k === 'suppressHydrationWarning' ||\n k === 'suppressContentEditableWarning' ||\n (k[0] === 'o' && k[1] === 'n' && typeof value == 'function')\n ) continue\n\n if (k === 'dangerouslySetInnerHTML') {\n const probe = document.createElement('div')\n probe.innerHTML = value?.__html ?? ''\n if ((el as HTMLElement).innerHTML !== probe.innerHTML) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(`Hydration HTML mismatch inside <${tag}>.`),\n )\n }\n failHydration(fiber)\n }\n continue\n }\n\n if (k === 'value' || k === 'defaultValue') {\n if (tag === 'select') continue\n if (tag === 'input' || tag === 'textarea') {\n if (k === 'value' || props.value == null) {\n if (value != null && (el as HTMLInputElement).value !== '' + value) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(fiber, new Error(`Hydration ${tag} value mismatch on <${tag}>.`))\n }\n failHydration(fiber)\n }\n }\n continue\n }\n }\n\n if (tag === 'input' && (k === 'checked' || k === 'defaultChecked')) {\n if (k === 'checked' || props.checked == null) {\n if (value != null && (el as HTMLInputElement).checked !== !!value) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(fiber, new Error(`Hydration checked mismatch on <input>.`))\n }\n failHydration(fiber)\n }\n }\n continue\n }\n\n if (tag === 'option' && k === 'selected') {\n if (value != null && (el as HTMLOptionElement).selected !== !!value) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(fiber, new Error(`Hydration selected mismatch on <option>.`))\n }\n failHydration(fiber)\n }\n continue\n }\n\n if (k === 'style') {\n expected ??= createHostNode(tag, isSvg)\n setProp(expected, k, value, undefined, isSvg)\n if ((el as HTMLElement).style.cssText !== (expected as HTMLElement).style.cssText) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(`Hydration style mismatch on <${tag}>.`),\n )\n }\n failHydration(fiber)\n }\n continue\n }\n\n const stringifiedBoolean = k.startsWith('aria-') || k.startsWith('data-')\n const attr = k === 'className' ? 'class' : k === 'htmlFor' ? 'for' : stringifiedBoolean ? k : k.toLowerCase()\n\n let expectedValue: string | null\n if (value == null || (value === false && !stringifiedBoolean)) {\n expectedValue = null\n } else {\n expected ??= createHostNode(tag, isSvg)\n setProp(expected, k, value, undefined, isSvg)\n expectedValue = expected.getAttribute(attr)\n }\n const actualValue = el.getAttribute(attr)\n if (expectedValue !== actualValue) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(\n `Hydration attribute mismatch on <${tag}> for \"${attr}\": ` +\n `expected ${formatHydrationValue(expectedValue)} but found ${formatHydrationValue(actualValue)}.`,\n ),\n )\n }\n failHydration(fiber)\n }\n }\n}\n\nfunction formatHydrationValue(value: string | null): string {\n return value == null ? 'nothing' : JSON.stringify(value)\n}\n"],
5
- "mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AACP,SAAS,gBAAgB,eAAe;AACxC,SAAS,wBAAwB;AACjC,SAAS,oBAAoB,UAAU,eAAe,kBAAkB;AACxE,SAAS,iBAAiB,uBAAuB;AAgB1C,SAAS,8BAAoC;AAClD,MAAI,OAAO,WAAW,YAAa;AACnC,QAAM,IAAI;AACV,MAAI,EAAE,GAAI;AACV,QAAM,OAAO,KAAK;AAClB,QAAM,iBAAiB,EAAE,KAAK,KAAK;AACnC,MAAI,mBAAmB;AACvB,MAAI,eAAe;AACnB,IAAE;AAAA,IACA;AAAA,IACA,MAAM;AACJ,UAAI,CAAC,cAAc;AACjB,2BAAmB,KAAK;AAAA,MAC1B;AAAA,IACF;AAAA,IACA,EAAE,SAAS,MAAM,SAAS,KAAK;AAAA,EACjC;AACA,QAAM,eAAe,EAAE;AACvB,IAAE,WAAW,YAAa,MAAa;AACrC,UAAM,MAAM,KAAK;AACjB,QACE,MAAM,iBAAiB,OACvB,MAAM,mBAAmB,MACzB;AACA;AAAA,IACF;AACA,mBAAe;AACf,QAAI;AACF,aAAQ,aAAqB,MAAM,GAAG,IAAI;AAAA,IAC5C,UAAE;AACA,qBAAe,MAAM;AACnB,uBAAe;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF;AACF;AASO,IAAM,kBAAN,MAAsB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,QAAc,QAA0B,MAAM,YAA8B,MAAM;AAC5F,SAAK,IAAI;AACT,SAAK,IAAI,SAAS,OAAO;AACzB,SAAK,IAAI;AAAA,EACX;AAAA,EACA,OAAyB;AACvB,WAAO,KAAK,KAAK,KAAK,MAAM,KAAK,GAAG;AAClC,Y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C;AAAA,QAC5E;AACA,sBAAc,KAAK;AAAA,MACrB;AACA;AAAA,IACF;AAEA,QAAI,MAAM,SAAS;AACjB,mBAAa,eAAe,KAAK,KAAK;AACtC,cAAQ,UAAU,GAAG,OAAO,QAAW,KAAK;AAC5C,UAAK,GAAmB,MAAM,YAAa,SAAyB,MAAM,SAAS;AACjF,YAAI,MAAuC;AACzC;AAAA,YACE;AAAA,YACA,IAAI,MAAM,gCAAgC,GAAG,IAAI;AAAA,UACnD;AAAA,QACF;AACA,sBAAc,KAAK;AAAA,MACrB;AACA;AAAA,IACF;AAEA,UAAM,qBAAqB,EAAE,WAAW,OAAO,KAAK,EAAE,WAAW,OAAO;AACxE,UAAM,OAAO,MAAM,cAAc,UAAU,MAAM,YAAY,QAAQ,qBAAqB,IAAI,EAAE,YAAY;AAE5G,QAAI;AACJ,QAAI,SAAS,QAAS,UAAU,SAAS,CAAC,oBAAqB;AAC7D,sBAAgB;AAAA,IAClB,OAAO;AACL,mBAAa,eAAe,KAAK,KAAK;AACtC,cAAQ,UAAU,GAAG,OAAO,QAAW,KAAK;AAC5C,sBAAgB,SAAS,aAAa,IAAI;AAAA,IAC5C;AACA,UAAM,cAAc,GAAG,aAAa,IAAI;AACxC,QAAI,kBAAkB,aAAa;AACjC,UAAI,MAAuC;AACzC;AAAA,UACE;AAAA,UACA,IAAI;AAAA,YACF,oCAAoC,GAAG,UAAU,IAAI,eACvC,qBAAqB,aAAa,CAAC,cAAc,qBAAqB,WAAW,CAAC;AAAA,UAClG;AAAA,QACF;AAAA,MACF;AACA,oBAAc,KAAK;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,qBAAqB,OAA8B;AAC1D,SAAO,SAAS,OAAO,YAAY,KAAK,UAAU,KAAK;AACzD;",
4
+ "sourcesContent": ["import {\n FiberTag,\n REACT_ELEMENT_TYPE,\n type Fiber,\n type FiberRoot,\n type ReactElement,\n type ReactNode,\n} from '../../../core'\nimport { createHostNode, setProp } from '../../dom'\nimport { drainReplayQueue } from '../../event-replay'\nimport { discardPendingWork, findRoot, flushSyncWork, renderRoot } from '../../reconcile'\nimport { attachRootFiber, createFiberRoot } from '../../root-internal'\n\n// Re-export from event-replay so all hydration concerns live behind one\n// feature boundary \u2014 the plugin's stub swap strips drainReplayQueue too.\nexport { drainReplayQueue }\n\n/**\n * Preserve the user's scroll position across hydration. If the user scrolled\n * between SSR paint and hydrate (common in dev where JS takes seconds to\n * load), libraries that wire scroll-restoration into a `useLayoutEffect`\n * near the root (e.g. TanStack Router) will run during our synchronous\n * hydrate and call `window.scrollTo(savedFromLastVisit)` \u2014 overwriting the\n * user's fresh scroll. We install a short-lived wrapper around scrollTo that\n * suppresses programmatic calls when a user-initiated scroll happened\n * recently. Only runs in the hydration feature \u2014 the stub skips it.\n */\nexport function installHydrationScrollGuard(): void {\n if (typeof window === 'undefined') return\n const w = window as any\n if (w._r) return\n const time = Date.now\n const guardStartedAt = w._r = time()\n let lastUserScrollAt = 0\n let programmatic = false\n w.addEventListener(\n 'scroll',\n () => {\n if (!programmatic) {\n lastUserScrollAt = time()\n }\n },\n { capture: true, passive: true },\n )\n const origScrollTo = w.scrollTo\n w.scrollTo = function (...args: any[]) {\n const now = time()\n if (\n now - guardStartedAt < 3000 &&\n now - lastUserScrollAt < 1500\n ) {\n return\n }\n programmatic = true\n try {\n return (origScrollTo as any).apply(w, args)\n } finally {\n queueMicrotask(() => {\n programmatic = false\n })\n }\n }\n}\n\n/**\n * Hydration cursor: walks existing DOM children in document order so we can\n * adopt them during fiber tree construction. One cursor per host parent.\n *\n * `endBefore` scopes the cursor to a subrange \u2014 used by rehydrateBoundary()\n * so we only adopt DOM up to the closing `/$` marker for that boundary.\n */\nexport class HydrationCursor {\n n: ChildNode | null\n p: Node\n e: ChildNode | null\n constructor(parent: Node, start: ChildNode | null = null, endBefore: ChildNode | null = null) {\n this.p = parent\n this.n = start ?? parent.firstChild\n this.e = endBefore\n }\n take(): ChildNode | null {\n while (this.n && this.n !== this.e) {\n const n = this.n\n // Skip anything that isn't an element (1) or text (3):\n // comments (8), doctype (10), processing instructions (7), cdata (4).\n if (n.nodeType !== 1 && n.nodeType !== 3) {\n this.n = n.nextSibling\n continue\n }\n this.n = n.nextSibling\n return n\n }\n return null\n }\n /**\n * Position-insensitive lookup for head/html adoption. Scans forward past\n * non-matching nodes without removing them, matching by tag AND the key\n * attributes that identify head elements uniquely (rel/href for links,\n * name/property for meta, src for script). Non-matching nodes stay in\n * place so the SSR'd stylesheet/script order is preserved.\n */\n head(tag: string, props: Record<string, any>): ChildNode | null {\n const target = tag.toLowerCase()\n const keyAttrs = HEAD_KEY_ATTRS[target]\n let scan = this.p.firstChild\n while (scan) {\n if (\n scan.nodeType === 1 &&\n (scan as Element).tagName.toLowerCase() === target &&\n headAttrsMatch(scan as Element, props, keyAttrs)\n ) {\n CLAIMED.add(scan)\n return scan\n }\n scan = scan.nextSibling\n }\n return null\n }\n has(): boolean {\n let n = this.n\n while (n && n !== this.e) {\n if (n.nodeType === 1 || n.nodeType === 3) return true\n n = n.nextSibling\n }\n return false\n }\n}\n\nconst hydrationCursors = new WeakMap<Fiber, HydrationCursor>()\nconst PROD_HYDRATION_ERROR = 'Hydration mismatch.'\n\nexport interface HydrationBailoutError extends Error {\n f: Fiber | null\n}\n\nexport function isHydrationBailout(error: unknown): error is HydrationBailoutError {\n return !!error && (error as any).f !== undefined\n}\n\nexport function abortHydration(cause: unknown, fiber: Fiber | null = null): never {\n const error = (cause instanceof Error ? cause : new Error(PROD_HYDRATION_ERROR)) as HydrationBailoutError\n ;(error as any).f = fiber\n throw error\n}\n\ninterface HydrateRootOptions {\n identifierPrefix?: string\n onRecoverableError?: (error: unknown) => void\n onCaughtError?: (error: unknown) => void\n onUncaughtError?: (error: unknown) => void\n}\n\ninterface HydratedRoot {\n render(children: ReactNode): void\n unmount(): void\n}\n\nexport function hydrateRootImpl(\n container: Element | Document,\n initialChildren: ReactNode,\n options: HydrateRootOptions,\n): HydratedRoot {\n const target = container as any as Element | Document\n const isDocument = (container as Node).nodeType === 9\n const body = isDocument ? (target as Document).body : null\n const root = createFiberRoot(target, options)\n\n installHydrationScrollGuard()\n\n const normalizedInitialChildren =\n isDocument ? normalizeDocumentChildren(initialChildren) : initialChildren\n let documentBodyFallback = false\n\n let hydrationError: unknown = null\n beginHydration(root)\n try {\n flushSyncWork(() => {\n renderRoot(root, normalizedInitialChildren)\n })\n } catch (e) {\n hydrationError = e\n }\n endHydration(root)\n\n if (hydrationError) {\n if (!isHydrationBailout(hydrationError)) {\n throw hydrationError\n }\n let recoveryContainer: Element | Document = target\n let recoveryChildren = normalizedInitialChildren\n const hostRecovery = getRecoverableHostChildren(hydrationError)\n if (hostRecovery) {\n recoveryContainer = hostRecovery[0]\n recoveryChildren = hostRecovery[1]\n } else if (body) {\n const bodyChildren = getRecoverableDocumentBodyChildren(hydrationError)\n if (bodyChildren != null) {\n documentBodyFallback = true\n recoveryContainer = body\n recoveryChildren = bodyChildren\n }\n }\n resetAfterHydrationFailure(root, recoveryContainer)\n try {\n flushSyncWork(() => {\n renderRoot(root, recoveryChildren)\n })\n } catch (clientError) {\n resetAfterHydrationFailure(root, recoveryContainer)\n throw clientError\n }\n }\n drainReplayQueue()\n\n return {\n render(children) {\n flushSyncWork(() => {\n const normalized = isDocument ? normalizeDocumentChildren(children) : children\n renderRoot(\n root,\n documentBodyFallback ? getStaticDocumentBodyChildren(normalized) ?? normalized : normalized,\n )\n })\n },\n unmount() {\n flushSyncWork(() => {\n renderRoot(root, null)\n })\n },\n }\n}\n\n// Head elements that we match against server DOM by attribute signature.\nconst HEAD_KEY_ATTRS: Record<string, ReadonlyArray<string>> = {\n link: ['rel', 'href', 'sizes', 'type'],\n meta: ['name', 'property', 'charset', 'http-equiv'],\n script: ['src', 'type'],\n}\n\nconst DOCUMENT_HEAD_TAGS = new Set(['base', 'link', 'meta', 'script', 'style', 'title'])\n\n// DOM elements already claimed by some fiber during this hydration pass.\nconst CLAIMED = new WeakSet<Node>()\n\nfunction headAttrsMatch(\n el: Element,\n props: Record<string, any>,\n keys: ReadonlyArray<string> | undefined,\n): boolean {\n if (CLAIMED.has(el)) return false\n if (!keys) return true\n let matched = false\n for (const k of keys) {\n const propVal = props[k] ?? (k === 'http-equiv' ? props.httpEquiv : undefined)\n const elVal = el.getAttribute(k)\n // If neither defines it, skip this key; if one defines it, they must match.\n if (propVal == null && elVal == null) continue\n matched = true\n if (propVal == null || elVal == null) continue // tolerate missing on either side\n if (String(propVal) !== elVal) return false\n }\n // At least one matching signal must be present.\n return matched\n}\n\nexport function beginHydration(root: FiberRoot): void {\n root.h = true\n hydrationCursors.set(root.r, new HydrationCursor(root.c))\n}\n\nexport function endHydration(root: FiberRoot): void {\n root.h = false\n hydrationCursors.delete(root.r)\n}\n\n/**\n * Inspect the current cursor position for a streaming-suspense boundary\n * marker emitted by the server. Returns info + advances the cursor past the\n * marker pair (start comment + fallback/real content + end comment).\n */\nexport type BoundaryInfo = [0 | 1, number, Comment, Comment]\n\nexport function tryConsumeBoundary(parent: Fiber): BoundaryInfo | null {\n const cursor = hydrationCursors.get(findHostParent(parent))\n if (!cursor) return null\n const peek = cursor.n\n if (!peek || peek.nodeType !== 8) return null\n const data = (peek as Comment).data\n const m = /^(\\$\\??)(\\d+)$/.exec(data)\n if (!m) return null\n const kind = m[1] === '$?' ? 1 : 0\n const id = Number(m[2])\n const startMark = peek as Comment\n // Advance past the start comment\n cursor.n = startMark.nextSibling\n // Locate end comment: closest <!--/$-->\n let endMark: Comment | null = null\n let scan = startMark.nextSibling\n while (scan) {\n if (scan.nodeType === 8 && (scan as Comment).data === '/$') {\n endMark = scan as Comment\n break\n }\n scan = scan.nextSibling\n }\n if (!endMark) return null\n return [kind, id, startMark, endMark]\n}\n\nexport function advanceCursorPast(parent: Fiber, node: Node): void {\n const cursor = hydrationCursors.get(findHostParent(parent))\n if (!cursor) return\n cursor.n = node.nextSibling\n}\n\nexport function getHydrationCursor(hostFiber: Fiber): HydrationCursor | undefined {\n return hydrationCursors.get(hostFiber)\n}\n\nexport function setHydrationCursor(hostFiber: Fiber, cursor: HydrationCursor): void {\n hydrationCursors.set(hostFiber, cursor)\n}\n\nexport function clearHydrationCursor(hostFiber: Fiber): void {\n hydrationCursors.delete(hostFiber)\n}\n\n/**\n * Try to adopt a DOM node for this host fiber. Returns true if adopted.\n * Attaches existing attrs/children via separate hydrate pass.\n */\nexport function adoptHostDom(fiber: Fiber, parent: Fiber): boolean {\n const hostParent = findHostParent(parent)\n const cursor = hydrationCursors.get(hostParent)\n if (!cursor) return false\n\n const tag = (fiber.type as string).toLowerCase()\n const documentHeadParent =\n cursor.p.nodeType === 9 && DOCUMENT_HEAD_TAGS.has(tag)\n ? (cursor.p as Document).head\n : null\n const parentEl = cursor.p as Element\n const parentTag =\n parentEl.nodeType === 1 ? (parentEl as Element).tagName.toLowerCase() : ''\n const isHeadish = parentTag === 'head' || parentTag === 'html' || !!documentHeadParent\n\n let candidate: ChildNode | null\n if (documentHeadParent) {\n // React 19 can project <meta>/<title>/<link> from anywhere in the tree into\n // document.head. Redact does not have that projection yet, so when a\n // document-root hydration pass sees a top-level head element, adopt it\n // from <head> rather than trying to append it beside <html>.\n candidate = new HydrationCursor(documentHeadParent).head(\n tag,\n fiber.pp ?? {},\n )\n } else if (isHeadish) {\n // Head/html children are position-insensitive \u2014 server may emit them in\n // a different order than the React tree (React 19 head hoisting, etc.).\n // Scan forward without removing non-matching nodes; match on attribute\n // signature so we don't adopt the wrong <link> and clobber its props.\n candidate = cursor.head(tag, fiber.pp ?? {})\n } else {\n candidate = cursor.take()\n }\n\n if (!candidate) {\n // Client expected a host here but the cursor is exhausted \u2014 server gave\n // fewer children than the client tree. Report the structural gap (React\n // fires `onRecoverableError` for this exact case) and let the reconciler\n // mount a fresh DOM for this fiber below.\n // Exception: <head> children are position-insensitive; a missing match\n // there means \"server didn't hoist this one yet\", which we silently mount.\n if (!isHeadish) onMismatch(fiber, null)\n return false\n }\n\n if (candidate.nodeType !== 1 || (candidate as Element).tagName.toLowerCase() !== tag) {\n // mismatch \u2014 log and re-render fresh from this point\n onMismatch(fiber, candidate)\n return false\n }\n fiber.dom = candidate\n // Apply props (attach events, sync IDL props). Don't re-set existing attrs.\n const props = fiber.pp ?? {}\n const isSvg =\n tag === 'svg' ||\n ((candidate as Element).namespaceURI === 'http://www.w3.org/2000/svg' &&\n tag !== 'foreignobject')\n validateHydrationProps(fiber, candidate as Element, props, tag, isSvg)\n for (const k in props) {\n if (k === 'children') continue\n if (k[0] === 'o' && k[1] === 'n' && typeof props[k] == 'function') {\n setProp(candidate as Element, k, props[k], undefined, isSvg)\n }\n // Non-event props: trust the server HTML, skip\n }\n // Set up child cursor for this host's children\n hydrationCursors.set(fiber, new HydrationCursor(candidate))\n return true\n}\n\nexport function adoptTextDom(fiber: Fiber, parent: Fiber, text: string): boolean {\n const cursor = hydrationCursors.get(findHostParent(parent))\n if (!cursor) return false\n const candidate = cursor.take()\n if (!candidate) onMismatch(fiber, null)\n if (candidate.nodeType === 3) {\n if ((candidate as Text).data !== text) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(`Hydration text mismatch: expected \"${text}\" but found \"${(candidate as Text).data}\".`),\n )\n }\n failHydration(fiber)\n }\n fiber.dom = candidate\n return true\n }\n onMismatch(fiber, candidate)\n return false\n}\n\nexport function findHostParent(fiber: Fiber): Fiber {\n let f: Fiber | null = fiber\n while (f) {\n // A fiber explicitly holding a cursor acts as a boundary for hydration\n // (e.g. Suspense with a scoped cursor during fallback/boundary hydration).\n if (hydrationCursors.has(f)) return f\n if (f.tag === FiberTag.Host || f.tag === FiberTag.Root || f.tag === FiberTag.Portal) {\n return f\n }\n f = f.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 onMismatch(fiber: Fiber, actualNode: ChildNode | null): never {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(\n `Hydration mismatch: expected <${(fiber.type as string) ?? 'text'}> but found ${\n actualNode ? (actualNode.nodeType === 1 ? (actualNode as Element).tagName : 'text') : 'nothing'\n }.`,\n ),\n )\n }\n failHydration(fiber)\n}\n\nfunction failHydration(fiber: Fiber, error: Error = new Error(PROD_HYDRATION_ERROR)): never {\n const root = findRoot(fiber)\n if (root?.re) {\n root.re(error)\n }\n abortHydration(error, findHostRecoveryParent(fiber) ?? fiber)\n}\n\nfunction findHostRecoveryParent(fiber: Fiber): Fiber | null {\n if (fiber.tag === FiberTag.Text) {\n let directHost = fiber.parent\n while (directHost && (directHost.tag !== FiberTag.Host || !directHost.dom)) {\n directHost = directHost.parent\n }\n if (!directHost) return null\n let hasEvent\n const props = directHost.pp ?? directHost.mp\n if (props) {\n for (const k in props) {\n if (k[0] === 'o' && k[1] === 'n' && typeof props[k] == 'function') {\n hasEvent = true\n }\n }\n }\n return findNearestSafeHostAboveComposite(\n hasEvent\n ? directHost.parent\n : directHost.parent?.tag === FiberTag.Host\n ? directHost.parent\n : directHost,\n )\n }\n\n return findNearestSafeHostAboveComposite(fiber.parent)\n}\n\nfunction findNearestSafeHostAboveComposite(fiber: Fiber | null): Fiber | null {\n let host: Fiber | null = null\n let f = fiber\n while (f) {\n if (f.tag === FiberTag.Host && f.dom) {\n if (!isSafeHostRecoveryElement(f)) return null\n const parentTag = f.parent?.tag as number\n if (!host || (parentTag > FiberTag.Text && parentTag < FiberTag.Suspense)) {\n host = f\n }\n }\n f = f.parent\n }\n return host\n}\n\nfunction isSafeHostRecoveryElement(fiber: Fiber): boolean {\n const tag = fiber.type.toLowerCase()\n return tag !== 'html' && tag !== 'head' && tag !== 'body'\n}\n\nfunction resetAfterHydrationFailure(\n root: FiberRoot,\n container: Element | Document,\n): void {\n discardPendingWork(root)\n clearHydrationContainer(container)\n attachRootFiber(root, container)\n root.h = false\n}\n\nfunction clearHydrationContainer(container: Element | Document): void {\n if (container.nodeType === 9) {\n let node = container.firstChild\n while (node) {\n const next = node.nextSibling\n if (node.nodeType !== 10 /* DOCUMENT_TYPE_NODE */) {\n container.removeChild(node)\n }\n node = next\n }\n return\n }\n ;(container as Element).textContent = ''\n}\n\nfunction getRecoverableHostChildren(\n error: HydrationBailoutError,\n): [Element, ReactNode] | null {\n const host = error.f\n if (\n host?.tag !== FiberTag.Host ||\n !host.dom ||\n !findNearestSafeHostAboveComposite(host.parent)\n ) {\n return null\n }\n return [host.dom as Element, (host.pp ?? host.mp)?.children ?? null]\n}\n\nfunction getRecoverableDocumentBodyChildren(error: HydrationBailoutError): ReactNode | null {\n const bodyFiber = findBodyAncestor(error.f)\n if (!bodyFiber) return null\n return (bodyFiber.pp ?? bodyFiber.mp)?.children ?? null\n}\n\nfunction findBodyAncestor(fiber: Fiber | null): Fiber | null {\n let f = fiber\n while (f) {\n if (f.tag === FiberTag.Host && f.type === 'body') {\n return f === fiber ? null : f\n }\n f = f.parent\n }\n return null\n}\n\nfunction getStaticDocumentBodyChildren(children: ReactNode): ReactNode | null {\n const list = toChildArray(children)\n const html = list.find((child) => isHostElement(child, 'html')) as ReactElement | undefined\n if (!html) return null\n const htmlChildren = toChildArray(html.props?.children)\n const body = htmlChildren.find((child) => isHostElement(child, 'body')) as ReactElement | undefined\n return body ? body.props?.children ?? null : null\n}\n\nfunction normalizeDocumentChildren(children: ReactNode): ReactNode {\n const list = toChildArray(children)\n const htmlIndex = list.findIndex((child) => isHostElement(child, 'html'))\n if (htmlIndex === -1) return children\n\n const headNodes = list.filter(isHeadElement)\n if (headNodes.length === 0) return children\n\n const htmlElement = list[htmlIndex] as ReactElement\n const normalizedHtml = hoistIntoHtmlHead(htmlElement, headNodes)\n return list\n .filter((child, index) => index === htmlIndex || !isHeadElement(child))\n .map((child) => (child === htmlElement ? normalizedHtml : child))\n}\n\nfunction hoistIntoHtmlHead(htmlElement: ReactElement, headNodes: ReactNode[]): ReactElement {\n const htmlChildren = toChildArray(htmlElement.props?.children)\n const headIndex = htmlChildren.findIndex((child) => isHostElement(child, 'head'))\n let nextChildren: ReactNode[]\n\n if (headIndex === -1) {\n nextChildren = [\n createHostElement('head', { children: headNodes }),\n ...htmlChildren,\n ]\n } else {\n const headElement = htmlChildren[headIndex] as ReactElement\n const existingHeadChildren = toChildArray(headElement.props?.children)\n const nextHead = {\n ...headElement,\n props: {\n ...headElement.props,\n children: [...headNodes, ...existingHeadChildren],\n },\n }\n nextChildren = htmlChildren.map((child, index) => (index === headIndex ? nextHead : child))\n }\n\n return {\n ...htmlElement,\n props: {\n ...htmlElement.props,\n children: nextChildren,\n },\n }\n}\n\nfunction toChildArray(children: unknown): ReactNode[] {\n if (children == null || typeof children === 'boolean') return []\n if (Array.isArray(children)) return children as ReactNode[]\n if (isReactElement(children)) return [children]\n if (typeof children !== 'string' && isIterable(children)) return Array.from(children) as ReactNode[]\n return [children as ReactNode]\n}\n\nfunction isHeadElement(value: ReactNode): boolean {\n return isReactElement(value) && typeof value.type === 'string' && DOCUMENT_HEAD_TAGS.has(value.type)\n}\n\nfunction isHostElement(value: ReactNode, tag: string): boolean {\n return isReactElement(value) && value.type === tag\n}\n\nfunction isReactElement(value: unknown): value is ReactElement {\n return !!value && typeof value === 'object' && (value as ReactElement).$$typeof === REACT_ELEMENT_TYPE\n}\n\nfunction isIterable(value: unknown): value is Iterable<ReactNode> {\n return !!value && typeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] == 'function'\n}\n\nfunction createHostElement(type: string, props: Record<string, unknown>): ReactElement {\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type,\n key: null,\n ref: null,\n props,\n }\n}\n\nfunction validateHydrationProps(\n fiber: Fiber,\n el: Element,\n props: Record<string, any>,\n tag: string,\n isSvg: boolean,\n): void {\n if (props.suppressHydrationWarning) return\n\n let expected: Element | undefined\n\n for (const k in props) {\n const value = props[k]\n if (\n k === 'children' ||\n k === 'key' ||\n k === 'ref' ||\n k === 'suppressHydrationWarning' ||\n k === 'suppressContentEditableWarning' ||\n (k[0] === 'o' && k[1] === 'n' && typeof value == 'function')\n ) continue\n\n if (k === 'dangerouslySetInnerHTML') {\n const probe = document.createElement('div')\n probe.innerHTML = value?.__html ?? ''\n if ((el as HTMLElement).innerHTML !== probe.innerHTML) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(`Hydration HTML mismatch inside <${tag}>.`),\n )\n }\n failHydration(fiber)\n }\n continue\n }\n\n if (k === 'value' || k === 'defaultValue') {\n if (tag === 'select') continue\n if (tag === 'input' || tag === 'textarea') {\n if (k === 'value' || props.value == null) {\n if (value != null && (el as HTMLInputElement).value !== '' + value) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(fiber, new Error(`Hydration ${tag} value mismatch on <${tag}>.`))\n }\n failHydration(fiber)\n }\n }\n continue\n }\n }\n\n if (tag === 'input' && (k === 'checked' || k === 'defaultChecked')) {\n if (k === 'checked' || props.checked == null) {\n if (value != null && (el as HTMLInputElement).checked !== !!value) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(fiber, new Error(`Hydration checked mismatch on <input>.`))\n }\n failHydration(fiber)\n }\n }\n continue\n }\n\n if (tag === 'option' && k === 'selected') {\n if (value != null && (el as HTMLOptionElement).selected !== !!value) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(fiber, new Error(`Hydration selected mismatch on <option>.`))\n }\n failHydration(fiber)\n }\n continue\n }\n\n if (k === 'style') {\n expected ??= createHostNode(tag, isSvg)\n setProp(expected, k, value, undefined, isSvg)\n if ((el as HTMLElement).style.cssText !== (expected as HTMLElement).style.cssText) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(`Hydration style mismatch on <${tag}>.`),\n )\n }\n failHydration(fiber)\n }\n continue\n }\n\n const stringifiedBoolean = k.startsWith('aria-') || k.startsWith('data-')\n const attr = k === 'className' ? 'class' : k === 'htmlFor' ? 'for' : stringifiedBoolean ? k : k.toLowerCase()\n\n let expectedValue: string | null\n if (value == null || (value === false && !stringifiedBoolean)) {\n expectedValue = null\n } else {\n expected ??= createHostNode(tag, isSvg)\n setProp(expected, k, value, undefined, isSvg)\n expectedValue = expected.getAttribute(attr)\n }\n const actualValue = el.getAttribute(attr)\n if (expectedValue !== actualValue) {\n if (process.env.NODE_ENV !== 'production') {\n failHydration(\n fiber,\n new Error(\n `Hydration attribute mismatch on <${tag}> for \"${attr}\": ` +\n `expected ${formatHydrationValue(expectedValue)} but found ${formatHydrationValue(actualValue)}.`,\n ),\n )\n }\n failHydration(fiber)\n }\n }\n}\n\nfunction formatHydrationValue(value: string | null): string {\n return value == null ? 'nothing' : JSON.stringify(value)\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AACP,SAAS,gBAAgB,eAAe;AACxC,SAAS,wBAAwB;AACjC,SAAS,oBAAoB,UAAU,eAAe,kBAAkB;AACxE,SAAS,iBAAiB,uBAAuB;AAgB1C,SAAS,8BAAoC;AAClD,MAAI,OAAO,WAAW,YAAa;AACnC,QAAM,IAAI;AACV,MAAI,EAAE,GAAI;AACV,QAAM,OAAO,KAAK;AAClB,QAAM,iBAAiB,EAAE,KAAK,KAAK;AACnC,MAAI,mBAAmB;AACvB,MAAI,eAAe;AACnB,IAAE;AAAA,IACA;AAAA,IACA,MAAM;AACJ,UAAI,CAAC,cAAc;AACjB,2BAAmB,KAAK;AAAA,MAC1B;AAAA,IACF;AAAA,IACA,EAAE,SAAS,MAAM,SAAS,KAAK;AAAA,EACjC;AACA,QAAM,eAAe,EAAE;AACvB,IAAE,WAAW,YAAa,MAAa;AACrC,UAAM,MAAM,KAAK;AACjB,QACE,MAAM,iBAAiB,OACvB,MAAM,mBAAmB,MACzB;AACA;AAAA,IACF;AACA,mBAAe;AACf,QAAI;AACF,aAAQ,aAAqB,MAAM,GAAG,IAAI;AAAA,IAC5C,UAAE;AACA,qBAAe,MAAM;AACnB,uBAAe;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF;AACF;AASO,IAAM,kBAAN,MAAsB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AA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UAClG;AAAA,QACF;AAAA,MACF;AACA,oBAAc,KAAK;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,qBAAqB,OAA8B;AAC1D,SAAO,SAAS,OAAO,YAAY,KAAK,UAAU,KAAK;AACzD;",
6
6
  "names": []
7
7
  }
@@ -58,7 +58,7 @@ function renderSuspense(fiber, domParent, anchor) {
58
58
  fiber.mp = props;
59
59
  return;
60
60
  }
61
- const hadCommittedPrimary = fiber.mp !== void 0 && fiber.child !== null;
61
+ const hadCommittedPrimary = fiber.mp && fiber.child;
62
62
  const prevHandler = suspendHandler;
63
63
  let pendingThenable;
64
64
  suspendHandler = (thenable) => {
@@ -76,9 +76,9 @@ function renderSuspense(fiber, domParent, anchor) {
76
76
  scheduleUpdate(fiber);
77
77
  };
78
78
  pendingThenable.then(onSettle, onSettle);
79
- if (hadCommittedPrimary && fiber.child) {
79
+ if (hadCommittedPrimary) {
80
80
  const hidden = [];
81
- let c = fiber.child;
81
+ let c = hadCommittedPrimary;
82
82
  while (c) {
83
83
  hideRootHostDoms(c, hidden);
84
84
  c = c.sibling;
@@ -111,10 +111,8 @@ function renderSuspense(fiber, domParent, anchor) {
111
111
  function hideRootHostDoms(fiber, out) {
112
112
  if (fiber.tag === FiberTag.Host) {
113
113
  const el = fiber.dom;
114
- if (el) {
115
- out.push([el, el.style.display]);
116
- el.style.display = "none";
117
- }
114
+ out.push([el, el.style.display]);
115
+ el.style.display = "none";
118
116
  return;
119
117
  }
120
118
  if (fiber.tag === FiberTag.Portal) return;
@@ -205,10 +203,10 @@ function recoverFallbackHydration(fiber, fallback, parent) {
205
203
  }
206
204
  function rehydrateBoundary(fiber) {
207
205
  const state = fiber.ms;
208
- if (!state || !state.b || !state.e) return;
206
+ if (!state?.b || !state.e) return;
209
207
  const root = findRoot(fiber);
210
208
  const parent = state.b.parentNode;
211
- if (!root || !parent) return;
209
+ if (!(root && parent)) return;
212
210
  withCurrentRoot(root, () => {
213
211
  const prevHydrating = root.h;
214
212
  try {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/dom/features/suspense/full.ts"],
4
- "sourcesContent": ["import { FiberTag, createFiber, type Fiber } from '../../../core'\nimport { REACT_SUSPENSE_TYPE } from '../../../react'\nimport {\n registerRenderer,\n registerTypeMatcher,\n installCapability,\n reconcileChildren,\n childrenToArray,\n renderFiber,\n scheduleUpdate,\n unmountAllChildren,\n unmountFiber,\n findRoot,\n runEffects,\n getCurrentRoot,\n withCurrentRoot,\n discardPendingWork,\n} from '../../reconcile'\nimport {\n HydrationCursor,\n setHydrationCursor,\n clearHydrationCursor,\n advanceCursorPast,\n tryConsumeBoundary,\n isHydrationBailout,\n} from '../hydration'\n\nlet suspendHandler: ((t: Promise<any>) => void) | null = null\n\nfunction realHandleSuspended(fiber: Fiber, thenable: Promise<any>): void {\n if (suspendHandler) return suspendHandler(thenable)\n // Fallback: schedule re-render when promise settles\n thenable.then(\n () => scheduleUpdate(fiber),\n () => scheduleUpdate(fiber),\n )\n}\n\n// React's Suspense semantics: when a re-render of an already-committed\n// boundary suspends, the previously-committed children are kept in the DOM\n// (hidden) so their scroll position, focus, selection, native form state,\n// and component state survive across the suspension. The fallback is mounted\n// alongside the hidden primary until the pending promise resolves.\n//\n// We track the hidden subtree DOM in `state.d` (root host nodes +\n// their original `display` so we can restore it) and the fallback as a\n// detached Fragment fiber in `state.f` (deliberately kept OUT of\n// `fiber.child` so reconciles against `props.children` don't trip on it).\n// First-mount suspensions have no committed DOM worth preserving, so they\n// keep the original unmount-and-render-fallback behavior.\ninterface SuspenseState {\n p?: Promise<any> | null\n b?: Comment\n e?: Comment\n r?: any\n a?: boolean\n // Re-suspend preservation:\n d?: Array<[HTMLElement, string]> | null\n f?: Fiber | null\n}\n\nfunction renderSuspense(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const props = fiber.pp ?? {}\n const state = (fiber.ms ??= {}) as SuspenseState\n\n // Streaming hydration: if the next DOM node is a server-emitted boundary\n // marker, route through the boundary-aware hydration path.\n const root = getCurrentRoot()\n if (root?.h && !state.b) {\n const boundary = tryConsumeBoundary(fiber.parent!)\n if (boundary) {\n hydrateSuspenseBoundary(fiber, props, boundary, domParent, anchor)\n return\n }\n }\n\n // A descendant Lazy deferred its hydration (see renderLazy's hydrating\n // branch). Its SSR-rendered content is still in the DOM and cursor-bound\n // via the Lazy fiber \u2014 we just haven't swapped it into a fiber subtree\n // yet. Until the Lazy's resume fires, skip our own tryChildren pass so\n // an unrelated re-render can't accidentally flip us into the suspended\n // path and mount a duplicate fallback on top of the SSR content.\n if (state.a) {\n fiber.mp = props\n return\n }\n\n // We were already in the suspended-with-preserved-primary state. Don't\n // re-attempt primary children (would re-throw and churn the tree). Just\n // refresh the fallback in case its JSX changed, and wait for the pending\n // promise to fire scheduleUpdate.\n if (state.p) {\n if (state.f) {\n state.f.pp = { children: props.fallback }\n renderFiber(state.f, domParent, anchor)\n } else {\n // Initial-mount suspended path: no committed primary to preserve.\n reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)\n }\n fiber.mp = props\n return\n }\n\n // Snapshot whether we have an existing committed primary tree before\n // attempting the new render. If the new attempt suspends and we did have a\n // committed primary, we keep it (hidden) rather than destroying it.\n const hadCommittedPrimary = fiber.mp !== undefined && fiber.child !== null\n\n const prevHandler = suspendHandler\n let pendingThenable: any\n suspendHandler = (thenable) => {\n pendingThenable = thenable\n }\n try {\n reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)\n } finally {\n suspendHandler = prevHandler\n }\n\n if (pendingThenable) {\n state.p = pendingThenable\n const onSettle = () => {\n state.p = null\n scheduleUpdate(fiber)\n }\n pendingThenable.then(onSettle, onSettle)\n\n if (hadCommittedPrimary && fiber.child) {\n // Hide the primary subtree's root host doms so the fallback is the only\n // thing visible, but the underlying nodes (and their scroll/state/focus)\n // survive. Save original `display` for the resume path.\n const hidden: Array<[HTMLElement, string]> = []\n let c: Fiber | null = fiber.child\n while (c) {\n hideRootHostDoms(c, hidden)\n c = c.sibling\n }\n state.d = hidden\n\n // Mount fallback in a detached Fragment fiber. Kept off `fiber.child`\n // so reconciles of primary don't see it as a stale match candidate.\n if (!state.f) {\n state.f = createFiber(FiberTag.Fragment, null, null)\n state.f.parent = fiber\n }\n state.f.pp = { children: props.fallback }\n renderFiber(state.f, domParent, anchor)\n } else {\n // First-mount suspension \u2014 nothing to preserve.\n unmountAllChildren(fiber, domParent)\n reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)\n }\n } else {\n // Render succeeded. Clean up any preserved-suspend state from a prior\n // suspension cycle: unhide primary, unmount the orphan fallback fiber.\n if (state.d) {\n for (const [el, origDisplay] of state.d) {\n el.style.display = origDisplay\n }\n state.d = null\n }\n if (state.f) {\n unmountFiber(state.f, domParent)\n state.f = null\n }\n }\n fiber.mp = props\n}\n\n// Walk a fiber subtree collecting host/text DOM nodes that sit at the root\n// of the subtree (do not descend through their children \u2014 display:none on\n// the root hides the whole element). Used by the hide-on-suspend path.\nfunction hideRootHostDoms(fiber: Fiber, out: Array<[HTMLElement, string]>): void {\n if (fiber.tag === FiberTag.Host) {\n const el = fiber.dom as HTMLElement | null\n if (el) {\n out.push([el, el.style.display])\n el.style.display = 'none'\n }\n return\n }\n if (fiber.tag === FiberTag.Portal) return\n let c = fiber.child\n while (c) {\n hideRootHostDoms(c, out)\n c = c.sibling\n }\n}\n\nfunction hydrateSuspenseBoundary(\n fiber: Fiber,\n props: any,\n boundary: [0 | 1, number, Comment, Comment],\n domParent: Node,\n anchor: Node | null,\n): void {\n const [pendingBoundary, id, startMark, endMark] = boundary\n // Record the boundary shape so we can re-hydrate on reveal.\n fiber.ms = {\n b: startMark,\n e: endMark,\n r: props.children,\n }\n\n if (!pendingBoundary) {\n // Real DOM is inline between startMark and endMark. Hydrate into it.\n const parent = startMark.parentNode!\n try {\n setHydrationCursor(fiber, new HydrationCursor(parent, startMark.nextSibling, endMark))\n reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)\n advanceCursorPast(fiber.parent!, endMark)\n } catch (e) {\n if (!isHydrationBailout(e)) {\n clearBoundaryRange(startMark, endMark)\n unmountAllChildren(fiber, parent)\n throw e\n }\n recoverBoundaryHydration(fiber, props.children, parent, startMark, endMark)\n } finally {\n clearHydrationCursor(fiber)\n }\n fiber.mp = props\n return\n }\n\n // Pending: fallback DOM lives inside <div id=\"B:ID\">. Hydrate the fallback\n // React subtree against that div's children.\n const bDiv = document.getElementById(`B:${id}`)\n try {\n if (bDiv) {\n setHydrationCursor(fiber, new HydrationCursor(bDiv))\n reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)\n } else {\n // Couldn't find fallback container \u2014 render fresh (non-adopting)\n reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)\n }\n } catch (e) {\n if (!isHydrationBailout(e) || !bDiv) throw e\n recoverFallbackHydration(fiber, props.fallback, bDiv)\n } finally {\n clearHydrationCursor(fiber)\n }\n advanceCursorPast(fiber.parent!, endMark)\n\n // Register for server-streamed reveal (HTML chunks + $RC calls).\n ;(globalThis as any).$RH?.(id, () => rehydrateBoundary(fiber))\n // If the inline runtime isn't present, nothing external will mark us dy.\n\n fiber.mp = props\n}\n\nfunction recoverBoundaryHydration(\n fiber: Fiber,\n children: any,\n parent: Node,\n startMark: Comment,\n endMark: Comment,\n): void {\n const root = findRoot(fiber)!\n const prevHydrating = root.h\n discardPendingWork(root)\n clearBoundaryRange(startMark, endMark)\n unmountAllChildren(fiber, parent)\n root.h = false\n try {\n reconcileChildren(fiber, childrenToArray(children), parent, endMark)\n advanceCursorPast(fiber.parent!, endMark)\n } catch (clientError) {\n clearBoundaryRange(startMark, endMark)\n unmountAllChildren(fiber, parent)\n throw clientError\n } finally {\n root.h = prevHydrating\n }\n}\n\nfunction recoverFallbackHydration(fiber: Fiber, fallback: any, parent: HTMLElement): void {\n const root = findRoot(fiber)!\n const prevHydrating = root.h\n discardPendingWork(root)\n parent.textContent = ''\n unmountAllChildren(fiber, parent)\n root.h = false\n try {\n reconcileChildren(fiber, childrenToArray(fallback), parent, null)\n } catch (clientError) {\n parent.textContent = ''\n unmountAllChildren(fiber, parent)\n throw clientError\n } finally {\n root.h = prevHydrating\n }\n}\n\nfunction rehydrateBoundary(fiber: Fiber): void {\n const state = fiber.ms\n if (!state || !state.b || !state.e) return\n\n const root = findRoot(fiber)\n const parent = state.b.parentNode as Node\n if (!root || !parent) return\n\n // Unmount existing fallback subtree. Its DOM has already been removed by $RC\n // (or at least its container); unmounting here cleans up fibers + fx.\n withCurrentRoot(root, () => {\n const prevHydrating = root.h\n try {\n unmountAllChildren(fiber, parent)\n\n // Re-hydrate with real children against the now-real DOM range.\n root.h = true\n setHydrationCursor(fiber, new HydrationCursor(parent, state.b.nextSibling, state.e))\n reconcileChildren(fiber, childrenToArray(state.r), parent, null)\n } catch (e) {\n if (!isHydrationBailout(e)) {\n clearBoundaryRange(state.b, state.e)\n unmountAllChildren(fiber, parent)\n throw e\n }\n\n recoverBoundaryHydration(fiber, state.r, parent, state.b, state.e)\n } finally {\n root.h = prevHydrating\n clearHydrationCursor(fiber)\n }\n runEffects(root)\n })\n}\n\nfunction clearBoundaryRange(startMark: Comment, endMark: Comment): void {\n let node = startMark.nextSibling\n while (node && node !== endMark) {\n const next = node.nextSibling\n node.parentNode?.removeChild(node)\n node = next\n }\n}\n\nregisterTypeMatcher((type) => (type === REACT_SUSPENSE_TYPE ? FiberTag.Suspense : null))\nregisterRenderer(FiberTag.Suspense, renderSuspense)\ninstallCapability('handleSuspended', realHandleSuspended)\n"],
5
- "mappings": ";AAAA,SAAS,UAAU,mBAA+B;AAClD,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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MAAM,GAAG,MAAM,CAAC;AACnC,2BAAmB,OAAO,MAAM;AAChC,cAAM;AAAA,MACR;AAEA,+BAAyB,OAAO,MAAM,GAAG,QAAQ,MAAM,GAAG,MAAM,CAAC;AAAA,IACnE,UAAE;AACA,WAAK,IAAI;AACT,2BAAqB,KAAK;AAAA,IAC5B;AACA,eAAW,IAAI;AAAA,EACjB,CAAC;AACH;AAEA,SAAS,mBAAmB,WAAoB,SAAwB;AACtE,MAAI,OAAO,UAAU;AACrB,SAAO,QAAQ,SAAS,SAAS;AAC/B,UAAM,OAAO,KAAK;AAClB,SAAK,YAAY,YAAY,IAAI;AACjC,WAAO;AAAA,EACT;AACF;AAEA,oBAAoB,CAAC,SAAU,SAAS,sBAAsB,SAAS,WAAW,IAAK;AACvF,iBAAiB,SAAS,UAAU,cAAc;AAClD,kBAAkB,mBAAmB,mBAAmB;",
4
+ "sourcesContent": ["import { FiberTag, createFiber, type Fiber } from '../../../core'\nimport { REACT_SUSPENSE_TYPE } from '../../../react'\nimport {\n registerRenderer,\n registerTypeMatcher,\n installCapability,\n reconcileChildren,\n childrenToArray,\n renderFiber,\n scheduleUpdate,\n unmountAllChildren,\n unmountFiber,\n findRoot,\n runEffects,\n getCurrentRoot,\n withCurrentRoot,\n discardPendingWork,\n} from '../../reconcile'\nimport {\n HydrationCursor,\n setHydrationCursor,\n clearHydrationCursor,\n advanceCursorPast,\n tryConsumeBoundary,\n isHydrationBailout,\n} from '../hydration'\n\nlet suspendHandler: ((t: Promise<any>) => void) | null = null\n\nfunction realHandleSuspended(fiber: Fiber, thenable: Promise<any>): void {\n if (suspendHandler) return suspendHandler(thenable)\n // Fallback: schedule re-render when promise settles\n thenable.then(\n () => scheduleUpdate(fiber),\n () => scheduleUpdate(fiber),\n )\n}\n\n// React's Suspense semantics: when a re-render of an already-committed\n// boundary suspends, the previously-committed children are kept in the DOM\n// (hidden) so their scroll position, focus, selection, native form state,\n// and component state survive across the suspension. The fallback is mounted\n// alongside the hidden primary until the pending promise resolves.\n//\n// We track the hidden subtree DOM in `state.d` (root host nodes +\n// their original `display` so we can restore it) and the fallback as a\n// detached Fragment fiber in `state.f` (deliberately kept OUT of\n// `fiber.child` so reconciles against `props.children` don't trip on it).\n// First-mount suspensions have no committed DOM worth preserving, so they\n// keep the original unmount-and-render-fallback behavior.\ninterface SuspenseState {\n p?: Promise<any> | null\n b?: Comment\n e?: Comment\n r?: any\n a?: boolean\n // Re-suspend preservation:\n d?: Array<[HTMLElement, string]> | null\n f?: Fiber | null\n}\n\nfunction renderSuspense(fiber: Fiber, domParent: Node, anchor: Node | null): void {\n const props = fiber.pp ?? {}\n const state = (fiber.ms ??= {}) as SuspenseState\n\n // Streaming hydration: if the next DOM node is a server-emitted boundary\n // marker, route through the boundary-aware hydration path.\n const root = getCurrentRoot()\n if (root?.h && !state.b) {\n const boundary = tryConsumeBoundary(fiber.parent!)\n if (boundary) {\n hydrateSuspenseBoundary(fiber, props, boundary, domParent, anchor)\n return\n }\n }\n\n // A descendant Lazy deferred its hydration (see renderLazy's hydrating\n // branch). Its SSR-rendered content is still in the DOM and cursor-bound\n // via the Lazy fiber \u2014 we just haven't swapped it into a fiber subtree\n // yet. Until the Lazy's resume fires, skip our own tryChildren pass so\n // an unrelated re-render can't accidentally flip us into the suspended\n // path and mount a duplicate fallback on top of the SSR content.\n if (state.a) {\n fiber.mp = props\n return\n }\n\n // We were already in the suspended-with-preserved-primary state. Don't\n // re-attempt primary children (would re-throw and churn the tree). Just\n // refresh the fallback in case its JSX changed, and wait for the pending\n // promise to fire scheduleUpdate.\n if (state.p) {\n if (state.f) {\n state.f.pp = { children: props.fallback }\n renderFiber(state.f, domParent, anchor)\n } else {\n // Initial-mount suspended path: no committed primary to preserve.\n reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)\n }\n fiber.mp = props\n return\n }\n\n // Snapshot whether we have an existing committed primary tree before\n // attempting the new render. If the new attempt suspends and we did have a\n // committed primary, we keep it (hidden) rather than destroying it.\n const hadCommittedPrimary = fiber.mp && fiber.child\n\n const prevHandler = suspendHandler\n let pendingThenable: any\n suspendHandler = (thenable) => {\n pendingThenable = thenable\n }\n try {\n reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)\n } finally {\n suspendHandler = prevHandler\n }\n\n if (pendingThenable) {\n state.p = pendingThenable\n const onSettle = () => {\n state.p = null\n scheduleUpdate(fiber)\n }\n pendingThenable.then(onSettle, onSettle)\n\n if (hadCommittedPrimary) {\n // Hide the primary subtree's root host doms so the fallback is the only\n // thing visible, but the underlying nodes (and their scroll/state/focus)\n // survive. Save original `display` for the resume path.\n const hidden: Array<[HTMLElement, string]> = []\n let c: Fiber | null = hadCommittedPrimary\n while (c) {\n hideRootHostDoms(c, hidden)\n c = c.sibling\n }\n state.d = hidden\n\n // Mount fallback in a detached Fragment fiber. Kept off `fiber.child`\n // so reconciles of primary don't see it as a stale match candidate.\n if (!state.f) {\n state.f = createFiber(FiberTag.Fragment, null, null)\n state.f.parent = fiber\n }\n state.f.pp = { children: props.fallback }\n renderFiber(state.f, domParent, anchor)\n } else {\n // First-mount suspension \u2014 nothing to preserve.\n unmountAllChildren(fiber, domParent)\n reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)\n }\n } else {\n // Render succeeded. Clean up any preserved-suspend state from a prior\n // suspension cycle: unhide primary, unmount the orphan fallback fiber.\n if (state.d) {\n for (const [el, origDisplay] of state.d) {\n el.style.display = origDisplay\n }\n state.d = null\n }\n if (state.f) {\n unmountFiber(state.f, domParent)\n state.f = null\n }\n }\n fiber.mp = props\n}\n\n// Walk a fiber subtree collecting host/text DOM nodes that sit at the root\n// of the subtree (do not descend through their children \u2014 display:none on\n// the root hides the whole element). Used by the hide-on-suspend path.\nfunction hideRootHostDoms(fiber: Fiber, out: Array<[HTMLElement, string]>): void {\n if (fiber.tag === FiberTag.Host) {\n const el = fiber.dom as HTMLElement\n out.push([el, el.style.display])\n el.style.display = 'none'\n return\n }\n if (fiber.tag === FiberTag.Portal) return\n let c = fiber.child\n while (c) {\n hideRootHostDoms(c, out)\n c = c.sibling\n }\n}\n\nfunction hydrateSuspenseBoundary(\n fiber: Fiber,\n props: any,\n boundary: [0 | 1, number, Comment, Comment],\n domParent: Node,\n anchor: Node | null,\n): void {\n const [pendingBoundary, id, startMark, endMark] = boundary\n // Record the boundary shape so we can re-hydrate on reveal.\n fiber.ms = {\n b: startMark,\n e: endMark,\n r: props.children,\n }\n\n if (!pendingBoundary) {\n // Real DOM is inline between startMark and endMark. Hydrate into it.\n const parent = startMark.parentNode!\n try {\n setHydrationCursor(fiber, new HydrationCursor(parent, startMark.nextSibling, endMark))\n reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor)\n advanceCursorPast(fiber.parent!, endMark)\n } catch (e) {\n if (!isHydrationBailout(e)) {\n clearBoundaryRange(startMark, endMark)\n unmountAllChildren(fiber, parent)\n throw e\n }\n recoverBoundaryHydration(fiber, props.children, parent, startMark, endMark)\n } finally {\n clearHydrationCursor(fiber)\n }\n fiber.mp = props\n return\n }\n\n // Pending: fallback DOM lives inside <div id=\"B:ID\">. Hydrate the fallback\n // React subtree against that div's children.\n const bDiv = document.getElementById(`B:${id}`)\n try {\n if (bDiv) {\n setHydrationCursor(fiber, new HydrationCursor(bDiv))\n reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)\n } else {\n // Couldn't find fallback container \u2014 render fresh (non-adopting)\n reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)\n }\n } catch (e) {\n if (!isHydrationBailout(e) || !bDiv) throw e\n recoverFallbackHydration(fiber, props.fallback, bDiv)\n } finally {\n clearHydrationCursor(fiber)\n }\n advanceCursorPast(fiber.parent!, endMark)\n\n // Register for server-streamed reveal (HTML chunks + $RC calls).\n ;(globalThis as any).$RH?.(id, () => rehydrateBoundary(fiber))\n // If the inline runtime isn't present, nothing external will mark us dy.\n\n fiber.mp = props\n}\n\nfunction recoverBoundaryHydration(\n fiber: Fiber,\n children: any,\n parent: Node,\n startMark: Comment,\n endMark: Comment,\n): void {\n const root = findRoot(fiber)!\n const prevHydrating = root.h\n discardPendingWork(root)\n clearBoundaryRange(startMark, endMark)\n unmountAllChildren(fiber, parent)\n root.h = false\n try {\n reconcileChildren(fiber, childrenToArray(children), parent, endMark)\n advanceCursorPast(fiber.parent!, endMark)\n } catch (clientError) {\n clearBoundaryRange(startMark, endMark)\n unmountAllChildren(fiber, parent)\n throw clientError\n } finally {\n root.h = prevHydrating\n }\n}\n\nfunction recoverFallbackHydration(fiber: Fiber, fallback: any, parent: HTMLElement): void {\n const root = findRoot(fiber)!\n const prevHydrating = root.h\n discardPendingWork(root)\n parent.textContent = ''\n unmountAllChildren(fiber, parent)\n root.h = false\n try {\n reconcileChildren(fiber, childrenToArray(fallback), parent, null)\n } catch (clientError) {\n parent.textContent = ''\n unmountAllChildren(fiber, parent)\n throw clientError\n } finally {\n root.h = prevHydrating\n }\n}\n\nfunction rehydrateBoundary(fiber: Fiber): void {\n const state = fiber.ms\n if (!state?.b || !state.e) return\n\n const root = findRoot(fiber)\n const parent = state.b.parentNode as Node\n if (!(root && parent)) return\n\n // Unmount existing fallback subtree. Its DOM has already been removed by $RC\n // (or at least its container); unmounting here cleans up fibers + fx.\n withCurrentRoot(root, () => {\n const prevHydrating = root.h\n try {\n unmountAllChildren(fiber, parent)\n\n // Re-hydrate with real children against the now-real DOM range.\n root.h = true\n setHydrationCursor(fiber, new HydrationCursor(parent, state.b.nextSibling, state.e))\n reconcileChildren(fiber, childrenToArray(state.r), parent, null)\n } catch (e) {\n if (!isHydrationBailout(e)) {\n clearBoundaryRange(state.b, state.e)\n unmountAllChildren(fiber, parent)\n throw e\n }\n\n recoverBoundaryHydration(fiber, state.r, parent, state.b, state.e)\n } finally {\n root.h = prevHydrating\n clearHydrationCursor(fiber)\n }\n runEffects(root)\n })\n}\n\nfunction clearBoundaryRange(startMark: Comment, endMark: Comment): void {\n let node = startMark.nextSibling\n while (node && node !== endMark) {\n const next = node.nextSibling\n node.parentNode?.removeChild(node)\n node = next\n }\n}\n\nregisterTypeMatcher((type) => (type === REACT_SUSPENSE_TYPE ? FiberTag.Suspense : null))\nregisterRenderer(FiberTag.Suspense, renderSuspense)\ninstallCapability('handleSuspended', realHandleSuspended)\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU,mBAA+B;AAClD,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,IAAI,iBAAqD;AAEzD,SAAS,oBAAoB,OAAc,UAA8B;AACvE,MAAI,eAAgB,QAAO,eAAe,QAAQ;AAElD,WAAS;AAAA,IACP,MAAM,eAAe,KAAK;AAAA,IAC1B,MAAM,eAAe,KAAK;AAAA,EAC5B;AACF;AAyBA,SAAS,eAAe,OAAc,WAAiB,QAA2B;AAChF,QAAM,QAAQ,MAAM,MAAM,CAAC;AAC3B,QAAM,QAAS,MAAM,OAAO,CAAC;AAI7B,QAAM,OAAO,eAAe;AAC5B,MAAI,MAAM,KAAK,CAAC,MAAM,GAAG;AACvB,UAAM,WAAW,mBAAmB,MAAM,MAAO;AACjD,QAAI,UAAU;AACZ,8BAAwB,OAAO,OAAO,UAAU,WAAW,MAAM;AACjE;AAAA,IACF;AAAA,EACF;AAQA,MAAI,MAAM,GAAG;AACX,UAAM,KAAK;AACX;AAAA,EACF;AAMA,MAAI,MAAM,GAAG;AACX,QAAI,MAAM,GAAG;AACX,YAAM,EAAE,KAAK,EAAE,UAAU,MAAM,SAAS;AACxC,kBAAY,MAAM,GAAG,WAAW,MAAM;AAAA,IACxC,OAAO;AAEL,wBAAkB,OAAO,gBAAgB,MAAM,QAAQ,GAAG,WAAW,MAAM;AAAA,IAC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AACvB,MAAI,EAAE,QAAQ,QAAS;AAIvB,kBAAgB,MAAM,MAAM;AAC1B,UAAM,gBAAgB,KAAK;AAC3B,QAAI;AACF,yBAAmB,OAAO,MAAM;AAGhC,WAAK,IAAI;AACT,yBAAmB,OAAO,IAAI,gBAAgB,QAAQ,MAAM,EAAE,aAAa,MAAM,CAAC,CAAC;AACnF,wBAAkB,OAAO,gBAAgB,MAAM,CAAC,GAAG,QAAQ,IAAI;AAAA,IACjE,SAAS,GAAG;AACV,UAAI,CAAC,mBAAmB,CAAC,GAAG;AAC1B,2BAAmB,MAAM,GAAG,MAAM,CAAC;AACnC,2BAAmB,OAAO,MAAM;AAChC,cAAM;AAAA,MACR;AAEA,+BAAyB,OAAO,MAAM,GAAG,QAAQ,MAAM,GAAG,MAAM,CAAC;AAAA,IACnE,UAAE;AACA,WAAK,IAAI;AACT,2BAAqB,KAAK;AAAA,IAC5B;AACA,eAAW,IAAI;AAAA,EACjB,CAAC;AACH;AAEA,SAAS,mBAAmB,WAAoB,SAAwB;AACtE,MAAI,OAAO,UAAU;AACrB,SAAO,QAAQ,SAAS,SAAS;AAC/B,UAAM,OAAO,KAAK;AAClB,SAAK,YAAY,YAAY,IAAI;AACjC,WAAO;AAAA,EACT;AACF;AAEA,oBAAoB,CAAC,SAAU,SAAS,sBAAsB,SAAS,WAAW,IAAK;AACvF,iBAAiB,SAAS,UAAU,cAAc;AAClD,kBAAkB,mBAAmB,mBAAmB;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/redact",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "React, redacted. A minimal React-API-compatible drop-in replacement.",
5
5
  "type": "module",
6
6
  "main": "./dist/react/index.js",
@@ -490,14 +490,19 @@ function findHostRecoveryParent(fiber: Fiber): Fiber | null {
490
490
  }
491
491
 
492
492
  function findNearestSafeHostAboveComposite(fiber: Fiber | null): Fiber | null {
493
+ let host: Fiber | null = null
493
494
  let f = fiber
494
495
  while (f) {
495
496
  if (f.tag === FiberTag.Host && f.dom) {
496
- return isSafeHostRecoveryElement(f) ? f : null
497
+ if (!isSafeHostRecoveryElement(f)) return null
498
+ const parentTag = f.parent?.tag as number
499
+ if (!host || (parentTag > FiberTag.Text && parentTag < FiberTag.Suspense)) {
500
+ host = f
501
+ }
497
502
  }
498
503
  f = f.parent
499
504
  }
500
- return null
505
+ return host
501
506
  }
502
507
 
503
508
  function isSafeHostRecoveryElement(fiber: Fiber): boolean {
@@ -535,10 +540,8 @@ function getRecoverableHostChildren(
535
540
  ): [Element, ReactNode] | null {
536
541
  const host = error.f
537
542
  if (
538
- !host ||
539
- host.tag !== FiberTag.Host ||
543
+ host?.tag !== FiberTag.Host ||
540
544
  !host.dom ||
541
- !isSafeHostRecoveryElement(host) ||
542
545
  !findNearestSafeHostAboveComposite(host.parent)
543
546
  ) {
544
547
  return null
@@ -104,7 +104,7 @@ function renderSuspense(fiber: Fiber, domParent: Node, anchor: Node | null): voi
104
104
  // Snapshot whether we have an existing committed primary tree before
105
105
  // attempting the new render. If the new attempt suspends and we did have a
106
106
  // committed primary, we keep it (hidden) rather than destroying it.
107
- const hadCommittedPrimary = fiber.mp !== undefined && fiber.child !== null
107
+ const hadCommittedPrimary = fiber.mp && fiber.child
108
108
 
109
109
  const prevHandler = suspendHandler
110
110
  let pendingThenable: any
@@ -125,12 +125,12 @@ function renderSuspense(fiber: Fiber, domParent: Node, anchor: Node | null): voi
125
125
  }
126
126
  pendingThenable.then(onSettle, onSettle)
127
127
 
128
- if (hadCommittedPrimary && fiber.child) {
128
+ if (hadCommittedPrimary) {
129
129
  // Hide the primary subtree's root host doms so the fallback is the only
130
130
  // thing visible, but the underlying nodes (and their scroll/state/focus)
131
131
  // survive. Save original `display` for the resume path.
132
132
  const hidden: Array<[HTMLElement, string]> = []
133
- let c: Fiber | null = fiber.child
133
+ let c: Fiber | null = hadCommittedPrimary
134
134
  while (c) {
135
135
  hideRootHostDoms(c, hidden)
136
136
  c = c.sibling
@@ -172,11 +172,9 @@ function renderSuspense(fiber: Fiber, domParent: Node, anchor: Node | null): voi
172
172
  // the root hides the whole element). Used by the hide-on-suspend path.
173
173
  function hideRootHostDoms(fiber: Fiber, out: Array<[HTMLElement, string]>): void {
174
174
  if (fiber.tag === FiberTag.Host) {
175
- const el = fiber.dom as HTMLElement | null
176
- if (el) {
177
- out.push([el, el.style.display])
178
- el.style.display = 'none'
179
- }
175
+ const el = fiber.dom as HTMLElement
176
+ out.push([el, el.style.display])
177
+ el.style.display = 'none'
180
178
  return
181
179
  }
182
180
  if (fiber.tag === FiberTag.Portal) return
@@ -294,11 +292,11 @@ function recoverFallbackHydration(fiber: Fiber, fallback: any, parent: HTMLEleme
294
292
 
295
293
  function rehydrateBoundary(fiber: Fiber): void {
296
294
  const state = fiber.ms
297
- if (!state || !state.b || !state.e) return
295
+ if (!state?.b || !state.e) return
298
296
 
299
297
  const root = findRoot(fiber)
300
298
  const parent = state.b.parentNode as Node
301
- if (!root || !parent) return
299
+ if (!(root && parent)) return
302
300
 
303
301
  // Unmount existing fallback subtree. Its DOM has already been removed by $RC
304
302
  // (or at least its container); unmounting here cleans up fibers + fx.