@joker.front/core 1.3.76 → 1.3.81
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/README.md +0 -97
- package/dist/bundle.es.js +1 -1
- package/dist/bundle.js +1 -1
- package/package.json +3 -3
- package/types/component.d.ts +53 -53
- package/types/event-bus.d.ts +15 -16
- package/types/global.d.ts +6 -6
- package/types/observer/dep.d.ts +22 -18
- package/types/observer/index.d.ts +15 -19
- package/types/observer/watcher.d.ts +15 -15
- package/types/parser/index.d.ts +16 -16
- package/types/parser/parser.d.ts +2 -2
- package/types/parser/render.d.ts +28 -28
- package/types/parser/vnode.d.ts +49 -43
- package/types/props.d.ts +7 -0
- package/types/utils/DI.d.ts +15 -4
package/types/observer/dep.d.ts
CHANGED
|
@@ -1,42 +1,46 @@
|
|
|
1
1
|
import { Watcher } from "./watcher";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Dependency manager acting as a bridge between watchers and proxied objects
|
|
4
|
+
* Data change flow: Ob -> dep -> watcher
|
|
5
|
+
* Dependency setup flow: watcher -> dep
|
|
6
6
|
*/
|
|
7
7
|
export declare class Dep {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Current target watcher
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Set this static value before changing a value to collect dependencies,
|
|
12
|
+
* clear it after setup.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Using a static value instead of a method allows handling
|
|
15
|
+
* multiple value changes/reads.
|
|
16
16
|
*/
|
|
17
17
|
static target?: Watcher<any>;
|
|
18
18
|
watchers: Map<string | symbol | number, Watcher<any>[]>;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param key
|
|
20
|
+
* Establish a dependency for a key
|
|
21
|
+
* @param key Property key to depend on
|
|
22
22
|
*/
|
|
23
23
|
depend(key: string | symbol | number): void;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param key
|
|
27
|
-
* @param watcher
|
|
25
|
+
* Add a watcher for a key
|
|
26
|
+
* @param key Property key to watch
|
|
27
|
+
* @param watcher Watcher instance to add
|
|
28
28
|
*/
|
|
29
29
|
addWatcher(key: string | symbol | number, watcher: Watcher<any>): void;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @param key
|
|
33
|
-
* @param watcher
|
|
31
|
+
* Remove a watcher for a key
|
|
32
|
+
* @param key Property key to unwatch
|
|
33
|
+
* @param watcher Watcher instance to remove
|
|
34
34
|
*/
|
|
35
35
|
removeWatcher(key: string | symbol | number, watcher: Watcher<any>): void;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @param key
|
|
37
|
+
* Notify watchers of a key change
|
|
38
|
+
* @param key Property key that changed
|
|
39
39
|
*/
|
|
40
40
|
notify(key: string | symbol | number): void;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Notify groups of dependencies in a batch
|
|
44
|
+
* @param list Map of Dep instances to their respective keys
|
|
45
|
+
*/
|
|
42
46
|
export declare function notifyGroupDeps(list: Map<Dep, Array<string | symbol | number>>): void;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Symbol key for storing the Dep instance of a proxied object
|
|
3
3
|
*/
|
|
4
4
|
export declare const OBJECTPROXY_DEPID: unique symbol;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @param data
|
|
8
|
-
* @param clone
|
|
9
|
-
* @returns
|
|
6
|
+
* Create a reactive version of an object
|
|
7
|
+
* @param data Object to observe
|
|
8
|
+
* @param clone Whether to clone the object before observing
|
|
9
|
+
* @returns Reactive object
|
|
10
10
|
*/
|
|
11
11
|
export declare function observer<T extends Object>(data: T, clone?: boolean): T;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param key
|
|
18
|
-
* @param value
|
|
13
|
+
* Define a reactive property on an object
|
|
14
|
+
* @param target Object to define property on
|
|
15
|
+
* @param key Property key
|
|
16
|
+
* @param value Property value
|
|
19
17
|
*/
|
|
20
18
|
export declare function defineObserverProperty(target: any, key: string | symbol | number, value: any): void;
|
|
21
19
|
declare const JOKER_SHALLOW_OBSERVER_TAG: unique symbol;
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @returns
|
|
21
|
+
* Shallow observer that watches only the root value
|
|
22
|
+
* @returns Shallow observer instance
|
|
25
23
|
*/
|
|
26
24
|
export declare class ShallowObserver<T> {
|
|
27
25
|
private data;
|
|
@@ -29,21 +27,19 @@ export declare class ShallowObserver<T> {
|
|
|
29
27
|
private dep;
|
|
30
28
|
constructor(data: T);
|
|
31
29
|
/**
|
|
32
|
-
*
|
|
30
|
+
* Flag indicating if the value has changed
|
|
33
31
|
*/
|
|
34
32
|
isChanged: boolean;
|
|
35
33
|
get value(): T;
|
|
36
34
|
set value(newVal: T);
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @param func 处理方法
|
|
42
|
-
* @returns
|
|
37
|
+
* Combine multiple dependency updates into a single notification
|
|
38
|
+
* @param func Function containing changes to combine
|
|
43
39
|
*/
|
|
44
40
|
export declare function combinedReply(func: Function): void;
|
|
45
41
|
/**
|
|
46
|
-
*
|
|
42
|
+
* Check if an object is being observed
|
|
47
43
|
*/
|
|
48
44
|
export declare function isObserverData(data: any): boolean;
|
|
49
45
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Dep } from "./dep";
|
|
2
2
|
export declare const BREAK_WATCH_UPDATE: unique symbol;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Observer
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Manages object observation, collects dependency relationships,
|
|
7
|
+
* and triggers callback responses when values change
|
|
7
8
|
*/
|
|
8
9
|
export declare class Watcher<T extends object = any> {
|
|
9
10
|
private ob;
|
|
@@ -14,33 +15,32 @@ export declare class Watcher<T extends object = any> {
|
|
|
14
15
|
isDestroy: boolean;
|
|
15
16
|
updating: boolean;
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Runtime relationship collection
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* Main purpose: filter duplicates at runtime and collect "valid" Dep relationships
|
|
21
|
+
* Each Dep corresponds to an object, and object keys do not repeat
|
|
21
22
|
*/
|
|
22
23
|
private runRelations;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* Actual dependency relations
|
|
25
26
|
*/
|
|
26
27
|
relations: Map<Dep, Array<string | symbol | number>>;
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param
|
|
30
|
-
* @param expOrFn
|
|
31
|
-
* @param
|
|
32
|
-
* @param forceCallBack 是否强制回调, 有些值未变更时也会强制回调
|
|
29
|
+
* @param ob Data source to observe (object or getter function)
|
|
30
|
+
* @param updateCallBack Callback function for value changes
|
|
31
|
+
* @param expOrFn Expression string or value extraction function
|
|
32
|
+
* @param forceCallBack Force callback even if value appears unchanged
|
|
33
33
|
*/
|
|
34
34
|
constructor(ob: T | (() => T), updateCallBack: Function, expOrFn?: string | ((obj: T) => any | void) | Function, forceCallBack?: boolean | undefined);
|
|
35
35
|
getValue(): any;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @param dep
|
|
39
|
-
* @param key
|
|
37
|
+
* Add Dep relationship
|
|
38
|
+
* @param dep Dependency instance
|
|
39
|
+
* @param key Observed property key
|
|
40
40
|
*/
|
|
41
41
|
addDep(dep: Dep, key: string | symbol | number): void;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Update observed value and trigger response
|
|
44
44
|
*/
|
|
45
45
|
update(): void;
|
|
46
46
|
destroy(): void;
|
package/types/parser/index.d.ts
CHANGED
|
@@ -7,56 +7,56 @@ export type ObType = Component & Record<string, any>;
|
|
|
7
7
|
export declare class ParserTemplate {
|
|
8
8
|
asts: AST.Node[];
|
|
9
9
|
ob: ObType;
|
|
10
|
-
/** VNode
|
|
10
|
+
/** VNode root */
|
|
11
11
|
root: VNode.Root;
|
|
12
|
-
/** VNode ref
|
|
12
|
+
/** VNode ref index set */
|
|
13
13
|
refs: Record<string, Array<VNode.Node>>;
|
|
14
14
|
sleeped: boolean;
|
|
15
15
|
promiseQueue: Set<Promise<any>>;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Node change observer
|
|
18
18
|
*/
|
|
19
19
|
nodeWatcherEvents: Record<string, Array<(node: VNode.Node, type: NodeChangeType, propertyKey?: string) => void>>;
|
|
20
|
-
/** VNode
|
|
20
|
+
/** VNode rendering handler (dependency injection) */
|
|
21
21
|
render: Render.IRender;
|
|
22
22
|
constructor(asts: AST.Node[], ob: ObType, parent?: VNode.Node);
|
|
23
23
|
parser(): void;
|
|
24
24
|
/**
|
|
25
|
-
* VNode
|
|
25
|
+
* Mount VNode
|
|
26
26
|
* @param root
|
|
27
27
|
*/
|
|
28
28
|
mount(root: any): void;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Compile AST subset
|
|
31
31
|
* @param asts
|
|
32
32
|
* @param parent
|
|
33
33
|
*/
|
|
34
34
|
parserNodes(asts: AST.Node[], parent: VNode.Node, ob?: Component & Record<string, any>): void;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param refName ref
|
|
38
|
-
* @param node VNode
|
|
36
|
+
* Add ref
|
|
37
|
+
* @param refName ref value
|
|
38
|
+
* @param node VNode node
|
|
39
39
|
*/
|
|
40
40
|
addRef(refKey: string, node: VNode.Node): void;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param node VNode
|
|
42
|
+
* Remove ref where Node is located
|
|
43
|
+
* @param node VNode node
|
|
44
44
|
*/
|
|
45
45
|
removeRef(node: VNode.Node): void;
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* Add node change observer
|
|
48
48
|
* @param ref
|
|
49
49
|
* @param callBack
|
|
50
50
|
*/
|
|
51
51
|
addNodeWatcher(ref: string, callBack: (node: VNode.Node, type: NodeChangeType) => void): void;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Remove node change observer
|
|
54
54
|
* @param ref
|
|
55
55
|
* @param callBack
|
|
56
56
|
*/
|
|
57
57
|
removeNodeWatcher(ref: string, callBack: Function): void;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Respond to node changes and notify observers
|
|
60
60
|
* @param ref
|
|
61
61
|
* @param node
|
|
62
62
|
* @param nodeChangeType
|
|
@@ -65,10 +65,10 @@ export declare class ParserTemplate {
|
|
|
65
65
|
sleep(node?: VNode.Node): void;
|
|
66
66
|
private weakup;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Destroy
|
|
69
69
|
*/
|
|
70
70
|
destroy(keepalive?: boolean): void;
|
|
71
|
-
/**
|
|
71
|
+
/** Clear all watches to optimize nested component destruction when custom destroy events trigger watchers again */
|
|
72
72
|
destroyWathcers(): void;
|
|
73
73
|
reSetAsts(asts: AST.Node[], keepalive?: boolean): void;
|
|
74
74
|
nodeTransition(node: VNode.Node | undefined, mode: "enter" | "leave", name?: string, callBack?: Function, type?: "transition" | "animation"): boolean;
|
package/types/parser/parser.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare abstract class IParser<T extends AST.Node, N extends VNode.Node>
|
|
|
63
63
|
* @param ob 数据源
|
|
64
64
|
* @returns
|
|
65
65
|
*/
|
|
66
|
-
protected runExpress(express: string, ob: any): any;
|
|
66
|
+
protected runExpress(express: string, ob: any, customLog: () => string | void): any;
|
|
67
67
|
/**
|
|
68
68
|
* 运行表达式方法,并返回运行后的值(带观察者)
|
|
69
69
|
* @param express 表达式 string|function
|
|
@@ -72,7 +72,7 @@ export declare abstract class IParser<T extends AST.Node, N extends VNode.Node>
|
|
|
72
72
|
* @param forceCallBack 是否强制回调
|
|
73
73
|
* @returns
|
|
74
74
|
*/
|
|
75
|
-
protected runExpressWithWatcher(express: string | Function, ob: any, updateCallBack: (newVal: any, oldVal: any, isEqul: boolean, wathcer: Watcher) => void, forceCallBack?: boolean): any;
|
|
75
|
+
protected runExpressWithWatcher(express: string | Function, ob: any, updateCallBack: (newVal: any, oldVal: any, isEqul: boolean, wathcer: Watcher) => void, forceCallBack?: boolean, customLog?: () => string | void): any;
|
|
76
76
|
/**
|
|
77
77
|
* 添加观察者
|
|
78
78
|
* @param watcher
|
package/types/parser/render.d.ts
CHANGED
|
@@ -2,72 +2,72 @@ import { VNode } from "./vnode";
|
|
|
2
2
|
type TransitionType = "transition" | "animation";
|
|
3
3
|
export declare namespace Render {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Inversion of Control tag ID for rendering
|
|
6
6
|
*/
|
|
7
7
|
const IRENDERIOCTAGID: unique symbol;
|
|
8
8
|
let ROOT_CONTAINER: string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* 上游调用也无需关心parent,特别是在watch周期内
|
|
10
|
+
* Note: appendNode is executed during rendering, and mount is called once at the end.
|
|
11
|
+
* There will be no scenario where the root is appended because command groups take precedence.
|
|
12
|
+
* append and remove methods do not require a parent parameter because after mounting,
|
|
13
|
+
* the relationship is established, and they are executed directly based on that relationship.
|
|
14
|
+
* Upstream calls do not need to care about the parent, especially during watch cycles.
|
|
16
15
|
*/
|
|
17
16
|
interface IRender {
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param root
|
|
21
|
-
*
|
|
18
|
+
* Mount the rendering to a root container
|
|
19
|
+
* @param root Root container (element or component)
|
|
20
|
+
* Root type is not restricted for multi-platform compatibility
|
|
22
21
|
*/
|
|
23
22
|
mount(root: any): void;
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param node
|
|
24
|
+
* Append a node to the rendering
|
|
25
|
+
* @param node VNode to append
|
|
26
|
+
* @param index Optional index for insertion
|
|
27
27
|
*/
|
|
28
28
|
appendNode(node: VNode.Node, index?: number): void;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param node
|
|
32
|
-
* @param propertyKey
|
|
30
|
+
* Update a node's properties
|
|
31
|
+
* @param node VNode to update
|
|
32
|
+
* @param propertyKey Property to update (optional)
|
|
33
33
|
*/
|
|
34
34
|
updateNode(node: VNode.Node, propertyKey?: string): void;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
36
|
+
* Remove a node from the rendering
|
|
37
|
+
* @param node VNode to remove
|
|
38
|
+
* @param parent Optional parent node (root if undefined)
|
|
39
|
+
* @param reserveOutPut Whether to retain the output
|
|
40
40
|
*/
|
|
41
41
|
removeNode(node: VNode.Node, reserveOutPut?: boolean): void;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Destroy the renderer, unmount DOM and release resources
|
|
44
44
|
*/
|
|
45
45
|
destroy(): void;
|
|
46
46
|
/**
|
|
47
|
-
* element
|
|
47
|
+
* Handle element transition enter animation
|
|
48
48
|
*/
|
|
49
49
|
elementToEnter(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
|
50
50
|
/**
|
|
51
|
-
* element
|
|
51
|
+
* Handle element transition leave animation
|
|
52
52
|
*/
|
|
53
53
|
elementToLeave(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @param node
|
|
57
|
-
* @param eventName
|
|
58
|
-
* @returns false
|
|
55
|
+
* Trigger a component event
|
|
56
|
+
* @param node Component node
|
|
57
|
+
* @param eventName Event name
|
|
58
|
+
* @returns false to stop propagation
|
|
59
59
|
*/
|
|
60
60
|
triggerEvent(node: VNode.Component, eventName: string, e: VNode.Event): void | false;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Default renderer using HTML DOM
|
|
64
64
|
*/
|
|
65
65
|
class DomRender implements IRender {
|
|
66
66
|
elements: DocumentFragment;
|
|
67
67
|
constructor();
|
|
68
68
|
mount(root: Element | VNode.Component): void;
|
|
69
69
|
appendNode(node: VNode.Node, index?: number): void;
|
|
70
|
-
updateNode(node: VNode.Node, propertyKey?: string
|
|
70
|
+
updateNode(node: VNode.Node, propertyKey?: string): void;
|
|
71
71
|
removeNode(node: VNode.Node, reserveOutPut?: boolean): void;
|
|
72
72
|
destroy(): void;
|
|
73
73
|
elementToEnter(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
package/types/parser/vnode.d.ts
CHANGED
|
@@ -5,20 +5,20 @@ import { SectionType } from "../component";
|
|
|
5
5
|
import { IParser } from "./parser";
|
|
6
6
|
export declare const JOKER_VNODE_TAG: unique symbol;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Virtual DOM (VNode)
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* This control classification differs from AST, as it is divided based on the actual output type.
|
|
11
11
|
*/
|
|
12
12
|
export declare namespace VNode {
|
|
13
13
|
const PARSERKEY: unique symbol;
|
|
14
14
|
/**
|
|
15
|
-
* VNode
|
|
15
|
+
* Base class for VNode
|
|
16
16
|
*/
|
|
17
17
|
class Node {
|
|
18
18
|
parent?: Node | undefined;
|
|
19
19
|
[JOKER_VNODE_TAG]: boolean;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Whether it is a static node (non-dynamic), such as element, text, comment, etc.
|
|
22
22
|
*/
|
|
23
23
|
static?: boolean;
|
|
24
24
|
output?: any;
|
|
@@ -26,43 +26,48 @@ export declare namespace VNode {
|
|
|
26
26
|
childrens?: Node[];
|
|
27
27
|
ref?: string;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Whether the current node is in sleep state
|
|
30
30
|
*/
|
|
31
31
|
sleep: boolean;
|
|
32
32
|
constructor(parent?: Node | undefined);
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Previous node
|
|
35
35
|
*/
|
|
36
36
|
get prev(): Node | undefined;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Next node
|
|
39
39
|
*/
|
|
40
40
|
get next(): Node | undefined;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param filter
|
|
44
|
-
* @param shouldBreak
|
|
45
|
-
* @returns
|
|
42
|
+
* Find the first ancestor element that matches the filter
|
|
43
|
+
* @param filter Filter condition: return true to select the current node
|
|
44
|
+
* @param shouldBreak Custom stop condition: return true to stop searching upwards
|
|
45
|
+
* @returns The matched ancestor node or undefined
|
|
46
46
|
*/
|
|
47
47
|
closest<T extends VNode.Node = VNode.Element & VNode.Component>(filter: (node: VNode.Node) => true | any, shouldBreak?: (node: VNode.Node) => true | any): T | undefined;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param filter
|
|
51
|
-
* @param shouldBreak
|
|
52
|
-
* @param deepSearch
|
|
53
|
-
* @returns
|
|
49
|
+
* Find all child elements that match the filter
|
|
50
|
+
* @param filter Return true to include the node
|
|
51
|
+
* @param shouldBreak Custom stop condition: return true to stop searching downwards
|
|
52
|
+
* @param deepSearch Whether to search deeply (default: false). If true, continue searching after matching.
|
|
53
|
+
* @returns Array of matched nodes
|
|
54
54
|
*/
|
|
55
55
|
find<T extends VNode.Node = VNode.Element & VNode.Component>(filter: (node: VNode.Node) => true | any, shouldBreak?: (node: VNode.Node) => true | any, deepSearch?: boolean, _childrens?: Array<VNode.Node>, _out?: Array<VNode.Node>): Array<T>;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param filter
|
|
59
|
-
* @returns
|
|
57
|
+
* Check if any child node matches the filter
|
|
58
|
+
* @param filter Return true to include the node, return false to skip its children
|
|
59
|
+
* @returns True if any child matches, false otherwise
|
|
60
60
|
*/
|
|
61
61
|
contains(filter: (node: VNode.Node) => true | any, childrens?: Array<VNode.Node>): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Find the first child node that matches the filter
|
|
64
|
+
* @param filter Return true to select the node
|
|
65
|
+
* @returns The first matched child node or undefined
|
|
66
|
+
*/
|
|
62
67
|
first<T extends VNode.Node = VNode.Element & VNode.Component>(filter: (node: VNode.Node) => true | any, childrens?: Array<VNode.Node>): T | undefined;
|
|
63
68
|
}
|
|
64
69
|
/**
|
|
65
|
-
*
|
|
70
|
+
* Root node
|
|
66
71
|
*/
|
|
67
72
|
class Root<T extends IComponent = IComponent & Record<string, any>> extends Node {
|
|
68
73
|
childrens: Node[];
|
|
@@ -70,7 +75,7 @@ export declare namespace VNode {
|
|
|
70
75
|
constructor();
|
|
71
76
|
}
|
|
72
77
|
/**
|
|
73
|
-
*
|
|
78
|
+
* Text node
|
|
74
79
|
*/
|
|
75
80
|
class Text extends Node {
|
|
76
81
|
text: string;
|
|
@@ -78,16 +83,17 @@ export declare namespace VNode {
|
|
|
78
83
|
constructor(text: string, parent: Node);
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
|
-
*
|
|
86
|
+
* HTML node
|
|
82
87
|
*/
|
|
83
88
|
class Html extends Node {
|
|
84
89
|
html: string;
|
|
85
90
|
notShadow?: boolean | undefined;
|
|
86
91
|
static: boolean;
|
|
92
|
+
scopedId?: string;
|
|
87
93
|
constructor(html: string, parent: Node, notShadow?: boolean | undefined);
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
90
|
-
*
|
|
96
|
+
* Comment node
|
|
91
97
|
*/
|
|
92
98
|
class Comment extends Node {
|
|
93
99
|
text: string;
|
|
@@ -95,7 +101,7 @@ export declare namespace VNode {
|
|
|
95
101
|
constructor(text: string, parent: Node);
|
|
96
102
|
}
|
|
97
103
|
/**
|
|
98
|
-
* Element
|
|
104
|
+
* Element node
|
|
99
105
|
*/
|
|
100
106
|
class Element extends Node {
|
|
101
107
|
tagName: string;
|
|
@@ -107,56 +113,56 @@ export declare namespace VNode {
|
|
|
107
113
|
callBack: EventCallBack;
|
|
108
114
|
}]>;
|
|
109
115
|
/**
|
|
110
|
-
*
|
|
116
|
+
* Auxiliary event storage for storing assist events like 'outside'
|
|
111
117
|
*/
|
|
112
118
|
_assistEventCache?: Array<[string, (e: any) => void]>;
|
|
113
119
|
constructor(tagName: string, parent: Node);
|
|
114
120
|
}
|
|
115
121
|
type Event<T = undefined, N extends VNode.Node = VNode.Element | VNode.Component | VNode.Root> = {
|
|
116
122
|
/**
|
|
117
|
-
*
|
|
123
|
+
* Event name
|
|
118
124
|
*/
|
|
119
125
|
eventName: string;
|
|
120
126
|
/**
|
|
121
|
-
*
|
|
127
|
+
* Native event corresponding to the runtime platform
|
|
122
128
|
*/
|
|
123
129
|
event?: any;
|
|
124
|
-
/**
|
|
130
|
+
/** Target element that triggered the event */
|
|
125
131
|
target?: N;
|
|
126
|
-
/**
|
|
132
|
+
/** Prevent default event behavior */
|
|
127
133
|
preventDefault(): void;
|
|
128
|
-
/**
|
|
134
|
+
/** Stop event propagation */
|
|
129
135
|
stopPropagation(): void;
|
|
130
|
-
/**
|
|
136
|
+
/** Event parameters */
|
|
131
137
|
data: T;
|
|
132
138
|
};
|
|
133
139
|
type EventCallBack<T = any> = (e: Event<T>) => void;
|
|
134
140
|
/**
|
|
135
|
-
*
|
|
141
|
+
* Component node
|
|
136
142
|
*/
|
|
137
143
|
class Component<T extends ComponentClass = ComponentClass<any> & Record<string, any>> extends Node {
|
|
138
|
-
/**
|
|
144
|
+
/** Component name (template tag name) */
|
|
139
145
|
name?: string;
|
|
140
|
-
/**
|
|
146
|
+
/** Component instance */
|
|
141
147
|
component: T;
|
|
142
|
-
/**
|
|
148
|
+
/** Events */
|
|
143
149
|
events: Array<[string, {
|
|
144
150
|
modifiers?: string[];
|
|
145
151
|
callBack: EventCallBack;
|
|
146
152
|
}]>;
|
|
147
|
-
/**
|
|
153
|
+
/** Properties values */
|
|
148
154
|
propValues: Record<string, any>;
|
|
149
|
-
/**
|
|
155
|
+
/** Whether to keep the component alive */
|
|
150
156
|
keepalive?: boolean;
|
|
151
157
|
/**
|
|
152
|
-
*
|
|
158
|
+
* First element VNode of the current component
|
|
153
159
|
*/
|
|
154
160
|
get firstElement(): Element | undefined;
|
|
155
|
-
/**
|
|
161
|
+
/** Get root element nodes (including VNode.Html) */
|
|
156
162
|
get rootElements(): (Element | Html)[];
|
|
157
163
|
}
|
|
158
164
|
/**
|
|
159
|
-
*
|
|
165
|
+
* Condition node
|
|
160
166
|
*/
|
|
161
167
|
class Condition extends Node {
|
|
162
168
|
cmdName: AST.IfCommand["kind"];
|
|
@@ -166,13 +172,13 @@ export declare namespace VNode {
|
|
|
166
172
|
constructor(cmdName: AST.IfCommand["kind"], parent: Node);
|
|
167
173
|
}
|
|
168
174
|
/**
|
|
169
|
-
*
|
|
175
|
+
* List node, containing multiple list items
|
|
170
176
|
*/
|
|
171
177
|
class List extends Node {
|
|
172
178
|
childrens: ListItem[];
|
|
173
179
|
}
|
|
174
180
|
/**
|
|
175
|
-
*
|
|
181
|
+
* List item for looping
|
|
176
182
|
*/
|
|
177
183
|
class ListItem extends Node {
|
|
178
184
|
ob: ObType;
|
|
@@ -180,7 +186,7 @@ export declare namespace VNode {
|
|
|
180
186
|
constructor(ob: ObType, parent: VNode.Node);
|
|
181
187
|
}
|
|
182
188
|
/**
|
|
183
|
-
*
|
|
189
|
+
* Render section node (slot)
|
|
184
190
|
*/
|
|
185
191
|
class RenderSection extends Node {
|
|
186
192
|
id: string;
|
package/types/props.d.ts
CHANGED
|
@@ -6,4 +6,11 @@ export type PropTypeFullModel = {
|
|
|
6
6
|
validate?: (val: any) => Boolean;
|
|
7
7
|
};
|
|
8
8
|
export type PropType = PropValueType | Array<PropValueType> | PropTypeFullModel;
|
|
9
|
+
/**
|
|
10
|
+
* Get and validate a prop value based on its definition
|
|
11
|
+
* @param propsData Source props data
|
|
12
|
+
* @param key Prop key
|
|
13
|
+
* @param propsType Prop type definition
|
|
14
|
+
* @returns Validated and processed prop value
|
|
15
|
+
*/
|
|
9
16
|
export declare function getPropValue(propsData: Readonly<Record<string | symbol, any>>, key: string | symbol, propsType?: Record<string | symbol, any>): any;
|
package/types/utils/DI.d.ts
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
type Constructor<T = any> = new (...args: any[]) => T;
|
|
2
2
|
/**
|
|
3
|
-
* IOC
|
|
3
|
+
* IOC Dependency Injection Container
|
|
4
4
|
*
|
|
5
|
-
* IOC
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Applicable scenarios for IOC dependency injection:
|
|
6
|
+
* APIs and Interfaces that are internally planned but need external logic injection.
|
|
7
|
+
* Different from plugins, which are aspect injections based on the overall lifecycle.
|
|
8
8
|
*/
|
|
9
9
|
export declare namespace IContainer {
|
|
10
|
+
/**
|
|
11
|
+
* Bind a tag identifier to a constructor
|
|
12
|
+
* @param tagId Unique identifier for the binding
|
|
13
|
+
* @returns Object with 'to' method to specify the target constructor
|
|
14
|
+
*/
|
|
10
15
|
function bind<T>(tagId: symbol | string): {
|
|
11
16
|
to: (target: Constructor<T>) => void;
|
|
12
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a dependency by tag identifier
|
|
20
|
+
* @param tagId Unique identifier for the binding
|
|
21
|
+
* @param params Parameters to pass to the constructor
|
|
22
|
+
* @returns New instance of the bound constructor, or undefined if not found
|
|
23
|
+
*/
|
|
13
24
|
function get<T>(tagId: symbol | string, ...params: any[]): T | undefined;
|
|
14
25
|
}
|
|
15
26
|
export {};
|