j-templates 7.0.47 → 7.0.49

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/elements.d.ts CHANGED
@@ -46,6 +46,14 @@ export declare const input: <T>(config: {
46
46
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
47
47
  data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
48
48
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
49
+ export declare const textarea: <T>(config: {
50
+ props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLTextAreaElement>>;
51
+ attrs?: import("../Node/vNode.types").FunctionOr<{
52
+ [name: string]: string;
53
+ }>;
54
+ on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
55
+ data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
56
+ }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
49
57
  export declare const span: <T>(config: {
50
58
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
51
59
  attrs?: import("../Node/vNode.types").FunctionOr<{
package/DOM/elements.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.text = exports.video = exports.img = exports.td = exports.tr = exports.tbody = exports.table = exports.span = exports.input = exports.h1 = exports.button = exports.b = exports.a = exports.div = void 0;
3
+ exports.text = exports.video = exports.img = exports.td = exports.tr = exports.tbody = exports.table = exports.span = exports.textarea = exports.input = exports.h1 = exports.button = exports.b = exports.a = exports.div = void 0;
4
4
  const vNode_1 = require("../Node/vNode");
5
5
  exports.div = vNode_1.vNode.ToFunction("div");
6
6
  exports.a = vNode_1.vNode.ToFunction("a");
@@ -8,6 +8,7 @@ exports.b = vNode_1.vNode.ToFunction("b");
8
8
  exports.button = vNode_1.vNode.ToFunction("button");
9
9
  exports.h1 = vNode_1.vNode.ToFunction("h1");
10
10
  exports.input = vNode_1.vNode.ToFunction("input");
11
+ exports.textarea = vNode_1.vNode.ToFunction("textarea");
11
12
  exports.span = vNode_1.vNode.ToFunction("span");
12
13
  exports.table = vNode_1.vNode.ToFunction("table");
13
14
  exports.tbody = vNode_1.vNode.ToFunction("tbody");
@@ -3,7 +3,6 @@ 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;
7
6
  function Create<T>(value: T): T;
8
7
  function Touch(value: unknown, prop?: string | number): void;
9
8
  function ApplyDiff(rootNode: any, diffResult: JsonDiffResult): void;
@@ -4,7 +4,6 @@ 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;
8
7
  exports.IS_OBSERVABLE_NODE = "____isObservableNode";
9
8
  exports.GET_OBSERVABLE_VALUE = "____getObservableValue";
10
9
  exports.GET_TO_JSON = "toJSON";
@@ -147,8 +146,6 @@ function CreateProxyFactory(alias) {
147
146
  const scope = scopeCache.get(array);
148
147
  array = observableScope_1.ObservableScope.Value(scope);
149
148
  const arrayValue = array[prop];
150
- if (bypassProxy)
151
- return arrayValue;
152
149
  if (typeof prop === "symbol")
153
150
  return arrayValue;
154
151
  if (typeof arrayValue === "function")
@@ -224,8 +221,6 @@ function CreateProxyFactory(alias) {
224
221
  case exports.GET_OBSERVABLE_VALUE:
225
222
  return object;
226
223
  default: {
227
- if (bypassProxy)
228
- return object[prop];
229
224
  return GetAccessorValue(object, prop);
230
225
  }
231
226
  }
@@ -264,10 +259,6 @@ function CreateProxyFactory(alias) {
264
259
  const DefaultCreateProxy = CreateProxyFactory();
265
260
  var ObservableNode;
266
261
  (function (ObservableNode) {
267
- function BypassProxy(value) {
268
- bypassProxy = value;
269
- }
270
- ObservableNode.BypassProxy = BypassProxy;
271
262
  function Create(value) {
272
263
  return DefaultCreateProxy(value);
273
264
  }
@@ -3,10 +3,8 @@ 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 distinctArray_1 = require("../../Utils/distinctArray");
7
6
  const emitter_1 = require("../../Utils/emitter");
8
7
  const functions_1 = require("../../Utils/functions");
9
- const observableNode_1 = require("./observableNode");
10
8
  class ObservableScopeValue {
11
9
  get Value() {
12
10
  return ObservableScope.Value(this.scope);
@@ -53,10 +51,10 @@ exports.ObservableScope = ObservableScope;
53
51
  let watchState = null;
54
52
  function WatchScope(scope) {
55
53
  const parent = watchState;
56
- watchState = [distinctArray_1.DistinctArray.Create(emitter_1.Emitter.GetId), []];
54
+ watchState = [[], []];
57
55
  const value = scope.getFunction();
58
- const emitters = distinctArray_1.DistinctArray.Get(watchState[0]);
59
- emitters.sort(emitter_1.Emitter.Compare);
56
+ const emitters = watchState[0];
57
+ emitter_1.Emitter.Distinct(emitters);
60
58
  const result = [value, emitters, watchState[1]];
61
59
  watchState = parent;
62
60
  return result;
@@ -93,7 +91,7 @@ function CalcScope(callback) {
93
91
  function Register(emitter) {
94
92
  if (watchState === null)
95
93
  return;
96
- distinctArray_1.DistinctArray.Push(watchState[0], emitter);
94
+ watchState[0].push(emitter);
97
95
  }
98
96
  ObservableScope.Register = Register;
99
97
  function Init(scope) {
@@ -158,13 +156,11 @@ function CalcScope(callback) {
158
156
  function DirtyScope(scope) {
159
157
  if (scope.dirty || !scope.getFunction)
160
158
  return;
161
- observableNode_1.ObservableNode.BypassProxy(true);
162
159
  let dirty = scope.calcFunctions.length === 0;
163
160
  for (let x = 0; !dirty && x < scope.calcFunctions.length; x++) {
164
161
  const calc = scope.calcFunctions[x];
165
162
  dirty = dirty || calc.value !== calc.getFunction();
166
163
  }
167
- observableNode_1.ObservableNode.BypassProxy(false);
168
164
  scope.dirty = dirty;
169
165
  if (!scope.dirty)
170
166
  return;
@@ -178,8 +174,13 @@ let scopeQueue = [];
178
174
  function ProcessScopeQueue() {
179
175
  const scopes = scopeQueue;
180
176
  scopeQueue = [];
181
- for (let x = 0; x < scopes.length; x++)
182
- DirtyScope(scopes[x]);
177
+ const distinct = new Set();
178
+ for (let x = 0; x < scopes.length; x++) {
179
+ if (!distinct.has(scopes[x])) {
180
+ distinct.add(scopes[x]);
181
+ DirtyScope(scopes[x]);
182
+ }
183
+ }
183
184
  }
184
185
  function OnSet(scope) {
185
186
  if (scope.destroyed)
@@ -1,12 +1,10 @@
1
1
  export type DistinctArray<T> = {
2
- id: (value: T) => unknown;
3
- distinct: Set<unknown> | null;
2
+ id: (value: T) => number;
3
+ distinct: Array<true | undefined> | null;
4
4
  array: T[];
5
5
  };
6
6
  export declare namespace DistinctArray {
7
- function Create<T>(id?: (value: T) => unknown): DistinctArray<T>;
7
+ function Create<T>(id: (value: T) => number): DistinctArray<T>;
8
8
  function Push<T>(distinctArr: DistinctArray<T>, value: T): void;
9
9
  function Get<T>({ array }: DistinctArray<T>): T[];
10
- function Size<T>(distinct: DistinctArray<T>): number;
11
- function Clear<T>(distinct: DistinctArray<T>): void;
12
10
  }
@@ -3,31 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DistinctArray = void 0;
4
4
  var DistinctArray;
5
5
  (function (DistinctArray) {
6
- function Create(id = (val) => val) {
6
+ function Create(id) {
7
7
  return {
8
8
  id,
9
9
  distinct: null,
10
- array: [],
10
+ array: []
11
11
  };
12
12
  }
13
13
  DistinctArray.Create = Create;
14
14
  function Push(distinctArr, value) {
15
- switch (distinctArr.array.length) {
15
+ const { id, array } = distinctArr;
16
+ switch (array.length) {
16
17
  case 0:
17
- distinctArr.array.push(value);
18
+ array.push(value);
18
19
  break;
19
20
  case 1: {
20
21
  if (distinctArr.distinct === null) {
21
- distinctArr.distinct = new Set([
22
- distinctArr.id(distinctArr.array[0]),
23
- ]);
22
+ distinctArr.distinct = [];
23
+ distinctArr.distinct[id(array[0])] = true;
24
24
  }
25
25
  }
26
26
  default: {
27
- const vId = distinctArr.id(value);
28
- if (!distinctArr.distinct.has(vId)) {
29
- distinctArr.distinct.add(vId);
30
- distinctArr.array.push(value);
27
+ const vId = id(value);
28
+ if (distinctArr.distinct[vId] === undefined) {
29
+ distinctArr.distinct[vId] = true;
30
+ array.push(value);
31
31
  }
32
32
  }
33
33
  }
@@ -37,13 +37,4 @@ var DistinctArray;
37
37
  return array;
38
38
  }
39
39
  DistinctArray.Get = Get;
40
- function Size(distinct) {
41
- return distinct.distinct.size;
42
- }
43
- DistinctArray.Size = Size;
44
- function Clear(distinct) {
45
- distinct.array = [];
46
- distinct.distinct?.clear();
47
- }
48
- DistinctArray.Clear = Clear;
49
40
  })(DistinctArray || (exports.DistinctArray = DistinctArray = {}));
@@ -7,6 +7,7 @@ export declare namespace Emitter {
7
7
  function Emit(emitter: Emitter, ...args: any[]): void;
8
8
  function Remove(emitter: Emitter, callback: EmitterCallback): void;
9
9
  function Clear(emitter: Emitter): void;
10
+ function Distinct(emitters: Emitter[]): void;
10
11
  function Sort(emitters: Emitter[]): Emitter[];
11
12
  function Compare(a: Emitter, b: Emitter): number;
12
13
  }
package/Utils/emitter.js CHANGED
@@ -40,6 +40,41 @@ var Emitter;
40
40
  emitter.splice(1);
41
41
  }
42
42
  Emitter.Clear = Clear;
43
+ function Distinct(emitters) {
44
+ if (emitters.length === 1)
45
+ return;
46
+ emitters.length < 50 ? DistinctSmall(emitters) : DistinctLarge(emitters);
47
+ }
48
+ Emitter.Distinct = Distinct;
49
+ function DistinctSmall(emitters) {
50
+ Sort(emitters);
51
+ let lastId = -1;
52
+ let remove = false;
53
+ for (let x = 0; x < emitters.length; x++) {
54
+ const id = emitters[x][0];
55
+ if (lastId === emitters[x][0]) {
56
+ emitters[x] = null;
57
+ remove = true;
58
+ }
59
+ lastId = id;
60
+ }
61
+ remove && (0, array_1.RemoveNulls)(emitters);
62
+ }
63
+ function DistinctLarge(emitters) {
64
+ let remove = false;
65
+ const ids = new Set();
66
+ for (let x = 0; x < emitters.length; x++) {
67
+ const id = emitters[x][0];
68
+ if (!ids.has(id))
69
+ ids.add(id);
70
+ else {
71
+ emitters[x] = null;
72
+ remove = true;
73
+ }
74
+ }
75
+ remove && (0, array_1.RemoveNulls)(emitters);
76
+ Sort(emitters);
77
+ }
43
78
  function Sort(emitters) {
44
79
  return emitters.sort(Compare);
45
80
  }
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,9 +49,7 @@ function DoWork(ctx, deadline = createDeadline()) {
49
49
  threadContext = ctx;
50
50
  const async = ctx.async;
51
51
  let callback;
52
- while (async === ctx.async &&
53
- deadline.timeRemaining() > 0 &&
54
- (callback = list_1.List.Pop(ctx.workList)))
52
+ while (async === ctx.async && deadline.timeRemaining() > 0 && (callback = list_1.List.Pop(ctx.workList)))
55
53
  Invoke(ctx, callback);
56
54
  if (ctx.workList.size > 0)
57
55
  ScheduleWork(ctx);
@@ -61,7 +59,7 @@ function CreateContext() {
61
59
  return {
62
60
  async: false,
63
61
  workEndNode: null,
64
- workList: list_1.List.Create(),
62
+ workList: list_1.List.Create()
65
63
  };
66
64
  }
67
65
  function ScheduleCallback(callback, before, async) {
@@ -91,9 +89,7 @@ function After(callback) {
91
89
  }
92
90
  function Callback(callback) {
93
91
  return function (a, b, c, d) {
94
- Schedule(function () {
95
- callback(a, b, c, d);
96
- });
92
+ Schedule(function () { callback(a, b, c, d); });
97
93
  };
98
94
  }
99
95
  var inSynchCallback = false;
@@ -113,7 +109,7 @@ function Thread(callback) {
113
109
  Synch(callback);
114
110
  }
115
111
  function ThreadAsync(callback) {
116
- return new Promise((resolve) => Thread(function (async) {
112
+ return new Promise(resolve => Thread(function (async) {
117
113
  callback(async);
118
114
  Thread(resolve);
119
115
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.47",
3
+ "version": "7.0.49",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",