j-templates 7.0.89 → 7.0.91

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.
@@ -1,3 +1,6 @@
1
+ export declare function Assignment(target: any, next: any, assignment: {
2
+ (target: any, key: string, value: any): void;
3
+ }): void;
1
4
  export declare function CreateAssignment(target: any, createAssignment: {
2
5
  (target: any, key: string): (next: any) => void;
3
6
  }): (next: any) => void;
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Assignment = Assignment;
3
4
  exports.CreateAssignment = CreateAssignment;
4
5
  const DEFAULT_ASSIGNMENT = {};
6
+ function Assignment(target, next, assignment) {
7
+ for (const key in next) {
8
+ assignment(target, key, next[key]);
9
+ }
10
+ }
5
11
  function CreateAssignment(target, createAssignment) {
6
12
  let last;
7
13
  let writeTo = {};
@@ -1 +1,2 @@
1
+ export declare function AttributeAssignment(target: HTMLElement, attribute: string, next: any): void;
1
2
  export declare function CreateAttributeAssignment(target: HTMLElement, attribute: string): (next: any) => void;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttributeAssignment = AttributeAssignment;
3
4
  exports.CreateAttributeAssignment = CreateAttributeAssignment;
5
+ function AttributeAssignment(target, attribute, next) {
6
+ target.setAttribute(attribute, next);
7
+ }
4
8
  function CreateAttributeAssignment(target, attribute) {
5
9
  let lastValue;
6
10
  return function (next) {
@@ -1 +1,2 @@
1
+ export declare function EventAssignment(target: HTMLElement, event: string, next: any): void;
1
2
  export declare function CreateEventAssignment(target: HTMLElement, event: string): (next: any) => void;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventAssignment = EventAssignment;
3
4
  exports.CreateEventAssignment = CreateEventAssignment;
5
+ function EventAssignment(target, event, next) {
6
+ target.addEventListener(event, next);
7
+ }
4
8
  function CreateEventAssignment(target, event) {
5
9
  let lastEvent;
6
10
  return function (next) {
@@ -1 +1,2 @@
1
+ export declare function PropertyAssignment(target: HTMLElement, property: string, next: any): void;
1
2
  export declare function CreateRootPropertyAssignment(target: HTMLElement, property: string): (next: any) => void;
@@ -1,8 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropertyAssignment = PropertyAssignment;
3
4
  exports.CreateRootPropertyAssignment = CreateRootPropertyAssignment;
4
5
  const json_1 = require("../Utils/json");
5
6
  const createAssignment_1 = require("./createAssignment");
7
+ function PropertyAssignment(target, property, next) {
8
+ switch (property) {
9
+ case "nodeValue": {
10
+ AssignNodeValue(target, next);
11
+ break;
12
+ }
13
+ case "className": {
14
+ AssignClassName(target, next);
15
+ break;
16
+ }
17
+ case "value": {
18
+ AssignValue(target, next);
19
+ break;
20
+ }
21
+ default: {
22
+ const jsonType = (0, json_1.JsonType)(next);
23
+ switch (jsonType) {
24
+ case "value":
25
+ target[property] = next;
26
+ break;
27
+ default: {
28
+ const childTarget = target[property];
29
+ (0, createAssignment_1.Assignment)(childTarget, next, PropertyAssignment);
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
6
35
  function CreatePropertyAssignment(target, property) {
7
36
  let lastValue;
8
37
  let jsonType;
@@ -119,12 +119,21 @@ exports.DOMNodeConfig = {
119
119
  setAttribute(target, attribute, value) {
120
120
  target.setAttribute(attribute, value);
121
121
  },
122
+ propertyAssignment(target, next) {
123
+ (0, createAssignment_1.Assignment)(target, next, createPropertyAssignment_1.PropertyAssignment);
124
+ },
122
125
  createPropertyAssignment(target) {
123
126
  return (0, createAssignment_1.CreateAssignment)(target, createPropertyAssignment_1.CreateRootPropertyAssignment);
124
127
  },
128
+ eventAssignment(target, next) {
129
+ (0, createAssignment_1.Assignment)(target, next, createEventAssignment_1.EventAssignment);
130
+ },
125
131
  createEventAssignment(target) {
126
132
  return (0, createAssignment_1.CreateAssignment)(target, createEventAssignment_1.CreateEventAssignment);
127
133
  },
134
+ attributeAssignment(target, next) {
135
+ (0, createAssignment_1.Assignment)(target, next, createAttributeAssignment_1.AttributeAssignment);
136
+ },
128
137
  createAttributeAssignment(target) {
129
138
  return (0, createAssignment_1.CreateAssignment)(target, createAttributeAssignment_1.CreateAttributeAssignment);
130
139
  },
@@ -145,42 +154,47 @@ exports.DOMNodeConfig = {
145
154
  target.replaceChildren(...children);
146
155
  },
147
156
  reconcileChildren(target, children) {
148
- if (!target.firstChild) {
157
+ if (!target.hasChildNodes()) {
149
158
  for (let x = 0; x < children.length; x++) {
150
- const child = getHTMLNode(children[x]);
151
- target.appendChild(child);
159
+ const nextChild = getHTMLNode(children[x], null);
160
+ target.appendChild(nextChild);
152
161
  }
153
162
  return;
154
163
  }
155
- if (children.length === 0) {
156
- target.replaceChildren();
157
- return;
158
- }
159
- let actualNode = target.firstChild;
160
- let x = 0;
161
- let removed = false;
162
- for (; actualNode && x < children.length; x++) {
163
- const child = children[x];
164
- let expectedNode = getHTMLNode(child, actualNode);
165
- if (!removed && actualNode !== expectedNode) {
166
- const remove = actualNode;
167
- actualNode = actualNode.nextSibling;
168
- target.removeChild(remove);
169
- removed = true;
170
- }
171
- if (actualNode !== expectedNode) {
172
- target.insertBefore(expectedNode, actualNode);
173
- }
174
- else {
175
- actualNode = actualNode.nextSibling;
176
- removed = false;
164
+ let lastChild = null;
165
+ switch (children.length) {
166
+ case 0:
167
+ target.replaceChildren();
168
+ break;
169
+ case 1:
170
+ lastChild = getHTMLNode(children[0], target.firstChild);
171
+ if (target.firstChild !== lastChild)
172
+ target.insertBefore(lastChild, target.firstChild);
173
+ break;
174
+ default: {
175
+ let currentChild = target.firstChild;
176
+ let inNextChildren = false;
177
+ for (let x = 0; x < children.length; x++) {
178
+ const nextChild = (lastChild = getHTMLNode(children[x], currentChild));
179
+ if (!currentChild)
180
+ target.appendChild(nextChild);
181
+ else if (nextChild !== currentChild) {
182
+ while (currentChild && (!(inNextChildren = inNextChildren || children.indexOf(currentChild, x + 1) >= 0))) {
183
+ const toRemove = currentChild;
184
+ currentChild = currentChild.nextSibling;
185
+ target.removeChild(toRemove);
186
+ }
187
+ nextChild !== currentChild &&
188
+ target.insertBefore(nextChild, currentChild);
189
+ }
190
+ else
191
+ inNextChildren = false;
192
+ currentChild = nextChild.nextSibling;
193
+ }
194
+ break;
177
195
  }
178
196
  }
179
- while (target.lastChild && target.lastChild !== children[x - 1])
197
+ while (target.lastChild !== lastChild)
180
198
  target.removeChild(target.lastChild);
181
- for (; x < children.length; x++) {
182
- const child = getHTMLNode(children[x]);
183
- target.appendChild(child);
184
- }
185
- },
199
+ }
186
200
  };
package/Node/component.js CHANGED
@@ -57,6 +57,8 @@ class Component {
57
57
  this.scope = {
58
58
  type: "static",
59
59
  value: data,
60
+ destroyed: false,
61
+ onDestroyed: null
60
62
  };
61
63
  this.componentEvents = on;
62
64
  this.templates = templates || {};
@@ -21,14 +21,17 @@ export interface INodeConfig {
21
21
  removeChild(root: any, child: any): void;
22
22
  remove(target: any): void;
23
23
  fireEvent(target: any, event: string, data: any): void;
24
+ propertyAssignment(target: any, next: any): void;
24
25
  createPropertyAssignment(target: any): {
25
26
  (next: any): void;
26
27
  };
28
+ eventAssignment(target: any, next: any): void;
27
29
  createEventAssignment(target: any): {
28
30
  (next: {
29
31
  [event: string]: (event: Event) => void;
30
32
  }): void;
31
33
  };
34
+ attributeAssignment(target: any, next: any): void;
32
35
  createAttributeAssignment(target: any): {
33
36
  (next: {
34
37
  [attribute: string]: string;
package/Node/vNode.js CHANGED
@@ -61,10 +61,7 @@ var vNode;
61
61
  vnode.component?.Destroy();
62
62
  Store_1.ObservableScope.DestroyAll(vnode.scopes);
63
63
  vnode.onDestroyed && emitter_1.Emitter.Emit(vnode.onDestroyed);
64
- for (let x = 0; vnode.children && x < vnode.children.length; x++) {
65
- DestroyAll(vnode.children[x][1]);
66
- Store_1.ObservableScope.Destroy(vnode.children[x][2]);
67
- }
64
+ vnode.children && DestroyAll(vnode.children);
68
65
  }
69
66
  vNode.Destroy = Destroy;
70
67
  function DestroyAll(vnodes) {
@@ -94,54 +91,54 @@ var vNode;
94
91
  }
95
92
  vNode.Attach = Attach;
96
93
  })(vNode || (exports.vNode = vNode = {}));
94
+ function ComponentChildren() {
95
+ return this.Template();
96
+ }
97
97
  function InitNode(vnode) {
98
98
  const { type, namespace, props, attrs, on, data, componentFactory, children, childrenArray, } = vnode.definition;
99
99
  const node = (vnode.node =
100
100
  vnode.definition.node ?? nodeConfig_1.NodeConfig.createNode(type, namespace));
101
101
  vnode.definition = null;
102
102
  if (props) {
103
- const assignProperties = nodeConfig_1.NodeConfig.createPropertyAssignment(node);
104
103
  if (typeof props === "function") {
104
+ const assignProperties = nodeConfig_1.NodeConfig.createPropertyAssignment(node);
105
105
  const scope = Store_1.ObservableScope.Create(props);
106
106
  vnode.scopes.push(scope);
107
107
  Store_1.ObservableScope.Watch(scope, ScheduledAssignment(assignProperties));
108
108
  assignProperties(Store_1.ObservableScope.Value(scope));
109
109
  }
110
110
  else
111
- assignProperties(props);
111
+ nodeConfig_1.NodeConfig.propertyAssignment(node, props);
112
112
  }
113
113
  if (on) {
114
- const assignEvents = nodeConfig_1.NodeConfig.createEventAssignment(node);
115
114
  if (typeof on === "function") {
115
+ const assignEvents = nodeConfig_1.NodeConfig.createEventAssignment(node);
116
116
  const scope = Store_1.ObservableScope.Create(on);
117
117
  vnode.scopes.push(scope);
118
118
  Store_1.ObservableScope.Watch(scope, ScheduledAssignment(assignEvents));
119
119
  assignEvents(Store_1.ObservableScope.Value(scope));
120
120
  }
121
121
  else
122
- assignEvents(on);
122
+ nodeConfig_1.NodeConfig.eventAssignment(node, on);
123
123
  }
124
124
  if (attrs) {
125
- const assignAttributes = nodeConfig_1.NodeConfig.createAttributeAssignment(node);
126
125
  if (typeof attrs === "function") {
126
+ const assignAttributes = nodeConfig_1.NodeConfig.createAttributeAssignment(node);
127
127
  const scope = Store_1.ObservableScope.Create(attrs);
128
128
  vnode.scopes.push(scope);
129
129
  Store_1.ObservableScope.Watch(scope, ScheduledAssignment(assignAttributes));
130
130
  assignAttributes(Store_1.ObservableScope.Value(scope));
131
131
  }
132
132
  else
133
- assignAttributes(attrs);
133
+ nodeConfig_1.NodeConfig.attributeAssignment(node, attrs);
134
134
  }
135
135
  if (componentFactory) {
136
136
  vnode.component = componentFactory(vnode);
137
137
  vnode.component.Bound();
138
- function componentChildren() {
139
- return vnode.component.Template();
140
- }
141
- Children(vnode, componentChildren, DefaultData);
138
+ Children(vnode, ComponentChildren.bind(vnode.component));
142
139
  }
143
140
  else if (childrenArray) {
144
- vnode.children = [[undefined, childrenArray, null]];
141
+ vnode.children = childrenArray;
145
142
  vNode.InitAll(childrenArray);
146
143
  }
147
144
  else if (children) {
@@ -151,26 +148,22 @@ function InitNode(vnode) {
151
148
  }
152
149
  function Children(vnode, children, data) {
153
150
  const childrenScope = CreateChildrenScope(vnode, children, data);
154
- if (childrenScope) {
155
- vnode.scopes.push(childrenScope);
156
- Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function (scope) {
157
- if (vnode.destroyed)
158
- return;
159
- const startChildren = vnode.children;
160
- const newChildren = Store_1.ObservableScope.Value(scope);
161
- if (startChildren !== newChildren) {
162
- vnode.children = newChildren;
163
- UpdateChildren(vnode);
164
- }
165
- }));
166
- }
151
+ vnode.scopes.push(childrenScope);
152
+ Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function (scope) {
153
+ if (vnode.destroyed)
154
+ return;
155
+ vnode.children = Store_1.ObservableScope.Value(scope);
156
+ UpdateChildren(vnode);
157
+ }));
167
158
  vnode.children = Store_1.ObservableScope.Value(childrenScope);
168
159
  }
169
- const DEFAULT_DATA = [undefined];
170
- function DefaultData() {
171
- return DEFAULT_DATA;
172
- }
173
- function CreateChildrenScope(vnode, children, data = DefaultData) {
160
+ function CreateChildrenScope(vnode, children, data) {
161
+ if (data === undefined) {
162
+ const scope = Store_1.ObservableScope.Create(GetNextNodesAsArray.bind(null, vnode.injector, children));
163
+ Store_1.ObservableScope.OnUpdated(scope, DestroyScopedVNodes);
164
+ Store_1.ObservableScope.OnDestroyed(scope, DestroyScopedVNodes);
165
+ return scope;
166
+ }
174
167
  if ((0, functions_1.IsAsync)(data)) {
175
168
  const asyncData = data;
176
169
  data = function () {
@@ -179,35 +172,27 @@ function CreateChildrenScope(vnode, children, data = DefaultData) {
179
172
  });
180
173
  };
181
174
  }
182
- return Store_1.ObservableScope.Create(WrapChildren(vnode.injector, children, data));
175
+ return Store_1.ObservableScope.Create(DynamicChildrenFunction.bind(null, vnode.injector, children, data));
183
176
  }
184
- function WrapChildren(injector, children, data) {
185
- let nodeArray;
186
- return function () {
187
- const nextData = data === DefaultData ? data() : ToArray(data());
188
- switch (nextData.length) {
189
- case 0: {
190
- if (nodeArray !== undefined) {
191
- for (let x = 0; x < nodeArray.length; x++) {
192
- vNode.DestroyAll(nodeArray[x][1]);
193
- Store_1.ObservableScope.Destroy(nodeArray[x][2]);
194
- }
195
- nodeArray = [];
196
- }
197
- break;
198
- }
199
- default: {
200
- if (nodeArray === undefined)
201
- nodeArray = InitializeNextNodes(injector, children, nextData);
202
- else if (nodeArray.length < 11)
203
- nodeArray = EvaluateNextNodesSmall(injector, children, nextData, nodeArray);
204
- else
205
- nodeArray = EvaluateNextNodesLarge(injector, children, nextData, nodeArray);
206
- break;
207
- }
208
- }
209
- return nodeArray;
210
- };
177
+ function GetNextNodes(injector, children, data) {
178
+ return ToVNodeType(injector_1.Injector.Scope(injector, children, data));
179
+ }
180
+ function GetNextNodesAsArray(injector, children, data) {
181
+ const nodes = GetNextNodes(injector, children, data);
182
+ return ToArray(nodes);
183
+ }
184
+ function DestroyScopedVNodes(value) {
185
+ Array.isArray(value) ? vNode.DestroyAll(value) : vNode.Destroy(value);
186
+ }
187
+ function DynamicChildrenFunction(injector, children, data) {
188
+ const nextData = ToArray(data());
189
+ const getNextNodes = GetNextNodes.bind(null, injector, children);
190
+ let results = new Array(nextData.length);
191
+ for (let x = 0; x < nextData.length; x++) {
192
+ const nodes = (0, observableScope_1.MappedScope)(nextData[x], getNextNodes, DestroyScopedVNodes, DestroyScopedVNodes);
193
+ results[x] = nodes;
194
+ }
195
+ return results.flat();
211
196
  }
212
197
  function ToArray(result) {
213
198
  if (!result)
@@ -216,124 +201,40 @@ function ToArray(result) {
216
201
  return result;
217
202
  return [result];
218
203
  }
219
- function GetNextNodeRow(data, injector, getNextChildren, scope) {
220
- scope ??=
221
- data === undefined
222
- ? null
223
- : Store_1.ObservableScope.Create(function () {
224
- const children = injector_1.Injector.Scope(injector, getNextChildren, data);
225
- return CreateNodeArray(children);
226
- });
227
- const children = scope === null
228
- ? CreateNodeArray(injector_1.Injector.Scope(injector, getNextChildren, undefined))
229
- : Store_1.ObservableScope.Value(scope);
230
- return [data, children, scope];
231
- }
232
- function InitializeNextNodes(injector, getNextChildren, nextData) {
233
- const nextNodes = new Array(nextData.length);
234
- for (let x = 0; x < nextData.length; x++) {
235
- const data = nextData[x];
236
- nextNodes[x] = GetNextNodeRow(data, injector, getNextChildren);
237
- }
238
- return nextNodes;
239
- }
240
- function GetNextNodeRowSmall(injector, getNextChildren, nodeArray, data) {
241
- let i = 0;
242
- for (; i < nodeArray.length && (nodeArray[i] === null || nodeArray[i][0] !== data); i++) { }
243
- if (i === nodeArray.length)
244
- return GetNextNodeRow(data, injector, getNextChildren);
245
- const nextNodeRow = GetNextNodeRow(data, injector, getNextChildren, nodeArray[i][2]);
246
- if (nodeArray[i][1] !== nextNodeRow[1])
247
- vNode.DestroyAll(nodeArray[i][1]);
248
- nodeArray[i] = null;
249
- return nextNodeRow;
250
- }
251
- function EvaluateNextNodesSmall(injector, getNextChildren, nextData, nodeArray) {
252
- const nextNodes = new Array(nextData.length);
253
- for (let x = 0; x < nextData.length; x++)
254
- nextNodes[x] = GetNextNodeRowSmall(injector, getNextChildren, nodeArray, nextData[x]);
255
- return nextNodes;
256
- }
257
- function GetNextNodeRowLarge(injector, getNextChildren, nodeRowMap, data) {
258
- const currentChildren = nodeRowMap.get(data);
259
- let currentChildIndex = currentChildren ? currentChildren.length - 1 : -1;
260
- for (; currentChildIndex >= 0 && currentChildren[currentChildIndex] === null; currentChildIndex--) { }
261
- if (currentChildIndex >= 0) {
262
- const nodeRow = currentChildren[currentChildIndex];
263
- if (currentChildIndex === 0)
264
- nodeRowMap.delete(data);
265
- else
266
- currentChildren[currentChildIndex] = null;
267
- const nextNodeRow = GetNextNodeRow(data, injector, getNextChildren, nodeRow[2]);
268
- if (nodeRow[1] !== nextNodeRow[1])
269
- vNode.DestroyAll(nodeRow[1]);
270
- return nextNodeRow;
271
- }
272
- return GetNextNodeRow(data, injector, getNextChildren);
273
- }
274
- function EvaluateNextNodesLarge(injector, getNextChildren, nextData, nodeArray) {
275
- const nextNodes = new Array(nextData.length);
276
- const dataMap = new Map();
277
- for (let x = 0; x < nodeArray.length; x++) {
278
- const arr = dataMap.get(nodeArray[x][0]) ?? [];
279
- arr.push(nodeArray[x]);
280
- dataMap.set(nodeArray[x][0], arr);
281
- }
282
- for (let x = 0; x < nextData.length; x++) {
283
- nextNodes[x] = GetNextNodeRowLarge(injector, getNextChildren, dataMap, nextData[x]);
284
- }
285
- for (const value of dataMap.values()) {
286
- for (let x = 0; x < value.length; x++) {
287
- const row = value[x];
288
- row && vNode.DestroyAll(row[1]);
289
- row && Store_1.ObservableScope.Destroy(row[2]);
290
- }
291
- }
292
- return nextNodes;
204
+ function ToVNodeType(children) {
205
+ return typeof children === "string" ? { type: "string", node: children } : children;
293
206
  }
294
- function CreateNodeArray(children) {
295
- if (!Array.isArray(children)) {
296
- return typeof children === "string"
297
- ? [{ type: "string", node: children }]
298
- : [children];
299
- }
300
- return children;
207
+ function GetNode(vnode) {
208
+ return vnode.node;
301
209
  }
302
210
  function UpdateChildren(vnode, init = false, skipInit = false) {
303
211
  if (!vnode.children)
304
212
  return;
305
- if (vnode.children.length === 1 &&
306
- vnode.children[0][1].length === 1 &&
307
- vnode.children[0][1][0].node) {
308
- nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, vnode.children.flatMap((row) => row[1].map((vnode) => vnode.node)));
309
- return;
310
- }
311
213
  const children = vnode.children;
312
214
  (0, thread_1.Thread)(function () {
313
215
  if (vnode.destroyed || children !== vnode.children)
314
216
  return;
315
- for (let x = 0; !skipInit && x < children.length; x++)
316
- for (let y = 0; y < children[x][1].length; y++) {
317
- const childNode = children[x][1][y];
318
- if (!(0, vNode_types_1.isStringNode)(childNode) && childNode.definition) {
319
- (0, thread_1.Schedule)(function () {
320
- if (vnode.destroyed || children !== vnode.children)
321
- return;
322
- vNode.Init(childNode);
323
- });
324
- }
217
+ for (let x = 0; !skipInit && x < children.length; x++) {
218
+ const childNode = children[x];
219
+ if (!(0, vNode_types_1.isStringNode)(childNode) && childNode.definition) {
220
+ (0, thread_1.Schedule)(function () {
221
+ if (vnode.destroyed || children !== vnode.children)
222
+ return;
223
+ vNode.Init(childNode);
224
+ });
325
225
  }
226
+ }
326
227
  (0, thread_1.Thread)(function (async) {
327
228
  if (vnode.destroyed || children !== vnode.children)
328
229
  return;
329
230
  if (init || !async) {
330
- nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, vnode.children.flatMap((row) => row[1].map((vnode) => vnode.node)));
231
+ nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, vnode.children.map(GetNode));
331
232
  }
332
233
  else
333
234
  nodeConfig_1.NodeConfig.scheduleUpdate(function () {
334
235
  if (vnode.destroyed || children !== vnode.children)
335
236
  return;
336
- nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, vnode.children.flatMap((row) => row[1].map((vnode) => vnode.node)));
237
+ nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, vnode.children.map(GetNode));
337
238
  });
338
239
  });
339
240
  });
@@ -23,11 +23,7 @@ export type vElementNode = {
23
23
  definition: vNodeDefinition<any, any, any>;
24
24
  injector: Injector;
25
25
  node: Node | null;
26
- children: (readonly [
27
- any,
28
- vNode[],
29
- IObservableScope<string | vNode | vNode[]> | null
30
- ])[] | null;
26
+ children: vNode[];
31
27
  destroyed: boolean;
32
28
  onDestroyed: Emitter | null;
33
29
  scopes: IObservableScope<unknown>[];
@@ -26,7 +26,7 @@ class Store {
26
26
  const rootObject = this.rootMap.get(key);
27
27
  if (rootObject === undefined)
28
28
  throw `No root object found for key: ${key}`;
29
- const rootValue = rootObject[observableNode_1.GET_OBSERVABLE_VALUE];
29
+ const rootValue = observableNode_1.ObservableNode.Unwrap(rootObject); // rootObject[GET_OBSERVABLE_VALUE];
30
30
  const alias = rootValue[key];
31
31
  return alias;
32
32
  });
@@ -118,7 +118,7 @@ class StoreAsync extends store_1.Store {
118
118
  async Splice(key, start, deleteCount, ...items) {
119
119
  return await this.queue.Next(async () => {
120
120
  const arr = this.Get(key);
121
- const arrValue = arr[observableNode_1.GET_OBSERVABLE_VALUE];
121
+ const arrValue = observableNode_1.ObservableNode.Unwrap(arr); // (arr as any)[GET_OBSERVABLE_VALUE] as any[];
122
122
  const arrCopy = arrValue.slice();
123
123
  const spliceResult = (0, json_1.JsonDeepClone)(arrCopy.splice(start, deleteCount, ...items));
124
124
  const diffResult = await this.diff.DiffPath(key, arrCopy);
@@ -49,7 +49,7 @@ class StoreSync extends store_1.Store {
49
49
  * @throws Will throw an error if no key is provided for the data.
50
50
  */
51
51
  Write(data, key) {
52
- data = (0, json_1.JsonDeepClone)(data);
52
+ // data = JsonDeepClone(data);
53
53
  key = key || this.keyFunc?.(data);
54
54
  if (!key)
55
55
  throw "No key provided for data";
@@ -66,7 +66,7 @@ class StoreSync extends store_1.Store {
66
66
  const value = this.Get(key);
67
67
  if (value === undefined)
68
68
  throw "Unable to patch undefined value";
69
- const json = value.toJSON();
69
+ const json = observableNode_1.ObservableNode.Unwrap(value);
70
70
  const mergedJson = (0, json_1.JsonMerge)(json, patch);
71
71
  const diffResult = this.diff.DiffPath(key, mergedJson);
72
72
  this.UpdateRootMap(diffResult);
@@ -98,7 +98,7 @@ class StoreSync extends store_1.Store {
98
98
  */
99
99
  Splice(key, start, deleteCount, ...items) {
100
100
  const arr = this.Get(key);
101
- const arrValue = arr[observableNode_1.GET_OBSERVABLE_VALUE];
101
+ const arrValue = observableNode_1.ObservableNode.Unwrap(arr); // (arr as any)[GET_OBSERVABLE_VALUE] as any[];
102
102
  const arrCopy = arrValue.slice();
103
103
  const spliceResult = (0, json_1.JsonDeepClone)(arrCopy.splice(start, deleteCount, ...items));
104
104
  const diffResult = this.diff.DiffPath(key, arrCopy);
@@ -1,19 +1,4 @@
1
1
  import { JsonDiffResult } from "../../Utils/json";
2
- /**
3
- * Symbol to identify observable nodes.
4
- * Used to check if a value is an observable node proxy.
5
- */
6
- export declare const IS_OBSERVABLE_NODE: unique symbol;
7
- /**
8
- * Symbol to get the raw underlying value from an observable node.
9
- * Returns the unwrapped, non-proxied value.
10
- */
11
- export declare const GET_OBSERVABLE_VALUE: unique symbol;
12
- /**
13
- * Symbol for the toJSON method on observable nodes.
14
- * Used to serialize observable nodes to plain JSON.
15
- */
16
- export declare const GET_TO_JSON: unique symbol;
17
2
  export declare namespace ObservableNode {
18
3
  /**
19
4
  * Unwraps an observable node to get the raw underlying value.
@@ -38,6 +23,7 @@ export declare namespace ObservableNode {
38
23
  * @param prop Optional property name or index to touch a specific nested property.
39
24
  */
40
25
  function Touch(value: unknown, prop?: string | number): void;
26
+ function Apply(rootNode: any, update: any): void;
41
27
  /**
42
28
  * Applies a JSON diff result to an observable node, efficiently updating only changed properties.
43
29
  * Optimizes nested object updates by computing paths incrementally and touching modified properties.