-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwiring-context.ts
50 lines (44 loc) · 1.36 KB
/
wiring-context.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import type { Observable, Subscription } from 'rxjs'
import type {
Component,
ComponentContext,
ComponentDescription,
ElementDescription,
NodeDescription,
} from './component.js'
export type ElementBinds = Array<[Element, ElementDescription]>
export type NodeBinds = Array<[CharacterData | Element, NodeDescription]>
export type DomStrategy = (
component: Component,
properties: unknown,
componentContext: ComponentContext,
container: Element | DocumentFragment | undefined,
document: Document,
) => {
container: Element | DocumentFragment
isSameContainer: boolean
elementBinds: ElementBinds
nodeBinds: NodeBinds
}
export interface WiringContext {
domStrategy: DomStrategy
suspense?: Observable<boolean>
treeError?: (error: unknown) => void
isStaticComponent: boolean
isStaticTree: boolean
preserveOnComplete?: boolean
}
export type ObservableComponent = Observable<Element> & { name: string }
export type ComponentRunner = (
container: Element,
description: ComponentDescription | Component | ObservableComponent,
context: WiringContext,
placeholder: Element | CharacterData,
document?: Document,
) => Subscription
export type ComponentWirer = (
component: ComponentDescription | Component | ObservableComponent,
context: WiringContext,
container?: Element | DocumentFragment,
document?: Document,
) => Observable<Element>