vasille 3.0.2 → 3.2.0
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 +10 -10
- package/lib/core/core.js +40 -24
- package/lib/core/ivalue.js +1 -2
- package/lib/index.js +20 -22
- package/lib/node/app.js +7 -7
- package/lib/node/node.js +47 -360
- package/lib/node/watch.js +5 -6
- package/lib/{binding → runner/web/binding}/attribute.js +1 -1
- package/lib/{binding → runner/web/binding}/binding.js +1 -1
- package/lib/{binding → runner/web/binding}/class.js +3 -1
- package/lib/{binding → runner/web/binding}/style.js +2 -1
- package/lib/runner/web/runner.js +165 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/value/expression.js +3 -2
- package/lib/value/pointer.js +8 -12
- package/lib/value/reference.js +2 -2
- package/lib/views/array-view.js +1 -1
- package/lib/views/base-view.js +3 -3
- package/lib/views/map-view.js +1 -1
- package/lib/views/repeat-node.js +5 -6
- package/lib/views/set-view.js +3 -3
- package/package.json +31 -25
- package/types/core/core.d.ts +14 -13
- package/types/index.d.ts +22 -24
- package/types/node/app.d.ts +8 -7
- package/types/node/node.d.ts +49 -144
- package/types/node/runner.d.ts +10 -0
- package/types/node/watch.d.ts +7 -6
- package/types/{binding → runner/web/binding}/attribute.d.ts +4 -4
- package/types/{binding → runner/web/binding}/binding.d.ts +2 -2
- package/types/runner/web/binding/class.d.ts +11 -0
- package/types/{binding → runner/web/binding}/style.d.ts +4 -4
- package/types/runner/web/runner.d.ts +42 -0
- package/types/tsconfig-types.tsbuildinfo +1 -1
- package/types/value/expression.d.ts +2 -2
- package/types/value/pointer.d.ts +1 -1
- package/types/value/reference.d.ts +1 -1
- package/types/views/array-view.d.ts +5 -5
- package/types/views/base-view.d.ts +7 -6
- package/types/views/map-view.d.ts +3 -3
- package/types/views/repeat-node.d.ts +8 -7
- package/types/views/set-view.d.ts +5 -4
- package/lib/core/config.js +0 -3
- package/lib/models/array-model.js +0 -147
- package/lib/models/listener.js +0 -66
- package/lib/models/map-model.js +0 -59
- package/lib/models/model.js +0 -1
- package/lib/models/object-model.js +0 -78
- package/lib/models/set-model.js +0 -55
- package/lib/spec/html.js +0 -1
- package/lib/spec/react.js +0 -1
- package/lib/spec/svg.js +0 -1
- package/lib/tsconfig-build.tsbuildinfo +0 -1
- package/lib/value/mirror.js +0 -42
- package/lib/views/object-view.js +0 -17
- package/lib-node/binding/attribute.js +0 -34
- package/lib-node/binding/binding.js +0 -32
- package/lib-node/binding/class.js +0 -46
- package/lib-node/binding/style.js +0 -36
- package/lib-node/core/config.js +0 -6
- package/lib-node/core/core.js +0 -101
- package/lib-node/core/destroyable.js +0 -14
- package/lib-node/core/errors.js +0 -22
- package/lib-node/core/ivalue.js +0 -19
- package/lib-node/functional/options.js +0 -2
- package/lib-node/functional/safety.js +0 -12
- package/lib-node/index.js +0 -51
- package/lib-node/models/array-model.js +0 -152
- package/lib-node/models/listener.js +0 -70
- package/lib-node/models/map-model.js +0 -63
- package/lib-node/models/model.js +0 -2
- package/lib-node/models/object-model.js +0 -82
- package/lib-node/models/set-model.js +0 -59
- package/lib-node/node/app.js +0 -34
- package/lib-node/node/node.js +0 -656
- package/lib-node/node/watch.js +0 -26
- package/lib-node/spec/html.js +0 -2
- package/lib-node/spec/react.js +0 -2
- package/lib-node/spec/svg.js +0 -2
- package/lib-node/tsconfig-build-node.tsbuildinfo +0 -1
- package/lib-node/value/expression.js +0 -65
- package/lib-node/value/mirror.js +0 -46
- package/lib-node/value/pointer.js +0 -79
- package/lib-node/value/reference.js +0 -50
- package/lib-node/views/array-view.js +0 -21
- package/lib-node/views/base-view.js +0 -31
- package/lib-node/views/map-view.js +0 -18
- package/lib-node/views/object-view.js +0 -21
- package/lib-node/views/repeat-node.js +0 -53
- package/lib-node/views/set-view.js +0 -22
- package/types/binding/class.d.ts +0 -11
- package/types/core/config.d.ts +0 -3
- package/types/functional/options.d.ts +0 -10
- package/types/models/array-model.d.ts +0 -55
- package/types/models/listener.d.ts +0 -48
- package/types/models/map-model.d.ts +0 -34
- package/types/models/model.d.ts +0 -14
- package/types/models/object-model.d.ts +0 -38
- package/types/models/set-model.d.ts +0 -33
- package/types/spec/html.d.ts +0 -975
- package/types/spec/react.d.ts +0 -4
- package/types/spec/svg.d.ts +0 -314
- package/types/value/mirror.d.ts +0 -33
- package/types/views/object-view.d.ts +0 -10
- /package/lib/{functional/options.js → node/runner.js} +0 -0
package/types/node/node.d.ts
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import { Reactive } from "../core/core";
|
|
2
|
-
import { IValue } from "../core/ivalue";
|
|
3
|
-
import {
|
|
1
|
+
import { Reactive } from "../core/core.js";
|
|
2
|
+
import { IValue } from "../core/ivalue.js";
|
|
3
|
+
import { Runner } from "./runner.js";
|
|
4
4
|
/**
|
|
5
5
|
* This class is symbolic
|
|
6
6
|
* @extends Reactive
|
|
7
7
|
*/
|
|
8
|
-
export declare abstract class Root<T extends object = object> extends Reactive<T> {
|
|
8
|
+
export declare abstract class Root<Node, Element, TagOptions extends object, T extends object = object> extends Reactive<T> {
|
|
9
9
|
/**
|
|
10
10
|
* The children list
|
|
11
11
|
* @type Array
|
|
12
12
|
*/
|
|
13
|
-
children: Set<Fragment
|
|
14
|
-
|
|
13
|
+
readonly children: Set<Fragment<Node, Element, TagOptions>>;
|
|
14
|
+
readonly runner: Runner<Node, Element, TagOptions>;
|
|
15
|
+
lastChild: Fragment<Node, Element, TagOptions> | undefined;
|
|
16
|
+
protected constructor(input: T, runner: Runner<Node, Element, TagOptions>);
|
|
15
17
|
/**
|
|
16
18
|
* Pushes a node to children immediately
|
|
17
19
|
* @param node {Fragment} A node to push
|
|
18
20
|
* @protected
|
|
19
21
|
*/
|
|
20
|
-
protected pushNode(node: Fragment): void;
|
|
22
|
+
protected pushNode(node: Fragment<Node, Element, TagOptions>): void;
|
|
21
23
|
/**
|
|
22
24
|
* Find the first node in the element if so exists
|
|
23
25
|
* @return {?Element}
|
|
24
26
|
* @protected
|
|
25
27
|
*/
|
|
26
|
-
protected findFirstChild(): Node | undefined;
|
|
28
|
+
protected findFirstChild(): Node | Element | undefined;
|
|
27
29
|
/**
|
|
28
30
|
* Append a node to end of element
|
|
29
31
|
* @param node {Node} node to insert
|
|
@@ -42,64 +44,64 @@ export declare abstract class Root<T extends object = object> extends Reactive<T
|
|
|
42
44
|
* @param input
|
|
43
45
|
* @param cb {function(Tag, *)} callback
|
|
44
46
|
*/
|
|
45
|
-
tag(tagName: string, input:
|
|
47
|
+
tag(tagName: string, input: TagOptions, cb?: (ctx: Tag<Node, Element, TagOptions>) => void): void;
|
|
46
48
|
/**
|
|
47
49
|
* Defines a custom element
|
|
48
50
|
* @param node {Fragment} vasille element to insert
|
|
49
51
|
* @param callback {function($ : *)}
|
|
50
52
|
*/
|
|
51
|
-
create<T extends Fragment
|
|
53
|
+
create<T extends Fragment<Node, Element, TagOptions>>(node: T, callback?: (ctx: T) => void): void;
|
|
52
54
|
/**
|
|
53
55
|
* Defines an if node
|
|
54
56
|
* @param cond {IValue} condition
|
|
55
57
|
* @param cb {function(Fragment)} callback to run on true
|
|
56
58
|
* @return {this}
|
|
57
59
|
*/
|
|
58
|
-
if(cond: IValue<unknown>, cb: (node: Fragment) => void): void;
|
|
59
|
-
else(cb: (node: Fragment) => void): void;
|
|
60
|
-
elif(cond: IValue<unknown>, cb: (node: Fragment) => void): void;
|
|
60
|
+
if(cond: IValue<unknown>, cb: (node: Fragment<Node, Element, TagOptions>) => void): void;
|
|
61
|
+
else(cb: (node: Fragment<Node, Element, TagOptions>) => void): void;
|
|
62
|
+
elif(cond: IValue<unknown>, cb: (node: Fragment<Node, Element, TagOptions>) => void): void;
|
|
61
63
|
/**
|
|
62
64
|
* Create a case for switch
|
|
63
65
|
* @param cond {IValue<boolean>}
|
|
64
66
|
* @param cb {function(Fragment) : void}
|
|
65
67
|
* @return {{cond : IValue, cb : (function(Fragment) : void)}}
|
|
66
68
|
*/
|
|
67
|
-
case(cond: IValue<unknown>, cb: (node: Fragment) => void): {
|
|
69
|
+
case(cond: IValue<unknown>, cb: (node: Fragment<Node, Element, TagOptions>) => void): {
|
|
68
70
|
cond: IValue<unknown>;
|
|
69
|
-
cb: (node: Fragment) => void;
|
|
71
|
+
cb: (node: Fragment<Node, Element, TagOptions>) => void;
|
|
70
72
|
};
|
|
71
73
|
/**
|
|
72
74
|
* @param cb {(function(Fragment) : void)}
|
|
73
75
|
* @return {{cond : IValue, cb : (function(Fragment) : void)}}
|
|
74
76
|
*/
|
|
75
|
-
default(cb: (node: Fragment) => void): {
|
|
77
|
+
default(cb: (node: Fragment<Node, Element, TagOptions>) => void): {
|
|
76
78
|
cond: IValue<boolean>;
|
|
77
|
-
cb: (node: Fragment) => void;
|
|
79
|
+
cb: (node: Fragment<Node, Element, TagOptions>) => void;
|
|
78
80
|
};
|
|
79
81
|
destroy(): void;
|
|
80
82
|
}
|
|
81
|
-
export declare class Fragment<T extends object = object> extends Root<T> {
|
|
83
|
+
export declare class Fragment<Node, Element, TagOptions extends object, T extends object = object> extends Root<Node, Element, TagOptions, T> {
|
|
82
84
|
readonly name?: string;
|
|
83
|
-
parent: Root
|
|
84
|
-
constructor(input: T, name?: string);
|
|
85
|
+
parent: Root<Node, Element, TagOptions>;
|
|
86
|
+
constructor(input: T, runner: Runner<Node, Element, TagOptions>, name?: string);
|
|
85
87
|
/**
|
|
86
88
|
* Next node
|
|
87
89
|
* @type {?Fragment}
|
|
88
90
|
*/
|
|
89
|
-
protected next?: Fragment
|
|
91
|
+
protected next?: Fragment<Node, Element, TagOptions>;
|
|
90
92
|
/**
|
|
91
93
|
* Previous node
|
|
92
94
|
* @type {?Fragment}
|
|
93
95
|
*/
|
|
94
|
-
protected prev?: Fragment
|
|
96
|
+
protected prev?: Fragment<Node, Element, TagOptions>;
|
|
95
97
|
/**
|
|
96
98
|
* Pushes a node to children immediately
|
|
97
99
|
* @param node {Fragment} A node to push
|
|
98
100
|
* @protected
|
|
99
101
|
*/
|
|
100
|
-
protected pushNode(node: Fragment): void;
|
|
102
|
+
protected pushNode(node: Fragment<Node, Element, TagOptions>): void;
|
|
101
103
|
/**
|
|
102
|
-
* Append a node to end of element
|
|
104
|
+
* Append a node to the end of element
|
|
103
105
|
* @param node {Node} node to insert
|
|
104
106
|
*/
|
|
105
107
|
appendNode(node: Node): void;
|
|
@@ -109,12 +111,12 @@ export declare class Fragment<T extends object = object> extends Root<T> {
|
|
|
109
111
|
*/
|
|
110
112
|
insertAdjacent(node: Node): void;
|
|
111
113
|
compose(): void;
|
|
112
|
-
insertBefore(node: Fragment): void;
|
|
113
|
-
insertAfter(node: Fragment): void;
|
|
114
|
+
insertBefore(node: Fragment<Node, Element, TagOptions>): void;
|
|
115
|
+
insertAfter(node: Fragment<Node, Element, TagOptions>): void;
|
|
114
116
|
remove(): void;
|
|
115
117
|
destroy(): void;
|
|
116
118
|
}
|
|
117
|
-
interface TextProps {
|
|
119
|
+
export interface TextProps {
|
|
118
120
|
text: unknown;
|
|
119
121
|
}
|
|
120
122
|
/**
|
|
@@ -122,11 +124,11 @@ interface TextProps {
|
|
|
122
124
|
* @class TextNode
|
|
123
125
|
* @extends Fragment
|
|
124
126
|
*/
|
|
125
|
-
export declare class TextNode extends Fragment<TextProps> {
|
|
126
|
-
|
|
127
|
-
constructor(input: TextProps);
|
|
128
|
-
compose(): void;
|
|
129
|
-
protected findFirstChild(): Node;
|
|
127
|
+
export declare abstract class TextNode<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions, TextProps> {
|
|
128
|
+
protected handler: ((v: unknown) => void) | null;
|
|
129
|
+
constructor(input: TextProps, runner: Runner<Node, Element, TagOptions>);
|
|
130
|
+
abstract compose(): void;
|
|
131
|
+
protected abstract findFirstChild(): Node;
|
|
130
132
|
destroy(): void;
|
|
131
133
|
}
|
|
132
134
|
/**
|
|
@@ -134,124 +136,31 @@ export declare class TextNode extends Fragment<TextProps> {
|
|
|
134
136
|
* @class INode
|
|
135
137
|
* @extends Fragment
|
|
136
138
|
*/
|
|
137
|
-
export declare class INode<
|
|
138
|
-
/**
|
|
139
|
-
* Defines if node is unmounted
|
|
140
|
-
* @type {boolean}
|
|
141
|
-
*/
|
|
142
|
-
protected unmounted: boolean;
|
|
139
|
+
export declare abstract class INode<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions, TagOptions> {
|
|
143
140
|
/**
|
|
144
141
|
* The element of vasille node
|
|
145
142
|
* @type Element
|
|
146
143
|
*/
|
|
147
144
|
protected node: Element;
|
|
148
145
|
get element(): Element;
|
|
149
|
-
/**
|
|
150
|
-
* Bind attribute value
|
|
151
|
-
* @param name {String} name of attribute
|
|
152
|
-
* @param value {IValue} value
|
|
153
|
-
*/
|
|
154
|
-
attr(name: string, value: IValue<string | number | boolean | null | undefined>): void;
|
|
155
|
-
/**
|
|
156
|
-
* Set attribute value
|
|
157
|
-
* @param name {string} name of attribute
|
|
158
|
-
* @param value {string} value
|
|
159
|
-
*/
|
|
160
|
-
setAttr(name: string, value: string | number | boolean | null | undefined): this;
|
|
161
|
-
/**
|
|
162
|
-
* Adds a CSS class
|
|
163
|
-
* @param cl {string} Class name
|
|
164
|
-
*/
|
|
165
|
-
addClass(cl: string): void;
|
|
166
|
-
/**
|
|
167
|
-
* Adds some CSS classes
|
|
168
|
-
* @param cl {string} classes names
|
|
169
|
-
*/
|
|
170
|
-
removeClass(cl: string): void;
|
|
171
|
-
/**
|
|
172
|
-
* Bind a CSS class
|
|
173
|
-
* @param className {IValue}
|
|
174
|
-
*/
|
|
175
|
-
bindClass(className: IValue<string>): void;
|
|
176
|
-
/**
|
|
177
|
-
* Bind a floating class name
|
|
178
|
-
* @param cond {IValue} condition
|
|
179
|
-
* @param className {string} class name
|
|
180
|
-
*/
|
|
181
|
-
floatingClass(cond: IValue<boolean>, className: string): void;
|
|
182
|
-
/**
|
|
183
|
-
* Defines a style attribute
|
|
184
|
-
* @param name {String} name of style attribute
|
|
185
|
-
* @param value {IValue} value
|
|
186
|
-
*/
|
|
187
|
-
style(name: string, value: IValue<string | number | number[]>): void;
|
|
188
|
-
/**
|
|
189
|
-
* Sets a style property value
|
|
190
|
-
* @param prop {string} Property name
|
|
191
|
-
* @param value {string} Property value
|
|
192
|
-
*/
|
|
193
|
-
setStyle(prop: string, value: string | number | number[]): this;
|
|
194
|
-
/**
|
|
195
|
-
* Add a listener for an event
|
|
196
|
-
* @param name {string} Event name
|
|
197
|
-
* @param handler {function (Event)} Event handler
|
|
198
|
-
* @param options {Object | boolean} addEventListener options
|
|
199
|
-
*/
|
|
200
|
-
listen(name: string, handler: (ev: Event) => void, options?: boolean | AddEventListenerOptions): void;
|
|
201
146
|
insertAdjacent(node: Node): void;
|
|
202
|
-
|
|
203
|
-
* A v-show & ngShow alternative
|
|
204
|
-
* @param cond {IValue} show condition
|
|
205
|
-
*/
|
|
206
|
-
bindShow(cond: IValue<unknown>): void;
|
|
207
|
-
/**
|
|
208
|
-
* bind HTML
|
|
209
|
-
* @param value {IValue}
|
|
210
|
-
*/
|
|
211
|
-
bindDomApi(name: string, value: IValue<string>): void;
|
|
212
|
-
protected applyAttrs(attrs: Record<string, AttrType<number | boolean>>): void;
|
|
213
|
-
protected applyStyle(style: Record<string, string | number | number[] | IValue<string | number | number[]>>): void;
|
|
214
|
-
protected applyBind(bind: Record<string, any>): void;
|
|
215
|
-
protected applyOptions(options: T): void;
|
|
216
|
-
}
|
|
217
|
-
export interface TagOptionsWithSlot extends TagOptions {
|
|
218
|
-
slot?: (ctx: Tag) => void;
|
|
219
|
-
callback?: (node: Element) => void;
|
|
147
|
+
protected abstract applyOptions(options: TagOptions): void;
|
|
220
148
|
}
|
|
221
149
|
/**
|
|
222
150
|
* Represents an Vasille.js HTML element node
|
|
223
151
|
* @class Tag
|
|
224
152
|
* @extends INode
|
|
225
153
|
*/
|
|
226
|
-
export declare class Tag extends INode<
|
|
227
|
-
constructor(input:
|
|
228
|
-
compose(): void;
|
|
229
|
-
protected findFirstChild(): Node | undefined;
|
|
230
|
-
insertAdjacent(node: Node): void;
|
|
154
|
+
export declare abstract class Tag<Node, Element, TagOptions extends object> extends INode<Node, Element, TagOptions> {
|
|
155
|
+
constructor(input: TagOptions, runner: Runner<Node, Element, TagOptions>, tagName: string);
|
|
156
|
+
abstract compose(): void;
|
|
157
|
+
protected findFirstChild(): Node | Element | undefined;
|
|
231
158
|
appendNode(node: Node): void;
|
|
232
|
-
extent(options: TagOptions): void;
|
|
233
|
-
/**
|
|
234
|
-
* Mount/Unmount a node
|
|
235
|
-
* @param cond {IValue} show condition
|
|
236
|
-
*/
|
|
237
|
-
bindMount(cond: IValue<unknown>): void;
|
|
238
|
-
/**
|
|
239
|
-
* Runs GC
|
|
240
|
-
*/
|
|
241
|
-
destroy(): void;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Represents a vasille extension node
|
|
245
|
-
* @class Extension
|
|
246
|
-
* @extends INode
|
|
247
|
-
*/
|
|
248
|
-
export declare class Extension extends Fragment {
|
|
249
|
-
tag(tagName: string, input: TagOptionsWithSlot): void;
|
|
250
159
|
}
|
|
251
160
|
/**
|
|
252
161
|
* Defines a node which can switch its children conditionally
|
|
253
162
|
*/
|
|
254
|
-
export declare class SwitchedNode extends Fragment {
|
|
163
|
+
export declare class SwitchedNode<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions> {
|
|
255
164
|
/**
|
|
256
165
|
* Index of current true condition
|
|
257
166
|
* @type number
|
|
@@ -270,19 +179,19 @@ export declare class SwitchedNode extends Fragment {
|
|
|
270
179
|
/**
|
|
271
180
|
* Constructs a switch node and define a sync function
|
|
272
181
|
*/
|
|
273
|
-
constructor();
|
|
182
|
+
constructor(runner: Runner<Node, Element, TagOptions>);
|
|
274
183
|
addCase(case_: {
|
|
275
184
|
cond: IValue<unknown>;
|
|
276
|
-
cb: (node: Fragment) => void;
|
|
185
|
+
cb: (node: Fragment<Node, Element, TagOptions>) => void;
|
|
277
186
|
}): void;
|
|
278
187
|
/**
|
|
279
188
|
* Creates a child node
|
|
280
189
|
* @param cb {function(Fragment)} Call-back
|
|
281
190
|
*/
|
|
282
|
-
createChild(cb: (node: Fragment) => void): void;
|
|
191
|
+
createChild(cb: (node: Fragment<Node, Element, TagOptions>) => void): void;
|
|
283
192
|
destroy(): void;
|
|
284
193
|
}
|
|
285
|
-
interface DebugProps {
|
|
194
|
+
export interface DebugProps {
|
|
286
195
|
text: IValue<unknown>;
|
|
287
196
|
}
|
|
288
197
|
/**
|
|
@@ -290,13 +199,9 @@ interface DebugProps {
|
|
|
290
199
|
* @class DebugNode
|
|
291
200
|
* @extends Fragment
|
|
292
201
|
*/
|
|
293
|
-
export declare class DebugNode extends Fragment<DebugProps> {
|
|
294
|
-
|
|
295
|
-
constructor(input: DebugProps);
|
|
296
|
-
compose(): void;
|
|
297
|
-
/**
|
|
298
|
-
* Runs garbage collector
|
|
299
|
-
*/
|
|
202
|
+
export declare abstract class DebugNode<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions, DebugProps> {
|
|
203
|
+
protected handler: ((v: unknown) => void) | null;
|
|
204
|
+
constructor(input: DebugProps, runner: Runner<Node, Element, TagOptions>);
|
|
205
|
+
abstract compose(): void;
|
|
300
206
|
destroy(): void;
|
|
301
207
|
}
|
|
302
|
-
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IValue } from "../core/ivalue.js";
|
|
2
|
+
import { DebugNode, Tag, TextNode } from "./node.js";
|
|
3
|
+
export interface Runner<Node, Element, TagOptions extends object> {
|
|
4
|
+
debugUi: boolean;
|
|
5
|
+
insertBefore(node: Node, before: Node | Element): void;
|
|
6
|
+
appendChild(node: Element, child: Node | Element): void;
|
|
7
|
+
textNode(text: unknown): TextNode<Node, Element, TagOptions>;
|
|
8
|
+
debugNode(text: IValue<unknown>): DebugNode<Node, Element, TagOptions>;
|
|
9
|
+
tag(tagName: string, input: TagOptions, cb?: (ctx: Tag<Node, Element, TagOptions>) => void): Tag<Node, Element, TagOptions>;
|
|
10
|
+
}
|
package/types/node/watch.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { Fragment } from "./node";
|
|
2
|
-
import { IValue } from "../core/ivalue";
|
|
3
|
-
|
|
1
|
+
import { Fragment } from "./node.js";
|
|
2
|
+
import { IValue } from "../core/ivalue.js";
|
|
3
|
+
import { Runner } from "./runner.js";
|
|
4
|
+
interface WatchOptions<Node, Element, TagOptions extends object, T> {
|
|
4
5
|
model: IValue<T>;
|
|
5
|
-
slot?: (ctx: Fragment, value: T) => void;
|
|
6
|
+
slot?: (ctx: Fragment<Node, Element, TagOptions>, value: T) => void;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Watch Node
|
|
9
10
|
* @class Watch
|
|
10
11
|
* @extends Fragment
|
|
11
12
|
*/
|
|
12
|
-
export declare class Watch<T> extends Fragment<WatchOptions<T>> {
|
|
13
|
-
constructor(input: WatchOptions<T>);
|
|
13
|
+
export declare class Watch<Node, Element, TagOptions extends object, T> extends Fragment<Node, Element, TagOptions, WatchOptions<Node, Element, TagOptions, T>> {
|
|
14
|
+
constructor(input: WatchOptions<Node, Element, TagOptions, T>, runner: Runner<Node, Element, TagOptions>);
|
|
14
15
|
compose(): void;
|
|
15
16
|
}
|
|
16
17
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Binding } from "./binding";
|
|
2
|
-
import type { INode } from "
|
|
3
|
-
import type { IValue } from "
|
|
1
|
+
import { Binding } from "./binding.js";
|
|
2
|
+
import type { INode } from "../../../node/node.js";
|
|
3
|
+
import type { IValue } from "../../../core/ivalue.js";
|
|
4
4
|
/**
|
|
5
5
|
* Represents an Attribute binding description
|
|
6
6
|
* @class AttributeBinding
|
|
@@ -13,5 +13,5 @@ export declare class AttributeBinding extends Binding<string | number | boolean
|
|
|
13
13
|
* @param name {String} the name of attribute
|
|
14
14
|
* @param value {IValue} value to bind
|
|
15
15
|
*/
|
|
16
|
-
constructor(node: INode, name: string, value: IValue<string | number | boolean | null | undefined>);
|
|
16
|
+
constructor(node: INode<Node, Element, object>, name: string, value: IValue<string | number | boolean | null | undefined>);
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Destroyable } from "
|
|
2
|
-
import type { IValue } from "
|
|
1
|
+
import { Destroyable } from "../../../core/destroyable.js";
|
|
2
|
+
import type { IValue } from "../../../core/ivalue.js";
|
|
3
3
|
/**
|
|
4
4
|
* Describe a common binding logic
|
|
5
5
|
* @class Binding
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Binding } from "./binding.js";
|
|
2
|
+
import type { INode } from "../../../node/node.js";
|
|
3
|
+
import type { IValue } from "../../../core/ivalue.js";
|
|
4
|
+
export declare class StaticClassBinding extends Binding<boolean> {
|
|
5
|
+
private current;
|
|
6
|
+
constructor(node: INode<Node, Element, object>, name: string, value: IValue<boolean>);
|
|
7
|
+
}
|
|
8
|
+
export declare class DynamicalClassBinding extends Binding<string> {
|
|
9
|
+
private current;
|
|
10
|
+
constructor(node: INode<Node, Element, object>, value: IValue<string>);
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Binding } from "./binding";
|
|
2
|
-
import type { INode } from "
|
|
3
|
-
import type { IValue } from "
|
|
1
|
+
import { Binding } from "./binding.js";
|
|
2
|
+
import type { INode } from "../../../node/node.js";
|
|
3
|
+
import type { IValue } from "../../../core/ivalue.js";
|
|
4
4
|
export declare function stringifyStyleValue(value: string | number | number[]): string;
|
|
5
5
|
/**
|
|
6
6
|
* Describes a style attribute binding
|
|
@@ -14,5 +14,5 @@ export declare class StyleBinding extends Binding<string | number | number[]> {
|
|
|
14
14
|
* @param name {string} the name of style property
|
|
15
15
|
* @param value {IValue} the value to bind
|
|
16
16
|
*/
|
|
17
|
-
constructor(node: INode, name: string, value: IValue<string | number | number[]>);
|
|
17
|
+
constructor(node: INode<Node, Element, object>, name: string, value: IValue<string | number | number[]>);
|
|
18
18
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TextNode as AbstractTextNode, DebugNode as AbstractDebugNode, Tag as AbstractTag, Runner as IRunner, IValue } from "../../index.js";
|
|
2
|
+
export type AttrType<T> = IValue<T | string | null> | T | string | null | undefined;
|
|
3
|
+
export type StyleType<T> = T | number | number[] | IValue<string | number | number[]>;
|
|
4
|
+
export interface TagOptions {
|
|
5
|
+
attr?: Record<string, AttrType<number | boolean>>;
|
|
6
|
+
class?: (string | IValue<string> | Record<string, boolean | IValue<boolean>>)[];
|
|
7
|
+
style?: Record<string, StyleType<string>>;
|
|
8
|
+
events?: Record<string, (...args: unknown[]) => unknown>;
|
|
9
|
+
bind?: Record<string, any>;
|
|
10
|
+
slot?: (ctx: Tag) => void;
|
|
11
|
+
callback?: (node: Element) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class TextNode extends AbstractTextNode<Node, Element, TagOptions> {
|
|
14
|
+
readonly runner: Runner;
|
|
15
|
+
protected node: Text;
|
|
16
|
+
compose(): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
protected findFirstChild(): Node;
|
|
19
|
+
}
|
|
20
|
+
export declare class DebugNode extends AbstractDebugNode<Node, Element, TagOptions> {
|
|
21
|
+
readonly runner: Runner;
|
|
22
|
+
protected node: Comment;
|
|
23
|
+
compose(): void;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
protected findFirstChild(): Node | Element | undefined;
|
|
26
|
+
}
|
|
27
|
+
export declare class Tag extends AbstractTag<Node, Element, TagOptions> {
|
|
28
|
+
readonly runner: Runner;
|
|
29
|
+
compose(): void;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
protected applyOptions(options: TagOptions): void;
|
|
32
|
+
}
|
|
33
|
+
export declare class Runner implements IRunner<Node, Element, TagOptions> {
|
|
34
|
+
readonly debugUi: boolean;
|
|
35
|
+
readonly document: Document;
|
|
36
|
+
constructor(debugUi: boolean, document: Document);
|
|
37
|
+
insertBefore(node: Node, before: Element | Node): void;
|
|
38
|
+
appendChild(node: Element, child: Element | Node): void;
|
|
39
|
+
textNode(text: unknown): AbstractTextNode<Node, Element, TagOptions>;
|
|
40
|
+
debugNode(text: IValue<unknown>): AbstractDebugNode<Node, Element, TagOptions>;
|
|
41
|
+
tag(tagName: string, input: TagOptions, cb?: ((ctx: AbstractTag<Node, Element, TagOptions>) => void) | undefined): AbstractTag<Node, Element, TagOptions>;
|
|
42
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/
|
|
1
|
+
{"root":["../src/index.ts","../src/core/core.ts","../src/core/destroyable.ts","../src/core/errors.ts","../src/core/ivalue.ts","../src/functional/safety.ts","../src/models/array-model.ts","../src/models/listener.ts","../src/models/map-model.ts","../src/models/model.ts","../src/models/set-model.ts","../src/node/app.ts","../src/node/node.ts","../src/node/runner.ts","../src/node/watch.ts","../src/runner/web/runner.ts","../src/runner/web/binding/attribute.ts","../src/runner/web/binding/binding.ts","../src/runner/web/binding/class.ts","../src/runner/web/binding/style.ts","../src/value/expression.ts","../src/value/pointer.ts","../src/value/reference.ts","../src/views/array-view.ts","../src/views/base-view.ts","../src/views/map-view.ts","../src/views/repeat-node.ts","../src/views/set-view.ts"],"version":"5.8.3"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IValue } from "../core/ivalue";
|
|
1
|
+
import { IValue } from "../core/ivalue.js";
|
|
2
2
|
export type KindOfIValue<T extends unknown[]> = {
|
|
3
3
|
[K in keyof T]: IValue<T[K]>;
|
|
4
4
|
};
|
|
@@ -36,7 +36,7 @@ export declare class Expression<T, Args extends unknown[]> extends IValue<T> {
|
|
|
36
36
|
* @param values
|
|
37
37
|
* @param link {Boolean} links immediately if true
|
|
38
38
|
*/
|
|
39
|
-
constructor(func: (...args: Args) => T,
|
|
39
|
+
constructor(func: (...args: Args) => T, values: KindOfIValue<Args>);
|
|
40
40
|
get $(): T;
|
|
41
41
|
set $(value: T);
|
|
42
42
|
on(handler: (value: T) => void): void;
|
package/types/value/pointer.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { BaseView, BaseViewOptions } from "./base-view";
|
|
2
|
-
import { ArrayModel } from "../models/array-model";
|
|
3
|
-
import { Fragment } from "../node/node";
|
|
1
|
+
import { BaseView, BaseViewOptions } from "./base-view.js";
|
|
2
|
+
import { ArrayModel } from "../models/array-model.js";
|
|
3
|
+
import { Fragment } from "../node/node.js";
|
|
4
4
|
/**
|
|
5
5
|
* Represents a view of an array model
|
|
6
6
|
* @class ArrayView
|
|
7
7
|
* @extends BaseView
|
|
8
8
|
*/
|
|
9
|
-
export declare class ArrayView<T> extends BaseView<T, T, ArrayModel<T>> {
|
|
10
|
-
createChild(input: BaseViewOptions<T, T, ArrayModel<T>>, id: T, item: T, before?: Fragment): any;
|
|
9
|
+
export declare class ArrayView<Node, Element, TagOptions extends object, T> extends BaseView<Node, Element, TagOptions, T, T, ArrayModel<T>> {
|
|
10
|
+
createChild(input: BaseViewOptions<Node, Element, TagOptions, T, T, ArrayModel<T>>, id: T, item: T, before?: Fragment<Node, Element, TagOptions>): any;
|
|
11
11
|
compose(): void;
|
|
12
12
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Runner } from "../node/runner.js";
|
|
2
|
+
import { RepeatNode, RepeatNodeOptions } from "./repeat-node.js";
|
|
3
|
+
import { ListenableModel } from "../models/model.js";
|
|
4
|
+
export interface BaseViewOptions<Node, Element, TagOptions extends object, K, T, Model extends ListenableModel<K, T>> extends RepeatNodeOptions<Node, Element, TagOptions, T, K> {
|
|
4
5
|
model: Model;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
@@ -9,8 +10,8 @@ export interface BaseViewOptions<K, T, Model extends ListenableModel<K, T>> exte
|
|
|
9
10
|
* @extends RepeatNode
|
|
10
11
|
* @implements IModel
|
|
11
12
|
*/
|
|
12
|
-
export declare class BaseView<K, T, Model extends ListenableModel<K, T>> extends RepeatNode<K, T, BaseViewOptions<K, T, Model>> {
|
|
13
|
-
readonly input: BaseViewOptions<K, T, Model>;
|
|
13
|
+
export declare class BaseView<Node, Element, TagOptions extends object, K, T, Model extends ListenableModel<K, T>> extends RepeatNode<Node, Element, TagOptions, K, T, BaseViewOptions<Node, Element, TagOptions, K, T, Model>> {
|
|
14
|
+
readonly input: BaseViewOptions<Node, Element, TagOptions, K, T, Model>;
|
|
14
15
|
/**
|
|
15
16
|
* Handler to catch values addition
|
|
16
17
|
* @type {Function}
|
|
@@ -21,7 +22,7 @@ export declare class BaseView<K, T, Model extends ListenableModel<K, T>> extends
|
|
|
21
22
|
* @type {Function}
|
|
22
23
|
*/
|
|
23
24
|
protected removeHandler: (index: K, value: T) => void;
|
|
24
|
-
constructor(input: BaseViewOptions<K, T, Model>, name?: string);
|
|
25
|
+
constructor(input: BaseViewOptions<Node, Element, TagOptions, K, T, Model>, runner: Runner<Node, Element, TagOptions>, name?: string);
|
|
25
26
|
compose(): void;
|
|
26
27
|
destroy(): void;
|
|
27
28
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BaseView } from "./base-view";
|
|
2
|
-
import { MapModel } from "../models/map-model";
|
|
1
|
+
import { BaseView } from "./base-view.js";
|
|
2
|
+
import { MapModel } from "../models/map-model.js";
|
|
3
3
|
/**
|
|
4
4
|
* Create a children pack for each map value
|
|
5
5
|
* @class MapView
|
|
6
6
|
* @extends BaseView
|
|
7
7
|
*/
|
|
8
|
-
export declare class MapView<K, T> extends BaseView<K, T, MapModel<K, T>> {
|
|
8
|
+
export declare class MapView<Node, Element, TagOptions extends object, K, T> extends BaseView<Node, Element, TagOptions, K, T, MapModel<K, T>> {
|
|
9
9
|
compose(): void;
|
|
10
10
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { Fragment } from "../node/node";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Fragment } from "../node/node.js";
|
|
2
|
+
import { Runner } from "../node/runner.js";
|
|
3
|
+
export interface RepeatNodeOptions<Node, Element, TagOptions extends object, T, IdT> {
|
|
4
|
+
slot?: (ctx: Fragment<Node, Element, TagOptions>, value: T, index: IdT) => void;
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
6
7
|
* Repeat node repeats its children
|
|
7
8
|
* @class RepeatNode
|
|
8
9
|
* @extends Fragment
|
|
9
10
|
*/
|
|
10
|
-
export declare class RepeatNode<IdT, T, Opts extends RepeatNodeOptions<T, IdT> = RepeatNodeOptions<T, IdT>> extends Fragment<Opts> {
|
|
11
|
+
export declare class RepeatNode<Node, Element, TagOptions extends object, IdT, T, Opts extends RepeatNodeOptions<Node, Element, TagOptions, T, IdT> = RepeatNodeOptions<Node, Element, TagOptions, T, IdT>> extends Fragment<Node, Element, TagOptions, Opts> {
|
|
11
12
|
/**
|
|
12
13
|
* Children node hash
|
|
13
14
|
* @type {Map}
|
|
14
15
|
*/
|
|
15
|
-
protected nodes: Map<IdT, Fragment
|
|
16
|
-
constructor(input: Opts, name?: string);
|
|
17
|
-
createChild(opts: Opts, id: IdT, item: T, before?: Fragment): any;
|
|
16
|
+
protected nodes: Map<IdT, Fragment<Node, Element, TagOptions>>;
|
|
17
|
+
constructor(input: Opts, runner: Runner<Node, Element, TagOptions>, name?: string);
|
|
18
|
+
createChild(opts: Opts, id: IdT, item: T, before?: Fragment<Node, Element, TagOptions>): any;
|
|
18
19
|
destroyChild(id: IdT, item: T): void;
|
|
19
20
|
destroy(): void;
|
|
20
21
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Runner } from "../node/runner.js";
|
|
2
|
+
import { BaseView, BaseViewOptions } from "./base-view.js";
|
|
3
|
+
import { SetModel } from "../models/set-model.js";
|
|
3
4
|
/**
|
|
4
5
|
* Create a children pack for each set value
|
|
5
6
|
* @class SetView
|
|
6
7
|
* @extends BaseView
|
|
7
8
|
*/
|
|
8
|
-
export declare class SetView<T> extends BaseView<T, T, SetModel<T>> {
|
|
9
|
-
constructor(input: BaseViewOptions<T, T, SetModel<T
|
|
9
|
+
export declare class SetView<Node, Element, TagOptions extends object, T> extends BaseView<Node, Element, TagOptions, T, T, SetModel<T>> {
|
|
10
|
+
constructor(input: BaseViewOptions<Node, Element, TagOptions, T, T, SetModel<T>>, runner: Runner<Node, Element, TagOptions>);
|
|
10
11
|
compose(): {};
|
|
11
12
|
}
|
package/lib/core/config.js
DELETED