@askrjs/askr 0.0.31 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/benchmark.js +2 -2
- package/dist/data/index.d.ts +43 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +293 -0
- package/dist/data/index.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/renderer/children.js +3 -2
- package/dist/renderer/children.js.map +1 -1
- package/dist/renderer/dom.js +29 -6
- package/dist/renderer/dom.js.map +1 -1
- package/dist/renderer/evaluate.js +2 -2
- package/dist/renderer/evaluate.js.map +1 -1
- package/dist/renderer/fastpath.js +2 -1
- package/dist/renderer/fastpath.js.map +1 -1
- package/dist/resources/index.d.ts +2 -1
- package/dist/resources/index.js +2 -1
- package/dist/runtime/fastlane.js +2 -2
- package/dist/runtime/fastlane.js.map +1 -1
- package/dist/runtime/for.d.ts.map +1 -1
- package/dist/runtime/for.js +9 -4
- package/dist/runtime/for.js.map +1 -1
- package/package.json +6 -2
package/dist/runtime/for.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"for.js","names":[],"sources":["../../src/runtime/for.ts"],"sourcesContent":["/**\n * For primitive runtime\n *\n * Manages per-item component instances and array reconciliation\n * to eliminate over-invalidation in list rendering.\n */\n\nimport { type ComponentInstance, getCurrentInstance } from './component';\nimport { claimHookIndex } from './component';\nimport { type DOMElement, type VNode } from '../common/vnode';\nimport { isDevelopmentEnvironment } from '../common/env';\nimport { teardownNodeSubtree } from '../renderer/cleanup';\nimport {\n createChildScope,\n disposeChildScope,\n type ChildScope,\n} from './child-scope';\nimport type { ForProps } from '../control/for';\nimport type { ForEachSource } from '../control/for';\nimport {\n markReactivePropsDirtySource,\n markReadableDerivedSubscribersDirty,\n notifyReadableReaders,\n recordReadableRead,\n type ReadableSource,\n} from './readable';\nimport type { FineGrainedEffectHandle } from './effect';\nimport {\n flushBenchMetrics,\n getBenchMetrics,\n isBenchBuildEnabled,\n isBenchMetricScopeActive,\n recordBenchEvent,\n recordBenchCounter,\n recordBenchFastLane,\n recordBenchTiming,\n resetBenchMetrics,\n withBenchMetricScope,\n} from './for-bench';\n\nconst BENCH_BUILD_ENABLED = isBenchBuildEnabled();\n\nexport {\n getBenchMetrics,\n isBenchMetricScopeActive,\n recordBenchEvent,\n recordBenchCounter,\n recordBenchTiming,\n resetBenchMetrics,\n withBenchMetricScope,\n};\n\nexport interface ForItemInstance<T> {\n key: string | number;\n item: T;\n reactiveItem: T;\n itemSignal: ForItemSignal<T> | null;\n itemPropertySignals: Map<PropertyKey, ForItemPropertySignal> | null;\n indexSignal: ForIndexSignal;\n scope: ChildScope;\n}\n\ntype ForItemSignal<T> = ReadableSource<T> &\n (() => T) & {\n peek(): T;\n set(newValue: T, notifyReaders?: boolean): void;\n };\n\ntype ForItemPropertySignal = ReadableSource<unknown> &\n (() => unknown) & {\n peek(): unknown;\n set(newValue: unknown, notifyReaders?: boolean): void;\n };\n\ntype ForIndexSignal = ReadableSource<number> &\n (() => number) & {\n peek(): number;\n set(newValue: number | ((prev: number) => number)): void;\n };\n\nexport type ForCommitStrategy =\n | 'APPEND'\n | 'TRUNCATE'\n | 'NO_REORDER'\n | 'SWAP'\n | 'FULL_KEYED';\n\nexport interface ForState<T> {\n kind: 'for';\n currentItems: T[];\n eachSource: ForEachSource<T>;\n fallback: VNode | null;\n fallbackScope: ChildScope | null;\n items: Map<string | number, ForItemInstance<T>>;\n orderedKeys: Array<string | number>;\n orderedVNodes: VNode[];\n byFn: NonNullable<ForProps<T>['by']> | ((item: T, index: number) => number);\n renderFn: (item: T, index: () => number) => VNode;\n parentInstance: ComponentInstance | null;\n lastCommitStrategy: ForCommitStrategy;\n lastRemovedNodes: Node[];\n pendingDirtyIndices: number[] | null;\n pendingSwapIndices: [number, number] | null;\n pendingMoveOnly: boolean;\n _hasResolvedItemDom: boolean;\n _needsSourceReconcile: boolean;\n _sourceEffect: FineGrainedEffectHandle<T[]> | null;\n _suspendSourceCommit: boolean;\n _enqueueBoundaryCommit?: (() => void) | null;\n _hasPendingBoundaryCommit?: boolean;\n devKeyKinds?: Map<string, 'number' | 'string'>;\n}\n\nconst forStates = new WeakMap<\n ComponentInstance,\n Map<number, ForState<unknown>>\n>();\n\nfunction getForStore(\n instance: ComponentInstance\n): Map<number, ForState<unknown>> {\n let store = forStates.get(instance);\n if (!store) {\n store = new Map();\n forStates.set(instance, store);\n }\n return store;\n}\n\nexport function createForState<T>(\n eachSource: ForEachSource<T>,\n byFn: ForState<T>['byFn'],\n renderFn: (item: T, index: () => number) => VNode,\n fallback: VNode | null\n): ForState<T> {\n const parentInstance = getCurrentInstance();\n\n return {\n kind: 'for',\n currentItems: [],\n eachSource,\n fallback,\n fallbackScope: null,\n items: new Map(),\n orderedKeys: [],\n orderedVNodes: [],\n byFn,\n renderFn,\n parentInstance,\n lastCommitStrategy: 'NO_REORDER',\n lastRemovedNodes: [],\n pendingDirtyIndices: null,\n pendingSwapIndices: null,\n pendingMoveOnly: false,\n _hasResolvedItemDom: false,\n _needsSourceReconcile: false,\n _sourceEffect: null,\n _suspendSourceCommit: false,\n _enqueueBoundaryCommit: null,\n _hasPendingBoundaryCommit: false,\n };\n}\n\nexport function useForState<T>(\n eachSource: ForEachSource<T>,\n byFn: ForState<T>['byFn'],\n renderFn: (item: T, index: () => number) => VNode,\n fallback: VNode | null\n): ForState<T> {\n const instance = getCurrentInstance();\n if (!instance) {\n throw new Error(\n 'For can only be created during component render execution.'\n );\n }\n\n const hookIndex = claimHookIndex(instance, 'For');\n const store = getForStore(instance);\n const existing = store.get(hookIndex) as ForState<T> | undefined;\n\n if (existing) {\n existing.eachSource = eachSource;\n existing.byFn = byFn;\n existing.renderFn = renderFn;\n existing.fallback = fallback;\n return existing;\n }\n\n const created = createForState(eachSource, byFn, renderFn, fallback);\n store.set(hookIndex, created as ForState<unknown>);\n\n (instance.cleanupFns ??= []).push(() => {\n created._sourceEffect?.cleanup();\n created._sourceEffect = null;\n store.delete(hookIndex);\n });\n\n return created;\n}\n\nfunction createForIndexSignal(initialIndex: number): ForIndexSignal {\n let indexValue = initialIndex;\n const readers = new Map<ComponentInstance, number>();\n\n const indexSignal = (() => {\n indexSignal._hasBeenRead = true;\n recordReadableRead(indexSignal);\n return indexValue;\n }) as ForIndexSignal;\n indexSignal._readers = readers;\n indexSignal.peek = () => indexValue;\n indexSignal.set = (newValue: number | ((prev: number) => number)) => {\n const nextValue =\n typeof newValue === 'function' ? newValue(indexValue) : newValue;\n if (nextValue !== indexValue) {\n indexValue = nextValue;\n markReadableDerivedSubscribersDirty(indexSignal);\n markReactivePropsDirtySource(indexSignal);\n notifyReadableReaders(indexSignal);\n }\n };\n indexSignal._hasBeenRead = false;\n\n return indexSignal;\n}\n\nfunction createForItemSignal<T>(initialItem: T): ForItemSignal<T> {\n let itemValue = initialItem;\n const readers = new Map<ComponentInstance, number>();\n\n const itemSignal = (() => {\n itemSignal._hasBeenRead = true;\n recordReadableRead(itemSignal);\n return itemValue;\n }) as ForItemSignal<T>;\n\n itemSignal._readers = readers;\n itemSignal.peek = () => itemValue;\n itemSignal.set = (newValue: T, notifyReaders = true) => {\n if (Object.is(itemValue, newValue)) {\n return;\n }\n\n itemValue = newValue;\n markReadableDerivedSubscribersDirty(itemSignal);\n markReactivePropsDirtySource(itemSignal);\n\n if (notifyReaders) {\n notifyReadableReaders(itemSignal);\n }\n };\n itemSignal._hasBeenRead = false;\n\n return itemSignal;\n}\n\nfunction createForItemPropertySignal(\n initialValue: unknown\n): ForItemPropertySignal {\n let propertyValue = initialValue;\n const readers = new Map<ComponentInstance, number>();\n\n const propertySignal = (() => {\n propertySignal._hasBeenRead = true;\n recordReadableRead(propertySignal);\n return propertyValue;\n }) as ForItemPropertySignal;\n\n propertySignal._readers = readers;\n propertySignal.peek = () => propertyValue;\n propertySignal.set = (newValue: unknown, notifyReaders = true) => {\n if (Object.is(propertyValue, newValue)) {\n return;\n }\n\n propertyValue = newValue;\n markReadableDerivedSubscribersDirty(propertySignal);\n markReactivePropsDirtySource(propertySignal);\n\n if (notifyReaders) {\n notifyReadableReaders(propertySignal);\n }\n };\n propertySignal._hasBeenRead = false;\n\n return propertySignal;\n}\n\nfunction readForItemProperty(item: unknown, prop: PropertyKey): unknown {\n return Reflect.get(Object(item), prop);\n}\n\nfunction getOrCreateForItemPropertySignal<T>(\n item: T,\n propertySignals: Map<PropertyKey, ForItemPropertySignal>,\n prop: PropertyKey\n): ForItemPropertySignal {\n const existingSignal = propertySignals.get(prop);\n if (existingSignal) {\n return existingSignal;\n }\n\n const propertySignal = createForItemPropertySignal(\n readForItemProperty(item, prop)\n );\n propertySignals.set(prop, propertySignal);\n return propertySignal;\n}\n\nfunction canProxyForItem(item: unknown): item is object {\n return (\n (typeof item === 'object' && item !== null) || typeof item === 'function'\n );\n}\n\nfunction createReactiveForItem<T>(\n itemSignal: ForItemSignal<T>,\n propertySignals: Map<PropertyKey, ForItemPropertySignal>\n): T {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n\n return new Proxy(target, {\n get(target, prop, receiver) {\n const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, prop);\n if (ownDescriptor) {\n return Reflect.get(target, prop, receiver);\n }\n\n const currentItem = itemSignal.peek();\n\n if (typeof prop !== 'symbol') {\n return getOrCreateForItemPropertySignal(\n currentItem,\n propertySignals,\n prop\n )();\n }\n\n return Reflect.get(Object(currentItem), prop, receiver);\n },\n has(target, prop) {\n return prop in target || prop in Object(itemSignal.peek());\n },\n ownKeys(target) {\n const keys = new Set<string | symbol>(Reflect.ownKeys(target));\n for (const key of Reflect.ownKeys(Object(itemSignal.peek()))) {\n keys.add(key);\n }\n\n return Array.from(keys);\n },\n getOwnPropertyDescriptor(target, prop) {\n const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, prop);\n if (ownDescriptor) {\n return ownDescriptor;\n }\n\n return Object.getOwnPropertyDescriptor(Object(itemSignal.peek()), prop);\n },\n getPrototypeOf() {\n return Object.getPrototypeOf(Object(itemSignal.peek()));\n },\n }) as T;\n}\n\nfunction materializeItemVnode(\n key: string | number,\n vnode: VNode | undefined\n): void {\n if (vnode && typeof vnode === 'object' && 'type' in vnode) {\n const vn = vnode as DOMElement;\n vn.key = key;\n\n if (typeof vn.type === 'string') {\n if (!vn.props) vn.props = {};\n if (vn.props['data-key'] === undefined) {\n vn.props['data-key'] = String(key);\n }\n }\n }\n}\n\nfunction renderItemScope<T>(\n forState: ForState<T>,\n scope: ChildScope,\n item: T,\n indexSignal: ForIndexSignal,\n key: string | number\n): VNode {\n recordBenchEvent('rowFactory');\n const vnode = scope.render(() => forState.renderFn(item, indexSignal));\n materializeItemVnode(key, vnode);\n return vnode;\n}\n\nfunction failForValidation(message: string): never {\n throw new Error(message);\n}\n\nfunction validateForKeys<T>(forState: ForState<T>, newArray: T[]): void {\n if (!isDevelopmentEnvironment()) {\n return;\n }\n\n const seen = new Set<string | number>();\n const keyKinds = new Map<string, 'number' | 'string'>();\n for (let i = 0; i < newArray.length; i++) {\n const key = forState.byFn(newArray[i], i);\n\n if (key === null || key === undefined) {\n failForValidation(\n '[askr] Invalid For key detected. Keys should be stable, non-null, and unique within a For list.'\n );\n }\n\n if (seen.has(key)) {\n failForValidation(\n `[askr] Duplicate For key detected: ${String(key)}. Keys should be stable, non-null, and unique within a For list.`\n );\n }\n\n seen.add(key);\n\n const keyString = String(key);\n const keyKind = typeof key;\n const previousKeyKind = forState.devKeyKinds?.get(keyString);\n if (previousKeyKind && previousKeyKind !== keyKind) {\n failForValidation(\n `[askr] For key type changed for ${keyString}. Keys must remain consistently typed across renders.`\n );\n }\n keyKinds.set(keyString, keyKind as 'number' | 'string');\n }\n\n forState.devKeyKinds = keyKinds;\n}\n\ntype RemovedDomCleanupMode = 'none' | 'teardown' | 'full-clear';\n\nfunction disposeItemInstance<T>(\n forState: ForState<T>,\n itemInstance: ForItemInstance<T>,\n domCleanup: RemovedDomCleanupMode\n): void {\n recordBenchEvent('itemRemoved');\n const removedDom = itemInstance.scope.dom;\n\n try {\n disposeChildScope(itemInstance.scope);\n } catch (err) {\n if (isDevelopmentEnvironment()) {\n console.error('[For] Cleanup error:', err);\n }\n }\n\n if (!removedDom) {\n return;\n }\n\n if (removedDom instanceof Element) {\n if (domCleanup === 'teardown') {\n teardownNodeSubtree(removedDom);\n }\n }\n\n forState.lastRemovedNodes.push(removedDom);\n}\n\nexport function createItemInstance<T>(\n key: string | number,\n item: T,\n index: number,\n forState: ForState<T>\n): ForItemInstance<T> {\n recordBenchEvent('itemCreated');\n\n // Create index signal manually without going through state() hook\n // to avoid hook order violations (each For item creates its signal dynamically)\n const indexSignal = createForIndexSignal(index);\n const itemSignal = canProxyForItem(item) ? createForItemSignal(item) : null;\n const itemPropertySignals = itemSignal\n ? new Map<PropertyKey, ForItemPropertySignal>()\n : null;\n const reactiveItem =\n itemSignal && itemPropertySignals\n ? createReactiveForItem(itemSignal, itemPropertySignals)\n : item;\n const scope = createChildScope(forState.parentInstance, key, () => {\n if (forState._enqueueBoundaryCommit) {\n forState._enqueueBoundaryCommit();\n return;\n }\n\n const parent = forState.parentInstance;\n if (parent) {\n parent._enqueueRun?.();\n }\n });\n\n renderItemScope(forState, scope, reactiveItem, indexSignal, key);\n\n const itemInstance: ForItemInstance<T> = {\n key,\n item,\n reactiveItem,\n itemSignal,\n itemPropertySignals,\n indexSignal,\n scope,\n };\n\n return itemInstance;\n}\n\nfunction rerenderItemInstance<T>(\n forState: ForState<T>,\n itemInstance: ForItemInstance<T>,\n item: T\n): void {\n renderItemScope(\n forState,\n itemInstance.scope,\n item,\n itemInstance.indexSignal,\n itemInstance.key\n );\n}\n\nfunction updateItemInstance<T>(\n forState: ForState<T>,\n itemInstance: ForItemInstance<T>,\n item: T\n): boolean {\n if (itemInstance.item === item) {\n return false;\n }\n\n const previousItem = itemInstance.item;\n itemInstance.item = item;\n\n const itemSignal = itemInstance.itemSignal;\n if (!itemSignal) {\n rerenderItemInstance(forState, itemInstance, item);\n return true;\n }\n\n let hasPropertyRenderReaders = false;\n const propertySignals = itemInstance.itemPropertySignals;\n if (propertySignals && propertySignals.size > 0) {\n for (const [prop, propertySignal] of propertySignals) {\n const previousValue = readForItemProperty(previousItem, prop);\n const nextValue = readForItemProperty(item, prop);\n if (Object.is(previousValue, nextValue)) {\n continue;\n }\n\n const propertyHasRenderReaders = (propertySignal._readers?.size ?? 0) > 0;\n if (propertyHasRenderReaders) {\n hasPropertyRenderReaders = true;\n }\n\n propertySignal.set(nextValue, !propertyHasRenderReaders);\n }\n }\n\n const hasRenderReaders = (itemSignal._readers?.size ?? 0) > 0;\n itemSignal.set(item, hasRenderReaders);\n\n if (!hasRenderReaders && !hasPropertyRenderReaders) {\n return false;\n }\n\n rerenderItemInstance(forState, itemInstance, itemInstance.reactiveItem);\n return true;\n}\n\nconst FOR_FALLBACK_SCOPE_KEY = '__for-fallback__';\n\nfunction disposeFallbackScope<T>(\n forState: ForState<T>,\n domCleanup: RemovedDomCleanupMode\n): void {\n const fallbackScope = forState.fallbackScope;\n if (!fallbackScope) {\n return;\n }\n\n const removedDom = fallbackScope.dom;\n disposeChildScope(fallbackScope);\n forState.fallbackScope = null;\n\n if (!removedDom) {\n return;\n }\n\n if (removedDom instanceof Element) {\n if (domCleanup === 'teardown') {\n teardownNodeSubtree(removedDom);\n }\n }\n\n forState.lastRemovedNodes.push(removedDom);\n}\n\nfunction renderFallbackScope<T>(forState: ForState<T>): VNode[] {\n if (forState.fallback == null || forState.fallback === false) {\n if (forState.fallbackScope) {\n disposeFallbackScope(forState, 'none');\n }\n forState.orderedVNodes = [];\n return [];\n }\n\n const fallbackScope =\n forState.fallbackScope ??\n createChildScope(forState.parentInstance, FOR_FALLBACK_SCOPE_KEY, () => {\n if (forState._enqueueBoundaryCommit) {\n forState._enqueueBoundaryCommit();\n return;\n }\n\n forState.parentInstance?._enqueueRun?.();\n });\n forState.fallbackScope = fallbackScope;\n\n const vnode = fallbackScope.render(() => forState.fallback as VNode);\n forState.orderedVNodes = vnode == null || vnode === false ? [] : [vnode];\n return forState.orderedVNodes;\n}\n\nfunction disposeAllItems<T>(\n forState: ForState<T>,\n domCleanup: RemovedDomCleanupMode\n): void {\n const { items, orderedKeys } = forState;\n for (let index = 0; index < orderedKeys.length; index += 1) {\n const key = orderedKeys[index];\n const itemInstance = items.get(key);\n if (!itemInstance) {\n continue;\n }\n disposeItemInstance(forState, itemInstance, domCleanup);\n items.delete(key);\n }\n orderedKeys.length = 0;\n forState.orderedKeys = orderedKeys;\n}\n\nexport function reconcileForItems<T>(\n forState: ForState<T>,\n newArray: T[]\n): VNode[] {\n forState.currentItems = newArray;\n validateForKeys(forState, newArray);\n\n if (BENCH_BUILD_ENABLED) {\n resetBenchMetrics();\n }\n\n const reconcileStartMs = BENCH_BUILD_ENABLED ? performance.now() : 0;\n\n const { items, orderedKeys, byFn } = forState;\n const oldLen = orderedKeys.length;\n const newLen = newArray.length;\n forState.lastRemovedNodes = [];\n\n if (newLen === 0) {\n if (oldLen > 0) {\n disposeAllItems(forState, forState.fallback ? 'teardown' : 'none');\n }\n recordBenchFastLane('TRUNCATE');\n forState.lastCommitStrategy = 'TRUNCATE';\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n return renderFallbackScope(forState);\n }\n\n if (forState.fallbackScope) {\n disposeFallbackScope(forState, 'none');\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // FAST PATH A: APPEND\n // Guard: oldLen <= newLen && all old keys match new keys at same indices\n // ─────────────────────────────────────────────────────────────────────────\n if (oldLen < newLen) {\n let canUseAppendPath = true;\n for (let i = 0; i < oldLen; i++) {\n const key = byFn(newArray[i], i);\n if (key !== orderedKeys[i]) {\n canUseAppendPath = false;\n break;\n }\n }\n\n if (canUseAppendPath) {\n recordBenchFastLane('APPEND');\n forState.lastCommitStrategy = 'APPEND';\n const resultVNodes = forState.orderedVNodes;\n resultVNodes.length = newLen;\n\n // Update existing rows in-place\n for (let i = 0; i < oldLen; i++) {\n const item = newArray[i];\n const key = orderedKeys[i];\n const existing = items.get(key)!;\n recordBenchEvent('itemReused');\n\n updateItemInstance(forState, existing, item);\n\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n // Create and append new rows\n for (let i = oldLen; i < newLen; i++) {\n const item = newArray[i];\n const key = byFn(item, i);\n const itemInstance = createItemInstance(key, item, i, forState);\n items.set(key, itemInstance);\n resultVNodes[i] = itemInstance.scope.vnode as VNode;\n orderedKeys[i] = key;\n }\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.orderedVNodes = resultVNodes;\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n return resultVNodes;\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // FAST PATH B: TRUNCATE\n // Guard: newLen <= oldLen && all new keys match old keys at same indices\n // ─────────────────────────────────────────────────────────────────────────\n if (newLen < oldLen) {\n if (oldLen === newLen + 1) {\n let removedIndex = -1;\n\n for (let i = 0; i < newLen; i++) {\n const nextKey = byFn(newArray[i], i);\n if (nextKey !== orderedKeys[i]) {\n removedIndex = i;\n break;\n }\n }\n\n if (removedIndex !== -1) {\n let canUseRemoveOnePath = true;\n for (let i = removedIndex; i < newLen; i++) {\n const nextKey = byFn(newArray[i], i);\n if (nextKey !== orderedKeys[i + 1]) {\n canUseRemoveOnePath = false;\n break;\n }\n }\n\n if (canUseRemoveOnePath) {\n recordBenchFastLane('REMOVE_ONE');\n forState.lastCommitStrategy = 'NO_REORDER';\n\n const resultVNodes = forState.orderedVNodes;\n resultVNodes.length = newLen;\n const dirtyIndices: number[] = [];\n\n for (let i = 0; i < newLen; i++) {\n const item = newArray[i];\n const key = i < removedIndex ? orderedKeys[i] : orderedKeys[i + 1];\n const existing = items.get(key)!;\n recordBenchEvent('itemReused');\n\n const itemChanged = existing.item !== item;\n const needsDomUpdate = existing.scope.needsDomUpdate;\n const indexChanged = existing.indexSignal.peek() !== i;\n\n if (itemChanged) {\n updateItemInstance(forState, existing, item);\n }\n\n if (indexChanged && existing.indexSignal._hasBeenRead) {\n existing.indexSignal.set(i);\n }\n\n if (\n itemChanged ||\n indexChanged ||\n needsDomUpdate ||\n existing.scope.needsDomUpdate\n ) {\n dirtyIndices.push(i);\n }\n\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n const removedKey = orderedKeys[removedIndex];\n const removedItem = items.get(removedKey);\n if (removedItem) {\n disposeItemInstance(forState, removedItem, 'teardown');\n items.delete(removedKey);\n }\n\n const nextOrderedKeys = orderedKeys.slice(0, newLen);\n for (let i = removedIndex; i < newLen; i++) {\n nextOrderedKeys[i] = orderedKeys[i + 1];\n }\n forState.orderedKeys = nextOrderedKeys;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming(\n 'reconcile',\n performance.now() - reconcileStartMs\n );\n flushBenchMetrics();\n }\n\n forState.pendingDirtyIndices = dirtyIndices;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n return resultVNodes;\n }\n }\n }\n\n let canUseTruncatePath = true;\n for (let i = 0; i < newLen; i++) {\n const key = byFn(newArray[i], i);\n if (key !== orderedKeys[i]) {\n canUseTruncatePath = false;\n break;\n }\n }\n\n if (canUseTruncatePath) {\n recordBenchFastLane('TRUNCATE');\n forState.lastCommitStrategy = 'TRUNCATE';\n const resultVNodes = forState.orderedVNodes;\n resultVNodes.length = newLen;\n const isFullClear = newLen === 0;\n\n // Update existing rows in-place\n for (let i = 0; i < newLen; i++) {\n const item = newArray[i];\n const key = orderedKeys[i];\n const existing = items.get(key)!;\n recordBenchEvent('itemReused');\n\n updateItemInstance(forState, existing, item);\n\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n // Remove tail rows\n for (let i = newLen; i < oldLen; i++) {\n const key = orderedKeys[i];\n const itemInstance = items.get(key);\n if (itemInstance) {\n disposeItemInstance(\n forState,\n itemInstance,\n isFullClear ? 'full-clear' : 'teardown'\n );\n items.delete(key);\n }\n }\n\n orderedKeys.length = newLen;\n forState.orderedKeys = orderedKeys;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.orderedVNodes = resultVNodes;\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n return resultVNodes;\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // FAST PATH C: NO-REORDER (in-place update only)\n // Guard: oldLen === newLen && keys match at all indices\n // ─────────────────────────────────────────────────────────────────────────\n if (oldLen === newLen) {\n let canUseNoReorderPath = true;\n for (let i = 0; i < oldLen; i++) {\n const key = byFn(newArray[i], i);\n if (key !== orderedKeys[i]) {\n canUseNoReorderPath = false;\n break;\n }\n }\n\n if (canUseNoReorderPath) {\n recordBenchFastLane('NO_REORDER');\n forState.lastCommitStrategy = 'NO_REORDER';\n const resultVNodes = forState.orderedVNodes;\n resultVNodes.length = oldLen;\n const dirtyIndices: number[] = [];\n\n // Update in-place only, no DOM moves needed\n for (let i = 0; i < oldLen; i++) {\n const item = newArray[i];\n const key = orderedKeys[i];\n const existing = items.get(key)!;\n recordBenchEvent('itemReused');\n\n const itemChanged = existing.item !== item;\n const needsDomUpdate = existing.scope.needsDomUpdate;\n let rerendered = false;\n\n if (itemChanged) {\n rerendered = updateItemInstance(forState, existing, item);\n }\n\n if (rerendered || needsDomUpdate || existing.scope.needsDomUpdate) {\n dirtyIndices.push(i);\n }\n\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.pendingDirtyIndices = dirtyIndices;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n return resultVNodes;\n }\n\n let firstMismatch = -1;\n let secondMismatch = -1;\n let firstMismatchKey: string | number | null = null;\n let secondMismatchKey: string | number | null = null;\n let mismatchCount = 0;\n let canUseSwapPath = true;\n\n for (let i = 0; i < oldLen; i++) {\n const item = newArray[i];\n const key = byFn(newArray[i], i);\n if (key === orderedKeys[i]) {\n const existing = items.get(key);\n if (existing && existing.item !== item) {\n canUseSwapPath = false;\n break;\n }\n continue;\n }\n\n mismatchCount++;\n if (firstMismatch === -1) {\n firstMismatch = i;\n firstMismatchKey = key;\n continue;\n }\n\n if (secondMismatch === -1) {\n secondMismatch = i;\n secondMismatchKey = key;\n continue;\n }\n\n mismatchCount = 3;\n break;\n }\n\n if (\n canUseSwapPath &&\n mismatchCount === 2 &&\n firstMismatch !== -1 &&\n secondMismatch !== -1 &&\n firstMismatchKey === orderedKeys[secondMismatch] &&\n secondMismatchKey === orderedKeys[firstMismatch]\n ) {\n recordBenchFastLane('SWAP');\n recordBenchEvent('itemMoved');\n recordBenchEvent('itemMoved');\n\n forState.lastCommitStrategy = 'SWAP';\n\n const nextOrderedKeys = orderedKeys.slice();\n nextOrderedKeys[firstMismatch] = firstMismatchKey;\n nextOrderedKeys[secondMismatch] = secondMismatchKey;\n\n const resultVNodes = forState.orderedVNodes;\n const firstExisting = items.get(firstMismatchKey)!;\n const secondExisting = items.get(secondMismatchKey)!;\n const firstItem = newArray[firstMismatch];\n const secondItem = newArray[secondMismatch];\n\n recordBenchEvent('itemReused');\n recordBenchEvent('itemReused');\n\n if (firstExisting.item !== firstItem) {\n updateItemInstance(forState, firstExisting, firstItem);\n }\n\n if (secondExisting.item !== secondItem) {\n updateItemInstance(forState, secondExisting, secondItem);\n }\n\n if (\n firstExisting.indexSignal._hasBeenRead &&\n firstExisting.indexSignal.peek() !== firstMismatch\n ) {\n firstExisting.indexSignal.set(firstMismatch);\n }\n\n if (\n secondExisting.indexSignal._hasBeenRead &&\n secondExisting.indexSignal.peek() !== secondMismatch\n ) {\n secondExisting.indexSignal.set(secondMismatch);\n }\n\n resultVNodes[firstMismatch] = firstExisting.scope.vnode as VNode;\n resultVNodes[secondMismatch] = secondExisting.scope.vnode as VNode;\n\n forState.orderedKeys = nextOrderedKeys;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = [firstMismatch, secondMismatch];\n forState.pendingMoveOnly = true;\n\n return resultVNodes;\n }\n\n let canUseMoveOnlyPath = true;\n const moveOnlyKeys: Array<string | number> = [];\n const moveOnlyVNodes: VNode[] = [];\n\n for (let i = 0; i < oldLen; i++) {\n const item = newArray[i];\n const key = byFn(item, i);\n const existing = items.get(key);\n\n if (\n !existing ||\n existing.item !== item ||\n (existing.indexSignal._hasBeenRead && existing.indexSignal.peek() !== i)\n ) {\n canUseMoveOnlyPath = false;\n break;\n }\n\n moveOnlyKeys[i] = key;\n moveOnlyVNodes[i] = existing.scope.vnode as VNode;\n recordBenchEvent('itemReused');\n }\n\n if (canUseMoveOnlyPath) {\n recordBenchFastLane('FULL_KEYED');\n forState.lastCommitStrategy = 'FULL_KEYED';\n forState.orderedKeys = moveOnlyKeys;\n forState.orderedVNodes = moveOnlyVNodes;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = true;\n\n return moveOnlyVNodes;\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // FULL KEYED RECONCILIATION (slow path for complex reorders)\n // Avoid allocating newKeyMap: iterate directly and track removals\n // ─────────────────────────────────────────────────────────────────────────\n recordBenchFastLane('FULL_KEYED');\n forState.lastCommitStrategy = 'FULL_KEYED';\n\n const toRemove = new Set(orderedKeys);\n const newOrderedKeys: Array<string | number> = [];\n const resultVNodes: VNode[] = [];\n let moveOnly = toRemove.size === newArray.length;\n\n // Single pass: iterate new array directly, no intermediate map\n for (let i = 0; i < newArray.length; i++) {\n const item = newArray[i];\n const key = byFn(item, i);\n recordBenchEvent('keyLookup');\n\n toRemove.delete(key);\n newOrderedKeys.push(key);\n\n const existing = items.get(key);\n recordBenchEvent(existing ? 'keyHit' : 'keyMiss');\n\n if (!existing) {\n // Added: create new item instance\n const itemInstance = createItemInstance(key, item, i, forState);\n items.set(key, itemInstance);\n resultVNodes.push(itemInstance.scope.vnode as VNode);\n } else {\n // Exists: check if item changed (by identity)\n recordBenchEvent('itemReused');\n const itemChanged = existing.item !== item;\n const indexChanged =\n existing.indexSignal._hasBeenRead && existing.indexSignal.peek() !== i;\n\n if (itemChanged) {\n moveOnly = false;\n updateItemInstance(forState, existing, item);\n }\n\n if (indexChanged) {\n // Index changed: update index signal (triggers re-render if index is used)\n existing.indexSignal.set(i);\n }\n\n resultVNodes.push(existing.scope.vnode as VNode);\n }\n }\n\n // Remove deleted items\n for (const key of toRemove) {\n moveOnly = false;\n const itemInstance = items.get(key);\n if (itemInstance) {\n disposeItemInstance(forState, itemInstance, 'none');\n items.delete(key);\n }\n }\n\n forState.orderedKeys = newOrderedKeys;\n\n // Record reconcile timing\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.orderedVNodes = resultVNodes;\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = moveOnly;\n\n return resultVNodes;\n}\n\nexport function evaluateForState<T>(forState: ForState<T>): VNode[] {\n if (!Array.isArray(forState.currentItems)) {\n throw new Error('For source must evaluate to an array');\n }\n\n forState._needsSourceReconcile = false;\n return reconcileForItems(forState, forState.currentItems);\n}\n\nexport function clearForDomUpdateState<T>(forState: ForState<T>): void {\n for (let i = 0; i < forState.orderedKeys.length; i++) {\n const key = forState.orderedKeys[i];\n const itemInstance = forState.items.get(key);\n if (itemInstance) {\n itemInstance.scope.needsDomUpdate = false;\n }\n }\n if (forState.fallbackScope) {\n forState.fallbackScope.needsDomUpdate = false;\n }\n forState.lastRemovedNodes = [];\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n forState._needsSourceReconcile = false;\n}\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAAM,sBAAsB,qBAAqB;AAyEjD,MAAM,4BAAY,IAAI,SAGnB;AAEH,SAAS,YACP,UACgC;CAChC,IAAI,QAAQ,UAAU,IAAI,SAAS;AACnC,KAAI,CAAC,OAAO;AACV,0BAAQ,IAAI,KAAK;AACjB,YAAU,IAAI,UAAU,MAAM;;AAEhC,QAAO;;AAGT,SAAgB,eACd,YACA,MACA,UACA,UACa;CACb,MAAM,iBAAiB,oBAAoB;AAE3C,QAAO;EACL,MAAM;EACN,cAAc,EAAE;EAChB;EACA;EACA,eAAe;EACf,uBAAO,IAAI,KAAK;EAChB,aAAa,EAAE;EACf,eAAe,EAAE;EACjB;EACA;EACA;EACA,oBAAoB;EACpB,kBAAkB,EAAE;EACpB,qBAAqB;EACrB,oBAAoB;EACpB,iBAAiB;EACjB,qBAAqB;EACrB,uBAAuB;EACvB,eAAe;EACf,sBAAsB;EACtB,wBAAwB;EACxB,2BAA2B;EAC5B;;AAGH,SAAgB,YACd,YACA,MACA,UACA,UACa;CACb,MAAM,WAAW,oBAAoB;AACrC,KAAI,CAAC,SACH,OAAM,IAAI,MACR,6DACD;CAGH,MAAM,YAAY,eAAe,UAAU,MAAM;CACjD,MAAM,QAAQ,YAAY,SAAS;CACnC,MAAM,WAAW,MAAM,IAAI,UAAU;AAErC,KAAI,UAAU;AACZ,WAAS,aAAa;AACtB,WAAS,OAAO;AAChB,WAAS,WAAW;AACpB,WAAS,WAAW;AACpB,SAAO;;CAGT,MAAM,UAAU,eAAe,YAAY,MAAM,UAAU,SAAS;AACpE,OAAM,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AS,aAAa;;AAG3D,SAAgB,uBAA0B,UAA6B;AACrE,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,YAAY,QAAQ,KAAK;EACpD,MAAM,MAAM,SAAS,YAAY;EACjC,MAAM,eAAe,SAAS,MAAM,IAAI,IAAI;AAC5C,MAAI,aACF,cAAa,MAAM,iBAAiB;;AAGxC,KAAI,SAAS,cACX,UAAS,cAAc,iBAAiB;AAE1C,UAAS,mBAAmB,EAAE;AAC9B,UAAS,sBAAsB;AAC/B,UAAS,qBAAqB;AAC9B,UAAS,kBAAkB;AAC3B,UAAS,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"for.js","names":[],"sources":["../../src/runtime/for.ts"],"sourcesContent":["/**\n * For primitive runtime\n *\n * Manages per-item component instances and array reconciliation\n * to eliminate over-invalidation in list rendering.\n */\n\nimport { type ComponentInstance, getCurrentInstance } from './component';\nimport { claimHookIndex } from './component';\nimport { type DOMElement, type VNode } from '../common/vnode';\nimport { isDevelopmentEnvironment } from '../common/env';\nimport { teardownNodeSubtree } from '../renderer/cleanup';\nimport {\n createChildScope,\n disposeChildScope,\n type ChildScope,\n} from './child-scope';\nimport type { ForProps } from '../control/for';\nimport type { ForEachSource } from '../control/for';\nimport {\n markReactivePropsDirtySource,\n markReadableDerivedSubscribersDirty,\n notifyReadableReaders,\n recordReadableRead,\n type ReadableSource,\n} from './readable';\nimport type { FineGrainedEffectHandle } from './effect';\nimport {\n flushBenchMetrics,\n getBenchMetrics,\n isBenchBuildEnabled,\n isBenchMetricScopeActive,\n recordBenchEvent,\n recordBenchCounter,\n recordBenchFastLane,\n recordBenchTiming,\n resetBenchMetrics,\n withBenchMetricScope,\n} from './for-bench';\n\nconst BENCH_BUILD_ENABLED = isBenchBuildEnabled();\n\nexport {\n getBenchMetrics,\n isBenchMetricScopeActive,\n recordBenchEvent,\n recordBenchCounter,\n recordBenchTiming,\n resetBenchMetrics,\n withBenchMetricScope,\n};\n\nexport interface ForItemInstance<T> {\n key: string | number;\n item: T;\n reactiveItem: T;\n itemSignal: ForItemSignal<T> | null;\n itemPropertySignals: Map<PropertyKey, ForItemPropertySignal> | null;\n indexSignal: ForIndexSignal;\n scope: ChildScope;\n}\n\ntype ForItemSignal<T> = ReadableSource<T> &\n (() => T) & {\n peek(): T;\n set(newValue: T, notifyReaders?: boolean): void;\n };\n\ntype ForItemPropertySignal = ReadableSource<unknown> &\n (() => unknown) & {\n peek(): unknown;\n set(newValue: unknown, notifyReaders?: boolean): void;\n };\n\ntype ForIndexSignal = ReadableSource<number> &\n (() => number) & {\n peek(): number;\n set(newValue: number | ((prev: number) => number)): void;\n };\n\nexport type ForCommitStrategy =\n | 'APPEND'\n | 'TRUNCATE'\n | 'NO_REORDER'\n | 'SWAP'\n | 'FULL_KEYED';\n\nexport interface ForState<T> {\n kind: 'for';\n currentItems: T[];\n eachSource: ForEachSource<T>;\n fallback: VNode | null;\n fallbackScope: ChildScope | null;\n items: Map<string | number, ForItemInstance<T>>;\n orderedKeys: Array<string | number>;\n orderedVNodes: VNode[];\n byFn: NonNullable<ForProps<T>['by']> | ((item: T, index: number) => number);\n renderFn: (item: T, index: () => number) => VNode;\n parentInstance: ComponentInstance | null;\n lastCommitStrategy: ForCommitStrategy;\n lastRemovedNodes: Node[];\n pendingDirtyIndices: number[] | null;\n pendingSwapIndices: [number, number] | null;\n pendingMoveOnly: boolean;\n _hasResolvedItemDom: boolean;\n _needsSourceReconcile: boolean;\n _sourceEffect: FineGrainedEffectHandle<T[]> | null;\n _suspendSourceCommit: boolean;\n _enqueueBoundaryCommit?: (() => void) | null;\n _hasPendingBoundaryCommit?: boolean;\n devKeyKinds?: Map<string, 'number' | 'string'>;\n}\n\nconst forStates = new WeakMap<\n ComponentInstance,\n Map<number, ForState<unknown>>\n>();\n\nfunction getForStore(\n instance: ComponentInstance\n): Map<number, ForState<unknown>> {\n let store = forStates.get(instance);\n if (!store) {\n store = new Map();\n forStates.set(instance, store);\n }\n return store;\n}\n\nexport function createForState<T>(\n eachSource: ForEachSource<T>,\n byFn: ForState<T>['byFn'],\n renderFn: (item: T, index: () => number) => VNode,\n fallback: VNode | null\n): ForState<T> {\n const parentInstance = getCurrentInstance();\n\n return {\n kind: 'for',\n currentItems: [],\n eachSource,\n fallback,\n fallbackScope: null,\n items: new Map(),\n orderedKeys: [],\n orderedVNodes: [],\n byFn,\n renderFn,\n parentInstance,\n lastCommitStrategy: 'NO_REORDER',\n lastRemovedNodes: [],\n pendingDirtyIndices: null,\n pendingSwapIndices: null,\n pendingMoveOnly: false,\n _hasResolvedItemDom: false,\n _needsSourceReconcile: false,\n _sourceEffect: null,\n _suspendSourceCommit: false,\n _enqueueBoundaryCommit: null,\n _hasPendingBoundaryCommit: false,\n };\n}\n\nexport function useForState<T>(\n eachSource: ForEachSource<T>,\n byFn: ForState<T>['byFn'],\n renderFn: (item: T, index: () => number) => VNode,\n fallback: VNode | null\n): ForState<T> {\n const instance = getCurrentInstance();\n if (!instance) {\n throw new Error(\n 'For can only be created during component render execution.'\n );\n }\n\n const hookIndex = claimHookIndex(instance, 'For');\n const store = getForStore(instance);\n const existing = store.get(hookIndex) as ForState<T> | undefined;\n\n if (existing) {\n existing.eachSource = eachSource;\n existing.byFn = byFn;\n existing.renderFn = renderFn;\n existing.fallback = fallback;\n return existing;\n }\n\n const created = createForState(eachSource, byFn, renderFn, fallback);\n store.set(hookIndex, created as ForState<unknown>);\n\n (instance.cleanupFns ??= []).push(() => {\n created._sourceEffect?.cleanup();\n created._sourceEffect = null;\n store.delete(hookIndex);\n });\n\n return created;\n}\n\nfunction createForIndexSignal(initialIndex: number): ForIndexSignal {\n let indexValue = initialIndex;\n const readers = new Map<ComponentInstance, number>();\n\n const indexSignal = (() => {\n indexSignal._hasBeenRead = true;\n recordReadableRead(indexSignal);\n return indexValue;\n }) as ForIndexSignal;\n indexSignal._readers = readers;\n indexSignal.peek = () => indexValue;\n indexSignal.set = (newValue: number | ((prev: number) => number)) => {\n const nextValue =\n typeof newValue === 'function' ? newValue(indexValue) : newValue;\n if (nextValue !== indexValue) {\n indexValue = nextValue;\n markReadableDerivedSubscribersDirty(indexSignal);\n markReactivePropsDirtySource(indexSignal);\n notifyReadableReaders(indexSignal);\n }\n };\n indexSignal._hasBeenRead = false;\n\n return indexSignal;\n}\n\nfunction createForItemSignal<T>(initialItem: T): ForItemSignal<T> {\n let itemValue = initialItem;\n const readers = new Map<ComponentInstance, number>();\n\n const itemSignal = (() => {\n itemSignal._hasBeenRead = true;\n recordReadableRead(itemSignal);\n return itemValue;\n }) as ForItemSignal<T>;\n\n itemSignal._readers = readers;\n itemSignal.peek = () => itemValue;\n itemSignal.set = (newValue: T, notifyReaders = true) => {\n if (Object.is(itemValue, newValue)) {\n return;\n }\n\n itemValue = newValue;\n markReadableDerivedSubscribersDirty(itemSignal);\n markReactivePropsDirtySource(itemSignal);\n\n if (notifyReaders) {\n notifyReadableReaders(itemSignal);\n }\n };\n itemSignal._hasBeenRead = false;\n\n return itemSignal;\n}\n\nfunction createForItemPropertySignal(\n initialValue: unknown\n): ForItemPropertySignal {\n let propertyValue = initialValue;\n const readers = new Map<ComponentInstance, number>();\n\n const propertySignal = (() => {\n propertySignal._hasBeenRead = true;\n recordReadableRead(propertySignal);\n return propertyValue;\n }) as ForItemPropertySignal;\n\n propertySignal._readers = readers;\n propertySignal.peek = () => propertyValue;\n propertySignal.set = (newValue: unknown, notifyReaders = true) => {\n if (Object.is(propertyValue, newValue)) {\n return;\n }\n\n propertyValue = newValue;\n markReadableDerivedSubscribersDirty(propertySignal);\n markReactivePropsDirtySource(propertySignal);\n\n if (notifyReaders) {\n notifyReadableReaders(propertySignal);\n }\n };\n propertySignal._hasBeenRead = false;\n\n return propertySignal;\n}\n\nfunction readForItemProperty(item: unknown, prop: PropertyKey): unknown {\n return Reflect.get(Object(item), prop);\n}\n\nfunction getOrCreateForItemPropertySignal<T>(\n item: T,\n propertySignals: Map<PropertyKey, ForItemPropertySignal>,\n prop: PropertyKey\n): ForItemPropertySignal {\n const existingSignal = propertySignals.get(prop);\n if (existingSignal) {\n return existingSignal;\n }\n\n const propertySignal = createForItemPropertySignal(\n readForItemProperty(item, prop)\n );\n propertySignals.set(prop, propertySignal);\n return propertySignal;\n}\n\nfunction canProxyForItem(item: unknown): item is object {\n return (\n (typeof item === 'object' && item !== null) || typeof item === 'function'\n );\n}\n\nfunction createReactiveForItem<T>(\n itemSignal: ForItemSignal<T>,\n propertySignals: Map<PropertyKey, ForItemPropertySignal>\n): T {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n\n return new Proxy(target, {\n get(target, prop, receiver) {\n const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, prop);\n if (ownDescriptor) {\n return Reflect.get(target, prop, receiver);\n }\n\n const currentItem = itemSignal.peek();\n\n if (typeof prop !== 'symbol') {\n return getOrCreateForItemPropertySignal(\n currentItem,\n propertySignals,\n prop\n )();\n }\n\n recordReadableRead(itemSignal);\n return Reflect.get(Object(currentItem), prop, receiver);\n },\n has(target, prop) {\n recordReadableRead(itemSignal);\n return prop in target || prop in Object(itemSignal.peek());\n },\n ownKeys(target) {\n recordReadableRead(itemSignal);\n const keys = new Set<string | symbol>(Reflect.ownKeys(target));\n for (const key of Reflect.ownKeys(Object(itemSignal.peek()))) {\n keys.add(key);\n }\n\n return Array.from(keys);\n },\n getOwnPropertyDescriptor(target, prop) {\n recordReadableRead(itemSignal);\n const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, prop);\n if (ownDescriptor) {\n return ownDescriptor;\n }\n\n return Object.getOwnPropertyDescriptor(Object(itemSignal.peek()), prop);\n },\n getPrototypeOf() {\n recordReadableRead(itemSignal);\n return Object.getPrototypeOf(Object(itemSignal.peek()));\n },\n }) as T;\n}\n\nfunction materializeItemVnode(\n key: string | number,\n vnode: VNode | undefined\n): void {\n if (vnode && typeof vnode === 'object' && 'type' in vnode) {\n const vn = vnode as DOMElement;\n vn.key = key;\n\n if (typeof vn.type === 'string') {\n if (!vn.props) vn.props = {};\n if (vn.props['data-key'] === undefined) {\n vn.props['data-key'] = String(key);\n }\n }\n }\n}\n\nfunction renderItemScope<T>(\n forState: ForState<T>,\n scope: ChildScope,\n item: T,\n indexSignal: ForIndexSignal,\n key: string | number\n): VNode {\n recordBenchEvent('rowFactory');\n const vnode = scope.render(() => forState.renderFn(item, indexSignal));\n materializeItemVnode(key, vnode);\n return vnode;\n}\n\nfunction failForValidation(message: string): never {\n throw new Error(message);\n}\n\nfunction validateForKeys<T>(forState: ForState<T>, newArray: T[]): void {\n if (!isDevelopmentEnvironment()) {\n return;\n }\n\n const seen = new Set<string | number>();\n const keyKinds = new Map<string, 'number' | 'string'>();\n for (let i = 0; i < newArray.length; i++) {\n const key = forState.byFn(newArray[i], i);\n\n if (key === null || key === undefined) {\n failForValidation(\n '[askr] Invalid For key detected. Keys should be stable, non-null, and unique within a For list.'\n );\n }\n\n if (seen.has(key)) {\n failForValidation(\n `[askr] Duplicate For key detected: ${String(key)}. Keys should be stable, non-null, and unique within a For list.`\n );\n }\n\n seen.add(key);\n\n const keyString = String(key);\n const keyKind = typeof key;\n const previousKeyKind = forState.devKeyKinds?.get(keyString);\n if (previousKeyKind && previousKeyKind !== keyKind) {\n failForValidation(\n `[askr] For key type changed for ${keyString}. Keys must remain consistently typed across renders.`\n );\n }\n keyKinds.set(keyString, keyKind as 'number' | 'string');\n }\n\n forState.devKeyKinds = keyKinds;\n}\n\ntype RemovedDomCleanupMode = 'none' | 'teardown' | 'full-clear';\n\nfunction disposeItemInstance<T>(\n forState: ForState<T>,\n itemInstance: ForItemInstance<T>,\n domCleanup: RemovedDomCleanupMode\n): void {\n recordBenchEvent('itemRemoved');\n const removedDom = itemInstance.scope.dom;\n\n try {\n disposeChildScope(itemInstance.scope);\n } catch (err) {\n if (isDevelopmentEnvironment()) {\n console.error('[For] Cleanup error:', err);\n }\n }\n\n if (!removedDom) {\n return;\n }\n\n if (removedDom instanceof Element) {\n if (domCleanup === 'teardown') {\n teardownNodeSubtree(removedDom);\n }\n }\n\n forState.lastRemovedNodes.push(removedDom);\n}\n\nexport function createItemInstance<T>(\n key: string | number,\n item: T,\n index: number,\n forState: ForState<T>\n): ForItemInstance<T> {\n recordBenchEvent('itemCreated');\n\n // Create index signal manually without going through state() hook\n // to avoid hook order violations (each For item creates its signal dynamically)\n const indexSignal = createForIndexSignal(index);\n const itemSignal = canProxyForItem(item) ? createForItemSignal(item) : null;\n const itemPropertySignals = itemSignal\n ? new Map<PropertyKey, ForItemPropertySignal>()\n : null;\n const reactiveItem =\n itemSignal && itemPropertySignals\n ? createReactiveForItem(itemSignal, itemPropertySignals)\n : item;\n const scope = createChildScope(forState.parentInstance, key, () => {\n if (forState._enqueueBoundaryCommit) {\n forState._enqueueBoundaryCommit();\n return;\n }\n\n const parent = forState.parentInstance;\n if (parent) {\n parent._enqueueRun?.();\n }\n });\n\n renderItemScope(forState, scope, reactiveItem, indexSignal, key);\n\n const itemInstance: ForItemInstance<T> = {\n key,\n item,\n reactiveItem,\n itemSignal,\n itemPropertySignals,\n indexSignal,\n scope,\n };\n\n return itemInstance;\n}\n\nfunction rerenderItemInstance<T>(\n forState: ForState<T>,\n itemInstance: ForItemInstance<T>,\n item: T\n): void {\n renderItemScope(\n forState,\n itemInstance.scope,\n item,\n itemInstance.indexSignal,\n itemInstance.key\n );\n}\n\nfunction updateItemInstance<T>(\n forState: ForState<T>,\n itemInstance: ForItemInstance<T>,\n item: T\n): boolean {\n if (itemInstance.item === item) {\n return false;\n }\n\n const previousItem = itemInstance.item;\n itemInstance.item = item;\n\n let needsRerender = false;\n const itemSignal = itemInstance.itemSignal;\n if (!itemSignal) {\n rerenderItemInstance(forState, itemInstance, item);\n return true;\n }\n\n const propertySignals = itemInstance.itemPropertySignals;\n if (propertySignals && propertySignals.size > 0) {\n for (const [prop, propertySignal] of propertySignals) {\n const previousValue = readForItemProperty(previousItem, prop);\n const nextValue = readForItemProperty(item, prop);\n if (Object.is(previousValue, nextValue)) {\n continue;\n }\n\n const propertyHasRenderReaders = (propertySignal._readers?.size ?? 0) > 0;\n if (propertyHasRenderReaders) {\n needsRerender = true;\n }\n\n propertySignal.set(nextValue, !propertyHasRenderReaders);\n }\n }\n\n const hasRenderReaders = (itemSignal._readers?.size ?? 0) > 0;\n if (hasRenderReaders) {\n needsRerender = true;\n }\n itemSignal.set(item, hasRenderReaders);\n\n if (needsRerender) {\n rerenderItemInstance(forState, itemInstance, itemInstance.reactiveItem);\n }\n return true;\n}\n\nconst FOR_FALLBACK_SCOPE_KEY = '__for-fallback__';\n\nfunction disposeFallbackScope<T>(\n forState: ForState<T>,\n domCleanup: RemovedDomCleanupMode\n): void {\n const fallbackScope = forState.fallbackScope;\n if (!fallbackScope) {\n return;\n }\n\n const removedDom = fallbackScope.dom;\n disposeChildScope(fallbackScope);\n forState.fallbackScope = null;\n\n if (!removedDom) {\n return;\n }\n\n if (removedDom instanceof Element) {\n if (domCleanup === 'teardown') {\n teardownNodeSubtree(removedDom);\n }\n }\n\n forState.lastRemovedNodes.push(removedDom);\n}\n\nfunction renderFallbackScope<T>(forState: ForState<T>): VNode[] {\n if (forState.fallback == null || forState.fallback === false) {\n if (forState.fallbackScope) {\n disposeFallbackScope(forState, 'none');\n }\n forState.orderedVNodes = [];\n return [];\n }\n\n const fallbackScope =\n forState.fallbackScope ??\n createChildScope(forState.parentInstance, FOR_FALLBACK_SCOPE_KEY, () => {\n if (forState._enqueueBoundaryCommit) {\n forState._enqueueBoundaryCommit();\n return;\n }\n\n forState.parentInstance?._enqueueRun?.();\n });\n forState.fallbackScope = fallbackScope;\n\n const vnode = fallbackScope.render(() => forState.fallback as VNode);\n forState.orderedVNodes = vnode == null || vnode === false ? [] : [vnode];\n return forState.orderedVNodes;\n}\n\nfunction disposeAllItems<T>(\n forState: ForState<T>,\n domCleanup: RemovedDomCleanupMode\n): void {\n const { items, orderedKeys } = forState;\n for (let index = 0; index < orderedKeys.length; index += 1) {\n const key = orderedKeys[index];\n const itemInstance = items.get(key);\n if (!itemInstance) {\n continue;\n }\n disposeItemInstance(forState, itemInstance, domCleanup);\n items.delete(key);\n }\n orderedKeys.length = 0;\n forState.orderedKeys = orderedKeys;\n}\n\nexport function reconcileForItems<T>(\n forState: ForState<T>,\n newArray: T[]\n): VNode[] {\n forState.currentItems = newArray;\n validateForKeys(forState, newArray);\n\n if (BENCH_BUILD_ENABLED) {\n resetBenchMetrics();\n }\n\n const reconcileStartMs = BENCH_BUILD_ENABLED ? performance.now() : 0;\n\n const { items, orderedKeys, byFn } = forState;\n const oldLen = orderedKeys.length;\n const newLen = newArray.length;\n forState.lastRemovedNodes = [];\n\n if (newLen === 0) {\n if (oldLen > 0) {\n disposeAllItems(forState, forState.fallback ? 'teardown' : 'none');\n }\n recordBenchFastLane('TRUNCATE');\n forState.lastCommitStrategy = 'TRUNCATE';\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n return renderFallbackScope(forState);\n }\n\n if (forState.fallbackScope) {\n disposeFallbackScope(forState, 'none');\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // FAST PATH A: APPEND\n // Guard: oldLen <= newLen && all old keys match new keys at same indices\n // ─────────────────────────────────────────────────────────────────────────\n if (oldLen < newLen) {\n let canUseAppendPath = true;\n for (let i = 0; i < oldLen; i++) {\n const key = byFn(newArray[i], i);\n if (key !== orderedKeys[i]) {\n canUseAppendPath = false;\n break;\n }\n }\n\n if (canUseAppendPath) {\n recordBenchFastLane('APPEND');\n forState.lastCommitStrategy = 'APPEND';\n const resultVNodes = forState.orderedVNodes;\n resultVNodes.length = newLen;\n\n // Update existing rows in-place\n for (let i = 0; i < oldLen; i++) {\n const item = newArray[i];\n const key = orderedKeys[i];\n const existing = items.get(key)!;\n recordBenchEvent('itemReused');\n\n updateItemInstance(forState, existing, item);\n\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n // Create and append new rows\n for (let i = oldLen; i < newLen; i++) {\n const item = newArray[i];\n const key = byFn(item, i);\n const itemInstance = createItemInstance(key, item, i, forState);\n items.set(key, itemInstance);\n resultVNodes[i] = itemInstance.scope.vnode as VNode;\n orderedKeys[i] = key;\n }\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.orderedVNodes = resultVNodes;\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n return resultVNodes;\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // FAST PATH B: TRUNCATE\n // Guard: newLen <= oldLen && all new keys match old keys at same indices\n // ─────────────────────────────────────────────────────────────────────────\n if (newLen < oldLen) {\n if (oldLen === newLen + 1) {\n let removedIndex = -1;\n\n for (let i = 0; i < newLen; i++) {\n const nextKey = byFn(newArray[i], i);\n if (nextKey !== orderedKeys[i]) {\n removedIndex = i;\n break;\n }\n }\n\n if (removedIndex !== -1) {\n let canUseRemoveOnePath = true;\n for (let i = removedIndex; i < newLen; i++) {\n const nextKey = byFn(newArray[i], i);\n if (nextKey !== orderedKeys[i + 1]) {\n canUseRemoveOnePath = false;\n break;\n }\n }\n\n if (canUseRemoveOnePath) {\n recordBenchFastLane('REMOVE_ONE');\n forState.lastCommitStrategy = 'NO_REORDER';\n\n const resultVNodes = forState.orderedVNodes;\n resultVNodes.length = newLen;\n const dirtyIndices: number[] = [];\n\n for (let i = 0; i < newLen; i++) {\n const item = newArray[i];\n const key = i < removedIndex ? orderedKeys[i] : orderedKeys[i + 1];\n const existing = items.get(key)!;\n recordBenchEvent('itemReused');\n\n const itemChanged = existing.item !== item;\n const needsDomUpdate = existing.scope.needsDomUpdate;\n const indexChanged = existing.indexSignal.peek() !== i;\n\n if (itemChanged) {\n updateItemInstance(forState, existing, item);\n }\n\n if (indexChanged && existing.indexSignal._hasBeenRead) {\n existing.indexSignal.set(i);\n }\n\n if (\n itemChanged ||\n indexChanged ||\n needsDomUpdate ||\n existing.scope.needsDomUpdate\n ) {\n dirtyIndices.push(i);\n }\n\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n const removedKey = orderedKeys[removedIndex];\n const removedItem = items.get(removedKey);\n if (removedItem) {\n disposeItemInstance(forState, removedItem, 'teardown');\n items.delete(removedKey);\n }\n\n const nextOrderedKeys = orderedKeys.slice(0, newLen);\n for (let i = removedIndex; i < newLen; i++) {\n nextOrderedKeys[i] = orderedKeys[i + 1];\n }\n forState.orderedKeys = nextOrderedKeys;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming(\n 'reconcile',\n performance.now() - reconcileStartMs\n );\n flushBenchMetrics();\n }\n\n forState.pendingDirtyIndices = dirtyIndices;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n return resultVNodes;\n }\n }\n }\n\n let canUseTruncatePath = true;\n for (let i = 0; i < newLen; i++) {\n const key = byFn(newArray[i], i);\n if (key !== orderedKeys[i]) {\n canUseTruncatePath = false;\n break;\n }\n }\n\n if (canUseTruncatePath) {\n recordBenchFastLane('TRUNCATE');\n forState.lastCommitStrategy = 'TRUNCATE';\n const resultVNodes = forState.orderedVNodes;\n resultVNodes.length = newLen;\n const isFullClear = newLen === 0;\n\n // Update existing rows in-place\n for (let i = 0; i < newLen; i++) {\n const item = newArray[i];\n const key = orderedKeys[i];\n const existing = items.get(key)!;\n recordBenchEvent('itemReused');\n\n updateItemInstance(forState, existing, item);\n\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n // Remove tail rows\n for (let i = newLen; i < oldLen; i++) {\n const key = orderedKeys[i];\n const itemInstance = items.get(key);\n if (itemInstance) {\n disposeItemInstance(\n forState,\n itemInstance,\n isFullClear ? 'full-clear' : 'teardown'\n );\n items.delete(key);\n }\n }\n\n orderedKeys.length = newLen;\n forState.orderedKeys = orderedKeys;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.orderedVNodes = resultVNodes;\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n return resultVNodes;\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // FAST PATH C: NO-REORDER (in-place update only)\n // Guard: oldLen === newLen && keys match at all indices\n // ─────────────────────────────────────────────────────────────────────────\n if (oldLen === newLen) {\n let canUseNoReorderPath = true;\n for (let i = 0; i < oldLen; i++) {\n const key = byFn(newArray[i], i);\n if (key !== orderedKeys[i]) {\n canUseNoReorderPath = false;\n break;\n }\n }\n\n if (canUseNoReorderPath) {\n recordBenchFastLane('NO_REORDER');\n forState.lastCommitStrategy = 'NO_REORDER';\n const resultVNodes = forState.orderedVNodes;\n resultVNodes.length = oldLen;\n const dirtyIndices: number[] = [];\n\n // Update in-place only, no DOM moves needed\n for (let i = 0; i < oldLen; i++) {\n const item = newArray[i];\n const key = orderedKeys[i];\n const existing = items.get(key)!;\n recordBenchEvent('itemReused');\n\n const itemChanged = existing.item !== item;\n const needsDomUpdate = existing.scope.needsDomUpdate;\n let rerendered = false;\n\n if (itemChanged) {\n rerendered = updateItemInstance(forState, existing, item);\n }\n\n if (rerendered || needsDomUpdate || existing.scope.needsDomUpdate) {\n dirtyIndices.push(i);\n }\n\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.pendingDirtyIndices = dirtyIndices;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n\n return resultVNodes;\n }\n\n let firstMismatch = -1;\n let secondMismatch = -1;\n let firstMismatchKey: string | number | null = null;\n let secondMismatchKey: string | number | null = null;\n let mismatchCount = 0;\n let canUseSwapPath = true;\n\n for (let i = 0; i < oldLen; i++) {\n const item = newArray[i];\n const key = byFn(newArray[i], i);\n if (key === orderedKeys[i]) {\n const existing = items.get(key);\n if (existing && existing.item !== item) {\n canUseSwapPath = false;\n break;\n }\n continue;\n }\n\n mismatchCount++;\n if (firstMismatch === -1) {\n firstMismatch = i;\n firstMismatchKey = key;\n continue;\n }\n\n if (secondMismatch === -1) {\n secondMismatch = i;\n secondMismatchKey = key;\n continue;\n }\n\n mismatchCount = 3;\n break;\n }\n\n if (\n canUseSwapPath &&\n mismatchCount === 2 &&\n firstMismatch !== -1 &&\n secondMismatch !== -1 &&\n firstMismatchKey === orderedKeys[secondMismatch] &&\n secondMismatchKey === orderedKeys[firstMismatch]\n ) {\n recordBenchFastLane('SWAP');\n recordBenchEvent('itemMoved');\n recordBenchEvent('itemMoved');\n\n forState.lastCommitStrategy = 'SWAP';\n\n const nextOrderedKeys = orderedKeys.slice();\n nextOrderedKeys[firstMismatch] = firstMismatchKey;\n nextOrderedKeys[secondMismatch] = secondMismatchKey;\n\n const resultVNodes = forState.orderedVNodes;\n const firstExisting = items.get(firstMismatchKey)!;\n const secondExisting = items.get(secondMismatchKey)!;\n const firstItem = newArray[firstMismatch];\n const secondItem = newArray[secondMismatch];\n\n recordBenchEvent('itemReused');\n recordBenchEvent('itemReused');\n\n if (firstExisting.item !== firstItem) {\n updateItemInstance(forState, firstExisting, firstItem);\n }\n\n if (secondExisting.item !== secondItem) {\n updateItemInstance(forState, secondExisting, secondItem);\n }\n\n if (\n firstExisting.indexSignal._hasBeenRead &&\n firstExisting.indexSignal.peek() !== firstMismatch\n ) {\n firstExisting.indexSignal.set(firstMismatch);\n }\n\n if (\n secondExisting.indexSignal._hasBeenRead &&\n secondExisting.indexSignal.peek() !== secondMismatch\n ) {\n secondExisting.indexSignal.set(secondMismatch);\n }\n\n resultVNodes[firstMismatch] = firstExisting.scope.vnode as VNode;\n resultVNodes[secondMismatch] = secondExisting.scope.vnode as VNode;\n\n forState.orderedKeys = nextOrderedKeys;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = [firstMismatch, secondMismatch];\n forState.pendingMoveOnly = true;\n\n return resultVNodes;\n }\n\n let canUseMoveOnlyPath = true;\n const moveOnlyKeys: Array<string | number> = [];\n const moveOnlyVNodes: VNode[] = [];\n\n for (let i = 0; i < oldLen; i++) {\n const item = newArray[i];\n const key = byFn(item, i);\n const existing = items.get(key);\n\n if (\n !existing ||\n existing.item !== item ||\n (existing.indexSignal._hasBeenRead && existing.indexSignal.peek() !== i)\n ) {\n canUseMoveOnlyPath = false;\n break;\n }\n\n moveOnlyKeys[i] = key;\n moveOnlyVNodes[i] = existing.scope.vnode as VNode;\n recordBenchEvent('itemReused');\n }\n\n if (canUseMoveOnlyPath) {\n recordBenchFastLane('FULL_KEYED');\n forState.lastCommitStrategy = 'FULL_KEYED';\n forState.orderedKeys = moveOnlyKeys;\n forState.orderedVNodes = moveOnlyVNodes;\n\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = true;\n\n return moveOnlyVNodes;\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // FULL KEYED RECONCILIATION (slow path for complex reorders)\n // Avoid allocating newKeyMap: iterate directly and track removals\n // ─────────────────────────────────────────────────────────────────────────\n recordBenchFastLane('FULL_KEYED');\n forState.lastCommitStrategy = 'FULL_KEYED';\n\n const toRemove = new Set(orderedKeys);\n const newOrderedKeys: Array<string | number> = [];\n const resultVNodes: VNode[] = [];\n let moveOnly = toRemove.size === newArray.length;\n\n // Single pass: iterate new array directly, no intermediate map\n for (let i = 0; i < newArray.length; i++) {\n const item = newArray[i];\n const key = byFn(item, i);\n recordBenchEvent('keyLookup');\n\n toRemove.delete(key);\n newOrderedKeys.push(key);\n\n const existing = items.get(key);\n recordBenchEvent(existing ? 'keyHit' : 'keyMiss');\n\n if (!existing) {\n // Added: create new item instance\n const itemInstance = createItemInstance(key, item, i, forState);\n items.set(key, itemInstance);\n resultVNodes.push(itemInstance.scope.vnode as VNode);\n } else {\n // Exists: check if item changed (by identity)\n recordBenchEvent('itemReused');\n const itemChanged = existing.item !== item;\n const indexChanged =\n existing.indexSignal._hasBeenRead && existing.indexSignal.peek() !== i;\n\n if (itemChanged) {\n moveOnly = false;\n updateItemInstance(forState, existing, item);\n }\n\n if (indexChanged) {\n // Index changed: update index signal (triggers re-render if index is used)\n existing.indexSignal.set(i);\n }\n\n resultVNodes.push(existing.scope.vnode as VNode);\n }\n }\n\n // Remove deleted items\n for (const key of toRemove) {\n moveOnly = false;\n const itemInstance = items.get(key);\n if (itemInstance) {\n disposeItemInstance(forState, itemInstance, 'none');\n items.delete(key);\n }\n }\n\n forState.orderedKeys = newOrderedKeys;\n\n // Record reconcile timing\n if (BENCH_BUILD_ENABLED) {\n recordBenchTiming('reconcile', performance.now() - reconcileStartMs);\n flushBenchMetrics();\n }\n\n forState.orderedVNodes = resultVNodes;\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = moveOnly;\n\n return resultVNodes;\n}\n\nexport function evaluateForState<T>(forState: ForState<T>): VNode[] {\n if (!Array.isArray(forState.currentItems)) {\n throw new Error('For source must evaluate to an array');\n }\n\n forState._needsSourceReconcile = false;\n return reconcileForItems(forState, forState.currentItems);\n}\n\nexport function clearForDomUpdateState<T>(forState: ForState<T>): void {\n for (let i = 0; i < forState.orderedKeys.length; i++) {\n const key = forState.orderedKeys[i];\n const itemInstance = forState.items.get(key);\n if (itemInstance) {\n itemInstance.scope.needsDomUpdate = false;\n }\n }\n if (forState.fallbackScope) {\n forState.fallbackScope.needsDomUpdate = false;\n }\n forState.lastRemovedNodes = [];\n forState.pendingDirtyIndices = null;\n forState.pendingSwapIndices = null;\n forState.pendingMoveOnly = false;\n forState._needsSourceReconcile = false;\n}\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAA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C5C,MAAI,aACF,cAAa,MAAM,iBAAiB;;AAGxC,KAAI,SAAS,cACX,UAAS,cAAc,iBAAiB;AAE1C,UAAS,mBAAmB,EAAE;AAC9B,UAAS,sBAAsB;AAC/B,UAAS,qBAAqB;AAC9B,UAAS,kBAAkB;AAC3B,UAAS,wBAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askrjs/askr",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"description": "Actor-backed deterministic UI framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"askr",
|
|
@@ -50,6 +50,10 @@
|
|
|
50
50
|
"import": "./dist/resources/index.js",
|
|
51
51
|
"types": "./dist/resources/index.d.ts"
|
|
52
52
|
},
|
|
53
|
+
"./data": {
|
|
54
|
+
"import": "./dist/data/index.js",
|
|
55
|
+
"types": "./dist/data/index.d.ts"
|
|
56
|
+
},
|
|
53
57
|
"./fx": {
|
|
54
58
|
"import": "./dist/fx/index.js",
|
|
55
59
|
"types": "./dist/fx/index.d.ts"
|
|
@@ -97,7 +101,7 @@
|
|
|
97
101
|
"bench:tier4": "vp test bench -c vitest.bench.dom.tier4.config.ts --run"
|
|
98
102
|
},
|
|
99
103
|
"devDependencies": {
|
|
100
|
-
"@axe-core/playwright": "^4.11.
|
|
104
|
+
"@axe-core/playwright": "^4.11.3",
|
|
101
105
|
"@playwright/test": "^1.59.1",
|
|
102
106
|
"@types/node": "^25.6.0",
|
|
103
107
|
"jsdom": "^29.1.1",
|