-
Notifications
You must be signed in to change notification settings - Fork 1
/
be.d.ts
110 lines (89 loc) · 3.17 KB
/
be.d.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { AttrChangeInfo, MountInit, RootCnfg, ObservedSourceOfTruthAttribute} from 'mount-observer/types.d.ts';
import { RegExpExt } from './prs';
import {IObject$tring, CSSQuery} from './types';
export type stringArray = string | Array<string>;
export type stringArrayOrTree = Array<string> | [string, Array<string>];
// export interface AttrParts {
// root: string,
// base: string,
// branch: string,
// leaf: string,
// }
type prefixDelimiter = '-' | ':' | '--';
/**
* Abbrev. for EnhancementMountConfig
*/
export type EMC<TBranches = any, TProps = any> = EnhancementMountConfig<TBranches, TProps>
export interface AttrCacheConfig {
enable: 'always' | 'instantiating',
clone?: boolean
}
export interface EnhancementMountConfig<TBranches = any, TProps = any>{
id?: string;
enhancedElementInstanceOf?: Array<{new(): Element}>,
enhancedElementMatches?: string,
enhPropKey: string,
hasRootIn?: Array<RootCnfg>,
preBaseDelimiter?: prefixDelimiter,
base?: string,
preBranchDelimiter?: prefixDelimiter,
branches?: Array<string>,
//TODO
watchedBranches?: Array<string>,
//TODO
preLeafDelimiter?: prefixDelimiter,
//TODO
leaves?: Partial<{[key in keyof TBranches & string]: stringArray}>,
//TODO
hostMatches?: CSSQuery,
//TODO
hostInstanceOf?: Array<{new(): HTMLElement}>,
block?: boolean,
//TODO
unblock?: boolean,
importEnh?: () => Promise<{new(): IEnhancement}>
map?: {[key: AttrCoordinates]: AttrMapPoint<TProps>},
/**
* Observed Source of Truth Attributes [TODO, need better name]
*/
osotas? : Array<ObservedSourceOfTruthAttribute<TProps>>,
cacheConfig?: AttrCacheConfig,
}
export type AttrMapPoint<TProps = any> = keyof TProps & string | AttrMapConfig<TProps>
export interface AttrMapConfig<TProps = any, TMethods = TProps> {
instanceOf?: 'Object' | 'String' | 'Object$tring' | 'Object$entences' | 'DSSArray' | 'Boolean' | 'Number',
mapsTo?: '.' | keyof TProps,
valIfFalsy?: any,
strValMapsTo?: keyof TProps,
objValMapsTo?: '.' | keyof TProps,
arrValMapsTo?: keyof TProps,
strArrMapsTo?: keyof TProps,
regExpExts?: Partial<{[key in keyof TProps]: RegExpExt<any>[]}>;
parsedRegExps?: boolean;
}
export type Branchitude = number;
export type Leafitude = number;
export type AttrCoordinates = `${Branchitude}.${Leafitude}`;
export type MountBeHive<TBranches = any> = Partial<EMC<TBranches>>;
export interface EnhancementInfo {
initialPropValues?: any,
initialAttrInfo?: Array<AttrChangeInfo>,
mountCnfg?: EMC,
}
export interface BEAllProps<TElement = Element> {
resolved: boolean;
rejected: boolean;
enhancedElement: TElement;
}
export interface IEnhancement<TElement = Element> extends BEAllProps<TElement>{
attach(el: TElement, enhancement: EnhancementInfo): Promise<void>;
detach(el: TElement): Promise<void>;
resolved: boolean;
rejected: boolean;
readonly enhancedElement: TElement;
whenResolved(): Promise<boolean>;
de(src: EventTarget, name: string) : Event,
attrChgCB(attrChangeInfos: Array<AttrChangeInfo>) : void,
//parsedFrom: string;
//autoImport?: boolean | string;
}