@ibyar/core 0.5.62 → 0.6.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/annotation/decorators.d.ts +24 -0
- package/annotation/decorators.js.map +1 -1
- package/binding/binding.expressions.d.ts +4 -4
- package/binding/binding.expressions.js +3 -15
- package/binding/binding.expressions.js.map +1 -1
- package/component/component.d.ts +3 -0
- package/component/component.js.map +1 -1
- package/component/custom-element.d.ts +6 -4
- package/component/custom-element.js.map +1 -1
- package/component/events.js +2 -6
- package/component/events.js.map +1 -1
- package/directive/providers.js +3 -3
- package/directive/providers.js.map +1 -1
- package/html/expression.js +1 -1
- package/html/expression.js.map +1 -1
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/linker/change-detector-ref.d.ts +12 -3
- package/linker/change-detector-ref.js +27 -18
- package/linker/change-detector-ref.js.map +1 -1
- package/linker/template-ref.d.ts +5 -5
- package/linker/template-ref.js +21 -20
- package/linker/template-ref.js.map +1 -1
- package/linker/view-container-ref.d.ts +73 -19
- package/linker/view-container-ref.js +81 -31
- package/linker/view-container-ref.js.map +1 -1
- package/linker/view-ref.d.ts +10 -5
- package/linker/view-ref.js +23 -9
- package/linker/view-ref.js.map +1 -1
- package/package.json +9 -5
- package/pipe/pipe.js +4 -4
- package/pipe/pipe.js.map +1 -1
- package/render/host-listener.handler.js +3 -3
- package/render/host-listener.handler.js.map +1 -1
- package/view/base-view.js +40 -19
- package/view/base-view.js.map +1 -1
- package/view/render.d.ts +9 -9
- package/view/render.js +10 -26
- package/view/render.js.map +1 -1
- package/view/view.js +1 -0
- package/view/view.js.map +1 -1
- package/zone/bootstrap.d.ts +21 -0
- package/zone/bootstrap.js +35 -0
- package/zone/bootstrap.js.map +1 -0
- package/zone/proxy.d.ts +15 -0
- package/zone/proxy.js +32 -0
- package/zone/proxy.js.map +1 -0
- package/zone/task.d.ts +61 -0
- package/zone/task.js +109 -0
- package/zone/task.js.map +1 -0
- package/zone/zone.d.ts +49 -0
- package/zone/zone.js +198 -0
- package/zone/zone.js.map +1 -0
- package/component/provider.d.ts +0 -10
- package/component/provider.js +0 -17
- package/component/provider.js.map +0 -1
package/linker/view-ref.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ReactiveScopeControl, Context, ScopeSubscription } from '@ibyar/expressions';
|
|
2
|
+
import { ChangeDetectorRef } from './change-detector-ref.js';
|
|
3
|
+
export declare abstract class ViewRef extends ChangeDetectorRef {
|
|
3
4
|
/**
|
|
4
5
|
* Destroys this view and all of the data structures associated with it.
|
|
5
6
|
*/
|
|
@@ -55,12 +56,12 @@ export declare abstract class EmbeddedViewRef<C extends object> extends ViewRef
|
|
|
55
56
|
abstract detach(): void;
|
|
56
57
|
}
|
|
57
58
|
export declare class EmbeddedViewRefImpl<C extends object> extends EmbeddedViewRef<C> {
|
|
58
|
-
private
|
|
59
|
+
private _scope;
|
|
59
60
|
private _rootNodes;
|
|
60
61
|
private _subscriptions?;
|
|
61
62
|
private _destroyed;
|
|
62
|
-
private
|
|
63
|
-
constructor(
|
|
63
|
+
private _onDestroySubscribes;
|
|
64
|
+
constructor(_scope: ReactiveScopeControl<C>, _rootNodes: Node[], _subscriptions?: ScopeSubscription<Context>[] | undefined);
|
|
64
65
|
get context(): C;
|
|
65
66
|
get rootNodes(): Node[];
|
|
66
67
|
get first(): Element;
|
|
@@ -71,6 +72,10 @@ export declare class EmbeddedViewRefImpl<C extends object> extends EmbeddedViewR
|
|
|
71
72
|
after(node: ChildNode): void;
|
|
72
73
|
before(node: ChildNode): void;
|
|
73
74
|
detach(): void;
|
|
75
|
+
reattach(): void;
|
|
76
|
+
markForCheck(): void;
|
|
77
|
+
detectChanges(): void;
|
|
78
|
+
checkNoChanges(): void;
|
|
74
79
|
onDestroy(callback: () => void): {
|
|
75
80
|
unsubscribe(): void;
|
|
76
81
|
};
|
package/linker/view-ref.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { ChangeDetectorRef } from './change-detector-ref.js';
|
|
2
|
+
export class ViewRef extends ChangeDetectorRef {
|
|
2
3
|
}
|
|
3
4
|
export class EmbeddedViewRef extends ViewRef {
|
|
4
5
|
}
|
|
5
6
|
export class EmbeddedViewRefImpl extends EmbeddedViewRef {
|
|
6
|
-
constructor(
|
|
7
|
+
constructor(_scope, _rootNodes, _subscriptions) {
|
|
7
8
|
super();
|
|
8
|
-
this.
|
|
9
|
+
this._scope = _scope;
|
|
9
10
|
this._rootNodes = _rootNodes;
|
|
10
11
|
this._subscriptions = _subscriptions;
|
|
11
12
|
this._destroyed = false;
|
|
12
|
-
this.
|
|
13
|
+
this._onDestroySubscribes = [];
|
|
13
14
|
}
|
|
14
15
|
get context() {
|
|
15
|
-
return this.
|
|
16
|
+
return this._scope.getContext();
|
|
16
17
|
}
|
|
17
18
|
get rootNodes() {
|
|
18
19
|
return this._rootNodes;
|
|
@@ -33,7 +34,7 @@ export class EmbeddedViewRefImpl extends EmbeddedViewRef {
|
|
|
33
34
|
for (const node of this._rootNodes) {
|
|
34
35
|
node.remove();
|
|
35
36
|
}
|
|
36
|
-
this.
|
|
37
|
+
this._onDestroySubscribes.forEach(callback => {
|
|
37
38
|
try {
|
|
38
39
|
callback();
|
|
39
40
|
}
|
|
@@ -62,14 +63,27 @@ export class EmbeddedViewRefImpl extends EmbeddedViewRef {
|
|
|
62
63
|
for (const node of this._rootNodes) {
|
|
63
64
|
node.remove();
|
|
64
65
|
}
|
|
66
|
+
this._scope.detach();
|
|
67
|
+
}
|
|
68
|
+
reattach() {
|
|
69
|
+
this._scope.emitChanges();
|
|
70
|
+
}
|
|
71
|
+
markForCheck() {
|
|
72
|
+
this._scope.emitChanges();
|
|
73
|
+
}
|
|
74
|
+
detectChanges() {
|
|
75
|
+
this._scope.detectChanges();
|
|
76
|
+
}
|
|
77
|
+
checkNoChanges() {
|
|
78
|
+
this._scope.checkNoChanges();
|
|
65
79
|
}
|
|
66
80
|
onDestroy(callback) {
|
|
67
|
-
this.
|
|
81
|
+
this._onDestroySubscribes.push(callback);
|
|
68
82
|
return {
|
|
69
83
|
unsubscribe: () => {
|
|
70
|
-
const index = this.
|
|
84
|
+
const index = this._onDestroySubscribes.indexOf(callback);
|
|
71
85
|
if (index > -1) {
|
|
72
|
-
this.
|
|
86
|
+
this._onDestroySubscribes.splice(index, 1);
|
|
73
87
|
}
|
|
74
88
|
}
|
|
75
89
|
};
|
package/linker/view-ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-ref.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,OAAgB,OAAQ,SAAQ,iBAAiB;CAmBtD;AAGD,MAAM,OAAgB,eAAkC,SAAQ,OAAO;CAwCtE;AAED,MAAM,OAAO,mBAAsC,SAAQ,eAAkB;IAK5E,YACS,MAA+B,EAC/B,UAAkB,EAClB,cAA6C;QACrD,KAAK,EAAE,CAAC;QAHA,WAAM,GAAN,MAAM,CAAyB;QAC/B,eAAU,GAAV,UAAU,CAAQ;QAClB,mBAAc,GAAd,cAAc,CAA+B;QAN9C,eAAU,GAAY,KAAK,CAAC;QAC5B,yBAAoB,GAAmB,EAAE,CAAC;IAOlD,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACjC,CAAC;IAED,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IACD,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAY,CAAC;IACtC,CAAC;IACD,IAAI,IAAI;QACP,OAAO,IAAI,C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Ae;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,MAAM;QACL,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;YACzB,IAAK,CAAC,MAAM,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;IACD,QAAQ;QACP,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;IACD,YAAY;QACX,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;IACD,aAAa;QACZ,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IACD,cAAc;QACb,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IAC9B,CAAC;IACD,SAAS,CAAC,QAAoB;QAC7B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO;YACN,WAAW,EAAE,GAAG,EAAE;gBACjB,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;oBACf,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBAC3C;YACF,CAAC;SACD,CAAC;IACH,CAAC;CAED","sourcesContent":["import { ReactiveScopeControl, Context, ScopeSubscription } from '@ibyar/expressions';\nimport { ChangeDetectorRef } from './change-detector-ref.js';\n\nexport abstract class ViewRef extends ChangeDetectorRef {\n\t/**\n\t * Destroys this view and all of the data structures associated with it.\n\t */\n\tabstract destroy(): void;\n\n\t/**\n\t * Reports whether this view has been destroyed.\n\t * @returns True after the `destroy()` method has been called, false otherwise.\n\t */\n\tabstract get destroyed(): boolean;\n\n\t/**\n\t * A lifecycle hook that provides additional developer-defined cleanup\n\t * functionality for views.\n\t * @param callback A handler function that cleans up developer-defined data\n\t * associated with a view. Called when the `destroy()` method is invoked.\n\t */\n\tabstract onDestroy(callback: Function): { unsubscribe(): void };\n}\n\n\nexport abstract class EmbeddedViewRef<C extends object> extends ViewRef {\n\t/**\n\t * The context for this view, inherited from the anchor element.\n\t */\n\tabstract get context(): C;\n\n\t/**\n\t * The root nodes for this embedded view.\n\t */\n\tabstract get rootNodes(): Node[];\n\n\t/**\n\t * the first node for this embedded view.\n\t */\n\tabstract get first(): ChildNode;\n\n\t/**\n\t * the last node for this embedded view.\n\t */\n\tabstract get last(): ChildNode;\n\n\t/**\n\t * insert view after the node.\n\t * @param node \n\t */\n\tabstract after(node: ChildNode): void;\n\n\t/**\n\t * insert view before the node.\n\t * @param node \n\t */\n\tabstract before(node: ChildNode): void;\n\n\t/**\n\t * remove the root nodes from the view, but keep reference to them.\n\t * \n\t * Detaches a view from this container without destroying it.\n\t * Use along with after()/before() to move a view within the current container.\n\t */\n\tabstract detach(): void;\n}\n\nexport class EmbeddedViewRefImpl<C extends object> extends EmbeddedViewRef<C> {\n\n\tprivate _destroyed: boolean = false;\n\tprivate _onDestroySubscribes: (() => void)[] = [];\n\n\tconstructor(\n\t\tprivate _scope: ReactiveScopeControl<C>,\n\t\tprivate _rootNodes: Node[],\n\t\tprivate _subscriptions?: ScopeSubscription<Context>[]) {\n\t\tsuper();\n\t}\n\n\tget context(): C {\n\t\treturn this._scope.getContext();\n\t}\n\n\tget rootNodes(): Node[] {\n\t\treturn this._rootNodes;\n\t}\n\tget first(): Element {\n\t\treturn this._rootNodes[0] as Element;\n\t}\n\tget last(): Element {\n\t\treturn this._rootNodes[this._rootNodes.length - 1] as Element;\n\t}\n\tget destroyed(): boolean {\n\t\treturn this._destroyed;\n\t}\n\tdestroy(): void {\n\t\tif (!this._destroyed) {\n\t\t\tthis._subscriptions?.forEach(sub => sub.unsubscribe());\n\t\t\tthis._subscriptions?.splice(0, this._subscriptions.length);\n\t\t\tfor (const node of this._rootNodes) {\n\t\t\t\t(<Element>node).remove();\n\t\t\t}\n\t\t\tthis._onDestroySubscribes.forEach(callback => {\n\t\t\t\ttry {\n\t\t\t\t\tcallback();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._destroyed = true;\n\t\t}\n\t}\n\tprivate getAsANode() {\n\t\tif (this._rootNodes.length == 1) {\n\t\t\treturn this._rootNodes[0];\n\t\t}\n\t\tconst fragment = document.createDocumentFragment();\n\t\tthis._rootNodes.forEach(node => fragment.append(node));\n\t\treturn fragment;\n\t}\n\tafter(node: ChildNode): void {\n\t\tnode.after(this.getAsANode());\n\t}\n\tbefore(node: ChildNode): void {\n\t\tnode.before(this.getAsANode());\n\t}\n\tdetach(): void {\n\t\tfor (const node of this._rootNodes) {\n\t\t\t(<Element>node).remove();\n\t\t}\n\t\tthis._scope.detach();\n\t}\n\treattach(): void {\n\t\tthis._scope.emitChanges();\n\t}\n\tmarkForCheck(): void {\n\t\tthis._scope.emitChanges();\n\t}\n\tdetectChanges(): void {\n\t\tthis._scope.detectChanges();\n\t}\n\tcheckNoChanges(): void {\n\t\tthis._scope.checkNoChanges();\n\t}\n\tonDestroy(callback: () => void): { unsubscribe(): void; } {\n\t\tthis._onDestroySubscribes.push(callback);\n\t\treturn {\n\t\t\tunsubscribe: () => {\n\t\t\t\tconst index = this._onDestroySubscribes.indexOf(callback);\n\t\t\t\tif (index > -1) {\n\t\t\t\t\tthis._onDestroySubscribes.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibyar/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Implements Aurora's core functionality, low-level services, and utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ibyar/aurora/tree/dev/packages/core",
|
|
@@ -23,11 +23,14 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@ibyar/elements": "^0.
|
|
27
|
-
"@ibyar/expressions": "^0.
|
|
26
|
+
"@ibyar/elements": "^0.6.0",
|
|
27
|
+
"@ibyar/expressions": "^0.6.0",
|
|
28
28
|
"reflect-metadata": "^0.1.13",
|
|
29
29
|
"tslib": "^2.4.0"
|
|
30
30
|
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"zone.js": "^0.11.6"
|
|
33
|
+
},
|
|
31
34
|
"devDependencies": {
|
|
32
35
|
"typescript": "^4.7.4"
|
|
33
36
|
},
|
|
@@ -60,7 +63,8 @@
|
|
|
60
63
|
"elements-info",
|
|
61
64
|
"element",
|
|
62
65
|
"interceptor",
|
|
63
|
-
"typescript"
|
|
66
|
+
"typescript",
|
|
67
|
+
"front-end"
|
|
64
68
|
],
|
|
65
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "543b42bc87e268480e497c5e25c0215641d2c252"
|
|
66
70
|
}
|
package/pipe/pipe.js
CHANGED
|
@@ -14,7 +14,7 @@ export class PipeProvider extends ReadOnlyScope {
|
|
|
14
14
|
super({});
|
|
15
15
|
}
|
|
16
16
|
has(pipeName) {
|
|
17
|
-
if (pipeName in this.
|
|
17
|
+
if (pipeName in this._ctx) {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
const pipeRef = ClassRegistryProvider.getPipe(pipeName);
|
|
@@ -22,14 +22,14 @@ export class PipeProvider extends ReadOnlyScope {
|
|
|
22
22
|
}
|
|
23
23
|
get(pipeName) {
|
|
24
24
|
let transformFunc;
|
|
25
|
-
if (transformFunc = this.
|
|
25
|
+
if (transformFunc = this._ctx[pipeName]) {
|
|
26
26
|
return transformFunc;
|
|
27
27
|
}
|
|
28
28
|
const pipeRef = ClassRegistryProvider.getPipe(pipeName);
|
|
29
29
|
if (pipeRef !== undefined && !pipeRef.asynchronous) {
|
|
30
30
|
const pipe = new pipeRef.modelClass();
|
|
31
31
|
transformFunc = (value, ...args) => pipe.transform(value, ...args);
|
|
32
|
-
this.
|
|
32
|
+
this._ctx[pipeRef.name] = transformFunc;
|
|
33
33
|
return transformFunc;
|
|
34
34
|
}
|
|
35
35
|
return void 0;
|
|
@@ -81,7 +81,7 @@ export class AsyncPipeScope extends ReactiveScopeControl {
|
|
|
81
81
|
}
|
|
82
82
|
unsubscribe(propertyKey, subscription) {
|
|
83
83
|
super.unsubscribe(propertyKey, subscription);
|
|
84
|
-
const pipe = this.
|
|
84
|
+
const pipe = this._ctx[propertyKey];
|
|
85
85
|
pipe.onDestroy();
|
|
86
86
|
}
|
|
87
87
|
getClass() {
|
package/pipe/pipe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../../src/core/pipe/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAqB,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAcjE,MAAM,OAAgB,kBAAkB;IACvC,YAAsB,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAI,CAAC;CAG/D;AAED,MAAM,UAAU,eAAe,CAA+B,IAAS;IACtE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,OAAO,YAAa,SAAQ,aAA+C;IAChF;QACC,KAAK,CAAC,EAAE,CAAC,CAAC;IACX,CAAC;IACD,GAAG,CAAC,QAAgB;QACnB,IAAI,QAAQ,IAAI,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../../src/core/pip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,CAAC;QACtD,IAAI,MAAM,EAAE;YACX,IAAI,CAAC,OAAO,CAAC,WAAqB,CAAC,GAAG,CAAC,KAAU,EAAE,GAAG,IAAW,EAAE,EAAE;gBACpE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAA;YACtC,CAAC,CAAC;SACF;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IACQ,GAAG,CAAC,WAAoB;QAChC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC;IACQ,WAAW,CAAC,WAAoB,EAAE,YAAmC;QAC7E,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;IACD,QAAQ;QACP,OAAO,cAAc,CAAC;IACvB,CAAC;CACD","sourcesContent":["import { ReactiveScopeControl, ReadOnlyScope, ScopeSubscription } from '@ibyar/expressions';\nimport { OnDestroy } from '../component/lifecycle.js';\nimport { ChangeDetectorRef, createChangeDetectorRef } from '../linker/change-detector-ref.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { TypeOf } from '../utils/typeof.js';\n\n/**\n * Pipes are used as singleton\n * it will be created if it needed, had no life cycle\n * \n * * no dependency injection applied on filters for now,\n * TODO: add support of dependency injection\n */\nexport interface PipeTransform<T, U> {\n\ttransform(value: T, ...args: any[]): U;\n}\n\nexport abstract class AsyncPipeTransform<T, U> implements PipeTransform<T, U>, OnDestroy {\n\tconstructor(protected changeDetectorRef: ChangeDetectorRef) { }\n\tabstract transform(value: T, ...args: any[]): U;\n\tabstract onDestroy(): void;\n}\n\nexport function isPipeTransform<T extends any, U extends any>(pipe: any): pipe is PipeTransform<T, U> {\n\treturn Reflect.has(Object.getPrototypeOf(pipe), 'transform');\n}\n\nexport class PipeProvider extends ReadOnlyScope<{ [pipeName: string]: Function }> {\n\tconstructor() {\n\t\tsuper({});\n\t}\n\thas(pipeName: string): boolean {\n\t\tif (pipeName in this._ctx) {\n\t\t\treturn true;\n\t\t}\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<PipeTransform<any, any>>(pipeName);\n\t\treturn pipeRef !== undefined && !pipeRef.asynchronous;\n\t}\n\tget(pipeName: string): any {\n\t\tlet transformFunc: Function | undefined;\n\t\tif (transformFunc = this._ctx[pipeName]) {\n\t\t\treturn transformFunc;\n\t\t}\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<PipeTransform<any, any>>(pipeName);\n\t\tif (pipeRef !== undefined && !pipeRef.asynchronous) {\n\t\t\tconst pipe = new pipeRef.modelClass();\n\t\t\ttransformFunc = (value: any, ...args: any[]) => pipe.transform(value, ...args);\n\t\t\tthis._ctx[pipeRef.name] = transformFunc;\n\t\t\treturn transformFunc;\n\t\t}\n\t\treturn void 0;\n\t}\n\tgetClass(): TypeOf<PipeProvider> {\n\t\treturn PipeProvider;\n\t}\n}\n\nexport class AsyncPipeProvider extends ReadOnlyScope<object> {\n\tconstructor() {\n\t\tsuper({});\n\t}\n\thas(pipeName: string): boolean {\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<AsyncPipeTransform<any, any>>(pipeName);\n\t\treturn pipeRef?.asynchronous ? true : false;\n\t}\n\tget(pipeName: string): TypeOf<AsyncPipeTransform<any, any>> | undefined {\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<AsyncPipeTransform<any, any>>(pipeName);\n\t\tif (pipeRef?.asynchronous) {\n\t\t\treturn pipeRef.modelClass;\n\t\t}\n\t\treturn;\n\t}\n\tgetClass(): TypeOf<AsyncPipeProvider> {\n\t\treturn AsyncPipeProvider;\n\t}\n}\n\nexport class AsyncPipeScope<T extends { [key: string]: AsyncPipeTransform<any, any> }> extends ReactiveScopeControl<T> {\n\tstatic blockScope<P extends { [key: string]: AsyncPipeTransform<any, any> }>(): AsyncPipeScope<P> {\n\t\treturn new AsyncPipeScope();\n\t}\n\tprivate wrapper: { [key: string]: Function } = {};\n\tconstructor() {\n\t\tsuper({} as T);\n\t}\n\toverride set(propertyKey: keyof T, pipeClass: TypeOf<AsyncPipeTransform<any, any>>, receiver?: any): boolean {\n\t\tconst detector = createChangeDetectorRef(this, propertyKey);\n\t\tconst pipe = new pipeClass(detector);\n\t\tconst result = super.set(propertyKey, pipe, receiver);\n\t\tif (result) {\n\t\t\tthis.wrapper[propertyKey as string] = (value: any, ...args: any[]) => {\n\t\t\t\treturn pipe.transform(value, ...args)\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t}\n\toverride get(propertyKey: keyof T): any {\n\t\treturn Reflect.get(this.wrapper, propertyKey);\n\t}\n\toverride unsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tsuper.unsubscribe(propertyKey, subscription);\n\t\tconst pipe = this._ctx[propertyKey];\n\t\tpipe.onDestroy();\n\t}\n\tgetClass(): TypeOf<AsyncPipeScope<T>> {\n\t\treturn AsyncPipeScope;\n\t}\n}\n"]}
|
|
@@ -22,12 +22,12 @@ export class HostListenerHandler {
|
|
|
22
22
|
this.element = element;
|
|
23
23
|
this.elementScope = elementScope;
|
|
24
24
|
this.listener = (event) => {
|
|
25
|
-
const
|
|
26
|
-
if (typeof
|
|
25
|
+
const callback = this.element._model[this.listenerRef.modelCallbackName];
|
|
26
|
+
if (typeof callback === 'function') {
|
|
27
27
|
const eventScope = this.stack.pushBlockScopeFor({ $event: event });
|
|
28
28
|
const params = this.argumentsExpression.get(this.stack);
|
|
29
29
|
this.stack.clearTo(eventScope);
|
|
30
|
-
|
|
30
|
+
this.element._zone.run(callback, this.element._model, params);
|
|
31
31
|
typeof event.preventDefault === 'function' && event.preventDefault();
|
|
32
32
|
}
|
|
33
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-listener.handler.js","sourceRoot":"","sources":["../../../src/core/render/host-listener.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,gBAAgB,EAAoC,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAOhH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,mBAAmB;
|
|
1
|
+
{"version":3,"file":"host-listener.handler.js","sourceRoot":"","sources":["../../../src/core/render/host-listener.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,gBAAgB,EAAoC,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAOhH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,mBAAmB;IA0B/B,YAAoB,WAAwB,EAAU,OAA2B,EAAU,YAAyC;QAAhH,gBAAW,GAAX,WAAW,CAAa;QAAU,YAAO,GAAP,OAAO,CAAoB;QAAU,iBAAY,GAAZ,YAAY,CAA6B;QAf5H,aAAQ,GAAG,CAAC,KAAY,EAAE,EAAE;YACnC,MAAM,QAAQ,GAAyB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;YAC/F,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;gBACnC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;gBACnE,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC/B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CACrB,QAAsB,EACtB,IAAI,CAAC,OAAO,CAAC,MAAM,EACnB,MAAM,CACN,CAAC;gBACF,OAAO,KAAK,CAAC,cAAc,KAAK,UAAU,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;aACrE;QACF,CAAC,CAAC;QAGD,IAAI,CAAC,KAAK,GAAG,IAAI,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,CAAC,SAAS,CAAC;YAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;SAC3B;QACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACzB,CAAC;IAEO,gBAAgB;QACvB,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB;QAC1B,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,SAAS;QACR,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,YAAY;QACX,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,SAAS;QACR,IAAI,CAAC,iBAAiB,EAAE,WAAW,EAAE,CAAC;QACtC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC5B,CAAC;CAED","sourcesContent":["import { ArrayExpression, JavaScriptParser, ReactiveScope, ScopeSubscription, Stack } from '@ibyar/expressions';\nimport { ListenerRef } from '../component/component.js';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { RenderHandler } from './render-handler.js';\n\ntype ElementScope = { [element: string]: HTMLElement };\n\n/**\n * ```ts\n * class View {\n * \n *\t@HostListener('window:load', ['$event.target', '\"load\"'])\n * \t@HostListener('click', ['$event.target', '\"click\"'])\n * \tpublic onClick(target: any, type: string){\n * \t\tconsole.log(target, type);\n * \t}\n * }\n * ```\n * \n * window.addEventListener('load', $event => listener($event.target, 'load'));\n * \n * view.addEventListener('click', $event => listener($event.target, 'click'));\n * \n */\nexport class HostListenerHandler implements RenderHandler {\n\n\tprivate source: HTMLElement | Window;\n\tprivate eventName: string;\n\n\tprivate argumentsExpression: ArrayExpression;\n\tprivate stack: Stack;\n\n\tprivate scopeSubscription?: ScopeSubscription<ElementScope>;\n\n\n\tprivate listener = (event: Event) => {\n\t\tconst callback: Function | undefined = this.element._model[this.listenerRef.modelCallbackName];\n\t\tif (typeof callback === 'function') {\n\t\t\tconst eventScope = this.stack.pushBlockScopeFor({ $event: event });\n\t\t\tconst params = this.argumentsExpression.get(this.stack);\n\t\t\tthis.stack.clearTo(eventScope);\n\t\t\tthis.element._zone.run(\n\t\t\t\tcallback as () => void,\n\t\t\t\tthis.element._model,\n\t\t\t\tparams\n\t\t\t);\n\t\t\ttypeof event.preventDefault === 'function' && event.preventDefault();\n\t\t}\n\t};\n\n\tconstructor(private listenerRef: ListenerRef, private element: HTMLComponent<any>, private elementScope: ReactiveScope<ElementScope>) {\n\t\tthis.stack = new Stack(elementScope);\n\t}\n\tonInit(): void {\n\t\tconst args = this.listenerRef.args ?? [];\n\t\tconst array = `[${args.join(', ')}]`;\n\t\tthis.argumentsExpression = JavaScriptParser.parseScript(array) as ArrayExpression;\n\t\tif (this.listenerRef.eventName.includes(':')) {\n\t\t\tconst [eventSource, eventName] = this.listenerRef.eventName.split(':', 2);\n\t\t\tthis.eventName = eventName;\n\t\t\tif ('window' === eventSource.toLowerCase()) {\n\t\t\t\tthis.source = window;\n\t\t\t} else {\n\t\t\t\tlet source = this.elementScope.get(eventSource) as HTMLElement;\n\t\t\t\tthis.scopeSubscription = this.elementScope.subscribe(eventSource, (newValue: HTMLElement) => {\n\t\t\t\t\tif (source !== newValue) {\n\t\t\t\t\t\tif (source) {\n\t\t\t\t\t\t\tthis.removeEventListener();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!newValue) {\n\t\t\t\t\t\tthis.removeEventListener();\n\t\t\t\t\t}\n\t\t\t\t\tsource = newValue;\n\t\t\t\t\tthis.addEventListener();\n\t\t\t\t});\n\t\t\t\tthis.source = source;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.eventName = this.listenerRef.eventName;\n\t\t\tthis.source = this.element;\n\t\t}\n\t\tthis.addEventListener();\n\t}\n\n\tprivate addEventListener() {\n\t\tthis.source?.addEventListener(this.eventName, this.listener);\n\t}\n\n\tprivate removeEventListener() {\n\t\tthis.source?.removeEventListener(this.eventName, this.listener);\n\t}\n\n\tonConnect() {\n\t\tthis.scopeSubscription?.resume();\n\t}\n\n\tonDisconnect() {\n\t\tthis.scopeSubscription?.pause();\n\t}\n\n\tonDestroy(): void {\n\t\tthis.scopeSubscription?.unsubscribe();\n\t\tthis.removeEventListener();\n\t}\n\n}\n"]}
|
package/view/base-view.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ReactiveScope } from '@ibyar/expressions';
|
|
1
|
+
import { ReactiveScope, ReactiveScopeControl } from '@ibyar/expressions';
|
|
2
2
|
import { isAfterContentChecked, isAfterContentInit, isAfterViewChecked, isAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit } from '../component/lifecycle.js';
|
|
3
3
|
import { ComponentRender } from './render.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getCurrentZone } from '../zone/bootstrap.js';
|
|
5
|
+
import { createModelChangeDetectorRef } from '../linker/change-detector-ref.js';
|
|
5
6
|
const FACTORY_CACHE = new WeakMap();
|
|
6
7
|
export function baseFactoryView(htmlElementType) {
|
|
7
8
|
if (FACTORY_CACHE.has(htmlElementType)) {
|
|
@@ -11,9 +12,10 @@ export function baseFactoryView(htmlElementType) {
|
|
|
11
12
|
constructor(componentRef, modelClass) {
|
|
12
13
|
super();
|
|
13
14
|
this.subscriptions = [];
|
|
15
|
+
this.onDestroyCalls = [];
|
|
14
16
|
this.doBlockCallback = () => {
|
|
15
17
|
if (isDoCheck(this._model)) {
|
|
16
|
-
this._model.doCheck
|
|
18
|
+
this._zone.run(this._model.doCheck, this._model);
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
21
|
this._componentRef = componentRef;
|
|
@@ -23,13 +25,18 @@ export function baseFactoryView(htmlElementType) {
|
|
|
23
25
|
delegatesFocus: componentRef.shadowDomDelegatesFocus
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
|
-
const
|
|
28
|
+
const args = []; /* resolve dependency injection*/
|
|
29
|
+
const detector = createModelChangeDetectorRef(() => this._modelScope);
|
|
30
|
+
args.push(detector);
|
|
31
|
+
this._zone = getCurrentZone(componentRef.zone).fork();
|
|
32
|
+
args.push(this._zone);
|
|
33
|
+
const model = new modelClass(...args);
|
|
27
34
|
this._model = model;
|
|
28
|
-
const modelScope =
|
|
29
|
-
|
|
35
|
+
const modelScope = ReactiveScopeControl.for(model);
|
|
36
|
+
modelScope.getContextProxy = () => model;
|
|
30
37
|
this._modelScope = modelScope;
|
|
31
38
|
this._viewScope = ReactiveScope.for({ 'this': this });
|
|
32
|
-
const elementScope = this._viewScope.
|
|
39
|
+
const elementScope = this._viewScope.getInnerScope('this');
|
|
33
40
|
componentRef.inputs.forEach(input => {
|
|
34
41
|
elementScope.subscribe(input.viewAttribute, (newValue, oldValue) => {
|
|
35
42
|
if (newValue === oldValue) {
|
|
@@ -142,7 +149,7 @@ export function baseFactoryView(htmlElementType) {
|
|
|
142
149
|
return;
|
|
143
150
|
}
|
|
144
151
|
if (isOnChanges(this._model)) {
|
|
145
|
-
this._model.onChanges
|
|
152
|
+
this._zone.run(this._model.onChanges, this._model);
|
|
146
153
|
}
|
|
147
154
|
this.doBlockCallback();
|
|
148
155
|
}
|
|
@@ -151,6 +158,8 @@ export function baseFactoryView(htmlElementType) {
|
|
|
151
158
|
this.subscriptions.forEach(sub => sub.unsubscribe());
|
|
152
159
|
}
|
|
153
160
|
this.subscriptions.splice(0, this.subscriptions.length);
|
|
161
|
+
const cds = this._zone.onEmpty.subscribe(() => this._modelScope.detectChanges());
|
|
162
|
+
this.onDestroy(() => cds.unsubscribe());
|
|
154
163
|
this._componentRef.inputs.forEach(input => {
|
|
155
164
|
const inputDefaultValue = this._model[input.modelProperty];
|
|
156
165
|
if (inputDefaultValue !== null && inputDefaultValue !== undefined) {
|
|
@@ -162,19 +171,19 @@ export function baseFactoryView(htmlElementType) {
|
|
|
162
171
|
attrs.forEach(attr => this.initOuterAttribute(attr));
|
|
163
172
|
}
|
|
164
173
|
if (isOnChanges(this._model)) {
|
|
165
|
-
this._model.onChanges
|
|
174
|
+
this._zone.run(this._model.onChanges, this._model);
|
|
166
175
|
}
|
|
167
176
|
if (isOnInit(this._model)) {
|
|
168
|
-
this._model.onInit
|
|
177
|
+
this._zone.run(this._model.onInit, this._model);
|
|
169
178
|
}
|
|
170
179
|
if (isDoCheck(this._model)) {
|
|
171
|
-
this._model.doCheck
|
|
180
|
+
this._zone.run(this._model.doCheck, this._model);
|
|
172
181
|
}
|
|
173
182
|
if (isAfterContentInit(this._model)) {
|
|
174
|
-
this._model.afterContentInit
|
|
183
|
+
this._zone.run(this._model.afterContentInit, this._model);
|
|
175
184
|
}
|
|
176
185
|
if (isAfterContentChecked(this._model)) {
|
|
177
|
-
this._model.afterContentChecked
|
|
186
|
+
this._zone.run(this._model.afterContentChecked, this._model);
|
|
178
187
|
}
|
|
179
188
|
// do once
|
|
180
189
|
if (this.childNodes.length === 0) {
|
|
@@ -184,20 +193,20 @@ export function baseFactoryView(htmlElementType) {
|
|
|
184
193
|
this._render.initHostListener();
|
|
185
194
|
}
|
|
186
195
|
if (isAfterViewInit(this._model)) {
|
|
187
|
-
this._model.afterViewInit
|
|
196
|
+
this._zone.run(this._model.afterViewInit, this._model);
|
|
188
197
|
}
|
|
189
198
|
if (isAfterViewChecked(this._model)) {
|
|
190
|
-
this._model.afterViewChecked
|
|
199
|
+
this._zone.run(this._model.afterViewChecked, this._model);
|
|
191
200
|
}
|
|
192
201
|
this.doBlockCallback = () => {
|
|
193
202
|
if (isDoCheck(this._model)) {
|
|
194
|
-
this._model.doCheck
|
|
203
|
+
this._zone.run(this._model.doCheck, this._model);
|
|
195
204
|
}
|
|
196
205
|
if (isAfterContentChecked(this._model)) {
|
|
197
|
-
this._model.afterContentChecked
|
|
206
|
+
this._zone.run(this._model.afterContentChecked, this._model);
|
|
198
207
|
}
|
|
199
208
|
if (isAfterViewChecked(this._model)) {
|
|
200
|
-
this._model.afterViewChecked
|
|
209
|
+
this._zone.run(this._model.afterViewChecked, this._model);
|
|
201
210
|
}
|
|
202
211
|
};
|
|
203
212
|
}
|
|
@@ -238,6 +247,9 @@ export function baseFactoryView(htmlElementType) {
|
|
|
238
247
|
this.setInputValue(attr.name, attr.value);
|
|
239
248
|
}
|
|
240
249
|
}
|
|
250
|
+
onDestroy(callback) {
|
|
251
|
+
this.onDestroyCalls.push(callback);
|
|
252
|
+
}
|
|
241
253
|
adoptedCallback() {
|
|
242
254
|
// restart the process
|
|
243
255
|
this.innerHTML = '';
|
|
@@ -246,10 +258,19 @@ export function baseFactoryView(htmlElementType) {
|
|
|
246
258
|
disconnectedCallback() {
|
|
247
259
|
// notify first, then call model.onDestroy func
|
|
248
260
|
if (isOnDestroy(this._model)) {
|
|
249
|
-
this._model.onDestroy
|
|
261
|
+
this._zone.run(this._model.onDestroy, this._model);
|
|
250
262
|
}
|
|
251
263
|
this.subscriptions.forEach(sub => sub.unsubscribe());
|
|
252
264
|
this.subscriptions.splice(0, this.subscriptions.length);
|
|
265
|
+
this.onDestroyCalls.forEach(callback => {
|
|
266
|
+
try {
|
|
267
|
+
callback();
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
console.error(error);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
this.onDestroyCalls.splice(0, this.onDestroyCalls.length);
|
|
253
274
|
}
|
|
254
275
|
// events api
|
|
255
276
|
addEventListener(eventName, listener, options) {
|
package/view/base-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmC,MAAM,oBAAoB,CAAC;AACpF,OAAO,EACN,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAC7D,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAC9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AI,WAAW,EAAE;gBAChB,WAAW,CAAC,SAAS,CAAC,CAAC,IAAS,EAAE,EAAE;oBAClC,QAAqB,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;aACH;QACF,CAAC;QAED,aAAa,CAAC,SAAiB,EAAE,KAAW;YAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACxD,IAAI,UAAU,EAAE;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO;aACP;QACF,CAAC;KACD;IAAA,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope, ScopeContext, ScopeSubscription } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef, PropertyRef } from '../component/component.js';\nimport { BaseComponent, CustomElement, HTMLComponent, ModelType } from '../component/custom-element.js';\nimport { EventEmitter } from '../component/events.js';\nimport { ComponentRender } from './render.js';\nimport { ElementModelReactiveScope } from '../component/provider.js';\n\nconst FACTORY_CACHE = new WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>>();\n\nexport function baseFactoryView<T extends object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\n\tif (FACTORY_CACHE.has(htmlElementType)) {\n\t\treturn FACTORY_CACHE.get(htmlElementType) as TypeOf<HTMLComponent<T>>;\n\t}\n\tclass CustomView extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: ModelType<T>;\n\t\t_proxyModel: T;\n\t\t_parentComponent: HTMLComponent<object>;\n\t\t_render: ComponentRender<T>;\n\t\t_shadowRoot: ShadowRoot;\n\n\t\t_componentRef: ComponentRef<T>;\n\n\t\t_modelScope: ReactiveScope<T>;\n\t\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\n\t\tprivate subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper();\n\t\t\tthis._componentRef = componentRef;\n\t\t\tif (componentRef.isShadowDom) {\n\t\t\t\tthis._shadowRoot = this.attachShadow({\n\t\t\t\t\tmode: componentRef.shadowDomMode,\n\t\t\t\t\tdelegatesFocus: componentRef.shadowDomDelegatesFocus\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst model = new modelClass(/* resolve dependency injection*/);\n\t\t\tthis._model = model;\n\n\t\t\tconst modelScope = ElementModelReactiveScope.for(model);\n\t\t\tthis._proxyModel = modelScope.getContextProxy();\n\t\t\tthis._modelScope = modelScope;\n\n\t\t\tthis._viewScope = ReactiveScope.for<{ 'this': BaseComponent<T> }>({ 'this': this });\n\t\t\tconst elementScope = this._viewScope.getScopeOrCreat('this');\n\t\t\tcomponentRef.inputs.forEach(input => {\n\t\t\t\telementScope.subscribe(input.viewAttribute as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis._modelScope.set(input.modelProperty as any, newValue);\n\t\t\t\t});\n\t\t\t\tthis._modelScope.subscribe(input.modelProperty as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telementScope.emit(input.viewAttribute as any, newValue, oldValue);\n\t\t\t\t});\n\t\t\t});\n\n\n\t\t\t// if property of the model has view decorator\n\t\t\tif (this._componentRef.view) {\n\t\t\t\tReflect.set(this._model, this._componentRef.view, this);\n\t\t\t}\n\t\t\tthis._render = new ComponentRender(this, this.subscriptions);\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t}\n\t\t};\n\n\t\tgetComponentRef(): ComponentRef<T> {\n\t\t\treturn this._componentRef;\n\t\t}\n\n\t\tsetParentComponent(parent: HTMLComponent<any>): void {\n\t\t\tthis._parentComponent = parent;\n\t\t}\n\n\t\tgetParentComponent(): HTMLComponent<any> {\n\t\t\treturn this._parentComponent;\n\t\t}\n\n\t\thasParentComponent(): boolean {\n\t\t\treturn this._parentComponent ? true : false;\n\t\t}\n\n\t\thasInputStartWith(viewProp: string): boolean {\n\t\t\tlet dotIndex = viewProp.indexOf('.');\n\t\t\tif (dotIndex > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, dotIndex);\n\t\t\t}\n\t\t\treturn this.hasInput(viewProp);\n\t\t}\n\n\t\tgetInputStartWith(viewProp: string): PropertyRef | undefined {\n\t\t\tlet index = viewProp.indexOf('.');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\tindex = viewProp.indexOf('[');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\treturn this.getInput(viewProp);\n\t\t}\n\n\t\thasInput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.inputs.some(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.inputs.find(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInputValue(viewProp: string): any {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\treturn this._model[inputRef.modelProperty];\n\t\t\t}\n\t\t}\n\n\t\tsetInputValue(viewProp: PropertyKey, value: any): void {\n\t\t\tconst inputRef = this.getInput(viewProp as string);\n\t\t\tif (inputRef) {\n\t\t\t\tthis._modelScope.set(inputRef.modelProperty as never, value);\n\t\t\t}\n\t\t}\n\n\t\thasOutput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.outputs.some(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetOutput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.outputs.find(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined {\n\t\t\tconst outputRef = this.getOutput(viewProp);\n\t\t\tif (outputRef) {\n\t\t\t\treturn this._model[outputRef.modelProperty] as EventEmitter<V>;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\thasProp(propName: string): boolean {\n\t\t\treturn Reflect.has(this._model, propName);\n\t\t}\n\n\t\tprivate setAttributeHelper(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t}\n\t\t\telse if (typeof value === 'boolean') {\n\t\t\t\tif (value) {\n\t\t\t\t\tsuper.setAttribute(attrViewName, '');\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.setAttribute(attrViewName, value);\n\t\t\t}\n\t\t}\n\n\t\tsetAttribute(attrViewName: string, value: any): void {\n\t\t\tthis.setInputValue(attrViewName, value);\n\t\t\tthis.setAttributeHelper(attrViewName, value);\n\t\t}\n\n\t\tgetAttribute(attrViewName: string): string | null {\n\t\t\treturn this.getInputValue(attrViewName) ?? super.getAttribute(attrViewName);\n\t\t}\n\n\t\tattributeChangedCallback(name: string, oldValue: string, newValue: string) {\n\t\t\tif (newValue === oldValue) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\t\t\tif (this.subscriptions.length) {\n\t\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\t}\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tthis._componentRef.inputs.forEach(input => {\n\t\t\t\tconst inputDefaultValue = this._model[input.modelProperty];\n\t\t\t\tif (inputDefaultValue !== null && inputDefaultValue !== undefined) {\n\t\t\t\t\tthis.setAttributeHelper(input.viewAttribute, inputDefaultValue);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t\tlet attrs: Attr[] = Array.prototype.slice.call(this.attributes);\n\t\t\t\tattrs.forEach(attr => this.initOuterAttribute(attr));\n\t\t\t}\n\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._model.onInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._model.afterContentInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t}\n\n\t\t\t// do once\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\t// setup ui view\n\t\t\t\tthis._render.initView();\n\n\t\t\t\t// init Host Listener events\n\t\t\t\tthis._render.initHostListener();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._model.afterViewInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\n\t\tinitOuterAttribute(attr: Attr) {\n\t\t\t// [window, this] scop\n\t\t\tlet elementAttr = attr.name;\n\t\t\tlet modelProperty = attr.value;\n\t\t\tif (elementAttr.startsWith('[')) {\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\tif (Reflect.has(window, modelProperty)) {\n\t\t\t\t\tthis.setInputValue(elementAttr, Reflect.get(window, modelProperty));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (elementAttr.startsWith('(')) {\n\t\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\t// this.handleEvent(element, elementAttr, viewProperty);\n\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\tlet callback: Function = Reflect.get(window, modelProperty);\n\t\t\t\tthis.addEventListener(elementAttr, event => {\n\t\t\t\t\tcallback(event);\n\t\t\t\t});\n\t\t\t} else if (elementAttr.startsWith('on')) {\n\t\t\t\tconst modelEvent = this.getEventEmitter<any>(elementAttr.substring(2));\n\t\t\t\tif (modelEvent) {\n\t\t\t\t\t// modelEvent.subscribe(listener);\n\t\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\t\tlet listener: Function = Reflect.get(window, modelProperty);\n\t\t\t\t\tmodelEvent.subscribe((data: any) => {\n\t\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.setInputValue(attr.name, attr.value);\n\t\t\t}\n\t\t}\n\n\t\tadoptedCallback() {\n\t\t\t// restart the process\n\t\t\tthis.innerHTML = '';\n\t\t\tthis.connectedCallback();\n\t\t}\n\t\tdisconnectedCallback() {\n\t\t\t// notify first, then call model.onDestroy func\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._model.onDestroy.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t}\n\n\t\t// events api\n\t\taddEventListener(eventName: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void {\n\t\t\tif ('on' + eventName in this) {\n\t\t\t\tsuper.addEventListener(eventName, (event: Event) => {\n\t\t\t\t\t(listener as Function)(event);\n\t\t\t\t}, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst modelOutput = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelOutput) {\n\t\t\t\tmodelOutput.subscribe((data: any) => {\n\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\ttriggerOutput(eventName: string, value?: any): void {\n\t\t\tconst modelEvent = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelEvent) {\n\t\t\t\tmodelEvent.emit(value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\tFACTORY_CACHE.set(htmlElementType, CustomView);\n\treturn CustomView;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAA8B,MAAM,oBAAoB,CAAC;AACrG,OAAO,EACN,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAC7D,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAC9D,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAA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CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACzD,IAAI,WAAW,EAAE;gBAChB,WAAW,CAAC,SAAS,CAAC,CAAC,IAAS,EAAE,EAAE;oBAClC,QAAqB,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;aACH;QACF,CAAC;QAED,aAAa,CAAC,SAAiB,EAAE,KAAW;YAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACxD,IAAI,UAAU,EAAE;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO;aACP;QACF,CAAC;KACD;IAAA,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope, ReactiveScopeControl, Context, ScopeSubscription } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef, PropertyRef } from '../component/component.js';\nimport { BaseComponent, CustomElement, HTMLComponent, ModelType } from '../component/custom-element.js';\nimport { EventEmitter } from '../component/events.js';\nimport { ComponentRender } from './render.js';\nimport { getCurrentZone } from '../zone/bootstrap.js';\nimport { AuroraZone } from '../zone/zone.js';\nimport { createModelChangeDetectorRef } from '../linker/change-detector-ref.js';\n\nconst FACTORY_CACHE = new WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>>();\n\nexport function baseFactoryView<T extends object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\n\tif (FACTORY_CACHE.has(htmlElementType)) {\n\t\treturn FACTORY_CACHE.get(htmlElementType) as TypeOf<HTMLComponent<T>>;\n\t}\n\tclass CustomView extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: ModelType<T>;\n\t\t_parentComponent: HTMLComponent<object>;\n\t\t_render: ComponentRender<T>;\n\t\t_shadowRoot: ShadowRoot;\n\n\t\t_componentRef: ComponentRef<T>;\n\n\t\t_modelScope: ReactiveScopeControl<T>;\n\t\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\t\t_zone: AuroraZone;\n\n\t\tprivate subscriptions: ScopeSubscription<Context>[] = [];\n\t\tprivate onDestroyCalls: (() => void)[] = [];\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper();\n\t\t\tthis._componentRef = componentRef;\n\t\t\tif (componentRef.isShadowDom) {\n\t\t\t\tthis._shadowRoot = this.attachShadow({\n\t\t\t\t\tmode: componentRef.shadowDomMode,\n\t\t\t\t\tdelegatesFocus: componentRef.shadowDomDelegatesFocus\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst args = []; /* resolve dependency injection*/\n\t\t\tconst detector = createModelChangeDetectorRef(() => this._modelScope);\n\t\t\targs.push(detector)\n\t\t\tthis._zone = getCurrentZone(componentRef.zone).fork();\n\t\t\targs.push(this._zone);\n\t\t\tconst model = new modelClass(...args);\n\t\t\tthis._model = model;\n\n\t\t\tconst modelScope = ReactiveScopeControl.for(model);\n\t\t\tmodelScope.getContextProxy = () => model;\n\t\t\tthis._modelScope = modelScope;\n\n\t\t\tthis._viewScope = ReactiveScope.for<{ 'this': BaseComponent<T> }>({ 'this': this });\n\t\t\tconst elementScope = this._viewScope.getInnerScope<ReactiveScope<BaseComponent<T>>>('this')!;\n\t\t\tcomponentRef.inputs.forEach(input => {\n\t\t\t\telementScope.subscribe(input.viewAttribute as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis._modelScope.set(input.modelProperty as any, newValue);\n\t\t\t\t});\n\t\t\t\tthis._modelScope.subscribe(input.modelProperty as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telementScope.emit(input.viewAttribute as any, newValue, oldValue);\n\t\t\t\t});\n\t\t\t});\n\n\n\t\t\t// if property of the model has view decorator\n\t\t\tif (this._componentRef.view) {\n\t\t\t\tReflect.set(this._model, this._componentRef.view, this);\n\t\t\t}\n\t\t\tthis._render = new ComponentRender(this, this.subscriptions);\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._zone.run(this._model.doCheck, this._model);\n\t\t\t}\n\t\t};\n\n\t\tgetComponentRef(): ComponentRef<T> {\n\t\t\treturn this._componentRef;\n\t\t}\n\n\t\tsetParentComponent(parent: HTMLComponent<any>): void {\n\t\t\tthis._parentComponent = parent;\n\t\t}\n\n\t\tgetParentComponent(): HTMLComponent<any> {\n\t\t\treturn this._parentComponent;\n\t\t}\n\n\t\thasParentComponent(): boolean {\n\t\t\treturn this._parentComponent ? true : false;\n\t\t}\n\n\t\thasInputStartWith(viewProp: string): boolean {\n\t\t\tlet dotIndex = viewProp.indexOf('.');\n\t\t\tif (dotIndex > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, dotIndex);\n\t\t\t}\n\t\t\treturn this.hasInput(viewProp);\n\t\t}\n\n\t\tgetInputStartWith(viewProp: string): PropertyRef | undefined {\n\t\t\tlet index = viewProp.indexOf('.');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\tindex = viewProp.indexOf('[');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\treturn this.getInput(viewProp);\n\t\t}\n\n\t\thasInput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.inputs.some(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.inputs.find(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInputValue(viewProp: string): any {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\treturn this._model[inputRef.modelProperty];\n\t\t\t}\n\t\t}\n\n\t\tsetInputValue(viewProp: PropertyKey, value: any): void {\n\t\t\tconst inputRef = this.getInput(viewProp as string);\n\t\t\tif (inputRef) {\n\t\t\t\tthis._modelScope.set(inputRef.modelProperty as never, value);\n\t\t\t}\n\t\t}\n\n\t\thasOutput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.outputs.some(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetOutput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.outputs.find(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined {\n\t\t\tconst outputRef = this.getOutput(viewProp);\n\t\t\tif (outputRef) {\n\t\t\t\treturn this._model[outputRef.modelProperty] as EventEmitter<V>;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\thasProp(propName: string): boolean {\n\t\t\treturn Reflect.has(this._model, propName);\n\t\t}\n\n\t\tprivate setAttributeHelper(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t}\n\t\t\telse if (typeof value === 'boolean') {\n\t\t\t\tif (value) {\n\t\t\t\t\tsuper.setAttribute(attrViewName, '');\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.setAttribute(attrViewName, value);\n\t\t\t}\n\t\t}\n\n\t\tsetAttribute(attrViewName: string, value: any): void {\n\t\t\tthis.setInputValue(attrViewName, value);\n\t\t\tthis.setAttributeHelper(attrViewName, value);\n\t\t}\n\n\t\tgetAttribute(attrViewName: string): string | null {\n\t\t\treturn this.getInputValue(attrViewName) ?? super.getAttribute(attrViewName);\n\t\t}\n\n\t\tattributeChangedCallback(name: string, oldValue: string, newValue: string) {\n\t\t\tif (newValue === oldValue) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onChanges, this._model);\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\t\t\tif (this.subscriptions.length) {\n\t\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\t}\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tconst cds = this._zone.onEmpty.subscribe(() => this._modelScope.detectChanges());\n\t\t\tthis.onDestroy(() => cds.unsubscribe());\n\t\t\tthis._componentRef.inputs.forEach(input => {\n\t\t\t\tconst inputDefaultValue = this._model[input.modelProperty];\n\t\t\t\tif (inputDefaultValue !== null && inputDefaultValue !== undefined) {\n\t\t\t\t\tthis.setAttributeHelper(input.viewAttribute, inputDefaultValue);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t\tlet attrs: Attr[] = Array.prototype.slice.call(this.attributes);\n\t\t\t\tattrs.forEach(attr => this.initOuterAttribute(attr));\n\t\t\t}\n\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onChanges, this._model);\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onInit, this._model);\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._zone.run(this._model.doCheck, this._model);\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterContentInit, this._model);\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterContentChecked, this._model);\n\t\t\t}\n\n\t\t\t// do once\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\t// setup ui view\n\t\t\t\tthis._render.initView();\n\n\t\t\t\t// init Host Listener events\n\t\t\t\tthis._render.initHostListener();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterViewInit, this._model);\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterViewChecked, this._model);\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.doCheck, this._model);\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.afterContentChecked, this._model);\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.afterViewChecked, this._model);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\n\t\tinitOuterAttribute(attr: Attr) {\n\t\t\t// [window, this] scop\n\t\t\tlet elementAttr = attr.name;\n\t\t\tlet modelProperty = attr.value;\n\t\t\tif (elementAttr.startsWith('[')) {\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\tif (Reflect.has(window, modelProperty)) {\n\t\t\t\t\tthis.setInputValue(elementAttr, Reflect.get(window, modelProperty));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (elementAttr.startsWith('(')) {\n\t\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\t// this.handleEvent(element, elementAttr, viewProperty);\n\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\tlet callback: Function = Reflect.get(window, modelProperty);\n\t\t\t\tthis.addEventListener(elementAttr, event => {\n\t\t\t\t\tcallback(event);\n\t\t\t\t});\n\t\t\t} else if (elementAttr.startsWith('on')) {\n\t\t\t\tconst modelEvent = this.getEventEmitter<any>(elementAttr.substring(2));\n\t\t\t\tif (modelEvent) {\n\t\t\t\t\t// modelEvent.subscribe(listener);\n\t\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\t\tlet listener: Function = Reflect.get(window, modelProperty);\n\t\t\t\t\tmodelEvent.subscribe((data: any) => {\n\t\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.setInputValue(attr.name, attr.value);\n\t\t\t}\n\t\t}\n\t\tonDestroy(callback: () => void) {\n\t\t\tthis.onDestroyCalls.push(callback);\n\t\t}\n\t\tadoptedCallback() {\n\t\t\t// restart the process\n\t\t\tthis.innerHTML = '';\n\t\t\tthis.connectedCallback();\n\t\t}\n\t\tdisconnectedCallback() {\n\t\t\t// notify first, then call model.onDestroy func\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onDestroy, this._model);\n\t\t\t}\n\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tthis.onDestroyCalls.forEach(callback => {\n\t\t\t\ttry {\n\t\t\t\t\tcallback();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.onDestroyCalls.splice(0, this.onDestroyCalls.length);\n\t\t}\n\n\t\t// events api\n\t\taddEventListener(eventName: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void {\n\t\t\tif ('on' + eventName in this) {\n\t\t\t\tsuper.addEventListener(eventName, (event: Event) => {\n\t\t\t\t\t(listener as Function)(event);\n\t\t\t\t}, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst modelOutput = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelOutput) {\n\t\t\t\tmodelOutput.subscribe((data: any) => {\n\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\ttriggerOutput(eventName: string, value?: any): void {\n\t\t\tconst modelEvent = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelEvent) {\n\t\t\t\tmodelEvent.emit(value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\tFACTORY_CACHE.set(htmlElementType, CustomView);\n\treturn CustomView;\n}\n"]}
|
package/view/render.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context, ScopeSubscription, Stack } from '@ibyar/expressions';
|
|
2
2
|
import { CommentNode, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, DomNode, LiveTextContent, TextContent, DomAttributeDirectiveNode } from '@ibyar/elements';
|
|
3
3
|
import { HTMLComponent } from '../component/custom-element.js';
|
|
4
4
|
import { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';
|
|
@@ -10,25 +10,25 @@ export declare class ComponentRender<T extends object> {
|
|
|
10
10
|
private contextStack;
|
|
11
11
|
private templateNameScope;
|
|
12
12
|
private viewScope;
|
|
13
|
-
constructor(view: HTMLComponent<T>, subscriptions: ScopeSubscription<
|
|
13
|
+
constructor(view: HTMLComponent<T>, subscriptions: ScopeSubscription<Context>[]);
|
|
14
14
|
initView(): void;
|
|
15
15
|
isTemplateRefName(template: DomNode): template is DomElementNode;
|
|
16
16
|
initTemplateRefMap(domNode: DomNode): void;
|
|
17
17
|
initHostListener(): void;
|
|
18
18
|
addNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function): void;
|
|
19
19
|
getElementByName(name: string): any;
|
|
20
|
-
createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<
|
|
20
|
+
createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void;
|
|
21
21
|
createComment(node: CommentNode): Comment;
|
|
22
22
|
createText(node: TextContent): Text;
|
|
23
|
-
createLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<
|
|
24
|
-
createDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<
|
|
25
|
-
appendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<
|
|
23
|
+
createLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[]): Text;
|
|
24
|
+
createDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment;
|
|
25
|
+
appendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): void;
|
|
26
26
|
createElementByTagName(node: {
|
|
27
27
|
tagName: string;
|
|
28
28
|
is?: string;
|
|
29
29
|
}): HTMLElement;
|
|
30
|
-
createElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<
|
|
30
|
+
createElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): HTMLElement;
|
|
31
31
|
private initAttributeDirectives;
|
|
32
|
-
initAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<
|
|
33
|
-
initStructuralDirective(directive: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<
|
|
32
|
+
initAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<Context>[];
|
|
33
|
+
initStructuralDirective(directive: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<Context>[];
|
|
34
34
|
}
|