@ibyar/core 0.8.6 → 1.1.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 +20 -285
- package/annotation/decorators.d.ts.map +1 -0
- package/annotation/decorators.js +92 -84
- package/annotation/decorators.js.map +1 -1
- package/annotation/options.d.ts +276 -0
- package/annotation/options.d.ts.map +1 -0
- package/annotation/options.js +2 -0
- package/annotation/options.js.map +1 -0
- package/binding/binding.expressions.d.ts +2 -1
- package/binding/binding.expressions.d.ts.map +1 -0
- package/binding/binding.expressions.js +149 -124
- package/binding/binding.expressions.js.map +1 -1
- package/component/component.d.ts +13 -11
- package/component/component.d.ts.map +1 -0
- package/component/component.js +39 -45
- package/component/component.js.map +1 -1
- package/component/custom-element.d.ts +1 -3
- package/component/custom-element.d.ts.map +1 -0
- package/component/custom-element.js.map +1 -1
- package/component/events.d.ts +1 -0
- package/component/events.d.ts.map +1 -0
- package/component/events.js +4 -3
- package/component/events.js.map +1 -1
- package/component/lifecycle.d.ts +1 -0
- package/component/lifecycle.d.ts.map +1 -0
- package/component/reflect.d.ts +12 -15
- package/component/reflect.d.ts.map +1 -0
- package/component/reflect.js +28 -47
- package/component/reflect.js.map +1 -1
- package/context/stack.d.ts +1 -0
- package/context/stack.d.ts.map +1 -0
- package/context/subscription.d.ts +1 -0
- package/context/subscription.d.ts.map +1 -0
- package/directive/directive.d.ts +1 -0
- package/directive/directive.d.ts.map +1 -0
- package/directive/directive.js +8 -0
- package/directive/directive.js.map +1 -1
- package/directive/parser.d.ts +1 -0
- package/directive/parser.d.ts.map +1 -0
- package/directive/parser.js +9 -7
- package/directive/parser.js.map +1 -1
- package/directive/providers.d.ts +1 -0
- package/directive/providers.d.ts.map +1 -0
- package/directive/providers.js +2 -1
- package/directive/providers.js.map +1 -1
- package/html/deserialize.d.ts +1 -0
- package/html/deserialize.d.ts.map +1 -0
- package/html/expression.d.ts +1 -0
- package/html/expression.d.ts.map +1 -0
- package/html/expression.js +2 -2
- package/html/expression.js.map +1 -1
- package/html/types.d.ts +1 -0
- package/html/types.d.ts.map +1 -0
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -0
- package/index.js +1 -2
- package/index.js.map +1 -1
- package/linker/change-detector-ref.d.ts +1 -0
- package/linker/change-detector-ref.d.ts.map +1 -0
- package/linker/template-ref.d.ts +1 -0
- package/linker/template-ref.d.ts.map +1 -0
- package/linker/template-ref.js +5 -0
- package/linker/template-ref.js.map +1 -1
- package/linker/view-container-ref.d.ts +4 -2
- package/linker/view-container-ref.d.ts.map +1 -0
- package/linker/view-container-ref.js +9 -7
- package/linker/view-container-ref.js.map +1 -1
- package/linker/view-ref.d.ts +1 -0
- package/linker/view-ref.d.ts.map +1 -0
- package/linker/view-ref.js +5 -2
- package/linker/view-ref.js.map +1 -1
- package/node.d.ts +1 -0
- package/node.d.ts.map +1 -0
- package/package.json +8 -9
- package/pipe/pipe.d.ts +1 -0
- package/pipe/pipe.d.ts.map +1 -0
- package/pipe/pipe.js +2 -1
- package/pipe/pipe.js.map +1 -1
- package/providers/provider.d.ts +15 -13
- package/providers/provider.d.ts.map +1 -0
- package/providers/provider.js +13 -15
- package/providers/provider.js.map +1 -1
- package/scope/variables.d.ts +19 -0
- package/scope/variables.d.ts.map +1 -0
- package/scope/variables.js +38 -0
- package/scope/variables.js.map +1 -0
- package/utils/elements-util.d.ts +1 -0
- package/utils/elements-util.d.ts.map +1 -0
- package/utils/path.d.ts +1 -0
- package/utils/path.d.ts.map +1 -0
- package/utils/typeof.d.ts +3 -0
- package/utils/typeof.d.ts.map +1 -0
- package/utils/typeof.js.map +1 -1
- package/utils/utils.d.ts +1 -0
- package/utils/utils.d.ts.map +1 -0
- package/view/base-view.d.ts +1 -0
- package/view/base-view.d.ts.map +1 -0
- package/view/base-view.js +33 -29
- package/view/base-view.js.map +1 -1
- package/view/form-view.d.ts +1 -0
- package/view/form-view.d.ts.map +1 -0
- package/view/form-view.js +70 -67
- package/view/form-view.js.map +1 -1
- package/view/mutation.d.ts +1 -0
- package/view/mutation.d.ts.map +1 -0
- package/view/mutation.js +35 -35
- package/view/mutation.js.map +1 -1
- package/view/render.d.ts +2 -0
- package/view/render.d.ts.map +1 -0
- package/view/render.js +25 -13
- package/view/render.js.map +1 -1
- package/view/utils.d.ts +4 -3
- package/view/utils.d.ts.map +1 -0
- package/view/utils.js.map +1 -1
- package/view/view.d.ts +5 -4
- package/view/view.d.ts.map +1 -0
- package/view/view.js +34 -7
- package/view/view.js.map +1 -1
- package/zone/bootstrap.d.ts +1 -0
- package/zone/bootstrap.d.ts.map +1 -0
- package/zone/proxy.d.ts +1 -0
- package/zone/proxy.d.ts.map +1 -0
- package/zone/proxy.js +1 -0
- package/zone/proxy.js.map +1 -1
- package/zone/task.d.ts +1 -0
- package/zone/task.d.ts.map +1 -0
- package/zone/task.js +11 -3
- package/zone/task.js.map +1 -1
- package/zone/zone.d.ts +1 -0
- package/zone/zone.d.ts.map +1 -0
- package/zone/zone.js +8 -6
- package/zone/zone.js.map +1 -1
- package/providers/injector.d.ts +0 -10
- package/providers/injector.js +0 -27
- package/providers/injector.js.map +0 -1
- package/render/host-binding.handler.d.ts +0 -46
- package/render/host-binding.handler.js +0 -60
- package/render/host-binding.handler.js.map +0 -1
- package/render/host-listener.handler.d.ts +0 -50
- package/render/host-listener.handler.js +0 -88
- package/render/host-listener.handler.js.map +0 -1
- package/render/render-handler.d.ts +0 -11
- package/render/render-handler.js +0 -2
- package/render/render-handler.js.map +0 -1
package/linker/template-ref.js
CHANGED
|
@@ -3,6 +3,11 @@ import { EmbeddedViewRefImpl } from './view-ref.js';
|
|
|
3
3
|
export class TemplateRef {
|
|
4
4
|
}
|
|
5
5
|
export class TemplateRefImpl extends TemplateRef {
|
|
6
|
+
_render;
|
|
7
|
+
_node;
|
|
8
|
+
_stack;
|
|
9
|
+
_templateExpressions;
|
|
10
|
+
_host;
|
|
6
11
|
constructor(_render, _node, _stack, _templateExpressions) {
|
|
7
12
|
super();
|
|
8
13
|
this._render = _render;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-ref.js","sourceRoot":"","sources":["../../../src/core/linker/template-ref.ts"],"names":[],"mappings":"AACA,OAAO,EACU,2BAA2B,EAC3C,oBAAoB,EACD,KAAK,EACxB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,OAAgB,WAAW;CAiBhC;AAGD,MAAM,OAAO,eAAgB,SAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"template-ref.js","sourceRoot":"","sources":["../../../src/core/linker/template-ref.ts"],"names":[],"mappings":"AACA,OAAO,EACU,2BAA2B,EAC3C,oBAAoB,EACD,KAAK,EACxB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,OAAgB,WAAW;CAiBhC;AAGD,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAWtC;IACA;IACA;IACA;IAbD,KAAK,CAA2C;IASxD,YACS,OAA6B,EAC7B,KAAc,EACd,MAAa,EACb,oBAAsC;QAE9C,KAAK,EAAE,CAAC;QALA,YAAO,GAAP,OAAO,CAAsB;QAC7B,UAAK,GAAL,KAAK,CAAS;QACd,WAAM,GAAN,MAAM,CAAO;QACb,yBAAoB,GAApB,oBAAoB,CAAkB;IAG/C,CAAC;IACD,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,IAAI,IAAI,CAAC,IAA8C;QACtD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,kBAAkB,CAAmB,UAAa,EAAO,EAAE,UAAgB;QAC1E,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,oBAAoB,CAAC,UAAU,EAAK,CAAC;QAC3D,cAAc,CAAC,SAAS,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AAC;QAC3D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC9C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,WAAW,GAAG,2BAA2B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACjE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC3B,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CACtC,KAAK,CAAC,CAAC,CAAC,EACR,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAC7B,CAAC;gBACF,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,kBAAkB,CAAC;IAC3B,CAAC;CACD","sourcesContent":["import { DomNode } from '@ibyar/elements';\nimport {\n\tExpressionNode, findReactiveScopeByEventMap,\n\tReactiveScopeControl, Context,\n\tScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { StructuralDirective } from '../directive/directive.js';\nimport { ComponentRender } from '../view/render.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl } from './view-ref.js';\n\nexport abstract class TemplateRef {\n\n\t/**\n\t * get the current ref of this template\n\t */\n\tabstract get astNode(): DomNode;\n\n\t/**\n\t * Instantiates an embedded view based on this template,\n\t * `Not attached to the view`.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<template>` usage.\n\t * \n\t * To insert it to a view need to use a `ViewContainerRef.createEmbeddedView()`\n\t * @returns The new embedded view object.\n\t */\n\tabstract createEmbeddedView<C extends object>(context: C, parentNode: Node): EmbeddedViewRef<C>;\n}\n\n\nexport class TemplateRefImpl extends TemplateRef {\n\tprivate _host: HTMLComponent<any> | StructuralDirective;\n\n\tconstructor(\n\t\trender: ComponentRender<any>,\n\t\tnode: DomNode,\n\t\tstack: Stack,\n\t\ttemplateExpressions: ExpressionNode[],\n\t);\n\n\tconstructor(\n\t\tprivate _render: ComponentRender<any>,\n\t\tprivate _node: DomNode,\n\t\tprivate _stack: Stack,\n\t\tprivate _templateExpressions: ExpressionNode[],\n\t) {\n\t\tsuper();\n\t}\n\tget astNode(): DomNode {\n\t\treturn this._node;\n\t}\n\tset host(host: HTMLComponent<any> | StructuralDirective) {\n\t\tthis._host = host;\n\t}\n\tcreateEmbeddedView<C extends object>(context: C = {} as C, parentNode: Node): EmbeddedViewRef<C> {\n\t\tconst directiveStack = this._stack.copyStack();\n\t\tconst templateScope = ReactiveScopeControl.blockScope<C>();\n\t\tdirectiveStack.pushScope(templateScope);\n\n\t\tconst sandBox = new Stack();\n\t\tconst contextScope = ReactiveScopeControl.for<C>(context);\n\t\tsandBox.pushScope(contextScope);\n\t\tsandBox.pushScope(templateScope);\n\n\t\tconst elements: Node[] = [];\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tconst embeddedViewRef = new EmbeddedViewRefImpl(contextScope, elements, subscriptions);\n\t\tconst scopeSubscriptions = this.executeTemplateExpressions(sandBox);\n\t\tscopeSubscriptions && subscriptions.push(...scopeSubscriptions);\n\n\t\tconst fragment = document.createDocumentFragment();\n\t\tthis._render.appendChildToParent(fragment, this._node, directiveStack, parentNode, subscriptions, this._host);\n\n\t\tfragment.childNodes.forEach(item => elements.push(item));\n\t\t// const updateSubscriptions = this.render.view._zone.onFinal.subscribe(() => contextScope.detectChanges());\n\t\t// embeddedViewRef.onDestroy(() => updateSubscriptions.unsubscribe());\n\t\treturn embeddedViewRef;\n\t}\n\tprivate executeTemplateExpressions(sandBox: Stack): ScopeSubscription<Context>[] | undefined {\n\t\tif (!this._templateExpressions?.length) {\n\t\t\treturn;\n\t\t}\n\t\t// init value\n\t\tthis._templateExpressions.forEach(expression => {\n\t\t\texpression.get(sandBox);\n\t\t});\n\n\t\t// subscribe to changes\n\t\tconst scopeSubscriptions: ScopeSubscription<object>[] = [];\n\t\tthis._templateExpressions.forEach(expression => {\n\t\t\tconst events = expression.events();\n\t\t\tconst scopeTuples = findReactiveScopeByEventMap(events, sandBox);\n\t\t\tscopeTuples.forEach(tuple => {\n\t\t\t\tconst subscription = tuple[1].subscribe(\n\t\t\t\t\ttuple[0],\n\t\t\t\t\t() => expression.get(sandBox)\n\t\t\t\t);\n\t\t\t\tscopeSubscriptions.push(subscription);\n\t\t\t});\n\t\t});\n\t\treturn scopeSubscriptions;\n\t}\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MetadataClass } from '@ibyar/decorators';
|
|
1
2
|
import type { TypeOf } from '../utils/typeof.js';
|
|
2
3
|
import { TemplateRef } from './template-ref.js';
|
|
3
4
|
import { EmbeddedViewRef, ViewRef } from './view-ref.js';
|
|
@@ -163,11 +164,12 @@ export declare class ViewContainerRefImpl extends ViewContainerRef {
|
|
|
163
164
|
move(viewRef: EmbeddedViewRef<any>, newIndex: number): ViewRef;
|
|
164
165
|
createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;
|
|
165
166
|
createComponent<C extends {}>(selector: string, options?: IndexOptions): C;
|
|
166
|
-
createComponent<C extends {}>(viewClass:
|
|
167
|
-
createComponent<C extends {}>(componentType:
|
|
167
|
+
createComponent<C extends {}>(viewClass: MetadataClass<HTMLComponent<C>>, options?: IndexOptions): C;
|
|
168
|
+
createComponent<C extends {}>(componentType: MetadataClass<C>, options?: ViewContainerComponentOptions): C;
|
|
168
169
|
createElement<K extends keyof HTMLElementTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementTagNameMap[K];
|
|
169
170
|
createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementDeprecatedTagNameMap[K];
|
|
170
171
|
createTextNode(data: string, options?: IndexOptions): Text;
|
|
171
172
|
updateViews(views: ViewRef[]): void;
|
|
172
173
|
}
|
|
173
174
|
export {};
|
|
175
|
+
//# sourceMappingURL=view-container-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-container-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/view-container-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAuB,OAAO,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,UAAU,YAAY;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,CAAE,SAAQ,YAAY;IAC5D,OAAO,CAAC,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,WAAW,6BAA8B,SAAQ,YAAY;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB,EAAE,YAAY;CAE/E;AAED,8BAAsB,gBAAgB;IAErC;;;;;;;;;;;OAWG;IACH,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,KAAK,IAAI,IAAI;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAEhD;;;OAGG;IACH,QAAQ,KAAK,MAAM,IAAI,MAAM,CAAC;IAE9B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,kBAAkB,CAAC,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,oBAAoB,CAAC,CAA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,CAAC,CAAC,CAAC;IAKjH,eAAe,CAAC,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,CAAC;IAC1E,eAAe,CAAC,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,CAAC;IACpG,eAAe,CAAC,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,6BAA6B,GAAG,CAAC;IA0B1G,aAAa,CAAC,CAAC,SAAS,MAAM,qBAAqB,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAC,CAAC,CAAC;IACzH,aAAa,CAAC,CAAC,SAAS,MAAM,+BAA+B,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,+BAA+B,CAAC,CAAC,CAAC;IAe7I,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI;IAQ1D,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI;CAS5C"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactiveScopeControl } from '@ibyar/expressions';
|
|
2
2
|
import { EmbeddedViewRefImpl } from './view-ref.js';
|
|
3
3
|
import { getComponentView } from '../view/utils.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ReflectComponents } from '../component/reflect.js';
|
|
5
5
|
;
|
|
6
6
|
;
|
|
7
7
|
export class ViewContainerRef {
|
|
8
8
|
}
|
|
9
9
|
export class ViewContainerRefImpl extends ViewContainerRef {
|
|
10
|
+
_parent;
|
|
11
|
+
_firstComment;
|
|
12
|
+
_views = [];
|
|
10
13
|
constructor(_parent, _firstComment) {
|
|
11
14
|
super();
|
|
12
15
|
this._parent = _parent;
|
|
13
16
|
this._firstComment = _firstComment;
|
|
14
|
-
this._views = [];
|
|
15
17
|
}
|
|
16
18
|
get anchorElement() {
|
|
17
19
|
return this._parent;
|
|
@@ -34,7 +36,7 @@ export class ViewContainerRefImpl extends ViewContainerRef {
|
|
|
34
36
|
return this._views[index];
|
|
35
37
|
}
|
|
36
38
|
detach(index) {
|
|
37
|
-
index
|
|
39
|
+
index ??= this._views.length - 1;
|
|
38
40
|
const viewRef = this._views[index];
|
|
39
41
|
viewRef.detach();
|
|
40
42
|
this._views.splice(index, 1);
|
|
@@ -44,12 +46,12 @@ export class ViewContainerRefImpl extends ViewContainerRef {
|
|
|
44
46
|
return this._views.indexOf(viewRef);
|
|
45
47
|
}
|
|
46
48
|
remove(index) {
|
|
47
|
-
index
|
|
49
|
+
index ??= this._views.length - 1;
|
|
48
50
|
this._views[index].destroy();
|
|
49
51
|
this._views.splice(index, 1);
|
|
50
52
|
}
|
|
51
53
|
insert(viewRef, index) {
|
|
52
|
-
index = ((index
|
|
54
|
+
index = ((index ??= this._views.length) > this._views.length) ? this._views.length : index;
|
|
53
55
|
const lastNode = index == 0 ? this._firstComment : this._views[index - 1].last;
|
|
54
56
|
this._views.splice(index, 0, viewRef);
|
|
55
57
|
viewRef.after(lastNode);
|
|
@@ -82,7 +84,7 @@ export class ViewContainerRefImpl extends ViewContainerRef {
|
|
|
82
84
|
}
|
|
83
85
|
else {
|
|
84
86
|
const componentType = arg0;
|
|
85
|
-
const defaultTagName = ReflectComponents.
|
|
87
|
+
const defaultTagName = ReflectComponents.getMetaDate(componentType)?.selector;
|
|
86
88
|
const view = getComponentView(componentType, options?.selector ?? defaultTagName);
|
|
87
89
|
if (!view) {
|
|
88
90
|
throw new Error(`Can't find View component for class ${componentType.name}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-container-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-container-ref.ts"],"names":[],"mappings":"AAC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G,CAAO,IAAI,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAO,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACb,CAAC;IAEQ,WAAW,CAAC,KAAgB;QACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAyB,EAAE,CAAC,CAAC,CAAC;SAC/C;QACD,OAAO,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE;YAClC,IAAI,CAAC,MAAM,EAAE,CAAC;SACd;IACF,CAAC;CAED","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReflectComponents } from '../component/reflect.js';\nimport { TemplateRef } from './template-ref.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl, ViewRef } from './view-ref.js';\nimport { getComponentView } from '../view/utils.js';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { ReactiveScopeControl } from '@ibyar/expressions';\n\ninterface IndexOptions {\n\t/**\n\t * the index to insert the \n\t */\n\tindex?: number;\n\t/**\n\t * the default value is true\n\t */\n\tinsert?: boolean\n}\n\nexport interface ViewContainerOptions<C> extends IndexOptions {\n\tcontext?: C;\n};\n\nexport interface ViewContainerComponentOptions extends IndexOptions {\n\tselector?: string;\n};\n\nexport interface HTMLElementOptions extends ElementCreationOptions, IndexOptions {\n\n}\n\nexport abstract class ViewContainerRef {\n\n\t/**\n\t * Anchor element that specifies the location of this container in the containing view.\n\t * Each view container can have only one anchor element, and each anchor element\n\t * can have only a single view container.\n\t * \n\t * Root elements of views attached to this container become siblings of the anchor element in\n\t * the rendered view.\n\t *\n\t * Access the `ViewContainerRef` of an element by placing a `Directive` injected\n\t * with `ViewContainerRef` on the element, or use a `ViewChild` query.\n\t *\n\t */\n\tabstract get anchorElement(): Element;\n\n\t/**\n\t * Destroys all views in this container.\n\t */\n\tabstract clear(): void;\n\n\t/**\n\t * Retrieves a view from this container.\n\t * @param index The 0-based index of the view to retrieve.\n\t * @returns The `ViewRef` instance, or null if the index is out of range.\n\t */\n\tabstract get(index: number): ViewRef | undefined;\n\n\t/**\n\t * Reports how many views are currently attached to this container.\n\t * @returns The number of views.\n\t */\n\tabstract get length(): number;\n\n\t/**\n\t * Instantiates an embedded view and inserts it\n\t * into this container.\n\t * @param templateRef The HTML template that defines the view.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<ng-template>` usage.\n\t * @param index The 0-based index at which to insert the new view into this container.\n\t * If not specified, appends the new view as the last entry.\n\t *\n\t * @returns The `ViewRef` instance for the newly created view.\n\t */\n\tabstract createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;\n\n\t/**\n\t * create component by tag name `selector`.\n\t * @param selector the tag name for the aurora custom-element\n\t * @param options \n\t */\n\tabstract createComponent<C extends {}>(selector: string, options?: IndexOptions): C;\n\n\t/**\n\t * create component by the aurora custom-element `View` Class\n\t * @param viewClass the generated aurora view class\n\t * @param options \n\t */\n\tabstract createComponent<C extends {}>(viewClass: TypeOf<HTMLComponent<C>>, options?: IndexOptions): C;\n\t/**\n\t * Instantiates a single component and inserts its host view into this container.\n\t *\n\t * @param componentType Component Type to use.\n\t * @param options An object that contains extra parameters:\n\t * * index: the index at which to insert the new component's host view into this container.\n\t * If not specified, appends the new view as the last entry.\n\t * * selector: the tag name of the new create component that attached with this model class.\n\t * \t\tAny Model class can have many views with different selectors.\n\t *\n\t * @returns The new `HTMLComponent` which contains the component instance and the host view.\n\t */\n\tabstract createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;\n\n\n\t/**\n\t * create an HTMLElement by tag name `selector`.\n\t * @param selector the tag name for the aurora custom-element\n\t * @param options \n\t */\n\tabstract createElement<K extends keyof HTMLElementTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementTagNameMap[K];\n\tabstract createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementDeprecatedTagNameMap[K];\n\n\t/**\n\t * create HTMLElement by View Class reference\n\t * @param viewClass the generated aurora view class\n\t * @param options \n\t */\n\tabstract createElement<C extends HTMLElement>(htmlElementClass: TypeOf<C>, options?: HTMLElementOptions): C;\n\n\t/**\n\t * create a text node and insert to the view\n\t * @param data \n\t * @param options \n\t */\n\tabstract createTextNode(data: string, options?: IndexOptions): Text;\n\n\t/**\n\t * Inserts a view into this container.\n\t * @param viewRef The view to insert.\n\t * @param index The 0-based index at which to insert the view.\n\t * If not specified, appends the new view as the last entry.\n\t * @returns The inserted `ViewRef` instance.\n\t *\n\t */\n\tabstract insert(viewRef: ViewRef, index?: number): ViewRef;\n\n\t/**\n\t * Moves a view to a new location in this container.\n\t * @param viewRef The view to move.\n\t * @param newIndex The 0-based index of the new location.\n\t * @returns The moved `ViewRef` instance.\n\t */\n\tabstract move(viewRef: ViewRef, newIndex: number): ViewRef;\n\n\t/**\n\t * Returns the index of a view within the current container.\n\t * @param viewRef The view to query.\n\t * @returns The 0-based index of the view's position in this container,\n\t * or `-1` if this container doesn't contain the view.\n\t */\n\tabstract indexOf(viewRef: ViewRef): number;\n\n\t/**\n\t * Destroys a view attached to this container\n\t * @param index The 0-based index of the view to destroy.\n\t * If not specified, the last view in the container is removed.\n\t */\n\tabstract remove(index?: number): void;\n\n\t/**\n\t * Detaches a view from this container without destroying it.\n\t * Use along with `insert()` to move a view within the current container.\n\t * @param index The 0-based index of the view to detach.\n\t * If not specified, the last view in the container is detached.\n\t */\n\tabstract detach(index?: number): ViewRef | undefined;\n\n\t/**\n\t * set the current views from this\n\t * @param views the new `ViewRef` list \n\t */\n\tabstract updateViews(views: ViewRef[]): void;\n}\n\n\nexport class ViewContainerRefImpl extends ViewContainerRef {\n\n\tprivate _views: EmbeddedViewRef<any>[] = [];\n\n\tconstructor(parent: Element, firstComment: Comment);\n\tconstructor(private _parent: Element, private _firstComment: Comment) {\n\t\tsuper();\n\t}\n\toverride get anchorElement(): Element {\n\t\treturn this._parent;\n\t}\n\toverride get length(): number {\n\t\treturn this._views.length;\n\t}\n\toverride clear(): void {\n\t\tif (this._views.length > 0) {\n\t\t\tfor (const elm of this._views) {\n\t\t\t\telm.destroy();\n\t\t\t}\n\t\t\tthis._views.splice(0);\n\t\t}\n\t}\n\toverride get(index: number): ViewRef | undefined {\n\t\tif (index >= this._views.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this._views[index];\n\t}\n\toverride detach(index?: number): ViewRef | undefined {\n\t\tindex ??= this._views.length - 1;\n\t\tconst viewRef = this._views[index];\n\t\tviewRef.detach();\n\t\tthis._views.splice(index, 1);\n\t\treturn viewRef;\n\t}\n\toverride indexOf(viewRef: EmbeddedViewRef<any>): number {\n\t\treturn this._views.indexOf(viewRef);\n\t}\n\toverride remove(index?: number): void {\n\t\tindex ??= this._views.length - 1;\n\t\tthis._views[index].destroy();\n\t\tthis._views.splice(index, 1);\n\t}\n\toverride insert(viewRef: EmbeddedViewRef<any>, index?: number): ViewRef {\n\t\tindex = ((index ??= this._views.length) > this._views.length) ? this._views.length : index;\n\t\tconst lastNode = index == 0 ? this._firstComment : this._views[index - 1].last;\n\t\tthis._views.splice(index, 0, viewRef);\n\t\tviewRef.after(lastNode);\n\t\treturn viewRef;\n\t}\n\toverride move(viewRef: EmbeddedViewRef<any>, newIndex: number): ViewRef {\n\t\tconst oldIndex = this.indexOf(viewRef);\n\t\tif (oldIndex > -1) {\n\t\t\tthis.detach(oldIndex);\n\t\t} else {\n\t\t\t// should remove it from the container first\n\t\t\tviewRef.detach();\n\t\t}\n\t\treturn this.insert(viewRef, newIndex);\n\t}\n\toverride createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C> {\n\t\tconst viewRef = templateRef.createEmbeddedView<C>(options?.context || <C>{}, this._parent);\n\t\t(options?.insert != false) && this.insert(viewRef, options?.index);\n\t\treturn viewRef;\n\t}\n\toverride createComponent<C extends {}>(selector: string, options?: IndexOptions): C;\n\toverride createComponent<C extends {}>(viewClass: TypeOf<HTMLComponent<C>>, options?: IndexOptions): C;\n\toverride createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;\n\toverride createComponent<C extends {}>(arg0: string | TypeOf<C> | TypeOf<HTMLComponent<C>>, options?: ViewContainerComponentOptions): C {\n\t\tlet ViewClass: TypeOf<HTMLComponent<C>>;\n\t\tif (typeof arg0 === 'string') {\n\t\t\tViewClass = customElements.get(arg0) as TypeOf<HTMLComponent<C>>;\n\t\t} else if (typeof arg0 === 'function') {\n\t\t\tif (Reflect.has(arg0, 'observedAttributes')) {\n\t\t\t\tViewClass = arg0 as TypeOf<HTMLComponent<C>>;\n\t\t\t} else {\n\t\t\t\tconst componentType = arg0 as TypeOf<C>;\n\t\t\t\tconst defaultTagName = ReflectComponents.getComponentRef<C>(componentType).selector;\n\t\t\t\tconst view = getComponentView(componentType, options?.selector ?? defaultTagName);\n\t\t\t\tif (!view) {\n\t\t\t\t\tthrow new Error(`Can't find View component for class ${componentType.name}`);\n\t\t\t\t}\n\t\t\t\tViewClass = view;\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(`Can't find View component for args, ${arg0}, ${options}`);\n\t\t}\n\t\tconst component = new ViewClass();\n\t\tconst viewRef = new EmbeddedViewRefImpl<C>(component._modelScope, [component]);\n\t\t(options?.insert != false) && this.insert(viewRef, options?.index);\n\t\treturn component as any as C;\n\t}\n\n\toverride createElement<K extends keyof HTMLElementTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementTagNameMap[K];\n\toverride createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementDeprecatedTagNameMap[K];\n\toverride createElement<C extends HTMLElement>(arg0: string | TypeOf<C>, options?: HTMLElementOptions): C {\n\t\tlet element: C;\n\t\tif (typeof arg0 === 'string') {\n\t\t\telement = document.createElement(arg0, { is: options?.is }) as C;\n\t\t} else if (typeof arg0 === 'function') {\n\t\t\telement = new arg0();\n\t\t} else {\n\t\t\tthrow new Error(`Can't find View component for args, ${arg0}, ${options}`);\n\t\t}\n\t\tconst scope = ReactiveScopeControl.for<C>(element);\n\t\tconst viewRef = new EmbeddedViewRefImpl<C>(scope, [element]);\n\t\t(options?.insert != false) && this.insert(viewRef, options?.index);\n\t\treturn element;\n\t}\n\toverride createTextNode(data: string, options?: IndexOptions): Text {\n\t\tconst text = document.createTextNode(data);\n\t\tconst scope = ReactiveScopeControl.for<Text>(text);\n\t\tconst viewRef = new EmbeddedViewRefImpl<Text>(scope, [text]);\n\t\t(options?.insert != false) && this.insert(viewRef, options?.index);\n\t\treturn text;\n\t}\n\n\toverride updateViews(views: ViewRef[]): void {\n\t\tfor (let i = 0; i < views.length; i++) {\n\t\t\tthis.move(views[i] as EmbeddedViewRef<any>, i);\n\t\t}\n\t\twhile (this.length > views.length) {\n\t\t\tthis.remove();\n\t\t}\n\t}\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"view-container-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-container-ref.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAmB,mBAAmB,EAAW,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAe3D,CAAC;AAID,CAAC;AAMF,MAAM,OAAgB,gBAAgB;CA+IrC;AAGD,MAAM,OAAO,oBAAqB,SAAQ,gBAAgB;IAKrC;IAA0B;IA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G,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAyB,EAAE,CAAC,CAAC,CAAC;SAC/C;QACD,OAAO,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE;YAClC,IAAI,CAAC,MAAM,EAAE,CAAC;SACd;IACF,CAAC;CAED","sourcesContent":["import type { MetadataClass } from '@ibyar/decorators';\nimport type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScopeControl } from '@ibyar/expressions';\nimport { TemplateRef } from './template-ref.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl, ViewRef } from './view-ref.js';\nimport { getComponentView } from '../view/utils.js';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { ReflectComponents } from '../component/reflect.js';\n\ninterface IndexOptions {\n\t/**\n\t * the index to insert the \n\t */\n\tindex?: number;\n\t/**\n\t * the default value is true\n\t */\n\tinsert?: boolean\n}\n\nexport interface ViewContainerOptions<C> extends IndexOptions {\n\tcontext?: C;\n};\n\nexport interface ViewContainerComponentOptions extends IndexOptions {\n\tselector?: string;\n};\n\nexport interface HTMLElementOptions extends ElementCreationOptions, IndexOptions {\n\n}\n\nexport abstract class ViewContainerRef {\n\n\t/**\n\t * Anchor element that specifies the location of this container in the containing view.\n\t * Each view container can have only one anchor element, and each anchor element\n\t * can have only a single view container.\n\t * \n\t * Root elements of views attached to this container become siblings of the anchor element in\n\t * the rendered view.\n\t *\n\t * Access the `ViewContainerRef` of an element by placing a `Directive` injected\n\t * with `ViewContainerRef` on the element, or use a `ViewChild` query.\n\t *\n\t */\n\tabstract get anchorElement(): Element;\n\n\t/**\n\t * Destroys all views in this container.\n\t */\n\tabstract clear(): void;\n\n\t/**\n\t * Retrieves a view from this container.\n\t * @param index The 0-based index of the view to retrieve.\n\t * @returns The `ViewRef` instance, or null if the index is out of range.\n\t */\n\tabstract get(index: number): ViewRef | undefined;\n\n\t/**\n\t * Reports how many views are currently attached to this container.\n\t * @returns The number of views.\n\t */\n\tabstract get length(): number;\n\n\t/**\n\t * Instantiates an embedded view and inserts it\n\t * into this container.\n\t * @param templateRef The HTML template that defines the view.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<ng-template>` usage.\n\t * @param index The 0-based index at which to insert the new view into this container.\n\t * If not specified, appends the new view as the last entry.\n\t *\n\t * @returns The `ViewRef` instance for the newly created view.\n\t */\n\tabstract createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;\n\n\t/**\n\t * create component by tag name `selector`.\n\t * @param selector the tag name for the aurora custom-element\n\t * @param options \n\t */\n\tabstract createComponent<C extends {}>(selector: string, options?: IndexOptions): C;\n\n\t/**\n\t * create component by the aurora custom-element `View` Class\n\t * @param viewClass the generated aurora view class\n\t * @param options \n\t */\n\tabstract createComponent<C extends {}>(viewClass: TypeOf<HTMLComponent<C>>, options?: IndexOptions): C;\n\t/**\n\t * Instantiates a single component and inserts its host view into this container.\n\t *\n\t * @param componentType Component Type to use.\n\t * @param options An object that contains extra parameters:\n\t * * index: the index at which to insert the new component's host view into this container.\n\t * If not specified, appends the new view as the last entry.\n\t * * selector: the tag name of the new create component that attached with this model class.\n\t * \t\tAny Model class can have many views with different selectors.\n\t *\n\t * @returns The new `HTMLComponent` which contains the component instance and the host view.\n\t */\n\tabstract createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;\n\n\n\t/**\n\t * create an HTMLElement by tag name `selector`.\n\t * @param selector the tag name for the aurora custom-element\n\t * @param options \n\t */\n\tabstract createElement<K extends keyof HTMLElementTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementTagNameMap[K];\n\tabstract createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementDeprecatedTagNameMap[K];\n\n\t/**\n\t * create HTMLElement by View Class reference\n\t * @param viewClass the generated aurora view class\n\t * @param options \n\t */\n\tabstract createElement<C extends HTMLElement>(htmlElementClass: TypeOf<C>, options?: HTMLElementOptions): C;\n\n\t/**\n\t * create a text node and insert to the view\n\t * @param data \n\t * @param options \n\t */\n\tabstract createTextNode(data: string, options?: IndexOptions): Text;\n\n\t/**\n\t * Inserts a view into this container.\n\t * @param viewRef The view to insert.\n\t * @param index The 0-based index at which to insert the view.\n\t * If not specified, appends the new view as the last entry.\n\t * @returns The inserted `ViewRef` instance.\n\t *\n\t */\n\tabstract insert(viewRef: ViewRef, index?: number): ViewRef;\n\n\t/**\n\t * Moves a view to a new location in this container.\n\t * @param viewRef The view to move.\n\t * @param newIndex The 0-based index of the new location.\n\t * @returns The moved `ViewRef` instance.\n\t */\n\tabstract move(viewRef: ViewRef, newIndex: number): ViewRef;\n\n\t/**\n\t * Returns the index of a view within the current container.\n\t * @param viewRef The view to query.\n\t * @returns The 0-based index of the view's position in this container,\n\t * or `-1` if this container doesn't contain the view.\n\t */\n\tabstract indexOf(viewRef: ViewRef): number;\n\n\t/**\n\t * Destroys a view attached to this container\n\t * @param index The 0-based index of the view to destroy.\n\t * If not specified, the last view in the container is removed.\n\t */\n\tabstract remove(index?: number): void;\n\n\t/**\n\t * Detaches a view from this container without destroying it.\n\t * Use along with `insert()` to move a view within the current container.\n\t * @param index The 0-based index of the view to detach.\n\t * If not specified, the last view in the container is detached.\n\t */\n\tabstract detach(index?: number): ViewRef | undefined;\n\n\t/**\n\t * set the current views from this\n\t * @param views the new `ViewRef` list \n\t */\n\tabstract updateViews(views: ViewRef[]): void;\n}\n\n\nexport class ViewContainerRefImpl extends ViewContainerRef {\n\n\tprivate _views: EmbeddedViewRef<any>[] = [];\n\n\tconstructor(parent: Element, firstComment: Comment);\n\tconstructor(private _parent: Element, private _firstComment: Comment) {\n\t\tsuper();\n\t}\n\toverride get anchorElement(): Element {\n\t\treturn this._parent;\n\t}\n\toverride get length(): number {\n\t\treturn this._views.length;\n\t}\n\toverride clear(): void {\n\t\tif (this._views.length > 0) {\n\t\t\tfor (const elm of this._views) {\n\t\t\t\telm.destroy();\n\t\t\t}\n\t\t\tthis._views.splice(0);\n\t\t}\n\t}\n\toverride get(index: number): ViewRef | undefined {\n\t\tif (index >= this._views.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this._views[index];\n\t}\n\toverride detach(index?: number): ViewRef | undefined {\n\t\tindex ??= this._views.length - 1;\n\t\tconst viewRef = this._views[index];\n\t\tviewRef.detach();\n\t\tthis._views.splice(index, 1);\n\t\treturn viewRef;\n\t}\n\toverride indexOf(viewRef: EmbeddedViewRef<any>): number {\n\t\treturn this._views.indexOf(viewRef);\n\t}\n\toverride remove(index?: number): void {\n\t\tindex ??= this._views.length - 1;\n\t\tthis._views[index].destroy();\n\t\tthis._views.splice(index, 1);\n\t}\n\toverride insert(viewRef: EmbeddedViewRef<any>, index?: number): ViewRef {\n\t\tindex = ((index ??= this._views.length) > this._views.length) ? this._views.length : index;\n\t\tconst lastNode = index == 0 ? this._firstComment : this._views[index - 1].last;\n\t\tthis._views.splice(index, 0, viewRef);\n\t\tviewRef.after(lastNode);\n\t\treturn viewRef;\n\t}\n\toverride move(viewRef: EmbeddedViewRef<any>, newIndex: number): ViewRef {\n\t\tconst oldIndex = this.indexOf(viewRef);\n\t\tif (oldIndex > -1) {\n\t\t\tthis.detach(oldIndex);\n\t\t} else {\n\t\t\t// should remove it from the container first\n\t\t\tviewRef.detach();\n\t\t}\n\t\treturn this.insert(viewRef, newIndex);\n\t}\n\toverride createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C> {\n\t\tconst viewRef = templateRef.createEmbeddedView<C>(options?.context || <C>{}, this._parent);\n\t\t(options?.insert != false) && this.insert(viewRef, options?.index);\n\t\treturn viewRef;\n\t}\n\toverride createComponent<C extends {}>(selector: string, options?: IndexOptions): C;\n\toverride createComponent<C extends {}>(viewClass: MetadataClass<HTMLComponent<C>>, options?: IndexOptions): C;\n\toverride createComponent<C extends {}>(componentType: MetadataClass<C>, options?: ViewContainerComponentOptions): C;\n\toverride createComponent<C extends {}>(arg0: string | MetadataClass<C> | TypeOf<HTMLComponent<C>>, options?: ViewContainerComponentOptions): C {\n\t\tlet ViewClass: TypeOf<HTMLComponent<C>>;\n\t\tif (typeof arg0 === 'string') {\n\t\t\tViewClass = customElements.get(arg0) as TypeOf<HTMLComponent<C>>;\n\t\t} else if (typeof arg0 === 'function') {\n\t\t\tif (Reflect.has(arg0, 'observedAttributes')) {\n\t\t\t\tViewClass = arg0 as TypeOf<HTMLComponent<C>>;\n\t\t\t} else {\n\t\t\t\tconst componentType = arg0 as MetadataClass<C>;\n\t\t\t\tconst defaultTagName = ReflectComponents.getMetaDate(componentType)?.selector;\n\t\t\t\tconst view = getComponentView(componentType, options?.selector ?? defaultTagName);\n\t\t\t\tif (!view) {\n\t\t\t\t\tthrow new Error(`Can't find View component for class ${componentType.name}`);\n\t\t\t\t}\n\t\t\t\tViewClass = view;\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(`Can't find View component for args, ${arg0}, ${options}`);\n\t\t}\n\t\tconst component = new ViewClass();\n\t\tconst viewRef = new EmbeddedViewRefImpl<C>(component._modelScope, [component]);\n\t\t(options?.insert != false) && this.insert(viewRef, options?.index);\n\t\treturn component as any as C;\n\t}\n\n\toverride createElement<K extends keyof HTMLElementTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementTagNameMap[K];\n\toverride createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementDeprecatedTagNameMap[K];\n\toverride createElement<C extends HTMLElement>(arg0: string | TypeOf<C>, options?: HTMLElementOptions): C {\n\t\tlet element: C;\n\t\tif (typeof arg0 === 'string') {\n\t\t\telement = document.createElement(arg0, { is: options?.is }) as C;\n\t\t} else if (typeof arg0 === 'function') {\n\t\t\telement = new arg0();\n\t\t} else {\n\t\t\tthrow new Error(`Can't find View component for args, ${arg0}, ${options}`);\n\t\t}\n\t\tconst scope = ReactiveScopeControl.for<C>(element);\n\t\tconst viewRef = new EmbeddedViewRefImpl<C>(scope, [element]);\n\t\t(options?.insert != false) && this.insert(viewRef, options?.index);\n\t\treturn element;\n\t}\n\toverride createTextNode(data: string, options?: IndexOptions): Text {\n\t\tconst text = document.createTextNode(data);\n\t\tconst scope = ReactiveScopeControl.for<Text>(text);\n\t\tconst viewRef = new EmbeddedViewRefImpl<Text>(scope, [text]);\n\t\t(options?.insert != false) && this.insert(viewRef, options?.index);\n\t\treturn text;\n\t}\n\n\toverride updateViews(views: ViewRef[]): void {\n\t\tfor (let i = 0; i < views.length; i++) {\n\t\t\tthis.move(views[i] as EmbeddedViewRef<any>, i);\n\t\t}\n\t\twhile (this.length > views.length) {\n\t\t\tthis.remove();\n\t\t}\n\t}\n\n}\n"]}
|
package/linker/view-ref.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/view-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,8BAAsB,OAAQ,SAAQ,iBAAiB;IACtD;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,IAAI;IAExB;;;OAGG;IACH,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC;IAElC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG;QAAE,WAAW,IAAI,IAAI,CAAA;KAAE;CAC/D;AAGD,8BAAsB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,OAAO;IACtE;;OAEG;IACH,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC;IAE1B;;OAEG;IACH,QAAQ,KAAK,SAAS,IAAI,IAAI,EAAE,CAAC;IAEjC;;OAEG;IACH,QAAQ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ViewRef extends ChangeDetectorRef {
|
|
|
4
4
|
export class EmbeddedViewRef extends ViewRef {
|
|
5
5
|
}
|
|
6
6
|
export class EmbeddedViewRefImpl extends EmbeddedViewRef {
|
|
7
|
+
_scope;
|
|
8
|
+
_rootNodes;
|
|
9
|
+
_subscriptions;
|
|
10
|
+
_destroyed = false;
|
|
11
|
+
_onDestroySubscribes = [];
|
|
7
12
|
constructor(_scope, _rootNodes, _subscriptions) {
|
|
8
13
|
super();
|
|
9
14
|
this._scope = _scope;
|
|
10
15
|
this._rootNodes = _rootNodes;
|
|
11
16
|
this._subscriptions = _subscriptions;
|
|
12
|
-
this._destroyed = false;
|
|
13
|
-
this._onDestroySubscribes = [];
|
|
14
17
|
}
|
|
15
18
|
get context() {
|
|
16
19
|
return this._scope.getContext();
|
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":"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;
|
|
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;IAMnE;IACA;IACA;IAND,UAAU,GAAY,KAAK,CAAC;IAC5B,oBAAoB,GAAmB,EAAE,CAAC;IAElD,YACS,MAA+B,EAC/B,UAAkB,EAClB,cAA6C;QACrD,KAAK,EAA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C,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/node.d.ts
CHANGED
package/node.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/core/node.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibyar/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Ibyar core, 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",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ibyar/
|
|
39
|
-
"@ibyar/
|
|
40
|
-
"
|
|
41
|
-
"tslib": "^2.
|
|
38
|
+
"@ibyar/decorators": "^1.1.0",
|
|
39
|
+
"@ibyar/elements": "^1.1.0",
|
|
40
|
+
"@ibyar/expressions": "^1.1.0",
|
|
41
|
+
"tslib": "^2.6.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"zone.js": "~0.11.4 || ~0.12.0"
|
|
44
|
+
"zone.js": "~0.11.4 || ~0.12.0 || ~0.13.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"typescript": "^
|
|
47
|
+
"typescript": "^5.2.2"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc --build --verbose"
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"shadow-dom",
|
|
59
59
|
"shadowdom",
|
|
60
60
|
"dependency-injection",
|
|
61
|
-
"reflect-metadata",
|
|
62
61
|
"services",
|
|
63
62
|
"component",
|
|
64
63
|
"directive",
|
|
@@ -78,5 +77,5 @@
|
|
|
78
77
|
"typescript",
|
|
79
78
|
"front-end"
|
|
80
79
|
],
|
|
81
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "9427f428b9783263536b896d363bd10a59b380de"
|
|
82
81
|
}
|
package/pipe/pipe.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../../src/core/pipe/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAA2B,MAAM,kCAAkC,CAAC;AAE9F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,EAAE,CAAC;IAClC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;CACvC;AAED,8BAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS;IAC3E,SAAS,CAAC,iBAAiB,EAAE,iBAAiB;gBAApC,iBAAiB,EAAE,iBAAiB;IAC1D,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC;IAC/C,QAAQ,CAAC,SAAS,IAAI,IAAI;CAC1B;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,GAAG,EAAE,IAAI,EAAE,GAA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iB,CAAC,CAAC,CAAC;IAK9E,QAAQ,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CAGrC"}
|
package/pipe/pipe.js
CHANGED
|
@@ -2,6 +2,7 @@ import { ReactiveScopeControl, ReadOnlyScope } from '@ibyar/expressions';
|
|
|
2
2
|
import { createChangeDetectorRef } from '../linker/change-detector-ref.js';
|
|
3
3
|
import { ClassRegistryProvider } from '../providers/provider.js';
|
|
4
4
|
export class AsyncPipeTransform {
|
|
5
|
+
changeDetectorRef;
|
|
5
6
|
constructor(changeDetectorRef) {
|
|
6
7
|
this.changeDetectorRef = changeDetectorRef;
|
|
7
8
|
}
|
|
@@ -61,9 +62,9 @@ export class AsyncPipeScope extends ReactiveScopeControl {
|
|
|
61
62
|
static blockScope() {
|
|
62
63
|
return new AsyncPipeScope();
|
|
63
64
|
}
|
|
65
|
+
wrapper = {};
|
|
64
66
|
constructor() {
|
|
65
67
|
super({});
|
|
66
|
-
this.wrapper = {};
|
|
67
68
|
}
|
|
68
69
|
set(propertyKey, pipeClass, receiver) {
|
|
69
70
|
const detector = createChangeDetectorRef(this, propertyKey);
|
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;
|
|
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,kCA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O,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"]}
|
package/providers/provider.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
import type { MetadataClass } from '@ibyar/decorators';
|
|
1
2
|
import type { ComponentRef, DirectiveRef, PipeRef, ServiceRef } from '../component/component.js';
|
|
2
|
-
import { PropertyRef } from '../component/reflect.js';
|
|
3
|
+
import { type PropertyRef } from '../component/reflect.js';
|
|
3
4
|
export type ProviderType = 'component' | 'service' | 'directive' | 'pipe' | 'self';
|
|
4
5
|
export declare class ClassRegistry {
|
|
5
|
-
viewSet: Set<
|
|
6
|
-
componentSet: Set<
|
|
7
|
-
serviceSet: Set<
|
|
8
|
-
directiveSet: Set<
|
|
9
|
-
pipeSet: Set<
|
|
10
|
-
registerView(classRef:
|
|
11
|
-
registerComponent(classRef:
|
|
12
|
-
registerService(classRef:
|
|
13
|
-
registerDirective(classRef:
|
|
14
|
-
registerPipe(classRef:
|
|
6
|
+
viewSet: Set<MetadataClass>;
|
|
7
|
+
componentSet: Set<MetadataClass>;
|
|
8
|
+
serviceSet: Set<MetadataClass>;
|
|
9
|
+
directiveSet: Set<MetadataClass>;
|
|
10
|
+
pipeSet: Set<MetadataClass>;
|
|
11
|
+
registerView(classRef: MetadataClass): void;
|
|
12
|
+
registerComponent(classRef: MetadataClass): void;
|
|
13
|
+
registerService(classRef: MetadataClass): void;
|
|
14
|
+
registerDirective(classRef: MetadataClass): void;
|
|
15
|
+
registerPipe(classRef: MetadataClass): void;
|
|
15
16
|
hasComponent<T>(selector: string): boolean;
|
|
16
17
|
getComponentRef<T>(selector: string): ComponentRef<T> | undefined;
|
|
17
|
-
getComponent<T>(selector: string):
|
|
18
|
-
getComponentView(selector: string): (
|
|
18
|
+
getComponent<T>(selector: string): MetadataClass | undefined;
|
|
19
|
+
getComponentView(selector: string): (MetadataClass<import("../index.js").HTMLComponent<unknown>> & CustomElementConstructor) | undefined;
|
|
19
20
|
hasOutput<T>(model: Object, eventName: string): PropertyRef | false;
|
|
20
21
|
hasInput<T>(model: Object, eventName: string): PropertyRef | false;
|
|
21
22
|
hasDirective<T>(selector: string): boolean;
|
|
@@ -25,3 +26,4 @@ export declare class ClassRegistry {
|
|
|
25
26
|
getService<T>(serviceName: string): ServiceRef<T> | undefined;
|
|
26
27
|
}
|
|
27
28
|
export declare const ClassRegistryProvider: ClassRegistry;
|
|
29
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EACX,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAC/C,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC9E,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnF,qBAAa,aAAa;IACzB,OAAO,EAAE,G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,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS;IAUpD,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS;CAS7D;AAED,eAAO,MAAM,qBAAqB,eAAsB,CAAC"}
|
package/providers/provider.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { ReflectComponents } from '../component/reflect.js';
|
|
2
2
|
export class ClassRegistry {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.pipeSet = new Set();
|
|
9
|
-
}
|
|
3
|
+
viewSet = new Set();
|
|
4
|
+
componentSet = new Set();
|
|
5
|
+
serviceSet = new Set();
|
|
6
|
+
directiveSet = new Set();
|
|
7
|
+
pipeSet = new Set();
|
|
10
8
|
registerView(classRef) {
|
|
11
9
|
this.viewSet.add(classRef);
|
|
12
10
|
}
|
|
@@ -24,7 +22,7 @@ export class ClassRegistry {
|
|
|
24
22
|
}
|
|
25
23
|
hasComponent(selector) {
|
|
26
24
|
for (const modelClass of this.componentSet) {
|
|
27
|
-
const componentRef = ReflectComponents.
|
|
25
|
+
const componentRef = ReflectComponents.getMetaDate(modelClass);
|
|
28
26
|
if (componentRef.selector === selector) {
|
|
29
27
|
return true;
|
|
30
28
|
}
|
|
@@ -33,7 +31,7 @@ export class ClassRegistry {
|
|
|
33
31
|
}
|
|
34
32
|
getComponentRef(selector) {
|
|
35
33
|
for (const modelClass of this.componentSet) {
|
|
36
|
-
const componentRef = ReflectComponents.
|
|
34
|
+
const componentRef = ReflectComponents.getMetaDate(modelClass);
|
|
37
35
|
if (componentRef.selector === selector) {
|
|
38
36
|
return componentRef;
|
|
39
37
|
}
|
|
@@ -42,7 +40,7 @@ export class ClassRegistry {
|
|
|
42
40
|
}
|
|
43
41
|
getComponent(selector) {
|
|
44
42
|
for (const modelClass of this.componentSet) {
|
|
45
|
-
const componentRef = ReflectComponents.
|
|
43
|
+
const componentRef = ReflectComponents.getMetaDate(modelClass);
|
|
46
44
|
if (componentRef.selector === selector) {
|
|
47
45
|
return modelClass;
|
|
48
46
|
}
|
|
@@ -80,7 +78,7 @@ export class ClassRegistry {
|
|
|
80
78
|
}
|
|
81
79
|
hasDirective(selector) {
|
|
82
80
|
for (const directiveClass of this.directiveSet) {
|
|
83
|
-
const directiveRef = ReflectComponents.
|
|
81
|
+
const directiveRef = ReflectComponents.getMetaDate(directiveClass);
|
|
84
82
|
if (directiveRef.selector === selector) {
|
|
85
83
|
return true;
|
|
86
84
|
}
|
|
@@ -89,7 +87,7 @@ export class ClassRegistry {
|
|
|
89
87
|
}
|
|
90
88
|
directiveHasInput(input, directiveType = 'attributes') {
|
|
91
89
|
for (const directiveClass of this.directiveSet) {
|
|
92
|
-
const directiveRef = ReflectComponents.
|
|
90
|
+
const directiveRef = ReflectComponents.getMetaDate(directiveClass);
|
|
93
91
|
if ((directiveType === 'attributes' && !directiveRef.selector.startsWith('*'))
|
|
94
92
|
|| (directiveType === 'structural' && directiveRef.selector.startsWith('*'))) {
|
|
95
93
|
if (directiveRef.inputs?.filter(ref => ref.viewAttribute === input).length > 0) {
|
|
@@ -101,7 +99,7 @@ export class ClassRegistry {
|
|
|
101
99
|
}
|
|
102
100
|
getDirectiveRef(selector) {
|
|
103
101
|
for (const directiveClass of this.directiveSet) {
|
|
104
|
-
const directiveRef = ReflectComponents.
|
|
102
|
+
const directiveRef = ReflectComponents.getMetaDate(directiveClass);
|
|
105
103
|
if (directiveRef.selector === selector) {
|
|
106
104
|
return directiveRef;
|
|
107
105
|
}
|
|
@@ -110,7 +108,7 @@ export class ClassRegistry {
|
|
|
110
108
|
}
|
|
111
109
|
getPipe(pipeName) {
|
|
112
110
|
for (const pipeClass of this.pipeSet) {
|
|
113
|
-
const pipeRef = ReflectComponents.
|
|
111
|
+
const pipeRef = ReflectComponents.getMetaDate(pipeClass);
|
|
114
112
|
if (pipeRef.name === pipeName) {
|
|
115
113
|
return pipeRef;
|
|
116
114
|
}
|
|
@@ -119,7 +117,7 @@ export class ClassRegistry {
|
|
|
119
117
|
}
|
|
120
118
|
getService(serviceName) {
|
|
121
119
|
for (const serviceClass of this.serviceSet) {
|
|
122
|
-
const serviceRef = ReflectComponents.
|
|
120
|
+
const serviceRef = ReflectComponents.getMetaDate(serviceClass);
|
|
123
121
|
if (serviceRef.name === serviceName) {
|
|
124
122
|
return serviceRef;
|
|
125
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/providers/provider.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/providers/provider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,yBAAyB,CAAC;AAG9E,MAAM,OAAO,aAAa;IACzB,OAAO,GAAuB,IAAI,GAAG,EAAE,CAAC;IACxC,YAAY,GAAuB,IAAI,GAAG,EAAE,CAAC;IAC7C,UAAU,GAAuB,IAAI,GAAG,EAAE,CAAC;IAC3C,YAAY,GAAuB,IAAI,GAAG,EAAE,CAAC;IAC7C,OAAO,GAAuB,IAAI,GAAG,EAAE,CAAC;IAExC,YAAY,CAAC,QAAuB;QACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IACD,iBAAiB,CAAC,QAAuB;QACxC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IACD,eAAe,CAAC,QAAuB;QACtC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IACD,iBAAiB,CAAC,QAAuB;QACxC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IACD,YAAY,CAAC,QAAuB;QACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CA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,CAAC,aAAa,KAAK,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC/E,OAAO,IAAI,CAAC;iBACZ;aACD;SACD;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,eAAe,CAAI,QAAgB;QAClC,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,YAAY,EAAE;YAC/C,MAAM,YAAY,GAAG,iBAAiB,CAAC,WAAW,CAAC,cAAc,CAAoB,CAAC;YACtF,IAAI,YAAY,CAAC,QAAQ,KAAK,QAAQ,EAAE;gBACvC,OAAO,YAAY,CAAC;aACpB;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAGD,OAAO,CAAI,QAAgB;QAC1B,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE;YACrC,MAAM,OAAO,GAAG,iBAAiB,CAAC,WAAW,CAAC,SAAS,CAAe,CAAC;YACvE,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;gBAC9B,OAAO,OAAO,CAAC;aACf;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,UAAU,CAAI,WAAmB;QAChC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,UAAU,EAAE;YAC3C,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,YAAY,CAAkB,CAAC;YAChF,IAAI,UAAU,CAAC,IAAI,KAAK,WAAW,EAAE;gBACpC,OAAO,UAAU,CAAC;aAClB;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["import type { MetadataClass } from '@ibyar/decorators';\nimport type {\n\tComponentRef, DirectiveRef, PipeRef, ServiceRef\n} from '../component/component.js';\nimport { ReflectComponents, type PropertyRef } from '../component/reflect.js';\nexport type ProviderType = 'component' | 'service' | 'directive' | 'pipe' | 'self';\n\nexport class ClassRegistry {\n\tviewSet: Set<MetadataClass> = new Set();\n\tcomponentSet: Set<MetadataClass> = new Set();\n\tserviceSet: Set<MetadataClass> = new Set();\n\tdirectiveSet: Set<MetadataClass> = new Set();\n\tpipeSet: Set<MetadataClass> = new Set();\n\n\tregisterView(classRef: MetadataClass): void {\n\t\tthis.viewSet.add(classRef);\n\t}\n\tregisterComponent(classRef: MetadataClass): void {\n\t\tthis.componentSet.add(classRef);\n\t}\n\tregisterService(classRef: MetadataClass): void {\n\t\tthis.serviceSet.add(classRef);\n\t}\n\tregisterDirective(classRef: MetadataClass): void {\n\t\tthis.directiveSet.add(classRef);\n\t}\n\tregisterPipe(classRef: MetadataClass): void {\n\t\tthis.pipeSet.add(classRef);\n\t}\n\n\thasComponent<T>(selector: string): boolean {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef = ReflectComponents.getMetaDate(modelClass) as ComponentRef<T>;\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tgetComponentRef<T>(selector: string): ComponentRef<T> | undefined {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef = ReflectComponents.getMetaDate(modelClass) as ComponentRef<T>;\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn componentRef;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tgetComponent<T>(selector: string) {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef = ReflectComponents.getMetaDate(modelClass) as ComponentRef<T>;\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn modelClass;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tgetComponentView(selector: string) {\n\t\treturn this.getComponentRef(selector)?.viewClass;\n\t}\n\n\thasOutput<T>(model: Object, eventName: string): PropertyRef | false {\n\t\tif (Reflect.has(model, 'bootstrap')) {\n\t\t\tconst componentRef: ComponentRef<T> = Reflect.get(model, 'bootstrap');\n\t\t\tif (componentRef.outputs) {\n\t\t\t\tfor (const out of componentRef.outputs) {\n\t\t\t\t\tif (out.viewAttribute === eventName) {\n\t\t\t\t\t\treturn out;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\thasInput<T>(model: Object, eventName: string): PropertyRef | false {\n\t\tif (Reflect.has(model, 'bootstrap')) {\n\t\t\tconst componentRef: ComponentRef<T> = Reflect.get(model, 'bootstrap');\n\t\t\tif (componentRef.inputs) {\n\t\t\t\tfor (const input of componentRef.inputs) {\n\t\t\t\t\tif (input.viewAttribute === eventName) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\thasDirective<T>(selector: string): boolean {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef = ReflectComponents.getMetaDate(directiveClass) as DirectiveRef<T>;\n\t\t\tif (directiveRef.selector === selector) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tdirectiveHasInput<T>(input: string, directiveType: 'attributes' | 'structural' = 'attributes'): boolean {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef = ReflectComponents.getMetaDate(directiveClass) as DirectiveRef<T>;\n\t\t\tif ((directiveType === 'attributes' && !directiveRef.selector.startsWith('*'))\n\t\t\t\t|| (directiveType === 'structural' && directiveRef.selector.startsWith('*'))) {\n\t\t\t\tif (directiveRef.inputs?.filter(ref => ref.viewAttribute === input).length > 0) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetDirectiveRef<T>(selector: string): DirectiveRef<T> | undefined {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef = ReflectComponents.getMetaDate(directiveClass) as DirectiveRef<T>;\n\t\t\tif (directiveRef.selector === selector) {\n\t\t\t\treturn directiveRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\n\tgetPipe<T>(pipeName: string): PipeRef<T> | undefined {\n\t\tfor (const pipeClass of this.pipeSet) {\n\t\t\tconst pipeRef = ReflectComponents.getMetaDate(pipeClass) as PipeRef<T>;\n\t\t\tif (pipeRef.name === pipeName) {\n\t\t\t\treturn pipeRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tgetService<T>(serviceName: string): ServiceRef<T> | undefined {\n\t\tfor (const serviceClass of this.serviceSet) {\n\t\t\tconst serviceRef = ReflectComponents.getMetaDate(serviceClass) as ServiceRef<T>;\n\t\t\tif (serviceRef.name === serviceName) {\n\t\t\t\treturn serviceRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n\nexport const ClassRegistryProvider = new ClassRegistry();\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Context, ReactiveScope } from '@ibyar/expressions';
|
|
2
|
+
export interface ScopeVariable<T> {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
get(): T | undefined;
|
|
5
|
+
set(value: T | undefined): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class ScopeVariable<T> implements ScopeVariable<T> {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
private scope;
|
|
10
|
+
constructor(name: string, scope: ReactiveScope<Context>, value?: T);
|
|
11
|
+
}
|
|
12
|
+
export declare class ScopeEdit {
|
|
13
|
+
private scopes;
|
|
14
|
+
getScope<T extends Context>(): ReactiveScope<T>;
|
|
15
|
+
pushScope<T extends Context>(scope: ReactiveScope<T>): void;
|
|
16
|
+
popScope<T extends Context>(): ReactiveScope<T> | undefined;
|
|
17
|
+
}
|
|
18
|
+
export declare function input<T>(name: string, value?: T): ScopeVariable<T>;
|
|
19
|
+
//# sourceMappingURL=variables.d.ts.map
|