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

+17
View File
@@ -0,0 +1,17 @@
import type Setting from '../../packages/artplayer/src/setting'
import type { SettingItem } from '../../packages/artplayer/src/setting/types'
declare const setting: Setting
const input = { name: 'custom', html: 'Custom', customValue: 42 }
const added = setting.add(input)
const value: number = added.customValue
const updated: SettingItem = setting.update(input)
const found: SettingItem | null = setting.find('absent')
const removed: void = setting.remove('custom')
// @ts-expect-error Runtime find can return null.
const definite: SettingItem = setting.find('absent')
// @ts-expect-error Setting add returns the item rather than its DOM row.
const element: HTMLDivElement = setting.add(input)
// @ts-expect-error Range values must be numeric.
setting.add({ html: 'Range', range: ['invalid'] })
void [value, updated, found, removed, definite, element]
+20
View File
@@ -0,0 +1,20 @@
import { findItem, formatTree, traverseTree, treeBinding } from '../../packages/artplayer/src/setting/model'
const item = { name: 'custom', payload: 42, selector: [{ name: 'child' }] }
const result = formatTree({ id: 0 }, [item])
const payload: number = result[0]!.payload
const binding = treeBinding(item)
const events: (() => void)[] = binding.events
const found = findItem(result, 'absent')
const nullable: typeof found | null = null
traverseTree(result, (node) => {
const name: string | undefined = node.name
void name
})
// @ts-expect-error A tree item can be missing; find must not promise a DOM node.
const element: HTMLElement = found
// @ts-expect-error Item names are strings.
formatTree({ id: 0 }, [{ name: 12 }])
// @ts-expect-error The generated-name counter is numeric.
formatTree({ id: '0' }, [item])
void [payload, events, nullable, element]