j-templates 6.1.11 → 7.0.0
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/createAssignment.js +4 -5
- package/DOM/createAttributeAssignment.d.ts +1 -0
- package/DOM/createAttributeAssignment.js +16 -0
- package/DOM/createPropertyAssignment.d.ts +1 -0
- package/DOM/createPropertyAssignment.js +7 -0
- package/DOM/domNodeConfig.js +41 -1
- package/DOM/elements.d.ts +80 -26
- package/DOM/elements.js +12 -101
- package/DOM/index.d.ts +0 -1
- package/DOM/index.js +0 -1
- package/DOM/svgElements.d.ts +0 -4
- package/DOM/svgElements.js +0 -16
- package/Node/component.d.ts +19 -16
- package/Node/component.js +25 -31
- package/Node/component.types.d.ts +5 -0
- package/Node/nodeConfig.d.ts +7 -0
- package/Node/vNode.d.ts +20 -0
- package/Node/vNode.js +296 -0
- package/Node/vNode.types.d.ts +45 -0
- package/Store/Tree/observableNode.js +1 -2
- package/Store/Tree/observableScope.d.ts +3 -4
- package/Store/Tree/observableScope.js +64 -66
- package/Utils/avlTree.d.ts +15 -0
- package/Utils/avlTree.js +139 -0
- package/Utils/decorators.d.ts +4 -25
- package/Utils/decorators.js +3 -61
- package/Utils/distinctArray.d.ts +10 -0
- package/Utils/distinctArray.js +26 -0
- package/Utils/emitter.d.ts +2 -0
- package/Utils/emitter.js +5 -0
- package/index.d.ts +1 -2
- package/package.json +1 -1
- package/Node/boundNode.d.ts +0 -4
- package/Node/boundNode.js +0 -115
- package/Node/boundNode.types.d.ts +0 -57
- package/Node/componentNode.d.ts +0 -7
- package/Node/componentNode.js +0 -123
- package/Node/componentNode.types.d.ts +0 -37
- package/Node/elementNode.d.ts +0 -5
- package/Node/elementNode.js +0 -176
- package/Node/elementNode.types.d.ts +0 -40
- package/Node/elementNode.types.js +0 -2
- package/Node/nodeRef.d.ts +0 -26
- package/Node/nodeRef.js +0 -252
- package/Node/nodeRef.types.d.ts +0 -21
- package/Node/nodeRef.types.js +0 -2
- package/Node/textNode.types.d.ts +0 -7
- package/Node/textNode.types.js +0 -2
- /package/Node/{boundNode.types.js → component.types.js} +0 -0
- /package/Node/{componentNode.types.js → vNode.types.js} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { BoundNodeFunctionParam, IBoundNodeBase, NodeDefinition } from "./boundNode.types";
|
|
2
|
-
import { Component, ComponentConstructor } from "./component";
|
|
3
|
-
import { NodeRefType } from "./nodeRef";
|
|
4
|
-
import { AllNodeRefTypes } from "./nodeRef.types";
|
|
5
|
-
export type ComponentNodeEvents<E = void> = {
|
|
6
|
-
[P in keyof E]?: {
|
|
7
|
-
(data: E[P]): void;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export interface ComponentNodeDefinition<D = void, E = void> extends NodeDefinition<D> {
|
|
11
|
-
on: ComponentNodeEvents<E>;
|
|
12
|
-
data?: {
|
|
13
|
-
(): D | Promise<D>;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export interface ComponentNodeFunctionParam<D = void, E = void, P = HTMLElement> extends BoundNodeFunctionParam<P> {
|
|
17
|
-
on?: ComponentNodeEvents<E>;
|
|
18
|
-
data?: {
|
|
19
|
-
(): D | Promise<D>;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export type ComponentNodeFunction<D = void, T = void, E = void> = (nodeDef: ComponentNodeFunctionParam<D, E>, templates?: T) => IComponentNode<D, T, E>;
|
|
23
|
-
export interface IComponentNodeBase<D, T, E> extends IBoundNodeBase {
|
|
24
|
-
nodeDef: ComponentNodeFunctionParam<D, E>;
|
|
25
|
-
constructor: ComponentConstructor<D, T, E>;
|
|
26
|
-
component: Component<D, T, E>;
|
|
27
|
-
componentEvents: {
|
|
28
|
-
[name: string]: {
|
|
29
|
-
(...args: Array<any>): void;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
templates: T;
|
|
33
|
-
}
|
|
34
|
-
export interface IComponentNode<D, T, E> extends IComponentNodeBase<D, T, E> {
|
|
35
|
-
type: NodeRefType.ComponentNode;
|
|
36
|
-
childNodes: AllNodeRefTypes[];
|
|
37
|
-
}
|
package/Node/elementNode.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ElementChildrenFunctionParam, ElementNodeFunctionParam, IElementNode, IElementNodeBase } from "./elementNode.types";
|
|
2
|
-
export declare namespace ElementNode {
|
|
3
|
-
function Create<T>(type: any, namespace: string, nodeDef: ElementNodeFunctionParam<T>, children: ElementChildrenFunctionParam<T>): IElementNode<T>;
|
|
4
|
-
function Init<T>(elementNode: IElementNodeBase<T>): void;
|
|
5
|
-
}
|
package/Node/elementNode.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ElementNode = void 0;
|
|
4
|
-
const observableScope_1 = require("../Store/Tree/observableScope");
|
|
5
|
-
const injector_1 = require("../Utils/injector");
|
|
6
|
-
const list_1 = require("../Utils/list");
|
|
7
|
-
const thread_1 = require("../Utils/thread");
|
|
8
|
-
const boundNode_1 = require("./boundNode");
|
|
9
|
-
const nodeConfig_1 = require("./nodeConfig");
|
|
10
|
-
const nodeRef_1 = require("./nodeRef");
|
|
11
|
-
const valueDefault = [];
|
|
12
|
-
var ElementNode;
|
|
13
|
-
(function (ElementNode) {
|
|
14
|
-
function Create(type, namespace, nodeDef, children) {
|
|
15
|
-
var elemNode = nodeRef_1.NodeRef.Create(type, namespace, nodeRef_1.NodeRefType.ElementNode);
|
|
16
|
-
elemNode.nodeDef = nodeDef;
|
|
17
|
-
if (Array.isArray(children))
|
|
18
|
-
elemNode.childrenArray = children;
|
|
19
|
-
else if (children !== undefined)
|
|
20
|
-
elemNode.children = children;
|
|
21
|
-
return elemNode;
|
|
22
|
-
}
|
|
23
|
-
ElementNode.Create = Create;
|
|
24
|
-
function CreateValueScopeCallback(dataScope) {
|
|
25
|
-
return function () {
|
|
26
|
-
const value = observableScope_1.ObservableScope.Value(dataScope);
|
|
27
|
-
if (!value)
|
|
28
|
-
return valueDefault;
|
|
29
|
-
if (!Array.isArray(value))
|
|
30
|
-
return [value];
|
|
31
|
-
return value;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function CreateNodeScopeCallback(elementNode, valueScope) {
|
|
35
|
-
let lastNodeList;
|
|
36
|
-
return function () {
|
|
37
|
-
const values = observableScope_1.ObservableScope.Value(valueScope);
|
|
38
|
-
const lastNodeMap = lastNodeList && list_1.List.ToNodeMap(lastNodeList, GetDataValue);
|
|
39
|
-
const nextNodeList = list_1.List.Create();
|
|
40
|
-
for (let x = 0; x < values.length; x++) {
|
|
41
|
-
let curNode = null;
|
|
42
|
-
if (lastNodeMap !== undefined) {
|
|
43
|
-
const nodeArr = lastNodeMap.get(values[x]);
|
|
44
|
-
if (nodeArr !== undefined) {
|
|
45
|
-
let y = nodeArr.length - 1;
|
|
46
|
-
for (; y >= 0 && nodeArr[y] === null; y--) { }
|
|
47
|
-
curNode = nodeArr[y];
|
|
48
|
-
nodeArr[y] = null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const value = values[x];
|
|
52
|
-
if (curNode !== null) {
|
|
53
|
-
list_1.List.RemoveNode(lastNodeList, curNode);
|
|
54
|
-
list_1.List.AddNode(nextNodeList, curNode);
|
|
55
|
-
const nextNodes = observableScope_1.ObservableScope.Value(curNode.data.scope);
|
|
56
|
-
if (curNode.data.nodes !== nextNodes) {
|
|
57
|
-
list_1.List.Add(elementNode.destroyNodeList, {
|
|
58
|
-
...curNode.data,
|
|
59
|
-
scope: null
|
|
60
|
-
});
|
|
61
|
-
curNode.data.init = false;
|
|
62
|
-
curNode.data.nodes = nextNodes;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
const scope = observableScope_1.ObservableScope.Create(function () {
|
|
67
|
-
return injector_1.Injector.Scope(elementNode.injector, CreateNodeArray, elementNode.children, value);
|
|
68
|
-
});
|
|
69
|
-
curNode = list_1.List.Add(nextNodeList, {
|
|
70
|
-
value,
|
|
71
|
-
init: false,
|
|
72
|
-
scope,
|
|
73
|
-
nodes: observableScope_1.ObservableScope.Value(scope),
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
lastNodeList && list_1.List.Append(elementNode.destroyNodeList, lastNodeList);
|
|
78
|
-
lastNodeList = nextNodeList;
|
|
79
|
-
return nextNodeList;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function Init(elementNode) {
|
|
83
|
-
elementNode.childNodes = new Set();
|
|
84
|
-
if (elementNode.children !== null) {
|
|
85
|
-
const dataScope = elementNode.nodeDef.data ? observableScope_1.ObservableScope.Create(elementNode.nodeDef.data) : observableScope_1.ObservableScope.Create(function () {
|
|
86
|
-
return [true];
|
|
87
|
-
});
|
|
88
|
-
const valueScope = observableScope_1.ObservableScope.Create(CreateValueScopeCallback(dataScope));
|
|
89
|
-
const nodeScope = observableScope_1.ObservableScope.Create(CreateNodeScopeCallback(elementNode, valueScope));
|
|
90
|
-
elementNode.childNodes = new Set();
|
|
91
|
-
elementNode.scopes ??= [];
|
|
92
|
-
elementNode.scopes.push(dataScope, valueScope, nodeScope);
|
|
93
|
-
observableScope_1.ObservableScope.Watch(nodeScope, function (scope) {
|
|
94
|
-
ScheduleSetData(elementNode, scope);
|
|
95
|
-
});
|
|
96
|
-
UpdateNodes(elementNode, observableScope_1.ObservableScope.Value(nodeScope), true);
|
|
97
|
-
}
|
|
98
|
-
else if (elementNode.childrenArray !== null) {
|
|
99
|
-
SetDefaultData(elementNode);
|
|
100
|
-
}
|
|
101
|
-
boundNode_1.BoundNode.Init(elementNode);
|
|
102
|
-
}
|
|
103
|
-
ElementNode.Init = Init;
|
|
104
|
-
})(ElementNode || (exports.ElementNode = ElementNode = {}));
|
|
105
|
-
function ScheduleSetData(node, scope) {
|
|
106
|
-
if (node.setData)
|
|
107
|
-
return;
|
|
108
|
-
node.setData = true;
|
|
109
|
-
nodeConfig_1.NodeConfig.scheduleUpdate(function () {
|
|
110
|
-
node.setData = false;
|
|
111
|
-
if (node.destroyed)
|
|
112
|
-
return;
|
|
113
|
-
UpdateNodes(node, observableScope_1.ObservableScope.Value(scope));
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function SetDefaultData(node) {
|
|
117
|
-
const nodes = node.childrenArray ||
|
|
118
|
-
injector_1.Injector.Scope(node.injector, CreateNodeArray, node.children, true);
|
|
119
|
-
node.childrenArray = null;
|
|
120
|
-
const defaultNodeList = list_1.List.Create();
|
|
121
|
-
list_1.List.Add(defaultNodeList, {
|
|
122
|
-
value: null,
|
|
123
|
-
init: false,
|
|
124
|
-
scope: null,
|
|
125
|
-
nodes
|
|
126
|
-
});
|
|
127
|
-
UpdateNodes(node, defaultNodeList, true);
|
|
128
|
-
}
|
|
129
|
-
function GetDataValue(data) {
|
|
130
|
-
return data.value;
|
|
131
|
-
}
|
|
132
|
-
function UpdateNodes(elementNode, nodeList, init = false) {
|
|
133
|
-
(0, thread_1.Synch)(function () {
|
|
134
|
-
let data;
|
|
135
|
-
while (data = list_1.List.Pop(elementNode.destroyNodeList)) {
|
|
136
|
-
observableScope_1.ObservableScope.Destroy(data.scope);
|
|
137
|
-
for (let x = 0; x < data.nodes.length; x++)
|
|
138
|
-
elementNode.childNodes.delete(data.nodes[x]);
|
|
139
|
-
nodeRef_1.NodeRef.DestroyAll(data.nodes);
|
|
140
|
-
}
|
|
141
|
-
for (let node = nodeList.head; node !== null; node = node.next) {
|
|
142
|
-
if (!node.data.init) {
|
|
143
|
-
const nodeData = node.data;
|
|
144
|
-
(0, thread_1.Schedule)(function () {
|
|
145
|
-
if (elementNode.destroyed || nodeData.init)
|
|
146
|
-
return;
|
|
147
|
-
nodeRef_1.NodeRef.InitAll(elementNode, nodeData.nodes);
|
|
148
|
-
nodeData.init = true;
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const startSize = nodeList.size;
|
|
153
|
-
(0, thread_1.Thread)(function (async) {
|
|
154
|
-
if (elementNode.destroyed)
|
|
155
|
-
return;
|
|
156
|
-
if (init || !async)
|
|
157
|
-
nodeRef_1.NodeRef.ReconcileChildren(elementNode, nodeList);
|
|
158
|
-
else
|
|
159
|
-
nodeConfig_1.NodeConfig.scheduleUpdate(function () {
|
|
160
|
-
if (elementNode.destroyed || nodeList.size !== startSize)
|
|
161
|
-
return;
|
|
162
|
-
nodeRef_1.NodeRef.ReconcileChildren(elementNode, nodeList);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function CreateNodeArray(childrenFunc, value) {
|
|
168
|
-
const newNodes = childrenFunc(value);
|
|
169
|
-
if (typeof newNodes === "string" || !newNodes) {
|
|
170
|
-
const textNode = nodeRef_1.NodeRef.Create(newNodes, null, nodeRef_1.NodeRefType.TextNode);
|
|
171
|
-
return [textNode];
|
|
172
|
-
}
|
|
173
|
-
if (Array.isArray(newNodes))
|
|
174
|
-
return newNodes;
|
|
175
|
-
return [newNodes];
|
|
176
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IObservableScope } from "../Store/Tree/observableScope";
|
|
2
|
-
import { IList } from "../Utils/list";
|
|
3
|
-
import { NodeDefinition, BoundNodeFunctionParam, IBoundNodeBase } from "./boundNode.types";
|
|
4
|
-
import { NodeRefType } from "./nodeRef";
|
|
5
|
-
import { INodeRefBase, ElementNodeRefTypes, AllNodeRefTypes } from "./nodeRef.types";
|
|
6
|
-
export type ElementChildrenFunction<T> = {
|
|
7
|
-
(data: T): string | ElementNodeRefTypes | ElementNodeRefTypes[];
|
|
8
|
-
};
|
|
9
|
-
export type ElementChildrenFunctionParam<T> = ElementChildrenFunction<T> | ElementNodeRefTypes[];
|
|
10
|
-
export type ElementNodeFunction<T> = {
|
|
11
|
-
(nodeDef: ElementNodeFunctionParam<T>, children?: ElementChildrenFunctionParam<T>): INodeRefBase;
|
|
12
|
-
};
|
|
13
|
-
export interface ElementNodeDefinition<T> extends NodeDefinition<T> {
|
|
14
|
-
data?: {
|
|
15
|
-
(): T | Array<T> | Promise<Array<T>> | Promise<T>;
|
|
16
|
-
};
|
|
17
|
-
children?: ElementChildrenFunction<T>;
|
|
18
|
-
}
|
|
19
|
-
export interface ElementNodeFunctionParam<T, P = HTMLElement, E = HTMLElementEventMap> extends BoundNodeFunctionParam<P, E> {
|
|
20
|
-
data?: {
|
|
21
|
-
(): T | Array<T> | Promise<Array<T>> | Promise<T>;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export interface IElementDataNode<T> {
|
|
25
|
-
value: T;
|
|
26
|
-
init: boolean;
|
|
27
|
-
scope: IObservableScope<AllNodeRefTypes[] | null>;
|
|
28
|
-
nodes: AllNodeRefTypes[] | null;
|
|
29
|
-
}
|
|
30
|
-
export interface IElementNodeBase<T> extends IBoundNodeBase {
|
|
31
|
-
nodeDef: ElementNodeFunctionParam<T>;
|
|
32
|
-
children: ElementChildrenFunction<T>;
|
|
33
|
-
childrenArray: ElementNodeRefTypes[];
|
|
34
|
-
destroyNodeList: IList<IElementDataNode<T>>;
|
|
35
|
-
setData: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface IElementNode<T> extends IElementNodeBase<T> {
|
|
38
|
-
type: NodeRefType.ElementNode;
|
|
39
|
-
childNodes: Set<AllNodeRefTypes>;
|
|
40
|
-
}
|
package/Node/nodeRef.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { INodeRef, ElementNodeRefTypes, AllNodeRefTypes } from "./nodeRef.types";
|
|
2
|
-
import { IBoundNode } from "./boundNode.types";
|
|
3
|
-
import { IElementDataNode, IElementNode } from "./elementNode.types";
|
|
4
|
-
import { IComponentNode } from "./componentNode.types";
|
|
5
|
-
import { IList } from "../Utils/list";
|
|
6
|
-
import { ITextNode } from "./textNode.types";
|
|
7
|
-
export declare enum NodeRefType {
|
|
8
|
-
NodeRef = 0,
|
|
9
|
-
BoundNode = 1,
|
|
10
|
-
ElementNode = 2,
|
|
11
|
-
ComponentNode = 3,
|
|
12
|
-
TextNode = 4
|
|
13
|
-
}
|
|
14
|
-
export declare namespace NodeRef {
|
|
15
|
-
function Wrap(node: any): INodeRef;
|
|
16
|
-
function Create(nodeType: any, namespace: string, type: NodeRefType): INodeRef | IBoundNode | IElementNode<any> | IComponentNode<any, any, any> | ITextNode;
|
|
17
|
-
function Init(nodeRef: AllNodeRefTypes): void;
|
|
18
|
-
function InitAll(parentNode: ElementNodeRefTypes, nodeRefs: Array<AllNodeRefTypes>): void;
|
|
19
|
-
function AddChild(node: ElementNodeRefTypes, child: AllNodeRefTypes): void;
|
|
20
|
-
function AddChildAfter(node: ElementNodeRefTypes, currentChild: AllNodeRefTypes, newChild: AllNodeRefTypes): void;
|
|
21
|
-
function AddChildBefore(node: ElementNodeRefTypes, currentChild: AllNodeRefTypes, newChild: AllNodeRefTypes): void;
|
|
22
|
-
function ReconcileChildren(node: ElementNodeRefTypes, nextChildren: IList<IElementDataNode<unknown>>): void;
|
|
23
|
-
function DetachChild(node: ElementNodeRefTypes, child: AllNodeRefTypes): void;
|
|
24
|
-
function Destroy(node: AllNodeRefTypes): void;
|
|
25
|
-
function DestroyAll(nodes: Array<AllNodeRefTypes>): void;
|
|
26
|
-
}
|
package/Node/nodeRef.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NodeRef = exports.NodeRefType = void 0;
|
|
4
|
-
const nodeConfig_1 = require("./nodeConfig");
|
|
5
|
-
const injector_1 = require("../Utils/injector");
|
|
6
|
-
const boundNode_1 = require("./boundNode");
|
|
7
|
-
const elementNode_1 = require("./elementNode");
|
|
8
|
-
const componentNode_1 = require("./componentNode");
|
|
9
|
-
const list_1 = require("../Utils/list");
|
|
10
|
-
const Store_1 = require("../Store");
|
|
11
|
-
var NodeRefType;
|
|
12
|
-
(function (NodeRefType) {
|
|
13
|
-
NodeRefType[NodeRefType["NodeRef"] = 0] = "NodeRef";
|
|
14
|
-
NodeRefType[NodeRefType["BoundNode"] = 1] = "BoundNode";
|
|
15
|
-
NodeRefType[NodeRefType["ElementNode"] = 2] = "ElementNode";
|
|
16
|
-
NodeRefType[NodeRefType["ComponentNode"] = 3] = "ComponentNode";
|
|
17
|
-
NodeRefType[NodeRefType["TextNode"] = 4] = "TextNode";
|
|
18
|
-
})(NodeRefType || (exports.NodeRefType = NodeRefType = {}));
|
|
19
|
-
var NodeRef;
|
|
20
|
-
(function (NodeRef) {
|
|
21
|
-
function Wrap(node) {
|
|
22
|
-
const nodeRef = Create(null, null, NodeRefType.BoundNode);
|
|
23
|
-
nodeRef.node = node;
|
|
24
|
-
nodeRef.childNodes = [];
|
|
25
|
-
return nodeRef;
|
|
26
|
-
}
|
|
27
|
-
NodeRef.Wrap = Wrap;
|
|
28
|
-
function Create(nodeType, namespace, type) {
|
|
29
|
-
switch (type) {
|
|
30
|
-
case NodeRefType.TextNode:
|
|
31
|
-
return {
|
|
32
|
-
type: NodeRefType.TextNode,
|
|
33
|
-
parent: null,
|
|
34
|
-
node: null,
|
|
35
|
-
value: nodeType
|
|
36
|
-
};
|
|
37
|
-
case NodeRefType.NodeRef:
|
|
38
|
-
return {
|
|
39
|
-
node: null,
|
|
40
|
-
nodeType: nodeType,
|
|
41
|
-
nodeNamespace: namespace,
|
|
42
|
-
type: NodeRefType.NodeRef,
|
|
43
|
-
injector: injector_1.Injector.Current() || new injector_1.Injector(),
|
|
44
|
-
parent: null,
|
|
45
|
-
childNodes: null,
|
|
46
|
-
destroyed: false
|
|
47
|
-
};
|
|
48
|
-
case NodeRefType.BoundNode:
|
|
49
|
-
return {
|
|
50
|
-
node: null,
|
|
51
|
-
nodeDef: null,
|
|
52
|
-
nodeType: nodeType,
|
|
53
|
-
nodeNamespace: namespace,
|
|
54
|
-
type: NodeRefType.BoundNode,
|
|
55
|
-
injector: injector_1.Injector.Current() || new injector_1.Injector(),
|
|
56
|
-
parent: null,
|
|
57
|
-
childNodes: null,
|
|
58
|
-
destroyed: false,
|
|
59
|
-
lastEvents: null,
|
|
60
|
-
setProperties: false,
|
|
61
|
-
assignProperties: null,
|
|
62
|
-
assignEvents: null,
|
|
63
|
-
assignText: null,
|
|
64
|
-
setAttributes: false,
|
|
65
|
-
setEvents: false,
|
|
66
|
-
setText: false,
|
|
67
|
-
scopes: null
|
|
68
|
-
};
|
|
69
|
-
case NodeRefType.ElementNode:
|
|
70
|
-
return {
|
|
71
|
-
node: null,
|
|
72
|
-
nodeDef: null,
|
|
73
|
-
nodeType: nodeType,
|
|
74
|
-
nodeNamespace: namespace,
|
|
75
|
-
type: NodeRefType.ElementNode,
|
|
76
|
-
injector: injector_1.Injector.Current() || new injector_1.Injector(),
|
|
77
|
-
parent: null,
|
|
78
|
-
childNodes: null,
|
|
79
|
-
destroyed: false,
|
|
80
|
-
lastEvents: null,
|
|
81
|
-
setProperties: false,
|
|
82
|
-
assignProperties: null,
|
|
83
|
-
assignEvents: null,
|
|
84
|
-
assignText: null,
|
|
85
|
-
setAttributes: false,
|
|
86
|
-
setEvents: false,
|
|
87
|
-
children: null,
|
|
88
|
-
childrenArray: null,
|
|
89
|
-
nodeList: null,
|
|
90
|
-
setData: false,
|
|
91
|
-
setText: false,
|
|
92
|
-
scopes: null,
|
|
93
|
-
destroyNodeList: list_1.List.Create()
|
|
94
|
-
};
|
|
95
|
-
case NodeRefType.ComponentNode:
|
|
96
|
-
return {
|
|
97
|
-
node: null,
|
|
98
|
-
nodeDef: null,
|
|
99
|
-
nodeType: nodeType,
|
|
100
|
-
nodeNamespace: namespace,
|
|
101
|
-
type: NodeRefType.ComponentNode,
|
|
102
|
-
injector: injector_1.Injector.Current() || new injector_1.Injector(),
|
|
103
|
-
parent: null,
|
|
104
|
-
childNodes: null,
|
|
105
|
-
destroyed: false,
|
|
106
|
-
setProperties: false,
|
|
107
|
-
assignProperties: null,
|
|
108
|
-
assignEvents: null,
|
|
109
|
-
setAttributes: false,
|
|
110
|
-
setEvents: false,
|
|
111
|
-
component: null,
|
|
112
|
-
componentEvents: null,
|
|
113
|
-
scopes: null
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
NodeRef.Create = Create;
|
|
118
|
-
function Init(nodeRef) {
|
|
119
|
-
if (nodeRef.node || nodeRef.type === NodeRefType.TextNode)
|
|
120
|
-
return;
|
|
121
|
-
nodeRef.node = nodeRef.nodeType === 'text' ? nodeConfig_1.NodeConfig.createTextNode() : nodeConfig_1.NodeConfig.createNode(nodeRef.nodeType, nodeRef.nodeNamespace);
|
|
122
|
-
nodeRef.childNodes = nodeRef.nodeType !== 'text' ? [] : null;
|
|
123
|
-
switch (nodeRef.type) {
|
|
124
|
-
case NodeRefType.BoundNode:
|
|
125
|
-
boundNode_1.BoundNode.Init(nodeRef);
|
|
126
|
-
break;
|
|
127
|
-
case NodeRefType.ElementNode:
|
|
128
|
-
elementNode_1.ElementNode.Init(nodeRef);
|
|
129
|
-
break;
|
|
130
|
-
case NodeRefType.ComponentNode:
|
|
131
|
-
componentNode_1.ComponentNode.Init(nodeRef);
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
NodeRef.Init = Init;
|
|
136
|
-
function AddChildToNode(parentNode, child) {
|
|
137
|
-
switch (parentNode.type) {
|
|
138
|
-
case NodeRefType.ElementNode:
|
|
139
|
-
parentNode.childNodes.add(child);
|
|
140
|
-
break;
|
|
141
|
-
case NodeRefType.ComponentNode:
|
|
142
|
-
case NodeRefType.BoundNode:
|
|
143
|
-
parentNode.childNodes.push(child);
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
throw "Unable to add child node to node";
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function InitAll(parentNode, nodeRefs) {
|
|
150
|
-
for (var x = 0; x < nodeRefs.length; x++) {
|
|
151
|
-
nodeRefs[x].parent = parentNode;
|
|
152
|
-
AddChildToNode(parentNode, nodeRefs[x]);
|
|
153
|
-
Init(nodeRefs[x]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
NodeRef.InitAll = InitAll;
|
|
157
|
-
function AddChild(node, child) {
|
|
158
|
-
child.parent = node;
|
|
159
|
-
AddChildToNode(node, child);
|
|
160
|
-
nodeConfig_1.NodeConfig.addChild(node.node, child.node);
|
|
161
|
-
}
|
|
162
|
-
NodeRef.AddChild = AddChild;
|
|
163
|
-
function AddChildAfter(node, currentChild, newChild) {
|
|
164
|
-
if (currentChild && currentChild.parent !== node)
|
|
165
|
-
throw "currentChild is not valid";
|
|
166
|
-
newChild.parent = node;
|
|
167
|
-
AddChildToNode(node, newChild);
|
|
168
|
-
nodeConfig_1.NodeConfig.addChildAfter(node.node, currentChild && currentChild.node, newChild.node);
|
|
169
|
-
}
|
|
170
|
-
NodeRef.AddChildAfter = AddChildAfter;
|
|
171
|
-
function AddChildBefore(node, currentChild, newChild) {
|
|
172
|
-
if (currentChild && currentChild.parent !== node)
|
|
173
|
-
throw "currentChild is not valid";
|
|
174
|
-
newChild.parent = node;
|
|
175
|
-
AddChildToNode(node, newChild);
|
|
176
|
-
nodeConfig_1.NodeConfig.addChildBefore(node.node, currentChild && currentChild.node, newChild.node);
|
|
177
|
-
}
|
|
178
|
-
NodeRef.AddChildBefore = AddChildBefore;
|
|
179
|
-
function ReconcileChildren(node, nextChildren) {
|
|
180
|
-
const rootNode = node.node;
|
|
181
|
-
if (nextChildren.size === 0) {
|
|
182
|
-
nodeConfig_1.NodeConfig.replaceChildren(rootNode, []);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
let priorNode;
|
|
186
|
-
let insert = false;
|
|
187
|
-
let remove = false;
|
|
188
|
-
for (let curDataNode = nextChildren.head; curDataNode !== null; curDataNode = curDataNode.next) {
|
|
189
|
-
for (let x = 0; x < curDataNode.data.nodes.length; x++) {
|
|
190
|
-
const virtualNode = curDataNode.data.nodes[x];
|
|
191
|
-
const actualNode = priorNode ? nodeConfig_1.NodeConfig.getNextSibling(priorNode) : nodeConfig_1.NodeConfig.getFirstChild(rootNode);
|
|
192
|
-
let expectedNode;
|
|
193
|
-
if (virtualNode.type === NodeRefType.TextNode && actualNode !== null && nodeConfig_1.NodeConfig.isTextNode(actualNode)) {
|
|
194
|
-
nodeConfig_1.NodeConfig.setText(actualNode, virtualNode.value);
|
|
195
|
-
virtualNode.node = expectedNode = actualNode;
|
|
196
|
-
}
|
|
197
|
-
else if (virtualNode.type === NodeRefType.TextNode)
|
|
198
|
-
expectedNode = nodeConfig_1.NodeConfig.createTextNode(virtualNode.value);
|
|
199
|
-
else
|
|
200
|
-
expectedNode = virtualNode.node;
|
|
201
|
-
if (actualNode !== expectedNode) {
|
|
202
|
-
nodeConfig_1.NodeConfig.addChildBefore(rootNode, actualNode, expectedNode);
|
|
203
|
-
!remove && insert && actualNode && nodeConfig_1.NodeConfig.removeChild(rootNode, actualNode);
|
|
204
|
-
remove = insert;
|
|
205
|
-
insert = true;
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
insert = false;
|
|
209
|
-
remove = false;
|
|
210
|
-
}
|
|
211
|
-
priorNode = expectedNode;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
let lastChild = nodeConfig_1.NodeConfig.getLastChild(rootNode);
|
|
215
|
-
while (priorNode && priorNode !== lastChild) {
|
|
216
|
-
nodeConfig_1.NodeConfig.removeChild(rootNode, lastChild);
|
|
217
|
-
lastChild = nodeConfig_1.NodeConfig.getLastChild(rootNode);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
NodeRef.ReconcileChildren = ReconcileChildren;
|
|
221
|
-
function DetachChild(node, child) {
|
|
222
|
-
if (node.type === NodeRefType.ElementNode && node.childNodes.delete(child))
|
|
223
|
-
child.parent = null;
|
|
224
|
-
}
|
|
225
|
-
NodeRef.DetachChild = DetachChild;
|
|
226
|
-
function Destroy(node) {
|
|
227
|
-
if (node.type === NodeRefType.TextNode || node.destroyed)
|
|
228
|
-
return;
|
|
229
|
-
node.destroyed = true;
|
|
230
|
-
if (Array.isArray(node.childNodes))
|
|
231
|
-
for (let x = 0; x < node.childNodes.length; x++)
|
|
232
|
-
Destroy(node.childNodes[x]);
|
|
233
|
-
else
|
|
234
|
-
node.childNodes?.forEach(Destroy);
|
|
235
|
-
switch (node.type) {
|
|
236
|
-
case NodeRefType.ComponentNode:
|
|
237
|
-
node.component?.Destroy();
|
|
238
|
-
case NodeRefType.BoundNode:
|
|
239
|
-
node.assignEvents?.(null);
|
|
240
|
-
case NodeRefType.ElementNode:
|
|
241
|
-
for (let x = 0; node.scopes && x < node.scopes.length; x++)
|
|
242
|
-
Store_1.ObservableScope.Destroy(node.scopes[x]);
|
|
243
|
-
}
|
|
244
|
-
node.node = null;
|
|
245
|
-
}
|
|
246
|
-
NodeRef.Destroy = Destroy;
|
|
247
|
-
function DestroyAll(nodes) {
|
|
248
|
-
for (let x = 0; x < nodes.length; x++)
|
|
249
|
-
Destroy(nodes[x]);
|
|
250
|
-
}
|
|
251
|
-
NodeRef.DestroyAll = DestroyAll;
|
|
252
|
-
})(NodeRef || (exports.NodeRef = NodeRef = {}));
|
package/Node/nodeRef.types.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Injector } from "../Utils/injector";
|
|
2
|
-
import { IBoundNode } from "./boundNode.types";
|
|
3
|
-
import { IComponentNode } from "./componentNode.types";
|
|
4
|
-
import { IElementNode } from "./elementNode.types";
|
|
5
|
-
import { NodeRefType } from "./nodeRef";
|
|
6
|
-
import { ITextNode } from "./textNode.types";
|
|
7
|
-
export interface INodeRefBase {
|
|
8
|
-
type: NodeRefType;
|
|
9
|
-
node: any;
|
|
10
|
-
nodeType: any;
|
|
11
|
-
nodeNamespace: string;
|
|
12
|
-
injector: Injector;
|
|
13
|
-
parent: INodeRefBase;
|
|
14
|
-
childNodes: AllNodeRefTypes[] | Set<AllNodeRefTypes>;
|
|
15
|
-
destroyed: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface INodeRef extends INodeRefBase {
|
|
18
|
-
type: NodeRefType.NodeRef;
|
|
19
|
-
}
|
|
20
|
-
export type ElementNodeRefTypes = INodeRef | IBoundNode | IElementNode<any> | IComponentNode<any, any, any>;
|
|
21
|
-
export type AllNodeRefTypes = ElementNodeRefTypes | ITextNode;
|
package/Node/nodeRef.types.js
DELETED
package/Node/textNode.types.d.ts
DELETED
package/Node/textNode.types.js
DELETED
|
File without changes
|
|
File without changes
|