j-templates 7.0.74 → 7.0.76

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.
@@ -9,7 +9,7 @@ function CreatePropertyAssignment(target, property) {
9
9
  let childAssignment;
10
10
  return function (next) {
11
11
  const nextValue = next && next[property];
12
- if (nextValue === lastValue)
12
+ if (nextValue === lastValue || nextValue === undefined)
13
13
  return;
14
14
  jsonType ??= (0, json_1.JsonType)(nextValue);
15
15
  switch (jsonType) {
@@ -31,7 +31,7 @@ function CreateRootPropertyAssignment(target, property) {
31
31
  let childAssignment;
32
32
  return function (next) {
33
33
  const nextValue = next && next[property];
34
- if (nextValue === lastValue)
34
+ if (nextValue === lastValue || nextValue === undefined)
35
35
  return;
36
36
  switch (property) {
37
37
  case "nodeValue": {
@@ -67,11 +67,18 @@ function AssignNodeValue(target, value) {
67
67
  target.nodeValue = value;
68
68
  }
69
69
  function AssignValue(target, value) {
70
- const start = target.selectionStart;
71
- const end = target.selectionEnd;
72
- target.value = value;
73
- if (target.ownerDocument.activeElement === target)
74
- target.setSelectionRange(start, end);
70
+ switch (target.nodeName) {
71
+ case "INPUT": {
72
+ const start = target.selectionStart;
73
+ const end = target.selectionEnd;
74
+ target.value = value;
75
+ if (target.ownerDocument.activeElement === target)
76
+ target.setSelectionRange(start, end);
77
+ break;
78
+ }
79
+ default:
80
+ target.value = value;
81
+ }
75
82
  }
76
83
  function AssignClassName(target, value) {
77
84
  target.className = value;
package/DOM/elements.d.ts CHANGED
@@ -4,7 +4,7 @@ export declare const div: <T>(config: {
4
4
  [name: string]: string;
5
5
  }>;
6
6
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
7
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
7
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
8
8
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
9
9
  export declare const a: <T>(config: {
10
10
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -12,7 +12,7 @@ export declare const a: <T>(config: {
12
12
  [name: string]: string;
13
13
  }>;
14
14
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
15
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
15
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
16
16
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
17
17
  export declare const b: <T>(config: {
18
18
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -20,7 +20,7 @@ export declare const b: <T>(config: {
20
20
  [name: string]: string;
21
21
  }>;
22
22
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
23
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
23
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
24
24
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
25
25
  export declare const button: <T>(config: {
26
26
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLButtonElement>>;
@@ -28,7 +28,7 @@ export declare const button: <T>(config: {
28
28
  [name: string]: string;
29
29
  }>;
30
30
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
31
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
31
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
32
32
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
33
33
  export declare const h1: <T>(config: {
34
34
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -36,7 +36,7 @@ export declare const h1: <T>(config: {
36
36
  [name: string]: string;
37
37
  }>;
38
38
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
39
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
39
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
40
40
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
41
41
  export declare const h2: <T>(config: {
42
42
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -44,7 +44,7 @@ export declare const h2: <T>(config: {
44
44
  [name: string]: string;
45
45
  }>;
46
46
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
47
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
47
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
48
48
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
49
49
  export declare const h3: <T>(config: {
50
50
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -52,7 +52,7 @@ export declare const h3: <T>(config: {
52
52
  [name: string]: string;
53
53
  }>;
54
54
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
55
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
55
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
56
56
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
57
57
  export declare const input: <T>(config: {
58
58
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLInputElement>>;
@@ -60,7 +60,7 @@ export declare const input: <T>(config: {
60
60
  [name: string]: string;
61
61
  }>;
62
62
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
63
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
63
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
64
64
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
65
65
  export declare const textarea: <T>(config: {
66
66
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLTextAreaElement>>;
@@ -68,7 +68,7 @@ export declare const textarea: <T>(config: {
68
68
  [name: string]: string;
69
69
  }>;
70
70
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
71
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
71
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
72
72
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
73
73
  export declare const span: <T>(config: {
74
74
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -76,7 +76,7 @@ export declare const span: <T>(config: {
76
76
  [name: string]: string;
77
77
  }>;
78
78
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
79
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
79
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
80
80
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
81
81
  export declare const table: <T>(config: {
82
82
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -84,7 +84,7 @@ export declare const table: <T>(config: {
84
84
  [name: string]: string;
85
85
  }>;
86
86
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
87
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
87
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
88
88
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
89
89
  export declare const thead: <T>(config: {
90
90
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -92,7 +92,7 @@ export declare const thead: <T>(config: {
92
92
  [name: string]: string;
93
93
  }>;
94
94
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
95
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
95
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
96
96
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
97
97
  export declare const th: <T>(config: {
98
98
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -100,7 +100,7 @@ export declare const th: <T>(config: {
100
100
  [name: string]: string;
101
101
  }>;
102
102
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
103
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
103
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
104
104
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
105
105
  export declare const tbody: <T>(config: {
106
106
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -108,7 +108,7 @@ export declare const tbody: <T>(config: {
108
108
  [name: string]: string;
109
109
  }>;
110
110
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
111
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
111
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
112
112
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
113
113
  export declare const tr: <T>(config: {
114
114
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -116,7 +116,7 @@ export declare const tr: <T>(config: {
116
116
  [name: string]: string;
117
117
  }>;
118
118
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
119
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
119
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
120
120
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
121
121
  export declare const td: <T>(config: {
122
122
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -124,7 +124,7 @@ export declare const td: <T>(config: {
124
124
  [name: string]: string;
125
125
  }>;
126
126
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
127
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
127
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
128
128
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
129
129
  export declare const img: <T>(config: {
130
130
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLImageElement>>;
@@ -132,7 +132,7 @@ export declare const img: <T>(config: {
132
132
  [name: string]: string;
133
133
  }>;
134
134
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
135
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
135
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
136
136
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
137
137
  export declare const video: <T>(config: {
138
138
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLVideoElement>>;
@@ -140,7 +140,7 @@ export declare const video: <T>(config: {
140
140
  [name: string]: string;
141
141
  }>;
142
142
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
143
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
143
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
144
144
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
145
145
  export declare const select: <T>(config: {
146
146
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLSelectElement>>;
@@ -148,7 +148,7 @@ export declare const select: <T>(config: {
148
148
  [name: string]: string;
149
149
  }>;
150
150
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
151
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
151
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
152
152
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
153
153
  export declare const option: <T>(config: {
154
154
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLOptionElement>>;
@@ -156,7 +156,7 @@ export declare const option: <T>(config: {
156
156
  [name: string]: string;
157
157
  }>;
158
158
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
159
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
159
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
160
160
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
161
161
  export declare const aside: <T>(config: {
162
162
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -164,7 +164,7 @@ export declare const aside: <T>(config: {
164
164
  [name: string]: string;
165
165
  }>;
166
166
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
167
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
167
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
168
168
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
169
169
  export declare const p: <T>(config: {
170
170
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -172,7 +172,7 @@ export declare const p: <T>(config: {
172
172
  [name: string]: string;
173
173
  }>;
174
174
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
175
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
175
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
176
176
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
177
177
  export declare const label: <T>(config: {
178
178
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -180,7 +180,7 @@ export declare const label: <T>(config: {
180
180
  [name: string]: string;
181
181
  }>;
182
182
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
183
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
183
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
184
184
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
185
185
  export declare const pre: <T>(config: {
186
186
  props?: import("../Node/vNode.types").FunctionOr<import("../Utils/utils.types").RecursivePartial<HTMLElement>>;
@@ -188,6 +188,6 @@ export declare const pre: <T>(config: {
188
188
  [name: string]: string;
189
189
  }>;
190
190
  on?: import("../Node/vNode.types").FunctionOr<import("../Node/vNode.types").vNodeEvents<HTMLElementEventMap>>;
191
- data?: () => T | Array<T> | Promise<Array<T>> | Promise<T>;
191
+ data?: () => T | T[] | Promise<T[]> | Promise<T>;
192
192
  }, children?: import("../Node/vNode.types").vNode[] | import("../Node/vNode.types").vNodeChildrenFunction<T>) => import("../Node/vNode.types").vNode;
193
193
  export declare const text: (callback: () => string) => import("../Node/vNode.types").vNode;
package/DOM/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from "./elements";
2
+ export * from "./createPropertyAssignment";
3
+ export * from "./createEventAssignment";
package/DOM/index.js CHANGED
@@ -16,5 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./elements"), exports);
18
18
  // export * from "./svgElements";
19
- // export * from "./createPropertyAssignment";
20
- // export * from "./createEventAssignment";
19
+ __exportStar(require("./createPropertyAssignment"), exports);
20
+ __exportStar(require("./createEventAssignment"), exports);
package/Node/vNode.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vNode = void 0;
4
4
  const Store_1 = require("../Store");
5
5
  const observableScope_1 = require("../Store/Tree/observableScope");
6
+ const emitter_1 = require("../Utils/emitter");
6
7
  const functions_1 = require("../Utils/functions");
7
8
  const injector_1 = require("../Utils/injector");
8
9
  const thread_1 = require("../Utils/thread");
@@ -21,6 +22,7 @@ var vNode;
21
22
  node: definition.node ?? null,
22
23
  children: null,
23
24
  destroyed: false,
25
+ onDestroyed: null,
24
26
  component: null,
25
27
  scopes: [],
26
28
  };
@@ -34,6 +36,7 @@ var vNode;
34
36
  node: nodeConfig_1.NodeConfig.createTextNode(text),
35
37
  children: null,
36
38
  destroyed: false,
39
+ onDestroyed: null,
37
40
  component: null,
38
41
  scopes: [],
39
42
  };
@@ -56,6 +59,7 @@ var vNode;
56
59
  vnode.destroyed = true;
57
60
  vnode.component?.Destroy();
58
61
  Store_1.ObservableScope.DestroyAll(vnode.scopes);
62
+ vnode.onDestroyed && emitter_1.Emitter.Emit(vnode.onDestroyed);
59
63
  for (let x = 0; vnode.children && x < vnode.children.length; x++) {
60
64
  DestroyAll(vnode.children[x][1]);
61
65
  Store_1.ObservableScope.Destroy(vnode.children[x][2]);
@@ -2,6 +2,7 @@ import { Component } from "./component";
2
2
  import { IObservableScope } from "../Store/Tree/observableScope";
3
3
  import { Injector } from "../Utils/injector";
4
4
  import { RecursivePartial } from "../Utils/utils.types";
5
+ import { Emitter } from "../Utils/emitter";
5
6
  export type FunctionOr<T> = {
6
7
  (): T | Promise<T>;
7
8
  } | T;
@@ -20,6 +21,7 @@ export type vNode = {
20
21
  node: Node | null;
21
22
  children: [any, vNode[], IObservableScope<string | vNode | vNode[]> | null][] | null;
22
23
  destroyed: boolean;
24
+ onDestroyed: Emitter | null;
23
25
  scopes: IObservableScope<unknown>[];
24
26
  component: Component;
25
27
  };
@@ -1,18 +1,46 @@
1
1
  import { IDiffTree } from "./diffTree";
2
2
  import { JsonDiffResult } from "../../Utils/json";
3
+ /**
4
+ * Async version of IDiffTree interface with all methods returning promises.
5
+ */
3
6
  type IDiffTreeAsync = {
4
7
  [property in keyof IDiffTree]: (...args: Parameters<IDiffTree[property]>) => Promise<ReturnType<IDiffTree[property]>>;
5
8
  };
9
+ /**
10
+ * Asynchronous diff implementation using web workers.
11
+ * Offloads diff computation to a worker to prevent blocking the main thread.
12
+ *
13
+ * @see StoreAsync
14
+ * @see DiffSync
15
+ */
6
16
  export declare class DiffAsync implements IDiffTreeAsync {
7
17
  private workerQueue;
18
+ /**
19
+ * Creates a DiffAsync instance and initializes the worker.
20
+ * @param keyFunc - Optional function to extract a key from objects
21
+ */
8
22
  constructor(keyFunc?: {
9
23
  (val: any): string;
10
24
  });
25
+ /**
26
+ * Computes the diff between a new value and the current value at a path asynchronously.
27
+ * @param path - Dot-separated path to the value
28
+ * @param value - The new value to compare
29
+ * @returns Promise that resolves to diff results showing changes
30
+ */
11
31
  DiffPath(path: string, value: any): Promise<JsonDiffResult>;
32
+ /**
33
+ * Computes diffs for a batch of path/value pairs asynchronously.
34
+ * @param data - Array of objects with path and value properties
35
+ * @returns Promise that resolves to combined diff results
36
+ */
12
37
  DiffBatch(data: Array<{
13
38
  path: string;
14
39
  value: any;
15
40
  }>): Promise<JsonDiffResult>;
41
+ /**
42
+ * Destroys the DiffAsync instance and terminates the worker.
43
+ */
16
44
  Destroy(): void;
17
45
  }
18
46
  export {};
@@ -3,7 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DiffAsync = void 0;
4
4
  const workerQueue_1 = require("./workerQueue");
5
5
  const diffWorker_1 = require("./diffWorker");
6
+ /**
7
+ * Asynchronous diff implementation using web workers.
8
+ * Offloads diff computation to a worker to prevent blocking the main thread.
9
+ *
10
+ * @see StoreAsync
11
+ * @see DiffSync
12
+ */
6
13
  class DiffAsync {
14
+ /**
15
+ * Creates a DiffAsync instance and initializes the worker.
16
+ * @param keyFunc - Optional function to extract a key from objects
17
+ */
7
18
  constructor(keyFunc) {
8
19
  this.workerQueue = new workerQueue_1.WorkerQueue(diffWorker_1.DiffWorker.Create());
9
20
  this.workerQueue.Push({
@@ -11,18 +22,32 @@ class DiffAsync {
11
22
  arguments: keyFunc ? [keyFunc.toString()] : [],
12
23
  });
13
24
  }
25
+ /**
26
+ * Computes the diff between a new value and the current value at a path asynchronously.
27
+ * @param path - Dot-separated path to the value
28
+ * @param value - The new value to compare
29
+ * @returns Promise that resolves to diff results showing changes
30
+ */
14
31
  async DiffPath(path, value) {
15
32
  return await this.workerQueue.Push({
16
33
  method: "diffpath",
17
34
  arguments: [path, value],
18
35
  });
19
36
  }
37
+ /**
38
+ * Computes diffs for a batch of path/value pairs asynchronously.
39
+ * @param data - Array of objects with path and value properties
40
+ * @returns Promise that resolves to combined diff results
41
+ */
20
42
  async DiffBatch(data) {
21
43
  return await this.workerQueue.Push({
22
44
  method: "diffbatch",
23
45
  arguments: [data],
24
46
  });
25
47
  }
48
+ /**
49
+ * Destroys the DiffAsync instance and terminates the worker.
50
+ */
26
51
  Destroy() {
27
52
  this.workerQueue.Destroy();
28
53
  }
@@ -1,10 +1,32 @@
1
1
  import { IDiffTree } from "./diffTree";
2
+ /**
3
+ * Synchronous diff implementation.
4
+ * Computes diffs immediately without queuing or workers.
5
+ *
6
+ * @see StoreSync
7
+ * @see DiffAsync
8
+ */
2
9
  export declare class DiffSync implements IDiffTree {
3
10
  private diffTree;
11
+ /**
12
+ * Creates a DiffSync instance.
13
+ * @param keyFunc - Optional function to extract a key from objects
14
+ */
4
15
  constructor(keyFunc?: {
5
16
  (val: any): string;
6
17
  });
18
+ /**
19
+ * Computes the diff between a new value and the current value at a path.
20
+ * @param path - Dot-separated path to the value
21
+ * @param value - The new value to compare
22
+ * @returns Diff results showing changes
23
+ */
7
24
  DiffPath(path: string, value: any): import("../../Utils/json").JsonDiffResult;
25
+ /**
26
+ * Computes diffs for a batch of path/value pairs.
27
+ * @param data - Array of objects with path and value properties
28
+ * @returns Combined diff results
29
+ */
8
30
  DiffBatch(data: Array<{
9
31
  path: string;
10
32
  value: any;
@@ -4,13 +4,35 @@ exports.DiffSync = void 0;
4
4
  const json_1 = require("../../Utils/json");
5
5
  const diffTree_1 = require("./diffTree");
6
6
  const diffCnstr = (0, diffTree_1.DiffTreeFactory)(json_1.JsonDiffFactory);
7
+ /**
8
+ * Synchronous diff implementation.
9
+ * Computes diffs immediately without queuing or workers.
10
+ *
11
+ * @see StoreSync
12
+ * @see DiffAsync
13
+ */
7
14
  class DiffSync {
15
+ /**
16
+ * Creates a DiffSync instance.
17
+ * @param keyFunc - Optional function to extract a key from objects
18
+ */
8
19
  constructor(keyFunc) {
9
20
  this.diffTree = new diffCnstr(keyFunc);
10
21
  }
22
+ /**
23
+ * Computes the diff between a new value and the current value at a path.
24
+ * @param path - Dot-separated path to the value
25
+ * @param value - The new value to compare
26
+ * @returns Diff results showing changes
27
+ */
11
28
  DiffPath(path, value) {
12
29
  return this.diffTree.DiffPath(path, value);
13
30
  }
31
+ /**
32
+ * Computes diffs for a batch of path/value pairs.
33
+ * @param data - Array of objects with path and value properties
34
+ * @returns Combined diff results
35
+ */
14
36
  DiffBatch(data) {
15
37
  return this.diffTree.DiffBatch(data);
16
38
  }
@@ -1,18 +1,51 @@
1
1
  import { JsonDiffFactoryResult, JsonDiffResult } from "../../Utils/json";
2
+ /**
3
+ * Represents a method call for worker-based diff operations.
4
+ */
2
5
  export interface IDiffMethod {
6
+ /** The method to call */
3
7
  method: "create" | "diffpath" | "diffbatch" | "updatepath" | "getpath";
8
+ /** Arguments for the method call */
4
9
  arguments: Array<any>;
5
10
  }
11
+ /**
12
+ * Interface for diff tree operations.
13
+ */
6
14
  export interface IDiffTree {
15
+ /**
16
+ * Computes diffs for a batch of path/value pairs.
17
+ * @param data - Array of objects with path and value properties
18
+ * @returns Combined diff results
19
+ */
7
20
  DiffBatch(data: Array<{
8
21
  path: string;
9
22
  value: any;
10
23
  }>): JsonDiffResult;
24
+ /**
25
+ * Computes the diff between a new value and the current value at a path.
26
+ * @param path - Dot-separated path to the value
27
+ * @param value - The new value to compare
28
+ * @returns Diff results showing changes
29
+ */
11
30
  DiffPath(path: string, value: any): JsonDiffResult;
12
31
  }
32
+ /**
33
+ * Constructor interface for IDiffTree.
34
+ */
13
35
  export interface IDiffTreeConstructor {
36
+ /**
37
+ * Creates a new IDiffTree instance.
38
+ * @param keyFunc - Optional function to extract a key from a value
39
+ */
14
40
  new (keyFunc?: {
15
41
  (val: any): string;
16
42
  }): IDiffTree;
17
43
  }
44
+ /**
45
+ * Factory function that creates a DiffTree class.
46
+ * Can operate in worker mode for async operations.
47
+ * @param jsonDiffFactory - Optional factory for JSON diff utilities
48
+ * @param worker - If true, sets up worker message handling
49
+ * @returns DiffTree constructor
50
+ */
18
51
  export declare function DiffTreeFactory(jsonDiffFactory?: () => JsonDiffFactoryResult, worker?: boolean): IDiffTreeConstructor;