@askrjs/askr 0.0.36 → 0.0.38
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/README.md +17 -9
- package/dist/bench/components/benchmark-table.js +2 -2
- package/dist/bench/components/benchmark-table.js.map +1 -1
- package/dist/benchmark.js +3 -3
- package/dist/boot/index.d.ts +1 -7
- package/dist/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +22 -13
- package/dist/boot/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/link.d.ts +4 -5
- package/dist/components/link.d.ts.map +1 -1
- package/dist/components/link.js +2 -1
- package/dist/components/link.js.map +1 -1
- package/dist/foundations/icon/icon.d.ts.map +1 -1
- package/dist/foundations/icon/icon.js.map +1 -1
- package/dist/foundations/icon/icon.types.d.ts +2 -1
- package/dist/foundations/icon/icon.types.d.ts.map +1 -1
- package/dist/foundations/icon/index.d.ts +3 -0
- package/dist/foundations/icon/index.js +2 -0
- package/dist/foundations/index.d.ts +1 -18
- package/dist/foundations/index.js +2 -18
- package/dist/foundations/interactions/index.d.ts +7 -0
- package/dist/foundations/interactions/index.js +7 -0
- package/dist/foundations/interactions/interaction-policy.js +2 -2
- package/dist/foundations/state/index.d.ts +2 -0
- package/dist/foundations/state/index.js +2 -0
- package/dist/foundations/structures/index.d.ts +8 -0
- package/dist/foundations/structures/index.js +7 -0
- package/dist/foundations/utilities/index.d.ts +7 -0
- package/dist/foundations/utilities/index.js +6 -0
- package/dist/index.d.ts +3 -14
- package/dist/index.js +2 -14
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/renderer/dom.js +26 -366
- package/dist/renderer/dom.js.map +1 -1
- package/dist/renderer/evaluate.js.map +1 -1
- package/dist/renderer/fastpath.js +20 -18
- package/dist/renderer/fastpath.js.map +1 -1
- package/dist/renderer/for-commit.js +486 -0
- package/dist/renderer/for-commit.js.map +1 -0
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/keyed.js +84 -23
- package/dist/renderer/keyed.js.map +1 -1
- package/dist/renderer/reconcile.js +11 -18
- package/dist/renderer/reconcile.js.map +1 -1
- package/dist/renderer/utils.js +5 -1
- package/dist/renderer/utils.js.map +1 -1
- package/dist/resources/index.d.ts +1 -2
- package/dist/resources/index.js +1 -2
- package/dist/router/route.js +1 -1
- package/dist/runtime/for.d.ts.map +1 -1
- package/dist/runtime/for.js +33 -21
- package/dist/runtime/for.js.map +1 -1
- package/dist/runtime/operations.js +1 -1
- package/dist/runtime/selector.d.ts.map +1 -1
- package/dist/runtime/selector.js +180 -103
- package/dist/runtime/selector.js.map +1 -1
- package/dist/runtime/state.d.ts +12 -4
- package/dist/runtime/state.d.ts.map +1 -1
- package/dist/runtime/state.js +1 -1
- package/dist/runtime/state.js.map +1 -1
- package/dist/ssg/index.d.ts +1 -6
- package/dist/ssg/index.js +1 -6
- package/dist/ssr/context.d.ts +2 -1
- package/dist/ssr/context.d.ts.map +1 -1
- package/dist/ssr/context.js +28 -11
- package/dist/ssr/context.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -31
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +4 -46
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/render-keys.js +1 -12
- package/dist/ssr/render-keys.js.map +1 -1
- package/dist/ssr/verify-hydration.js +25 -0
- package/dist/ssr/verify-hydration.js.map +1 -0
- package/package.json +39 -16
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/foundations/core.d.ts +0 -15
- package/dist/foundations/core.js +0 -13
- package/dist/foundations/structures.d.ts +0 -7
- package/dist/foundations/structures.js +0 -6
- package/dist/ssg/batch-render.d.ts +0 -16
- package/dist/ssg/batch-render.d.ts.map +0 -1
- package/dist/ssg/generate-metadata.d.ts +0 -24
- package/dist/ssg/generate-metadata.d.ts.map +0 -1
- package/dist/ssg/resolve-ssg-data.d.ts +0 -23
- package/dist/ssg/resolve-ssg-data.d.ts.map +0 -1
- package/dist/ssg/route-utils.d.ts +0 -16
- package/dist/ssg/route-utils.d.ts.map +0 -1
- package/dist/ssg/write-static-files.d.ts +0 -15
- package/dist/ssg/write-static-files.d.ts.map +0 -1
- package/dist/ssr/render-keys.d.ts +0 -37
- package/dist/ssr/render-keys.d.ts.map +0 -1
- package/dist/ssr/stream-render.js +0 -88
- package/dist/ssr/stream-render.js.map +0 -1
package/dist/renderer/keyed.js
CHANGED
|
@@ -65,9 +65,37 @@ function computeLISLength(positions) {
|
|
|
65
65
|
}
|
|
66
66
|
return tails.length;
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
function collectCurrentKeyOrder(parent, oldKeyMap) {
|
|
69
|
+
const currentKeys = [];
|
|
70
|
+
if (oldKeyMap && oldKeyMap.size > 0) {
|
|
71
|
+
let lastElement = null;
|
|
72
|
+
let keyCount = 0;
|
|
73
|
+
for (const [key, el] of oldKeyMap) {
|
|
74
|
+
if (el === lastElement) continue;
|
|
75
|
+
lastElement = el;
|
|
76
|
+
const normalizedKey = String(key);
|
|
77
|
+
currentKeys.push(normalizedKey);
|
|
78
|
+
keyCount++;
|
|
79
|
+
}
|
|
80
|
+
if (keyCount > 0) return {
|
|
81
|
+
keyCount,
|
|
82
|
+
currentKeys
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
let keyCount = 0;
|
|
86
|
+
try {
|
|
87
|
+
for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {
|
|
88
|
+
const keyAttr = el.getAttribute("data-key");
|
|
89
|
+
if (keyAttr === null) continue;
|
|
90
|
+
currentKeys.push(keyAttr);
|
|
91
|
+
keyCount++;
|
|
92
|
+
}
|
|
93
|
+
} catch {}
|
|
94
|
+
return {
|
|
95
|
+
keyCount,
|
|
96
|
+
currentKeys
|
|
97
|
+
};
|
|
98
|
+
}
|
|
71
99
|
function checkVnodePropChanges(keyedVnodes, oldKeyMap) {
|
|
72
100
|
for (const { key, vnode } of keyedVnodes) {
|
|
73
101
|
const el = oldKeyMap?.get(key);
|
|
@@ -81,39 +109,72 @@ function checkVnodePropChanges(keyedVnodes, oldKeyMap) {
|
|
|
81
109
|
return false;
|
|
82
110
|
}
|
|
83
111
|
/**
|
|
84
|
-
*
|
|
112
|
+
* Plan keyed reorder eligibility from one snapshot of keyed order and props.
|
|
85
113
|
*/
|
|
86
|
-
function
|
|
87
|
-
const keyedVnodes = extractKeyedVnodes(newChildren);
|
|
114
|
+
function planKeyedReorderFastPath(parent, keyedVnodes, totalChildren, oldKeyMap) {
|
|
88
115
|
const totalKeyed = keyedVnodes.length;
|
|
89
|
-
const
|
|
90
|
-
const
|
|
116
|
+
const isWholeKeyedList = totalKeyed === totalChildren;
|
|
117
|
+
const shouldEvaluateShape = isWholeKeyedList && totalKeyed >= LIS_THRESHOLD_MIN;
|
|
118
|
+
if (!shouldEvaluateShape) return {
|
|
119
|
+
useFastPath: false,
|
|
120
|
+
totalKeyed,
|
|
121
|
+
totalChildren,
|
|
122
|
+
currentKeyCount: 0,
|
|
123
|
+
moveCount: 0,
|
|
124
|
+
lisLen: 0,
|
|
125
|
+
hasPropChanges: false,
|
|
126
|
+
isWholeKeyedList
|
|
127
|
+
};
|
|
128
|
+
const hasPropChanges = checkVnodePropChanges(keyedVnodes, oldKeyMap);
|
|
129
|
+
if (hasPropChanges) return {
|
|
130
|
+
useFastPath: false,
|
|
131
|
+
totalKeyed,
|
|
132
|
+
totalChildren,
|
|
133
|
+
currentKeyCount: 0,
|
|
134
|
+
moveCount: 0,
|
|
135
|
+
lisLen: 0,
|
|
136
|
+
hasPropChanges,
|
|
137
|
+
isWholeKeyedList
|
|
138
|
+
};
|
|
139
|
+
const { keyCount: currentKeyCount, currentKeys } = collectCurrentKeyOrder(parent, oldKeyMap);
|
|
91
140
|
let moveCount = 0;
|
|
92
|
-
for (let i = 0; i <
|
|
93
|
-
|
|
94
|
-
if (i >= oldKeyOrder.length || oldKeyOrder[i] !== k || !oldKeyMap?.has(k)) moveCount++;
|
|
95
|
-
}
|
|
96
|
-
const cheapMoveTrigger = totalKeyed >= LIS_THRESHOLD_MIN && oldKeyOrder.length > 0 && moveCount > Math.max(64, Math.floor(totalKeyed * .1));
|
|
141
|
+
for (let i = 0; i < totalKeyed; i++) if (currentKeys[i] !== String(keyedVnodes[i].key)) moveCount++;
|
|
142
|
+
const cheapMoveTrigger = shouldEvaluateShape && currentKeyCount > 0 && moveCount > Math.max(64, Math.floor(totalKeyed * .1));
|
|
97
143
|
let lisTrigger = false;
|
|
98
144
|
let lisLen = 0;
|
|
99
|
-
if (
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
145
|
+
if (shouldEvaluateShape && !cheapMoveTrigger) {
|
|
146
|
+
const indexByKey = /* @__PURE__ */ new Map();
|
|
147
|
+
for (let i = 0; i < currentKeys.length; i++) indexByKey.set(currentKeys[i], i);
|
|
148
|
+
const positions = Array(totalKeyed).fill(-1);
|
|
149
|
+
for (let i = 0; i < totalKeyed; i++) positions[i] = indexByKey.get(String(keyedVnodes[i].key)) ?? -1;
|
|
150
|
+
lisLen = computeLISLength(positions);
|
|
105
151
|
lisTrigger = lisLen < Math.floor(totalKeyed * .5);
|
|
106
152
|
}
|
|
107
|
-
|
|
153
|
+
if (!shouldEvaluateShape || !(cheapMoveTrigger || lisTrigger)) return {
|
|
154
|
+
useFastPath: false,
|
|
155
|
+
totalKeyed,
|
|
156
|
+
totalChildren,
|
|
157
|
+
currentKeyCount,
|
|
158
|
+
moveCount,
|
|
159
|
+
lisLen,
|
|
160
|
+
hasPropChanges: false,
|
|
161
|
+
isWholeKeyedList
|
|
162
|
+
};
|
|
108
163
|
return {
|
|
109
|
-
useFastPath:
|
|
164
|
+
useFastPath: true,
|
|
110
165
|
totalKeyed,
|
|
166
|
+
totalChildren,
|
|
167
|
+
currentKeyCount,
|
|
111
168
|
moveCount,
|
|
112
169
|
lisLen,
|
|
113
|
-
hasPropChanges
|
|
170
|
+
hasPropChanges: false,
|
|
171
|
+
isWholeKeyedList
|
|
114
172
|
};
|
|
115
173
|
}
|
|
174
|
+
function isKeyedReorderFastPathEligible(parent, newChildren, oldKeyMap) {
|
|
175
|
+
return planKeyedReorderFastPath(parent, extractKeyedVnodes(newChildren), newChildren.length, oldKeyMap);
|
|
176
|
+
}
|
|
116
177
|
//#endregion
|
|
117
|
-
export { _reconcilerRecordedParents, getKeyMapForElement, isKeyedReorderFastPathEligible, keyedElements, populateKeyMapForElement };
|
|
178
|
+
export { _reconcilerRecordedParents, getKeyMapForElement, isKeyedReorderFastPathEligible, keyedElements, planKeyedReorderFastPath, populateKeyMapForElement };
|
|
118
179
|
|
|
119
180
|
//# sourceMappingURL=keyed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyed.js","names":[],"sources":["../../src/renderer/keyed.ts"],"sourcesContent":["import type { VNode } from './types';\nimport {\n extractKey,\n buildKeyMapFromChildren,\n isIgnoredForPropChanges,\n hasPropChanged,\n} from './utils';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Key Map Registry\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const keyedElements = new WeakMap<\n Element,\n Map<string | number, Element>\n>();\n\n/**\n * Retrieve existing keyed map for a parent element (runtime use)\n */\nexport function getKeyMapForElement(el: Element) {\n return keyedElements.get(el);\n}\n\n/**\n * Populate a keyed map for an element by scanning its immediate children\n * for `data-key` attributes. Proactive initialization for runtime layers.\n */\nexport function populateKeyMapForElement(parent: Element): void {\n try {\n if (keyedElements.has(parent)) return;\n\n let domMap = buildKeyMapFromChildren(parent);\n\n // Fallback: map by textContent when keys are not materialized as attrs\n if (domMap.size === 0) {\n domMap = new Map();\n const children = Array.from(parent.children);\n for (const ch of children) {\n const text = (ch.textContent || '').trim();\n if (text) {\n domMap.set(text, ch);\n const n = Number(text);\n if (!Number.isNaN(n)) domMap.set(n, ch);\n }\n }\n }\n\n if (domMap.size > 0) keyedElements.set(parent, domMap);\n } catch {\n // ignore\n }\n}\n\n// Track which parents had the reconciler record fast-path stats during the\n// current evaluation, so we can preserve diagnostics across additional\n// reconciliations within the same render pass without leaking between runs.\nexport const _reconcilerRecordedParents = new WeakSet<Element>();\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Fast-Path Eligibility\n// ─────────────────────────────────────────────────────────────────────────────\n\n// Configuration: LIS fast-path thresholds\nconst LIS_THRESHOLD_MIN = 64; // Minimum list size for LIS optimization\n\ninterface KeyedVnode {\n key: string | number;\n vnode: VNode;\n}\n\n/**\n * Extract keyed vnodes from children array\n */\nfunction extractKeyedVnodes(newChildren: VNode[]): KeyedVnode[] {\n const result: KeyedVnode[] = [];\n for (const child of newChildren) {\n const key = extractKey(child);\n if (key !== undefined) {\n result.push({ key, vnode: child });\n }\n }\n return result;\n}\n\n/**\n * Compute LIS (Longest Increasing Subsequence) length for positions\n */\nfunction computeLISLength(positions: number[]): number {\n const tails: number[] = [];\n for (const pos of positions) {\n if (pos === -1) continue;\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (tails[mid] < pos) lo = mid + 1;\n else hi = mid;\n }\n if (lo === tails.length) tails.push(pos);\n else tails[lo] = pos;\n }\n return tails.length;\n}\n\n/**\n * Check for prop changes between vnodes and existing elements\n */\nfunction checkVnodePropChanges(\n keyedVnodes: KeyedVnode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): boolean {\n for (const { key, vnode } of keyedVnodes) {\n const el = oldKeyMap?.get(key);\n if (!el || typeof vnode !== 'object' || vnode === null) continue;\n const vnodeObj = vnode as unknown as { props?: Record<string, unknown> };\n const props = vnodeObj.props || {};\n for (const k of Object.keys(props)) {\n if (isIgnoredForPropChanges(k)) continue;\n if (hasPropChanged(el, k, props[k])) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Determine if keyed reorder fast-path should be used\n */\nexport function isKeyedReorderFastPathEligible(\n parent: Element,\n newChildren: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n) {\n const keyedVnodes = extractKeyedVnodes(newChildren);\n const totalKeyed = keyedVnodes.length;\n const newKeyOrder = keyedVnodes.map((kv) => kv.key);\n const oldKeyOrder = oldKeyMap ? Array.from(oldKeyMap.keys()) : [];\n\n // Count moves needed\n let moveCount = 0;\n for (let i = 0; i < newKeyOrder.length; i++) {\n const k = newKeyOrder[i];\n if (i >= oldKeyOrder.length || oldKeyOrder[i] !== k || !oldKeyMap?.has(k)) {\n moveCount++;\n }\n }\n\n // Check move threshold triggers\n const FAST_MOVE_THRESHOLD_ABS = 64;\n const FAST_MOVE_THRESHOLD_REL = 0.1;\n const cheapMoveTrigger =\n totalKeyed >= LIS_THRESHOLD_MIN &&\n oldKeyOrder.length > 0 &&\n moveCount >\n Math.max(\n FAST_MOVE_THRESHOLD_ABS,\n Math.floor(totalKeyed * FAST_MOVE_THRESHOLD_REL)\n );\n\n // Compute LIS trigger for large lists\n let lisTrigger = false;\n let lisLen = 0;\n if (totalKeyed >= LIS_THRESHOLD_MIN && !cheapMoveTrigger) {\n const parentChildren = Array.from(parent.children);\n const positions = keyedVnodes.map(({ key }) => {\n const el = oldKeyMap?.get(key);\n return el?.parentElement === parent ? parentChildren.indexOf(el) : -1;\n });\n lisLen = computeLISLength(positions);\n lisTrigger = lisLen < Math.floor(totalKeyed * 0.5);\n }\n\n // Check for props that would prevent fast-path\n // Only block if props have CHANGED, not just if props exist\n const hasPropChanges = checkVnodePropChanges(keyedVnodes, oldKeyMap);\n\n // Allow fastpath even with props present, as long as props haven't changed\n // This enables fast-path for common patterns like <Row item={item} onClick={...} />\n const useFastPath = (cheapMoveTrigger || lisTrigger) && !hasPropChanges;\n\n return {\n useFastPath,\n totalKeyed,\n moveCount,\n lisLen,\n hasPropChanges,\n } as const;\n}\n"],"mappings":";;AAYA,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;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"keyed.js","names":[],"sources":["../../src/renderer/keyed.ts"],"sourcesContent":["import type { VNode } from './types';\nimport {\n extractKey,\n isIgnoredForPropChanges,\n hasPropChanged,\n buildKeyMapFromChildren,\n} from './utils';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Key Map Registry\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const keyedElements = new WeakMap<\n Element,\n Map<string | number, Element>\n>();\n\n/**\n * Retrieve existing keyed map for a parent element (runtime use)\n */\nexport function getKeyMapForElement(el: Element) {\n return keyedElements.get(el);\n}\n\n/**\n * Populate a keyed map for an element by scanning its immediate children\n * for `data-key` attributes. Proactive initialization for runtime layers.\n */\nexport function populateKeyMapForElement(parent: Element): void {\n try {\n if (keyedElements.has(parent)) return;\n\n let domMap = buildKeyMapFromChildren(parent);\n\n // Fallback: map by textContent when keys are not materialized as attrs\n if (domMap.size === 0) {\n domMap = new Map();\n const children = Array.from(parent.children);\n for (const ch of children) {\n const text = (ch.textContent || '').trim();\n if (text) {\n domMap.set(text, ch);\n const n = Number(text);\n if (!Number.isNaN(n)) domMap.set(n, ch);\n }\n }\n }\n\n if (domMap.size > 0) keyedElements.set(parent, domMap);\n } catch {\n // ignore\n }\n}\n\n// Track which parents had the reconciler record fast-path stats during the\n// current evaluation, so we can preserve diagnostics across additional\n// reconciliations within the same render pass without leaking between runs.\nexport const _reconcilerRecordedParents = new WeakSet<Element>();\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Fast-Path Eligibility\n// ─────────────────────────────────────────────────────────────────────────────\n\n// Configuration: LIS fast-path thresholds\nconst LIS_THRESHOLD_MIN = 64; // Minimum list size for LIS optimization\n\nexport interface KeyedVnode {\n key: string | number;\n vnode: VNode;\n}\n\n/**\n * Extract keyed vnodes from children array\n */\nfunction extractKeyedVnodes(newChildren: VNode[]): KeyedVnode[] {\n const result: KeyedVnode[] = [];\n for (const child of newChildren) {\n const key = extractKey(child);\n if (key !== undefined) {\n result.push({ key, vnode: child });\n }\n }\n return result;\n}\n\n/**\n * Compute LIS (Longest Increasing Subsequence) length for positions\n */\nfunction computeLISLength(positions: number[]): number {\n const tails: number[] = [];\n for (const pos of positions) {\n if (pos === -1) continue;\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (tails[mid] < pos) lo = mid + 1;\n else hi = mid;\n }\n if (lo === tails.length) tails.push(pos);\n else tails[lo] = pos;\n }\n return tails.length;\n}\n\ninterface CurrentKeyOrderSnapshot {\n keyCount: number;\n currentKeys: string[];\n}\n\nfunction collectCurrentKeyOrder(\n parent: Element,\n oldKeyMap: Map<string | number, Element> | undefined\n): CurrentKeyOrderSnapshot {\n const currentKeys: string[] = [];\n\n if (oldKeyMap && oldKeyMap.size > 0) {\n let lastElement: Element | null = null;\n let keyCount = 0;\n\n for (const [key, el] of oldKeyMap) {\n if (el === lastElement) {\n continue;\n }\n\n lastElement = el;\n const normalizedKey = String(key);\n currentKeys.push(normalizedKey);\n\n keyCount++;\n }\n\n if (keyCount > 0) {\n return { keyCount, currentKeys };\n }\n }\n\n let keyCount = 0;\n\n try {\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const keyAttr = el.getAttribute('data-key');\n if (keyAttr === null) {\n continue;\n }\n\n currentKeys.push(keyAttr);\n keyCount++;\n }\n } catch {\n // ignore\n }\n\n return { keyCount, currentKeys };\n}\n\n/**\n * Check for prop changes between vnodes and existing elements\n */\nexport interface KeyedReorderDecision {\n useFastPath: boolean;\n totalKeyed: number;\n totalChildren: number;\n currentKeyCount: number;\n moveCount: number;\n lisLen: number;\n hasPropChanges: boolean;\n isWholeKeyedList: boolean;\n}\n\nfunction checkVnodePropChanges(\n keyedVnodes: KeyedVnode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): boolean {\n for (const { key, vnode } of keyedVnodes) {\n const el = oldKeyMap?.get(key);\n if (!el || typeof vnode !== 'object' || vnode === null) continue;\n const vnodeObj = vnode as unknown as { props?: Record<string, unknown> };\n const props = vnodeObj.props || {};\n for (const k of Object.keys(props)) {\n if (isIgnoredForPropChanges(k)) continue;\n if (hasPropChanged(el, k, props[k])) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Plan keyed reorder eligibility from one snapshot of keyed order and props.\n */\nexport function planKeyedReorderFastPath(\n parent: Element,\n keyedVnodes: KeyedVnode[],\n totalChildren: number,\n oldKeyMap: Map<string | number, Element> | undefined\n): KeyedReorderDecision {\n const totalKeyed = keyedVnodes.length;\n const isWholeKeyedList = totalKeyed === totalChildren;\n const shouldEvaluateShape =\n isWholeKeyedList && totalKeyed >= LIS_THRESHOLD_MIN;\n\n if (!shouldEvaluateShape) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount: 0,\n moveCount: 0,\n lisLen: 0,\n hasPropChanges: false,\n isWholeKeyedList,\n };\n }\n\n const hasPropChanges = checkVnodePropChanges(keyedVnodes, oldKeyMap);\n if (hasPropChanges) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount: 0,\n moveCount: 0,\n lisLen: 0,\n hasPropChanges,\n isWholeKeyedList,\n };\n }\n\n const { keyCount: currentKeyCount, currentKeys } = collectCurrentKeyOrder(\n parent,\n oldKeyMap\n );\n\n let moveCount = 0;\n for (let i = 0; i < totalKeyed; i++) {\n if (currentKeys[i] !== String(keyedVnodes[i].key)) {\n moveCount++;\n }\n }\n\n const FAST_MOVE_THRESHOLD_ABS = 64;\n const FAST_MOVE_THRESHOLD_REL = 0.1;\n const cheapMoveTrigger =\n shouldEvaluateShape &&\n currentKeyCount > 0 &&\n moveCount >\n Math.max(\n FAST_MOVE_THRESHOLD_ABS,\n Math.floor(totalKeyed * FAST_MOVE_THRESHOLD_REL)\n );\n\n let lisTrigger = false;\n let lisLen = 0;\n if (shouldEvaluateShape && !cheapMoveTrigger) {\n const indexByKey = new Map<string, number>();\n for (let i = 0; i < currentKeys.length; i++) {\n indexByKey.set(currentKeys[i], i);\n }\n\n const positions: number[] = Array(totalKeyed).fill(-1);\n for (let i = 0; i < totalKeyed; i++) {\n positions[i] = indexByKey.get(String(keyedVnodes[i].key)) ?? -1;\n }\n lisLen = computeLISLength(positions);\n lisTrigger = lisLen < Math.floor(totalKeyed * 0.5);\n }\n\n if (!shouldEvaluateShape || !(cheapMoveTrigger || lisTrigger)) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount,\n moveCount,\n lisLen,\n hasPropChanges: false,\n isWholeKeyedList,\n };\n }\n\n return {\n useFastPath: true,\n totalKeyed,\n totalChildren,\n currentKeyCount,\n moveCount,\n lisLen,\n hasPropChanges: false,\n isWholeKeyedList,\n } as const;\n}\n\nexport function isKeyedReorderFastPathEligible(\n parent: Element,\n newChildren: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): KeyedReorderDecision {\n return planKeyedReorderFastPath(\n parent,\n extractKeyedVnodes(newChildren),\n newChildren.length,\n oldKeyMap\n );\n}\n"],"mappings":";;AAYA,MAAa,gCAAgB,IAAI,SAG9B;;;;AAKH,SAAgB,oBAAoB,IAAa;CAC/C,OAAO,cAAc,IAAI,GAAG;;;;;;AAO9B,SAAgB,yBAAyB,QAAuB;CAC9D,IAAI;EACF,IAAI,cAAc,IAAI,OAAO,EAAE;EAE/B,IAAI,SAAS,wBAAwB,OAAO;EAG5C,IAAI,OAAO,SAAS,GAAG;GACrB,yBAAS,IAAI,KAAK;GAClB,MAAM,WAAW,MAAM,KAAK,OAAO,SAAS;GAC5C,KAAK,MAAM,MAAM,UAAU;IACzB,MAAM,QAAQ,GAAG,eAAe,IAAI,MAAM;IAC1C,IAAI,MAAM;KACR,OAAO,IAAI,MAAM,GAAG;KACpB,MAAM,IAAI,OAAO,KAAK;KACtB,IAAI,CAAC,OAAO,MAAM,EAAE,EAAE,OAAO,IAAI,GAAG,GAAG;;;;EAK7C,IAAI,OAAO,OAAO,GAAG,cAAc,IAAI,QAAQ,OAAO;SAChD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AI,OAAO,YAAY,GAAG,IAAI,CAAC,IAAI;EAE/D,SAAS,iBAAiB,UAAU;EACpC,aAAa,SAAS,KAAK,MAAM,aAAa,GAAI;;CAGpD,IAAI,CAAC,uBAAuB,EAAE,oBAAoB,aAChD,OAAO;EACL,aAAa;EACb;EACA;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACD;CAGH,OAAO;EACL,aAAa;EACb;EACA;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACD;;AAGH,SAAgB,+BACd,QACA,aACA,WACsB;CACtB,OAAO,yBACL,QACA,mBAAmB,YAAY,EAC/B,YAAY,QACZ,UACD"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { getRuntimeEnv } from "../common/env.js";
|
|
2
2
|
import "./env.js";
|
|
3
3
|
import { checkPropChanges, extractKey, recordDOMReplace, recordFastPathStats, tagNamesEqualIgnoreCase } from "./utils.js";
|
|
4
|
-
import {
|
|
4
|
+
import { keyedElements, planKeyedReorderFastPath } from "./keyed.js";
|
|
5
5
|
import { teardownNodeSubtree } from "./cleanup.js";
|
|
6
6
|
import { applyRendererFastPath } from "./fastpath.js";
|
|
7
7
|
import { performBulkPositionalKeyedTextUpdate } from "./children.js";
|
|
8
8
|
import { createDOMNode, syncComponentElement, updateElementFromVnode } from "./dom.js";
|
|
9
9
|
function reconcileKeyedChildren(parent, newChildren, oldKeyMap) {
|
|
10
|
-
const
|
|
10
|
+
const keyedVnodes = extractKeyedChildren(newChildren);
|
|
11
11
|
const ensuredOldKeyMap = oldKeyMap || buildKeyMapFromDOM(parent);
|
|
12
|
-
const fastPathResult = tryFastPaths(parent, newChildren, keyedVnodes,
|
|
12
|
+
const fastPathResult = tryFastPaths(parent, newChildren, keyedVnodes, ensuredOldKeyMap);
|
|
13
13
|
if (fastPathResult) return fastPathResult;
|
|
14
14
|
return performFullReconciliation(parent, newChildren, keyedVnodes, ensuredOldKeyMap);
|
|
15
15
|
}
|
|
@@ -28,10 +28,9 @@ function buildKeyMapFromDOM(parent) {
|
|
|
28
28
|
} catch {}
|
|
29
29
|
return keyMap;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
function
|
|
31
|
+
/** Extract keyed children in a single pass. */
|
|
32
|
+
function extractKeyedChildren(newChildren) {
|
|
33
33
|
const keyedVnodes = [];
|
|
34
|
-
const unkeyedVnodes = [];
|
|
35
34
|
for (let i = 0; i < newChildren.length; i++) {
|
|
36
35
|
const child = newChildren[i];
|
|
37
36
|
const key = extractKey(child);
|
|
@@ -39,19 +38,15 @@ function partitionChildren(newChildren) {
|
|
|
39
38
|
key,
|
|
40
39
|
vnode: child
|
|
41
40
|
});
|
|
42
|
-
else unkeyedVnodes.push(child);
|
|
43
41
|
}
|
|
44
|
-
return
|
|
45
|
-
keyedVnodes,
|
|
46
|
-
unkeyedVnodes
|
|
47
|
-
};
|
|
42
|
+
return keyedVnodes;
|
|
48
43
|
}
|
|
49
44
|
/** Try fast paths before full reconciliation */
|
|
50
|
-
function tryFastPaths(parent, newChildren, keyedVnodes,
|
|
45
|
+
function tryFastPaths(parent, newChildren, keyedVnodes, oldKeyMap) {
|
|
51
46
|
try {
|
|
52
47
|
const forcedResult = tryForcedPositionalBulkUpdate(parent, newChildren, keyedVnodes);
|
|
53
48
|
if (forcedResult) return forcedResult;
|
|
54
|
-
const rendererResult = tryRendererFastPath(parent,
|
|
49
|
+
const rendererResult = tryRendererFastPath(parent, keyedVnodes, newChildren.length, oldKeyMap);
|
|
55
50
|
if (rendererResult) return rendererResult;
|
|
56
51
|
const positionalResult = tryPositionalBulkUpdate(parent, keyedVnodes);
|
|
57
52
|
if (positionalResult) return positionalResult;
|
|
@@ -59,11 +54,9 @@ function tryFastPaths(parent, newChildren, keyedVnodes, unkeyedVnodes, oldKeyMap
|
|
|
59
54
|
return null;
|
|
60
55
|
}
|
|
61
56
|
/** Try renderer fast-path */
|
|
62
|
-
function tryRendererFastPath(parent,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (decision.useFastPath && keyedVnodes.length >= 64 && isWholeKeyedList) try {
|
|
66
|
-
const map = applyRendererFastPath(parent, keyedVnodes, oldKeyMap, unkeyedVnodes);
|
|
57
|
+
function tryRendererFastPath(parent, keyedVnodes, totalChildren, oldKeyMap) {
|
|
58
|
+
if (planKeyedReorderFastPath(parent, keyedVnodes, totalChildren, oldKeyMap).useFastPath) try {
|
|
59
|
+
const map = applyRendererFastPath(parent, keyedVnodes, oldKeyMap);
|
|
67
60
|
if (map) {
|
|
68
61
|
keyedElements.set(parent, map);
|
|
69
62
|
return map;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile.js","names":[],"sources":["../../src/renderer/reconcile.ts"],"sourcesContent":["/**\n * ─────────────────────────────────────────────────────────────────────────────\n * RENDERER & RECONCILIATION INVARIANTS (LOCKED)\n * ─────────────────────────────────────────────────────────────────────────────\n *\n * These invariants are NON-NEGOTIABLE. Any optimization or fast-path MUST\n * preserve them. Violations WILL produce incorrect DOM.\n *\n * 1. DOM ORDER DERIVES ONLY FROM CURRENT VNODE ORDER\n * --------------------------------------------------\n * - Final DOM child order MUST be reconstructed from the current vnode list.\n * - Reusing an existing DOM node does NOT imply it stays in the same position.\n * - Appending an existing Node to a DocumentFragment is the ONLY valid way\n * to express reordering (it moves the node).\n *\n * ❌ NEVER skip fragment insertion because a node already has a parent.\n * ✅ ALWAYS append reused nodes into the fragment to establish order.\n *\n *\n * 2. VNODE IDENTITY ≠ VNODE STABILITY\n * ----------------------------------\n * - VNodes are mutable.\n * - `vnodeA === vnodeB` does NOT imply semantic equality.\n * - DOM reuse MUST NOT be gated on vnode identity alone.\n *\n * DOM reuse is allowed ONLY when:\n * - element type is unchanged\n * - structural shape is compatible\n * - updates are applied explicitly via updateElementFromVnode\n *\n * ❌ NEVER assume \"same object\" means \"no changes\".\n *\n *\n * 3. KEYED RECONCILIATION IS ELEMENT-ONLY\n * --------------------------------------\n * - Keyed reconciliation assumes ELEMENT nodes, not Text or Comment nodes.\n * - Any fast-path using `parent.children[i]` MUST prove:\n * - all children are elements\n * - no text nodes are present\n *\n * ❌ NEVER index `parent.children` when text nodes may exist.\n * ✅ Use `parent.childNodes` or bail out to full reconciliation.\n *\n *\n * 4. PRIMITIVES MAP TO TEXT NODES\n * -------------------------------\n * - string/number children represent Text nodes, not Elements.\n * - Reconciliation MUST attempt Text-to-Text reuse before replacement.\n *\n * ❌ NEVER update element.textContent as a substitute for text reconciliation\n * unless the shape is explicitly guaranteed.\n *\n *\n * 5. FAST-PATHS MUST BE STRICTLY SAFE\n * ----------------------------------\n * - Fast-paths are OPTIONAL.\n * - Correctness always beats performance.\n *\n * A fast-path MUST:\n * - prove its eligibility\n * - fall back cleanly on ANY ambiguity\n * - never partially apply\n *\n *\n * 6. CLEANUP IS POSITION-INDEPENDENT\n * ---------------------------------\n * - Cleanup is based on removal from the DOM, not vnode position.\n * - Any node removed or replaced MUST:\n * - remove listeners\n * - cleanup component instances\n *\n *\n * 7. FOR-BOUNDARY & KEYED LISTS OBEY THE SAME RULES\n * ------------------------------------------------\n * - For-boundaries are NOT special in ordering semantics.\n * - Cached DOM nodes MUST still be reordered via fragment insertion.\n * - Cache is an optimization, not an ownership claim.\n *\n *\n * If you are unsure whether an optimization preserves these invariants:\n * DO NOT APPLY IT.\n *\n * ─────────────────────────────────────────────────────────────────────────────\n */\n\nimport type { DOMElement, VNode } from './types';\nimport {\n createDOMNode,\n syncComponentElement,\n updateElementFromVnode,\n performBulkPositionalKeyedTextUpdate,\n} from './dom';\nimport type { Props } from '../common/props';\nimport {\n keyedElements,\n _reconcilerRecordedParents,\n isKeyedReorderFastPathEligible,\n} from './keyed';\nimport { teardownNodeSubtree } from './cleanup';\nimport { applyRendererFastPath } from './fastpath';\nimport { getRuntimeEnv } from './env';\nimport {\n extractKey,\n checkPropChanges,\n recordFastPathStats,\n recordDOMReplace,\n tagNamesEqualIgnoreCase,\n} from './utils';\n\nexport const IS_DOM_AVAILABLE = typeof document !== 'undefined';\n\n// Helper type for narrowings\ntype VnodeObj = VNode & { type?: unknown; props?: Record<string, unknown> };\ntype ComponentVNode = DOMElement & { type: (props: Props) => unknown };\n\nexport function reconcileKeyedChildren(\n parent: Element,\n newChildren: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> {\n const { keyedVnodes, unkeyedVnodes } = partitionChildren(newChildren);\n\n // Ensure we have a key map before reconciliation to avoid O(n) DOM scans\n // during O(n) reconciliation loop (which would be O(n²))\n const ensuredOldKeyMap = oldKeyMap || buildKeyMapFromDOM(parent);\n\n // Try fast paths first\n const fastPathResult = tryFastPaths(\n parent,\n newChildren,\n keyedVnodes,\n unkeyedVnodes,\n ensuredOldKeyMap\n );\n if (fastPathResult) {\n return fastPathResult;\n }\n\n // Full reconciliation\n return performFullReconciliation(\n parent,\n newChildren,\n keyedVnodes,\n ensuredOldKeyMap\n );\n}\n\n/** Build key map from DOM children */\nfunction buildKeyMapFromDOM(parent: Element): Map<string | number, Element> {\n const keyMap = new Map<string | number, Element>();\n try {\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const k = el.getAttribute('data-key');\n if (k !== null) {\n keyMap.set(k, el);\n const n = Number(k);\n if (!Number.isNaN(n)) keyMap.set(n, el);\n }\n }\n } catch {\n // Ignore\n }\n return keyMap;\n}\n\n/** Partition children into keyed and unkeyed */\nfunction partitionChildren(newChildren: VNode[]): {\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>;\n unkeyedVnodes: VNode[];\n} {\n const keyedVnodes: Array<{ key: string | number; vnode: VNode }> = [];\n const unkeyedVnodes: VNode[] = [];\n\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i];\n const key = extractKey(child);\n if (key !== undefined) {\n keyedVnodes.push({ key, vnode: child });\n } else {\n unkeyedVnodes.push(child);\n }\n }\n\n return { keyedVnodes, unkeyedVnodes };\n}\n\n/** Try fast paths before full reconciliation */\nfunction tryFastPaths(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n unkeyedVnodes: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> | null {\n try {\n const forcedResult = tryForcedPositionalBulkUpdate(\n parent,\n newChildren,\n keyedVnodes\n );\n if (forcedResult) {\n return forcedResult;\n }\n\n // Try renderer fast-path for large keyed reorder-only updates\n const rendererResult = tryRendererFastPath(\n parent,\n newChildren,\n keyedVnodes,\n unkeyedVnodes,\n oldKeyMap\n );\n if (rendererResult) {\n return rendererResult;\n }\n\n // Try positional bulk update for medium-sized lists\n const positionalResult = tryPositionalBulkUpdate(parent, keyedVnodes);\n if (positionalResult) {\n return positionalResult;\n }\n } catch {\n // Fall through to full reconciliation\n }\n\n return null;\n}\n\n/** Try renderer fast-path */\nfunction tryRendererFastPath(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n unkeyedVnodes: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> | null {\n const decision = isKeyedReorderFastPathEligible(\n parent,\n newChildren,\n oldKeyMap\n );\n const isWholeKeyedList =\n keyedVnodes.length === newChildren.length && unkeyedVnodes.length === 0;\n const canUseFastPath =\n decision.useFastPath && keyedVnodes.length >= 64 && isWholeKeyedList;\n\n // Apply fast-path only for a whole keyed list. Mixed root fragments may\n // contain a keyed portal sibling, but they are not reorder-only lists.\n if (canUseFastPath) {\n try {\n const map = applyRendererFastPath(\n parent,\n keyedVnodes,\n oldKeyMap,\n unkeyedVnodes\n );\n if (map) {\n keyedElements.set(parent, map);\n return map;\n }\n } catch {\n // Fall through\n }\n }\n\n return null;\n}\n\n/** Try the explicit test/bench forced positional keyed path. */\nfunction tryForcedPositionalBulkUpdate(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): Map<string | number, Element> | null {\n if (getRuntimeEnv().ASKR_FORCE_BULK_POSREUSE !== '1') return null;\n if (keyedVnodes.length === 0 || keyedVnodes.length !== newChildren.length) {\n return null;\n }\n\n try {\n const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);\n recordFastPathStats(stats, 'bulkKeyedPositionalForced');\n\n rebuildKeyedMap(parent);\n return keyedElements.get(parent) as Map<string | number, Element>;\n } catch {\n return null;\n }\n}\n\n/** Try positional bulk update for medium-sized lists */\nfunction tryPositionalBulkUpdate(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): Map<string | number, Element> | null {\n const total = keyedVnodes.length;\n if (total < 10) return null;\n\n // CRITICAL INVARIANT: Only use children[] indexing if element-only is guaranteed\n // If parent has text nodes or comment nodes, bail to full reconciliation\n if (parent.children.length !== total) {\n return null;\n }\n\n const matchCount = countPositionalMatches(parent, keyedVnodes);\n\n // For keyed lists, the positional bulk update path makes sense in two cases:\n // 1. Perfect match (100%): All keys are in the right positions, just update text\n // 2. Very low match (<10%): Keys changed en-masse, treat as bulk re-key, reuse nodes by position\n // ANY mismatch at all means we have a reorder and need full reconciliation\n // to preserve DOM node identity correctly.\n const matchFraction = matchCount / total;\n\n if (keyedVnodes.length > 0) {\n // For keyed lists: require perfect match or very low match\n // matchCount !== total catches ANY reordering, even just 2 swapped elements\n if (matchCount !== total && matchFraction >= 0.1) {\n return null;\n }\n } else {\n // For unkeyed lists: use original threshold\n if (matchFraction < 0.9) {\n return null;\n }\n }\n\n // Check for prop changes that would prevent positional update\n if (hasPositionalPropChanges(parent, keyedVnodes)) {\n return null;\n }\n\n // Perform positional update\n try {\n const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);\n recordFastPathStats(stats, 'bulkKeyedPositionalHits');\n\n rebuildKeyedMap(parent);\n return keyedElements.get(parent) as Map<string | number, Element>;\n } catch {\n return null;\n }\n}\n\n/** Count how many vnodes match parent children by position and tag */\nfunction countPositionalMatches(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): number {\n let matchCount = 0;\n\n try {\n // For keyed children, use children (elements only) since keyed nodes are elements\n for (let i = 0; i < keyedVnodes.length; i++) {\n const vnode = keyedVnodes[i].vnode as VnodeObj;\n const expectedKey = keyedVnodes[i].key;\n\n if (!vnode || typeof vnode !== 'object' || typeof vnode.type !== 'string')\n continue;\n\n const el = parent.children[i] as Element | undefined;\n if (!el) continue;\n\n // For keyed lists, check BOTH tag name AND key match\n if (tagNamesEqualIgnoreCase(el.tagName, vnode.type)) {\n // Check if the element at this position has the expected key\n const actualKey = el.getAttribute('data-key');\n const keyMatches =\n actualKey === String(expectedKey) ||\n (actualKey !== null &&\n !Number.isNaN(Number(actualKey)) &&\n Number(actualKey) === expectedKey);\n\n if (keyMatches) {\n matchCount++;\n }\n }\n }\n } catch {\n // Ignore\n }\n\n return matchCount;\n}\n\n/** Check if positional prop changes would prevent bulk update */\nfunction hasPositionalPropChanges(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): boolean {\n try {\n // For keyed children, use children (elements only) since keyed nodes are elements\n for (let i = 0; i < keyedVnodes.length; i++) {\n const vnode = keyedVnodes[i].vnode as VnodeObj;\n const el = parent.children[i] as Element | undefined;\n if (!el || !vnode || typeof vnode !== 'object') continue;\n\n if (checkPropChanges(el, vnode.props || {})) {\n return true;\n }\n }\n } catch {\n return true;\n }\n\n return false;\n}\n\n/** Rebuild keyed map from parent children */\nfunction rebuildKeyedMap(parent: Element): void {\n try {\n const map = new Map<string | number, Element>();\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const k = el.getAttribute('data-key');\n if (k !== null) {\n map.set(k, el);\n const n = Number(k);\n if (!Number.isNaN(n)) map.set(n, el);\n }\n }\n keyedElements.set(parent, map);\n } catch {\n // Ignore\n }\n}\n\n/** Perform full reconciliation when fast paths don't apply */\nfunction performFullReconciliation(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> {\n const newKeyMap = new Map<string | number, Element>();\n const finalNodes: Node[] = [];\n const usedOldEls = new WeakSet<Node>();\n\n const resolveOldElOnce = createOldElResolver(parent, oldKeyMap, usedOldEls);\n const unkeyedEls = collectUnkeyedElements(parent);\n let unkeyedIndex = 0;\n const resolveUnkeyedOnce = (): Element | undefined => {\n while (unkeyedIndex < unkeyedEls.length) {\n const candidate = unkeyedEls[unkeyedIndex++];\n if (!usedOldEls.has(candidate)) return candidate;\n }\n return undefined;\n };\n\n // Positional reconciliation\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i];\n const node = reconcileSingleChild(\n child,\n i,\n parent,\n resolveOldElOnce,\n resolveUnkeyedOnce,\n usedOldEls,\n newKeyMap\n );\n if (node) finalNodes.push(node);\n }\n\n // SSR guard\n if (typeof document === 'undefined') return newKeyMap;\n\n commitReconciliation(parent, finalNodes);\n keyedElements.delete(parent);\n\n return newKeyMap;\n}\n\n/** Create resolver for finding old elements by key */\nfunction createOldElResolver(\n parent: Element,\n oldKeyMap: Map<string | number, Element> | undefined,\n usedOldEls: WeakSet<Node>\n): (k: string | number) => Element | undefined {\n return (k: string | number) => {\n if (!oldKeyMap) return undefined;\n\n // Fast-path: directly from oldKeyMap\n const direct = oldKeyMap.get(k);\n if (direct && !usedOldEls.has(direct)) {\n usedOldEls.add(direct);\n return direct;\n }\n\n // Try string form\n const s = String(k);\n const byString = oldKeyMap.get(s);\n if (byString && !usedOldEls.has(byString)) {\n usedOldEls.add(byString);\n return byString;\n }\n\n // Try numeric form\n const n = Number(s);\n if (!Number.isNaN(n)) {\n const byNum = oldKeyMap.get(n);\n if (byNum && !usedOldEls.has(byNum)) {\n usedOldEls.add(byNum);\n return byNum;\n }\n }\n\n // Fallback: scan parent children\n return scanForElementByKey(parent, k, s, usedOldEls);\n };\n}\n\n/** Scan parent children for element with matching key */\nfunction scanForElementByKey(\n parent: Element,\n k: string | number,\n keyStr: string,\n usedOldEls: WeakSet<Node>\n): Element | undefined {\n try {\n for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {\n if (usedOldEls.has(ch)) continue;\n const attr = ch.getAttribute('data-key');\n if (attr === keyStr) {\n usedOldEls.add(ch);\n return ch;\n }\n if (attr !== null) {\n const numAttr = Number(attr);\n if (!Number.isNaN(numAttr) && numAttr === (k as number)) {\n usedOldEls.add(ch);\n return ch;\n }\n }\n }\n } catch {\n // Ignore\n }\n return undefined;\n}\n\n/** Reconcile a single child */\nfunction reconcileSingleChild(\n child: VNode,\n index: number,\n parent: Element,\n resolveOldElOnce: (k: string | number) => Element | undefined,\n resolveUnkeyedOnce: () => Element | undefined,\n usedOldEls: WeakSet<Node>,\n newKeyMap: Map<string | number, Element>\n): Node | null {\n // Keyed child\n const key = extractKey(child);\n\n if (key !== undefined) {\n return reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap);\n }\n\n // Unkeyed or primitive child\n return reconcileUnkeyedChild(\n child,\n index,\n parent,\n resolveUnkeyedOnce,\n usedOldEls\n );\n}\n\n/** Reconcile a keyed child */\nfunction reconcileKeyedChild(\n child: VNode,\n key: string | number,\n parent: Element,\n resolveOldElOnce: (k: string | number) => Element | undefined,\n newKeyMap: Map<string | number, Element>\n): Node | null {\n const el = resolveOldElOnce(key);\n\n if (el && el.parentElement === parent) {\n // Strict keyed guarantee: if the element tag changes for an existing key,\n // replace the DOM node rather than mutating in place.\n try {\n const childObj = child as VnodeObj;\n if (\n childObj &&\n typeof childObj === 'object' &&\n typeof childObj.type === 'string'\n ) {\n if (tagNamesEqualIgnoreCase(el.tagName, childObj.type)) {\n updateElementFromVnode(el, child);\n newKeyMap.set(key, el);\n return el;\n }\n }\n if (isComponentVNode(child)) {\n const synced = syncComponentElement(\n el,\n child,\n child.type,\n ((child.props ?? {}) as Props) || {}\n );\n if (synced) {\n if (synced instanceof Element) newKeyMap.set(key, synced);\n return synced;\n }\n }\n } catch {\n // Fall through to replacement\n }\n }\n\n const dom = createDOMNode(child);\n if (dom) {\n if (dom instanceof Element) newKeyMap.set(key, dom);\n return dom;\n }\n\n return null;\n}\n\n/** Reconcile an unkeyed or primitive child */\nfunction reconcileUnkeyedChild(\n child: VNode,\n index: number,\n parent: Element,\n resolveUnkeyedOnce: () => Element | undefined,\n usedOldEls: WeakSet<Node>\n): Node | null {\n try {\n // Use childNodes (includes Text nodes) instead of children (elements only)\n const existing = parent.childNodes[index] as Node | undefined;\n\n // Primitive child: try to reuse Text node if available\n if (typeof child === 'string' || typeof child === 'number') {\n if (existing && existing.nodeType === 3) {\n // Text node: reuse in-place\n (existing as Text).data = String(child);\n usedOldEls.add(existing);\n return existing;\n }\n return createDOMNode(child);\n }\n\n if (existing instanceof Element) {\n const synced = trySyncComponentChild(existing, child, usedOldEls);\n if (synced) return synced;\n }\n\n // Element child matching existing unkeyed element\n if (existing instanceof Element && canReuseElement(existing, child)) {\n updateElementFromVnode(existing, child);\n usedOldEls.add(existing);\n return existing;\n }\n\n // Try to find available unkeyed element elsewhere\n const avail = resolveUnkeyedOnce();\n if (avail) {\n const reuseResult = tryReuseElement(avail, child, usedOldEls);\n if (reuseResult) return reuseResult;\n }\n } catch {\n // Fall through to create new\n }\n\n const dom = createDOMNode(child);\n return dom;\n}\n\nfunction isComponentVNode(child: VNode): child is ComponentVNode {\n return (\n typeof child === 'object' &&\n child !== null &&\n 'type' in child &&\n typeof (child as VnodeObj).type === 'function'\n );\n}\n\nfunction trySyncComponentChild(\n existing: Element,\n child: VNode,\n usedOldEls: WeakSet<Node>\n): Node | null {\n if (!isComponentVNode(child)) return null;\n\n const synced = syncComponentElement(\n existing,\n child,\n child.type,\n ((child.props ?? {}) as Props) || {}\n );\n if (!synced) return null;\n\n usedOldEls.add(existing);\n usedOldEls.add(synced);\n return synced;\n}\n\n/** Check if existing element can be reused for child */\nfunction canReuseElement(existing: Element | undefined, child: VNode): boolean {\n if (!existing) return false;\n if (typeof child !== 'object' || child === null || !('type' in child))\n return false;\n\n const childObj = child as VnodeObj;\n const existingKey = existing.getAttribute('data-key');\n const hasNoKey = existingKey === null || existingKey === undefined;\n\n return (\n hasNoKey &&\n typeof childObj.type === 'string' &&\n tagNamesEqualIgnoreCase(existing.tagName, childObj.type)\n );\n}\n\n/** Collect unkeyed element children in DOM order. */\nfunction collectUnkeyedElements(parent: Element): Element[] {\n const elements: Element[] = [];\n for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {\n if (ch.getAttribute('data-key') === null) elements.push(ch);\n }\n return elements;\n}\n\n/** Try to reuse available element for child */\nfunction tryReuseElement(\n avail: Element,\n child: VNode,\n usedOldEls: WeakSet<Node>\n): Node | null {\n if (typeof child === 'string' || typeof child === 'number') {\n return null;\n }\n\n const synced = trySyncComponentChild(avail, child, usedOldEls);\n if (synced) {\n return synced;\n }\n\n if (typeof child === 'object' && child !== null && 'type' in child) {\n const childObj = child as VnodeObj;\n if (\n typeof childObj.type === 'string' &&\n tagNamesEqualIgnoreCase(avail.tagName, childObj.type)\n ) {\n updateElementFromVnode(avail, child);\n usedOldEls.add(avail);\n return avail;\n }\n }\n\n return null;\n}\n\n/** Commit reconciliation by replacing parent children */\nfunction commitReconciliation(parent: Element, finalNodes: Node[]): void {\n try {\n const finalSet = new Set<Node>(finalNodes);\n\n for (let n = parent.firstChild; n; ) {\n const next = n.nextSibling;\n if (!finalSet.has(n)) {\n teardownNodeSubtree(n);\n parent.removeChild(n);\n }\n n = next;\n }\n\n for (let i = 0; i < finalNodes.length; i++) {\n const desiredNode = finalNodes[i];\n const anchor = parent.childNodes[i] ?? null;\n if (desiredNode !== anchor) {\n parent.insertBefore(desiredNode, anchor);\n }\n }\n } catch {\n const fragment = document.createDocumentFragment();\n for (let i = 0; i < finalNodes.length; i++) {\n fragment.appendChild(finalNodes[i]);\n }\n\n try {\n for (let n = parent.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n } catch {\n // Ignore fallback cleanup failures.\n }\n\n recordDOMReplace('reconcile');\n parent.replaceChildren(fragment);\n return;\n }\n}\n"],"mappings":";;;;;;;;AAmHA,SAAg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AAS,KAAK,GAAG;CAE7D,OAAO;;;AAIT,SAAS,gBACP,OACA,OACA,YACa;CACb,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAChD,OAAO;CAGT,MAAM,SAAS,sBAAsB,OAAO,OAAO,WAAW;CAC9D,IAAI,QACF,OAAO;CAGT,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,OAAO;EAClE,MAAM,WAAW;EACjB,IACE,OAAO,SAAS,SAAS,YACzB,wBAAwB,MAAM,SAAS,SAAS,KAAK,EACrD;GACA,uBAAuB,OAAO,MAAM;GACpC,WAAW,IAAI,MAAM;GACrB,OAAO;;;CAIX,OAAO;;;AAIT,SAAS,qBAAqB,QAAiB,YAA0B;CACvE,IAAI;EACF,MAAM,WAAW,IAAI,IAAU,WAAW;EAE1C,KAAK,IAAI,IAAI,OAAO,YAAY,IAAK;GACnC,MAAM,OAAO,EAAE;GACf,IAAI,CAAC,SAAS,IAAI,EAAE,EAAE;IACpB,oBAAoB,EAAE;IACtB,OAAO,YAAY,EAAE;;GAEvB,IAAI;;EAGN,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;GAC1C,MAAM,cAAc,WAAW;GAC/B,MAAM,SAAS,OAAO,WAAW,MAAM;GACvC,IAAI,gBAAgB,QAClB,OAAO,aAAa,aAAa,OAAO;;SAGtC;EACN,MAAM,WAAW,SAAS,wBAAwB;EAClD,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KACrC,SAAS,YAAY,WAAW,GAAG;EAGrC,IAAI;GACF,KAAK,IAAI,IAAI,OAAO,YAAY,IAAK;IACnC,MAAM,OAAO,EAAE;IACf,oBAAoB,EAAE;IACtB,IAAI;;UAEA;EAIR,iBAAiB,YAAY;EAC7B,OAAO,gBAAgB,SAAS;EAChC"}
|
|
1
|
+
{"version":3,"file":"reconcile.js","names":[],"sources":["../../src/renderer/reconcile.ts"],"sourcesContent":["/**\n * ─────────────────────────────────────────────────────────────────────────────\n * RENDERER & RECONCILIATION INVARIANTS (LOCKED)\n * ─────────────────────────────────────────────────────────────────────────────\n *\n * These invariants are NON-NEGOTIABLE. Any optimization or fast-path MUST\n * preserve them. Violations WILL produce incorrect DOM.\n *\n * 1. DOM ORDER DERIVES ONLY FROM CURRENT VNODE ORDER\n * --------------------------------------------------\n * - Final DOM child order MUST be reconstructed from the current vnode list.\n * - Reusing an existing DOM node does NOT imply it stays in the same position.\n * - Appending an existing Node to a DocumentFragment is the ONLY valid way\n * to express reordering (it moves the node).\n *\n * ❌ NEVER skip fragment insertion because a node already has a parent.\n * ✅ ALWAYS append reused nodes into the fragment to establish order.\n *\n *\n * 2. VNODE IDENTITY ≠ VNODE STABILITY\n * ----------------------------------\n * - VNodes are mutable.\n * - `vnodeA === vnodeB` does NOT imply semantic equality.\n * - DOM reuse MUST NOT be gated on vnode identity alone.\n *\n * DOM reuse is allowed ONLY when:\n * - element type is unchanged\n * - structural shape is compatible\n * - updates are applied explicitly via updateElementFromVnode\n *\n * ❌ NEVER assume \"same object\" means \"no changes\".\n *\n *\n * 3. KEYED RECONCILIATION IS ELEMENT-ONLY\n * --------------------------------------\n * - Keyed reconciliation assumes ELEMENT nodes, not Text or Comment nodes.\n * - Any fast-path using `parent.children[i]` MUST prove:\n * - all children are elements\n * - no text nodes are present\n *\n * ❌ NEVER index `parent.children` when text nodes may exist.\n * ✅ Use `parent.childNodes` or bail out to full reconciliation.\n *\n *\n * 4. PRIMITIVES MAP TO TEXT NODES\n * -------------------------------\n * - string/number children represent Text nodes, not Elements.\n * - Reconciliation MUST attempt Text-to-Text reuse before replacement.\n *\n * ❌ NEVER update element.textContent as a substitute for text reconciliation\n * unless the shape is explicitly guaranteed.\n *\n *\n * 5. FAST-PATHS MUST BE STRICTLY SAFE\n * ----------------------------------\n * - Fast-paths are OPTIONAL.\n * - Correctness always beats performance.\n *\n * A fast-path MUST:\n * - prove its eligibility\n * - fall back cleanly on ANY ambiguity\n * - never partially apply\n *\n *\n * 6. CLEANUP IS POSITION-INDEPENDENT\n * ---------------------------------\n * - Cleanup is based on removal from the DOM, not vnode position.\n * - Any node removed or replaced MUST:\n * - remove listeners\n * - cleanup component instances\n *\n *\n * 7. FOR-BOUNDARY & KEYED LISTS OBEY THE SAME RULES\n * ------------------------------------------------\n * - For-boundaries are NOT special in ordering semantics.\n * - Cached DOM nodes MUST still be reordered via fragment insertion.\n * - Cache is an optimization, not an ownership claim.\n *\n *\n * If you are unsure whether an optimization preserves these invariants:\n * DO NOT APPLY IT.\n *\n * ─────────────────────────────────────────────────────────────────────────────\n */\n\nimport type { DOMElement, VNode } from './types';\nimport {\n createDOMNode,\n syncComponentElement,\n updateElementFromVnode,\n performBulkPositionalKeyedTextUpdate,\n} from './dom';\nimport type { Props } from '../common/props';\nimport {\n keyedElements,\n _reconcilerRecordedParents,\n planKeyedReorderFastPath,\n} from './keyed';\nimport { teardownNodeSubtree } from './cleanup';\nimport { applyRendererFastPath } from './fastpath';\nimport { getRuntimeEnv } from './env';\nimport type { ComponentFunction } from '../runtime/component';\nimport {\n extractKey,\n checkPropChanges,\n recordFastPathStats,\n recordDOMReplace,\n tagNamesEqualIgnoreCase,\n} from './utils';\n\nexport const IS_DOM_AVAILABLE = typeof document !== 'undefined';\n\n// Helper type for narrowings\ntype VnodeObj = VNode & { type?: unknown; props?: Record<string, unknown> };\ntype ComponentVNode = DOMElement & { type: ComponentFunction };\n\nexport function reconcileKeyedChildren(\n parent: Element,\n newChildren: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> {\n const keyedVnodes = extractKeyedChildren(newChildren);\n\n // Ensure we have a key map before reconciliation to avoid O(n) DOM scans\n // during O(n) reconciliation loop (which would be O(n²))\n const ensuredOldKeyMap = oldKeyMap || buildKeyMapFromDOM(parent);\n\n // Try fast paths first\n const fastPathResult = tryFastPaths(\n parent,\n newChildren,\n keyedVnodes,\n ensuredOldKeyMap\n );\n if (fastPathResult) {\n return fastPathResult;\n }\n\n // Full reconciliation\n return performFullReconciliation(\n parent,\n newChildren,\n keyedVnodes,\n ensuredOldKeyMap\n );\n}\n\n/** Build key map from DOM children */\nfunction buildKeyMapFromDOM(parent: Element): Map<string | number, Element> {\n const keyMap = new Map<string | number, Element>();\n try {\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const k = el.getAttribute('data-key');\n if (k !== null) {\n keyMap.set(k, el);\n const n = Number(k);\n if (!Number.isNaN(n)) keyMap.set(n, el);\n }\n }\n } catch {\n // Ignore\n }\n return keyMap;\n}\n\n/** Extract keyed children in a single pass. */\nfunction extractKeyedChildren(\n newChildren: VNode[]\n): Array<{ key: string | number; vnode: VNode }> {\n const keyedVnodes: Array<{ key: string | number; vnode: VNode }> = [];\n\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i];\n const key = extractKey(child);\n if (key !== undefined) {\n keyedVnodes.push({ key, vnode: child });\n }\n }\n\n return keyedVnodes;\n}\n\n/** Try fast paths before full reconciliation */\nfunction tryFastPaths(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> | null {\n try {\n const forcedResult = tryForcedPositionalBulkUpdate(\n parent,\n newChildren,\n keyedVnodes\n );\n if (forcedResult) {\n return forcedResult;\n }\n\n // Try renderer fast-path for large keyed reorder-only updates\n const rendererResult = tryRendererFastPath(\n parent,\n keyedVnodes,\n newChildren.length,\n oldKeyMap\n );\n if (rendererResult) {\n return rendererResult;\n }\n\n // Try positional bulk update for medium-sized lists\n const positionalResult = tryPositionalBulkUpdate(parent, keyedVnodes);\n if (positionalResult) {\n return positionalResult;\n }\n } catch {\n // Fall through to full reconciliation\n }\n\n return null;\n}\n\n/** Try renderer fast-path */\nfunction tryRendererFastPath(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n totalChildren: number,\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> | null {\n const decision = planKeyedReorderFastPath(\n parent,\n keyedVnodes,\n totalChildren,\n oldKeyMap\n );\n\n if (decision.useFastPath) {\n try {\n const map = applyRendererFastPath(parent, keyedVnodes, oldKeyMap);\n if (map) {\n keyedElements.set(parent, map);\n return map;\n }\n } catch {\n // Fall through\n }\n }\n\n return null;\n}\n\n/** Try the explicit test/bench forced positional keyed path. */\nfunction tryForcedPositionalBulkUpdate(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): Map<string | number, Element> | null {\n if (getRuntimeEnv().ASKR_FORCE_BULK_POSREUSE !== '1') return null;\n if (keyedVnodes.length === 0 || keyedVnodes.length !== newChildren.length) {\n return null;\n }\n\n try {\n const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);\n recordFastPathStats(stats, 'bulkKeyedPositionalForced');\n\n rebuildKeyedMap(parent);\n return keyedElements.get(parent) as Map<string | number, Element>;\n } catch {\n return null;\n }\n}\n\n/** Try positional bulk update for medium-sized lists */\nfunction tryPositionalBulkUpdate(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): Map<string | number, Element> | null {\n const total = keyedVnodes.length;\n if (total < 10) return null;\n\n // CRITICAL INVARIANT: Only use children[] indexing if element-only is guaranteed\n // If parent has text nodes or comment nodes, bail to full reconciliation\n if (parent.children.length !== total) {\n return null;\n }\n\n const matchCount = countPositionalMatches(parent, keyedVnodes);\n\n // For keyed lists, the positional bulk update path makes sense in two cases:\n // 1. Perfect match (100%): All keys are in the right positions, just update text\n // 2. Very low match (<10%): Keys changed en-masse, treat as bulk re-key, reuse nodes by position\n // ANY mismatch at all means we have a reorder and need full reconciliation\n // to preserve DOM node identity correctly.\n const matchFraction = matchCount / total;\n\n if (keyedVnodes.length > 0) {\n // For keyed lists: require perfect match or very low match\n // matchCount !== total catches ANY reordering, even just 2 swapped elements\n if (matchCount !== total && matchFraction >= 0.1) {\n return null;\n }\n } else {\n // For unkeyed lists: use original threshold\n if (matchFraction < 0.9) {\n return null;\n }\n }\n\n // Check for prop changes that would prevent positional update\n if (hasPositionalPropChanges(parent, keyedVnodes)) {\n return null;\n }\n\n // Perform positional update\n try {\n const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);\n recordFastPathStats(stats, 'bulkKeyedPositionalHits');\n\n rebuildKeyedMap(parent);\n return keyedElements.get(parent) as Map<string | number, Element>;\n } catch {\n return null;\n }\n}\n\n/** Count how many vnodes match parent children by position and tag */\nfunction countPositionalMatches(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): number {\n let matchCount = 0;\n\n try {\n // For keyed children, use children (elements only) since keyed nodes are elements\n for (let i = 0; i < keyedVnodes.length; i++) {\n const vnode = keyedVnodes[i].vnode as VnodeObj;\n const expectedKey = keyedVnodes[i].key;\n\n if (!vnode || typeof vnode !== 'object' || typeof vnode.type !== 'string')\n continue;\n\n const el = parent.children[i] as Element | undefined;\n if (!el) continue;\n\n // For keyed lists, check BOTH tag name AND key match\n if (tagNamesEqualIgnoreCase(el.tagName, vnode.type)) {\n // Check if the element at this position has the expected key\n const actualKey = el.getAttribute('data-key');\n const keyMatches =\n actualKey === String(expectedKey) ||\n (actualKey !== null &&\n !Number.isNaN(Number(actualKey)) &&\n Number(actualKey) === expectedKey);\n\n if (keyMatches) {\n matchCount++;\n }\n }\n }\n } catch {\n // Ignore\n }\n\n return matchCount;\n}\n\n/** Check if positional prop changes would prevent bulk update */\nfunction hasPositionalPropChanges(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): boolean {\n try {\n // For keyed children, use children (elements only) since keyed nodes are elements\n for (let i = 0; i < keyedVnodes.length; i++) {\n const vnode = keyedVnodes[i].vnode as VnodeObj;\n const el = parent.children[i] as Element | undefined;\n if (!el || !vnode || typeof vnode !== 'object') continue;\n\n if (checkPropChanges(el, vnode.props || {})) {\n return true;\n }\n }\n } catch {\n return true;\n }\n\n return false;\n}\n\n/** Rebuild keyed map from parent children */\nfunction rebuildKeyedMap(parent: Element): void {\n try {\n const map = new Map<string | number, Element>();\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const k = el.getAttribute('data-key');\n if (k !== null) {\n map.set(k, el);\n const n = Number(k);\n if (!Number.isNaN(n)) map.set(n, el);\n }\n }\n keyedElements.set(parent, map);\n } catch {\n // Ignore\n }\n}\n\n/** Perform full reconciliation when fast paths don't apply */\nfunction performFullReconciliation(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> {\n const newKeyMap = new Map<string | number, Element>();\n const finalNodes: Node[] = [];\n const usedOldEls = new WeakSet<Node>();\n\n const resolveOldElOnce = createOldElResolver(parent, oldKeyMap, usedOldEls);\n const unkeyedEls = collectUnkeyedElements(parent);\n let unkeyedIndex = 0;\n const resolveUnkeyedOnce = (): Element | undefined => {\n while (unkeyedIndex < unkeyedEls.length) {\n const candidate = unkeyedEls[unkeyedIndex++];\n if (!usedOldEls.has(candidate)) return candidate;\n }\n return undefined;\n };\n\n // Positional reconciliation\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i];\n const node = reconcileSingleChild(\n child,\n i,\n parent,\n resolveOldElOnce,\n resolveUnkeyedOnce,\n usedOldEls,\n newKeyMap\n );\n if (node) finalNodes.push(node);\n }\n\n // SSR guard\n if (typeof document === 'undefined') return newKeyMap;\n\n commitReconciliation(parent, finalNodes);\n keyedElements.delete(parent);\n\n return newKeyMap;\n}\n\n/** Create resolver for finding old elements by key */\nfunction createOldElResolver(\n parent: Element,\n oldKeyMap: Map<string | number, Element> | undefined,\n usedOldEls: WeakSet<Node>\n): (k: string | number) => Element | undefined {\n return (k: string | number) => {\n if (!oldKeyMap) return undefined;\n\n // Fast-path: directly from oldKeyMap\n const direct = oldKeyMap.get(k);\n if (direct && !usedOldEls.has(direct)) {\n usedOldEls.add(direct);\n return direct;\n }\n\n // Try string form\n const s = String(k);\n const byString = oldKeyMap.get(s);\n if (byString && !usedOldEls.has(byString)) {\n usedOldEls.add(byString);\n return byString;\n }\n\n // Try numeric form\n const n = Number(s);\n if (!Number.isNaN(n)) {\n const byNum = oldKeyMap.get(n);\n if (byNum && !usedOldEls.has(byNum)) {\n usedOldEls.add(byNum);\n return byNum;\n }\n }\n\n // Fallback: scan parent children\n return scanForElementByKey(parent, k, s, usedOldEls);\n };\n}\n\n/** Scan parent children for element with matching key */\nfunction scanForElementByKey(\n parent: Element,\n k: string | number,\n keyStr: string,\n usedOldEls: WeakSet<Node>\n): Element | undefined {\n try {\n for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {\n if (usedOldEls.has(ch)) continue;\n const attr = ch.getAttribute('data-key');\n if (attr === keyStr) {\n usedOldEls.add(ch);\n return ch;\n }\n if (attr !== null) {\n const numAttr = Number(attr);\n if (!Number.isNaN(numAttr) && numAttr === (k as number)) {\n usedOldEls.add(ch);\n return ch;\n }\n }\n }\n } catch {\n // Ignore\n }\n return undefined;\n}\n\n/** Reconcile a single child */\nfunction reconcileSingleChild(\n child: VNode,\n index: number,\n parent: Element,\n resolveOldElOnce: (k: string | number) => Element | undefined,\n resolveUnkeyedOnce: () => Element | undefined,\n usedOldEls: WeakSet<Node>,\n newKeyMap: Map<string | number, Element>\n): Node | null {\n // Keyed child\n const key = extractKey(child);\n\n if (key !== undefined) {\n return reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap);\n }\n\n // Unkeyed or primitive child\n return reconcileUnkeyedChild(\n child,\n index,\n parent,\n resolveUnkeyedOnce,\n usedOldEls\n );\n}\n\n/** Reconcile a keyed child */\nfunction reconcileKeyedChild(\n child: VNode,\n key: string | number,\n parent: Element,\n resolveOldElOnce: (k: string | number) => Element | undefined,\n newKeyMap: Map<string | number, Element>\n): Node | null {\n const el = resolveOldElOnce(key);\n\n if (el && el.parentElement === parent) {\n // Strict keyed guarantee: if the element tag changes for an existing key,\n // replace the DOM node rather than mutating in place.\n try {\n const childObj = child as VnodeObj;\n if (\n childObj &&\n typeof childObj === 'object' &&\n typeof childObj.type === 'string'\n ) {\n if (tagNamesEqualIgnoreCase(el.tagName, childObj.type)) {\n updateElementFromVnode(el, child);\n newKeyMap.set(key, el);\n return el;\n }\n }\n if (isComponentVNode(child)) {\n const synced = syncComponentElement(\n el,\n child,\n child.type,\n ((child.props ?? {}) as Props) || {}\n );\n if (synced) {\n if (synced instanceof Element) newKeyMap.set(key, synced);\n return synced;\n }\n }\n } catch {\n // Fall through to replacement\n }\n }\n\n const dom = createDOMNode(child);\n if (dom) {\n if (dom instanceof Element) newKeyMap.set(key, dom);\n return dom;\n }\n\n return null;\n}\n\n/** Reconcile an unkeyed or primitive child */\nfunction reconcileUnkeyedChild(\n child: VNode,\n index: number,\n parent: Element,\n resolveUnkeyedOnce: () => Element | undefined,\n usedOldEls: WeakSet<Node>\n): Node | null {\n try {\n // Use childNodes (includes Text nodes) instead of children (elements only)\n const existing = parent.childNodes[index] as Node | undefined;\n\n // Primitive child: try to reuse Text node if available\n if (typeof child === 'string' || typeof child === 'number') {\n if (existing && existing.nodeType === 3) {\n // Text node: reuse in-place\n (existing as Text).data = String(child);\n usedOldEls.add(existing);\n return existing;\n }\n return createDOMNode(child);\n }\n\n if (existing instanceof Element) {\n const synced = trySyncComponentChild(existing, child, usedOldEls);\n if (synced) return synced;\n }\n\n // Element child matching existing unkeyed element\n if (existing instanceof Element && canReuseElement(existing, child)) {\n updateElementFromVnode(existing, child);\n usedOldEls.add(existing);\n return existing;\n }\n\n // Try to find available unkeyed element elsewhere\n const avail = resolveUnkeyedOnce();\n if (avail) {\n const reuseResult = tryReuseElement(avail, child, usedOldEls);\n if (reuseResult) return reuseResult;\n }\n } catch {\n // Fall through to create new\n }\n\n const dom = createDOMNode(child);\n return dom;\n}\n\nfunction isComponentVNode(child: VNode): child is ComponentVNode {\n return (\n typeof child === 'object' &&\n child !== null &&\n 'type' in child &&\n typeof (child as VnodeObj).type === 'function'\n );\n}\n\nfunction trySyncComponentChild(\n existing: Element,\n child: VNode,\n usedOldEls: WeakSet<Node>\n): Node | null {\n if (!isComponentVNode(child)) return null;\n\n const synced = syncComponentElement(\n existing,\n child,\n child.type,\n ((child.props ?? {}) as Props) || {}\n );\n if (!synced) return null;\n\n usedOldEls.add(existing);\n usedOldEls.add(synced);\n return synced;\n}\n\n/** Check if existing element can be reused for child */\nfunction canReuseElement(existing: Element | undefined, child: VNode): boolean {\n if (!existing) return false;\n if (typeof child !== 'object' || child === null || !('type' in child))\n return false;\n\n const childObj = child as VnodeObj;\n const existingKey = existing.getAttribute('data-key');\n const hasNoKey = existingKey === null || existingKey === undefined;\n\n return (\n hasNoKey &&\n typeof childObj.type === 'string' &&\n tagNamesEqualIgnoreCase(existing.tagName, childObj.type)\n );\n}\n\n/** Collect unkeyed element children in DOM order. */\nfunction collectUnkeyedElements(parent: Element): Element[] {\n const elements: Element[] = [];\n for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {\n if (ch.getAttribute('data-key') === null) elements.push(ch);\n }\n return elements;\n}\n\n/** Try to reuse available element for child */\nfunction tryReuseElement(\n avail: Element,\n child: VNode,\n usedOldEls: WeakSet<Node>\n): Node | null {\n if (typeof child === 'string' || typeof child === 'number') {\n return null;\n }\n\n const synced = trySyncComponentChild(avail, child, usedOldEls);\n if (synced) {\n return synced;\n }\n\n if (typeof child === 'object' && child !== null && 'type' in child) {\n const childObj = child as VnodeObj;\n if (\n typeof childObj.type === 'string' &&\n tagNamesEqualIgnoreCase(avail.tagName, childObj.type)\n ) {\n updateElementFromVnode(avail, child);\n usedOldEls.add(avail);\n return avail;\n }\n }\n\n return null;\n}\n\n/** Commit reconciliation by replacing parent children */\nfunction commitReconciliation(parent: Element, finalNodes: Node[]): void {\n try {\n const finalSet = new Set<Node>(finalNodes);\n\n for (let n = parent.firstChild; n; ) {\n const next = n.nextSibling;\n if (!finalSet.has(n)) {\n teardownNodeSubtree(n);\n parent.removeChild(n);\n }\n n = next;\n }\n\n for (let i = 0; i < finalNodes.length; i++) {\n const desiredNode = finalNodes[i];\n const anchor = parent.childNodes[i] ?? null;\n if (desiredNode !== anchor) {\n parent.insertBefore(desiredNode, anchor);\n }\n }\n } catch {\n const fragment = document.createDocumentFragment();\n for (let i = 0; i < finalNodes.length; i++) {\n fragment.appendChild(finalNodes[i]);\n }\n\n try {\n for (let n = parent.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n } catch {\n // Ignore fallback cleanup failures.\n }\n\n recordDOMReplace('reconcile');\n parent.replaceChildren(fragment);\n return;\n }\n}\n"],"mappings":";;;;;;;;AAoHA,SAAgB,uBACd,QACA,aACA,WAC+B;CAC/B,MAAM,cAAc,qBAAqB,YAAY;CAIrD,MAAM,mBAAmB,aAAa,mBAAmB,OAAO;CAGhE,MAAM,iBAAiB,aACrB,QACA,aACA,aACA,iBACD;CACD,IAAI,gBACF,OAAO;CAIT,OAAO,0BACL,QACA,aACA,aACA,iBACD;;;AAIH,SAAS,mBAAmB,QAAgD;CAC1E,MAAM,yBAAS,IAAI,KAA+B;CAClD,IAAI;EACF,KAAK,IAAI,KAAK,OAAO,mBAAmB,IAAI,KAAK,GAAG,oBAAoB;GACtE,MAAM,IAAI,GAAG,aAAa,WAAW;GACrC,IAAI,MAAM,MAAM;IACd,OAAO,IAAI,GAAG,GAAG;IACjB,MAAM,IAAI,OAAO,EAAE;IACnB,IAAI,CAAC,OAAO,MAAM,EAAE,EAAE,OAAO,IAAI,GAAG,GAAG;;;SAGrC;CAGR,OAAO;;;AAIT,SAAS,qBACP,aAC+C;CAC/C,MAAM,cAA6D,EAAE;CAErE,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,QAAQ,YAAY;EAC1B,MAAM,MAAM,WAAW,MAAM;EAC7B,IAAI,QAAQ,QACV,YAAY,KAAK;GAAE;GAAK,OAAO;GAAO,CAAC;;CAI3C,OAAO;;;AAIT,SAAS,aACP,QAC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OAAO,EAAE;IACf,oBAAoB,EAAE;IACtB,IAAI;;UAEA;EAIR,iBAAiB,YAAY;EAC7B,OAAO,gBAAgB,SAAS;EAChC"}
|
package/dist/renderer/utils.js
CHANGED
|
@@ -8,6 +8,10 @@ import "./env.js";
|
|
|
8
8
|
* Shared utilities for the renderer module.
|
|
9
9
|
* Consolidates common patterns to reduce code duplication.
|
|
10
10
|
*/
|
|
11
|
+
const DIRECT_REPLACE_CHILDREN_SPREAD_LIMIT = 4096;
|
|
12
|
+
function canUseDirectReplaceChildrenSpread(count) {
|
|
13
|
+
return count <= DIRECT_REPLACE_CHILDREN_SPREAD_LIMIT;
|
|
14
|
+
}
|
|
11
15
|
const handlerCache = /* @__PURE__ */ new WeakMap();
|
|
12
16
|
let cacheSize = 0;
|
|
13
17
|
const MAX_CACHE_SIZE = 1e3;
|
|
@@ -215,6 +219,6 @@ function now() {
|
|
|
215
219
|
return typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
216
220
|
}
|
|
217
221
|
//#endregion
|
|
218
|
-
export { buildKeyMapFromChildren, checkPropChanges, createMutableWrappedHandler, createWrappedHandler, extractKey, getPassiveOptions, hasNonTrivialProps, hasPropChanged, isIgnoredForPropChanges, isSkippedProp, logFastPathDebug, now, parseEventName, readElementClassName, recordDOMReplace, recordFastPathStats, tagNamesEqualIgnoreCase, writeElementClassName };
|
|
222
|
+
export { buildKeyMapFromChildren, canUseDirectReplaceChildrenSpread, checkPropChanges, createMutableWrappedHandler, createWrappedHandler, extractKey, getPassiveOptions, hasNonTrivialProps, hasPropChanged, isIgnoredForPropChanges, isSkippedProp, logFastPathDebug, now, parseEventName, readElementClassName, recordDOMReplace, recordFastPathStats, tagNamesEqualIgnoreCase, writeElementClassName };
|
|
219
223
|
|
|
220
224
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/renderer/utils.ts"],"sourcesContent":["/**\n * Shared utilities for the renderer module.\n * Consolidates common patterns to reduce code duplication.\n */\n\nimport { globalScheduler } from '../runtime/scheduler';\nimport { logger } from '../dev/logger';\nimport { getRuntimeEnv } from './env';\nimport { setDevValue, incDevCounter } from '../runtime/dev-namespace';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Types\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface ListenerEntry {\n handler: EventListener;\n original: EventListener;\n options?: boolean | AddEventListenerOptions;\n updateHandler?: (nextHandler: EventListener) => void;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Event Handler Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n// Handler pooling cache to avoid recreating wrapped handlers\n// Key: handler reference, Value: { wrapped: EventListener, flushAfter: boolean }\nconst handlerCache = new WeakMap<EventListener, Map<boolean, EventListener>>();\nlet cacheSize = 0;\nconst MAX_CACHE_SIZE = 1000;\n\n/**\n * Parse an event prop name (e.g., 'onClick') to its DOM event name (e.g., 'click')\n */\nexport function parseEventName(propName: string): string | null {\n if (!propName.startsWith('on') || propName.length <= 2) return null;\n return (\n propName.slice(2).charAt(0).toLowerCase() + propName.slice(3).toLowerCase()\n );\n}\n\n/**\n * Get default event listener options for passive events\n */\nexport function getPassiveOptions(\n eventName: string\n): AddEventListenerOptions | undefined {\n if (\n eventName === 'wheel' ||\n eventName === 'scroll' ||\n eventName.startsWith('touch')\n ) {\n return { passive: true };\n }\n return undefined;\n}\n\n/**\n * Create a wrapped event handler that integrates with the scheduler\n * Uses caching to avoid recreating wrappers for the same handler\n */\nexport function createWrappedHandler(\n handler: EventListener,\n flushAfter = false\n): EventListener {\n // Check cache first\n const cachedByFlush = handlerCache.get(handler);\n if (cachedByFlush) {\n const cached = cachedByFlush.get(flushAfter);\n if (cached) return cached;\n }\n\n const wrapped: EventListener = (event: Event) => {\n try {\n globalScheduler.runInHandlerScope(\n () => {\n try {\n handler(event);\n } catch (error) {\n logger.error('[Askr] Event handler error:', error);\n }\n },\n flushAfter ? 'sync' : 'defer'\n );\n } catch (err) {\n if (flushAfter) {\n queueMicrotask(() => {\n throw err;\n });\n } else {\n logger.error('[Askr] Event handler error:', err);\n }\n }\n };\n\n // Cache the wrapped handler\n try {\n if (!handlerCache.has(handler)) {\n // Limit cache size to prevent memory leaks\n if (cacheSize >= MAX_CACHE_SIZE) {\n // Simple eviction - just don't cache new entries when full\n } else {\n cacheSize++;\n handlerCache.set(handler, new Map());\n }\n }\n handlerCache.get(handler)?.set(flushAfter, wrapped);\n } catch {\n // WeakMap can throw if handler is not a valid key\n }\n\n return wrapped;\n}\n\nexport function createMutableWrappedHandler(\n handler: EventListener,\n flushAfter = false\n): {\n handler: EventListener;\n updateHandler: (nextHandler: EventListener) => void;\n} {\n let currentHandler = handler;\n\n const wrapped: EventListener = (event: Event) => {\n try {\n globalScheduler.runInHandlerScope(\n () => {\n try {\n currentHandler(event);\n } catch (error) {\n logger.error('[Askr] Event handler error:', error);\n }\n },\n flushAfter ? 'sync' : 'defer'\n );\n } catch (err) {\n if (flushAfter) {\n queueMicrotask(() => {\n throw err;\n });\n } else {\n logger.error('[Askr] Event handler error:', err);\n }\n }\n };\n\n return {\n handler: wrapped,\n updateHandler(nextHandler: EventListener) {\n currentHandler = nextHandler;\n },\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Prop/Attribute Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Props that should be skipped during attribute processing */\nexport function isSkippedProp(key: string): boolean {\n return key === 'children' || key === 'key' || key === 'ref';\n}\n\n/** Check if prop should be ignored for prop-change detection */\nexport function isIgnoredForPropChanges(key: string): boolean {\n if (key === 'children' || key === 'key') return true;\n if (key.startsWith('on') && key.length > 2) return true;\n if (key.startsWith('data-')) return true;\n return false;\n}\n\n/**\n * Check if an element's current attribute value differs from vnode value\n */\nexport function hasPropChanged(\n el: Element,\n key: string,\n value: unknown\n): boolean {\n try {\n if (key === 'class' || key === 'className') {\n return readElementClassName(el) !== String(value);\n }\n if (key === 'value' || key === 'checked') {\n return (el as HTMLElement & Record<string, unknown>)[key] !== value;\n }\n const attr = el.getAttribute(key);\n if (value === undefined || value === null || value === false) {\n return attr !== null;\n }\n return String(value) !== attr;\n } catch {\n return true;\n }\n}\n\nexport function isSVGDomElement(el: Element): el is SVGElement {\n return typeof SVGElement !== 'undefined' && el instanceof SVGElement;\n}\n\nexport function readElementClassName(el: Element): string {\n if (isSVGDomElement(el)) {\n return el.getAttribute('class') ?? '';\n }\n\n return (el as HTMLElement).className;\n}\n\nexport function writeElementClassName(el: Element, value: string): void {\n if (isSVGDomElement(el)) {\n if (value.length > 0) {\n el.setAttribute('class', value);\n } else {\n el.removeAttribute('class');\n }\n return;\n }\n\n (el as HTMLElement).className = value;\n}\n\nexport function tagNamesEqualIgnoreCase(a: string, b: string): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n\n for (let index = 0; index < a.length; index += 1) {\n const aCode = a.charCodeAt(index);\n const bCode = b.charCodeAt(index);\n if (aCode === bCode) continue;\n\n const normalizedA = aCode >= 65 && aCode <= 90 ? aCode + 32 : aCode;\n const normalizedB = bCode >= 65 && bCode <= 90 ? bCode + 32 : bCode;\n if (normalizedA !== normalizedB) return false;\n }\n\n return true;\n}\n\n/**\n * Check if a vnode has non-trivial props (excluding events and data-*)\n */\nexport function hasNonTrivialProps(props: Record<string, unknown>): boolean {\n for (const k of Object.keys(props)) {\n if (isIgnoredForPropChanges(k)) continue;\n return true;\n }\n return false;\n}\n\n/**\n * Check for prop changes between vnode and existing element\n */\nexport function checkPropChanges(\n el: Element,\n props: Record<string, unknown>\n): boolean {\n for (const k of Object.keys(props)) {\n if (isIgnoredForPropChanges(k)) continue;\n if (hasPropChanged(el, k, props[k])) {\n return true;\n }\n }\n return false;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Key Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Extract key from a vnode object\n */\nexport function extractKey(vnode: unknown): string | number | undefined {\n if (typeof vnode !== 'object' || vnode === null) return undefined;\n const obj = vnode as Record<string, unknown>;\n const rawKey =\n obj.key ?? (obj.props as Record<string, unknown> | undefined)?.key;\n if (rawKey === undefined || rawKey === null) return undefined;\n return typeof rawKey === 'symbol'\n ? String(rawKey)\n : (rawKey as string | number);\n}\n\n/**\n * Build a key map from element's children\n */\nexport function buildKeyMapFromChildren(\n parent: Element\n): Map<string | number, Element> {\n const map = new Map<string | number, Element>();\n for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {\n const k = ch.getAttribute('data-key');\n if (k !== null) {\n map.set(k, ch);\n const n = Number(k);\n if (!Number.isNaN(n)) map.set(n, ch);\n }\n }\n return map;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Diagnostic Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Record DOM replace operation for diagnostics\n */\nexport function recordDOMReplace(source: string): void {\n try {\n incDevCounter('__DOM_REPLACE_COUNT');\n setDevValue(`__LAST_DOM_REPLACE_STACK_${source}`, new Error().stack);\n } catch {\n // ignore\n }\n}\n\n/**\n * Record fast-path stats for diagnostics\n */\nexport function recordFastPathStats(\n stats: Record<string, unknown>,\n counterName?: string\n): void {\n try {\n setDevValue('__LAST_FASTPATH_STATS', stats);\n setDevValue('__LAST_FASTPATH_COMMIT_COUNT', 1);\n if (counterName) {\n incDevCounter(counterName);\n }\n } catch {\n // ignore\n }\n}\n\n/**\n * Conditionally log debug info for fast-path operations\n */\nexport function logFastPathDebug(\n message: string,\n indexOrData?: number | unknown,\n data?: unknown\n): void {\n const env = getRuntimeEnv();\n if (env.ASKR_FASTPATH_DEBUG === '1' || env.ASKR_FASTPATH_DEBUG === 'true') {\n if (data !== undefined) {\n logger.warn(`[Askr][FASTPATH] ${message}`, indexOrData, data);\n } else if (indexOrData !== undefined) {\n logger.warn(`[Askr][FASTPATH] ${message}`, indexOrData);\n } else {\n logger.warn(`[Askr][FASTPATH] ${message}`);\n }\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Performance Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Get current high-resolution timestamp\n */\nexport function now(): number {\n return typeof performance !== 'undefined' && performance.now\n ? performance.now()\n : Date.now();\n}\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,+BAAe,IAAI,SAAqD;AAC9E,IAAI,YAAY;AAChB,MAAM,iBAAiB;;;;AAKvB,SAAgB,eAAe,UAAiC;CAC9D,IAAI,CAAC,SAAS,WAAW,KAAK,IAAI,SAAS,UAAU,GAAG,OAAO;CAC/D,OACE,SAAS,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,SAAS,MAAM,EAAE,CAAC,aAAa;;;;;AAO/E,SAAgB,kBACd,WACqC;CACrC,IACE,cAAc,WACd,cAAc,YACd,UAAU,WAAW,QAAQ,EAE7B,OAAO,EAAE,SAAS,MAAM;;;;;;AAS5B,SAAgB,qBACd,SACA,aAAa,OACE;CAEf,MAAM,gBAAgB,aAAa,IAAI,QAAQ;CAC/C,IAAI,eAAe;EACjB,MAAM,SAAS,cAAc,IAAI,WAAW;EAC5C,IAAI,QAAQ,OAAO;;CAGrB,MAAM,WAA0B,UAAiB;EAC/C,IAAI;GACF,gBAAgB,wBACR;IACJ,IAAI;KACF,QAAQ,MAAM;aACP,OAAO;KACd,OAAO,MAAM,+BAA+B,MAAM;;MAGtD,aAAa,SAAS,QACvB;WACM,KAAK;GACZ,IAAI,YACF,qBAAqB;IACnB,MAAM;KACN;QAEF,OAAO,MAAM,+BAA+B,IAAI;;;CAMtD,IAAI;EACF,IAAI,CAAC,aAAa,IAAI,QAAQ,EAE5B,IAAI,aAAa,gBAAgB,QAE1B;GACL;GACA,aAAa,IAAI,yBAAS,IAAI,KAAK,CAAC;;EAGxC,aAAa,IAAI,QAAQ,EAAE,IAAI,YAAY,QAAQ;SAC7C;CAIR,OAAO;;AAGT,SAAgB,4BACd,SACA,aAAa,OAIb;CACA,IAAI,iBAAiB;CAErB,MAAM,WAA0B,UAAiB;E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AAO,MAAM,EAAE,EAAE,IAAI,IAAI,GAAG,GAAG;;;CAGxC,OAAO;;;;;AAUT,SAAgB,iBAAiB,QAAsB;CACrD,IAAI;EACF,cAAc,sBAAsB;EACpC,YAAY,4BAA4B,2BAAU,IAAI,OAAO,EAAC,MAAM;SAC9D;;;;;AAQV,SAAgB,oBACd,OACA,aACM;CACN,IAAI;EACF,YAAY,yBAAyB,MAAM;EAC3C,YAAY,gCAAgC,EAAE;EAC9C,IAAI,aACF,cAAc,YAAY;SAEtB;;;;;AAQV,SAAgB,iBACd,SACA,aACA,MACM;CACN,MAAM,MAAM,eAAe;CAC3B,IAAI,IAAI,wBAAwB,OAAO,IAAI,wBAAwB,QACjE,IAAI,SAAS,QACX,OAAO,KAAK,oBAAoB,WAAW,aAAa,KAAK;MACxD,IAAI,gBAAgB,QACzB,OAAO,KAAK,oBAAoB,WAAW,YAAY;MAEvD,OAAO,KAAK,oBAAoB,UAAU;;;;;AAYhD,SAAgB,MAAc;CAC5B,OAAO,OAAO,gBAAgB,eAAe,YAAY,MACrD,YAAY,KAAK,GACjB,KAAK,KAAK"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/renderer/utils.ts"],"sourcesContent":["/**\n * Shared utilities for the renderer module.\n * Consolidates common patterns to reduce code duplication.\n */\n\nimport { globalScheduler } from '../runtime/scheduler';\nimport { logger } from '../dev/logger';\nimport { getRuntimeEnv } from './env';\nimport { setDevValue, incDevCounter } from '../runtime/dev-namespace';\n\n// Keep direct replaceChildren(...nodes) commits below a conservative argument\n// count until browser benchmarks prove larger spreads are safe.\nexport const DIRECT_REPLACE_CHILDREN_SPREAD_LIMIT = 4096;\n\nexport function canUseDirectReplaceChildrenSpread(count: number): boolean {\n return count <= DIRECT_REPLACE_CHILDREN_SPREAD_LIMIT;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Types\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface ListenerEntry {\n handler: EventListener;\n original: EventListener;\n options?: boolean | AddEventListenerOptions;\n updateHandler?: (nextHandler: EventListener) => void;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Event Handler Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n// Handler pooling cache to avoid recreating wrapped handlers\n// Key: handler reference, Value: { wrapped: EventListener, flushAfter: boolean }\nconst handlerCache = new WeakMap<EventListener, Map<boolean, EventListener>>();\nlet cacheSize = 0;\nconst MAX_CACHE_SIZE = 1000;\n\n/**\n * Parse an event prop name (e.g., 'onClick') to its DOM event name (e.g., 'click')\n */\nexport function parseEventName(propName: string): string | null {\n if (!propName.startsWith('on') || propName.length <= 2) return null;\n return (\n propName.slice(2).charAt(0).toLowerCase() + propName.slice(3).toLowerCase()\n );\n}\n\n/**\n * Get default event listener options for passive events\n */\nexport function getPassiveOptions(\n eventName: string\n): AddEventListenerOptions | undefined {\n if (\n eventName === 'wheel' ||\n eventName === 'scroll' ||\n eventName.startsWith('touch')\n ) {\n return { passive: true };\n }\n return undefined;\n}\n\n/**\n * Create a wrapped event handler that integrates with the scheduler\n * Uses caching to avoid recreating wrappers for the same handler\n */\nexport function createWrappedHandler(\n handler: EventListener,\n flushAfter = false\n): EventListener {\n // Check cache first\n const cachedByFlush = handlerCache.get(handler);\n if (cachedByFlush) {\n const cached = cachedByFlush.get(flushAfter);\n if (cached) return cached;\n }\n\n const wrapped: EventListener = (event: Event) => {\n try {\n globalScheduler.runInHandlerScope(\n () => {\n try {\n handler(event);\n } catch (error) {\n logger.error('[Askr] Event handler error:', error);\n }\n },\n flushAfter ? 'sync' : 'defer'\n );\n } catch (err) {\n if (flushAfter) {\n queueMicrotask(() => {\n throw err;\n });\n } else {\n logger.error('[Askr] Event handler error:', err);\n }\n }\n };\n\n // Cache the wrapped handler\n try {\n if (!handlerCache.has(handler)) {\n // Limit cache size to prevent memory leaks\n if (cacheSize >= MAX_CACHE_SIZE) {\n // Simple eviction - just don't cache new entries when full\n } else {\n cacheSize++;\n handlerCache.set(handler, new Map());\n }\n }\n handlerCache.get(handler)?.set(flushAfter, wrapped);\n } catch {\n // WeakMap can throw if handler is not a valid key\n }\n\n return wrapped;\n}\n\nexport function createMutableWrappedHandler(\n handler: EventListener,\n flushAfter = false\n): {\n handler: EventListener;\n updateHandler: (nextHandler: EventListener) => void;\n} {\n let currentHandler = handler;\n\n const wrapped: EventListener = (event: Event) => {\n try {\n globalScheduler.runInHandlerScope(\n () => {\n try {\n currentHandler(event);\n } catch (error) {\n logger.error('[Askr] Event handler error:', error);\n }\n },\n flushAfter ? 'sync' : 'defer'\n );\n } catch (err) {\n if (flushAfter) {\n queueMicrotask(() => {\n throw err;\n });\n } else {\n logger.error('[Askr] Event handler error:', err);\n }\n }\n };\n\n return {\n handler: wrapped,\n updateHandler(nextHandler: EventListener) {\n currentHandler = nextHandler;\n },\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Prop/Attribute Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Props that should be skipped during attribute processing */\nexport function isSkippedProp(key: string): boolean {\n return key === 'children' || key === 'key' || key === 'ref';\n}\n\n/** Check if prop should be ignored for prop-change detection */\nexport function isIgnoredForPropChanges(key: string): boolean {\n if (key === 'children' || key === 'key') return true;\n if (key.startsWith('on') && key.length > 2) return true;\n if (key.startsWith('data-')) return true;\n return false;\n}\n\n/**\n * Check if an element's current attribute value differs from vnode value\n */\nexport function hasPropChanged(\n el: Element,\n key: string,\n value: unknown\n): boolean {\n try {\n if (key === 'class' || key === 'className') {\n return readElementClassName(el) !== String(value);\n }\n if (key === 'value' || key === 'checked') {\n return (el as HTMLElement & Record<string, unknown>)[key] !== value;\n }\n const attr = el.getAttribute(key);\n if (value === undefined || value === null || value === false) {\n return attr !== null;\n }\n return String(value) !== attr;\n } catch {\n return true;\n }\n}\n\nexport function isSVGDomElement(el: Element): el is SVGElement {\n return typeof SVGElement !== 'undefined' && el instanceof SVGElement;\n}\n\nexport function readElementClassName(el: Element): string {\n if (isSVGDomElement(el)) {\n return el.getAttribute('class') ?? '';\n }\n\n return (el as HTMLElement).className;\n}\n\nexport function writeElementClassName(el: Element, value: string): void {\n if (isSVGDomElement(el)) {\n if (value.length > 0) {\n el.setAttribute('class', value);\n } else {\n el.removeAttribute('class');\n }\n return;\n }\n\n (el as HTMLElement).className = value;\n}\n\nexport function tagNamesEqualIgnoreCase(a: string, b: string): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n\n for (let index = 0; index < a.length; index += 1) {\n const aCode = a.charCodeAt(index);\n const bCode = b.charCodeAt(index);\n if (aCode === bCode) continue;\n\n const normalizedA = aCode >= 65 && aCode <= 90 ? aCode + 32 : aCode;\n const normalizedB = bCode >= 65 && bCode <= 90 ? bCode + 32 : bCode;\n if (normalizedA !== normalizedB) return false;\n }\n\n return true;\n}\n\n/**\n * Check if a vnode has non-trivial props (excluding events and data-*)\n */\nexport function hasNonTrivialProps(props: Record<string, unknown>): boolean {\n for (const k of Object.keys(props)) {\n if (isIgnoredForPropChanges(k)) continue;\n return true;\n }\n return false;\n}\n\n/**\n * Check for prop changes between vnode and existing element\n */\nexport function checkPropChanges(\n el: Element,\n props: Record<string, unknown>\n): boolean {\n for (const k of Object.keys(props)) {\n if (isIgnoredForPropChanges(k)) continue;\n if (hasPropChanged(el, k, props[k])) {\n return true;\n }\n }\n return false;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Key Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Extract key from a vnode object\n */\nexport function extractKey(vnode: unknown): string | number | undefined {\n if (typeof vnode !== 'object' || vnode === null) return undefined;\n const obj = vnode as Record<string, unknown>;\n const rawKey =\n obj.key ?? (obj.props as Record<string, unknown> | undefined)?.key;\n if (rawKey === undefined || rawKey === null) return undefined;\n return typeof rawKey === 'symbol'\n ? String(rawKey)\n : (rawKey as string | number);\n}\n\n/**\n * Build a key map from element's children\n */\nexport function buildKeyMapFromChildren(\n parent: Element\n): Map<string | number, Element> {\n const map = new Map<string | number, Element>();\n for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {\n const k = ch.getAttribute('data-key');\n if (k !== null) {\n map.set(k, ch);\n const n = Number(k);\n if (!Number.isNaN(n)) map.set(n, ch);\n }\n }\n return map;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Diagnostic Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Record DOM replace operation for diagnostics\n */\nexport function recordDOMReplace(source: string): void {\n try {\n incDevCounter('__DOM_REPLACE_COUNT');\n setDevValue(`__LAST_DOM_REPLACE_STACK_${source}`, new Error().stack);\n } catch {\n // ignore\n }\n}\n\n/**\n * Record fast-path stats for diagnostics\n */\nexport function recordFastPathStats(\n stats: Record<string, unknown>,\n counterName?: string\n): void {\n try {\n setDevValue('__LAST_FASTPATH_STATS', stats);\n setDevValue('__LAST_FASTPATH_COMMIT_COUNT', 1);\n if (counterName) {\n incDevCounter(counterName);\n }\n } catch {\n // ignore\n }\n}\n\n/**\n * Conditionally log debug info for fast-path operations\n */\nexport function logFastPathDebug(\n message: string,\n indexOrData?: number | unknown,\n data?: unknown\n): void {\n const env = getRuntimeEnv();\n if (env.ASKR_FASTPATH_DEBUG === '1' || env.ASKR_FASTPATH_DEBUG === 'true') {\n if (data !== undefined) {\n logger.warn(`[Askr][FASTPATH] ${message}`, indexOrData, data);\n } else if (indexOrData !== undefined) {\n logger.warn(`[Askr][FASTPATH] ${message}`, indexOrData);\n } else {\n logger.warn(`[Askr][FASTPATH] ${message}`);\n }\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Performance Utilities\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Get current high-resolution timestamp\n */\nexport function now(): number {\n return typeof performance !== 'undefined' && performance.now\n ? performance.now()\n : Date.now();\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAa,uCAAuC;AAEpD,SAAgB,kCAAkC,OAAwB;CACxE,OAAO,SAAS;;AAoBlB,MAAM,+BAAe,IAAI,SAAqD;AAC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;;;AAQV,SAAgB,oBACd,OACA,aACM;CACN,IAAI;EACF,YAAY,yBAAyB,MAAM;EAC3C,YAAY,gCAAgC,EAAE;EAC9C,IAAI,aACF,cAAc,YAAY;SAEtB;;;;;AAQV,SAAgB,iBACd,SACA,aACA,MACM;CACN,MAAM,MAAM,eAAe;CAC3B,IAAI,IAAI,wBAAwB,OAAO,IAAI,wBAAwB,QACjE,IAAI,SAAS,QACX,OAAO,KAAK,oBAAoB,WAAW,aAAa,KAAK;MACxD,IAAI,gBAAgB,QACzB,OAAO,KAAK,oBAAoB,WAAW,YAAY;MAEvD,OAAO,KAAK,oBAAoB,UAAU;;;;;AAYhD,SAAgB,MAAc;CAC5B,OAAO,OAAO,gBAAgB,eAAe,YAAY,MACrD,YAAY,KAAK,GACjB,KAAK,KAAK"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { getSignal } from "../runtime/component.js";
|
|
2
2
|
import { ResourceResult, capture, on, resource, stream, task, timer } from "../runtime/operations.js";
|
|
3
|
-
|
|
4
|
-
export { type Mutation, type Query, type QueryConsistency, type ResourceResult, capture, createMutation, createQuery, getSignal, invalidate, on, resource, stream, task, timer };
|
|
3
|
+
export { type ResourceResult, capture, getSignal, on, resource, stream, task, timer };
|
package/dist/resources/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { getSignal } from "../runtime/component.js";
|
|
2
2
|
import { capture, on, resource, stream, task, timer } from "../runtime/operations.js";
|
|
3
|
-
|
|
4
|
-
export { capture, createMutation, createQuery, getSignal, invalidate, on, resource, stream, task, timer };
|
|
3
|
+
export { capture, getSignal, on, resource, stream, task, timer };
|
package/dist/router/route.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { defineContext, readContext } from "../runtime/context.js";
|
|
2
2
|
import { markReactivePropsDirtySource, markReadableDerivedSubscribersDirty, notifyReadableReaders, recordReadableRead } from "../runtime/readable.js";
|
|
3
3
|
import { getCurrentComponentInstance } from "../runtime/component.js";
|
|
4
|
-
import { getRenderContext } from "../ssr/context.js";
|
|
5
4
|
import { computeRank, matchSegments, parseSegments } from "./match.js";
|
|
6
5
|
import { requireAuth, requireGuest, requirePermission, requireRole } from "./policy.js";
|
|
7
6
|
import { buildRouteContext, buildRouteContextBase, deepFreeze, makeQuery, parseLocation } from "./route-context.js";
|
|
8
7
|
import { getExecutionModel } from "../runtime/execution-model.js";
|
|
8
|
+
import { getRenderContext } from "../ssr/context.js";
|
|
9
9
|
//#region src/router/route.ts
|
|
10
10
|
/**
|
|
11
11
|
* Route definition, registration, and matching.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"for.d.ts","names":[],"sources":["../../src/runtime/for.ts"],"mappings":";;;;;;;;;UAoDiB,eAAA;EACf,GAAA;EACA,IAAA,EAAM,CAAA;EACN,YAAA,EAAc,CAAA;EACd,UAAA,EAAY,aAAA,CAAc,CAAA;EAC1B,mBAAA,EAAqB,GAAA,CAAI,WAAA,EAAa,qBAAA;EACtC,WAAA,EAAa,cAAA;EACb,KAAA,EAAO,UAAA;AAAA;AAAA,KAGJ,aAAA,MAAmB,cAAA,CAAe,CAAA,WAC9B,CAAA;EACL,IAAA,IAAQ,CAAA;EACR,GAAA,CAAI,QAAA,EAAU,CAAA,EAAG,aAAA;AAAA;AAAA,KAGhB,qBAAA,GAAwB,cAAA;EAEzB,IAAA;EACA,GAAA,CAAI,QAAA,WAAmB,aAAA;AAAA;AAAA,KAGtB,cAAA,GAAiB,cAAA;EAElB,IAAA;EACA,GAAA,CAAI,QAAA,aAAqB,IAAA;AAAA;AAAA,KAGjB,iBAAA;AAAA,UAOK,QAAA;EACf,IAAA;EACA,YAAA,EAAc,CAAA;EACd,UAAA,EAAY,aAAA,CAAc,CAAA;EAC1B,QAAA,EAAU,KAAA;EACV,aAAA,EAAe,UAAA;EACf,KAAA,EAAO,GAAA,kBAAqB,eAAA,CAAgB,CAAA;EAC5C,WAAA,EAAa,KAAA;EACb,YAAA,EAAc,eAA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