j-templates 7.0.43 → 7.0.45

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.
@@ -3,6 +3,7 @@ export declare const IS_OBSERVABLE_NODE = "____isObservableNode";
3
3
  export declare const GET_OBSERVABLE_VALUE = "____getObservableValue";
4
4
  export declare const GET_TO_JSON = "toJSON";
5
5
  export declare namespace ObservableNode {
6
+ function BypassProxy(value: boolean): void;
6
7
  function Create<T>(value: T): T;
7
8
  function Touch(value: unknown, prop?: string | number): void;
8
9
  function ApplyDiff(rootNode: any, diffResult: JsonDiffResult): void;
@@ -4,6 +4,7 @@ exports.ObservableNode = exports.GET_TO_JSON = exports.GET_OBSERVABLE_VALUE = ex
4
4
  const json_1 = require("../../Utils/json");
5
5
  const jsonType_1 = require("../../Utils/jsonType");
6
6
  const observableScope_1 = require("./observableScope");
7
+ let bypassProxy = false;
7
8
  exports.IS_OBSERVABLE_NODE = "____isObservableNode";
8
9
  exports.GET_OBSERVABLE_VALUE = "____getObservableValue";
9
10
  exports.GET_TO_JSON = "toJSON";
@@ -146,6 +147,8 @@ function CreateProxyFactory(alias) {
146
147
  const scope = scopeCache.get(array);
147
148
  array = observableScope_1.ObservableScope.Value(scope);
148
149
  const arrayValue = array[prop];
150
+ if (bypassProxy)
151
+ return arrayValue;
149
152
  if (typeof prop === "symbol")
150
153
  return arrayValue;
151
154
  if (typeof arrayValue === "function")
@@ -221,6 +224,8 @@ function CreateProxyFactory(alias) {
221
224
  case exports.GET_OBSERVABLE_VALUE:
222
225
  return object;
223
226
  default: {
227
+ if (bypassProxy)
228
+ return object[prop];
224
229
  return GetAccessorValue(object, prop);
225
230
  }
226
231
  }
@@ -259,6 +264,10 @@ function CreateProxyFactory(alias) {
259
264
  const DefaultCreateProxy = CreateProxyFactory();
260
265
  var ObservableNode;
261
266
  (function (ObservableNode) {
267
+ function BypassProxy(value) {
268
+ bypassProxy = value;
269
+ }
270
+ ObservableNode.BypassProxy = BypassProxy;
262
271
  function Create(value) {
263
272
  return DefaultCreateProxy(value);
264
273
  }
@@ -6,6 +6,7 @@ const array_1 = require("../../Utils/array");
6
6
  const distinctArray_1 = require("../../Utils/distinctArray");
7
7
  const emitter_1 = require("../../Utils/emitter");
8
8
  const functions_1 = require("../../Utils/functions");
9
+ const observableNode_1 = require("./observableNode");
9
10
  class ObservableScopeValue {
10
11
  get Value() {
11
12
  return ObservableScope.Value(this.scope);
@@ -65,7 +66,7 @@ function CalcScope(callback) {
65
66
  if (watchState !== null)
66
67
  watchState[1].push({
67
68
  getFunction: callback,
68
- value
69
+ value,
69
70
  });
70
71
  return value;
71
72
  }
@@ -157,11 +158,13 @@ function CalcScope(callback) {
157
158
  function DirtyScope(scope) {
158
159
  if (scope.dirty || !scope.getFunction)
159
160
  return;
161
+ observableNode_1.ObservableNode.BypassProxy(true);
160
162
  let dirty = scope.calcFunctions.length === 0;
161
163
  for (let x = 0; !dirty && x < scope.calcFunctions.length; x++) {
162
164
  const calc = scope.calcFunctions[x];
163
165
  dirty = dirty || calc.value !== calc.getFunction();
164
166
  }
167
+ observableNode_1.ObservableNode.BypassProxy(false);
165
168
  scope.dirty = dirty;
166
169
  if (!scope.dirty)
167
170
  return;
@@ -1,10 +1,10 @@
1
1
  export type DistinctArray<T> = {
2
- id: (value: T) => number;
3
- distinct: Array<true | undefined> | null;
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) => number): DistinctArray<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
  }
@@ -12,22 +12,20 @@ var DistinctArray;
12
12
  }
13
13
  DistinctArray.Create = Create;
14
14
  function Push(distinctArr, value) {
15
- const { id, array } = distinctArr;
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[vId] === undefined) {
29
- distinctArr.distinct[vId] = true;
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 && deadline.timeRemaining() > 0 && (callback = list_1.List.Pop(ctx.workList)))
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 () { callback(a, b, c, d); });
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
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.43",
3
+ "version": "7.0.45",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",