vasille 3.0.0 → 3.1.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.
Files changed (102) hide show
  1. package/README.md +6 -7
  2. package/lib/core/core.js +35 -13
  3. package/lib/core/ivalue.js +1 -2
  4. package/lib/index.js +20 -22
  5. package/lib/models/array-model.js +1 -1
  6. package/lib/models/map-model.js +2 -2
  7. package/lib/models/set-model.js +2 -2
  8. package/lib/node/app.js +7 -7
  9. package/lib/node/node.js +45 -360
  10. package/lib/node/watch.js +5 -6
  11. package/lib/{binding → runner/web/binding}/attribute.js +1 -1
  12. package/lib/{binding → runner/web/binding}/binding.js +1 -1
  13. package/lib/{binding → runner/web/binding}/class.js +1 -1
  14. package/lib/{binding → runner/web/binding}/style.js +1 -1
  15. package/lib/runner/web/runner.js +162 -0
  16. package/lib/tsconfig.tsbuildinfo +1 -1
  17. package/lib/value/expression.js +2 -2
  18. package/lib/value/pointer.js +7 -12
  19. package/lib/value/reference.js +2 -2
  20. package/lib/views/array-view.js +1 -1
  21. package/lib/views/base-view.js +3 -3
  22. package/lib/views/map-view.js +1 -1
  23. package/lib/views/repeat-node.js +5 -6
  24. package/lib/views/set-view.js +3 -3
  25. package/package.json +37 -27
  26. package/types/core/core.d.ts +14 -8
  27. package/types/index.d.ts +22 -24
  28. package/types/models/array-model.d.ts +2 -2
  29. package/types/models/map-model.d.ts +2 -2
  30. package/types/models/model.d.ts +2 -2
  31. package/types/models/set-model.d.ts +2 -2
  32. package/types/node/app.d.ts +8 -7
  33. package/types/node/node.d.ts +49 -144
  34. package/types/node/runner.d.ts +10 -0
  35. package/types/node/watch.d.ts +7 -6
  36. package/types/{binding → runner/web/binding}/attribute.d.ts +4 -4
  37. package/types/{binding → runner/web/binding}/binding.d.ts +2 -2
  38. package/types/runner/web/binding/class.d.ts +11 -0
  39. package/types/{binding → runner/web/binding}/style.d.ts +4 -4
  40. package/types/runner/web/runner.d.ts +42 -0
  41. package/types/tsconfig-types.tsbuildinfo +1 -1
  42. package/types/value/expression.d.ts +2 -2
  43. package/types/value/pointer.d.ts +1 -1
  44. package/types/value/reference.d.ts +1 -1
  45. package/types/views/array-view.d.ts +5 -5
  46. package/types/views/base-view.d.ts +7 -6
  47. package/types/views/map-view.d.ts +3 -3
  48. package/types/views/repeat-node.d.ts +8 -7
  49. package/types/views/set-view.d.ts +5 -4
  50. package/lib/core/config.js +0 -3
  51. package/lib/models/object-model.js +0 -78
  52. package/lib/spec/html.js +0 -1
  53. package/lib/spec/react.js +0 -1
  54. package/lib/spec/svg.js +0 -1
  55. package/lib/tsconfig-build.tsbuildinfo +0 -1
  56. package/lib/value/mirror.js +0 -42
  57. package/lib/views/object-view.js +0 -17
  58. package/lib-node/binding/attribute.js +0 -34
  59. package/lib-node/binding/binding.js +0 -32
  60. package/lib-node/binding/class.js +0 -46
  61. package/lib-node/binding/style.js +0 -36
  62. package/lib-node/core/config.js +0 -6
  63. package/lib-node/core/core.js +0 -101
  64. package/lib-node/core/destroyable.js +0 -14
  65. package/lib-node/core/errors.js +0 -22
  66. package/lib-node/core/ivalue.js +0 -19
  67. package/lib-node/functional/options.js +0 -2
  68. package/lib-node/functional/safety.js +0 -12
  69. package/lib-node/index.js +0 -51
  70. package/lib-node/models/array-model.js +0 -152
  71. package/lib-node/models/listener.js +0 -70
  72. package/lib-node/models/map-model.js +0 -63
  73. package/lib-node/models/model.js +0 -2
  74. package/lib-node/models/object-model.js +0 -82
  75. package/lib-node/models/set-model.js +0 -59
  76. package/lib-node/node/app.js +0 -34
  77. package/lib-node/node/node.js +0 -656
  78. package/lib-node/node/watch.js +0 -26
  79. package/lib-node/spec/html.js +0 -2
  80. package/lib-node/spec/react.js +0 -2
  81. package/lib-node/spec/svg.js +0 -2
  82. package/lib-node/tsconfig-build-node.tsbuildinfo +0 -1
  83. package/lib-node/value/expression.js +0 -65
  84. package/lib-node/value/mirror.js +0 -46
  85. package/lib-node/value/pointer.js +0 -79
  86. package/lib-node/value/reference.js +0 -50
  87. package/lib-node/views/array-view.js +0 -21
  88. package/lib-node/views/base-view.js +0 -31
  89. package/lib-node/views/map-view.js +0 -18
  90. package/lib-node/views/object-view.js +0 -21
  91. package/lib-node/views/repeat-node.js +0 -53
  92. package/lib-node/views/set-view.js +0 -22
  93. package/types/binding/class.d.ts +0 -11
  94. package/types/core/config.d.ts +0 -3
  95. package/types/functional/options.d.ts +0 -10
  96. package/types/models/object-model.d.ts +0 -38
  97. package/types/spec/html.d.ts +0 -975
  98. package/types/spec/react.d.ts +0 -4
  99. package/types/spec/svg.d.ts +0 -314
  100. package/types/value/mirror.d.ts +0 -33
  101. package/types/views/object-view.d.ts +0 -10
  102. /package/lib/{functional/options.js → node/runner.js} +0 -0
package/README.md CHANGED
@@ -29,7 +29,7 @@ npm install vasille-web --save
29
29
  Create an app from a template
30
30
 
31
31
  ```bash
32
- $ npx create vasille
32
+ $ npm create vasille
33
33
  ```
34
34
 
35
35
  Alternative method to create a TypeScript app.
@@ -47,7 +47,7 @@ $ npx degit vasille-js/example-javascript my-project
47
47
 
48
48
  ### Examples
49
49
  * [TypeScript Example](https://github.com/vasille-js/example-typescript)
50
- * [JavaScript Example](https://github.com/vas[README.md](..%2Ftest%2Fmy-app%2FREADME.md)ille-js/example-javascript)
50
+ * [JavaScript Example](https://github.com/vasille-js/example-javascript)
51
51
 
52
52
  <hr>
53
53
 
@@ -103,12 +103,11 @@ All of these are supported:
103
103
  * [x] Develop the `Vasille JSX` library.
104
104
  * [x] `100%` Test Coverage for the JSX library.
105
105
  * [x] Develop the `Vasille Babel Plugin`.
106
- * [ ] `100%` Test Coverage fot babel plugin.
107
- * [ ] Add CSS support (define styles in components).
108
- * [ ] Add custom `<input/>` components with 2-way value binding.
106
+ * [x] `100%` Test Coverage fot babel plugin.
107
+ * [x] Add CSS support (define styles in components).
109
108
  * [ ] Add router.
110
- * [ ] Develop dev-tools extension for debugging.
111
- * [ ] Develop a lot of libraries for the framework.
109
+ * [ ] Add SSR (server side rendering).
110
+ * [ ] Develop tools extension for debugging.
112
111
 
113
112
  ## Questions
114
113
 
package/lib/core/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Destroyable } from "./destroyable.js";
2
- import { Expression } from "../value/expression";
3
- import { Reference } from "../value/reference";
4
- import { OwningPointer, Pointer } from "../value/pointer";
2
+ import { Expression } from "../value/expression.js";
3
+ import { Reference } from "../value/reference.js";
4
+ import { OwningPointer, Pointer } from "../value/pointer.js";
5
5
  /**
6
6
  * A reactive object
7
7
  * @class Reactive
@@ -21,39 +21,55 @@ export class Reactive extends Destroyable {
21
21
  */
22
22
  this.bindings = new Set();
23
23
  this.input = input;
24
+ this.state = {};
24
25
  }
25
26
  /**
26
27
  * Create a reference
27
28
  * @param value {*} value to reference
29
+ * @param name {string} used for debugging internal state
28
30
  */
29
- ref(value) {
31
+ ref(value, name) {
30
32
  const ref = new Reference(value);
31
33
  this._watch.add(ref);
34
+ if (name) {
35
+ this.addState("ref", name, ref);
36
+ }
32
37
  return ref;
33
38
  }
34
39
  /**
35
40
  * Create a forward-only pointer
36
41
  * @param value {IValue} value to point
42
+ * @param name {string} used for debugging internal state
37
43
  */
38
- forward(value) {
44
+ forward(value, name) {
39
45
  const mirror = new Pointer(value);
40
46
  this._watch.add(mirror);
47
+ if (name) {
48
+ this.addState("forward", name, mirror);
49
+ }
41
50
  return mirror;
42
51
  }
43
52
  /**
44
53
  * Creates a pointer
45
54
  * @param value {*} default value to point
55
+ * @param name {string} used for debugging internal state
46
56
  */
47
- own(value) {
57
+ own(value, name) {
48
58
  const pointer = new OwningPointer(value);
49
59
  this._watch.add(pointer);
60
+ if (name) {
61
+ this.addState("own", name, pointer);
62
+ }
50
63
  return pointer;
51
64
  }
52
65
  /**
53
66
  * Register a model/dependency
54
67
  */
55
- register(data) {
68
+ register(data, name) {
56
69
  this.bindings.add(data);
70
+ if (name) {
71
+ this.addState("model", name, data);
72
+ }
57
73
  return data;
58
74
  }
59
75
  release(data) {
@@ -64,18 +80,22 @@ export class Reactive extends Destroyable {
64
80
  * @param func {function} function to run on any argument change
65
81
  * @param values
66
82
  */
67
- watch(func, ...values) {
68
- this._watch.add(new Expression(func, ...values));
83
+ watch(func, values) {
84
+ this._watch.add(new Expression(func, values));
69
85
  }
70
86
  /**
71
87
  * Creates a computed value
72
88
  * @param func {function} function to run on any argument change
73
89
  * @param values
90
+ * @param name {string} used for debugging internal state
74
91
  * @return {IValue} the created ivalue
75
92
  */
76
- expr(func, ...values) {
77
- const res = new Expression(func, ...values);
93
+ expr(func, values, name) {
94
+ const res = new Expression(func, values);
78
95
  this._watch.add(res);
96
+ if (name) {
97
+ this.addState("expr", name, res);
98
+ }
79
99
  return res;
80
100
  }
81
101
  runOnDestroy(func) {
@@ -85,13 +105,15 @@ export class Reactive extends Destroyable {
85
105
  }
86
106
  this.onDestroy = func;
87
107
  }
108
+ addState(method, name, state) {
109
+ this.state[name === "#" ? `#${Object.keys(this.state).length}` : name] = [method, state];
110
+ }
88
111
  destroy() {
89
- var _a;
90
112
  super.destroy();
91
113
  this._watch.forEach(value => value.destroy());
92
114
  this._watch.clear();
93
115
  this.bindings.forEach(binding => binding.destroy());
94
116
  this.bindings.clear();
95
- (_a = this.onDestroy) === null || _a === void 0 ? void 0 : _a.call(this);
117
+ this.onDestroy?.();
96
118
  }
97
119
  }
@@ -9,7 +9,6 @@ export class IValue extends Destroyable {
9
9
  return this.$;
10
10
  }
11
11
  toString() {
12
- var _a, _b;
13
- return (_b = (_a = this.$) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "iValue<void>";
12
+ return this.$?.toString() ?? "iValue<void>";
14
13
  }
15
14
  }
package/lib/index.js CHANGED
@@ -1,22 +1,20 @@
1
- import { config } from "./core/config";
2
- import { Destroyable } from "./core/destroyable";
3
- import { Reactive } from "./core/core";
4
- import { IValue } from "./core/ivalue";
5
- import { reportError, setErrorHandler } from "./functional/safety";
6
- import { ArrayModel, proxyArrayModel } from "./models/array-model";
7
- import { Listener } from "./models/listener";
8
- import { MapModel } from "./models/map-model";
9
- import { SetModel } from "./models/set-model";
10
- import { App, Portal } from "./node/app";
11
- import { Extension, Fragment, INode, Tag } from "./node/node";
12
- import { Expression } from "./value/expression";
13
- import { Pointer } from "./value/pointer";
14
- import { Reference } from "./value/reference";
15
- import { ArrayView } from "./views/array-view";
16
- import { BaseView } from "./views/base-view";
17
- import { MapView } from "./views/map-view";
18
- import { SetView } from "./views/set-view";
19
- import { Binding } from "./binding/binding";
20
- import { userError } from "./core/errors";
21
- import { Watch } from "./node/watch";
22
- export { Destroyable, IValue, Reference, Pointer, ArrayModel, proxyArrayModel, MapModel, SetModel, BaseView, Listener, ArrayView, MapView, SetView, Fragment, INode, Tag, Extension, App, Portal, Expression, Binding, Reactive, Watch, 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 } 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 { Watch } from "./node/watch.js";
20
+ export { Destroyable, IValue, Reference, Pointer, ArrayModel, proxyArrayModel, MapModel, SetModel, BaseView, Listener, ArrayView, MapView, SetView, Fragment, Tag, App, Portal, Expression, Reactive, TextNode, DebugNode, Watch, userError, setErrorHandler, reportError, };
@@ -1,4 +1,4 @@
1
- import { Listener } from "./listener";
1
+ import { Listener } from "./listener.js";
2
2
  /**
3
3
  * Model based on Array class
4
4
  * @extends Array
@@ -1,4 +1,4 @@
1
- import { Listener } from "./listener";
1
+ import { Listener } from "./listener.js";
2
2
  /**
3
3
  * A Map based memory
4
4
  * @class MapModel
@@ -13,7 +13,7 @@ export class MapModel extends Map {
13
13
  constructor(map) {
14
14
  super();
15
15
  this.listener = new Listener();
16
- map === null || map === void 0 ? void 0 : map.forEach(([key, value]) => {
16
+ map?.forEach(([key, value]) => {
17
17
  super.set(key, value);
18
18
  });
19
19
  }
@@ -1,4 +1,4 @@
1
- import { Listener } from "./listener";
1
+ import { Listener } from "./listener.js";
2
2
  /**
3
3
  * A Set based model
4
4
  * @class SetModel
@@ -13,7 +13,7 @@ export class SetModel extends Set {
13
13
  constructor(set) {
14
14
  super();
15
15
  this.listener = new Listener();
16
- set === null || set === void 0 ? void 0 : set.forEach(item => {
16
+ set?.forEach(item => {
17
17
  super.add(item);
18
18
  });
19
19
  }
package/lib/node/app.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Fragment, Root } from "./node";
1
+ import { Fragment, Root } from "./node.js";
2
2
  /**
3
3
  * Represents a Vasille.js application
4
4
  * @class App
@@ -10,20 +10,20 @@ export class App extends Root {
10
10
  * @param node {Element} The root of application
11
11
  * @param input
12
12
  */
13
- constructor(node, input) {
14
- super(input);
13
+ constructor(node, runner, input) {
14
+ super(input, runner);
15
15
  this.node = node;
16
16
  }
17
17
  appendNode(node) {
18
- this.node.appendChild(node);
18
+ this.runner.appendChild(this.node, node);
19
19
  }
20
20
  }
21
21
  export class Portal extends Fragment {
22
- constructor(input) {
23
- super(input, ":portal");
22
+ constructor(input, runner) {
23
+ super(input, runner, ":portal");
24
24
  this.node = input.node;
25
25
  }
26
26
  appendNode(node) {
27
- this.node.appendChild(node);
27
+ this.runner.appendChild(this.node, node);
28
28
  }
29
29
  }