vasille 4.3.0 → 5.0.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 +47 -31
- package/lib/dev/components.js +82 -0
- package/lib/dev/core.js +15 -0
- package/lib/dev/index.js +8 -0
- package/lib/dev/inspectable.js +113 -0
- package/lib/dev/models.js +147 -0
- package/lib/dev/node.js +59 -0
- package/lib/dev/runner.js +141 -0
- package/lib/dev/state.js +194 -0
- package/lib/dev/views.js +62 -0
- package/lib/index.js +1 -2
- package/lib/node/app.js +1 -1
- package/lib/node/node.js +16 -34
- package/lib/runner/web/binding/class.js +2 -15
- package/lib/runner/web/runner.js +25 -53
- package/lib/value/expression.js +3 -2
- package/lib/views/repeat-node.js +6 -2
- package/package.json +7 -1
- package/types/dev/components.d.ts +20 -0
- package/types/dev/core.d.ts +8 -0
- package/types/dev/index.d.ts +8 -0
- package/types/dev/inspectable.d.ts +244 -0
- package/types/dev/models.d.ts +38 -0
- package/types/dev/node.d.ts +12 -0
- package/types/dev/runner.d.ts +37 -0
- package/types/dev/state.d.ts +53 -0
- package/types/dev/views.d.ts +22 -0
- package/types/index.d.ts +2 -3
- package/types/node/app.d.ts +8 -9
- package/types/node/node.d.ts +17 -34
- package/types/node/runner.d.ts +2 -5
- package/types/node/watch.d.ts +5 -6
- package/types/runner/web/runner.d.ts +21 -25
- package/types/value/expression.d.ts +2 -1
- package/types/views/array-view.d.ts +3 -2
- package/types/views/base-view.d.ts +4 -4
- package/types/views/map-view.d.ts +2 -1
- package/types/views/repeat-node.d.ts +8 -7
- package/types/views/set-view.d.ts +3 -3
- package/lib/value/pointer.js +0 -61
- package/types/value/pointer.d.ts +0 -46
package/types/index.d.ts
CHANGED
|
@@ -7,9 +7,8 @@ export { Listener } from "./models/listener.js";
|
|
|
7
7
|
export { MapModel } from "./models/map-model.js";
|
|
8
8
|
export { SetModel } from "./models/set-model.js";
|
|
9
9
|
export { App, Portal } from "./node/app.js";
|
|
10
|
-
export { Fragment, Tag, TextNode,
|
|
10
|
+
export { Fragment, Tag, TextNode, SwitchedNode } from "./node/node.js";
|
|
11
11
|
export { Expression, type KindOfIValue } from "./value/expression.js";
|
|
12
|
-
export { Forward, Backward } from "./value/pointer.js";
|
|
13
12
|
export { Reference } from "./value/reference.js";
|
|
14
13
|
export { ArrayView } from "./views/array-view.js";
|
|
15
14
|
export { BaseView } from "./views/base-view.js";
|
|
@@ -18,4 +17,4 @@ export { SetView } from "./views/set-view.js";
|
|
|
18
17
|
export { userError } from "./core/errors.js";
|
|
19
18
|
export { type ListenableModel } from "./models/model.js";
|
|
20
19
|
export { Watch } from "./node/watch.js";
|
|
21
|
-
export { type Runner } from "./node/runner.js";
|
|
20
|
+
export { type IRunner as Runner } from "./node/runner.js";
|
package/types/node/app.d.ts
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { Fragment, Root } from "./node.js";
|
|
2
|
-
import {
|
|
2
|
+
import { IRunner } from "./runner.js";
|
|
3
3
|
/**
|
|
4
4
|
* Represents a Vasille.js application
|
|
5
5
|
* @class App
|
|
6
6
|
* @extends Root
|
|
7
7
|
*/
|
|
8
|
-
export declare class App<Node, Element, TagOptions extends object,
|
|
8
|
+
export declare class App<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends Root<Node, Element, TagOptions, Runner> {
|
|
9
9
|
private readonly node;
|
|
10
10
|
/**
|
|
11
11
|
* Constructs an app node
|
|
12
12
|
* @param node {Element} The root of application
|
|
13
|
-
* @param runner {
|
|
13
|
+
* @param runner {IRunner} A adapter which execute DOM manipulation
|
|
14
14
|
*/
|
|
15
|
-
constructor(node: Element, runner: Runner
|
|
15
|
+
constructor(node: Element, runner: Runner);
|
|
16
16
|
appendNode(node: Node): void;
|
|
17
17
|
}
|
|
18
|
-
interface PortalOptions<Node, Element, TagOptions extends object
|
|
18
|
+
export interface PortalOptions<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions>> {
|
|
19
19
|
node: Element;
|
|
20
|
-
slot?: (ctx: Fragment<Node, Element, TagOptions>) => void;
|
|
20
|
+
slot?: (ctx: Fragment<Node, Element, TagOptions, Runner>) => void;
|
|
21
21
|
}
|
|
22
|
-
export declare class Portal<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions> {
|
|
22
|
+
export declare class Portal<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends Fragment<Node, Element, TagOptions, Runner> {
|
|
23
23
|
private readonly node;
|
|
24
|
-
constructor(input: PortalOptions<Node, Element, TagOptions>, runner: Runner
|
|
24
|
+
constructor(input: PortalOptions<Node, Element, TagOptions, Runner>, runner: Runner);
|
|
25
25
|
appendNode(node: Node): void;
|
|
26
26
|
}
|
|
27
|
-
export {};
|
package/types/node/node.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { Reactive } from "../core/core.js";
|
|
2
|
-
import {
|
|
3
|
-
import { Runner } from "./runner.js";
|
|
2
|
+
import { IRunner } from "./runner.js";
|
|
4
3
|
/**
|
|
5
4
|
* This class is symbolic
|
|
6
5
|
* @extends Reactive
|
|
7
6
|
*/
|
|
8
|
-
export declare abstract class Root<Node, Element, TagOptions extends object> extends Reactive {
|
|
7
|
+
export declare abstract class Root<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends Reactive {
|
|
9
8
|
/**
|
|
10
9
|
* The children list
|
|
11
10
|
* @type Array
|
|
12
11
|
*/
|
|
13
12
|
readonly children: Set<Fragment<Node, Element, TagOptions>>;
|
|
14
|
-
readonly runner: Runner
|
|
13
|
+
readonly runner: Runner;
|
|
15
14
|
lastChild: Fragment<Node, Element, TagOptions> | undefined;
|
|
16
|
-
protected constructor(runner: Runner
|
|
15
|
+
protected constructor(runner: Runner);
|
|
17
16
|
/**
|
|
18
17
|
* Pushes a node to children immediately
|
|
19
18
|
* @param node {Fragment} A node to push
|
|
@@ -36,7 +35,6 @@ export declare abstract class Root<Node, Element, TagOptions extends object> ext
|
|
|
36
35
|
* @param text {String | IValue} A text fragment string
|
|
37
36
|
*/
|
|
38
37
|
text(text: unknown): void;
|
|
39
|
-
debug(text: IValue<unknown>): void;
|
|
40
38
|
/**
|
|
41
39
|
* Defines a tag element
|
|
42
40
|
* @param tagName {String} the tag name
|
|
@@ -52,9 +50,9 @@ export declare abstract class Root<Node, Element, TagOptions extends object> ext
|
|
|
52
50
|
create<T extends Fragment<Node, Element, TagOptions>>(node: T, callback?: (ctx: T) => void): void;
|
|
53
51
|
destroy(): void;
|
|
54
52
|
}
|
|
55
|
-
export declare class Fragment<Node, Element, TagOptions extends object> extends Root<Node, Element, TagOptions> {
|
|
53
|
+
export declare class Fragment<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends Root<Node, Element, TagOptions, Runner> {
|
|
56
54
|
parent: Root<Node, Element, TagOptions>;
|
|
57
|
-
constructor(runner: Runner
|
|
55
|
+
constructor(runner: Runner);
|
|
58
56
|
/**
|
|
59
57
|
* Next node
|
|
60
58
|
* @type {?Fragment}
|
|
@@ -95,10 +93,10 @@ export interface TextProps {
|
|
|
95
93
|
* @class TextNode
|
|
96
94
|
* @extends Fragment
|
|
97
95
|
*/
|
|
98
|
-
export declare abstract class TextNode<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions> {
|
|
96
|
+
export declare abstract class TextNode<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends Fragment<Node, Element, TagOptions, Runner> {
|
|
99
97
|
protected handler: ((v: unknown) => void) | null;
|
|
100
98
|
protected readonly data: unknown;
|
|
101
|
-
constructor(input: TextProps, runner: Runner
|
|
99
|
+
constructor(input: TextProps, runner: Runner);
|
|
102
100
|
abstract compose(): void;
|
|
103
101
|
protected abstract findFirstChild(): Node;
|
|
104
102
|
destroy(): void;
|
|
@@ -108,7 +106,7 @@ export declare abstract class TextNode<Node, Element, TagOptions extends object>
|
|
|
108
106
|
* @class INode
|
|
109
107
|
* @extends Fragment
|
|
110
108
|
*/
|
|
111
|
-
export declare abstract class INode<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions> {
|
|
109
|
+
export declare abstract class INode<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends Fragment<Node, Element, TagOptions, Runner> {
|
|
112
110
|
/**
|
|
113
111
|
* The element of vasille node
|
|
114
112
|
* @type Element
|
|
@@ -123,22 +121,22 @@ export declare abstract class INode<Node, Element, TagOptions extends object> ex
|
|
|
123
121
|
* @class Tag
|
|
124
122
|
* @extends INode
|
|
125
123
|
*/
|
|
126
|
-
export declare abstract class Tag<Node, Element, TagOptions extends object> extends INode<Node, Element, TagOptions> {
|
|
124
|
+
export declare abstract class Tag<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends INode<Node, Element, TagOptions, Runner> {
|
|
127
125
|
readonly name: string;
|
|
128
126
|
readonly options: TagOptions;
|
|
129
|
-
constructor(options: TagOptions, runner: Runner
|
|
127
|
+
constructor(options: TagOptions, runner: Runner, tagName: string);
|
|
130
128
|
abstract compose(): void;
|
|
131
129
|
protected findFirstChild(): Node | Element | undefined;
|
|
132
130
|
appendNode(node: Node): void;
|
|
133
131
|
}
|
|
134
|
-
interface SwitchedNodeCase<Node, Element, TagOptions extends object
|
|
135
|
-
$case:
|
|
136
|
-
slot: (node: Fragment<Node, Element, TagOptions>) => void;
|
|
132
|
+
export interface SwitchedNodeCase<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions>> {
|
|
133
|
+
$case: unknown;
|
|
134
|
+
slot: (node: Fragment<Node, Element, TagOptions, Runner>) => void;
|
|
137
135
|
}
|
|
138
136
|
/**
|
|
139
137
|
* Defines a node which can switch its children conditionally
|
|
140
138
|
*/
|
|
141
|
-
export declare class SwitchedNode<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions> {
|
|
139
|
+
export declare class SwitchedNode<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends Fragment<Node, Element, TagOptions, Runner> {
|
|
142
140
|
/**
|
|
143
141
|
* Index of current true condition
|
|
144
142
|
* @type number
|
|
@@ -157,23 +155,8 @@ export declare class SwitchedNode<Node, Element, TagOptions extends object> exte
|
|
|
157
155
|
/**
|
|
158
156
|
* Constructs a switch node and define a sync function
|
|
159
157
|
*/
|
|
160
|
-
constructor(runner: Runner
|
|
158
|
+
constructor(runner: Runner, cases: SwitchedNodeCase<Node, Element, TagOptions, Runner>[], _default?: (node: Fragment<Node, Element, TagOptions>) => void);
|
|
161
159
|
compose(): void;
|
|
162
160
|
destroy(): void;
|
|
161
|
+
protected newChild(_index: number): Fragment<Node, Element, TagOptions, Runner>;
|
|
163
162
|
}
|
|
164
|
-
export interface DebugProps {
|
|
165
|
-
text: IValue<unknown>;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Represents a debug node
|
|
169
|
-
* @class DebugNode
|
|
170
|
-
* @extends Fragment
|
|
171
|
-
*/
|
|
172
|
-
export declare abstract class DebugNode<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions> {
|
|
173
|
-
protected handler: ((v: unknown) => void) | null;
|
|
174
|
-
protected readonly data: IValue<unknown>;
|
|
175
|
-
constructor(input: DebugProps, runner: Runner<Node, Element, TagOptions>);
|
|
176
|
-
abstract compose(): void;
|
|
177
|
-
destroy(): void;
|
|
178
|
-
}
|
|
179
|
-
export {};
|
package/types/node/runner.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DebugNode, Tag, TextNode } from "./node.js";
|
|
1
|
+
import { Tag, TextNode } from "./node.js";
|
|
3
2
|
/**
|
|
4
3
|
* A runner executes DOM manipulations
|
|
5
4
|
*/
|
|
6
|
-
export interface
|
|
7
|
-
debugUi: boolean;
|
|
5
|
+
export interface IRunner<Node, Element, TagOptions extends object> {
|
|
8
6
|
insertBefore(node: Node, before: Node | Element): void;
|
|
9
7
|
appendChild(node: Element, child: Node | Element): void;
|
|
10
8
|
textNode(text: unknown): TextNode<Node, Element, TagOptions>;
|
|
11
|
-
debugNode(text: IValue<unknown>): DebugNode<Node, Element, TagOptions>;
|
|
12
9
|
tag(tagName: string, input: TagOptions, cb?: (ctx: Tag<Node, Element, TagOptions>) => void): Tag<Node, Element, TagOptions>;
|
|
13
10
|
}
|
package/types/node/watch.d.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { Fragment } from "./node.js";
|
|
2
2
|
import { IValue } from "../core/ivalue.js";
|
|
3
|
-
import {
|
|
4
|
-
interface WatchOptions<Node, Element, TagOptions extends object, T> {
|
|
3
|
+
import { IRunner } from "./runner.js";
|
|
4
|
+
export interface WatchOptions<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions>, T> {
|
|
5
5
|
model: IValue<T>;
|
|
6
|
-
slot?: (ctx: Fragment<Node, Element, TagOptions>, value: T) => void;
|
|
6
|
+
slot?: (ctx: Fragment<Node, Element, TagOptions, Runner>, value: T) => void;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Watch Node
|
|
10
10
|
* @class Watch
|
|
11
11
|
* @extends Fragment
|
|
12
12
|
*/
|
|
13
|
-
export declare class Watch<Node, Element, TagOptions extends object, T> extends Fragment<Node, Element, TagOptions> {
|
|
13
|
+
export declare class Watch<Node, Element, TagOptions extends object, T, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends Fragment<Node, Element, TagOptions, Runner> {
|
|
14
14
|
private readonly model;
|
|
15
15
|
private readonly slot?;
|
|
16
16
|
private handler?;
|
|
17
|
-
constructor(input: WatchOptions<Node, Element, TagOptions, T>, runner: Runner
|
|
17
|
+
constructor(input: WatchOptions<Node, Element, TagOptions, Runner, T>, runner: Runner);
|
|
18
18
|
compose(): void;
|
|
19
19
|
destroy(): void;
|
|
20
20
|
}
|
|
21
|
-
export {};
|
|
@@ -1,42 +1,38 @@
|
|
|
1
|
-
import { TextNode as AbstractTextNode,
|
|
1
|
+
import { TextNode as AbstractTextNode, Tag as AbstractTag, Runner as IRunner, IValue } from "../../index.js";
|
|
2
2
|
export type AttrType<T> = IValue<T | string | null> | T | string | null | undefined;
|
|
3
3
|
export type StyleType<T> = T | number | number[] | IValue<string | number | number[]>;
|
|
4
4
|
export interface TagOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
/** attributes */
|
|
6
|
+
a?: Record<string, AttrType<number | boolean>>;
|
|
7
|
+
/** classes */
|
|
8
|
+
c?: (string | IValue<string> | Record<string, boolean | IValue<boolean>>)[];
|
|
9
|
+
/** style */
|
|
10
|
+
s?: Record<string, StyleType<string>>;
|
|
11
|
+
/** events */
|
|
12
|
+
e?: Record<string, ((...args: unknown[]) => unknown) | [(...args: unknown[]) => unknown, object | boolean]>;
|
|
13
|
+
/** bindings */
|
|
14
|
+
b?: Record<string, any>;
|
|
15
|
+
/** slot */
|
|
16
|
+
l?: (ctx: Tag<typeof this, Runner<typeof this>>) => void;
|
|
17
|
+
/** callback */
|
|
18
|
+
k?: (node: Element) => void;
|
|
12
19
|
}
|
|
13
|
-
export declare class TextNode extends AbstractTextNode<Node, Element,
|
|
14
|
-
readonly runner: Runner;
|
|
20
|
+
export declare class TextNode<Options extends TagOptions, RunnerT extends Runner<Options>> extends AbstractTextNode<Node, Element, Options, RunnerT> {
|
|
15
21
|
protected node: Text;
|
|
16
22
|
compose(): void;
|
|
17
23
|
destroy(): void;
|
|
18
24
|
protected findFirstChild(): Node;
|
|
19
25
|
}
|
|
20
|
-
export declare class
|
|
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;
|
|
26
|
+
export declare class Tag<Options extends TagOptions, RunnerT extends Runner<Options>> extends AbstractTag<Node, Element, Options, RunnerT> {
|
|
29
27
|
compose(): void;
|
|
30
28
|
destroy(): void;
|
|
31
29
|
protected applyOptions(options: TagOptions): void;
|
|
32
30
|
}
|
|
33
|
-
export declare class Runner implements IRunner<Node, Element,
|
|
34
|
-
readonly debugUi: boolean;
|
|
31
|
+
export declare class Runner<Options extends TagOptions> implements IRunner<Node, Element, Options> {
|
|
35
32
|
readonly document: Document;
|
|
36
|
-
constructor(
|
|
33
|
+
constructor(document: Document);
|
|
37
34
|
insertBefore(node: Node, before: Element | Node): void;
|
|
38
35
|
appendChild(node: Element, child: Element | Node): void;
|
|
39
|
-
textNode(text: unknown): AbstractTextNode<Node, Element,
|
|
40
|
-
|
|
41
|
-
tag(tagName: string, input: TagOptions, cb?: ((ctx: AbstractTag<Node, Element, TagOptions>) => void) | undefined): AbstractTag<Node, Element, TagOptions>;
|
|
36
|
+
textNode(text: unknown): AbstractTextNode<Node, Element, Options>;
|
|
37
|
+
tag(tagName: string, input: Options, cb?: ((ctx: AbstractTag<Node, Element, Options>) => void) | undefined): AbstractTag<Node, Element, Options>;
|
|
42
38
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Reactive } from "../core/core.js";
|
|
2
2
|
import { Destroyable } from "../core/destroyable.js";
|
|
3
|
+
import { Reference } from "./reference.js";
|
|
3
4
|
import { IValue } from "../core/ivalue.js";
|
|
4
5
|
export type KindOfIValue<T extends unknown[]> = {
|
|
5
6
|
[K in keyof T]: IValue<T[K]> | undefined;
|
|
@@ -27,7 +28,7 @@ export declare class Expression<T, Args extends unknown[]> extends IValue<T> imp
|
|
|
27
28
|
/**
|
|
28
29
|
* The buffer to keep the last calculated value
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
protected sync: Reference<T>;
|
|
31
32
|
/**
|
|
32
33
|
* Creates a function bounded to N values
|
|
33
34
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IRunner } from "../node/runner.js";
|
|
1
2
|
import { BaseView } from "./base-view.js";
|
|
2
3
|
import { ArrayModel } from "../models/array-model.js";
|
|
3
4
|
import { Fragment } from "../node/node.js";
|
|
@@ -6,7 +7,7 @@ import { Fragment } from "../node/node.js";
|
|
|
6
7
|
* @class ArrayView
|
|
7
8
|
* @extends BaseView
|
|
8
9
|
*/
|
|
9
|
-
export declare class ArrayView<Node, Element, TagOptions extends object, T> extends BaseView<Node, Element, TagOptions, T, T, ArrayModel<T
|
|
10
|
-
createChild(id: T, item: T, before?: Fragment<Node, Element, TagOptions>): any;
|
|
10
|
+
export declare class ArrayView<Node, Element, TagOptions extends object, T, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends BaseView<Node, Element, TagOptions, T, T, ArrayModel<T>, Runner> {
|
|
11
|
+
createChild(id: T, item: T, before?: Fragment<Node, Element, TagOptions, Runner>): any;
|
|
11
12
|
compose(): void;
|
|
12
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IRunner } from "../node/runner.js";
|
|
2
2
|
import { RepeatNode, RepeatNodeOptions } from "./repeat-node.js";
|
|
3
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
|
+
export interface BaseViewOptions<Node, Element, TagOptions extends object, K, T, Model extends ListenableModel<K, T>, Runner extends IRunner<Node, Element, TagOptions>> extends RepeatNodeOptions<Node, Element, TagOptions, Runner, T, K> {
|
|
5
5
|
model: Model;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
@@ -9,7 +9,7 @@ export interface BaseViewOptions<Node, Element, TagOptions extends object, K, T,
|
|
|
9
9
|
* @class BaseView
|
|
10
10
|
* @extends RepeatNode
|
|
11
11
|
*/
|
|
12
|
-
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>> {
|
|
12
|
+
export declare class BaseView<Node, Element, TagOptions extends object, K, T, Model extends ListenableModel<K, T>, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends RepeatNode<Node, Element, TagOptions, K, T, Runner, BaseViewOptions<Node, Element, TagOptions, K, T, Model, Runner>> {
|
|
13
13
|
model: Model;
|
|
14
14
|
/**
|
|
15
15
|
* Handler to catch values addition
|
|
@@ -21,7 +21,7 @@ export declare class BaseView<Node, Element, TagOptions extends object, K, T, Mo
|
|
|
21
21
|
* @type {Function}
|
|
22
22
|
*/
|
|
23
23
|
protected removeHandler: (index: K, value: T) => void;
|
|
24
|
-
constructor(input: BaseViewOptions<Node, Element, TagOptions, K, T, Model>, runner: Runner
|
|
24
|
+
constructor(input: BaseViewOptions<Node, Element, TagOptions, K, T, Model, Runner>, runner: Runner);
|
|
25
25
|
compose(): void;
|
|
26
26
|
destroy(): void;
|
|
27
27
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IRunner } from "../node/runner.js";
|
|
1
2
|
import { BaseView } from "./base-view.js";
|
|
2
3
|
import { MapModel } from "../models/map-model.js";
|
|
3
4
|
/**
|
|
@@ -5,6 +6,6 @@ import { MapModel } from "../models/map-model.js";
|
|
|
5
6
|
* @class MapView
|
|
6
7
|
* @extends BaseView
|
|
7
8
|
*/
|
|
8
|
-
export declare class MapView<Node, Element, TagOptions extends object, K, T> extends BaseView<Node, Element, TagOptions, K, T, MapModel<K, T
|
|
9
|
+
export declare class MapView<Node, Element, TagOptions extends object, K, T, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends BaseView<Node, Element, TagOptions, K, T, MapModel<K, T>, Runner> {
|
|
9
10
|
compose(): void;
|
|
10
11
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment } from "../node/node.js";
|
|
2
|
-
import {
|
|
3
|
-
export interface RepeatNodeOptions<Node, Element, TagOptions extends object, T, IdT> {
|
|
2
|
+
import { IRunner } from "../node/runner.js";
|
|
3
|
+
export interface RepeatNodeOptions<Node, Element, TagOptions extends object, Runner extends IRunner<Node, Element, TagOptions>, T, IdT> {
|
|
4
4
|
slot?: (ctx: Fragment<Node, Element, TagOptions>, value: T, index: IdT) => void;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
@@ -8,15 +8,16 @@ export interface RepeatNodeOptions<Node, Element, TagOptions extends object, T,
|
|
|
8
8
|
* @class RepeatNode
|
|
9
9
|
* @extends Fragment
|
|
10
10
|
*/
|
|
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> {
|
|
11
|
+
export declare class RepeatNode<Node, Element, TagOptions extends object, IdT, T, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>, Opts extends RepeatNodeOptions<Node, Element, TagOptions, Runner, T, IdT> = RepeatNodeOptions<Node, Element, TagOptions, Runner, T, IdT>> extends Fragment<Node, Element, TagOptions, Runner> {
|
|
12
12
|
/**
|
|
13
13
|
* Children node hash
|
|
14
14
|
* @type {Map}
|
|
15
15
|
*/
|
|
16
|
-
protected nodes: Map<IdT, Fragment<Node, Element, TagOptions>>;
|
|
17
|
-
protected slot
|
|
18
|
-
constructor(input: Opts, runner: Runner
|
|
19
|
-
createChild(id: IdT, item: T, before?: Fragment<Node, Element, TagOptions>): any;
|
|
16
|
+
protected nodes: Map<IdT, Fragment<Node, Element, TagOptions, Runner>>;
|
|
17
|
+
protected slot: ((ctx: Fragment<Node, Element, TagOptions>, value: T, index: IdT) => void) | undefined;
|
|
18
|
+
constructor(input: Opts, runner: Runner);
|
|
19
|
+
createChild(id: IdT, item: T, before?: Fragment<Node, Element, TagOptions, Runner>): any;
|
|
20
20
|
destroyChild(id: IdT, item: T): void;
|
|
21
21
|
destroy(): void;
|
|
22
|
+
protected newChild(_id: IdT, _item: T): Fragment<Node, Element, TagOptions, Runner>;
|
|
22
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IRunner } from "../node/runner.js";
|
|
2
2
|
import { BaseView, BaseViewOptions } from "./base-view.js";
|
|
3
3
|
import { SetModel } from "../models/set-model.js";
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import { SetModel } from "../models/set-model.js";
|
|
|
6
6
|
* @class SetView
|
|
7
7
|
* @extends BaseView
|
|
8
8
|
*/
|
|
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
|
|
9
|
+
export declare class SetView<Node, Element, TagOptions extends object, T, Runner extends IRunner<Node, Element, TagOptions> = IRunner<Node, Element, TagOptions>> extends BaseView<Node, Element, TagOptions, T, T, SetModel<T>, Runner> {
|
|
10
|
+
constructor(input: BaseViewOptions<Node, Element, TagOptions, T, T, SetModel<T>, Runner>, runner: Runner);
|
|
11
11
|
compose(): void;
|
|
12
12
|
}
|
package/lib/value/pointer.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Reference } from "./reference.js";
|
|
2
|
-
/**
|
|
3
|
-
* Forward only link type
|
|
4
|
-
* @class Forward
|
|
5
|
-
* @extends Reference
|
|
6
|
-
*/
|
|
7
|
-
export class Forward extends Reference {
|
|
8
|
-
/**
|
|
9
|
-
* forwarded value
|
|
10
|
-
* @type IValue
|
|
11
|
-
*/
|
|
12
|
-
target;
|
|
13
|
-
/**
|
|
14
|
-
* Handler to receive updates from forwarded value
|
|
15
|
-
*/
|
|
16
|
-
handler;
|
|
17
|
-
/**
|
|
18
|
-
* Constructs a value forwarder
|
|
19
|
-
* @param value {IValue} is source of forwarded data
|
|
20
|
-
* @param ctx lifetime context
|
|
21
|
-
*/
|
|
22
|
-
constructor(value, ctx) {
|
|
23
|
-
super(value.V);
|
|
24
|
-
this.handler = (v) => {
|
|
25
|
-
this.V = v;
|
|
26
|
-
};
|
|
27
|
-
this.target = value;
|
|
28
|
-
value.on(this.handler);
|
|
29
|
-
ctx?.bind(this);
|
|
30
|
-
}
|
|
31
|
-
destroy() {
|
|
32
|
-
this.target.off(this.handler);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Backward only link type
|
|
37
|
-
* @class Backward
|
|
38
|
-
* @extends Reference
|
|
39
|
-
*/
|
|
40
|
-
export class Backward extends Reference {
|
|
41
|
-
/**
|
|
42
|
-
* target, which receive the updates
|
|
43
|
-
* @type IValue
|
|
44
|
-
*/
|
|
45
|
-
target;
|
|
46
|
-
/**
|
|
47
|
-
* Constructs a value backward stream
|
|
48
|
-
* @param value {IValue} target, which receive the updates
|
|
49
|
-
*/
|
|
50
|
-
constructor(value) {
|
|
51
|
-
super(value.V);
|
|
52
|
-
this.target = value;
|
|
53
|
-
}
|
|
54
|
-
get V() {
|
|
55
|
-
return super.V;
|
|
56
|
-
}
|
|
57
|
-
set V(value) {
|
|
58
|
-
super.V = value;
|
|
59
|
-
this.target.V = value;
|
|
60
|
-
}
|
|
61
|
-
}
|
package/types/value/pointer.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Reactive } from "../core/core.js";
|
|
2
|
-
import { Destroyable } from "../core/destroyable.js";
|
|
3
|
-
import { IValue } from "../core/ivalue.js";
|
|
4
|
-
import { Reference } from "./reference.js";
|
|
5
|
-
/**
|
|
6
|
-
* Forward only link type
|
|
7
|
-
* @class Forward
|
|
8
|
-
* @extends Reference
|
|
9
|
-
*/
|
|
10
|
-
export declare class Forward<T> extends Reference<T> implements Destroyable {
|
|
11
|
-
/**
|
|
12
|
-
* forwarded value
|
|
13
|
-
* @type IValue
|
|
14
|
-
*/
|
|
15
|
-
protected target: IValue<T>;
|
|
16
|
-
/**
|
|
17
|
-
* Handler to receive updates from forwarded value
|
|
18
|
-
*/
|
|
19
|
-
protected readonly handler: (value: T) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Constructs a value forwarder
|
|
22
|
-
* @param value {IValue} is source of forwarded data
|
|
23
|
-
* @param ctx lifetime context
|
|
24
|
-
*/
|
|
25
|
-
constructor(value: IValue<T>, ctx?: Reactive);
|
|
26
|
-
destroy(): void;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Backward only link type
|
|
30
|
-
* @class Backward
|
|
31
|
-
* @extends Reference
|
|
32
|
-
*/
|
|
33
|
-
export declare class Backward<T> extends Reference<T> {
|
|
34
|
-
/**
|
|
35
|
-
* target, which receive the updates
|
|
36
|
-
* @type IValue
|
|
37
|
-
*/
|
|
38
|
-
protected target: IValue<T>;
|
|
39
|
-
/**
|
|
40
|
-
* Constructs a value backward stream
|
|
41
|
-
* @param value {IValue} target, which receive the updates
|
|
42
|
-
*/
|
|
43
|
-
constructor(value: IValue<T>);
|
|
44
|
-
get V(): T;
|
|
45
|
-
set V(value: T);
|
|
46
|
-
}
|