j-templates 6.1.0 → 6.1.2
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/DOM/domNodeConfig.js +16 -8
- package/Utils/thread.js +2 -1
- package/package.json +1 -1
package/DOM/domNodeConfig.js
CHANGED
|
@@ -9,8 +9,10 @@ const createAssignment_1 = require("./createAssignment");
|
|
|
9
9
|
const createPropertyAssignment_2 = require("./createPropertyAssignment");
|
|
10
10
|
let pendingUpdates = list_1.List.Create();
|
|
11
11
|
let updateScheduled = false;
|
|
12
|
-
const
|
|
12
|
+
const frameTime = 16;
|
|
13
|
+
let lastUpdate = 0;
|
|
13
14
|
function processUpdates() {
|
|
15
|
+
lastUpdate = Date.now();
|
|
14
16
|
list_1.List.Add(pendingUpdates, null);
|
|
15
17
|
let callback;
|
|
16
18
|
while ((callback = list_1.List.Pop(pendingUpdates)))
|
|
@@ -20,6 +22,18 @@ function processUpdates() {
|
|
|
20
22
|
else
|
|
21
23
|
window_1.wndw.requestAnimationFrame(processUpdates);
|
|
22
24
|
}
|
|
25
|
+
function scheduleUpdate(callback) {
|
|
26
|
+
list_1.List.Add(pendingUpdates, callback);
|
|
27
|
+
if (!updateScheduled) {
|
|
28
|
+
if (!updateScheduled) {
|
|
29
|
+
updateScheduled = true;
|
|
30
|
+
if (Date.now() - lastUpdate < frameTime)
|
|
31
|
+
queueMicrotask(processUpdates);
|
|
32
|
+
else
|
|
33
|
+
window_1.wndw.requestAnimationFrame(processUpdates);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
23
37
|
exports.DOMNodeConfig = {
|
|
24
38
|
createNode(type, namespace) {
|
|
25
39
|
return namespace ?
|
|
@@ -29,13 +43,7 @@ exports.DOMNodeConfig = {
|
|
|
29
43
|
createTextNode(value = '') {
|
|
30
44
|
return window_1.wndw.document.createTextNode(value);
|
|
31
45
|
},
|
|
32
|
-
scheduleUpdate
|
|
33
|
-
list_1.List.Add(pendingUpdates, callback);
|
|
34
|
-
if (!updateScheduled) {
|
|
35
|
-
updateScheduled = true;
|
|
36
|
-
window_1.wndw.requestAnimationFrame(processUpdates);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
46
|
+
scheduleUpdate,
|
|
39
47
|
addListener(target, type, callback) {
|
|
40
48
|
target.addEventListener(type, callback);
|
|
41
49
|
},
|
package/Utils/thread.js
CHANGED
|
@@ -11,6 +11,7 @@ const workTimeMs = 16;
|
|
|
11
11
|
const contextQueue = list_1.List.Create();
|
|
12
12
|
let threadContext = null;
|
|
13
13
|
let timeoutRunning = false;
|
|
14
|
+
const scheduleInitialCallback = queueMicrotask;
|
|
14
15
|
const scheduleCallback = setTimeout;
|
|
15
16
|
function timeRemaining() {
|
|
16
17
|
return this.end - Date.now();
|
|
@@ -35,7 +36,7 @@ function ScheduleWork(ctx) {
|
|
|
35
36
|
if (timeoutRunning)
|
|
36
37
|
return;
|
|
37
38
|
timeoutRunning = true;
|
|
38
|
-
|
|
39
|
+
scheduleInitialCallback(ProcessQueue);
|
|
39
40
|
}
|
|
40
41
|
function Invoke(ctx, callback) {
|
|
41
42
|
const parent = ctx.workEndNode;
|