refactor(core): CORE-14 split typed settings and scope tree lifetimes

This commit is contained in:
Harvey Zhao committed 2026-09-11 06:49:04 +08:00
1 parent 697817eceb
commit 64d1939daa
51 files changed
+28144 -1519

No files matched your search

@@ -0,0 +1,20 @@
import type { SettingItem } from './types'
const registrations = new WeakMap<SettingItem, object>()
export function cancelSettingAdd(item: SettingItem): void {
registrations.delete(item)
}
export function beginSettingAdd(item: SettingItem): { current: () => boolean, finish: () => void } {
const token = {}
registrations.set(item, token)
const current = () => registrations.get(item) === token
return {
current,
finish() {
if (current())
registrations.delete(item)
},
}
}