j-templates 7.0.94 → 7.0.96

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.
@@ -7,6 +7,7 @@ exports.GateScope = GateScope;
7
7
  exports.PeekScope = PeekScope;
8
8
  const emitter_1 = require("../../Utils/emitter");
9
9
  const functions_1 = require("../../Utils/functions");
10
+ const scheduling_1 = require("../../Utils/scheduling");
10
11
  function Invoke(param, callback) {
11
12
  return callback(param);
12
13
  }
@@ -87,9 +88,9 @@ function ProcessScopeQueue() {
87
88
  * @param scope The scope to queue for update.
88
89
  */
89
90
  function OnSetQueued(scope) {
90
- if (scopeQueue.length === 0)
91
- queueMicrotask(ProcessScopeQueue);
92
91
  scopeQueue.push(scope);
92
+ if (scopeQueue.length === 1)
93
+ (0, scheduling_1._queueMicrotask)(ProcessScopeQueue);
93
94
  }
94
95
  /**
95
96
  * Marks a scope as dirty and triggers update behavior based on scope type.
package/Utils/emitter.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Emitter = void 0;
4
- const scheduleCallback = typeof requestIdleCallback !== "undefined"
5
- ? requestIdleCallback
6
- : setTimeout;
4
+ const scheduling_1 = require("./scheduling");
7
5
  const pendingCompactEmitters = new Set();
8
6
  function Compact(emitter) {
9
7
  if (emitter.length === 1 || emitter[0] === 0)
@@ -16,7 +14,7 @@ function ScheduleCompact() {
16
14
  if (compactScheduled)
17
15
  return;
18
16
  compactScheduled = true;
19
- scheduleCallback(PerformCompact);
17
+ (0, scheduling_1._requestIdleCallback)(PerformCompact);
20
18
  }
21
19
  function PerformCompact() {
22
20
  compactScheduled = false;
@@ -0,0 +1,4 @@
1
+ export declare const _requestAnimationFrame: typeof window.requestAnimationFrame;
2
+ export declare const _setTimeout: typeof window.setTimeout;
3
+ export declare const _queueMicrotask: typeof window.queueMicrotask;
4
+ export declare const _requestIdleCallback: typeof window.requestIdleCallback;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._requestIdleCallback = exports._queueMicrotask = exports._setTimeout = exports._requestAnimationFrame = void 0;
4
+ const IMMEDIATE_OVERRIDE = typeof process !== "undefined" ?
5
+ process.env.SYNC_SCHEDULING === 'true' :
6
+ false;
7
+ exports._requestAnimationFrame = IMMEDIATE_OVERRIDE ?
8
+ function immediateRequestAnimationFrame(callback) {
9
+ callback(0);
10
+ return 0;
11
+ } : window.requestAnimationFrame;
12
+ exports._setTimeout = IMMEDIATE_OVERRIDE ?
13
+ function immediateSetTimeout(handler, timeout, ...args) {
14
+ if (typeof handler === "function")
15
+ handler(...args);
16
+ return 0;
17
+ } : window.setTimeout;
18
+ exports._queueMicrotask = IMMEDIATE_OVERRIDE ?
19
+ function immediateQueueMicrotask(callback) {
20
+ callback();
21
+ } : window.queueMicrotask;
22
+ exports._requestIdleCallback = IMMEDIATE_OVERRIDE ?
23
+ function immediateRequestIdleCallback(callback, options) {
24
+ callback({ didTimeout: false, timeRemaining: () => 0 });
25
+ return 0;
26
+ } : window.requestIdleCallback ?? window.setTimeout;
package/Utils/thread.js CHANGED
@@ -7,6 +7,7 @@ exports.Synch = Synch;
7
7
  exports.Thread = Thread;
8
8
  exports.ThreadAsync = ThreadAsync;
9
9
  const list_1 = require("./list");
10
+ const scheduling_1 = require("./scheduling");
10
11
  // Constants
11
12
  /**
12
13
  * The maximum time allowed for work execution in milliseconds
@@ -19,9 +20,6 @@ const contextQueue = list_1.List.Create();
19
20
  // State variables
20
21
  let threadContext = null;
21
22
  let timeoutRunning = false;
22
- // Callback scheduling functions
23
- const scheduleInitialCallback = queueMicrotask;
24
- const scheduleCallback = setTimeout;
25
23
  /**
26
24
  * Calculates the remaining time until the deadline
27
25
  * @param this - The deadline object
@@ -49,7 +47,7 @@ function ProcessQueue(deadline = createDeadline()) {
49
47
  while (deadline.timeRemaining() > 0 && (ctx = list_1.List.Pop(contextQueue)))
50
48
  DoWork(ctx, deadline);
51
49
  if (contextQueue.size > 0)
52
- scheduleCallback(ProcessQueue);
50
+ (0, scheduling_1._setTimeout)(ProcessQueue);
53
51
  else
54
52
  timeoutRunning = false;
55
53
  }
@@ -62,7 +60,7 @@ function ScheduleWork(ctx) {
62
60
  if (timeoutRunning)
63
61
  return;
64
62
  timeoutRunning = true;
65
- scheduleInitialCallback(ProcessQueue);
63
+ (0, scheduling_1._queueMicrotask)(ProcessQueue);
66
64
  }
67
65
  /**
68
66
  * Invokes a callback in the specified thread context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.94",
3
+ "version": "7.0.96",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",
package/DOM/window.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const wndw: Window;
package/DOM/window.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wndw = void 0;
4
- function jsdomWindow() {
5
- try {
6
- return require("jsdom").JSDOM("").window;
7
- }
8
- catch (err) {
9
- return undefined;
10
- }
11
- }
12
- exports.wndw = typeof window !== "undefined" ? window : jsdomWindow();