j-templates 5.0.46 → 5.0.47

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.
Files changed (91) hide show
  1. package/DOM/domNodeConfig.d.ts +2 -2
  2. package/DOM/domNodeConfig.js +82 -82
  3. package/DOM/elements.d.ts +24 -24
  4. package/DOM/elements.js +96 -96
  5. package/DOM/index.d.ts +3 -3
  6. package/DOM/index.js +19 -19
  7. package/DOM/svgElements.d.ts +4 -4
  8. package/DOM/svgElements.js +17 -17
  9. package/DOM/utils.d.ts +1 -1
  10. package/DOM/utils.js +47 -47
  11. package/DOM/window.d.ts +1 -1
  12. package/DOM/window.js +4 -4
  13. package/Node/boundNode.d.ts +4 -4
  14. package/Node/boundNode.js +99 -94
  15. package/Node/boundNode.types.d.ts +43 -43
  16. package/Node/boundNode.types.js +2 -2
  17. package/Node/component.d.ts +34 -34
  18. package/Node/component.js +80 -80
  19. package/Node/componentNode.d.ts +7 -7
  20. package/Node/componentNode.js +115 -115
  21. package/Node/componentNode.types.d.ts +35 -35
  22. package/Node/componentNode.types.js +2 -2
  23. package/Node/elementNode.d.ts +5 -5
  24. package/Node/elementNode.js +157 -158
  25. package/Node/elementNode.types.d.ts +34 -34
  26. package/Node/elementNode.types.js +2 -2
  27. package/Node/nodeConfig.d.ts +22 -22
  28. package/Node/nodeConfig.js +5 -5
  29. package/Node/nodeRef.d.ts +21 -21
  30. package/Node/nodeRef.js +157 -157
  31. package/Node/nodeRef.types.d.ts +21 -21
  32. package/Node/nodeRef.types.js +2 -2
  33. package/Store/Diff/diffAsync.d.ts +17 -17
  34. package/Store/Diff/diffAsync.js +36 -36
  35. package/Store/Diff/diffSync.d.ts +14 -14
  36. package/Store/Diff/diffSync.js +27 -27
  37. package/Store/Diff/diffTree.d.ts +24 -24
  38. package/Store/Diff/diffTree.js +232 -221
  39. package/Store/Diff/diffWorker.d.ts +3 -3
  40. package/Store/Diff/diffWorker.js +19 -19
  41. package/Store/Diff/workerQueue.d.ts +7 -7
  42. package/Store/Diff/workerQueue.js +35 -35
  43. package/Store/Store/store.d.ts +14 -14
  44. package/Store/Store/store.js +31 -31
  45. package/Store/Store/storeAsync.d.ts +20 -20
  46. package/Store/Store/storeAsync.js +49 -49
  47. package/Store/Store/storeAsyncWriter.d.ts +15 -15
  48. package/Store/Store/storeAsyncWriter.js +52 -52
  49. package/Store/Store/storeSync.d.ts +15 -15
  50. package/Store/Store/storeSync.js +33 -33
  51. package/Store/Store/storeSyncWriter.d.ts +12 -12
  52. package/Store/Store/storeSyncWriter.js +41 -41
  53. package/Store/Store/storeWriter.d.ts +9 -9
  54. package/Store/Store/storeWriter.js +30 -30
  55. package/Store/Tree/observableScope.d.ts +57 -56
  56. package/Store/Tree/observableScope.js +168 -164
  57. package/Store/Tree/observableTree.d.ts +34 -33
  58. package/Store/Tree/observableTree.js +232 -214
  59. package/Store/index.d.ts +4 -4
  60. package/Store/index.js +11 -11
  61. package/Utils/animation.d.ts +29 -29
  62. package/Utils/animation.js +108 -108
  63. package/Utils/asyncQueue.d.ts +8 -8
  64. package/Utils/asyncQueue.js +42 -42
  65. package/Utils/decorators.d.ts +37 -37
  66. package/Utils/decorators.js +310 -300
  67. package/Utils/emitter.d.ts +12 -12
  68. package/Utils/emitter.js +24 -24
  69. package/Utils/index.d.ts +2 -2
  70. package/Utils/index.js +18 -18
  71. package/Utils/injector.d.ts +13 -13
  72. package/Utils/injector.js +38 -38
  73. package/Utils/list.d.ts +23 -23
  74. package/Utils/list.js +120 -120
  75. package/Utils/router.d.ts +23 -23
  76. package/Utils/router.js +116 -116
  77. package/Utils/thread.d.ts +16 -16
  78. package/Utils/thread.js +108 -108
  79. package/Utils/utils.types.d.ts +3 -3
  80. package/Utils/utils.types.js +2 -2
  81. package/index.d.ts +2 -2
  82. package/index.debug.d.ts +1 -0
  83. package/index.debug.js +12 -0
  84. package/index.js +5 -5
  85. package/jTemplates.js +2676 -2629
  86. package/jTemplates.js.map +1 -1
  87. package/package.json +1 -1
  88. package/web.d.ts +1 -1
  89. package/web.export.d.ts +4 -4
  90. package/web.export.js +24 -24
  91. package/web.js +5 -5
package/Node/boundNode.js CHANGED
@@ -1,94 +1,99 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BoundNode = void 0;
4
- const nodeConfig_1 = require("./nodeConfig");
5
- const observableScope_1 = require("../Store/Tree/observableScope");
6
- var BoundNode;
7
- (function (BoundNode) {
8
- function Init(boundNode) {
9
- const nodeDef = boundNode.nodeDef;
10
- if (nodeDef.props) {
11
- const scope = observableScope_1.ObservableScope.Create(nodeDef.props);
12
- boundNode.destroyables.push(CreateScopeDestroyable(scope));
13
- observableScope_1.ObservableScope.Watch(scope, function (scope) { ScheduleSetProperties(boundNode, scope); });
14
- SetProperties(boundNode, observableScope_1.ObservableScope.Value(scope));
15
- }
16
- if (nodeDef.attrs) {
17
- const scope = observableScope_1.ObservableScope.Create(nodeDef.attrs);
18
- boundNode.destroyables.push(CreateScopeDestroyable(scope));
19
- observableScope_1.ObservableScope.Watch(scope, function (scope) { ScheduleSetAttributes(boundNode, scope); });
20
- SetAttributes(boundNode, observableScope_1.ObservableScope.Value(scope));
21
- }
22
- if (nodeDef.on) {
23
- const scope = observableScope_1.ObservableScope.Create(nodeDef.on);
24
- boundNode.destroyables.push(CreateScopeDestroyable(scope));
25
- observableScope_1.ObservableScope.Watch(scope, function (scope) { ScheduleSetEvents(boundNode, scope); });
26
- SetEvents(boundNode, observableScope_1.ObservableScope.Value(scope));
27
- }
28
- }
29
- BoundNode.Init = Init;
30
- })(BoundNode = exports.BoundNode || (exports.BoundNode = {}));
31
- function CreateScopeDestroyable(scope) {
32
- return {
33
- Destroy() {
34
- observableScope_1.ObservableScope.Destroy(scope);
35
- }
36
- };
37
- }
38
- function ScheduleSetProperties(node, scope) {
39
- if (node.setProperties)
40
- return;
41
- node.setProperties = true;
42
- nodeConfig_1.NodeConfig.scheduleUpdate(function () {
43
- node.setProperties = false;
44
- if (node.destroyed)
45
- return;
46
- SetProperties(node, observableScope_1.ObservableScope.Value(scope));
47
- });
48
- }
49
- function SetProperties(node, properties) {
50
- if (!properties)
51
- return;
52
- nodeConfig_1.NodeConfig.setProperties(node.node, node.lastProperties, properties);
53
- node.lastProperties = properties;
54
- }
55
- function ScheduleSetAttributes(node, scope) {
56
- if (node.setAttributes)
57
- return;
58
- node.setAttributes = true;
59
- nodeConfig_1.NodeConfig.scheduleUpdate(function () {
60
- node.setAttributes = false;
61
- if (node.destroyed)
62
- return;
63
- SetAttributes(node, observableScope_1.ObservableScope.Value(scope));
64
- });
65
- }
66
- function SetAttributes(node, attributes) {
67
- if (!attributes)
68
- return;
69
- for (var key in attributes) {
70
- var val = nodeConfig_1.NodeConfig.getAttribute(node.node, key);
71
- if (val !== attributes[key])
72
- nodeConfig_1.NodeConfig.setAttribute(node.node, key, attributes[key]);
73
- }
74
- }
75
- function ScheduleSetEvents(node, scope) {
76
- if (node.setEvents)
77
- return;
78
- node.setEvents = true;
79
- nodeConfig_1.NodeConfig.scheduleUpdate(function () {
80
- node.setEvents = false;
81
- if (node.destroyed)
82
- return;
83
- SetEvents(node, observableScope_1.ObservableScope.Value(scope));
84
- });
85
- }
86
- function SetEvents(node, events) {
87
- if (!events)
88
- return;
89
- for (var key in node.lastEvents)
90
- nodeConfig_1.NodeConfig.removeListener(node.node, key, node.lastEvents[key]);
91
- for (var key in events)
92
- nodeConfig_1.NodeConfig.addListener(node.node, key, events[key]);
93
- node.lastEvents = events;
94
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BoundNode = void 0;
4
+ const nodeConfig_1 = require("./nodeConfig");
5
+ const observableScope_1 = require("../Store/Tree/observableScope");
6
+ var BoundNode;
7
+ (function (BoundNode) {
8
+ function Init(boundNode) {
9
+ const nodeDef = boundNode.nodeDef;
10
+ if (nodeDef.props) {
11
+ const scope = observableScope_1.ObservableScope.Create(nodeDef.props);
12
+ boundNode.destroyables.push(CreateScopeDestroyable(scope));
13
+ observableScope_1.ObservableScope.Watch(scope, function (scope) { ScheduleSetProperties(boundNode, scope); });
14
+ SetProperties(boundNode, observableScope_1.ObservableScope.Value(scope));
15
+ }
16
+ if (nodeDef.attrs) {
17
+ const scope = observableScope_1.ObservableScope.Create(nodeDef.attrs);
18
+ boundNode.destroyables.push(CreateScopeDestroyable(scope));
19
+ observableScope_1.ObservableScope.Watch(scope, function (scope) { ScheduleSetAttributes(boundNode, scope); });
20
+ SetAttributes(boundNode, observableScope_1.ObservableScope.Value(scope));
21
+ }
22
+ if (nodeDef.on) {
23
+ const scope = observableScope_1.ObservableScope.Create(nodeDef.on);
24
+ boundNode.destroyables.push(CreateScopeDestroyable(scope));
25
+ boundNode.destroyables.push({
26
+ Destroy() {
27
+ SetEvents(boundNode, {});
28
+ }
29
+ });
30
+ observableScope_1.ObservableScope.Watch(scope, function (scope) { ScheduleSetEvents(boundNode, scope); });
31
+ SetEvents(boundNode, observableScope_1.ObservableScope.Value(scope));
32
+ }
33
+ }
34
+ BoundNode.Init = Init;
35
+ })(BoundNode || (exports.BoundNode = BoundNode = {}));
36
+ function CreateScopeDestroyable(scope) {
37
+ return {
38
+ Destroy() {
39
+ observableScope_1.ObservableScope.Destroy(scope);
40
+ }
41
+ };
42
+ }
43
+ function ScheduleSetProperties(node, scope) {
44
+ if (node.setProperties)
45
+ return;
46
+ node.setProperties = true;
47
+ nodeConfig_1.NodeConfig.scheduleUpdate(function () {
48
+ node.setProperties = false;
49
+ if (node.destroyed)
50
+ return;
51
+ SetProperties(node, observableScope_1.ObservableScope.Value(scope));
52
+ });
53
+ }
54
+ function SetProperties(node, properties) {
55
+ if (!properties)
56
+ return;
57
+ nodeConfig_1.NodeConfig.setProperties(node.node, node.lastProperties, properties);
58
+ node.lastProperties = properties;
59
+ }
60
+ function ScheduleSetAttributes(node, scope) {
61
+ if (node.setAttributes)
62
+ return;
63
+ node.setAttributes = true;
64
+ nodeConfig_1.NodeConfig.scheduleUpdate(function () {
65
+ node.setAttributes = false;
66
+ if (node.destroyed)
67
+ return;
68
+ SetAttributes(node, observableScope_1.ObservableScope.Value(scope));
69
+ });
70
+ }
71
+ function SetAttributes(node, attributes) {
72
+ if (!attributes)
73
+ return;
74
+ for (var key in attributes) {
75
+ var val = nodeConfig_1.NodeConfig.getAttribute(node.node, key);
76
+ if (val !== attributes[key])
77
+ nodeConfig_1.NodeConfig.setAttribute(node.node, key, attributes[key]);
78
+ }
79
+ }
80
+ function ScheduleSetEvents(node, scope) {
81
+ if (node.setEvents)
82
+ return;
83
+ node.setEvents = true;
84
+ nodeConfig_1.NodeConfig.scheduleUpdate(function () {
85
+ node.setEvents = false;
86
+ if (node.destroyed)
87
+ return;
88
+ SetEvents(node, observableScope_1.ObservableScope.Value(scope));
89
+ });
90
+ }
91
+ function SetEvents(node, events) {
92
+ if (!events)
93
+ return;
94
+ for (var key in node.lastEvents)
95
+ nodeConfig_1.NodeConfig.removeListener(node.node, key, node.lastEvents[key]);
96
+ for (var key in events)
97
+ nodeConfig_1.NodeConfig.addListener(node.node, key, events[key]);
98
+ node.lastEvents = events;
99
+ }
@@ -1,43 +1,43 @@
1
- import { NodeRefType } from "./nodeRef";
2
- import { INodeRefBase } from "./nodeRef.types";
3
- export type FunctionOr<T> = {
4
- (...args: Array<any>): T | Promise<T>;
5
- } | T;
6
- export type NodeRefEvents = {
7
- [name: string]: {
8
- (...args: Array<any>): void;
9
- };
10
- };
11
- export interface NodeDefinition<T = any, E = any> {
12
- type: any;
13
- namespace: string;
14
- props?: FunctionOr<{
15
- [name: string]: any;
16
- }>;
17
- attrs?: FunctionOr<{
18
- [name: string]: string;
19
- }>;
20
- on?: FunctionOr<NodeRefEvents>;
21
- }
22
- export interface BoundNodeFunctionParam {
23
- props?: FunctionOr<{
24
- [name: string]: any;
25
- }>;
26
- attrs?: FunctionOr<{
27
- [name: string]: string;
28
- }>;
29
- on?: FunctionOr<NodeRefEvents>;
30
- }
31
- export interface IBoundNodeBase extends INodeRefBase {
32
- nodeDef: BoundNodeFunctionParam;
33
- lastProperties: any;
34
- lastEvents: {
35
- [name: string]: any;
36
- };
37
- setProperties: boolean;
38
- setAttributes: boolean;
39
- setEvents: boolean;
40
- }
41
- export interface IBoundNode extends IBoundNodeBase {
42
- type: NodeRefType.BoundNode;
43
- }
1
+ import { NodeRefType } from "./nodeRef";
2
+ import { INodeRefBase } from "./nodeRef.types";
3
+ export type FunctionOr<T> = {
4
+ (...args: Array<any>): T | Promise<T>;
5
+ } | T;
6
+ export type NodeRefEvents = {
7
+ [name: string]: {
8
+ (...args: Array<any>): void;
9
+ };
10
+ };
11
+ export interface NodeDefinition<T = any, E = any> {
12
+ type: any;
13
+ namespace: string;
14
+ props?: FunctionOr<{
15
+ [name: string]: any;
16
+ }>;
17
+ attrs?: FunctionOr<{
18
+ [name: string]: string;
19
+ }>;
20
+ on?: FunctionOr<NodeRefEvents>;
21
+ }
22
+ export interface BoundNodeFunctionParam {
23
+ props?: FunctionOr<{
24
+ [name: string]: any;
25
+ }>;
26
+ attrs?: FunctionOr<{
27
+ [name: string]: string;
28
+ }>;
29
+ on?: FunctionOr<NodeRefEvents>;
30
+ }
31
+ export interface IBoundNodeBase extends INodeRefBase {
32
+ nodeDef: BoundNodeFunctionParam;
33
+ lastProperties: any;
34
+ lastEvents: {
35
+ [name: string]: any;
36
+ };
37
+ setProperties: boolean;
38
+ setAttributes: boolean;
39
+ setEvents: boolean;
40
+ }
41
+ export interface IBoundNode extends IBoundNodeBase {
42
+ type: NodeRefType.BoundNode;
43
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,34 +1,34 @@
1
- import { ComponentNodeEvents } from "./componentNode.types";
2
- import { ObservableScope } from "../Store/Tree/observableScope";
3
- import { INodeRefBase, NodeRefTypes } from "./nodeRef.types";
4
- export declare class Component<D = void, T = void, E = void> {
5
- private nodeRef;
6
- private componentEvents;
7
- private scope;
8
- private templates;
9
- private decoratorMap;
10
- get Injector(): import("../Utils/injector").Injector;
11
- get Destroyed(): boolean;
12
- get DecoratorMap(): Map<string, any>;
13
- protected get Scope(): ObservableScope<D>;
14
- protected get Data(): D;
15
- protected get NodeRef(): INodeRefBase;
16
- protected get Templates(): T;
17
- constructor(data: D | {
18
- (): D | Promise<D>;
19
- }, templates: T, nodeRef: INodeRefBase, componentEvents: ComponentNodeEvents<E>);
20
- Template(): NodeRefTypes | NodeRefTypes[];
21
- Bound(): void;
22
- Fire<P extends keyof E>(event: P, data?: E[P]): void;
23
- Destroy(): void;
24
- }
25
- export declare namespace Component {
26
- function ToFunction<D = void, T = void, E = void>(type: any, namespace: any, constructor: ComponentConstructor<D, T, E>): import("./componentNode.types").ComponentNodeFunction<D, T, E>;
27
- function Register<D = void, T = void, E = void>(name: string, constructor: ComponentConstructor<D, T, E>): void;
28
- function Attach(node: Node, nodeRef: NodeRefTypes): void;
29
- }
30
- export type ComponentConstructor<D, T, E> = {
31
- new (data: {
32
- (): D | Promise<D>;
33
- }, templates: T, nodeRef: INodeRefBase, componentEvents: ComponentNodeEvents<E>): Component<D, T, E>;
34
- };
1
+ import { ComponentNodeEvents } from "./componentNode.types";
2
+ import { ObservableScope } from "../Store/Tree/observableScope";
3
+ import { INodeRefBase, NodeRefTypes } from "./nodeRef.types";
4
+ export declare class Component<D = void, T = void, E = void> {
5
+ private nodeRef;
6
+ private componentEvents;
7
+ private scope;
8
+ private templates;
9
+ private decoratorMap;
10
+ get Injector(): import("../Utils/injector").Injector;
11
+ get Destroyed(): boolean;
12
+ get DecoratorMap(): Map<string, any>;
13
+ protected get Scope(): ObservableScope<D>;
14
+ protected get Data(): D;
15
+ protected get NodeRef(): INodeRefBase;
16
+ protected get Templates(): T;
17
+ constructor(data: D | {
18
+ (): D | Promise<D>;
19
+ }, templates: T, nodeRef: INodeRefBase, componentEvents: ComponentNodeEvents<E>);
20
+ Template(): NodeRefTypes | NodeRefTypes[];
21
+ Bound(): void;
22
+ Fire<P extends keyof E>(event: P, data?: E[P]): void;
23
+ Destroy(): void;
24
+ }
25
+ export declare namespace Component {
26
+ function ToFunction<D = void, T = void, E = void>(type: any, namespace: any, constructor: ComponentConstructor<D, T, E>): import("./componentNode.types").ComponentNodeFunction<D, T, E>;
27
+ function Register<D = void, T = void, E = void>(name: string, constructor: ComponentConstructor<D, T, E>): void;
28
+ function Attach(node: Node, nodeRef: NodeRefTypes): void;
29
+ }
30
+ export type ComponentConstructor<D, T, E> = {
31
+ new (data: {
32
+ (): D | Promise<D>;
33
+ }, templates: T, nodeRef: INodeRefBase, componentEvents: ComponentNodeEvents<E>): Component<D, T, E>;
34
+ };
package/Node/component.js CHANGED
@@ -1,80 +1,80 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Component = void 0;
4
- const nodeRef_1 = require("./nodeRef");
5
- const componentNode_1 = require("./componentNode");
6
- const decorators_1 = require("../Utils/decorators");
7
- const observableScope_1 = require("../Store/Tree/observableScope");
8
- class Component {
9
- nodeRef;
10
- componentEvents;
11
- scope;
12
- templates;
13
- decoratorMap;
14
- get Injector() {
15
- return this.nodeRef.injector;
16
- }
17
- get Destroyed() {
18
- return this.nodeRef.destroyed;
19
- }
20
- get DecoratorMap() {
21
- return this.decoratorMap;
22
- }
23
- get Scope() {
24
- return this.scope;
25
- }
26
- get Data() {
27
- return this.scope.Value;
28
- }
29
- get NodeRef() {
30
- return this.nodeRef;
31
- }
32
- get Templates() {
33
- return this.templates;
34
- }
35
- constructor(data, templates, nodeRef, componentEvents) {
36
- this.nodeRef = nodeRef;
37
- this.componentEvents = componentEvents;
38
- this.scope = new observableScope_1.ObservableScope(data);
39
- this.templates = templates || {};
40
- this.decoratorMap = new Map();
41
- }
42
- Template() {
43
- return [];
44
- }
45
- Bound() {
46
- }
47
- Fire(event, data) {
48
- var eventCallback = this.componentEvents && this.componentEvents[event];
49
- eventCallback && eventCallback(data);
50
- }
51
- Destroy() {
52
- decorators_1.Destroy.All(this);
53
- }
54
- }
55
- exports.Component = Component;
56
- (function (Component) {
57
- function ToFunction(type, namespace, constructor) {
58
- return componentNode_1.ComponentNode.ToFunction(type, namespace, constructor);
59
- }
60
- Component.ToFunction = ToFunction;
61
- function Register(name, constructor) {
62
- const componentFunction = ToFunction(`${name}-component`, undefined, constructor);
63
- class WebComponent extends HTMLElement {
64
- constructor() {
65
- super();
66
- const shadowRoot = this.attachShadow({ mode: 'open' });
67
- const node = componentFunction({});
68
- Attach(shadowRoot, node);
69
- }
70
- }
71
- customElements.define(name, WebComponent);
72
- }
73
- Component.Register = Register;
74
- function Attach(node, nodeRef) {
75
- nodeRef_1.NodeRef.Init(nodeRef);
76
- var rootRef = nodeRef_1.NodeRef.Wrap(node);
77
- nodeRef_1.NodeRef.AddChild(rootRef, nodeRef);
78
- }
79
- Component.Attach = Attach;
80
- })(Component = exports.Component || (exports.Component = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Component = void 0;
4
+ const nodeRef_1 = require("./nodeRef");
5
+ const componentNode_1 = require("./componentNode");
6
+ const decorators_1 = require("../Utils/decorators");
7
+ const observableScope_1 = require("../Store/Tree/observableScope");
8
+ class Component {
9
+ nodeRef;
10
+ componentEvents;
11
+ scope;
12
+ templates;
13
+ decoratorMap;
14
+ get Injector() {
15
+ return this.nodeRef.injector;
16
+ }
17
+ get Destroyed() {
18
+ return this.nodeRef.destroyed;
19
+ }
20
+ get DecoratorMap() {
21
+ return this.decoratorMap;
22
+ }
23
+ get Scope() {
24
+ return this.scope;
25
+ }
26
+ get Data() {
27
+ return this.scope.Value;
28
+ }
29
+ get NodeRef() {
30
+ return this.nodeRef;
31
+ }
32
+ get Templates() {
33
+ return this.templates;
34
+ }
35
+ constructor(data, templates, nodeRef, componentEvents) {
36
+ this.nodeRef = nodeRef;
37
+ this.componentEvents = componentEvents;
38
+ this.scope = new observableScope_1.ObservableScope(data);
39
+ this.templates = templates || {};
40
+ this.decoratorMap = new Map();
41
+ }
42
+ Template() {
43
+ return [];
44
+ }
45
+ Bound() {
46
+ }
47
+ Fire(event, data) {
48
+ var eventCallback = this.componentEvents && this.componentEvents[event];
49
+ eventCallback && eventCallback(data);
50
+ }
51
+ Destroy() {
52
+ decorators_1.Destroy.All(this);
53
+ }
54
+ }
55
+ exports.Component = Component;
56
+ (function (Component) {
57
+ function ToFunction(type, namespace, constructor) {
58
+ return componentNode_1.ComponentNode.ToFunction(type, namespace, constructor);
59
+ }
60
+ Component.ToFunction = ToFunction;
61
+ function Register(name, constructor) {
62
+ const componentFunction = ToFunction(`${name}-component`, undefined, constructor);
63
+ class WebComponent extends HTMLElement {
64
+ constructor() {
65
+ super();
66
+ const shadowRoot = this.attachShadow({ mode: 'open' });
67
+ const node = componentFunction({});
68
+ Attach(shadowRoot, node);
69
+ }
70
+ }
71
+ customElements.define(name, WebComponent);
72
+ }
73
+ Component.Register = Register;
74
+ function Attach(node, nodeRef) {
75
+ nodeRef_1.NodeRef.Init(nodeRef);
76
+ var rootRef = nodeRef_1.NodeRef.Wrap(node);
77
+ nodeRef_1.NodeRef.AddChild(rootRef, nodeRef);
78
+ }
79
+ Component.Attach = Attach;
80
+ })(Component || (exports.Component = Component = {}));
@@ -1,7 +1,7 @@
1
- import { ComponentConstructor } from "./component";
2
- import { ComponentNodeFunction, IComponentNodeBase } from "./componentNode.types";
3
- export declare namespace ComponentNode {
4
- function Fire<E, P extends keyof E>(event: P, data?: E[P]): void;
5
- function ToFunction<D = void, T = void, E = void>(type: any, namespace: string, constructor: ComponentConstructor<D, T, E>): ComponentNodeFunction<D, T, E>;
6
- function Init(componentNode: IComponentNodeBase<any, any, any>): void;
7
- }
1
+ import { ComponentConstructor } from "./component";
2
+ import { ComponentNodeFunction, IComponentNodeBase } from "./componentNode.types";
3
+ export declare namespace ComponentNode {
4
+ function Fire<E, P extends keyof E>(event: P, data?: E[P]): void;
5
+ function ToFunction<D = void, T = void, E = void>(type: any, namespace: string, constructor: ComponentConstructor<D, T, E>): ComponentNodeFunction<D, T, E>;
6
+ function Init(componentNode: IComponentNodeBase<any, any, any>): void;
7
+ }