j-templates 7.0.42 → 7.0.44
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/Node/vNode.js +11 -20
- package/Utils/distinctArray.d.ts +3 -3
- package/Utils/distinctArray.js +7 -9
- package/Utils/thread.js +9 -5
- package/package.json +1 -1
package/Node/vNode.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vNode = void 0;
|
|
4
4
|
const Store_1 = require("../Store");
|
|
5
|
-
const functions_1 = require("../Utils/functions");
|
|
6
5
|
const injector_1 = require("../Utils/injector");
|
|
7
6
|
const list_1 = require("../Utils/list");
|
|
8
7
|
const thread_1 = require("../Utils/thread");
|
|
@@ -153,18 +152,20 @@ function Children(vnode, children, data) {
|
|
|
153
152
|
function CreateChildrenScope(vnode, children, data) {
|
|
154
153
|
if (data === undefined)
|
|
155
154
|
return Store_1.ObservableScope.Create(WrapStaticChildren(vnode, children));
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
155
|
+
const dataScope = Store_1.ObservableScope.Create(data);
|
|
156
|
+
data = function () {
|
|
157
|
+
const result = Store_1.ObservableScope.Value(dataScope);
|
|
158
|
+
if (!result)
|
|
159
|
+
return [];
|
|
160
|
+
if (Array.isArray(result))
|
|
161
|
+
return result;
|
|
162
|
+
return [result];
|
|
163
|
+
};
|
|
164
164
|
const nodeList = list_1.List.Create();
|
|
165
|
-
const scope = Store_1.ObservableScope.Create(WrapChildren(vnode.injector, children,
|
|
165
|
+
const scope = Store_1.ObservableScope.Create(WrapChildren(vnode.injector, children, data, nodeList));
|
|
166
166
|
Store_1.ObservableScope.OnDestroyed(scope, function () {
|
|
167
167
|
DestroyNodeList(nodeList);
|
|
168
|
+
Store_1.ObservableScope.Destroy(dataScope);
|
|
168
169
|
});
|
|
169
170
|
return scope;
|
|
170
171
|
}
|
|
@@ -277,16 +278,6 @@ function UpdateChildren(vnode, init = false, skipInit = false) {
|
|
|
277
278
|
});
|
|
278
279
|
});
|
|
279
280
|
}
|
|
280
|
-
function ToArray(callback) {
|
|
281
|
-
return function (...args) {
|
|
282
|
-
const result = callback(...args);
|
|
283
|
-
if (Array.isArray(result))
|
|
284
|
-
return result;
|
|
285
|
-
if (!result)
|
|
286
|
-
return [];
|
|
287
|
-
return [result];
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
281
|
function ScheduledAssignment(assign) {
|
|
291
282
|
let scheduled = false;
|
|
292
283
|
return function (scope) {
|
package/Utils/distinctArray.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type DistinctArray<T> = {
|
|
2
|
-
id: (value: T) =>
|
|
3
|
-
distinct:
|
|
2
|
+
id: (value: T) => unknown;
|
|
3
|
+
distinct: Set<unknown> | null;
|
|
4
4
|
array: T[];
|
|
5
5
|
};
|
|
6
6
|
export declare namespace DistinctArray {
|
|
7
|
-
function Create<T>(id: (value: T) =>
|
|
7
|
+
function Create<T>(id: (value: T) => unknown): DistinctArray<T>;
|
|
8
8
|
function Push<T>(distinctArr: DistinctArray<T>, value: T): void;
|
|
9
9
|
function Get<T>({ array }: DistinctArray<T>): T[];
|
|
10
10
|
}
|
package/Utils/distinctArray.js
CHANGED
|
@@ -12,22 +12,20 @@ var DistinctArray;
|
|
|
12
12
|
}
|
|
13
13
|
DistinctArray.Create = Create;
|
|
14
14
|
function Push(distinctArr, value) {
|
|
15
|
-
|
|
16
|
-
switch (array.length) {
|
|
15
|
+
switch (distinctArr.array.length) {
|
|
17
16
|
case 0:
|
|
18
|
-
array.push(value);
|
|
17
|
+
distinctArr.array.push(value);
|
|
19
18
|
break;
|
|
20
19
|
case 1: {
|
|
21
20
|
if (distinctArr.distinct === null) {
|
|
22
|
-
distinctArr.distinct = [];
|
|
23
|
-
distinctArr.distinct[id(array[0])] = true;
|
|
21
|
+
distinctArr.distinct = new Set([distinctArr.id(distinctArr.array[0])]);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
default: {
|
|
27
|
-
const vId = id(value);
|
|
28
|
-
if (distinctArr.distinct
|
|
29
|
-
distinctArr.distinct
|
|
30
|
-
array.push(value);
|
|
25
|
+
const vId = distinctArr.id(value);
|
|
26
|
+
if (!distinctArr.distinct.has(vId)) {
|
|
27
|
+
distinctArr.distinct.add(vId);
|
|
28
|
+
distinctArr.array.push(value);
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
}
|
package/Utils/thread.js
CHANGED
|
@@ -19,7 +19,7 @@ function timeRemaining() {
|
|
|
19
19
|
function createDeadline() {
|
|
20
20
|
return {
|
|
21
21
|
end: Date.now() + workTimeMs,
|
|
22
|
-
timeRemaining
|
|
22
|
+
timeRemaining,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function ProcessQueue(deadline = createDeadline()) {
|
|
@@ -49,7 +49,9 @@ function DoWork(ctx, deadline = createDeadline()) {
|
|
|
49
49
|
threadContext = ctx;
|
|
50
50
|
const async = ctx.async;
|
|
51
51
|
let callback;
|
|
52
|
-
while (async === ctx.async &&
|
|
52
|
+
while (async === ctx.async &&
|
|
53
|
+
deadline.timeRemaining() > 0 &&
|
|
54
|
+
(callback = list_1.List.Pop(ctx.workList)))
|
|
53
55
|
Invoke(ctx, callback);
|
|
54
56
|
if (ctx.workList.size > 0)
|
|
55
57
|
ScheduleWork(ctx);
|
|
@@ -59,7 +61,7 @@ function CreateContext() {
|
|
|
59
61
|
return {
|
|
60
62
|
async: false,
|
|
61
63
|
workEndNode: null,
|
|
62
|
-
workList: list_1.List.Create()
|
|
64
|
+
workList: list_1.List.Create(),
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
function ScheduleCallback(callback, before, async) {
|
|
@@ -89,7 +91,9 @@ function After(callback) {
|
|
|
89
91
|
}
|
|
90
92
|
function Callback(callback) {
|
|
91
93
|
return function (a, b, c, d) {
|
|
92
|
-
Schedule(function () {
|
|
94
|
+
Schedule(function () {
|
|
95
|
+
callback(a, b, c, d);
|
|
96
|
+
});
|
|
93
97
|
};
|
|
94
98
|
}
|
|
95
99
|
var inSynchCallback = false;
|
|
@@ -109,7 +113,7 @@ function Thread(callback) {
|
|
|
109
113
|
Synch(callback);
|
|
110
114
|
}
|
|
111
115
|
function ThreadAsync(callback) {
|
|
112
|
-
return new Promise(resolve => Thread(function (async) {
|
|
116
|
+
return new Promise((resolve) => Thread(function (async) {
|
|
113
117
|
callback(async);
|
|
114
118
|
Thread(resolve);
|
|
115
119
|
}));
|