j-templates 6.1.12 → 7.0.1

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 (48) hide show
  1. package/DOM/createAssignment.js +4 -5
  2. package/DOM/createAttributeAssignment.d.ts +1 -0
  3. package/DOM/createAttributeAssignment.js +16 -0
  4. package/DOM/createPropertyAssignment.d.ts +1 -0
  5. package/DOM/createPropertyAssignment.js +7 -0
  6. package/DOM/domNodeConfig.js +40 -0
  7. package/DOM/elements.d.ts +80 -26
  8. package/DOM/elements.js +12 -101
  9. package/DOM/index.d.ts +0 -1
  10. package/DOM/index.js +0 -1
  11. package/DOM/svgElements.d.ts +0 -4
  12. package/DOM/svgElements.js +0 -16
  13. package/Node/component.d.ts +19 -16
  14. package/Node/component.js +25 -31
  15. package/Node/component.types.d.ts +5 -0
  16. package/Node/nodeConfig.d.ts +7 -0
  17. package/Node/vNode.d.ts +20 -0
  18. package/Node/vNode.js +296 -0
  19. package/Node/vNode.types.d.ts +45 -0
  20. package/Store/Tree/observableNode.js +1 -2
  21. package/Store/Tree/observableScope.d.ts +2 -0
  22. package/Store/Tree/observableScope.js +29 -8
  23. package/Utils/avlTree.js +5 -6
  24. package/Utils/decorators.d.ts +4 -25
  25. package/Utils/decorators.js +3 -61
  26. package/Utils/distinctArray.d.ts +1 -1
  27. package/Utils/distinctArray.js +2 -2
  28. package/Utils/list.js +4 -37
  29. package/index.d.ts +1 -2
  30. package/package.json +1 -1
  31. package/Node/boundNode.d.ts +0 -4
  32. package/Node/boundNode.js +0 -115
  33. package/Node/boundNode.types.d.ts +0 -57
  34. package/Node/componentNode.d.ts +0 -7
  35. package/Node/componentNode.js +0 -123
  36. package/Node/componentNode.types.d.ts +0 -37
  37. package/Node/elementNode.d.ts +0 -5
  38. package/Node/elementNode.js +0 -176
  39. package/Node/elementNode.types.d.ts +0 -40
  40. package/Node/elementNode.types.js +0 -2
  41. package/Node/nodeRef.d.ts +0 -26
  42. package/Node/nodeRef.js +0 -253
  43. package/Node/nodeRef.types.d.ts +0 -21
  44. package/Node/nodeRef.types.js +0 -2
  45. package/Node/textNode.types.d.ts +0 -7
  46. package/Node/textNode.types.js +0 -2
  47. /package/Node/{boundNode.types.js → component.types.js} +0 -0
  48. /package/Node/{componentNode.types.js → vNode.types.js} +0 -0
package/Node/vNode.js ADDED
@@ -0,0 +1,296 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vNode = void 0;
4
+ const Store_1 = require("../Store");
5
+ const injector_1 = require("../Utils/injector");
6
+ const list_1 = require("../Utils/list");
7
+ const thread_1 = require("../Utils/thread");
8
+ const nodeConfig_1 = require("./nodeConfig");
9
+ var vNode;
10
+ (function (vNode) {
11
+ function Create(definition) {
12
+ return {
13
+ definition,
14
+ injector: injector_1.Injector.Current() ?? new injector_1.Injector(),
15
+ node: null,
16
+ children: null,
17
+ destroyed: false,
18
+ assignProperties: null,
19
+ assignEvents: null,
20
+ assignAttributes: null,
21
+ component: null,
22
+ scopes: []
23
+ };
24
+ }
25
+ vNode.Create = Create;
26
+ function Init(vnode) {
27
+ if (vnode.definition === null)
28
+ return;
29
+ InitNode(vnode);
30
+ }
31
+ vNode.Init = Init;
32
+ function InitAll(vnodes) {
33
+ for (let x = 0; x < vnodes.length; x++)
34
+ Init(vnodes[x]);
35
+ }
36
+ vNode.InitAll = InitAll;
37
+ function Destroy(vnode) {
38
+ if (vnode.destroyed)
39
+ return;
40
+ vnode.destroyed = true;
41
+ vnode.assignEvents?.(null);
42
+ vnode.component?.Destroy();
43
+ Store_1.ObservableScope.DestroyAll(vnode.scopes);
44
+ vnode.children && DestroyAll(vnode.children);
45
+ }
46
+ vNode.Destroy = Destroy;
47
+ function DestroyAll(vnodes) {
48
+ for (let x = 0; x < vnodes.length; x++)
49
+ Destroy(vnodes[x]);
50
+ }
51
+ vNode.DestroyAll = DestroyAll;
52
+ function ToFunction(type, namespace) {
53
+ return function (config, children) {
54
+ const childrenConfig = children ? Array.isArray(children) ? { childrenArray: children } : { children } : undefined;
55
+ const definition = Object.assign({
56
+ type,
57
+ namespace: namespace ?? null
58
+ }, config, childrenConfig);
59
+ return Create(definition);
60
+ };
61
+ }
62
+ vNode.ToFunction = ToFunction;
63
+ function Attach(node, vnode) {
64
+ Init(vnode);
65
+ nodeConfig_1.NodeConfig.addChild(node, vnode.node);
66
+ return vnode;
67
+ }
68
+ vNode.Attach = Attach;
69
+ })(vNode || (exports.vNode = vNode = {}));
70
+ function InitNode(vnode) {
71
+ const { type, namespace, props, attrs, on, data, componentConstructor, children, childrenArray } = vnode.definition;
72
+ const node = vnode.node = nodeConfig_1.NodeConfig.createNode(type, namespace);
73
+ vnode.definition = null;
74
+ if (props) {
75
+ vnode.assignProperties = nodeConfig_1.NodeConfig.createPropertyAssignment(node);
76
+ if (typeof props === 'function') {
77
+ const scope = Store_1.ObservableScope.Create(props);
78
+ vnode.scopes.push(scope);
79
+ Store_1.ObservableScope.Watch(scope, CreateScheduledCallback(function () {
80
+ const value = Store_1.ObservableScope.Peek(scope);
81
+ vnode.assignProperties(value);
82
+ }));
83
+ const value = Store_1.ObservableScope.Peek(scope);
84
+ vnode.assignProperties(value);
85
+ }
86
+ else {
87
+ vnode.assignProperties(props);
88
+ vnode.assignProperties = null;
89
+ }
90
+ }
91
+ if (on) {
92
+ vnode.assignEvents = nodeConfig_1.NodeConfig.createEventAssignment(node);
93
+ if (typeof on === 'function') {
94
+ const scope = Store_1.ObservableScope.Create(on);
95
+ vnode.scopes.push(scope);
96
+ Store_1.ObservableScope.Watch(scope, CreateScheduledCallback(function () {
97
+ const value = Store_1.ObservableScope.Peek(scope);
98
+ vnode.assignEvents(value);
99
+ }));
100
+ const value = Store_1.ObservableScope.Peek(scope);
101
+ vnode.assignEvents(value);
102
+ }
103
+ else
104
+ vnode.assignEvents(on);
105
+ }
106
+ if (attrs) {
107
+ vnode.assignAttributes = nodeConfig_1.NodeConfig.createAttributeAssignment(node);
108
+ if (typeof attrs === 'function') {
109
+ const scope = Store_1.ObservableScope.Create(attrs);
110
+ vnode.scopes.push(scope);
111
+ Store_1.ObservableScope.Watch(scope, CreateScheduledCallback(function () {
112
+ const value = Store_1.ObservableScope.Peek(scope);
113
+ vnode.assignAttributes(value);
114
+ }));
115
+ const value = Store_1.ObservableScope.Peek(scope);
116
+ vnode.assignAttributes(value);
117
+ }
118
+ else {
119
+ vnode.assignAttributes(attrs);
120
+ vnode.assignAttributes = null;
121
+ }
122
+ }
123
+ if (componentConstructor) {
124
+ vnode.component = new componentConstructor(vnode);
125
+ const componentScope = Store_1.ObservableScope.Create(function () {
126
+ let nodes = vnode.component.Template();
127
+ if (!Array.isArray(nodes))
128
+ nodes = [nodes];
129
+ return nodes;
130
+ });
131
+ vnode.scopes.push(componentScope);
132
+ Store_1.ObservableScope.Watch(componentScope, CreateScheduledCallback(function () {
133
+ const nodes = Store_1.ObservableScope.Peek(componentScope);
134
+ vNode.DestroyAll(vnode.children);
135
+ vnode.children = nodes;
136
+ UpdateChildren(vnode);
137
+ }));
138
+ const nodes = Store_1.ObservableScope.Peek(componentScope);
139
+ vnode.children = nodes;
140
+ }
141
+ else if (childrenArray) {
142
+ vnode.children = childrenArray;
143
+ }
144
+ else if (children) {
145
+ if (data) {
146
+ DynamicChildren(vnode, children, ToArray(data));
147
+ }
148
+ else
149
+ StaticChildren(vnode, children);
150
+ }
151
+ UpdateChildren(vnode, true);
152
+ }
153
+ function StaticChildren(vnode, children) {
154
+ const childrenScope = Store_1.ObservableScope.Create(WrapStaticChildren(vnode.injector, children));
155
+ const child = Store_1.ObservableScope.Peek(childrenScope);
156
+ if (typeof child === 'string') {
157
+ const node = vNode.Create({
158
+ type: 'text',
159
+ namespace: null,
160
+ props() {
161
+ return { nodeValue: Store_1.ObservableScope.Value(childrenScope) };
162
+ }
163
+ });
164
+ node.scopes.push(childrenScope);
165
+ vnode.children = [node];
166
+ }
167
+ else {
168
+ vnode.scopes.push(childrenScope);
169
+ Store_1.ObservableScope.Touch(childrenScope);
170
+ Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function () {
171
+ vNode.DestroyAll(vnode.children);
172
+ const nodes = Store_1.ObservableScope.Peek(childrenScope);
173
+ vnode.children = Array.isArray(nodes) ? nodes : [nodes];
174
+ UpdateChildren(vnode);
175
+ }));
176
+ vnode.children = Array.isArray(child) ? child : [child];
177
+ }
178
+ }
179
+ function WrapStaticChildren(injector, children) {
180
+ return function () {
181
+ return injector_1.Injector.Scope(injector, children, undefined);
182
+ };
183
+ }
184
+ function DestroyNodeList(nodeList) {
185
+ for (let node = nodeList.head; node !== null; node = node.next) {
186
+ vNode.DestroyAll(node.data.nodes);
187
+ Store_1.ObservableScope.Destroy(node.data.scope);
188
+ }
189
+ }
190
+ function DynamicChildren(vnode, children, data) {
191
+ const dataScope = Store_1.ObservableScope.Create(data);
192
+ vnode.scopes.push(dataScope);
193
+ const nodeList = list_1.List.Create();
194
+ const childrenScope = Store_1.ObservableScope.Create(WrapDynamicChildren(dataScope, nodeList, vnode.injector, children));
195
+ vnode.scopes.push(childrenScope);
196
+ Store_1.ObservableScope.OnDestroyed(dataScope, function () {
197
+ DestroyNodeList(nodeList);
198
+ });
199
+ Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function () {
200
+ vnode.children = Store_1.ObservableScope.Peek(childrenScope);
201
+ UpdateChildren(vnode);
202
+ }));
203
+ vnode.children = Store_1.ObservableScope.Value(childrenScope);
204
+ }
205
+ function WrapDynamicChildren(dataScope, nodeList, injector, children) {
206
+ return function () {
207
+ const nextData = Store_1.ObservableScope.Value(dataScope);
208
+ const nodeMap = list_1.List.ToNodeMap(nodeList, function (data) { return data.data; });
209
+ const nextNodeList = list_1.List.Create();
210
+ const nextNodeArray = [];
211
+ for (let x = 0; x < nextData.length; x++) {
212
+ const data = nextData[x];
213
+ const existingNodeArray = nodeMap.get(data);
214
+ let existingNode = null;
215
+ ;
216
+ for (let x = 0; existingNodeArray && x < existingNodeArray.length && existingNode === null; x++) {
217
+ existingNode = existingNodeArray[x];
218
+ existingNodeArray[x] = null;
219
+ }
220
+ if (existingNode !== null) {
221
+ list_1.List.RemoveNode(nodeList, existingNode);
222
+ list_1.List.AddNode(nextNodeList, existingNode);
223
+ if (existingNode.data.scope.dirty) {
224
+ const newNodes = Store_1.ObservableScope.Value(existingNode.data.scope);
225
+ vNode.DestroyAll(existingNode.data.nodes);
226
+ existingNode.data.nodes = newNodes;
227
+ existingNode.data.nodes = Store_1.ObservableScope.Value(existingNode.data.scope);
228
+ }
229
+ }
230
+ else {
231
+ const childrenScope = Store_1.ObservableScope.Create(function () {
232
+ const childNodes = injector_1.Injector.Scope(injector, children, data);
233
+ return Array.isArray(childNodes) ? childNodes : [childNodes];
234
+ });
235
+ list_1.List.Add(nextNodeList, {
236
+ data,
237
+ nodes: Store_1.ObservableScope.Value(childrenScope),
238
+ scope: childrenScope
239
+ });
240
+ }
241
+ nextNodeArray.push(...nextNodeList.tail.data.nodes);
242
+ }
243
+ DestroyNodeList(nodeList);
244
+ list_1.List.Clear(nodeList);
245
+ list_1.List.Append(nodeList, nextNodeList);
246
+ return nextNodeArray;
247
+ };
248
+ }
249
+ function UpdateChildren(vnode, init = false) {
250
+ if (!vnode.children)
251
+ return;
252
+ const children = vnode.children;
253
+ (0, thread_1.Thread)(function () {
254
+ if (vnode.destroyed || children !== vnode.children)
255
+ return;
256
+ for (let x = 0; x < children.length; x++)
257
+ if (children[x].node === null) {
258
+ const childNode = children[x];
259
+ (0, thread_1.Schedule)(function () {
260
+ if (vnode.destroyed || children !== vnode.children)
261
+ return;
262
+ vNode.Init(childNode);
263
+ });
264
+ }
265
+ (0, thread_1.Thread)(function (async) {
266
+ if (vnode.destroyed || children !== vnode.children)
267
+ return;
268
+ if (init || !async)
269
+ nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, vnode.children.map(vnode => vnode.node));
270
+ else
271
+ nodeConfig_1.NodeConfig.scheduleUpdate(function () {
272
+ if (vnode.destroyed || children !== vnode.children)
273
+ return;
274
+ nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, vnode.children.map(vnode => vnode.node));
275
+ });
276
+ });
277
+ });
278
+ }
279
+ function ToArray(callback) {
280
+ return function (...args) {
281
+ const result = callback(...args);
282
+ if (Array.isArray(result))
283
+ return result;
284
+ if (!result)
285
+ return [];
286
+ return [result];
287
+ };
288
+ }
289
+ function CreateScheduledCallback(callback) {
290
+ let scheduled = false;
291
+ return function () {
292
+ if (scheduled)
293
+ return;
294
+ nodeConfig_1.NodeConfig.scheduleUpdate(callback);
295
+ };
296
+ }
@@ -0,0 +1,45 @@
1
+ import { Component } from "./component";
2
+ import { IObservableScope } from "../Store/Tree/observableScope";
3
+ import { Injector } from "../Utils/injector";
4
+ import { RecursivePartial } from "../Utils/utils.types";
5
+ export type FunctionOr<T> = {
6
+ (): T | Promise<T>;
7
+ } | T;
8
+ export type vNodeEvents<E extends {
9
+ [event: string]: any;
10
+ } = any> = {
11
+ [P in keyof E]?: {
12
+ (events: E[P]): void;
13
+ };
14
+ };
15
+ export type vNode = {
16
+ definition: vNodeDefinition<any, any, any>;
17
+ injector: Injector;
18
+ node: Node | null;
19
+ children: vNode[] | null;
20
+ destroyed: boolean;
21
+ assignProperties: (next: any) => void;
22
+ assignEvents: (next: {
23
+ [event: string]: (event: Event) => void;
24
+ }) => void;
25
+ assignAttributes: (next: {
26
+ [attr: string]: string;
27
+ }) => void;
28
+ scopes: IObservableScope<unknown>[];
29
+ component: Component;
30
+ };
31
+ export type vNodeDefinition<P = HTMLElement, E = HTMLElementEventMap, T = never> = {
32
+ type: string;
33
+ namespace: string | null;
34
+ props?: FunctionOr<RecursivePartial<P>>;
35
+ attrs?: FunctionOr<{
36
+ [name: string]: string;
37
+ }>;
38
+ on?: FunctionOr<vNodeEvents<E>>;
39
+ data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
40
+ children?: (data: T) => string | vNode | vNode[];
41
+ childrenArray?: vNode[];
42
+ componentConstructor?: {
43
+ new (vnode: vNode): Component<any, any, any>;
44
+ };
45
+ };
@@ -131,8 +131,7 @@ function CreateProxyFactory(alias) {
131
131
  case "shift":
132
132
  case "sort":
133
133
  case "reverse":
134
- if (readOnly)
135
- throw `Object is readonly`;
134
+ throw "Object is readonly";
136
135
  }
137
136
  switch (prop) {
138
137
  case exports.IS_OBSERVABLE_NODE:
@@ -52,6 +52,7 @@ export declare namespace ObservableScope {
52
52
  }): IObservableScope<T>;
53
53
  function Register(emitter: Emitter): void;
54
54
  function Init<T>(scope: IObservableScope<T>): void;
55
+ function Peek<T>(scope: IObservableScope<T>): T;
55
56
  function Value<T>(scope: IObservableScope<T>): T;
56
57
  function Touch<T>(scope: IObservableScope<T>): void;
57
58
  function Watch<T>(scope: IObservableScope<T>, callback: EmitterCallback<[IObservableScope<T>]>): void;
@@ -59,5 +60,6 @@ export declare namespace ObservableScope {
59
60
  function OnDestroyed(scope: IObservableScope<unknown>, callback: () => void): void;
60
61
  function Update(scope: IObservableScope<any>): void;
61
62
  function Destroy<T>(scope: IObservableScope<T>): void;
63
+ function DestroyAll(scopes: IObservableScope<unknown>[]): void;
62
64
  }
63
65
  export {};
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObservableScope = exports.ObservableScopeWrapper = exports.ObservableScopeValue = void 0;
4
4
  exports.CalcScope = CalcScope;
5
5
  const array_1 = require("../../Utils/array");
6
- const avlTree_1 = require("../../Utils/avlTree");
6
+ const distinctArray_1 = require("../../Utils/distinctArray");
7
7
  const emitter_1 = require("../../Utils/emitter");
8
8
  class ObservableScopeValue {
9
9
  get Value() {
@@ -51,9 +51,11 @@ exports.ObservableScope = ObservableScope;
51
51
  let watchState = null;
52
52
  function WatchScope(scope) {
53
53
  const parent = watchState;
54
- watchState = [avlTree_1.AVL.Create(emitter_1.Emitter.Compare), []];
54
+ watchState = [distinctArray_1.DistinctArray.Create(emitter_1.Emitter.GetId), []];
55
55
  const value = scope.getFunction();
56
- const result = [value, avlTree_1.AVL.ToArray(watchState[0]), watchState[1]];
56
+ const emitters = distinctArray_1.DistinctArray.Get(watchState[0]);
57
+ emitters.sort(emitter_1.Emitter.Compare);
58
+ const result = [value, emitters, watchState[1]];
57
59
  watchState = parent;
58
60
  return result;
59
61
  }
@@ -89,7 +91,7 @@ function CalcScope(callback) {
89
91
  function Register(emitter) {
90
92
  if (watchState === null)
91
93
  return;
92
- avlTree_1.AVL.Insert(watchState[0], emitter);
94
+ distinctArray_1.DistinctArray.Push(watchState[0], emitter);
93
95
  }
94
96
  ObservableScope.Register = Register;
95
97
  function Init(scope) {
@@ -98,13 +100,19 @@ function CalcScope(callback) {
98
100
  UpdateValue(scope);
99
101
  }
100
102
  ObservableScope.Init = Init;
101
- function Value(scope) {
103
+ function Peek(scope) {
102
104
  if (!scope)
103
105
  return undefined;
104
- Register(scope.emitter);
105
106
  UpdateValue(scope);
106
107
  return scope.value;
107
108
  }
109
+ ObservableScope.Peek = Peek;
110
+ function Value(scope) {
111
+ if (!scope)
112
+ return undefined;
113
+ Touch(scope);
114
+ return Peek(scope);
115
+ }
108
116
  ObservableScope.Value = Value;
109
117
  function Touch(scope) {
110
118
  if (!scope || !scope.emitter)
@@ -139,6 +147,11 @@ function CalcScope(callback) {
139
147
  DestroyScope(scope);
140
148
  }
141
149
  ObservableScope.Destroy = Destroy;
150
+ function DestroyAll(scopes) {
151
+ for (let x = 0; x < scopes.length; x++)
152
+ Destroy(scopes[x]);
153
+ }
154
+ ObservableScope.DestroyAll = DestroyAll;
142
155
  })(ObservableScope || (exports.ObservableScope = ObservableScope = {}));
143
156
  function CalcChanged(calc) {
144
157
  const value = calc.getFunction();
@@ -150,7 +163,16 @@ function DirtyScope(scope) {
150
163
  if (scope.dirty || !scope.getFunction)
151
164
  return;
152
165
  scope.dirty = scope.calcFunctions.length === 0 || scope.calcFunctions.some(CalcChanged);
153
- scope.dirty && emitter_1.Emitter.Emit(scope.emitter, scope);
166
+ if (!scope.dirty)
167
+ return;
168
+ if (scope.async) {
169
+ UpdateValue(scope);
170
+ scope.promise.then(function () {
171
+ emitter_1.Emitter.Emit(scope.emitter, scope);
172
+ });
173
+ }
174
+ else
175
+ emitter_1.Emitter.Emit(scope.emitter, scope);
154
176
  }
155
177
  const scopeQueue = new Set();
156
178
  function ProcessScopeQueue() {
@@ -178,7 +200,6 @@ function UpdateValue(scope) {
178
200
  if (scope.async) {
179
201
  scope.promise = value.then(function (result) {
180
202
  scope.value = result;
181
- emitter_1.Emitter.Emit(scope.emitter, scope);
182
203
  return result;
183
204
  });
184
205
  }
package/Utils/avlTree.js CHANGED
@@ -30,7 +30,7 @@ var AVL;
30
30
  }
31
31
  AVL.Insert = Insert;
32
32
  function ForEach(tree, callback) {
33
- PreOrder(tree.root, callback);
33
+ InOrder(tree.root, callback);
34
34
  }
35
35
  AVL.ForEach = ForEach;
36
36
  function ToArray(tree) {
@@ -43,12 +43,12 @@ var AVL;
43
43
  }
44
44
  AVL.ToArray = ToArray;
45
45
  })(AVL || (exports.AVL = AVL = {}));
46
- function PreOrder(node, callback) {
46
+ function InOrder(node, callback) {
47
47
  if (node === null)
48
48
  return;
49
- PreOrder(node[LEFT], callback);
49
+ InOrder(node[LEFT], callback);
50
50
  callback(node[VALUE]);
51
- PreOrder(node[RIGHT], callback);
51
+ InOrder(node[RIGHT], callback);
52
52
  }
53
53
  function CreateTree(compare) {
54
54
  return {
@@ -63,10 +63,9 @@ function CreateNode(value) {
63
63
  function InsertValue(tree, value) {
64
64
  const startSize = tree.size;
65
65
  let node = tree.root;
66
- let comp = 0;
67
66
  const path = [];
68
67
  while (node !== null) {
69
- comp = Squash(tree.compare(value, node[VALUE]));
68
+ const comp = Squash(tree.compare(value, node[VALUE]));
70
69
  path.push([comp, node]);
71
70
  switch (comp) {
72
71
  case 0:
@@ -1,34 +1,13 @@
1
- import { Component } from "../Node/component";
2
1
  import { IDestroyable } from "./utils.types";
3
- import { ElementNodeRefTypes } from "../Node/nodeRef.types";
4
- export declare function Computed<T extends Component<any, any, any>, K extends keyof T, V extends T[K]>(defaultValue: V): (target: T, propertyKey: K, descriptor: PropertyDescriptor) => PropertyDescriptor;
5
- export declare function ComputedAsync<T extends Component<any, any, any>, K extends keyof T, V extends T[K]>(defaultValue: V): (target: T, propertyKey: K, descriptor: PropertyDescriptor) => PropertyDescriptor;
2
+ export declare function Computed<T extends WeakKey, K extends keyof T, V extends T[K]>(defaultValue: V): (target: T, propertyKey: K, descriptor: PropertyDescriptor) => PropertyDescriptor;
3
+ export declare function ComputedAsync<T extends WeakKey, K extends keyof T, V extends T[K]>(defaultValue: V): (target: T, propertyKey: K, descriptor: PropertyDescriptor) => PropertyDescriptor;
6
4
  export declare function State(): any;
7
5
  export declare function Value(): any;
8
6
  export declare function Scope(): typeof ScopeDecorator;
9
- declare function ScopeDecorator<T extends Component<any, any, any>, K extends string>(target: T, propertyKey: K, descriptor: PropertyDescriptor): PropertyDescriptor;
10
- export declare function Inject<I>(type: {
11
- new (...args: Array<any>): I;
12
- }): <F extends I, T extends Component<any, any, any> & Record<K, F>, K extends string>(target: T, propertyKey: K, descriptor?: PropertyDescriptor) => any;
7
+ declare function ScopeDecorator<T, K extends string>(target: T, propertyKey: K, descriptor: PropertyDescriptor): PropertyDescriptor;
13
8
  export declare function Destroy(): typeof DestroyDecorator;
14
9
  export declare namespace Destroy {
15
10
  function All<T extends WeakKey, K>(value: T): void;
16
11
  }
17
- declare function DestroyDecorator<T extends Component<any, any, any> & Record<K, IDestroyable>, K extends string>(target: T, propertyKey: K): any;
18
- export declare function PreReqTemplate(template: {
19
- (): ElementNodeRefTypes | ElementNodeRefTypes[];
20
- }): <T extends Component<any, any, any>>(target: {
21
- new (...args: Array<any>): T;
22
- }) => any;
23
- export declare namespace PreReqTemplate {
24
- function Get(value: any): ElementNodeRefTypes[];
25
- }
26
- export declare function PreReq(): typeof PreReqDecorator;
27
- export declare namespace PreReq {
28
- function All(value: any): Promise<void[]>;
29
- function Has(value: any): boolean;
30
- }
31
- declare function PreReqDecorator<T extends Record<K, {
32
- Init: Promise<void>;
33
- }>, K extends string>(target: T, propertyKey: K): any;
12
+ declare function DestroyDecorator<T extends Record<K, IDestroyable>, K extends string>(target: T, propertyKey: K): any;
34
13
  export {};
@@ -5,10 +5,7 @@ exports.ComputedAsync = ComputedAsync;
5
5
  exports.State = State;
6
6
  exports.Value = Value;
7
7
  exports.Scope = Scope;
8
- exports.Inject = Inject;
9
8
  exports.Destroy = Destroy;
10
- exports.PreReqTemplate = PreReqTemplate;
11
- exports.PreReq = PreReq;
12
9
  const observableScope_1 = require("../Store/Tree/observableScope");
13
10
  const observableNode_1 = require("../Store/Tree/observableNode");
14
11
  const Store_1 = require("../Store");
@@ -170,21 +167,6 @@ function ScopeDecorator(target, propertyKey, descriptor) {
170
167
  },
171
168
  };
172
169
  }
173
- function Inject(type) {
174
- return InjectorDecorator.bind(null, type);
175
- }
176
- function InjectorDecorator(type, target, propertyKey, descriptor) {
177
- return {
178
- configurable: false,
179
- enumerable: true,
180
- get: function () {
181
- return this.Injector.Get(type);
182
- },
183
- set: function (val) {
184
- this.Injector.Set(type, val);
185
- },
186
- };
187
- }
188
170
  function Destroy() {
189
171
  return DestroyDecorator;
190
172
  }
@@ -192,9 +174,9 @@ function Destroy() {
192
174
  function All(value) {
193
175
  const scopeMap = scopeInstanceMap.get(value);
194
176
  if (scopeMap !== undefined) {
195
- const keys = Object.keys(scopeMap);
196
- for (let x = 0; x < keys.length; x++)
197
- observableScope_1.ObservableScope.Destroy(scopeMap[keys[x]][0]);
177
+ const values = Object.values(scopeMap);
178
+ for (let x = 0; x < values.length; x++)
179
+ observableScope_1.ObservableScope.Destroy(values[x][0]);
198
180
  }
199
181
  const array = GetDestroyArrayForPrototype(Object.getPrototypeOf(value));
200
182
  for (let x = 0; x < array.length; x++)
@@ -206,43 +188,3 @@ function DestroyDecorator(target, propertyKey) {
206
188
  const array = GetDestroyArrayForPrototype(target);
207
189
  array.push(propertyKey);
208
190
  }
209
- function PreReqTemplate(template) {
210
- return PreReqTemplateDecorator.bind(null, template);
211
- }
212
- (function (PreReqTemplate) {
213
- function Get(value) {
214
- var func = value && value.PreReqTemplateDecorator_Template;
215
- var ret = func ? func() : [];
216
- if (!Array.isArray(ret))
217
- ret = [ret];
218
- return ret;
219
- }
220
- PreReqTemplate.Get = Get;
221
- })(PreReqTemplate || (exports.PreReqTemplate = PreReqTemplate = {}));
222
- function PreReqTemplateDecorator(template, target) {
223
- var proto = target.prototype;
224
- proto.PreReqTemplateDecorator_Template = template;
225
- }
226
- function PreReq() {
227
- return PreReqDecorator;
228
- }
229
- (function (PreReq) {
230
- function Get(value) {
231
- return (value && value.PreReqDecorator_PreReqs) || [];
232
- }
233
- function All(value) {
234
- var arr = Get(value).map((prop) => (value[prop] && value[prop].Init) ||
235
- Promise.resolve());
236
- return Promise.all(arr);
237
- }
238
- PreReq.All = All;
239
- function Has(value) {
240
- return Get(value).length > 0;
241
- }
242
- PreReq.Has = Has;
243
- })(PreReq || (exports.PreReq = PreReq = {}));
244
- function PreReqDecorator(target, propertyKey) {
245
- var proto = target;
246
- proto.PreReqDecorator_PreReqs = proto.PreReqDecorator_PreReqs || [];
247
- proto.PreReqDecorator_PreReqs.push(propertyKey);
248
- }
@@ -1,6 +1,6 @@
1
1
  export type DistinctArray<T> = {
2
2
  id: (value: T) => number;
3
- distinct: T[];
3
+ distinct: boolean[];
4
4
  array: T[];
5
5
  };
6
6
  export declare namespace DistinctArray {
@@ -13,8 +13,8 @@ var DistinctArray;
13
13
  DistinctArray.Create = Create;
14
14
  function Push({ id, distinct, array }, value) {
15
15
  const vId = id(value);
16
- if (distinct[vId] === undefined) {
17
- distinct[vId] = value;
16
+ if (!distinct[vId]) {
17
+ distinct[vId] = true;
18
18
  array.push(value);
19
19
  }
20
20
  }