@askrjs/askr 0.0.41 → 0.0.43
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/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +2 -0
- package/dist/boot/index.js.map +1 -1
- package/dist/common/route-activity.js +30 -0
- package/dist/common/route-activity.js.map +1 -0
- package/dist/common/router.d.ts +4 -2
- package/dist/common/router.d.ts.map +1 -1
- package/dist/data/index.d.ts +21 -2
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +56 -3
- package/dist/data/index.js.map +1 -1
- package/dist/data/invalidation-listeners.js +15 -0
- package/dist/data/invalidation-listeners.js.map +1 -0
- package/dist/renderer/dom.js +35 -20
- package/dist/renderer/dom.js.map +1 -1
- package/dist/renderer/evaluate.js +27 -17
- package/dist/renderer/evaluate.js.map +1 -1
- package/dist/renderer/for-commit.js +9 -0
- package/dist/renderer/for-commit.js.map +1 -1
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +2 -2
- package/dist/router/match.js +31 -6
- package/dist/router/match.js.map +1 -1
- package/dist/router/navigate.d.ts.map +1 -1
- package/dist/router/navigate.js +30 -4
- package/dist/router/navigate.js.map +1 -1
- package/dist/router/route.d.ts +6 -1
- package/dist/router/route.d.ts.map +1 -1
- package/dist/router/route.js +35 -8
- package/dist/router/route.js.map +1 -1
- package/dist/runtime/child-scope.js +1 -0
- package/dist/runtime/child-scope.js.map +1 -1
- package/dist/runtime/component.d.ts +8 -1
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/component.js +207 -44
- package/dist/runtime/component.js.map +1 -1
- package/dist/runtime/fastlane.js +6 -0
- package/dist/runtime/fastlane.js.map +1 -1
- package/dist/runtime/for.d.ts.map +1 -1
- package/dist/runtime/for.js +18 -1
- package/dist/runtime/for.js.map +1 -1
- package/dist/runtime/operations.d.ts +11 -3
- package/dist/runtime/operations.d.ts.map +1 -1
- package/dist/runtime/operations.js +161 -22
- package/dist/runtime/operations.js.map +1 -1
- package/dist/runtime/readable.d.ts +1 -0
- package/dist/runtime/readable.d.ts.map +1 -1
- package/dist/runtime/readable.js +7 -4
- package/dist/runtime/readable.js.map +1 -1
- package/dist/testing/index.d.ts +53 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +172 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +11 -3
package/dist/data/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/data/index.ts"],"sourcesContent":["import { globalScheduler } from '../runtime/scheduler';\nimport {\n claimHookIndex,\n getCurrentComponentInstance,\n type ComponentInstance,\n} from '../runtime/component';\nimport {\n markReadableDerivedSubscribersDirty,\n markReactivePropsDirtySource,\n notifyReadableReaders,\n recordReadableRead,\n type ReadableSource,\n} from '../runtime/readable';\nimport { getRenderContext } from '../ssr/context';\nimport { logger } from '../dev/logger';\n\nexport type QueryConsistency =\n | 'fresh'\n | 'stale'\n | 'refreshing'\n | 'pending-write';\n\nexport type QueryStaleReason = 'aborted' | 'error' | 'inconsistent';\n\ntype QueryControls = {\n refresh(): Promise<void>;\n};\n\ntype QueryLoading = {\n data: null;\n error: null;\n loading: true;\n refreshing: false;\n stale: false;\n consistency: 'fresh';\n staleReason: null;\n};\n\ntype QueryFresh<T> = {\n data: T;\n error: null;\n loading: false;\n refreshing: false;\n stale: false;\n consistency: 'fresh';\n staleReason: null;\n};\n\ntype QueryRefreshing<T> = {\n data: T;\n error: null;\n loading: false;\n refreshing: true;\n stale: true;\n consistency: 'refreshing';\n staleReason: null;\n};\n\ntype QueryPendingWrite<T> = {\n data: T;\n error: null;\n loading: false;\n refreshing: true;\n stale: true;\n consistency: 'pending-write';\n staleReason: null;\n};\n\ntype QueryStaleValue<T> = {\n data: T;\n error: null;\n loading: false;\n refreshing: false;\n stale: true;\n consistency: 'stale';\n staleReason: 'aborted' | 'inconsistent';\n};\n\ntype QueryStaleErrorWithValue<T> = {\n data: T;\n error: {};\n loading: false;\n refreshing: false;\n stale: true;\n consistency: 'stale';\n staleReason: 'error';\n};\n\ntype QueryStaleError = {\n data: null;\n error: {};\n loading: false;\n refreshing: false;\n stale: true;\n consistency: 'stale';\n staleReason: 'error';\n};\n\nexport type Query<T extends {}> = QueryControls &\n (\n | QueryLoading\n | QueryFresh<T>\n | QueryRefreshing<T>\n | QueryPendingWrite<T>\n | QueryStaleValue<T>\n | QueryStaleErrorWithValue<T>\n | QueryStaleError\n );\n\ntype MutationControls<TInput, TResult> = {\n execute(input: TInput): Promise<TResult>;\n abort(): void;\n reset(): void;\n};\n\ntype MutationIdle = {\n status: 'idle';\n pending: false;\n error: null;\n result: null;\n};\n\ntype MutationPending = {\n status: 'pending';\n pending: true;\n error: null;\n result: null;\n};\n\ntype MutationSuccess<TResult> = {\n status: 'success';\n pending: false;\n error: null;\n result: TResult;\n};\n\ntype MutationError = {\n status: 'error';\n pending: false;\n error: {};\n result: null;\n};\n\nexport type Mutation<TInput, TResult> = MutationControls<TInput, TResult> &\n (MutationIdle | MutationPending | MutationSuccess<TResult> | MutationError);\n\ntype MutationRecord<TResult> = {\n status: 'idle' | 'pending' | 'success' | 'error';\n error: {} | null;\n result: TResult | null;\n};\n\ntype QueryOptions<T> = {\n key: string;\n fetch: (ctx: { signal: AbortSignal }) => Promise<T>;\n isConsistent?: (data: T) => boolean;\n reconcile?: (data: T, ctx: { key: string }) => Promise<boolean> | boolean;\n};\n\ntype MutationOptions<TInput, TResult> = {\n action: (input: TInput, ctx: { signal: AbortSignal }) => Promise<TResult>;\n affects?: (input: TInput, result: TResult) => string[];\n afterSuccess?: 'invalidate';\n};\n\ntype QueryState<T> = {\n data: T | null;\n error: {} | null;\n loading: boolean;\n refreshing: boolean;\n stale: boolean;\n consistency: QueryConsistency;\n staleReason: QueryStaleReason | null;\n};\n\ntype QuerySlot = {\n key: string;\n cell: QueryCell<unknown>;\n};\n\ntype QueryDefinitionField = 'fetch' | 'isConsistent' | 'reconcile';\n\nconst RECONCILE_MAX_ATTEMPTS = 3;\nconst RECONCILE_RETRY_DELAY_MS = 25;\nconst globalQueryCache = new Map<string, QueryCell<unknown>>();\nconst querySlotsByInstance = new WeakMap<\n ComponentInstance,\n Map<number, QuerySlot>\n>();\nconst mutationSlotsByInstance = new WeakMap<\n ComponentInstance,\n Map<number, MutationCell<unknown, unknown>>\n>();\nconst queryCleanupRegistered = new WeakSet<ComponentInstance>();\nconst mutationCleanupRegistered = new WeakSet<ComponentInstance>();\n\nfunction createReadableSource(): ReadableSource<unknown> {\n return (() => undefined) as ReadableSource<unknown>;\n}\n\nfunction getQueryCache(): Map<string, QueryCell<unknown>> {\n return (\n (getRenderContext()?.queryCache as Map<\n string,\n QueryCell<unknown>\n > | null) ?? globalQueryCache\n );\n}\n\nfunction getQuerySlotStore(\n instance: ComponentInstance\n): Map<number, QuerySlot> {\n let store = querySlotsByInstance.get(instance);\n if (!store) {\n store = new Map();\n querySlotsByInstance.set(instance, store);\n }\n return store;\n}\n\nfunction getMutationSlotStore(\n instance: ComponentInstance\n): Map<number, MutationCell<unknown, unknown>> {\n let store = mutationSlotsByInstance.get(instance);\n if (!store) {\n store = new Map();\n mutationSlotsByInstance.set(instance, store);\n }\n return store;\n}\n\nfunction ensureQueryCleanup(instance: ComponentInstance): void {\n if (queryCleanupRegistered.has(instance)) {\n return;\n }\n\n queryCleanupRegistered.add(instance);\n instance.cleanupFns.push(() => {\n const slots = querySlotsByInstance.get(instance);\n if (!slots) {\n queryCleanupRegistered.delete(instance);\n return;\n }\n\n for (const [hookIndex, slot] of slots) {\n slot.cell.detach(instance, hookIndex);\n }\n\n slots.clear();\n querySlotsByInstance.delete(instance);\n queryCleanupRegistered.delete(instance);\n });\n}\n\nfunction ensureMutationCleanup(instance: ComponentInstance): void {\n if (mutationCleanupRegistered.has(instance)) {\n return;\n }\n\n mutationCleanupRegistered.add(instance);\n instance.cleanupFns.push(() => {\n const slots = mutationSlotsByInstance.get(instance);\n if (!slots) {\n mutationCleanupRegistered.delete(instance);\n return;\n }\n\n for (const cell of slots.values()) {\n cell.abort();\n }\n\n slots.clear();\n mutationSlotsByInstance.delete(instance);\n mutationCleanupRegistered.delete(instance);\n });\n}\n\nfunction notifySource(source: ReadableSource<unknown>): void {\n markReadableDerivedSubscribersDirty(source);\n markReactivePropsDirtySource(source);\n notifyReadableReaders(source);\n}\n\nfunction isAbortError(error: unknown, signal: AbortSignal): boolean {\n return (\n signal.aborted ||\n (error instanceof Error && error.name === 'AbortError') ||\n (typeof DOMException !== 'undefined' &&\n error instanceof DOMException &&\n error.name === 'AbortError')\n );\n}\n\nfunction normalizeAsyncDataError(error: unknown, fallbackMessage: string): {} {\n return error ?? new Error(fallbackMessage);\n}\n\nfunction invalidateQueries(prefix: string, markPendingWrite: boolean): void {\n const cache = getQueryCache();\n\n for (const [key, query] of cache) {\n if (!key.startsWith(prefix)) {\n continue;\n }\n\n if (markPendingWrite) {\n query.markPendingWrite();\n }\n\n void query.refresh();\n }\n}\n\nclass QueryCell<T> {\n private readonly source = createReadableSource();\n private readonly key: string;\n private readonly cache: Map<string, QueryCell<unknown>>;\n private options: QueryOptions<T>;\n private controller: AbortController | null = null;\n private generation = 0;\n private startQueued = false;\n private pendingRefresh: Promise<void> | null = null;\n private pendingRefreshResolve: (() => void) | null = null;\n private reconcileAttemptCount = 0;\n private destroyed = false;\n private ownerCount = 0;\n private readonly owners = new Map<ComponentInstance, Set<number>>();\n private readonly warnedDefinitionConflictKeys = new Set<string>();\n\n private state: QueryState<T> = {\n data: null,\n error: null,\n loading: true,\n refreshing: false,\n stale: false,\n consistency: 'fresh',\n staleReason: null,\n };\n\n constructor(\n options: QueryOptions<T>,\n key: string,\n cache: Map<string, QueryCell<unknown>>\n ) {\n this.options = options;\n this.key = key;\n this.cache = cache;\n }\n\n attach(instance: ComponentInstance, hookIndex: number): void {\n let hooks = this.owners.get(instance);\n if (!hooks) {\n hooks = new Set();\n this.owners.set(instance, hooks);\n }\n\n if (hooks.has(hookIndex)) {\n return;\n }\n\n hooks.add(hookIndex);\n this.ownerCount += 1;\n }\n\n detach(instance: ComponentInstance, hookIndex: number): void {\n const hooks = this.owners.get(instance);\n if (!hooks || !hooks.delete(hookIndex)) {\n return;\n }\n\n this.ownerCount -= 1;\n if (hooks.size === 0) {\n this.owners.delete(instance);\n }\n\n if (this.ownerCount <= 0) {\n this.destroy();\n }\n }\n\n warnOnConflictingDefinition(options: QueryOptions<T>): void {\n const conflicts = this.getDefinitionConflicts(options);\n if (conflicts.length === 0) {\n return;\n }\n\n const conflictKey = conflicts.join(',');\n if (this.warnedDefinitionConflictKeys.has(conflictKey)) {\n return;\n }\n\n this.warnedDefinitionConflictKeys.add(conflictKey);\n\n const callbackLabel =\n conflicts.length === 1\n ? `callback \\`${conflicts[0]}\\``\n : `callbacks ${conflicts.map((field) => `\\`${field}\\``).join(', ')}`;\n\n logger.warn(\n `[askr] Conflicting shared query definition for key \"${this.key}\". ` +\n `Shared queries are canonical by key, so reuse the same ${callbackLabel} ` +\n 'for every reader of that key.'\n );\n }\n\n private destroy(): void {\n if (this.destroyed) {\n return;\n }\n\n this.destroyed = true;\n this.controller?.abort();\n this.controller = null;\n this.startQueued = false;\n this.reconcileAttemptCount = 0;\n this.ownerCount = 0;\n this.owners.clear();\n this.cache.delete(this.key);\n this.finishPendingRefresh();\n }\n\n private getDefinitionConflicts(\n options: QueryOptions<T>\n ): QueryDefinitionField[] {\n const conflicts: QueryDefinitionField[] = [];\n\n if (this.options.fetch !== options.fetch) {\n conflicts.push('fetch');\n }\n\n if (this.options.isConsistent !== options.isConsistent) {\n conflicts.push('isConsistent');\n }\n\n if (this.options.reconcile !== options.reconcile) {\n conflicts.push('reconcile');\n }\n\n return conflicts;\n }\n\n get data(): T | null {\n recordReadableRead(this.source);\n return this.state.data;\n }\n\n get error(): {} | null {\n recordReadableRead(this.source);\n return this.state.error;\n }\n\n get loading(): boolean {\n recordReadableRead(this.source);\n return this.state.loading;\n }\n\n get refreshing(): boolean {\n recordReadableRead(this.source);\n return this.state.refreshing;\n }\n\n get stale(): boolean {\n recordReadableRead(this.source);\n return this.state.stale;\n }\n\n get consistency(): QueryConsistency {\n recordReadableRead(this.source);\n return this.state.consistency;\n }\n\n get staleReason(): QueryStaleReason | null {\n recordReadableRead(this.source);\n return this.state.staleReason;\n }\n\n ensureStarted(): void {\n if (\n this.destroyed ||\n this.state.data !== null ||\n this.pendingRefresh ||\n this.startQueued\n ) {\n return;\n }\n\n this.queueStart('initial');\n }\n\n refresh(): Promise<void> {\n if (this.destroyed) {\n return Promise.resolve();\n }\n\n if (this.pendingRefresh) {\n return this.pendingRefresh;\n }\n\n this.queueStart('manual');\n return this.pendingRefresh ?? Promise.resolve();\n }\n\n markPendingWrite(): void {\n if (this.destroyed) {\n return;\n }\n\n if (this.state.data === null) {\n return;\n }\n\n this.setState({\n loading: false,\n error: null,\n refreshing: true,\n stale: true,\n consistency: 'pending-write',\n staleReason: null,\n });\n }\n\n private queueStart(\n reason: 'initial' | 'manual' | 'invalidate' | 'pending-write'\n ): void {\n if (this.destroyed) {\n return;\n }\n\n this.startQueued = true;\n this.pendingRefresh = new Promise<void>((resolve) => {\n this.pendingRefreshResolve = resolve;\n globalScheduler.enqueue(() => {\n this.startQueued = false;\n if (this.destroyed) {\n this.finishPendingRefresh();\n return;\n }\n void this.start(reason).finally(() => {\n this.finishPendingRefresh();\n });\n });\n });\n }\n\n private finishPendingRefresh(): void {\n const resolve = this.pendingRefreshResolve;\n this.pendingRefresh = null;\n this.pendingRefreshResolve = null;\n resolve?.();\n }\n\n private setState(next: Partial<QueryState<T>>): void {\n if (this.destroyed) {\n return;\n }\n\n this.state = {\n ...this.state,\n ...next,\n };\n notifySource(this.source);\n }\n\n private async start(\n reason: 'initial' | 'manual' | 'invalidate' | 'pending-write'\n ): Promise<void> {\n if (this.destroyed) {\n return;\n }\n\n this.generation += 1;\n const generation = this.generation;\n\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n\n const hasData = this.state.data !== null;\n this.setState({\n loading: !hasData,\n refreshing: hasData,\n stale: hasData,\n consistency:\n reason === 'pending-write'\n ? 'pending-write'\n : hasData\n ? 'refreshing'\n : 'fresh',\n error: null,\n staleReason: null,\n });\n\n let nextData: T;\n try {\n nextData = await this.options.fetch({ signal: controller.signal });\n } catch (error) {\n if (\n this.destroyed ||\n this.generation !== generation ||\n this.controller !== controller\n ) {\n return;\n }\n\n if (isAbortError(error, controller.signal)) {\n this.setState(\n hasData\n ? {\n loading: false,\n refreshing: false,\n stale: true,\n consistency: 'stale',\n error: null,\n staleReason: 'aborted',\n }\n : {\n loading: true,\n refreshing: false,\n stale: false,\n consistency: 'fresh',\n error: null,\n staleReason: null,\n }\n );\n return;\n }\n\n this.setState({\n loading: false,\n refreshing: false,\n stale: true,\n consistency: 'stale',\n error: normalizeAsyncDataError(error, 'Unknown query error'),\n staleReason: 'error',\n });\n return;\n }\n\n if (\n this.destroyed ||\n this.generation !== generation ||\n this.controller !== controller\n ) {\n return;\n }\n\n const isConsistent = this.options.isConsistent?.(nextData) ?? true;\n if (!isConsistent) {\n this.setState({\n data: nextData,\n loading: false,\n refreshing: false,\n stale: true,\n consistency: 'stale',\n staleReason: 'inconsistent',\n });\n await this.reconcile(nextData);\n return;\n }\n\n this.reconcileAttemptCount = 0;\n this.setState({\n data: nextData,\n loading: false,\n refreshing: false,\n stale: false,\n consistency: 'fresh',\n error: null,\n staleReason: null,\n });\n }\n\n private async reconcile(data: T): Promise<void> {\n const shouldRetry =\n this.options.reconcile?.(data, { key: this.options.key }) ?? false;\n\n if (!shouldRetry || this.destroyed) {\n return;\n }\n\n this.reconcileAttemptCount += 1;\n if (this.reconcileAttemptCount > RECONCILE_MAX_ATTEMPTS) {\n this.setState({\n consistency: 'stale',\n refreshing: false,\n staleReason: 'inconsistent',\n });\n return;\n }\n\n await new Promise<void>((resolve) =>\n setTimeout(resolve, RECONCILE_RETRY_DELAY_MS)\n );\n if (this.destroyed || this.state.consistency === 'fresh') {\n return;\n }\n\n await this.refresh();\n }\n}\n\nclass MutationCell<TInput, TResult> {\n private readonly source = createReadableSource();\n private action: MutationOptions<TInput, TResult>['action'];\n private affects?: MutationOptions<TInput, TResult>['affects'];\n private afterSuccess?: MutationOptions<TInput, TResult>['afterSuccess'];\n private controller: AbortController | null = null;\n private generation = 0;\n\n private state: MutationRecord<TResult> = {\n status: 'idle',\n error: null,\n result: null,\n };\n\n constructor(options: MutationOptions<TInput, TResult>) {\n this.action = options.action;\n this.affects = options.affects;\n this.afterSuccess = options.afterSuccess;\n }\n\n setOptions(options: MutationOptions<TInput, TResult>): void {\n this.action = options.action;\n this.affects = options.affects;\n this.afterSuccess = options.afterSuccess;\n }\n\n get status(): 'idle' | 'pending' | 'success' | 'error' {\n recordReadableRead(this.source);\n return this.state.status;\n }\n\n get pending(): boolean {\n recordReadableRead(this.source);\n return this.state.status === 'pending';\n }\n\n get error(): {} | null {\n recordReadableRead(this.source);\n return this.state.error;\n }\n\n get result(): TResult | null {\n recordReadableRead(this.source);\n return this.state.result;\n }\n\n private setState(next: Partial<MutationRecord<TResult>>): void {\n this.state = {\n ...this.state,\n ...next,\n };\n notifySource(this.source);\n }\n\n async execute(input: TInput): Promise<TResult> {\n this.generation += 1;\n const generation = this.generation;\n\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n\n this.setState({ status: 'pending', error: null, result: null });\n\n let result: TResult;\n try {\n result = await this.action(input, { signal: controller.signal });\n } catch (error) {\n if (this.generation !== generation || this.controller !== controller) {\n throw error;\n }\n\n if (isAbortError(error, controller.signal)) {\n this.setState({ status: 'idle', error: null });\n throw error;\n }\n\n this.setState({\n status: 'error',\n error: normalizeAsyncDataError(error, 'Unknown mutation error'),\n });\n throw error;\n }\n\n if (this.generation !== generation || this.controller !== controller) {\n return result;\n }\n\n this.setState({ status: 'success', error: null, result });\n\n if (this.afterSuccess === 'invalidate') {\n const prefixes = this.affects?.(input, result) ?? [];\n for (const prefix of new Set(prefixes)) {\n invalidateQueries(prefix, true);\n }\n }\n\n return result;\n }\n\n abort(): void {\n if (this.state.status !== 'pending') {\n return;\n }\n\n this.generation += 1;\n this.controller?.abort();\n this.controller = null;\n this.setState({ status: 'idle', error: null, result: null });\n }\n\n reset(): void {\n this.generation += 1;\n this.controller?.abort();\n this.controller = null;\n this.setState({ status: 'idle', error: null, result: null });\n }\n}\n\nexport function createQuery<T extends {}>(options: QueryOptions<T>): Query<T> {\n const instance = getCurrentComponentInstance();\n const cache = getQueryCache();\n if (!instance) {\n let cell = cache.get(options.key) as QueryCell<T> | undefined;\n if (!cell) {\n cell = new QueryCell(options, options.key, cache);\n cache.set(options.key, cell as QueryCell<unknown>);\n cell.ensureStarted();\n } else {\n cell.warnOnConflictingDefinition(options);\n }\n return cell as unknown as Query<T>;\n }\n\n const hookIndex = claimHookIndex(instance, 'query');\n ensureQueryCleanup(instance);\n\n const slotStore = getQuerySlotStore(instance);\n const existingSlot = slotStore.get(hookIndex);\n if (existingSlot && existingSlot.key === options.key) {\n (existingSlot.cell as QueryCell<T>).warnOnConflictingDefinition(options);\n return existingSlot.cell as unknown as Query<T>;\n }\n\n if (existingSlot) {\n existingSlot.cell.detach(instance, hookIndex);\n }\n\n let cell = cache.get(options.key) as QueryCell<T> | undefined;\n if (!cell) {\n cell = new QueryCell(options, options.key, cache);\n cache.set(options.key, cell as QueryCell<unknown>);\n cell.ensureStarted();\n } else {\n cell.warnOnConflictingDefinition(options);\n }\n\n slotStore.set(hookIndex, {\n key: options.key,\n cell: cell as QueryCell<unknown>,\n });\n cell.attach(instance, hookIndex);\n return cell as unknown as Query<T>;\n}\n\nexport function invalidate(prefix: string): void {\n invalidateQueries(prefix, false);\n}\n\nexport function createMutation<TInput, TResult>(\n options: MutationOptions<TInput, TResult>\n): Mutation<TInput, TResult> {\n const instance = getCurrentComponentInstance();\n\n if (!instance) {\n return new MutationCell(options) as unknown as Mutation<TInput, TResult>;\n }\n\n const hookIndex = claimHookIndex(instance, 'mutation');\n ensureMutationCleanup(instance);\n\n const slotStore = getMutationSlotStore(instance);\n const existing = slotStore.get(hookIndex) as\n | MutationCell<TInput, TResult>\n | undefined;\n if (existing) {\n existing.setOptions(options);\n return existing as unknown as Mutation<TInput, TResult>;\n }\n\n const created = new MutationCell(options);\n slotStore.set(hookIndex, created as MutationCell<unknown, unknown>);\n return created as unknown as Mutation<TInput, TResult>;\n}\n"],"mappings":";;;;;;AAsLA,MAAM,yBAAyB;AAC/B,MAAM,2BAA2B;AACjC,MAAM,mCAAmB,IAAI,IAAgC;AAC7D,MAAM,uCAAuB,IAAI,QAG/B;AACF,MAAM,0CAA0B,IAAI,QAGlC;AACF,MAAM,yCAAyB,IAAI,QAA2B;AAC9D,MAAM,4CAA4B,IAAI,QAA2B;AAEjE,SAAS,uBAAgD;CACvD,cAAc;AAChB;AAEA,SAAS,gBAAiD;CACxD,OACG,iBAAiB,GAAG,cAGR;AAEjB;AAEA,SAAS,kBACP,UACwB;CACxB,IAAI,QAAQ,qBAAqB,IAAI,QAAQ;CAC7C,IAAI,CAAC,OAAO;EACV,wBAAQ,IAAI,IAAI;EAChB,qBAAqB,IAAI,UAAU,KAAK;CAC1C;CACA,OAAO;AACT;AAEA,SAAS,qBACP,UAC6C;CAC7C,IAAI,QAAQ,wBAAwB,IAAI,QAAQ;CAChD,IAAI,CAAC,OAAO;EACV,wBAAQ,IAAI,IAAI;EAChB,wBAAwB,IAAI,UAAU,KAAK;CAC7C;CACA,OAAO;AACT;AAEA,SAAS,mBAAmB,UAAmC;CAC7D,IAAI,uBAAuB,IAAI,QAAQ,GACrC;CAGF,uBAAuB,IAAI,QAAQ;CACnC,SAAS,WAAW,WAAW;EAC7B,MAAM,QAAQ,qBAAqB,IAAI,QAAQ;EAC/C,IAAI,CAAC,OAAO;GACV,uBAAuB,OAAO,QAAQ;GACtC;EACF;EAEA,KAAK,MAAM,CAAC,WAAW,SAAS,OAC9B,KAAK,KAAK,OAAO,UAAU,SAAS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KAAK,4BAA4B,OAAO;CAG1C,UAAU,IAAI,WAAW;EACvB,KAAK,QAAQ;EACP;CACR,CAAC;CACD,KAAK,OAAO,UAAU,SAAS;CAC/B,OAAO;AACT;AAEA,SAAgB,WAAW,QAAsB;CAC/C,kBAAkB,QAAQ,KAAK;AACjC;AAEA,SAAgB,eACd,SAC2B;CAC3B,MAAM,WAAW,4BAA4B;CAE7C,IAAI,CAAC,UACH,OAAO,IAAI,aAAa,OAAO;CAGjC,MAAM,YAAY,eAAe,UAAU,UAAU;CACrD,sBAAsB,QAAQ;CAE9B,MAAM,YAAY,qBAAqB,QAAQ;CAC/C,MAAM,WAAW,UAAU,IAAI,SAAS;CAGxC,IAAI,UAAU;EACZ,SAAS,WAAW,OAAO;EAC3B,OAAO;CACT;CAEA,MAAM,UAAU,IAAI,aAAa,OAAO;CACxC,UAAU,IAAI,WAAW,OAAyC;CAClE,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/data/index.ts"],"sourcesContent":["import { globalScheduler } from '../runtime/scheduler';\nimport {\n claimHookIndex,\n getCurrentComponentInstance,\n type ComponentInstance,\n} from '../runtime/component';\nimport {\n markReadableDerivedSubscribersDirty,\n markReactivePropsDirtySource,\n notifyReadableReaders,\n recordReadableRead,\n type ReadableSource,\n} from '../runtime/readable';\nimport { getRenderContext } from '../ssr/context';\nimport { logger } from '../dev/logger';\nimport { emitInvalidation } from './invalidation-listeners';\nimport {\n documentVisible,\n routeActive,\n timer,\n windowFocused,\n type ActivityPredicate,\n} from '../runtime/operations';\n\nexport type QueryConsistency =\n | 'fresh'\n | 'stale'\n | 'refreshing'\n | 'pending-write';\n\nexport type QueryStaleReason = 'aborted' | 'error' | 'inconsistent';\n\nexport interface InvalidateOptions {\n markPendingWrite?: boolean;\n}\n\nexport interface InvalidateOnIntervalOptions extends InvalidateOptions {\n intervalMs: number;\n activeOn?: string | readonly string[];\n visibleOnly?: boolean;\n focusedOnly?: boolean;\n}\n\nexport type QueryKeyPart =\n | string\n | number\n | boolean\n | null\n | undefined\n | readonly QueryKeyPart[]\n | { readonly [key: string]: QueryKeyPart };\n\nexport interface QueryScope {\n key(...parts: QueryKeyPart[]): string;\n prefix(...parts: QueryKeyPart[]): string;\n invalidate(parts: readonly QueryKeyPart[], options?: InvalidateOptions): void;\n}\n\ntype QueryControls = {\n refresh(): Promise<void>;\n};\n\ntype QueryLoading = {\n data: null;\n error: null;\n loading: true;\n refreshing: false;\n stale: false;\n consistency: 'fresh';\n staleReason: null;\n};\n\ntype QueryFresh<T> = {\n data: T;\n error: null;\n loading: false;\n refreshing: false;\n stale: false;\n consistency: 'fresh';\n staleReason: null;\n};\n\ntype QueryRefreshing<T> = {\n data: T;\n error: null;\n loading: false;\n refreshing: true;\n stale: true;\n consistency: 'refreshing';\n staleReason: null;\n};\n\ntype QueryPendingWrite<T> = {\n data: T;\n error: null;\n loading: false;\n refreshing: true;\n stale: true;\n consistency: 'pending-write';\n staleReason: null;\n};\n\ntype QueryStaleValue<T> = {\n data: T;\n error: null;\n loading: false;\n refreshing: false;\n stale: true;\n consistency: 'stale';\n staleReason: 'aborted' | 'inconsistent';\n};\n\ntype QueryStaleErrorWithValue<T> = {\n data: T;\n error: {};\n loading: false;\n refreshing: false;\n stale: true;\n consistency: 'stale';\n staleReason: 'error';\n};\n\ntype QueryStaleError = {\n data: null;\n error: {};\n loading: false;\n refreshing: false;\n stale: true;\n consistency: 'stale';\n staleReason: 'error';\n};\n\nexport type Query<T extends {}> = QueryControls &\n (\n | QueryLoading\n | QueryFresh<T>\n | QueryRefreshing<T>\n | QueryPendingWrite<T>\n | QueryStaleValue<T>\n | QueryStaleErrorWithValue<T>\n | QueryStaleError\n );\n\ntype MutationControls<TInput, TResult> = {\n execute(input: TInput): Promise<TResult>;\n abort(): void;\n reset(): void;\n};\n\ntype MutationIdle = {\n status: 'idle';\n pending: false;\n error: null;\n result: null;\n};\n\ntype MutationPending = {\n status: 'pending';\n pending: true;\n error: null;\n result: null;\n};\n\ntype MutationSuccess<TResult> = {\n status: 'success';\n pending: false;\n error: null;\n result: TResult;\n};\n\ntype MutationError = {\n status: 'error';\n pending: false;\n error: {};\n result: null;\n};\n\nexport type Mutation<TInput, TResult> = MutationControls<TInput, TResult> &\n (MutationIdle | MutationPending | MutationSuccess<TResult> | MutationError);\n\ntype MutationRecord<TResult> = {\n status: 'idle' | 'pending' | 'success' | 'error';\n error: {} | null;\n result: TResult | null;\n};\n\ntype QueryOptions<T> = {\n key: string;\n fetch: (ctx: { signal: AbortSignal }) => Promise<T>;\n isConsistent?: (data: T) => boolean;\n reconcile?: (data: T, ctx: { key: string }) => Promise<boolean> | boolean;\n};\n\ntype MutationOptions<TInput, TResult> = {\n action: (input: TInput, ctx: { signal: AbortSignal }) => Promise<TResult>;\n affects?: (input: TInput, result: TResult) => string[];\n afterSuccess?: 'invalidate';\n};\n\ntype QueryState<T> = {\n data: T | null;\n error: {} | null;\n loading: boolean;\n refreshing: boolean;\n stale: boolean;\n consistency: QueryConsistency;\n staleReason: QueryStaleReason | null;\n};\n\ntype QuerySlot = {\n key: string;\n cell: QueryCell<unknown>;\n};\n\ntype QueryDefinitionField = 'fetch' | 'isConsistent' | 'reconcile';\n\nconst RECONCILE_MAX_ATTEMPTS = 3;\nconst RECONCILE_RETRY_DELAY_MS = 25;\nconst globalQueryCache = new Map<string, QueryCell<unknown>>();\nconst querySlotsByInstance = new WeakMap<\n ComponentInstance,\n Map<number, QuerySlot>\n>();\nconst mutationSlotsByInstance = new WeakMap<\n ComponentInstance,\n Map<number, MutationCell<unknown, unknown>>\n>();\nconst queryCleanupRegistered = new WeakSet<ComponentInstance>();\nconst mutationCleanupRegistered = new WeakSet<ComponentInstance>();\n\nfunction createReadableSource(): ReadableSource<unknown> {\n return (() => undefined) as ReadableSource<unknown>;\n}\n\nfunction getQueryCache(): Map<string, QueryCell<unknown>> {\n return (\n (getRenderContext()?.queryCache as Map<\n string,\n QueryCell<unknown>\n > | null) ?? globalQueryCache\n );\n}\n\nfunction getQuerySlotStore(\n instance: ComponentInstance\n): Map<number, QuerySlot> {\n let store = querySlotsByInstance.get(instance);\n if (!store) {\n store = new Map();\n querySlotsByInstance.set(instance, store);\n }\n return store;\n}\n\nfunction getMutationSlotStore(\n instance: ComponentInstance\n): Map<number, MutationCell<unknown, unknown>> {\n let store = mutationSlotsByInstance.get(instance);\n if (!store) {\n store = new Map();\n mutationSlotsByInstance.set(instance, store);\n }\n return store;\n}\n\nfunction ensureQueryCleanup(instance: ComponentInstance): void {\n if (queryCleanupRegistered.has(instance)) {\n return;\n }\n\n queryCleanupRegistered.add(instance);\n instance.cleanupFns.push(() => {\n const slots = querySlotsByInstance.get(instance);\n if (!slots) {\n queryCleanupRegistered.delete(instance);\n return;\n }\n\n for (const [hookIndex, slot] of slots) {\n slot.cell.detach(instance, hookIndex);\n }\n\n slots.clear();\n querySlotsByInstance.delete(instance);\n queryCleanupRegistered.delete(instance);\n });\n}\n\nfunction ensureMutationCleanup(instance: ComponentInstance): void {\n if (mutationCleanupRegistered.has(instance)) {\n return;\n }\n\n mutationCleanupRegistered.add(instance);\n instance.cleanupFns.push(() => {\n const slots = mutationSlotsByInstance.get(instance);\n if (!slots) {\n mutationCleanupRegistered.delete(instance);\n return;\n }\n\n for (const cell of slots.values()) {\n cell.abort();\n }\n\n slots.clear();\n mutationSlotsByInstance.delete(instance);\n mutationCleanupRegistered.delete(instance);\n });\n}\n\nfunction notifySource(source: ReadableSource<unknown>): void {\n markReadableDerivedSubscribersDirty(source);\n markReactivePropsDirtySource(source);\n notifyReadableReaders(source);\n}\n\nfunction isAbortError(error: unknown, signal: AbortSignal): boolean {\n return (\n signal.aborted ||\n (error instanceof Error && error.name === 'AbortError') ||\n (typeof DOMException !== 'undefined' &&\n error instanceof DOMException &&\n error.name === 'AbortError')\n );\n}\n\nfunction normalizeAsyncDataError(error: unknown, fallbackMessage: string): {} {\n return error ?? new Error(fallbackMessage);\n}\n\nfunction invalidateQueries(prefix: string, markPendingWrite: boolean): void {\n emitInvalidation({ prefix, markPendingWrite });\n\n const cache = getQueryCache();\n\n for (const [key, query] of cache) {\n if (!key.startsWith(prefix)) {\n continue;\n }\n\n if (markPendingWrite) {\n query.markPendingWrite();\n }\n\n void query.refresh();\n }\n}\n\nclass QueryCell<T> {\n private readonly source = createReadableSource();\n private readonly key: string;\n private readonly cache: Map<string, QueryCell<unknown>>;\n private options: QueryOptions<T>;\n private controller: AbortController | null = null;\n private generation = 0;\n private startQueued = false;\n private pendingRefresh: Promise<void> | null = null;\n private pendingRefreshResolve: (() => void) | null = null;\n private reconcileAttemptCount = 0;\n private destroyed = false;\n private ownerCount = 0;\n private readonly owners = new Map<ComponentInstance, Set<number>>();\n private readonly warnedDefinitionConflictKeys = new Set<string>();\n\n private state: QueryState<T> = {\n data: null,\n error: null,\n loading: true,\n refreshing: false,\n stale: false,\n consistency: 'fresh',\n staleReason: null,\n };\n\n constructor(\n options: QueryOptions<T>,\n key: string,\n cache: Map<string, QueryCell<unknown>>\n ) {\n this.options = options;\n this.key = key;\n this.cache = cache;\n }\n\n attach(instance: ComponentInstance, hookIndex: number): void {\n let hooks = this.owners.get(instance);\n if (!hooks) {\n hooks = new Set();\n this.owners.set(instance, hooks);\n }\n\n if (hooks.has(hookIndex)) {\n return;\n }\n\n hooks.add(hookIndex);\n this.ownerCount += 1;\n }\n\n detach(instance: ComponentInstance, hookIndex: number): void {\n const hooks = this.owners.get(instance);\n if (!hooks || !hooks.delete(hookIndex)) {\n return;\n }\n\n this.ownerCount -= 1;\n if (hooks.size === 0) {\n this.owners.delete(instance);\n }\n\n if (this.ownerCount <= 0) {\n this.destroy();\n }\n }\n\n warnOnConflictingDefinition(options: QueryOptions<T>): void {\n const conflicts = this.getDefinitionConflicts(options);\n if (conflicts.length === 0) {\n return;\n }\n\n const conflictKey = conflicts.join(',');\n if (this.warnedDefinitionConflictKeys.has(conflictKey)) {\n return;\n }\n\n this.warnedDefinitionConflictKeys.add(conflictKey);\n\n const callbackLabel =\n conflicts.length === 1\n ? `callback \\`${conflicts[0]}\\``\n : `callbacks ${conflicts.map((field) => `\\`${field}\\``).join(', ')}`;\n\n logger.warn(\n `[askr] Conflicting shared query definition for key \"${this.key}\". ` +\n `Shared queries are canonical by key, so reuse the same ${callbackLabel} ` +\n 'for every reader of that key.'\n );\n }\n\n private destroy(): void {\n if (this.destroyed) {\n return;\n }\n\n this.destroyed = true;\n this.controller?.abort();\n this.controller = null;\n this.startQueued = false;\n this.reconcileAttemptCount = 0;\n this.ownerCount = 0;\n this.owners.clear();\n this.cache.delete(this.key);\n this.finishPendingRefresh();\n }\n\n private getDefinitionConflicts(\n options: QueryOptions<T>\n ): QueryDefinitionField[] {\n const conflicts: QueryDefinitionField[] = [];\n\n if (this.options.fetch !== options.fetch) {\n conflicts.push('fetch');\n }\n\n if (this.options.isConsistent !== options.isConsistent) {\n conflicts.push('isConsistent');\n }\n\n if (this.options.reconcile !== options.reconcile) {\n conflicts.push('reconcile');\n }\n\n return conflicts;\n }\n\n get data(): T | null {\n recordReadableRead(this.source);\n return this.state.data;\n }\n\n get error(): {} | null {\n recordReadableRead(this.source);\n return this.state.error;\n }\n\n get loading(): boolean {\n recordReadableRead(this.source);\n return this.state.loading;\n }\n\n get refreshing(): boolean {\n recordReadableRead(this.source);\n return this.state.refreshing;\n }\n\n get stale(): boolean {\n recordReadableRead(this.source);\n return this.state.stale;\n }\n\n get consistency(): QueryConsistency {\n recordReadableRead(this.source);\n return this.state.consistency;\n }\n\n get staleReason(): QueryStaleReason | null {\n recordReadableRead(this.source);\n return this.state.staleReason;\n }\n\n ensureStarted(): void {\n if (\n this.destroyed ||\n this.state.data !== null ||\n this.pendingRefresh ||\n this.startQueued\n ) {\n return;\n }\n\n this.queueStart('initial');\n }\n\n refresh(): Promise<void> {\n if (this.destroyed) {\n return Promise.resolve();\n }\n\n if (this.pendingRefresh) {\n return this.pendingRefresh;\n }\n\n this.queueStart('manual');\n return this.pendingRefresh ?? Promise.resolve();\n }\n\n markPendingWrite(): void {\n if (this.destroyed) {\n return;\n }\n\n if (this.state.data === null) {\n return;\n }\n\n this.setState({\n loading: false,\n error: null,\n refreshing: true,\n stale: true,\n consistency: 'pending-write',\n staleReason: null,\n });\n }\n\n private queueStart(\n reason: 'initial' | 'manual' | 'invalidate' | 'pending-write'\n ): void {\n if (this.destroyed) {\n return;\n }\n\n this.startQueued = true;\n this.pendingRefresh = new Promise<void>((resolve) => {\n this.pendingRefreshResolve = resolve;\n globalScheduler.enqueue(() => {\n this.startQueued = false;\n if (this.destroyed) {\n this.finishPendingRefresh();\n return;\n }\n void this.start(reason).finally(() => {\n this.finishPendingRefresh();\n });\n });\n });\n }\n\n private finishPendingRefresh(): void {\n const resolve = this.pendingRefreshResolve;\n this.pendingRefresh = null;\n this.pendingRefreshResolve = null;\n resolve?.();\n }\n\n private setState(next: Partial<QueryState<T>>): void {\n if (this.destroyed) {\n return;\n }\n\n this.state = {\n ...this.state,\n ...next,\n };\n notifySource(this.source);\n }\n\n private async start(\n reason: 'initial' | 'manual' | 'invalidate' | 'pending-write'\n ): Promise<void> {\n if (this.destroyed) {\n return;\n }\n\n this.generation += 1;\n const generation = this.generation;\n\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n\n const hasData = this.state.data !== null;\n this.setState({\n loading: !hasData,\n refreshing: hasData,\n stale: hasData,\n consistency:\n reason === 'pending-write'\n ? 'pending-write'\n : hasData\n ? 'refreshing'\n : 'fresh',\n error: null,\n staleReason: null,\n });\n\n let nextData: T;\n try {\n nextData = await this.options.fetch({ signal: controller.signal });\n } catch (error) {\n if (\n this.destroyed ||\n this.generation !== generation ||\n this.controller !== controller\n ) {\n return;\n }\n\n if (isAbortError(error, controller.signal)) {\n this.setState(\n hasData\n ? {\n loading: false,\n refreshing: false,\n stale: true,\n consistency: 'stale',\n error: null,\n staleReason: 'aborted',\n }\n : {\n loading: true,\n refreshing: false,\n stale: false,\n consistency: 'fresh',\n error: null,\n staleReason: null,\n }\n );\n return;\n }\n\n this.setState({\n loading: false,\n refreshing: false,\n stale: true,\n consistency: 'stale',\n error: normalizeAsyncDataError(error, 'Unknown query error'),\n staleReason: 'error',\n });\n return;\n }\n\n if (\n this.destroyed ||\n this.generation !== generation ||\n this.controller !== controller\n ) {\n return;\n }\n\n const isConsistent = this.options.isConsistent?.(nextData) ?? true;\n if (!isConsistent) {\n this.setState({\n data: nextData,\n loading: false,\n refreshing: false,\n stale: true,\n consistency: 'stale',\n staleReason: 'inconsistent',\n });\n await this.reconcile(nextData);\n return;\n }\n\n this.reconcileAttemptCount = 0;\n this.setState({\n data: nextData,\n loading: false,\n refreshing: false,\n stale: false,\n consistency: 'fresh',\n error: null,\n staleReason: null,\n });\n }\n\n private async reconcile(data: T): Promise<void> {\n const shouldRetry =\n this.options.reconcile?.(data, { key: this.options.key }) ?? false;\n\n if (!shouldRetry || this.destroyed) {\n return;\n }\n\n this.reconcileAttemptCount += 1;\n if (this.reconcileAttemptCount > RECONCILE_MAX_ATTEMPTS) {\n this.setState({\n consistency: 'stale',\n refreshing: false,\n staleReason: 'inconsistent',\n });\n return;\n }\n\n await new Promise<void>((resolve) =>\n setTimeout(resolve, RECONCILE_RETRY_DELAY_MS)\n );\n if (this.destroyed || this.state.consistency === 'fresh') {\n return;\n }\n\n await this.refresh();\n }\n}\n\nclass MutationCell<TInput, TResult> {\n private readonly source = createReadableSource();\n private action: MutationOptions<TInput, TResult>['action'];\n private affects?: MutationOptions<TInput, TResult>['affects'];\n private afterSuccess?: MutationOptions<TInput, TResult>['afterSuccess'];\n private controller: AbortController | null = null;\n private generation = 0;\n\n private state: MutationRecord<TResult> = {\n status: 'idle',\n error: null,\n result: null,\n };\n\n constructor(options: MutationOptions<TInput, TResult>) {\n this.action = options.action;\n this.affects = options.affects;\n this.afterSuccess = options.afterSuccess;\n }\n\n setOptions(options: MutationOptions<TInput, TResult>): void {\n this.action = options.action;\n this.affects = options.affects;\n this.afterSuccess = options.afterSuccess;\n }\n\n get status(): 'idle' | 'pending' | 'success' | 'error' {\n recordReadableRead(this.source);\n return this.state.status;\n }\n\n get pending(): boolean {\n recordReadableRead(this.source);\n return this.state.status === 'pending';\n }\n\n get error(): {} | null {\n recordReadableRead(this.source);\n return this.state.error;\n }\n\n get result(): TResult | null {\n recordReadableRead(this.source);\n return this.state.result;\n }\n\n private setState(next: Partial<MutationRecord<TResult>>): void {\n this.state = {\n ...this.state,\n ...next,\n };\n notifySource(this.source);\n }\n\n async execute(input: TInput): Promise<TResult> {\n this.generation += 1;\n const generation = this.generation;\n\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n\n this.setState({ status: 'pending', error: null, result: null });\n\n let result: TResult;\n try {\n result = await this.action(input, { signal: controller.signal });\n } catch (error) {\n if (this.generation !== generation || this.controller !== controller) {\n throw error;\n }\n\n if (isAbortError(error, controller.signal)) {\n this.setState({ status: 'idle', error: null });\n throw error;\n }\n\n this.setState({\n status: 'error',\n error: normalizeAsyncDataError(error, 'Unknown mutation error'),\n });\n throw error;\n }\n\n if (this.generation !== generation || this.controller !== controller) {\n return result;\n }\n\n this.setState({ status: 'success', error: null, result });\n\n if (this.afterSuccess === 'invalidate') {\n const prefixes = this.affects?.(input, result) ?? [];\n for (const prefix of new Set(prefixes)) {\n invalidateQueries(prefix, true);\n }\n }\n\n return result;\n }\n\n abort(): void {\n if (this.state.status !== 'pending') {\n return;\n }\n\n this.generation += 1;\n this.controller?.abort();\n this.controller = null;\n this.setState({ status: 'idle', error: null, result: null });\n }\n\n reset(): void {\n this.generation += 1;\n this.controller?.abort();\n this.controller = null;\n this.setState({ status: 'idle', error: null, result: null });\n }\n}\n\nexport function createQuery<T extends {}>(options: QueryOptions<T>): Query<T> {\n const instance = getCurrentComponentInstance();\n const cache = getQueryCache();\n if (!instance) {\n let cell = cache.get(options.key) as QueryCell<T> | undefined;\n if (!cell) {\n cell = new QueryCell(options, options.key, cache);\n cache.set(options.key, cell as QueryCell<unknown>);\n cell.ensureStarted();\n } else {\n cell.warnOnConflictingDefinition(options);\n }\n return cell as unknown as Query<T>;\n }\n\n const hookIndex = claimHookIndex(instance, 'query');\n ensureQueryCleanup(instance);\n\n const slotStore = getQuerySlotStore(instance);\n const existingSlot = slotStore.get(hookIndex);\n if (existingSlot && existingSlot.key === options.key) {\n (existingSlot.cell as QueryCell<T>).warnOnConflictingDefinition(options);\n return existingSlot.cell as unknown as Query<T>;\n }\n\n if (existingSlot) {\n existingSlot.cell.detach(instance, hookIndex);\n }\n\n let cell = cache.get(options.key) as QueryCell<T> | undefined;\n if (!cell) {\n cell = new QueryCell(options, options.key, cache);\n cache.set(options.key, cell as QueryCell<unknown>);\n cell.ensureStarted();\n } else {\n cell.warnOnConflictingDefinition(options);\n }\n\n slotStore.set(hookIndex, {\n key: options.key,\n cell: cell as QueryCell<unknown>,\n });\n cell.attach(instance, hookIndex);\n return cell as unknown as Query<T>;\n}\n\nexport function invalidate(prefix: string, options?: InvalidateOptions): void {\n invalidateQueries(prefix, options?.markPendingWrite ?? false);\n}\n\nfunction serializeQueryKeyNumber(part: number): string {\n if (Number.isNaN(part)) {\n return 'NaN';\n }\n\n if (Object.is(part, -0)) {\n return '-0';\n }\n\n if (part === Infinity) {\n return 'Infinity';\n }\n\n if (part === -Infinity) {\n return '-Infinity';\n }\n\n return String(part);\n}\n\nfunction serializeQueryKeyPart(part: QueryKeyPart): string {\n if (typeof (part as unknown) === 'symbol') {\n throw new Error('[Askr] queryScope() key parts cannot be symbols.');\n }\n\n if (part === null) {\n return 'null';\n }\n\n if (part === undefined) {\n return 'undefined';\n }\n\n switch (typeof part) {\n case 'string':\n return `s=${encodeURIComponent(part)}`;\n case 'number':\n return `n=${serializeQueryKeyNumber(part)}`;\n case 'boolean':\n return `b=${part ? '1' : '0'}`;\n case 'object':\n if (Array.isArray(part)) {\n return `a[${part.map((item) => serializeQueryKeyPart(item)).join(',')}]`;\n }\n\n return `o{${Object.keys(part)\n .sort()\n .map(\n (key) =>\n `${encodeURIComponent(key)}=${serializeQueryKeyPart(part[key])}`\n )\n .join(',')}}`;\n default:\n return String(part);\n }\n}\n\nexport function queryScope(namespace: string): QueryScope {\n if (typeof namespace !== 'string' || namespace.trim().length === 0) {\n throw new Error('[Askr] queryScope() requires a non-empty namespace string.');\n }\n\n const build = (parts: readonly QueryKeyPart[]): string =>\n [namespace, ...parts].map(serializeQueryKeyPart).join(':') + ':';\n\n return {\n key(...parts) {\n return build(parts);\n },\n\n prefix(...parts) {\n return build(parts);\n },\n\n invalidate(parts, options) {\n invalidate(build(parts), options);\n },\n };\n}\n\nconst INVALIDATE_ON_INTERVAL_OPTIONS_ERROR =\n '[Askr] invalidateOnInterval() requires an options object with a finite numeric intervalMs.';\n\nexport function invalidateOnInterval(\n prefix: string,\n options: InvalidateOnIntervalOptions\n): void {\n if (\n !options ||\n typeof options !== 'object' ||\n typeof options.intervalMs !== 'number' ||\n !Number.isFinite(options.intervalMs)\n ) {\n throw new Error(INVALIDATE_ON_INTERVAL_OPTIONS_ERROR);\n }\n\n const when: ActivityPredicate[] = [];\n\n if (options.activeOn) {\n when.push(routeActive(options.activeOn));\n }\n\n if (options.visibleOnly) {\n when.push(documentVisible());\n }\n\n if (options.focusedOnly) {\n when.push(windowFocused());\n }\n\n timer(\n options.intervalMs,\n () => {\n invalidate(prefix, {\n markPendingWrite: options.markPendingWrite,\n });\n },\n when.length > 0 ? { when } : undefined\n );\n}\n\nexport function createMutation<TInput, TResult>(\n options: MutationOptions<TInput, TResult>\n): Mutation<TInput, TResult> {\n const instance = getCurrentComponentInstance();\n\n if (!instance) {\n return new MutationCell(options) as unknown as Mutation<TInput, TResult>;\n }\n\n const hookIndex = claimHookIndex(instance, 'mutation');\n ensureMutationCleanup(instance);\n\n const slotStore = getMutationSlotStore(instance);\n const existing = slotStore.get(hookIndex) as\n | MutationCell<TInput, TResult>\n | undefined;\n if (existing) {\n existing.setOptions(options);\n return existing as unknown as Mutation<TInput, TResult>;\n }\n\n const created = new MutationCell(options);\n slotStore.set(hookIndex, created as MutationCell<unkn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EAClC;CACF;AACF;AAEA,MAAM,uCACJ;AAEF,SAAgB,qBACd,QACA,SACM;CACN,IACE,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,eAAe,YAC9B,CAAC,OAAO,SAAS,QAAQ,UAAU,GAEnC,MAAM,IAAI,MAAM,oCAAoC;CAGtD,MAAM,OAA4B,CAAC;CAEnC,IAAI,QAAQ,UACV,KAAK,KAAK,YAAY,QAAQ,QAAQ,CAAC;CAGzC,IAAI,QAAQ,aACV,KAAK,KAAK,gBAAgB,CAAC;CAG7B,IAAI,QAAQ,aACV,KAAK,KAAK,cAAc,CAAC;CAG3B,MACE,QAAQ,kBACF;EACJ,WAAW,QAAQ,EACjB,kBAAkB,QAAQ,iBAC5B,CAAC;CACH,GACA,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,MAC/B;AACF;AAEA,SAAgB,eACd,SAC2B;CAC3B,MAAM,WAAW,4BAA4B;CAE7C,IAAI,CAAC,UACH,OAAO,IAAI,aAAa,OAAO;CAGjC,MAAM,YAAY,eAAe,UAAU,UAAU;CACrD,sBAAsB,QAAQ;CAE9B,MAAM,YAAY,qBAAqB,QAAQ;CAC/C,MAAM,WAAW,UAAU,IAAI,SAAS;CAGxC,IAAI,UAAU;EACZ,SAAS,WAAW,OAAO;EAC3B,OAAO;CACT;CAEA,MAAM,UAAU,IAAI,aAAa,OAAO;CACxC,UAAU,IAAI,WAAW,OAAyC;CAClE,OAAO;AACT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/data/invalidation-listeners.ts
|
|
2
|
+
const invalidationListeners = /* @__PURE__ */ new Set();
|
|
3
|
+
function addInvalidationListener(listener) {
|
|
4
|
+
invalidationListeners.add(listener);
|
|
5
|
+
return () => {
|
|
6
|
+
invalidationListeners.delete(listener);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function emitInvalidation(event) {
|
|
10
|
+
for (const listener of invalidationListeners) listener(event);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { addInvalidationListener, emitInvalidation };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=invalidation-listeners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidation-listeners.js","names":[],"sources":["../../src/data/invalidation-listeners.ts"],"sourcesContent":["export interface InvalidationEvent {\n prefix: string;\n markPendingWrite: boolean;\n}\n\ntype InvalidationListener = (event: InvalidationEvent) => void;\n\nconst invalidationListeners = new Set<InvalidationListener>();\n\nexport function addInvalidationListener(\n listener: InvalidationListener\n): () => void {\n invalidationListeners.add(listener);\n return () => {\n invalidationListeners.delete(listener);\n };\n}\n\nexport function emitInvalidation(event: InvalidationEvent): void {\n for (const listener of invalidationListeners) {\n listener(event);\n }\n}\n"],"mappings":";AAOA,MAAM,wCAAwB,IAAI,IAA0B;AAE5D,SAAgB,wBACd,UACY;CACZ,sBAAsB,IAAI,QAAQ;CAClC,aAAa;EACX,sBAAsB,OAAO,QAAQ;CACvC;AACF;AAEA,SAAgB,iBAAiB,OAAgC;CAC/D,KAAK,MAAM,YAAY,uBACrB,SAAS,KAAK;AAElB"}
|
package/dist/renderer/dom.js
CHANGED
|
@@ -11,7 +11,7 @@ import { isPromiseLike } from "../common/promise.js";
|
|
|
11
11
|
import "./env.js";
|
|
12
12
|
import { createMutableWrappedHandler, extractKey, getEventListenerKey, getEventListenerOptions, getRenderedAttributeName, isSkippedProp, parseEventName, parseEventProp, readElementClassName, removeRenderedAttribute, setRenderedAttribute, tagNamesEqualIgnoreCase, writeElementClassName } from "./utils.js";
|
|
13
13
|
import { keyedElements } from "./keyed.js";
|
|
14
|
-
import { cleanupComponent, createComponentInstance, getCurrentInstance, mountInstanceInline, renderComponentInline, warnUnusedStateReads } from "../runtime/component.js";
|
|
14
|
+
import { captureInlineRenderSnapshot, cleanupComponent, createComponentInstance, getCurrentInstance, mountInstanceInline, renderComponentInline, warnUnusedStateReads } from "../runtime/component.js";
|
|
15
15
|
import { addDelegatedListener, getDelegatedHandlerForElement, getDelegatedHandlersForElement, isDelegatedEvent, isEventDelegationEnabled, removeDelegatedListener, updateDelegatedListener } from "../runtime/events.js";
|
|
16
16
|
import { REACTIVE_CHILDREN_KEY, elementListeners, elementReactivePropsCleanup, removeAllListeners, removeElementListeners, removeElementReactiveProps, teardownNodeSubtree } from "./cleanup.js";
|
|
17
17
|
import { ROUTE_ROOT_COMPONENT } from "../common/router-internal.js";
|
|
@@ -309,7 +309,7 @@ function createReactiveChildBoundaryHost(el) {
|
|
|
309
309
|
function disposeReactiveChildBoundaryNodes(nodes) {
|
|
310
310
|
for (const node of nodes) {
|
|
311
311
|
if (node.parentNode) node.parentNode.removeChild(node);
|
|
312
|
-
|
|
312
|
+
teardownNodeSubtree(node);
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
function syncReactiveChildExpectedNodes(el, expectedNodes) {
|
|
@@ -317,7 +317,7 @@ function syncReactiveChildExpectedNodes(el, expectedNodes) {
|
|
|
317
317
|
for (let node = el.firstChild; node;) {
|
|
318
318
|
const next = node.nextSibling;
|
|
319
319
|
if (!expectedNodeSet.has(node)) {
|
|
320
|
-
|
|
320
|
+
teardownNodeSubtree(node);
|
|
321
321
|
el.removeChild(node);
|
|
322
322
|
}
|
|
323
323
|
node = next;
|
|
@@ -341,7 +341,7 @@ function commitReactiveChildBoundaryEntryNodes(el, entry) {
|
|
|
341
341
|
}
|
|
342
342
|
const dom = entry.scope.dom;
|
|
343
343
|
if (dom?.parentNode === el) {
|
|
344
|
-
|
|
344
|
+
teardownNodeSubtree(dom);
|
|
345
345
|
el.removeChild(dom);
|
|
346
346
|
}
|
|
347
347
|
entry.scope.dom = void 0;
|
|
@@ -503,7 +503,7 @@ function setupReactiveChildBoundary(el, childFn) {
|
|
|
503
503
|
return;
|
|
504
504
|
}
|
|
505
505
|
if (dom?.parentNode === el) {
|
|
506
|
-
|
|
506
|
+
teardownNodeSubtree(dom);
|
|
507
507
|
el.removeChild(dom);
|
|
508
508
|
}
|
|
509
509
|
},
|
|
@@ -565,7 +565,7 @@ function setupReactiveChildBoundarySequence(el, source) {
|
|
|
565
565
|
continue;
|
|
566
566
|
}
|
|
567
567
|
if (dom?.parentNode === el) {
|
|
568
|
-
|
|
568
|
+
teardownNodeSubtree(dom);
|
|
569
569
|
el.removeChild(dom);
|
|
570
570
|
}
|
|
571
571
|
}
|
|
@@ -1202,9 +1202,7 @@ function materializeComponentResultNode(childInstance, result, parentNamespace)
|
|
|
1202
1202
|
placeholder.__ASKR_INSTANCE = childInstance;
|
|
1203
1203
|
} catch {}
|
|
1204
1204
|
childInstance._placeholder = placeholder;
|
|
1205
|
-
childInstance
|
|
1206
|
-
childInstance.notifyUpdate = childInstance._enqueueRun;
|
|
1207
|
-
childInstance.target = null;
|
|
1205
|
+
mountInstanceInline(childInstance, null);
|
|
1208
1206
|
return placeholder;
|
|
1209
1207
|
}
|
|
1210
1208
|
const host = document.createElement("div");
|
|
@@ -1221,6 +1219,7 @@ function resolveNestedComponentResult(result, snapshot, parentInstance) {
|
|
|
1221
1219
|
const nestedSnapshot = getVNodeContextFrame(currentResult) ?? activeSnapshot;
|
|
1222
1220
|
const nestedInstance = createComponentInstance(nextComponentInstanceId(), currentResult.type, currentResult.props ?? {}, null);
|
|
1223
1221
|
nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
|
|
1222
|
+
nestedInstance.parentInstance = parentInstance;
|
|
1224
1223
|
nestedInstance.portalScope = parentInstance?.portalScope ?? nestedInstance.portalScope;
|
|
1225
1224
|
inheritComponentCleanupStrict(nestedInstance);
|
|
1226
1225
|
if (nestedSnapshot) nestedInstance.ownerFrame = nestedSnapshot;
|
|
@@ -1233,21 +1232,25 @@ function resolveNestedComponentResult(result, snapshot, parentInstance) {
|
|
|
1233
1232
|
}
|
|
1234
1233
|
return currentResult;
|
|
1235
1234
|
}
|
|
1236
|
-
function resolveHostNestedComponentResult(host, retainedInstance, result, snapshot) {
|
|
1235
|
+
function resolveHostNestedComponentResult(host, retainedInstance, result, snapshot, retainedHostInstances) {
|
|
1237
1236
|
let currentResult = result;
|
|
1238
1237
|
let activeSnapshot = snapshot;
|
|
1239
1238
|
let depth = 0;
|
|
1240
1239
|
const retainedInstances = new Set([retainedInstance]);
|
|
1240
|
+
if (retainedHostInstances) for (const instance of retainedHostInstances) retainedInstances.add(instance);
|
|
1241
1241
|
const createdInstances = [];
|
|
1242
1242
|
while (_isDOMElement(currentResult) && typeof currentResult.type === "function" && depth < 16) {
|
|
1243
1243
|
const nestedSnapshot = getVNodeContextFrame(currentResult) ?? activeSnapshot;
|
|
1244
1244
|
let nestedInstance = findHostInstanceByType(host, currentResult.type);
|
|
1245
|
+
const hadNestedInstance = !!nestedInstance;
|
|
1245
1246
|
if (!nestedInstance) {
|
|
1246
1247
|
nestedInstance = createComponentInstance(nextComponentInstanceId(), currentResult.type, currentResult.props ?? {}, null);
|
|
1247
1248
|
createdInstances.push(nestedInstance);
|
|
1248
1249
|
}
|
|
1250
|
+
if (hadNestedInstance) captureInlineRenderSnapshot(nestedInstance);
|
|
1249
1251
|
setVNodeComponentInstance(currentResult, nestedInstance);
|
|
1250
1252
|
nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
|
|
1253
|
+
nestedInstance.parentInstance = retainedInstance;
|
|
1251
1254
|
nestedInstance.portalScope = retainedInstance.portalScope ?? nestedInstance.portalScope;
|
|
1252
1255
|
inheritComponentCleanupStrict(nestedInstance);
|
|
1253
1256
|
nestedInstance.props = (currentResult.props ?? {}) || {};
|
|
@@ -1262,7 +1265,9 @@ function resolveHostNestedComponentResult(host, retainedInstance, result, snapsh
|
|
|
1262
1265
|
}
|
|
1263
1266
|
const previousInstances = host.__ASKR_INSTANCES ?? [];
|
|
1264
1267
|
for (const instance of previousInstances) if (!retainedInstances.has(instance)) cleanupComponent(instance);
|
|
1265
|
-
|
|
1268
|
+
const nextHostInstances = previousInstances.filter((instance) => retainedInstances.has(instance));
|
|
1269
|
+
for (const instance of retainedInstances) if (instance.target === host && !nextHostInstances.includes(instance)) nextHostInstances.push(instance);
|
|
1270
|
+
host.__ASKR_INSTANCES = nextHostInstances;
|
|
1266
1271
|
host.__ASKR_INSTANCE = host.__ASKR_INSTANCES[0] ?? retainedInstance;
|
|
1267
1272
|
for (const instance of createdInstances) mountInstanceInline(instance, host);
|
|
1268
1273
|
return currentResult;
|
|
@@ -1275,7 +1280,9 @@ function resolveWrapperHostResult(host, result, snapshot) {
|
|
|
1275
1280
|
const nestedSnapshot = getVNodeContextFrame(currentResult) ?? activeSnapshot;
|
|
1276
1281
|
const nestedInstance = findHostInstanceByType(host, currentResult.type);
|
|
1277
1282
|
if (!nestedInstance) break;
|
|
1283
|
+
captureInlineRenderSnapshot(nestedInstance);
|
|
1278
1284
|
nestedInstance.props = (currentResult.props ?? {}) || {};
|
|
1285
|
+
nestedInstance.parentInstance = getCurrentInstance();
|
|
1279
1286
|
nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
|
|
1280
1287
|
nestedInstance.portalScope = getCurrentInstance()?.portalScope ?? nestedInstance.portalScope;
|
|
1281
1288
|
inheritComponentCleanupStrict(nestedInstance);
|
|
@@ -1301,7 +1308,7 @@ function normalizeComponentChildren(result) {
|
|
|
1301
1308
|
}
|
|
1302
1309
|
return [result];
|
|
1303
1310
|
}
|
|
1304
|
-
function syncComponentElement(currentDom, node, type, props, parentNamespace, forceChildrenUpdate = false) {
|
|
1311
|
+
function syncComponentElement(currentDom, node, type, props, parentNamespace, forceChildrenUpdate = false, retainedHostInstances) {
|
|
1305
1312
|
const existingHost = currentDom instanceof Element ? currentDom : null;
|
|
1306
1313
|
const existingInstance = existingHost ? findHostInstanceByType(existingHost, type) : null;
|
|
1307
1314
|
if (!existingHost) return null;
|
|
@@ -1326,7 +1333,7 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
|
|
|
1326
1333
|
warnUnusedStateReads(hydrationInstance);
|
|
1327
1334
|
return existingHost;
|
|
1328
1335
|
}
|
|
1329
|
-
const resolvedResult = resolveHostNestedComponentResult(existingHost, hydrationInstance, scopedResult, snapshot ?? null);
|
|
1336
|
+
const resolvedResult = resolveHostNestedComponentResult(existingHost, hydrationInstance, scopedResult, snapshot ?? null, retainedHostInstances);
|
|
1330
1337
|
if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)) {
|
|
1331
1338
|
withContext(snapshot, () => {
|
|
1332
1339
|
updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || hydrationInstance.mounted === false);
|
|
@@ -1347,6 +1354,7 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
|
|
|
1347
1354
|
return nextDom;
|
|
1348
1355
|
}
|
|
1349
1356
|
const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame() || existingInstance.ownerFrame || null;
|
|
1357
|
+
captureInlineRenderSnapshot(existingInstance);
|
|
1350
1358
|
existingInstance.props = props || {};
|
|
1351
1359
|
existingInstance.isRoot = isRouteRootComponentVNode(node);
|
|
1352
1360
|
existingInstance.portalScope = getCurrentInstance()?.portalScope ?? existingInstance.portalScope;
|
|
@@ -1368,7 +1376,7 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
|
|
|
1368
1376
|
warnUnusedStateReads(existingInstance);
|
|
1369
1377
|
return existingHost;
|
|
1370
1378
|
}
|
|
1371
|
-
const resolvedResult = resolveHostNestedComponentResult(existingHost, existingInstance, scopedResult, snapshot ?? null);
|
|
1379
|
+
const resolvedResult = resolveHostNestedComponentResult(existingHost, existingInstance, scopedResult, snapshot ?? null, retainedHostInstances);
|
|
1372
1380
|
if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)) {
|
|
1373
1381
|
withContext(snapshot, () => {
|
|
1374
1382
|
updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || existingInstance.mounted === false);
|
|
@@ -1398,11 +1406,14 @@ function createComponentElement(node, type, props, parentNamespace) {
|
|
|
1398
1406
|
const componentFn = type;
|
|
1399
1407
|
if (componentFn.constructor.name === "AsyncFunction") throw new Error("Async components are not supported. Use resource() for async work.");
|
|
1400
1408
|
let childInstance = getVNodeComponentInstance(node);
|
|
1409
|
+
const hadChildInstance = !!childInstance;
|
|
1401
1410
|
if (!childInstance) {
|
|
1402
1411
|
childInstance = createComponentInstance(nextComponentInstanceId(), componentFn, props || {}, null);
|
|
1403
1412
|
setVNodeComponentInstance(node, childInstance);
|
|
1404
1413
|
}
|
|
1414
|
+
if (hadChildInstance) captureInlineRenderSnapshot(childInstance);
|
|
1405
1415
|
childInstance.portalScope = getCurrentInstance()?.portalScope ?? childInstance.portalScope;
|
|
1416
|
+
childInstance.parentInstance = getCurrentInstance();
|
|
1406
1417
|
childInstance.props = props || {};
|
|
1407
1418
|
childInstance.isRoot = isRouteRootComponentVNode(node);
|
|
1408
1419
|
inheritComponentCleanupStrict(childInstance);
|
|
@@ -1642,12 +1653,15 @@ function syncForItemDom(parent, scope, vnode) {
|
|
|
1642
1653
|
}
|
|
1643
1654
|
const nextDom = materializeChildScopeDom(vnode, parentNamespace);
|
|
1644
1655
|
if (!nextDom) {
|
|
1645
|
-
if (dom.parentNode === parent)
|
|
1656
|
+
if (dom.parentNode === parent) {
|
|
1657
|
+
teardownNodeSubtree(dom);
|
|
1658
|
+
dom.parentNode.removeChild(dom);
|
|
1659
|
+
}
|
|
1646
1660
|
scope.dom = void 0;
|
|
1647
1661
|
return null;
|
|
1648
1662
|
}
|
|
1649
1663
|
if (dom.parentNode === parent) parent.replaceChild(nextDom, dom);
|
|
1650
|
-
|
|
1664
|
+
teardownNodeSubtree(dom);
|
|
1651
1665
|
scope.dom = nextDom;
|
|
1652
1666
|
return nextDom;
|
|
1653
1667
|
}
|
|
@@ -1691,6 +1705,7 @@ function resolveStableIntrinsicPatchVNode(dom, vnode) {
|
|
|
1691
1705
|
const existingInstance = findHostInstanceByType(host, vnode.type);
|
|
1692
1706
|
if (!existingInstance || existingInstance.fn !== vnode.type || host.__ASKR_WRAPPER_HOST) return null;
|
|
1693
1707
|
const snapshot = getVNodeContextFrame(vnode) || getCurrentContextFrame() || existingInstance.ownerFrame || null;
|
|
1708
|
+
captureInlineRenderSnapshot(existingInstance);
|
|
1694
1709
|
existingInstance.props = (vnode.props ?? {}) || {};
|
|
1695
1710
|
existingInstance.isRoot = isRouteRootComponentVNode(vnode);
|
|
1696
1711
|
existingInstance.portalScope = getCurrentInstance()?.portalScope ?? existingInstance.portalScope;
|
|
@@ -1932,7 +1947,7 @@ function updateElementChildren(el, children, forceUpdate = false) {
|
|
|
1932
1947
|
if (children === null || children === void 0) {
|
|
1933
1948
|
for (let n = el.firstChild; n;) {
|
|
1934
1949
|
const next = n.nextSibling;
|
|
1935
|
-
|
|
1950
|
+
teardownNodeSubtree(n);
|
|
1936
1951
|
n = next;
|
|
1937
1952
|
}
|
|
1938
1953
|
el.textContent = "";
|
|
@@ -1950,7 +1965,7 @@ function updateElementChildren(el, children, forceUpdate = false) {
|
|
|
1950
1965
|
} else {
|
|
1951
1966
|
for (let n = el.firstChild; n;) {
|
|
1952
1967
|
const next = n.nextSibling;
|
|
1953
|
-
|
|
1968
|
+
teardownNodeSubtree(n);
|
|
1954
1969
|
n = next;
|
|
1955
1970
|
}
|
|
1956
1971
|
el.textContent = String(children);
|
|
@@ -1981,7 +1996,7 @@ function updateElementChildren(el, children, forceUpdate = false) {
|
|
|
1981
1996
|
}
|
|
1982
1997
|
for (let n = el.firstChild; n;) {
|
|
1983
1998
|
const next = n.nextSibling;
|
|
1984
|
-
|
|
1999
|
+
teardownNodeSubtree(n);
|
|
1985
2000
|
n = next;
|
|
1986
2001
|
}
|
|
1987
2002
|
el.textContent = "";
|
|
@@ -2260,7 +2275,7 @@ function updateUnkeyedChildren(parent, newChildren, forceUpdate = false) {
|
|
|
2260
2275
|
if (existing.length === 0 && parent.childNodes.length > 0) {
|
|
2261
2276
|
for (let n = parent.firstChild; n;) {
|
|
2262
2277
|
const next = n.nextSibling;
|
|
2263
|
-
|
|
2278
|
+
teardownNodeSubtree(n);
|
|
2264
2279
|
n = next;
|
|
2265
2280
|
}
|
|
2266
2281
|
parent.textContent = "";
|