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.
Files changed (105) hide show
  1. package/README.md +10 -10
  2. package/lib/core/core.js +40 -24
  3. package/lib/core/ivalue.js +1 -2
  4. package/lib/index.js +20 -22
  5. package/lib/node/app.js +7 -7
  6. package/lib/node/node.js +47 -360
  7. package/lib/node/watch.js +5 -6
  8. package/lib/{binding → runner/web/binding}/attribute.js +1 -1
  9. package/lib/{binding → runner/web/binding}/binding.js +1 -1
  10. package/lib/{binding → runner/web/binding}/class.js +3 -1
  11. package/lib/{binding → runner/web/binding}/style.js +2 -1
  12. package/lib/runner/web/runner.js +165 -0
  13. package/lib/tsconfig.tsbuildinfo +1 -1
  14. package/lib/value/expression.js +3 -2
  15. package/lib/value/pointer.js +8 -12
  16. package/lib/value/reference.js +2 -2
  17. package/lib/views/array-view.js +1 -1
  18. package/lib/views/base-view.js +3 -3
  19. package/lib/views/map-view.js +1 -1
  20. package/lib/views/repeat-node.js +5 -6
  21. package/lib/views/set-view.js +3 -3
  22. package/package.json +31 -25
  23. package/types/core/core.d.ts +14 -13
  24. package/types/index.d.ts +22 -24
  25. package/types/node/app.d.ts +8 -7
  26. package/types/node/node.d.ts +49 -144
  27. package/types/node/runner.d.ts +10 -0
  28. package/types/node/watch.d.ts +7 -6
  29. package/types/{binding → runner/web/binding}/attribute.d.ts +4 -4
  30. package/types/{binding → runner/web/binding}/binding.d.ts +2 -2
  31. package/types/runner/web/binding/class.d.ts +11 -0
  32. package/types/{binding → runner/web/binding}/style.d.ts +4 -4
  33. package/types/runner/web/runner.d.ts +42 -0
  34. package/types/tsconfig-types.tsbuildinfo +1 -1
  35. package/types/value/expression.d.ts +2 -2
  36. package/types/value/pointer.d.ts +1 -1
  37. package/types/value/reference.d.ts +1 -1
  38. package/types/views/array-view.d.ts +5 -5
  39. package/types/views/base-view.d.ts +7 -6
  40. package/types/views/map-view.d.ts +3 -3
  41. package/types/views/repeat-node.d.ts +8 -7
  42. package/types/views/set-view.d.ts +5 -4
  43. package/lib/core/config.js +0 -3
  44. package/lib/models/array-model.js +0 -147
  45. package/lib/models/listener.js +0 -66
  46. package/lib/models/map-model.js +0 -59
  47. package/lib/models/model.js +0 -1
  48. package/lib/models/object-model.js +0 -78
  49. package/lib/models/set-model.js +0 -55
  50. package/lib/spec/html.js +0 -1
  51. package/lib/spec/react.js +0 -1
  52. package/lib/spec/svg.js +0 -1
  53. package/lib/tsconfig-build.tsbuildinfo +0 -1
  54. package/lib/value/mirror.js +0 -42
  55. package/lib/views/object-view.js +0 -17
  56. package/lib-node/binding/attribute.js +0 -34
  57. package/lib-node/binding/binding.js +0 -32
  58. package/lib-node/binding/class.js +0 -46
  59. package/lib-node/binding/style.js +0 -36
  60. package/lib-node/core/config.js +0 -6
  61. package/lib-node/core/core.js +0 -101
  62. package/lib-node/core/destroyable.js +0 -14
  63. package/lib-node/core/errors.js +0 -22
  64. package/lib-node/core/ivalue.js +0 -19
  65. package/lib-node/functional/options.js +0 -2
  66. package/lib-node/functional/safety.js +0 -12
  67. package/lib-node/index.js +0 -51
  68. package/lib-node/models/array-model.js +0 -152
  69. package/lib-node/models/listener.js +0 -70
  70. package/lib-node/models/map-model.js +0 -63
  71. package/lib-node/models/model.js +0 -2
  72. package/lib-node/models/object-model.js +0 -82
  73. package/lib-node/models/set-model.js +0 -59
  74. package/lib-node/node/app.js +0 -34
  75. package/lib-node/node/node.js +0 -656
  76. package/lib-node/node/watch.js +0 -26
  77. package/lib-node/spec/html.js +0 -2
  78. package/lib-node/spec/react.js +0 -2
  79. package/lib-node/spec/svg.js +0 -2
  80. package/lib-node/tsconfig-build-node.tsbuildinfo +0 -1
  81. package/lib-node/value/expression.js +0 -65
  82. package/lib-node/value/mirror.js +0 -46
  83. package/lib-node/value/pointer.js +0 -79
  84. package/lib-node/value/reference.js +0 -50
  85. package/lib-node/views/array-view.js +0 -21
  86. package/lib-node/views/base-view.js +0 -31
  87. package/lib-node/views/map-view.js +0 -18
  88. package/lib-node/views/object-view.js +0 -21
  89. package/lib-node/views/repeat-node.js +0 -53
  90. package/lib-node/views/set-view.js +0 -22
  91. package/types/binding/class.d.ts +0 -11
  92. package/types/core/config.d.ts +0 -3
  93. package/types/functional/options.d.ts +0 -10
  94. package/types/models/array-model.d.ts +0 -55
  95. package/types/models/listener.d.ts +0 -48
  96. package/types/models/map-model.d.ts +0 -34
  97. package/types/models/model.d.ts +0 -14
  98. package/types/models/object-model.d.ts +0 -38
  99. package/types/models/set-model.d.ts +0 -33
  100. package/types/spec/html.d.ts +0 -975
  101. package/types/spec/react.d.ts +0 -4
  102. package/types/spec/svg.d.ts +0 -314
  103. package/types/value/mirror.d.ts +0 -33
  104. package/types/views/object-view.d.ts +0 -10
  105. /package/lib/{functional/options.js → node/runner.js} +0 -0
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  * [Installation](#installation)
12
12
  * [How to use Vasille](#how-to-use-vasille)
13
13
  * [How SAFE is Vasille](#how-safe-is-vasille)
14
- * [How SIMPLE is Vasille](#how-simple-is-vasille)
14
+ * [How INTUITIVE is Vasille](#how-intuitive-is-vasille)
15
15
  * [How POWERFUL is Vasille](#how-powerful-is-vasille)
16
16
  * [Road Map](#road-map)
17
17
 
@@ -44,10 +44,11 @@ $ npx degit vasille-js/example-javascript my-project
44
44
 
45
45
  ### Full documentation:
46
46
  * [Learn `Vasille` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v3/doc/V3-API.md)
47
+ * [Vasille Router Documentation](https://github.com/vasille-js/vasille-js/blob/v3/doc/Router-API.md)
47
48
 
48
49
  ### Examples
49
50
  * [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)
51
+ * [JavaScript Example](https://github.com/vasille-js/example-javascript)
51
52
 
52
53
  <hr>
53
54
 
@@ -60,7 +61,7 @@ The safe of your application is ensured by
60
61
  * `strong typing` makes your javascript/typescript code safe as C++ code.
61
62
  All entities of `vasille` core library are strongly typed, including:
62
63
  * data fields & properties.
63
- * computed properties (function parameters & result).
64
+ * computed properties (function parameters and result).
64
65
  * methods.
65
66
  * events (defined handlers & event emit).
66
67
  * DOM events & DOM operation (attributing, styling, etc.).
@@ -68,7 +69,7 @@ All entities of `vasille` core library are strongly typed, including:
68
69
  * references to children.
69
70
  * No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
70
71
 
71
- ## How SIMPLE is Vasille
72
+ ## How INTUITIVE is Vasille
72
73
 
73
74
  There is the "Hello World":
74
75
  ```typescript jsx
@@ -103,12 +104,11 @@ All of these are supported:
103
104
  * [x] Develop the `Vasille JSX` library.
104
105
  * [x] `100%` Test Coverage for the JSX library.
105
106
  * [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.
109
- * [ ] Add router.
110
- * [ ] Develop dev-tools extension for debugging.
111
- * [ ] Develop a lot of libraries for the framework.
107
+ * [x] `100%` Test Coverage fot babel plugin.
108
+ * [x] Add CSS support (define styles in components).
109
+ * [x] Add router.
110
+ * [ ] Add SSR (server side rendering).
111
+ * [ ] Develop tools extension for debugging.
112
112
 
113
113
  ## Questions
114
114
 
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
@@ -10,50 +10,62 @@ import { OwningPointer, Pointer } from "../value/pointer";
10
10
  export class Reactive extends Destroyable {
11
11
  constructor(input) {
12
12
  super();
13
- /**
14
- * A list of user-defined values
15
- * @type {Set}
16
- */
17
- this._watch = new Set();
18
13
  /**
19
14
  * A list of user-defined bindings
20
15
  * @type {Set}
21
16
  */
22
17
  this.bindings = new Set();
23
18
  this.input = input;
19
+ this.state = {};
24
20
  }
25
21
  /**
26
22
  * Create a reference
27
23
  * @param value {*} value to reference
24
+ * @param name {string} used for debugging internal state
28
25
  */
29
- ref(value) {
26
+ ref(value, name) {
30
27
  const ref = new Reference(value);
31
- this._watch.add(ref);
28
+ this.bindings.add(ref);
29
+ if (name) {
30
+ this.addState("ref", name, ref);
31
+ }
32
32
  return ref;
33
33
  }
34
34
  /**
35
35
  * Create a forward-only pointer
36
36
  * @param value {IValue} value to point
37
+ * @param name {string} used for debugging internal state
37
38
  */
38
- forward(value) {
39
+ forward(value, name) {
39
40
  const mirror = new Pointer(value);
40
- this._watch.add(mirror);
41
+ this.bindings.add(mirror);
42
+ if (name) {
43
+ this.addState("forward", name, mirror);
44
+ }
41
45
  return mirror;
42
46
  }
43
47
  /**
44
48
  * Creates a pointer
45
49
  * @param value {*} default value to point
50
+ * @param name {string} used for debugging internal state
46
51
  */
47
- own(value) {
52
+ own(value, name) {
48
53
  const pointer = new OwningPointer(value);
49
- this._watch.add(pointer);
54
+ this.bindings.add(pointer);
55
+ /* istanbul ignore else */
56
+ if (name) {
57
+ this.addState("own", name, pointer);
58
+ }
50
59
  return pointer;
51
60
  }
52
61
  /**
53
62
  * Register a model/dependency
54
63
  */
55
- register(data) {
64
+ register(data, name) {
56
65
  this.bindings.add(data);
66
+ if (name) {
67
+ this.addState("model", name, data);
68
+ }
57
69
  return data;
58
70
  }
59
71
  release(data) {
@@ -64,18 +76,22 @@ export class Reactive extends Destroyable {
64
76
  * @param func {function} function to run on any argument change
65
77
  * @param values
66
78
  */
67
- watch(func, ...values) {
68
- this._watch.add(new Expression(func, ...values));
79
+ watch(func, values) {
80
+ this.bindings.add(new Expression(func, values));
69
81
  }
70
82
  /**
71
83
  * Creates a computed value
72
84
  * @param func {function} function to run on any argument change
73
85
  * @param values
86
+ * @param name {string} used for debugging internal state
74
87
  * @return {IValue} the created ivalue
75
88
  */
76
- expr(func, ...values) {
77
- const res = new Expression(func, ...values);
78
- this._watch.add(res);
89
+ expr(func, values, name) {
90
+ const res = new Expression(func, values);
91
+ this.bindings.add(res);
92
+ if (name) {
93
+ this.addState("expr", name, res);
94
+ }
79
95
  return res;
80
96
  }
81
97
  runOnDestroy(func) {
@@ -85,13 +101,13 @@ export class Reactive extends Destroyable {
85
101
  }
86
102
  this.onDestroy = func;
87
103
  }
104
+ addState(method, name, state) {
105
+ this.state[name === "#" ? `#${Object.keys(this.state).length}` : name] = [method, state];
106
+ }
88
107
  destroy() {
89
- var _a;
90
108
  super.destroy();
91
- this._watch.forEach(value => value.destroy());
92
- this._watch.clear();
93
109
  this.bindings.forEach(binding => binding.destroy());
94
110
  this.bindings.clear();
95
- (_a = this.onDestroy) === null || _a === void 0 ? void 0 : _a.call(this);
111
+ this.onDestroy?.();
96
112
  }
97
113
  }
@@ -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, };
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
  }