@askrjs/askr 0.0.36 → 0.0.37
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 +1 -1
- 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 +2 -16
- package/dist/index.js +1 -17
- 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/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/runtime/for.js
CHANGED
|
@@ -106,9 +106,11 @@ function createForItemSignal(initialItem) {
|
|
|
106
106
|
itemSignal.set = (newValue, notifyReaders = true) => {
|
|
107
107
|
if (Object.is(itemValue, newValue)) return;
|
|
108
108
|
itemValue = newValue;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
if (notifyReaders) {
|
|
110
|
+
markReadableDerivedSubscribersDirty(itemSignal);
|
|
111
|
+
markReactivePropsDirtySource(itemSignal);
|
|
112
|
+
notifyReadableReaders(itemSignal);
|
|
113
|
+
}
|
|
112
114
|
};
|
|
113
115
|
itemSignal._hasBeenRead = false;
|
|
114
116
|
return itemSignal;
|
|
@@ -126,9 +128,11 @@ function createForItemPropertySignal(initialValue) {
|
|
|
126
128
|
propertySignal.set = (newValue, notifyReaders = true) => {
|
|
127
129
|
if (Object.is(propertyValue, newValue)) return;
|
|
128
130
|
propertyValue = newValue;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
if (notifyReaders) {
|
|
132
|
+
markReadableDerivedSubscribersDirty(propertySignal);
|
|
133
|
+
markReactivePropsDirtySource(propertySignal);
|
|
134
|
+
notifyReadableReaders(propertySignal);
|
|
135
|
+
}
|
|
132
136
|
};
|
|
133
137
|
propertySignal._hasBeenRead = false;
|
|
134
138
|
return propertySignal;
|
|
@@ -136,6 +140,13 @@ function createForItemPropertySignal(initialValue) {
|
|
|
136
140
|
function readForItemProperty(item, prop) {
|
|
137
141
|
return Reflect.get(Object(item), prop);
|
|
138
142
|
}
|
|
143
|
+
function haveSameOwnKeys(previousItem, nextItem) {
|
|
144
|
+
const previousKeys = Reflect.ownKeys(Object(previousItem));
|
|
145
|
+
const nextKeys = Reflect.ownKeys(Object(nextItem));
|
|
146
|
+
if (previousKeys.length !== nextKeys.length) return false;
|
|
147
|
+
for (let i = 0; i < previousKeys.length; i += 1) if (previousKeys[i] !== nextKeys[i]) return false;
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
139
150
|
function scopeReadsSource(scope, source) {
|
|
140
151
|
return source._readers?.has(scope.componentInstance) ?? false;
|
|
141
152
|
}
|
|
@@ -236,6 +247,7 @@ function createItemInstance(key, item, index, forState) {
|
|
|
236
247
|
const itemSignal = canProxyForItem(item) ? createForItemSignal(item) : null;
|
|
237
248
|
const itemPropertySignals = itemSignal ? /* @__PURE__ */ new Map() : null;
|
|
238
249
|
const reactiveItem = itemSignal && itemPropertySignals ? createReactiveForItem(itemSignal, itemPropertySignals) : item;
|
|
250
|
+
let itemInstance = null;
|
|
239
251
|
const scope = createChildScope(forState.parentInstance, key, () => {
|
|
240
252
|
if (forState._enqueueBoundaryCommit) {
|
|
241
253
|
forState._enqueueBoundaryCommit();
|
|
@@ -245,7 +257,7 @@ function createItemInstance(key, item, index, forState) {
|
|
|
245
257
|
if (parent) parent._enqueueRun?.();
|
|
246
258
|
});
|
|
247
259
|
renderItemScope(forState, scope, reactiveItem, indexSignal, key);
|
|
248
|
-
|
|
260
|
+
itemInstance = {
|
|
249
261
|
key,
|
|
250
262
|
item,
|
|
251
263
|
reactiveItem,
|
|
@@ -254,6 +266,7 @@ function createItemInstance(key, item, index, forState) {
|
|
|
254
266
|
indexSignal,
|
|
255
267
|
scope
|
|
256
268
|
};
|
|
269
|
+
return itemInstance;
|
|
257
270
|
}
|
|
258
271
|
function rerenderItemInstance(forState, itemInstance, item) {
|
|
259
272
|
renderItemScope(forState, itemInstance.scope, item, itemInstance.indexSignal, itemInstance.key);
|
|
@@ -279,14 +292,13 @@ function updateItemInstance(forState, itemInstance, item) {
|
|
|
279
292
|
changedPropertySignals.push([propertySignal, nextValue]);
|
|
280
293
|
}
|
|
281
294
|
if (scopeReadsSource(scope, itemSignal)) scopeReadsChangedSignal = true;
|
|
282
|
-
const
|
|
295
|
+
const itemShapeChanged = changedPropertySignals.length === 0 && !haveSameOwnKeys(previousItem, item);
|
|
296
|
+
const notifyReaders = !scopeReadsChangedSignal && (changedPropertySignals.length > 0 || itemShapeChanged);
|
|
297
|
+
const visibleChange = scopeReadsChangedSignal || changedPropertySignals.length > 0 || itemShapeChanged;
|
|
283
298
|
for (const [propertySignal, nextValue] of changedPropertySignals) propertySignal.set(nextValue, notifyReaders);
|
|
284
299
|
itemSignal.set(item, notifyReaders);
|
|
285
|
-
if (scopeReadsChangedSignal)
|
|
286
|
-
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
return false;
|
|
300
|
+
if (scopeReadsChangedSignal) rerenderItemInstance(forState, itemInstance, itemInstance.reactiveItem);
|
|
301
|
+
return visibleChange;
|
|
290
302
|
}
|
|
291
303
|
const FOR_FALLBACK_SCOPE_KEY = "__for-fallback__";
|
|
292
304
|
function disposeFallbackScope(forState, domCleanup) {
|
|
@@ -424,12 +436,13 @@ function reconcileForItems(forState, newArray) {
|
|
|
424
436
|
const item = newArray[i];
|
|
425
437
|
const key = i < removedIndex ? orderedKeys[i] : orderedKeys[i + 1];
|
|
426
438
|
const existing = items.get(key);
|
|
439
|
+
const scopeNeedsDomUpdate = existing.scope.needsDomUpdate;
|
|
427
440
|
const itemChanged = existing.item !== item;
|
|
428
|
-
const
|
|
429
|
-
const indexChanged =
|
|
441
|
+
const indexSignal = existing.indexSignal;
|
|
442
|
+
const indexChanged = indexSignal._hasBeenRead && indexSignal.peek() !== i;
|
|
430
443
|
if (itemChanged) updateItemInstance(forState, existing, item);
|
|
431
|
-
if (indexChanged
|
|
432
|
-
if (itemChanged || indexChanged ||
|
|
444
|
+
if (indexChanged) indexSignal.set(i);
|
|
445
|
+
if (itemChanged || indexChanged || scopeNeedsDomUpdate) dirtyIndices.push(i);
|
|
433
446
|
resultItems[i] = existing;
|
|
434
447
|
resultVNodes[i] = existing.scope.vnode;
|
|
435
448
|
}
|
|
@@ -522,10 +535,8 @@ function reconcileForItems(forState, newArray) {
|
|
|
522
535
|
const key = orderedKeys[i];
|
|
523
536
|
const existing = items.get(key);
|
|
524
537
|
const itemChanged = existing.item !== item;
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (itemChanged) rerendered = updateItemInstance(forState, existing, item);
|
|
528
|
-
if (rerendered || needsDomUpdate || existing.scope.needsDomUpdate) dirtyIndices.push(i);
|
|
538
|
+
if (itemChanged) updateItemInstance(forState, existing, item);
|
|
539
|
+
if (!itemChanged && existing.scope.needsDomUpdate) dirtyIndices.push(i);
|
|
529
540
|
resultItems[i] = existing;
|
|
530
541
|
resultVNodes[i] = existing.scope.vnode;
|
|
531
542
|
}
|
|
@@ -713,6 +724,7 @@ function clearForDomUpdateState(forState) {
|
|
|
713
724
|
forState.pendingSwapIndices = null;
|
|
714
725
|
forState.pendingMoveOnly = false;
|
|
715
726
|
forState._needsSourceReconcile = false;
|
|
727
|
+
forState._hasResolvedItemDom = forState.orderedKeys.length > 0;
|
|
716
728
|
}
|
|
717
729
|
//#endregion
|
|
718
730
|
export { clearForDomUpdateState, evaluateForState, useForState };
|
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 orderedItems: ForItemInstance<T>[];\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 orderedItems: [],\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 scopeReadsSource(\n scope: ChildScope,\n source: ReadableSource<unknown>\n): boolean {\n return source._readers?.has(scope.componentInstance) ?? false;\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 const scope = itemInstance.scope;\n let scopeReadsChangedSignal = 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 const changedPropertySignals: Array<[ForItemPropertySignal, unknown]> = [];\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 if (scopeReadsSource(scope, propertySignal)) {\n scopeReadsChangedSignal = true;\n }\n\n changedPropertySignals.push([propertySignal, nextValue]);\n }\n }\n\n if (scopeReadsSource(scope, itemSignal)) {\n scopeReadsChangedSignal = true;\n }\n\n const notifyReaders = !scopeReadsChangedSignal;\n for (const [propertySignal, nextValue] of changedPropertySignals) {\n propertySignal.set(nextValue, notifyReaders);\n }\n itemSignal.set(item, notifyReaders);\n\n if (scopeReadsChangedSignal) {\n rerenderItemInstance(forState, itemInstance, itemInstance.reactiveItem);\n return true;\n }\n\n return false;\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 forState.orderedItems = [];\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 forState.orderedItems = [];\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 const resultItems = forState.orderedItems;\n resultVNodes.length = newLen;\n resultItems.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 = resultItems[i] ?? items.get(key)!;\n\n updateItemInstance(forState, existing, item);\n\n resultItems[i] = existing;\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n recordBenchEvent('itemReused', oldLen);\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 resultItems[i] = 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 previousOrderedItems = forState.orderedItems.slice();\n const resultVNodes = forState.orderedVNodes;\n const resultItems = forState.orderedItems;\n resultVNodes.length = newLen;\n resultItems.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\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 resultItems[i] = existing;\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n recordBenchEvent('itemReused', newLen);\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 const nextOrderedItems = previousOrderedItems.slice(0, newLen);\n for (let i = removedIndex; i < newLen; i++) {\n nextOrderedKeys[i] = orderedKeys[i + 1];\n nextOrderedItems[i] = previousOrderedItems[i + 1];\n }\n forState.orderedKeys = nextOrderedKeys;\n forState.orderedItems = nextOrderedItems;\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 const resultItems = forState.orderedItems;\n resultVNodes.length = newLen;\n resultItems.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\n updateItemInstance(forState, existing, item);\n\n resultItems[i] = existing;\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n recordBenchEvent('itemReused', newLen);\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 forState.orderedItems.length = newLen;\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 const resultItems = forState.orderedItems;\n resultVNodes.length = oldLen;\n resultItems.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\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 resultItems[i] = existing;\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n recordBenchEvent('itemReused', oldLen);\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 const nextOrderedItems = forState.orderedItems.slice();\n nextOrderedItems[firstMismatch] = secondExisting;\n nextOrderedItems[secondMismatch] = firstExisting;\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 forState.orderedItems = nextOrderedItems;\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 moveOnlyItems: ForItemInstance<T>[] = [];\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 moveOnlyItems[i] = existing;\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.orderedItems = moveOnlyItems;\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 newOrderedItems: ForItemInstance<T>[] = [];\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 newOrderedItems.push(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 newOrderedItems.push(existing);\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 forState.orderedItems = newOrderedItems;\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 const dirtyIndices = forState.pendingDirtyIndices;\n if (dirtyIndices && dirtyIndices.length > 0) {\n for (let i = 0; i < dirtyIndices.length; i++) {\n const itemInstance = forState.orderedItems[dirtyIndices[i]];\n if (itemInstance) {\n itemInstance.scope.needsDomUpdate = false;\n }\n }\n } else {\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 }\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;AA0EjD,MAAM,4BAAY,IAAI,SAGnB;AAEH,SAAS,YACP,UACgC;CAChC,IAAI,QAAQ,UAAU,IAAI,SAAS;CACnC,IAAI,CAAC,OAAO;EACV,wBAAQ,IAAI,KAAK;EACjB,UAAU,IAAI,UAAU,MAAM;;CAEhC,OAAO;;AAGT,SAAgB,eACd,YACA,MACA,UACA,UACa;CACb,MAAM,iBAAiB,oBAAoB;CAE3C,OAAO;EACL,MAAM;EACN,cAAc,EAAE;EAChB;EACA;EACA,eAAe;EACf,uBAAO,IAAI,KAAK;EAChB,aAAa,EAAE;EACf,cAAc,EAAE;EAChB,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;CACrC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,6DACD;CAGH,MAAM,YAAY,eAAe,UAAU,MAAM;CACjD,MAAM,QAAQ,YAAY,SAAS;CACnC,MAAM,WAAW,MAAM,IAAI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kB,UAAU,SAAS,aAAa;;AAG3D,SAAgB,uBAA0B,UAA6B;CACrE,MAAM,eAAe,SAAS;CAC9B,IAAI,gBAAgB,aAAa,SAAS,GACxC,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,eAAe,SAAS,aAAa,aAAa;EACxD,IAAI,cACF,aAAa,MAAM,iBAAiB;;MAIxC,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,YAAY,QAAQ,KAAK;EACpD,MAAM,MAAM,SAAS,YAAY;EACjC,MAAM,eAAe,SAAS,MAAM,IAAI,IAAI;EAC5C,IAAI,cACF,aAAa,MAAM,iBAAiB;;CAK1C,IAAI,SAAS,eACX,SAAS,cAAc,iBAAiB;CAE1C,SAAS,mBAAmB,EAAE;CAC9B,SAAS,sBAAsB;CAC/B,SAAS,qBAAqB;CAC9B,SAAS,kBAAkB;CAC3B,SAAS,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 orderedItems: ForItemInstance<T>[];\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 orderedItems: [],\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 if (notifyReaders) {\n markReadableDerivedSubscribersDirty(itemSignal);\n markReactivePropsDirtySource(itemSignal);\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 if (notifyReaders) {\n markReadableDerivedSubscribersDirty(propertySignal);\n markReactivePropsDirtySource(propertySignal);\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 haveSameOwnKeys(previousItem: unknown, nextItem: unknown): boolean {\n const previousKeys = Reflect.ownKeys(Object(previousItem));\n const nextKeys = Reflect.ownKeys(Object(nextItem));\n\n if (previousKeys.length !== nextKeys.length) {\n return false;\n }\n\n for (let i = 0; i < previousKeys.length; i += 1) {\n if (previousKeys[i] !== nextKeys[i]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction scopeReadsSource(\n scope: ChildScope,\n source: ReadableSource<unknown>\n): boolean {\n return source._readers?.has(scope.componentInstance) ?? false;\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 let itemInstance: ForItemInstance<T> | null = null;\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 itemInstance = {\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 scope = itemInstance.scope;\n let scopeReadsChangedSignal = 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 const changedPropertySignals: Array<[ForItemPropertySignal, unknown]> = [];\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 if (scopeReadsSource(scope, propertySignal)) {\n scopeReadsChangedSignal = true;\n }\n\n changedPropertySignals.push([propertySignal, nextValue]);\n }\n }\n\n if (scopeReadsSource(scope, itemSignal)) {\n scopeReadsChangedSignal = true;\n }\n\n const itemShapeChanged =\n changedPropertySignals.length === 0 && !haveSameOwnKeys(previousItem, item);\n const notifyReaders =\n !scopeReadsChangedSignal &&\n (changedPropertySignals.length > 0 || itemShapeChanged);\n const visibleChange =\n scopeReadsChangedSignal ||\n changedPropertySignals.length > 0 ||\n itemShapeChanged;\n for (const [propertySignal, nextValue] of changedPropertySignals) {\n propertySignal.set(nextValue, notifyReaders);\n }\n itemSignal.set(item, notifyReaders);\n\n if (scopeReadsChangedSignal) {\n rerenderItemInstance(forState, itemInstance, itemInstance.reactiveItem);\n }\n\n return visibleChange;\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 forState.orderedItems = [];\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 forState.orderedItems = [];\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 const resultItems = forState.orderedItems;\n resultVNodes.length = newLen;\n resultItems.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 = resultItems[i] ?? items.get(key)!;\n\n updateItemInstance(forState, existing, item);\n\n resultItems[i] = existing;\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n recordBenchEvent('itemReused', oldLen);\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 resultItems[i] = 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 previousOrderedItems = forState.orderedItems.slice();\n const resultVNodes = forState.orderedVNodes;\n const resultItems = forState.orderedItems;\n resultVNodes.length = newLen;\n resultItems.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 const scopeNeedsDomUpdate = existing.scope.needsDomUpdate;\n\n const itemChanged = existing.item !== item;\n const indexSignal = existing.indexSignal;\n const indexChanged =\n indexSignal._hasBeenRead && indexSignal.peek() !== i;\n\n if (itemChanged) {\n updateItemInstance(forState, existing, item);\n }\n\n if (indexChanged) {\n indexSignal.set(i);\n }\n\n if (itemChanged || indexChanged || scopeNeedsDomUpdate) {\n dirtyIndices.push(i);\n }\n\n resultItems[i] = existing;\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n recordBenchEvent('itemReused', newLen);\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 const nextOrderedItems = previousOrderedItems.slice(0, newLen);\n for (let i = removedIndex; i < newLen; i++) {\n nextOrderedKeys[i] = orderedKeys[i + 1];\n nextOrderedItems[i] = previousOrderedItems[i + 1];\n }\n forState.orderedKeys = nextOrderedKeys;\n forState.orderedItems = nextOrderedItems;\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 const resultItems = forState.orderedItems;\n resultVNodes.length = newLen;\n resultItems.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\n updateItemInstance(forState, existing, item);\n\n resultItems[i] = existing;\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n recordBenchEvent('itemReused', newLen);\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 forState.orderedItems.length = newLen;\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 const resultItems = forState.orderedItems;\n resultVNodes.length = oldLen;\n resultItems.length = oldLen;\n const dirtyIndices: number[] = [];\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 const itemChanged = existing.item !== item;\n\n if (itemChanged) {\n updateItemInstance(forState, existing, item);\n }\n\n if (!itemChanged && existing.scope.needsDomUpdate) {\n dirtyIndices.push(i);\n }\n\n resultItems[i] = existing;\n resultVNodes[i] = existing.scope.vnode as VNode;\n }\n\n recordBenchEvent('itemReused', oldLen);\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 const nextOrderedItems = forState.orderedItems.slice();\n nextOrderedItems[firstMismatch] = secondExisting;\n nextOrderedItems[secondMismatch] = firstExisting;\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 forState.orderedItems = nextOrderedItems;\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 moveOnlyItems: ForItemInstance<T>[] = [];\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 moveOnlyItems[i] = existing;\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.orderedItems = moveOnlyItems;\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 newOrderedItems: ForItemInstance<T>[] = [];\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 newOrderedItems.push(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 newOrderedItems.push(existing);\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 forState.orderedItems = newOrderedItems;\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 const dirtyIndices = forState.pendingDirtyIndices;\n if (dirtyIndices && dirtyIndices.length > 0) {\n for (let i = 0; i < dirtyIndices.length; i++) {\n const itemInstance = forState.orderedItems[dirtyIndices[i]];\n if (itemInstance) {\n itemInstance.scope.needsDomUpdate = false;\n }\n }\n } else {\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 }\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 forState._hasResolvedItemDom = forState.orderedKeys.length > 0;\n}\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAAM,sBAAsB,qBAAqB;AA0EjD,MAAM,4BAAY,IAAI,SAGnB;AAEH,SAAS,YACP,UACgC;CAChC,IAAI,QAAQ,UAAU,IAAI,SAAS;CACnC,IAAI,CAAC,OAAO;EACV,wBAAQ,IAAI,KAAK;EACjB,UAAU,IAAI,UAAU,MAAM;;CAEhC,OAAO;;AAGT,SAAgB,eACd,YACA,MACA,UACA,UACa;CACb,MAAM,iBAAiB,oBAAoB;CAE3C,OAAO;EACL,MAAM;EACN,cAAc,EAAE;EAChB;EACA;EACA,eAAe;EACf,uBAAO,IAAI,KAAK;EAChB,aAAa,EAAE;EACf,cAAc,EAAE;EAChB,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;CACrC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,6DACD;CAGH,MAAM,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ACX,MAAM,eAAe,MAAM,IAAI,IAAI;EACnC,IAAI,cAAc;GAChB,oBAAoB,UAAU,cAAc,OAAO;GACnD,MAAM,OAAO,IAAI;;;CAIrB,SAAS,cAAc;CACvB,SAAS,eAAe;CAGxB,IAAI,qBAAqB;EACvB,kBAAkB,aAAa,YAAY,KAAK,GAAG,iBAAiB;EACpE,mBAAmB;;CAGrB,SAAS,gBAAgB;CACzB,SAAS,sBAAsB;CAC/B,SAAS,qBAAqB;CAC9B,SAAS,kBAAkB;CAE3B,OAAO;;AAGT,SAAgB,iBAAoB,UAAgC;CAClE,IAAI,CAAC,MAAM,QAAQ,SAAS,aAAa,EACvC,MAAM,IAAI,MAAM,uCAAuC;CAGzD,SAAS,wBAAwB;CACjC,OAAO,kBAAkB,UAAU,SAAS,aAAa;;AAG3D,SAAgB,uBAA0B,UAA6B;CACrE,MAAM,eAAe,SAAS;CAC9B,IAAI,gBAAgB,aAAa,SAAS,GACxC,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,eAAe,SAAS,aAAa,aAAa;EACxD,IAAI,cACF,aAAa,MAAM,iBAAiB;;MAIxC,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,YAAY,QAAQ,KAAK;EACpD,MAAM,MAAM,SAAS,YAAY;EACjC,MAAM,eAAe,SAAS,MAAM,IAAI,IAAI;EAC5C,IAAI,cACF,aAAa,MAAM,iBAAiB;;CAK1C,IAAI,SAAS,eACX,SAAS,cAAc,iBAAiB;CAE1C,SAAS,mBAAmB,EAAE;CAC9B,SAAS,sBAAsB;CAC/B,SAAS,qBAAqB;CAC9B,SAAS,kBAAkB;CAC3B,SAAS,wBAAwB;CACjC,SAAS,sBAAsB,SAAS,YAAY,SAAS"}
|
|
@@ -3,9 +3,9 @@ import { getCurrentContextFrame } from "./context.js";
|
|
|
3
3
|
import { getCurrentComponentInstance, registerMountOperation } from "./component.js";
|
|
4
4
|
import { state } from "./state.js";
|
|
5
5
|
import { brandSnapshotSource } from "./snapshot-source.js";
|
|
6
|
+
import { SSRDataMissingError } from "../common/ssr-errors.js";
|
|
6
7
|
import { getSSRBridge } from "./ssr-bridge.js";
|
|
7
8
|
import { ResourceCell } from "./resource-cell.js";
|
|
8
|
-
import { SSRDataMissingError } from "../common/ssr-errors.js";
|
|
9
9
|
//#region src/runtime/operations.ts
|
|
10
10
|
/**
|
|
11
11
|
* Resource primitive — simple, deterministic async primitive
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector.d.ts","names":[],"sources":["../../src/runtime/selector.ts"],"mappings":";UA6BiB,QAAA;EAAA,CACd,SAAA,EAAW,CAAA;AAAA;AAAA,KAOT,cAAA;EACH,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"selector.d.ts","names":[],"sources":["../../src/runtime/selector.ts"],"mappings":";UA6BiB,QAAA;EAAA,CACd,SAAA,EAAW,CAAA;AAAA;AAAA,KAOT,cAAA;EACH,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA;AAAA,iBAqcV,QAAA,GAAA,CACd,MAAA,QAAc,CAAA,EACd,MAAA,GAAQ,cAAA,CAAe,CAAA,IACtB,QAAA,CAAS,CAAA"}
|