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
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { TextNode as AbstractTextNode, DebugNode as AbstractDebugNode, Tag as AbstractTag, IValue, } from "../../index.js";
|
|
2
|
+
import { internalError } from "../../core/errors.js";
|
|
3
|
+
import { AttributeBinding } from "./binding/attribute.js";
|
|
4
|
+
import { DynamicalClassBinding, StaticClassBinding } from "./binding/class.js";
|
|
5
|
+
import { stringifyStyleValue, StyleBinding } from "./binding/style.js";
|
|
6
|
+
export class TextNode extends AbstractTextNode {
|
|
7
|
+
compose() {
|
|
8
|
+
const text = this.input.text;
|
|
9
|
+
this.node = this.runner.document.createTextNode((text instanceof IValue ? text.$ : text)?.toString() ?? "");
|
|
10
|
+
if (text instanceof IValue) {
|
|
11
|
+
this.handler = (v) => {
|
|
12
|
+
this.node.replaceData(0, -1, v?.toString() ?? "");
|
|
13
|
+
};
|
|
14
|
+
text.on(this.handler);
|
|
15
|
+
}
|
|
16
|
+
this.parent.appendNode(this.node);
|
|
17
|
+
}
|
|
18
|
+
destroy() {
|
|
19
|
+
this.node.remove();
|
|
20
|
+
super.destroy();
|
|
21
|
+
}
|
|
22
|
+
findFirstChild() {
|
|
23
|
+
return this.node;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class DebugNode extends AbstractDebugNode {
|
|
27
|
+
compose() {
|
|
28
|
+
const text = this.input.text;
|
|
29
|
+
this.node = this.runner.document.createComment(text.$?.toString() ?? "");
|
|
30
|
+
this.handler = (v) => {
|
|
31
|
+
this.node.replaceData(0, -1, v?.toString() ?? "");
|
|
32
|
+
};
|
|
33
|
+
text.on(this.handler);
|
|
34
|
+
this.parent.appendNode(this.node);
|
|
35
|
+
}
|
|
36
|
+
destroy() {
|
|
37
|
+
this.node.remove();
|
|
38
|
+
super.destroy();
|
|
39
|
+
}
|
|
40
|
+
findFirstChild() {
|
|
41
|
+
return this.node;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class Tag extends AbstractTag {
|
|
45
|
+
compose() {
|
|
46
|
+
if (!this.name) {
|
|
47
|
+
throw internalError("wrong Tag constructor call");
|
|
48
|
+
}
|
|
49
|
+
const node = this.runner.document.createElement(this.name);
|
|
50
|
+
this.node = node;
|
|
51
|
+
this.applyOptions(this.input);
|
|
52
|
+
this.parent.appendNode(node);
|
|
53
|
+
this.input.callback?.(this.node);
|
|
54
|
+
this.input.slot?.(this);
|
|
55
|
+
}
|
|
56
|
+
destroy() {
|
|
57
|
+
this.node.remove();
|
|
58
|
+
super.destroy();
|
|
59
|
+
}
|
|
60
|
+
applyOptions(options) {
|
|
61
|
+
if (options.attr) {
|
|
62
|
+
for (const name in options.attr) {
|
|
63
|
+
const value = options.attr[name];
|
|
64
|
+
if (value instanceof IValue) {
|
|
65
|
+
this.register(new AttributeBinding(this, name, value));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
/* istanbul ignore else */
|
|
69
|
+
if (typeof value === "boolean") {
|
|
70
|
+
/* istanbul ignore else */
|
|
71
|
+
if (value) {
|
|
72
|
+
this.node.setAttribute(name, "");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (value !== null && value !== undefined) {
|
|
76
|
+
this.node.setAttribute(name, `${value}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (options.class) {
|
|
82
|
+
for (const item of options.class) {
|
|
83
|
+
if (item instanceof IValue) {
|
|
84
|
+
this.register(new DynamicalClassBinding(this, item));
|
|
85
|
+
}
|
|
86
|
+
else if (typeof item == "string") {
|
|
87
|
+
this.node.classList.add(item);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
for (const name in item) {
|
|
91
|
+
const value = item[name];
|
|
92
|
+
if (value instanceof IValue) {
|
|
93
|
+
this.register(new StaticClassBinding(this, name, value));
|
|
94
|
+
}
|
|
95
|
+
else if (value) {
|
|
96
|
+
this.node.classList.add(name);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.node.classList.remove(name);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (options.style && this.node instanceof HTMLElement) {
|
|
106
|
+
for (const name in options.style) {
|
|
107
|
+
const value = options.style[name];
|
|
108
|
+
if (value instanceof IValue) {
|
|
109
|
+
this.register(new StyleBinding(this, name, value));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.node.style.setProperty(name, stringifyStyleValue(value));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (options.events) {
|
|
117
|
+
for (const name in options.events) {
|
|
118
|
+
this.node.addEventListener(name, options.events[name]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (options.bind) {
|
|
122
|
+
const node = this.node;
|
|
123
|
+
for (const k in options.bind) {
|
|
124
|
+
const value = options.bind[k];
|
|
125
|
+
if (!(value instanceof IValue)) {
|
|
126
|
+
node[k] = value;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
node[k] = value.$;
|
|
130
|
+
this.watch((v) => {
|
|
131
|
+
node[k] = v;
|
|
132
|
+
}, [value]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export class Runner {
|
|
139
|
+
constructor(debugUi, document) {
|
|
140
|
+
this.debugUi = debugUi;
|
|
141
|
+
this.document = document;
|
|
142
|
+
}
|
|
143
|
+
insertBefore(node, before) {
|
|
144
|
+
const parent = before.parentElement;
|
|
145
|
+
/* istanbul ignore else */
|
|
146
|
+
if (parent) {
|
|
147
|
+
parent.insertBefore(node, before);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
appendChild(node, child) {
|
|
151
|
+
node.appendChild(child);
|
|
152
|
+
}
|
|
153
|
+
textNode(text) {
|
|
154
|
+
return new TextNode({ text }, this);
|
|
155
|
+
}
|
|
156
|
+
debugNode(text) {
|
|
157
|
+
return new DebugNode({ text }, this);
|
|
158
|
+
}
|
|
159
|
+
tag(tagName, input, cb) {
|
|
160
|
+
if (cb) {
|
|
161
|
+
input.slot = cb;
|
|
162
|
+
}
|
|
163
|
+
return new Tag(input, this, tagName);
|
|
164
|
+
}
|
|
165
|
+
}
|
package/lib/tsconfig.tsbuildinfo
CHANGED
|
@@ -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"}
|
package/lib/value/expression.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Reference } from "./reference.js";
|
|
2
|
-
import { IValue } from "../core/ivalue";
|
|
2
|
+
import { IValue } from "../core/ivalue.js";
|
|
3
3
|
/**
|
|
4
4
|
* Bind some values to one expression
|
|
5
5
|
* @class Expression
|
|
@@ -12,13 +12,14 @@ export class Expression extends IValue {
|
|
|
12
12
|
* @param values
|
|
13
13
|
* @param link {Boolean} links immediately if true
|
|
14
14
|
*/
|
|
15
|
-
constructor(func,
|
|
15
|
+
constructor(func, values) {
|
|
16
16
|
super();
|
|
17
17
|
/**
|
|
18
18
|
* Expression will link different handler for each value of the list
|
|
19
19
|
*/
|
|
20
20
|
this.linkedFunc = [];
|
|
21
21
|
const handler = (i) => {
|
|
22
|
+
/* istanbul ignore else */
|
|
22
23
|
if (typeof i === "number") {
|
|
23
24
|
this.valuesCache[i] = this.values[i].$;
|
|
24
25
|
}
|
package/lib/value/pointer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IValue } from "../core/ivalue";
|
|
2
|
-
import { Reference } from "./reference";
|
|
1
|
+
import { IValue } from "../core/ivalue.js";
|
|
2
|
+
import { Reference } from "./reference.js";
|
|
3
3
|
/**
|
|
4
4
|
* r/w pointer to a value
|
|
5
5
|
* @class Pointer
|
|
@@ -23,8 +23,7 @@ export class Pointer extends IValue {
|
|
|
23
23
|
return this.reference.$;
|
|
24
24
|
}
|
|
25
25
|
set $(v) {
|
|
26
|
-
|
|
27
|
-
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
26
|
+
this.target?.off(this.handler);
|
|
28
27
|
this.target = null;
|
|
29
28
|
this.reference.$ = v;
|
|
30
29
|
}
|
|
@@ -32,6 +31,7 @@ export class Pointer extends IValue {
|
|
|
32
31
|
return this.reference.$;
|
|
33
32
|
}
|
|
34
33
|
set $$(v) {
|
|
34
|
+
/* istanbul ignore else */
|
|
35
35
|
if (this.target !== v) {
|
|
36
36
|
this.disconnectTarget();
|
|
37
37
|
}
|
|
@@ -51,24 +51,20 @@ export class Pointer extends IValue {
|
|
|
51
51
|
this.reference.off(handler);
|
|
52
52
|
}
|
|
53
53
|
destroy() {
|
|
54
|
-
|
|
55
|
-
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
54
|
+
this.target?.off(this.handler);
|
|
56
55
|
this.reference.destroy();
|
|
57
56
|
super.destroy();
|
|
58
57
|
}
|
|
59
58
|
disconnectTarget() {
|
|
60
|
-
|
|
61
|
-
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
59
|
+
this.target?.off(this.handler);
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
export class OwningPointer extends Pointer {
|
|
65
63
|
destroy() {
|
|
66
|
-
|
|
67
|
-
(_a = this.target) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
64
|
+
this.target?.destroy();
|
|
68
65
|
super.destroy();
|
|
69
66
|
}
|
|
70
67
|
disconnectTarget() {
|
|
71
|
-
|
|
72
|
-
(_a = this.target) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
68
|
+
this.target?.destroy();
|
|
73
69
|
}
|
|
74
70
|
}
|
package/lib/value/reference.js
CHANGED
package/lib/views/array-view.js
CHANGED
package/lib/views/base-view.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RepeatNode } from "./repeat-node";
|
|
1
|
+
import { RepeatNode } from "./repeat-node.js";
|
|
2
2
|
/**
|
|
3
3
|
* Base class of default views
|
|
4
4
|
* @class BaseView
|
|
@@ -6,8 +6,8 @@ import { RepeatNode } from "./repeat-node";
|
|
|
6
6
|
* @implements IModel
|
|
7
7
|
*/
|
|
8
8
|
export class BaseView extends RepeatNode {
|
|
9
|
-
constructor(input, name) {
|
|
10
|
-
super(input, name);
|
|
9
|
+
constructor(input, runner, name) {
|
|
10
|
+
super(input, runner, name);
|
|
11
11
|
}
|
|
12
12
|
compose() {
|
|
13
13
|
this.addHandler = (id, item) => {
|
package/lib/views/map-view.js
CHANGED
package/lib/views/repeat-node.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fragment } from "../node/node";
|
|
1
|
+
import { Fragment } from "../node/node.js";
|
|
3
2
|
/**
|
|
4
3
|
* Repeat node repeats its children
|
|
5
4
|
* @class RepeatNode
|
|
6
5
|
* @extends Fragment
|
|
7
6
|
*/
|
|
8
7
|
export class RepeatNode extends Fragment {
|
|
9
|
-
constructor(input, name) {
|
|
10
|
-
super(input, name);
|
|
8
|
+
constructor(input, runner, name) {
|
|
9
|
+
super(input, runner, name);
|
|
11
10
|
/**
|
|
12
11
|
* Children node hash
|
|
13
12
|
* @type {Map}
|
|
@@ -15,8 +14,8 @@ export class RepeatNode extends Fragment {
|
|
|
15
14
|
this.nodes = new Map();
|
|
16
15
|
}
|
|
17
16
|
createChild(opts, id, item, before) {
|
|
18
|
-
const _id = id && typeof id === "object" && "id" in id ? id.id :
|
|
19
|
-
const node = new Fragment({}, `${_id}`);
|
|
17
|
+
const _id = id && typeof id === "object" && "id" in id ? id.id : id;
|
|
18
|
+
const node = new Fragment({}, this.runner, `${_id}`);
|
|
20
19
|
node.parent = this;
|
|
21
20
|
this.destroyChild(id, item);
|
|
22
21
|
if (before) {
|
package/lib/views/set-view.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { BaseView } from "./base-view";
|
|
1
|
+
import { BaseView } from "./base-view.js";
|
|
2
2
|
/**
|
|
3
3
|
* Create a children pack for each set value
|
|
4
4
|
* @class SetView
|
|
5
5
|
* @extends BaseView
|
|
6
6
|
*/
|
|
7
7
|
export class SetView extends BaseView {
|
|
8
|
-
constructor(input) {
|
|
9
|
-
super(input, ":set-view");
|
|
8
|
+
constructor(input, runner) {
|
|
9
|
+
super(input, runner, ":set-view");
|
|
10
10
|
}
|
|
11
11
|
compose() {
|
|
12
12
|
super.compose();
|
package/package.json
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vasille",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "The first Developer eXperience Orientated front-end framework (core library).",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
|
-
"version": "3.0
|
|
6
|
+
"version": "3.2.0",
|
|
7
7
|
"exports": {
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./types/index.d.ts",
|
|
10
|
+
"import": "./lib/index.js",
|
|
11
|
+
"browser": "./lib/index.js",
|
|
12
|
+
"node": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./web-runner": {
|
|
15
|
+
"types": "./types/runner/web/runner.d.ts",
|
|
16
|
+
"import": "./lib/runner/web/runner.js",
|
|
17
|
+
"browser": "./lib/runner/web/runner.js",
|
|
18
|
+
"node": "./lib/runner/web/runner.js"
|
|
19
|
+
}
|
|
12
20
|
},
|
|
13
21
|
"scripts": {
|
|
14
22
|
"prepack": "cp -f ../README.md ./README.md",
|
|
15
23
|
"prettier": "npx prettier src test --write",
|
|
16
24
|
"build": "tsc --build tsconfig.json",
|
|
17
|
-
"build-node": "tsc --build tsconfig-build-node.json",
|
|
18
25
|
"test": "jest",
|
|
19
26
|
"test-coverage": "jest --coverage",
|
|
20
|
-
"update-types": "tsc --build tsconfig-types.json"
|
|
21
|
-
"cdn-create": "node cdn/create.cjs"
|
|
27
|
+
"update-types": "tsc --build tsconfig-types.json"
|
|
22
28
|
},
|
|
23
29
|
"repository": {
|
|
24
30
|
"type": "git",
|
|
@@ -40,21 +46,21 @@
|
|
|
40
46
|
},
|
|
41
47
|
"homepage": "https://github.com/vasille-js/vasille-js#readme",
|
|
42
48
|
"devDependencies": {
|
|
43
|
-
"@types/debug": "4.1.12",
|
|
44
|
-
"@types/eslint": "9.6.1",
|
|
45
|
-
"@types/eslint-scope": "3.
|
|
46
|
-
"@types/estree": "1.0.
|
|
47
|
-
"@types/events": "3.0.3",
|
|
48
|
-
"@types/jest": "
|
|
49
|
-
"@types/jsdom": "21.1.7",
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
51
|
-
"@typescript-eslint/parser": "8.
|
|
52
|
-
"eslint": "9.
|
|
53
|
-
"jest": "
|
|
54
|
-
"jsdom": "
|
|
55
|
-
"prettier": "3.
|
|
56
|
-
"ts-jest": "29.
|
|
57
|
-
"tslint-config-prettier": "1.18.0",
|
|
58
|
-
"typescript": "5.
|
|
49
|
+
"@types/debug": "^4.1.12",
|
|
50
|
+
"@types/eslint": "^9.6.1",
|
|
51
|
+
"@types/eslint-scope": "^8.3.1",
|
|
52
|
+
"@types/estree": "^1.0.8",
|
|
53
|
+
"@types/events": "^3.0.3",
|
|
54
|
+
"@types/jest": "^30.0.0",
|
|
55
|
+
"@types/jsdom": "^21.1.7",
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
57
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
58
|
+
"eslint": "^9.32.0",
|
|
59
|
+
"jest": "^30.0.5",
|
|
60
|
+
"jsdom": "^26.1.0",
|
|
61
|
+
"prettier": "^3.6.2",
|
|
62
|
+
"ts-jest": "^29.4.0",
|
|
63
|
+
"tslint-config-prettier": "^1.18.0",
|
|
64
|
+
"typescript": "^5.8.3"
|
|
59
65
|
}
|
|
60
66
|
}
|
package/types/core/core.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { Destroyable } from "./destroyable.js";
|
|
2
2
|
import { IValue } from "./ivalue.js";
|
|
3
|
-
import { KindOfIValue } from "../value/expression";
|
|
4
|
-
import { Pointer } from "../value/pointer";
|
|
3
|
+
import { KindOfIValue } from "../value/expression.js";
|
|
4
|
+
import { Pointer } from "../value/pointer.js";
|
|
5
5
|
/**
|
|
6
6
|
* A reactive object
|
|
7
7
|
* @class Reactive
|
|
8
8
|
* @extends Destroyable
|
|
9
9
|
*/
|
|
10
10
|
export declare class Reactive<T extends object = object> extends Destroyable {
|
|
11
|
-
/**
|
|
12
|
-
* A list of user-defined values
|
|
13
|
-
* @type {Set}
|
|
14
|
-
*/
|
|
15
|
-
private _watch;
|
|
16
11
|
/**
|
|
17
12
|
* A list of user-defined bindings
|
|
18
13
|
* @type {Set}
|
|
@@ -20,40 +15,46 @@ export declare class Reactive<T extends object = object> extends Destroyable {
|
|
|
20
15
|
private bindings;
|
|
21
16
|
private onDestroy?;
|
|
22
17
|
readonly input: T;
|
|
18
|
+
readonly state: Record<string, [string, unknown]>;
|
|
23
19
|
constructor(input: T);
|
|
24
20
|
/**
|
|
25
21
|
* Create a reference
|
|
26
22
|
* @param value {*} value to reference
|
|
23
|
+
* @param name {string} used for debugging internal state
|
|
27
24
|
*/
|
|
28
|
-
ref<T>(value: T): IValue<T>;
|
|
25
|
+
ref<T>(value: T, name?: string): IValue<T>;
|
|
29
26
|
/**
|
|
30
27
|
* Create a forward-only pointer
|
|
31
28
|
* @param value {IValue} value to point
|
|
29
|
+
* @param name {string} used for debugging internal state
|
|
32
30
|
*/
|
|
33
|
-
forward<T>(value: IValue<T
|
|
31
|
+
forward<T>(value: IValue<T>, name?: string): IValue<T>;
|
|
34
32
|
/**
|
|
35
33
|
* Creates a pointer
|
|
36
34
|
* @param value {*} default value to point
|
|
35
|
+
* @param name {string} used for debugging internal state
|
|
37
36
|
*/
|
|
38
|
-
own<T>(value: IValue<T
|
|
37
|
+
own<T>(value: IValue<T>, name?: string): Pointer<T>;
|
|
39
38
|
/**
|
|
40
39
|
* Register a model/dependency
|
|
41
40
|
*/
|
|
42
|
-
register<T extends Destroyable>(data: T): T;
|
|
41
|
+
register<T extends Destroyable>(data: T, name?: string): T;
|
|
43
42
|
release(data: Destroyable): void;
|
|
44
43
|
/**
|
|
45
44
|
* Creates a watcher
|
|
46
45
|
* @param func {function} function to run on any argument change
|
|
47
46
|
* @param values
|
|
48
47
|
*/
|
|
49
|
-
watch<Args extends unknown[]>(func: (...args: Args) => void,
|
|
48
|
+
watch<Args extends unknown[]>(func: (...args: Args) => void, values: KindOfIValue<Args>): void;
|
|
50
49
|
/**
|
|
51
50
|
* Creates a computed value
|
|
52
51
|
* @param func {function} function to run on any argument change
|
|
53
52
|
* @param values
|
|
53
|
+
* @param name {string} used for debugging internal state
|
|
54
54
|
* @return {IValue} the created ivalue
|
|
55
55
|
*/
|
|
56
|
-
expr<T, Args extends unknown[]>(func: (...args: Args) => T,
|
|
56
|
+
expr<T, Args extends unknown[]>(func: (...args: Args) => T, values: KindOfIValue<Args>, name?: string): IValue<T>;
|
|
57
57
|
runOnDestroy(func: () => void): void;
|
|
58
|
+
addState(method: string, name: string, state: unknown): void;
|
|
58
59
|
destroy(): void;
|
|
59
60
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
import { Watch } from "./node/watch";
|
|
24
|
-
export { Destroyable, IValue, Reference, Pointer, ArrayModel, proxyArrayModel, MapModel, SetModel, BaseView, Listener, ArrayView, MapView, SetView, Fragment, INode, Tag, Extension, App, Portal, Expression, Binding, Reactive, Watch, TagOptions, KindOfIValue, ListenableModel, TagOptionsWithSlot, userError, config, setErrorHandler, reportError, };
|
|
1
|
+
import { Destroyable } from "./core/destroyable.js";
|
|
2
|
+
import { Reactive } from "./core/core.js";
|
|
3
|
+
import { IValue } from "./core/ivalue.js";
|
|
4
|
+
import { reportError, setErrorHandler } from "./functional/safety.js";
|
|
5
|
+
import { ArrayModel, proxyArrayModel } from "./models/array-model.js";
|
|
6
|
+
import { Listener } from "./models/listener.js";
|
|
7
|
+
import { MapModel } from "./models/map-model.js";
|
|
8
|
+
import { SetModel } from "./models/set-model.js";
|
|
9
|
+
import { App, Portal } from "./node/app.js";
|
|
10
|
+
import { Fragment, Tag, TextNode, DebugNode } from "./node/node.js";
|
|
11
|
+
import { Expression, KindOfIValue } from "./value/expression.js";
|
|
12
|
+
import { Pointer } from "./value/pointer.js";
|
|
13
|
+
import { Reference } from "./value/reference.js";
|
|
14
|
+
import { ArrayView } from "./views/array-view.js";
|
|
15
|
+
import { BaseView } from "./views/base-view.js";
|
|
16
|
+
import { MapView } from "./views/map-view.js";
|
|
17
|
+
import { SetView } from "./views/set-view.js";
|
|
18
|
+
import { userError } from "./core/errors.js";
|
|
19
|
+
import { ListenableModel } from "./models/model.js";
|
|
20
|
+
import { Watch } from "./node/watch.js";
|
|
21
|
+
import { Runner } from "./node/runner.js";
|
|
22
|
+
export { Destroyable, IValue, Reference, Pointer, ArrayModel, proxyArrayModel, MapModel, SetModel, BaseView, Listener, ArrayView, MapView, SetView, Fragment, Tag, App, Portal, Expression, Reactive, TextNode, DebugNode, Watch, Runner, KindOfIValue, ListenableModel, userError, setErrorHandler, reportError, };
|
package/types/node/app.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { Fragment, Root } from "./node";
|
|
1
|
+
import { Fragment, Root } from "./node.js";
|
|
2
|
+
import { Runner } from "./runner.js";
|
|
2
3
|
/**
|
|
3
4
|
* Represents a Vasille.js application
|
|
4
5
|
* @class App
|
|
5
6
|
* @extends AppNode
|
|
6
7
|
*/
|
|
7
|
-
export declare class App<T extends object = object> extends Root<T> {
|
|
8
|
+
export declare class App<Node, Element, TagOptions extends object, T extends object = object> extends Root<Node, Element, TagOptions, T> {
|
|
8
9
|
private node;
|
|
9
10
|
/**
|
|
10
11
|
* Constructs an app node
|
|
11
12
|
* @param node {Element} The root of application
|
|
12
13
|
* @param input
|
|
13
14
|
*/
|
|
14
|
-
constructor(node: Element, input: T);
|
|
15
|
+
constructor(node: Element, runner: Runner<Node, Element, TagOptions>, input: T);
|
|
15
16
|
appendNode(node: Node): void;
|
|
16
17
|
}
|
|
17
|
-
interface PortalOptions {
|
|
18
|
+
interface PortalOptions<Node, Element, TagOptions extends object> {
|
|
18
19
|
node: Element;
|
|
19
|
-
slot?: (ctx: Fragment) => void;
|
|
20
|
+
slot?: (ctx: Fragment<Node, Element, TagOptions>) => void;
|
|
20
21
|
}
|
|
21
|
-
export declare class Portal extends Fragment {
|
|
22
|
+
export declare class Portal<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions> {
|
|
22
23
|
private node;
|
|
23
|
-
constructor(input: PortalOptions);
|
|
24
|
+
constructor(input: PortalOptions<Node, Element, TagOptions>, runner: Runner<Node, Element, TagOptions>);
|
|
24
25
|
appendNode(node: Node): void;
|
|
25
26
|
}
|
|
26
27
|
export {};
|