@tanstack/redact 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dom/features/hydration/full.js +19 -8
- package/dist/dom/features/hydration/full.js.map +2 -2
- package/dist/dom/index.d.ts +30 -0
- package/dist/dom/index.js +26 -0
- package/dist/dom/index.js.map +2 -2
- package/dist/dom/reconcile.js +12 -0
- package/dist/dom/reconcile.js.map +2 -2
- package/dist/dom/root.js +79 -3
- package/dist/dom/root.js.map +2 -2
- package/dist/server/bootstrap-script.d.ts +4 -1
- package/dist/server/bootstrap-script.js.map +2 -2
- package/dist/server/stream.d.ts +1 -0
- package/dist/server/stream.js +72 -7
- package/dist/server/stream.js.map +2 -2
- package/dist/server/walk.js +21 -0
- package/dist/server/walk.js.map +2 -2
- package/dist/vite/index.js +2 -0
- package/dist/vite/index.js.map +2 -2
- package/package.json +1 -1
- package/src/dom/features/hydration/full.ts +25 -8
- package/src/dom/index.ts +17 -0
- package/src/dom/reconcile.ts +15 -1
- package/src/dom/root.ts +99 -3
- package/src/server/bootstrap-script.ts +4 -1
- package/src/server/stream.ts +88 -7
- package/src/server/walk.ts +30 -0
- package/src/vite/index.ts +2 -0
|
@@ -7,18 +7,18 @@ var GUARD_WINDOW_MS = 3e3;
|
|
|
7
7
|
function installHydrationScrollGuard() {
|
|
8
8
|
if (typeof window === "undefined") return;
|
|
9
9
|
const w = window;
|
|
10
|
-
if (w.
|
|
11
|
-
w.
|
|
10
|
+
if (w.__redactScrollGuardInstalled) return;
|
|
11
|
+
w.__redactScrollGuardInstalled = true;
|
|
12
12
|
const guardStartedAt = performance.now();
|
|
13
13
|
let lastUserScrollAt = 0;
|
|
14
14
|
let programmatic = 0;
|
|
15
|
-
w.
|
|
15
|
+
w.__redactScrollLog = [];
|
|
16
16
|
window.addEventListener(
|
|
17
17
|
"scroll",
|
|
18
18
|
() => {
|
|
19
19
|
if (programmatic === 0) {
|
|
20
20
|
lastUserScrollAt = performance.now();
|
|
21
|
-
w.
|
|
21
|
+
w.__redactScrollLog.push({ t: Math.round(lastUserScrollAt), ev: "user-scroll", y: window.scrollY });
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
{ capture: true, passive: true }
|
|
@@ -29,7 +29,7 @@ function installHydrationScrollGuard() {
|
|
|
29
29
|
const inGuardWindow = now - guardStartedAt < GUARD_WINDOW_MS;
|
|
30
30
|
const userScrolledRecently = lastUserScrollAt > 0 && now - lastUserScrollAt < 1500;
|
|
31
31
|
if (inGuardWindow && userScrolledRecently) {
|
|
32
|
-
w.
|
|
32
|
+
w.__redactScrollLog.push({
|
|
33
33
|
t: Math.round(now),
|
|
34
34
|
ev: "suppressed",
|
|
35
35
|
args: JSON.stringify(args).slice(0, 80),
|
|
@@ -38,7 +38,7 @@ function installHydrationScrollGuard() {
|
|
|
38
38
|
});
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
w.
|
|
41
|
+
w.__redactScrollLog.push({
|
|
42
42
|
t: Math.round(now),
|
|
43
43
|
ev: "allowed",
|
|
44
44
|
args: JSON.stringify(args).slice(0, 80),
|
|
@@ -115,6 +115,7 @@ var HEAD_KEY_ATTRS = {
|
|
|
115
115
|
style: [],
|
|
116
116
|
title: []
|
|
117
117
|
};
|
|
118
|
+
var DOCUMENT_HEAD_TAGS = /* @__PURE__ */ new Set(["base", "link", "meta", "script", "style", "title"]);
|
|
118
119
|
var CLAIMED = /* @__PURE__ */ new WeakSet();
|
|
119
120
|
function headAttrsMatch(el, props, keys) {
|
|
120
121
|
if (CLAIMED.has(el)) return false;
|
|
@@ -179,11 +180,17 @@ function adoptHostDom(fiber, parent) {
|
|
|
179
180
|
const cursor = hydrationCursors.get(hostParent);
|
|
180
181
|
if (!cursor) return false;
|
|
181
182
|
const tag = fiber.type.toLowerCase();
|
|
183
|
+
const documentHeadParent = getDocumentHeadParent(cursor.parent, tag);
|
|
182
184
|
const parentEl = cursor.parent;
|
|
183
185
|
const parentTag = parentEl.nodeType === 1 ? parentEl.tagName.toLowerCase() : "";
|
|
184
|
-
const isHeadish = parentTag === "head" || parentTag === "html";
|
|
186
|
+
const isHeadish = parentTag === "head" || parentTag === "html" || !!documentHeadParent;
|
|
185
187
|
let candidate;
|
|
186
|
-
if (
|
|
188
|
+
if (documentHeadParent) {
|
|
189
|
+
candidate = new HydrationCursor(documentHeadParent).takeMatchingHeadElement(
|
|
190
|
+
tag,
|
|
191
|
+
fiber.pendingProps ?? {}
|
|
192
|
+
);
|
|
193
|
+
} else if (isHeadish) {
|
|
187
194
|
candidate = cursor.takeMatchingHeadElement(tag, fiber.pendingProps ?? {});
|
|
188
195
|
} else {
|
|
189
196
|
candidate = cursor.takeHostNode();
|
|
@@ -208,6 +215,10 @@ function adoptHostDom(fiber, parent) {
|
|
|
208
215
|
hydrationCursors.set(fiber, new HydrationCursor(candidate));
|
|
209
216
|
return true;
|
|
210
217
|
}
|
|
218
|
+
function getDocumentHeadParent(parent, tag) {
|
|
219
|
+
if (parent.nodeType !== 9 || !DOCUMENT_HEAD_TAGS.has(tag)) return null;
|
|
220
|
+
return parent.head;
|
|
221
|
+
}
|
|
211
222
|
function adoptTextDom(fiber, parent, text) {
|
|
212
223
|
const cursor = hydrationCursors.get(findHostParent(parent));
|
|
213
224
|
if (!cursor) return false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/dom/features/hydration/full.ts"],
|
|
4
|
-
"sourcesContent": ["import { FiberTag, type Fiber, type FiberRoot } from '../../../core'\nimport { setProp } from '../../dom'\nimport { findRoot } from '../../reconcile'\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 } from '../../event-replay'\n\nconst GUARD_WINDOW_MS = 3000\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.__tdomScrollGuardInstalled) return\n w.__tdomScrollGuardInstalled = true\n const guardStartedAt = performance.now()\n let lastUserScrollAt = 0\n let programmatic = 0\n w.__tdomScrollLog = []\n window.addEventListener(\n 'scroll',\n () => {\n if (programmatic === 0) {\n lastUserScrollAt = performance.now()\n w.__tdomScrollLog.push({ t: Math.round(lastUserScrollAt), ev: 'user-scroll', y: window.scrollY })\n }\n },\n { capture: true, passive: true },\n )\n const origScrollTo = window.scrollTo.bind(window)\n window.scrollTo = function (this: any, ...args: any[]) {\n const now = performance.now()\n const inGuardWindow = now - guardStartedAt < GUARD_WINDOW_MS\n const userScrolledRecently = lastUserScrollAt > 0 && now - lastUserScrollAt < 1500\n if (inGuardWindow && userScrolledRecently) {\n w.__tdomScrollLog.push({\n t: Math.round(now),\n ev: 'suppressed',\n args: JSON.stringify(args).slice(0, 80),\n tSinceHydrate: Math.round(now - guardStartedAt),\n tSinceUserScroll: Math.round(now - lastUserScrollAt),\n })\n return\n }\n w.__tdomScrollLog.push({\n t: Math.round(now),\n ev: 'allowed',\n args: JSON.stringify(args).slice(0, 80),\n tSinceHydrate: Math.round(now - guardStartedAt),\n inGuard: inGuardWindow,\n userScrolled: userScrolledRecently,\n })\n programmatic++\n try {\n return (origScrollTo as any).apply(this, args)\n } finally {\n queueMicrotask(() => {\n programmatic = Math.max(0, programmatic - 1)\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 next: ChildNode | null\n parent: Node\n endBefore: ChildNode | null\n constructor(parent: Node, start: ChildNode | null = null, endBefore: ChildNode | null = null) {\n this.parent = parent\n this.next = start ?? parent.firstChild\n this.endBefore = endBefore\n }\n takeHostNode(): ChildNode | null {\n while (this.next && this.next !== this.endBefore) {\n const n = this.next\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.next = n.nextSibling\n continue\n }\n this.next = 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 takeMatchingHeadElement(tag: string, props: Record<string, any>): ChildNode | null {\n const target = tag.toLowerCase()\n const keyAttrs = HEAD_KEY_ATTRS[target] ?? []\n let scan = this.parent.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 remaining(): ChildNode[] {\n const out: ChildNode[] = []\n let n = this.next\n while (n && n !== this.endBefore) {\n out.push(n)\n n = n.nextSibling\n }\n return out\n }\n}\n\nconst hydrationCursors = new WeakMap<Fiber, HydrationCursor>()\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 style: [],\n title: [],\n}\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>,\n): boolean {\n if (CLAIMED.has(el)) return false\n if (keys.length === 0) return true\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 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 keys.some((k) => props[k] != null || el.hasAttribute(k))\n}\n\nexport function beginHydration(root: FiberRoot): void {\n root.hydrating = true\n hydrationCursors.set(root.current, new HydrationCursor(root.container))\n}\n\nexport function endHydration(root: FiberRoot): void {\n root.hydrating = false\n hydrationCursors.delete(root.current)\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 interface BoundaryInfo {\n kind: 'pending' | 'resolved'\n id: number\n startMark: Comment\n endMark: Comment\n}\n\nexport function tryConsumeBoundary(parent: Fiber): BoundaryInfo | null {\n const cursor = hydrationCursors.get(findHostParent(parent))\n if (!cursor) return null\n const peek = cursor.next\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] === '$?' ? 'pending' : 'resolved'\n const id = Number(m[2])\n const startMark = peek as Comment\n // Advance past the start comment\n cursor.next = 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.next = 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 parentEl = cursor.parent as Element\n const parentTag =\n parentEl.nodeType === 1 ? (parentEl as Element).tagName.toLowerCase() : ''\n const isHeadish = parentTag === 'head' || parentTag === 'html'\n\n let candidate: ChildNode | null\n 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.takeMatchingHeadElement(tag, fiber.pendingProps ?? {})\n } else {\n candidate = cursor.takeHostNode()\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.pendingProps ?? {}\n const isSvg =\n tag === 'svg' ||\n ((candidate as Element).namespaceURI === 'http://www.w3.org/2000/svg' &&\n tag !== 'foreignobject')\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.takeHostNode()\n if (!candidate) return false\n if (candidate.nodeType === 3) {\n if ((candidate as Text).data !== text) {\n ;(candidate as Text).data = text\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 throw new Error('No host parent found')\n}\n\nfunction onMismatch(fiber: Fiber, actualNode: ChildNode | null): void {\n // For v1: log and exit hydration for this subtree. The normal reconciler\n // will create a fresh DOM node below.\n const root = findRoot(fiber)\n if (root?.onRecoverableError) {\n root.onRecoverableError(\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 // Remove stale DOM if still there\n if (actualNode && actualNode.parentNode) actualNode.parentNode.removeChild(actualNode)\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,gBAA4C;AACrD,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAIzB,SAAS,wBAAwB;AAEjC,IAAM,kBAAkB;AAYjB,SAAS,8BAAoC;AAClD,MAAI,OAAO,WAAW,YAAa;AACnC,QAAM,IAAI;AACV,MAAI,EAAE,
|
|
4
|
+
"sourcesContent": ["import { FiberTag, type Fiber, type FiberRoot } from '../../../core'\nimport { setProp } from '../../dom'\nimport { findRoot } from '../../reconcile'\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 } from '../../event-replay'\n\nconst GUARD_WINDOW_MS = 3000\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.__redactScrollGuardInstalled) return\n w.__redactScrollGuardInstalled = true\n const guardStartedAt = performance.now()\n let lastUserScrollAt = 0\n let programmatic = 0\n w.__redactScrollLog = []\n window.addEventListener(\n 'scroll',\n () => {\n if (programmatic === 0) {\n lastUserScrollAt = performance.now()\n w.__redactScrollLog.push({ t: Math.round(lastUserScrollAt), ev: 'user-scroll', y: window.scrollY })\n }\n },\n { capture: true, passive: true },\n )\n const origScrollTo = window.scrollTo.bind(window)\n window.scrollTo = function (this: any, ...args: any[]) {\n const now = performance.now()\n const inGuardWindow = now - guardStartedAt < GUARD_WINDOW_MS\n const userScrolledRecently = lastUserScrollAt > 0 && now - lastUserScrollAt < 1500\n if (inGuardWindow && userScrolledRecently) {\n w.__redactScrollLog.push({\n t: Math.round(now),\n ev: 'suppressed',\n args: JSON.stringify(args).slice(0, 80),\n tSinceHydrate: Math.round(now - guardStartedAt),\n tSinceUserScroll: Math.round(now - lastUserScrollAt),\n })\n return\n }\n w.__redactScrollLog.push({\n t: Math.round(now),\n ev: 'allowed',\n args: JSON.stringify(args).slice(0, 80),\n tSinceHydrate: Math.round(now - guardStartedAt),\n inGuard: inGuardWindow,\n userScrolled: userScrolledRecently,\n })\n programmatic++\n try {\n return (origScrollTo as any).apply(this, args)\n } finally {\n queueMicrotask(() => {\n programmatic = Math.max(0, programmatic - 1)\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 next: ChildNode | null\n parent: Node\n endBefore: ChildNode | null\n constructor(parent: Node, start: ChildNode | null = null, endBefore: ChildNode | null = null) {\n this.parent = parent\n this.next = start ?? parent.firstChild\n this.endBefore = endBefore\n }\n takeHostNode(): ChildNode | null {\n while (this.next && this.next !== this.endBefore) {\n const n = this.next\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.next = n.nextSibling\n continue\n }\n this.next = 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 takeMatchingHeadElement(tag: string, props: Record<string, any>): ChildNode | null {\n const target = tag.toLowerCase()\n const keyAttrs = HEAD_KEY_ATTRS[target] ?? []\n let scan = this.parent.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 remaining(): ChildNode[] {\n const out: ChildNode[] = []\n let n = this.next\n while (n && n !== this.endBefore) {\n out.push(n)\n n = n.nextSibling\n }\n return out\n }\n}\n\nconst hydrationCursors = new WeakMap<Fiber, HydrationCursor>()\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 style: [],\n title: [],\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>,\n): boolean {\n if (CLAIMED.has(el)) return false\n if (keys.length === 0) return true\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 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 keys.some((k) => props[k] != null || el.hasAttribute(k))\n}\n\nexport function beginHydration(root: FiberRoot): void {\n root.hydrating = true\n hydrationCursors.set(root.current, new HydrationCursor(root.container))\n}\n\nexport function endHydration(root: FiberRoot): void {\n root.hydrating = false\n hydrationCursors.delete(root.current)\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 interface BoundaryInfo {\n kind: 'pending' | 'resolved'\n id: number\n startMark: Comment\n endMark: Comment\n}\n\nexport function tryConsumeBoundary(parent: Fiber): BoundaryInfo | null {\n const cursor = hydrationCursors.get(findHostParent(parent))\n if (!cursor) return null\n const peek = cursor.next\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] === '$?' ? 'pending' : 'resolved'\n const id = Number(m[2])\n const startMark = peek as Comment\n // Advance past the start comment\n cursor.next = 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.next = 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 = getDocumentHeadParent(cursor.parent, tag)\n const parentEl = cursor.parent 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).takeMatchingHeadElement(\n tag,\n fiber.pendingProps ?? {},\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.takeMatchingHeadElement(tag, fiber.pendingProps ?? {})\n } else {\n candidate = cursor.takeHostNode()\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.pendingProps ?? {}\n const isSvg =\n tag === 'svg' ||\n ((candidate as Element).namespaceURI === 'http://www.w3.org/2000/svg' &&\n tag !== 'foreignobject')\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\nfunction getDocumentHeadParent(parent: Node, tag: string): HTMLHeadElement | null {\n if (parent.nodeType !== 9 || !DOCUMENT_HEAD_TAGS.has(tag)) return null\n return (parent as Document).head\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.takeHostNode()\n if (!candidate) return false\n if (candidate.nodeType === 3) {\n if ((candidate as Text).data !== text) {\n ;(candidate as Text).data = text\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 throw new Error('No host parent found')\n}\n\nfunction onMismatch(fiber: Fiber, actualNode: ChildNode | null): void {\n // For v1: log and exit hydration for this subtree. The normal reconciler\n // will create a fresh DOM node below.\n const root = findRoot(fiber)\n if (root?.onRecoverableError) {\n root.onRecoverableError(\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 // Remove stale DOM if still there\n if (actualNode && actualNode.parentNode) actualNode.parentNode.removeChild(actualNode)\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,gBAA4C;AACrD,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAIzB,SAAS,wBAAwB;AAEjC,IAAM,kBAAkB;AAYjB,SAAS,8BAAoC;AAClD,MAAI,OAAO,WAAW,YAAa;AACnC,QAAM,IAAI;AACV,MAAI,EAAE,6BAA8B;AACpC,IAAE,+BAA+B;AACjC,QAAM,iBAAiB,YAAY,IAAI;AACvC,MAAI,mBAAmB;AACvB,MAAI,eAAe;AACnB,IAAE,oBAAoB,CAAC;AACvB,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AACJ,UAAI,iBAAiB,GAAG;AACtB,2BAAmB,YAAY,IAAI;AACnC,UAAE,kBAAkB,KAAK,EAAE,GAAG,KAAK,MAAM,gBAAgB,GAAG,IAAI,eAAe,GAAG,OAAO,QAAQ,CAAC;AAAA,MACpG;AAAA,IACF;AAAA,IACA,EAAE,SAAS,MAAM,SAAS,KAAK;AAAA,EACjC;AACA,QAAM,eAAe,OAAO,S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F;AAAA,EACF;AAEA,MAAI,cAAc,WAAW,WAAY,YAAW,WAAW,YAAY,UAAU;AACvF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -7,6 +7,21 @@ export declare function preload(_href: string, _opts?: any): void;
|
|
|
7
7
|
export declare function preinit(_href: string, _opts?: any): void;
|
|
8
8
|
export declare function preloadModule(_href: string, _opts?: any): void;
|
|
9
9
|
export declare function preinitModule(_href: string, _opts?: any): void;
|
|
10
|
+
export declare const __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE: {
|
|
11
|
+
d: {
|
|
12
|
+
f(): void;
|
|
13
|
+
r(): void;
|
|
14
|
+
D(): void;
|
|
15
|
+
C(): void;
|
|
16
|
+
L(): void;
|
|
17
|
+
m(): void;
|
|
18
|
+
X(): void;
|
|
19
|
+
S(): void;
|
|
20
|
+
M(): void;
|
|
21
|
+
};
|
|
22
|
+
p: number;
|
|
23
|
+
findDOMNode: any;
|
|
24
|
+
};
|
|
10
25
|
export declare const version = "19.2.3";
|
|
11
26
|
import { flushSync, batchedUpdates } from './root';
|
|
12
27
|
import { createPortal } from './portal';
|
|
@@ -20,6 +35,21 @@ declare const _default: {
|
|
|
20
35
|
preinit: typeof preinit;
|
|
21
36
|
preloadModule: typeof preloadModule;
|
|
22
37
|
preinitModule: typeof preinitModule;
|
|
38
|
+
__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE: {
|
|
39
|
+
d: {
|
|
40
|
+
f(): void;
|
|
41
|
+
r(): void;
|
|
42
|
+
D(): void;
|
|
43
|
+
C(): void;
|
|
44
|
+
L(): void;
|
|
45
|
+
m(): void;
|
|
46
|
+
X(): void;
|
|
47
|
+
S(): void;
|
|
48
|
+
M(): void;
|
|
49
|
+
};
|
|
50
|
+
p: number;
|
|
51
|
+
findDOMNode: any;
|
|
52
|
+
};
|
|
23
53
|
version: string;
|
|
24
54
|
};
|
|
25
55
|
export default _default;
|
package/dist/dom/index.js
CHANGED
|
@@ -16,6 +16,30 @@ function preloadModule(_href, _opts) {
|
|
|
16
16
|
}
|
|
17
17
|
function preinitModule(_href, _opts) {
|
|
18
18
|
}
|
|
19
|
+
var __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = {
|
|
20
|
+
d: {
|
|
21
|
+
f() {
|
|
22
|
+
},
|
|
23
|
+
r() {
|
|
24
|
+
},
|
|
25
|
+
D() {
|
|
26
|
+
},
|
|
27
|
+
C() {
|
|
28
|
+
},
|
|
29
|
+
L() {
|
|
30
|
+
},
|
|
31
|
+
m() {
|
|
32
|
+
},
|
|
33
|
+
X() {
|
|
34
|
+
},
|
|
35
|
+
S() {
|
|
36
|
+
},
|
|
37
|
+
M() {
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
p: 0,
|
|
41
|
+
findDOMNode: null
|
|
42
|
+
};
|
|
19
43
|
var version = "19.2.3";
|
|
20
44
|
var dom_default = {
|
|
21
45
|
flushSync: flushSync2,
|
|
@@ -27,9 +51,11 @@ var dom_default = {
|
|
|
27
51
|
preinit,
|
|
28
52
|
preloadModule,
|
|
29
53
|
preinitModule,
|
|
54
|
+
__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
30
55
|
version: "19.2.3"
|
|
31
56
|
};
|
|
32
57
|
export {
|
|
58
|
+
__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
33
59
|
createPortal,
|
|
34
60
|
dom_default as default,
|
|
35
61
|
flushSync,
|
package/dist/dom/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/dom/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Side-effect import: registers opt-in features (Portal, etc.) with the\n// reconciler. A vite plugin may alias individual feature modules to their\n// stub variants to strip them from the bundle.\nimport './features'\n\nexport { flushSync, batchedUpdates as unstable_batchedUpdates } from './root'\nexport { createPortal } from './portal'\n\n// Resource hints \u2014 stubs\nexport function preconnect(_href: string, _opts?: any): void {}\nexport function prefetchDNS(_href: string): void {}\nexport function preload(_href: string, _opts?: any): void {}\nexport function preinit(_href: string, _opts?: any): void {}\nexport function preloadModule(_href: string, _opts?: any): void {}\nexport function preinitModule(_href: string, _opts?: any): void {}\n\nexport const version = '19.2.3'\n\n// Required by React's default export consumers\nimport { flushSync, batchedUpdates } from './root'\nimport { createPortal } from './portal'\nexport default {\n flushSync,\n unstable_batchedUpdates: batchedUpdates,\n createPortal,\n preconnect,\n prefetchDNS,\n preload,\n preinit,\n preloadModule,\n preinitModule,\n version: '19.2.3',\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO;AAEP,SAAS,WAA6B,sBAA+B;AACrE,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["// Side-effect import: registers opt-in features (Portal, etc.) with the\n// reconciler. A vite plugin may alias individual feature modules to their\n// stub variants to strip them from the bundle.\nimport './features'\n\nexport { flushSync, batchedUpdates as unstable_batchedUpdates } from './root'\nexport { createPortal } from './portal'\n\n// Resource hints \u2014 stubs\nexport function preconnect(_href: string, _opts?: any): void {}\nexport function prefetchDNS(_href: string): void {}\nexport function preload(_href: string, _opts?: any): void {}\nexport function preinit(_href: string, _opts?: any): void {}\nexport function preloadModule(_href: string, _opts?: any): void {}\nexport function preinitModule(_href: string, _opts?: any): void {}\n\nexport const __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = {\n d: {\n f() {},\n r() {},\n D() {},\n C() {},\n L() {},\n m() {},\n X() {},\n S() {},\n M() {},\n },\n p: 0,\n findDOMNode: null,\n}\n\nexport const version = '19.2.3'\n\n// Required by React's default export consumers\nimport { flushSync, batchedUpdates } from './root'\nimport { createPortal } from './portal'\nexport default {\n flushSync,\n unstable_batchedUpdates: batchedUpdates,\n createPortal,\n preconnect,\n prefetchDNS,\n preload,\n preinit,\n preloadModule,\n preinitModule,\n __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,\n version: '19.2.3',\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO;AAEP,SAAS,WAA6B,sBAA+B;AACrE,SAAS,oBAAoB;AA6B7B,SAAS,aAAAA,YAAW,kBAAAC,uBAAsB;AAC1C,SAAS,gBAAAC,qBAAoB;AA3BtB,SAAS,WAAW,OAAe,OAAmB;AAAC;AACvD,SAAS,YAAY,OAAqB;AAAC;AAC3C,SAAS,QAAQ,OAAe,OAAmB;AAAC;AACpD,SAAS,QAAQ,OAAe,OAAmB;AAAC;AACpD,SAAS,cAAc,OAAe,OAAmB;AAAC;AAC1D,SAAS,cAAc,OAAe,OAAmB;AAAC;AAE1D,IAAM,+DAA+D;AAAA,EAC1E,GAAG;AAAA,IACD,IAAI;AAAA,IAAC;AAAA,IACL,IAAI;AAAA,IAAC;AAAA,IACL,IAAI;AAAA,IAAC;AAAA,IACL,IAAI;AAAA,IAAC;AAAA,IACL,IAAI;AAAA,IAAC;AAAA,IACL,IAAI;AAAA,IAAC;AAAA,IACL,IAAI;AAAA,IAAC;AAAA,IACL,IAAI;AAAA,IAAC;AAAA,IACL,IAAI;AAAA,IAAC;AAAA,EACP;AAAA,EACA,GAAG;AAAA,EACH,aAAa;AACf;AAEO,IAAM,UAAU;AAKvB,IAAO,cAAQ;AAAA,EACb,WAAAF;AAAA,EACA,yBAAyBC;AAAA,EACzB,cAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AACX;",
|
|
6
6
|
"names": ["flushSync", "batchedUpdates", "createPortal"]
|
|
7
7
|
}
|
package/dist/dom/reconcile.js
CHANGED
|
@@ -713,12 +713,24 @@ function unmountAllChildren(parent, domParent) {
|
|
|
713
713
|
parent.child = null;
|
|
714
714
|
}
|
|
715
715
|
function insertInto(parent, node, anchor) {
|
|
716
|
+
const projectedHeadParent = getDocumentHeadInsertionParent(parent, node);
|
|
717
|
+
if (projectedHeadParent) {
|
|
718
|
+
projectedHeadParent.appendChild(node);
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
716
721
|
if (anchor && anchor.parentNode === parent) {
|
|
717
722
|
parent.insertBefore(node, anchor);
|
|
718
723
|
} else {
|
|
719
724
|
parent.appendChild(node);
|
|
720
725
|
}
|
|
721
726
|
}
|
|
727
|
+
var DOCUMENT_HEAD_TAGS = /* @__PURE__ */ new Set(["base", "link", "meta", "script", "style", "title"]);
|
|
728
|
+
function getDocumentHeadInsertionParent(parent, node) {
|
|
729
|
+
if (parent.nodeType !== 9 || node.nodeType !== 1) return null;
|
|
730
|
+
const tag = node.tagName.toLowerCase();
|
|
731
|
+
if (!DOCUMENT_HEAD_TAGS.has(tag)) return null;
|
|
732
|
+
return parent.head;
|
|
733
|
+
}
|
|
722
734
|
function getHostParent(fiber) {
|
|
723
735
|
let p = fiber.parent;
|
|
724
736
|
while (p) {
|