@ibyar/core 2.3.0 → 2.5.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 +23 -2
- package/annotation/decorators.d.ts.map +1 -1
- package/annotation/decorators.js +18 -0
- package/annotation/decorators.js.map +1 -1
- package/annotation/options.d.ts +11 -7
- package/annotation/options.d.ts.map +1 -1
- package/annotation/options.js.map +1 -1
- package/binding/binding.expressions.d.ts +2 -2
- package/binding/binding.expressions.d.ts.map +1 -1
- package/binding/binding.expressions.js.map +1 -1
- package/component/component.d.ts +15 -10
- package/component/component.d.ts.map +1 -1
- package/component/component.js +46 -1
- package/component/component.js.map +1 -1
- package/component/custom-element.d.ts +6 -2
- package/component/custom-element.d.ts.map +1 -1
- package/component/custom-element.js.map +1 -1
- package/component/events.js.map +1 -1
- package/component/initializer.d.ts +67 -0
- package/component/initializer.d.ts.map +1 -0
- package/component/initializer.js +59 -0
- package/component/initializer.js.map +1 -0
- package/di/inject.d.ts +11 -4
- package/di/inject.d.ts.map +1 -1
- package/di/inject.js +18 -2
- package/di/inject.js.map +1 -1
- package/di/provider.d.ts +7 -5
- package/di/provider.d.ts.map +1 -1
- package/di/provider.js +29 -13
- package/di/provider.js.map +1 -1
- package/directive/directive.d.ts +3 -2
- package/directive/directive.d.ts.map +1 -1
- package/directive/directive.js +6 -3
- package/directive/directive.js.map +1 -1
- package/html/deserialize.d.ts.map +1 -1
- package/html/deserialize.js +11 -2
- package/html/deserialize.js.map +1 -1
- package/html/expression.d.ts.map +1 -1
- package/html/expression.js +14 -5
- package/html/expression.js.map +1 -1
- package/html/types.d.ts +6 -0
- package/html/types.d.ts.map +1 -1
- package/html/types.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/initializer/input.d.ts +1 -0
- package/initializer/input.d.ts.map +1 -0
- package/initializer/input.js +2 -0
- package/initializer/input.js.map +1 -0
- package/linker/change-detector-ref.d.ts.map +1 -1
- package/linker/change-detector-ref.js +26 -4
- package/linker/change-detector-ref.js.map +1 -1
- package/linker/view-container-ref.d.ts +4 -4
- package/linker/view-container-ref.d.ts.map +1 -1
- package/linker/view-container-ref.js.map +1 -1
- package/package.json +8 -8
- package/pipe/pipe.d.ts +6 -6
- package/pipe/pipe.d.ts.map +1 -1
- package/pipe/pipe.js.map +1 -1
- package/signals/factory.d.ts +23 -0
- package/signals/factory.d.ts.map +1 -0
- package/signals/factory.js +65 -0
- package/signals/factory.js.map +1 -0
- package/signals/initializer.d.ts +26 -0
- package/signals/initializer.d.ts.map +1 -0
- package/signals/initializer.js +19 -0
- package/signals/initializer.js.map +1 -0
- package/signals/input.d.ts +1 -0
- package/signals/input.d.ts.map +1 -0
- package/signals/input.js +2 -0
- package/signals/input.js.map +1 -0
- package/signals/runtime.d.ts +37 -0
- package/signals/runtime.d.ts.map +1 -0
- package/signals/runtime.js +165 -0
- package/signals/runtime.js.map +1 -0
- package/signals/signals.d.ts +11 -9
- package/signals/signals.d.ts.map +1 -1
- package/signals/signals.js +23 -41
- package/signals/signals.js.map +1 -1
- package/utils/typeof.d.ts +4 -2
- package/utils/typeof.d.ts.map +1 -1
- package/utils/typeof.js.map +1 -1
- package/view/base-view.d.ts +2 -2
- package/view/base-view.d.ts.map +1 -1
- package/view/base-view.js +42 -24
- package/view/base-view.js.map +1 -1
- package/view/form-view.d.ts +2 -2
- package/view/form-view.d.ts.map +1 -1
- package/view/form-view.js +2 -1
- package/view/form-view.js.map +1 -1
- package/view/render.d.ts +4 -1
- package/view/render.d.ts.map +1 -1
- package/view/render.js +32 -6
- package/view/render.js.map +1 -1
- package/view/utils.d.ts +2 -2
- package/view/utils.d.ts.map +1 -1
- package/view/utils.js.map +1 -1
- package/view/view.d.ts +3 -3
- package/view/view.d.ts.map +1 -1
- package/view/view.js +27 -7
- package/view/view.js.map +1 -1
- package/zone/zone.js +1 -1
- package/zone/zone.js.map +1 -1
package/directive/directive.js
CHANGED
|
@@ -6,13 +6,16 @@ export class StructuralDirective {
|
|
|
6
6
|
viewContainerRef;
|
|
7
7
|
host;
|
|
8
8
|
_zone;
|
|
9
|
-
|
|
10
|
-
constructor(templateRef, viewContainerRef, host, _zone,
|
|
9
|
+
successors;
|
|
10
|
+
constructor(templateRef, viewContainerRef, host, _zone, successors) {
|
|
11
11
|
this.templateRef = templateRef;
|
|
12
12
|
this.viewContainerRef = viewContainerRef;
|
|
13
13
|
this.host = host;
|
|
14
14
|
this._zone = _zone;
|
|
15
|
-
this.
|
|
15
|
+
this.successors = successors;
|
|
16
|
+
}
|
|
17
|
+
getSuccessor(name) {
|
|
18
|
+
return this.successors[name];
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAEpB;IACA;IACA;IACA;
|
|
1
|
+
{"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAEpB;IACA;IACA;IACA;IACF;IALT,YACW,WAAwB,EACxB,gBAAkC,EAClC,IAA8C,EAC9C,KAAiB,EACnB,UAAuC;QAJrC,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,SAAI,GAAJ,IAAI,CAA0C;QAC9C,UAAK,GAAL,KAAK,CAAY;QACnB,eAAU,GAAV,UAAU,CAA6B;IAC5C,CAAC;IAEL,YAAY,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CAED;AAED;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACR;IAA2B;IAAjD,YAAsB,EAAe,EAAY,KAAiB;QAA5C,OAAE,GAAF,EAAE,CAAa;QAAY,UAAK,GAAL,KAAK,CAAY;IAAI,CAAC;CACvE;AAED;;GAEG;AACH,MAAM,OAAO,8BAA8B;IACpB;IAA0C;IAAhE,YAAsB,SAA8B,EAAY,KAAiB;QAA3D,cAAS,GAAT,SAAS,CAAqB;QAAY,UAAK,GAAL,KAAK,CAAY;IAAI,CAAC;CACtF","sourcesContent":["\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { TemplateRef } from '../linker/template-ref.js';\nimport { ViewContainerRef } from '../linker/view-container-ref.js';\nimport { AuroraZone } from '../zone/zone.js';\n\n/**\n * A structural directive selector as '*if' '*for'\n */\nexport class StructuralDirective {\n\tconstructor(\n\t\tprotected templateRef: TemplateRef,\n\t\tprotected viewContainerRef: ViewContainerRef,\n\t\tprotected host: HTMLComponent<any> | StructuralDirective,\n\t\tprotected _zone: AuroraZone,\n\t\tprivate successors: Record<string, TemplateRef>,\n\t) { }\n\n\tgetSuccessor(name: string): TemplateRef | undefined {\n\t\treturn this.successors[name];\n\t}\n\n}\n\n/**\n * An attributes directive selector as '[class] [style]'\n */\nexport class AttributeDirective {\n\tconstructor(protected el: HTMLElement, protected _zone: AuroraZone) { }\n}\n\n/**\n * An attributes directive on structural directive\n */\nexport class AttributeOnStructuralDirective {\n\tconstructor(protected directive: StructuralDirective, protected _zone: AuroraZone) { }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../src/core/html/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACgD,OAAO,EAI7D,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../src/core/html/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACgD,OAAO,EAI7D,MAAM,iBAAiB,CAAC;AA6EzB,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,QAMvD"}
|
package/html/deserialize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent } from '@ibyar/elements';
|
|
1
|
+
import { DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent, LocalTemplateVariables } from '@ibyar/elements';
|
|
2
2
|
import { deserialize } from '@ibyar/expressions';
|
|
3
3
|
import { getPipelineNames } from './expression.js';
|
|
4
4
|
function deserializeLiveText(text) {
|
|
@@ -7,6 +7,12 @@ function deserializeLiveText(text) {
|
|
|
7
7
|
text.pipelineNames = getPipelineNames(text.expression.getRight());
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
function deserializeLocalTemplateVariables(local) {
|
|
11
|
+
local.variables?.forEach(variable => {
|
|
12
|
+
variable.expression = deserialize(variable.expression);
|
|
13
|
+
variable.pipelineNames = getPipelineNames(variable.expression.getRight());
|
|
14
|
+
});
|
|
15
|
+
}
|
|
10
16
|
function deserializeLiveAttribute(attr) {
|
|
11
17
|
if (attr.expression) {
|
|
12
18
|
attr.expression = deserialize(attr.expression);
|
|
@@ -46,7 +52,7 @@ function deserializeChild(child) {
|
|
|
46
52
|
child.templateExpressions = child.templateExpressions?.map(deserialize) ?? [];
|
|
47
53
|
deserializeChild(child.node);
|
|
48
54
|
deserializeBaseNode(child);
|
|
49
|
-
child.
|
|
55
|
+
child.successors?.forEach(deserializeChild);
|
|
50
56
|
}
|
|
51
57
|
else if (isLiveTextContent(child)) {
|
|
52
58
|
deserializeLiveText(child);
|
|
@@ -54,6 +60,9 @@ function deserializeChild(child) {
|
|
|
54
60
|
else if (child instanceof DomFragmentNode) {
|
|
55
61
|
deserializeDomParentNode(child);
|
|
56
62
|
}
|
|
63
|
+
else if (child instanceof LocalTemplateVariables) {
|
|
64
|
+
deserializeLocalTemplateVariables(child);
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
67
|
function deserializeDomParentNode(parent) {
|
|
59
68
|
parent.children?.forEach(deserializeChild);
|
package/html/deserialize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../src/core/html/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,0BAA0B,EAAE,cAAc,EACpD,eAAe,EACf,iBAAiB,
|
|
1
|
+
{"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../src/core/html/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,0BAA0B,EAAE,cAAc,EACpD,eAAe,EACf,iBAAiB,EACU,sBAAsB,EACjD,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,SAAS,mBAAmB,CAAC,IAAqB;IACjD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAA2B,CAAC;QACzE,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;AACF,CAAC;AAED,SAAS,iCAAiC,CAAC,KAA6B;IACvE,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;QACnC,QAAQ,CAAC,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,UAAU,CAA+B,CAAC;QACrF,QAAQ,CAAC,aAAa,GAAG,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAmB;IACpD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAA2B,CAAC;IAC1E,CAAC;AACF,CAAC;AAED,SAAS,qCAAqC,CAA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,CAAC;IACjC,CAAC;SAAM,IAAI,KAAK,YAAY,0BAA0B,EAAE,CAAC;QACvD,KAA2C,CAAC,mBAAmB,GAAI,KAA2C,CAAC,mBAAmB,EAAE,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAC5J,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC3B,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;SAAM,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;QAC7C,wBAAwB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;SAAM,IAAI,KAAK,YAAY,sBAAsB,EAAE,CAAC;QACpD,iCAAiC,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;AACF,CAAC;AAED,SAAS,wBAAwB,CAAC,MAAqB;IACtD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAa;IACvD,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;QACrC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACP,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["import {\n\tBaseNode, DomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomAttributeDirectiveNode, LocalTemplateVariables\n} from '@ibyar/elements';\n\nimport type { DomStructuralDirectiveNodeUpgrade } from '@ibyar/elements/node.js';\nimport { deserialize } from '@ibyar/expressions';\nimport { getPipelineNames } from './expression.js';\n\nfunction deserializeLiveText(text: LiveTextContent) {\n\tif (text.expression) {\n\t\ttext.expression = deserialize(text.expression) as typeof text.expression;\n\t\ttext.pipelineNames = getPipelineNames(text.expression.getRight());\n\t}\n}\n\nfunction deserializeLocalTemplateVariables(local: LocalTemplateVariables) {\n\tlocal.variables?.forEach(variable => {\n\t\tvariable.expression = deserialize(variable.expression) as typeof variable.expression;\n\t\tvariable.pipelineNames = getPipelineNames(variable.expression.getRight());\n\t});\n}\n\nfunction deserializeLiveAttribute(attr: LiveAttribute) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t}\n}\n\nfunction deserializeLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t\tattr.pipelineNames = getPipelineNames(attr.expression.getRight());\n\t}\n}\n\nfunction deserializeOutputExpression(attr: ElementAttribute<string, string>) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t}\n}\n\nfunction deserializeAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(deserializeLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(deserializeOutputExpression);\n\tdirective.twoWayBinding?.forEach(deserializeLiveAttribute);\n\tdirective.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);\n}\n\nfunction deserializeBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(deserializeLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(deserializeOutputExpression);\n\tbase.twoWayBinding?.forEach(deserializeLiveAttribute);\n\tbase.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(deserializeAttributeDirectives);\n}\n\nfunction deserializeChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tdeserializeBaseNode(child);\n\t\tdeserializeDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = (child as DomStructuralDirectiveNodeUpgrade).templateExpressions?.map(deserialize) ?? [];\n\t\tdeserializeChild(child.node);\n\t\tdeserializeBaseNode(child);\n\t\tchild.successors?.forEach(deserializeChild);\n\t} else if (isLiveTextContent(child)) {\n\t\tdeserializeLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tdeserializeDomParentNode(child);\n\t} else if (child instanceof LocalTemplateVariables) {\n\t\tdeserializeLocalTemplateVariables(child);\n\t}\n}\n\nfunction deserializeDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(deserializeChild);\n}\n\nexport function deserializeExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tdeserializeDomParentNode(node);\n\t} else {\n\t\tdeserializeChild(node);\n\t}\n}\n"]}
|
package/html/expression.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAEsC,OAAO,
|
|
1
|
+
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAEsC,OAAO,EAKnD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,cAAc,EAMd,MAAM,oBAAoB,CAAC;AAoF5B,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,cAAc,GAAG,MAAM,EAAE,GAAG,SAAS,CAWtF;AA8FD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,QAMjD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAE/D;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,QAE/C"}
|
package/html/expression.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createLiveAttribute, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent } from '@ibyar/elements/node.js';
|
|
2
|
-
import {
|
|
1
|
+
import { createLiveAttribute, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent, isLocalTemplateVariables } from '@ibyar/elements/node.js';
|
|
2
|
+
import { Identifier, MemberExpression, JavaScriptParser, expressionVisitor } from '@ibyar/expressions';
|
|
3
3
|
import { OneWayAssignmentExpression, TwoWayAssignmentExpression } from '../binding/binding.expressions.js';
|
|
4
4
|
import { DirectiveExpressionParser } from '../directive/parser.js';
|
|
5
5
|
import { classRegistryProvider } from '../providers/provider.js';
|
|
@@ -9,6 +9,14 @@ function parseLiveText(text) {
|
|
|
9
9
|
text.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);
|
|
10
10
|
text.pipelineNames = getPipelineNames(textExpression);
|
|
11
11
|
}
|
|
12
|
+
function parseLocalTemplateVariables(local) {
|
|
13
|
+
const expression = JavaScriptParser.parseScript(`let ${local.declarations}`);
|
|
14
|
+
local.variables = expression.getDeclarations().map(declaration => {
|
|
15
|
+
const expression = new OneWayAssignmentExpression(declaration.getId(), declaration.getInit());
|
|
16
|
+
const pipelineNames = getPipelineNames(expression.getRight());
|
|
17
|
+
return { expression, pipelineNames };
|
|
18
|
+
});
|
|
19
|
+
}
|
|
12
20
|
/**
|
|
13
21
|
* user-name ==> userName
|
|
14
22
|
*
|
|
@@ -143,13 +151,14 @@ function parseChild(child) {
|
|
|
143
151
|
// in case if add input/output support need to handle that here.
|
|
144
152
|
parseChild(child.node);
|
|
145
153
|
parseBaseNode(child);
|
|
146
|
-
|
|
147
|
-
parseChild(child.successor);
|
|
148
|
-
}
|
|
154
|
+
child.successors?.forEach(parseChild);
|
|
149
155
|
}
|
|
150
156
|
else if (isLiveTextContent(child)) {
|
|
151
157
|
parseLiveText(child);
|
|
152
158
|
}
|
|
159
|
+
else if (isLocalTemplateVariables(child)) {
|
|
160
|
+
parseLocalTemplateVariables(child);
|
|
161
|
+
}
|
|
153
162
|
else if (child instanceof DomFragmentNode) {
|
|
154
163
|
parseDomParentNode(child);
|
|
155
164
|
}
|
package/html/expression.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,mBAAmB,EAC7B,0BAA0B,EAAE,cAAc,EAC1C,eAAe,EACf,iBAAiB,EAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACU,iBAAiB,EAAE,UAAU,EAC7C,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,eAAe,GAAG,gBAAgB,CAAC,WAAW,CAAC,kBAAkB,CAAqB,CAAC;AAC7F,SAAS,aAAa,CAAC,IAAqB;IAC3C,MAAM,cAAc,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChE,IAAI,CAAC,UAAU,GAAG,IAAI,0BAA0B,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IAClF,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,SAAS,0BAA0B,CAAC,MAAyB;IAC5D,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,MAAgB,CAAC;IACzB,CAAC;IACD,OAAO,UAA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AC,EAAE,CAAC,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAAG,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,MAAM,UAAU,GAAG,OAAO,QAAQ,MAAM,CAAC,OAAO,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACrG,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAqB;IAChD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAa;IACjD,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;QACrC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACP,UAAU,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAA+B;IAC/D,qBAAqB,CAAC,iBAAiB,CAAC,UAAiB,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,qBAAqB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {\n\tBaseNode, createLiveAttribute,\n\tDomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomStructuralDirectiveNodeUpgrade, DomAttributeDirectiveNode\n} from '@ibyar/elements/node.js';\nimport {\n\tExpressionNode, expressionVisitor, Identifier,\n\tJavaScriptParser, MemberExpression, PipelineExpression\n} from '@ibyar/expressions';\nimport {\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { classRegistryProvider } from '../providers/provider.js';\n\nconst ThisTextContent = JavaScriptParser.parseScript('this.textContent') as MemberExpression;\nfunction parseLiveText(text: LiveTextContent) {\n\tconst textExpression = JavaScriptParser.parseScript(text.value);\n\ttext.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);\n\ttext.pipelineNames = getPipelineNames(textExpression);\n}\n\n/**\n * user-name ==> userName\n * \n * @param source \n * @returns \n */\nfunction convertToMemberAccessStyle(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('-');\n\tif (dashSplits.length === 1) {\n\t\treturn source as string;\n\t}\n\treturn dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');\n}\n\nfunction getAccessNotation(property: string) {\n\tif (property.includes('-')) {\n\t\treturn [`['`, property, `']`];\n\t} else if (Number.isInteger(property.at(0))) {\n\t\treturn ['[', property, ']'];\n\t}\n\treturn ['.', property];\n}\n\n/**\n * user.tel-number ==> user['tel-number']\n * \n * @param source \n * @returns \n */\nfunction escapeMemberExpression(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('.');\n\treturn dashSplits.flatMap(property => getAccessNotation(property)).join('');\n}\n\n/**\n * warp js code with `()` if necessary\n * \n * `{name: 'alex'}` will be `({name: 'alex'})`\n * \n * @param params \n */\nfunction checkAndValidateObjectSyntax(source: string) {\n\tif (source.startsWith('{')) {\n\t\treturn `(${source})`;\n\t}\n\treturn source;\n}\nfunction parseLiveAttribute(attr: LiveAttribute) {\n\tconst elementSource = `this${escapeMemberExpression(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression\n\t\t&& (modelExpression instanceof MemberExpression || modelExpression instanceof Identifier)) {\n\t\tattr.expression = new TwoWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name}=\"${attr.value}\"\" is not a valid MemberExpression or Identifier 'x.y.z'`);\n\t}\n\n}\n\nexport function getPipelineNames(modelExpression: ExpressionNode): string[] | undefined {\n\tconst pipelineNames: string[] = [];\n\texpressionVisitor.visit(modelExpression, (expression, type, control) => {\n\t\tif (type === 'PipelineExpression') {\n\t\t\tconst pipelineName = (expression as PipelineExpression).getRight();\n\t\t\tif (pipelineName instanceof Identifier) {\n\t\t\t\tpipelineNames.push(pipelineName.getName() as string);\n\t\t\t}\n\t\t}\n\t});\n\treturn pipelineNames.length ? pipelineNames : undefined;\n}\n\nfunction parseLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tconst elementSource = attr.name.startsWith('data-')\n\t\t? `this.dataset.${convertToMemberAccessStyle(attr.name.substring(5))}`\n\t\t: `this${escapeMemberExpression(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression) {\n\t\tattr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`[${attr.name}] is not a valid MemberExpression 'x.y.z'`);\n\t}\n\tattr.pipelineNames = getPipelineNames(modelExpression);\n}\n\nfunction parseOutputExpression(attr: ElementAttribute<string, string>) {\n\tattr.expression = JavaScriptParser.parseScript(attr.value);\n}\n\nfunction parseAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(parseOutputExpression);\n\tdirective.twoWayBinding?.forEach(parseLiveAttribute);\n\tdirective.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n}\n\nfunction parseBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(parseOutputExpression);\n\tbase.twoWayBinding?.forEach(parseLiveAttribute);\n\tbase.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(parseAttributeDirectives);\n}\n\nfunction parseChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tparseBaseNode(child);\n\t\tparseDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\tconst expressions: ExpressionNode[] = [];\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = expressions;\n\t\tif (child.value) {\n\t\t\t// use shorthand syntax, possible mixed with input and outputs\n\t\t\tconst info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);\n\t\t\texpressions.push(...info.templateExpressions.map(template => JavaScriptParser.parseScript(template)));\n\t\t\t// <div let-i=\"index\">{{item}}</div>\n\n\t\t\tsearchForLetAttributes(child, expressions);\n\n\t\t\tif (info.directiveInputs.size > 0) {\n\t\t\t\tconst ref = classRegistryProvider.getDirectiveRef(child.name);\n\t\t\t\tif (!ref?.inputs?.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchild.inputs ??= [];\n\t\t\t\tinfo.directiveInputs.forEach((expression, input) => {\n\t\t\t\t\tconst modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;\n\t\t\t\t\tconst attr: LiveAttribute = createLiveAttribute(modelName, expression);\n\t\t\t\t\t(child.inputs ??= []).push(attr);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tsearchForLetAttributes(child, expressions);\n\t\t}\n\t\t// DomDirectiveNode\n\t\t// in case if add input/output support need to handle that here.\n\t\tparseChild(child.node);\n\t\tparseBaseNode(child);\n\t\tif (child.successor) {\n\t\t\tparseChild(child.successor);\n\t\t}\n\t} else if (isLiveTextContent(child)) {\n\t\tparseLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tparseDomParentNode(child);\n\t}\n}\n\nfunction searchForLetAttributes(child: DomStructuralDirectiveNode, expressions: ExpressionNode[]) {\n\tconst templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));\n\ttemplateExpressionsFromInput?.forEach(attr => {\n\t\tchild.attributes!.splice(child.attributes!.indexOf(attr), 1);\n\t\tconst attrName = convertToMemberAccessStyle(attr.name.split('-').slice(1));\n\t\tconst expression = `let ${attrName} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;\n\t\texpressions.push(JavaScriptParser.parseScript(expression));\n\t});\n}\n\nfunction parseDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(parseChild);\n}\n\nexport function buildExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tparseDomParentNode(node);\n\t} else {\n\t\tparseChild(node);\n\t}\n}\n\n/**\n * function to skip node checking\n * @param modelClass \n */\nexport function provideDirective(modelClass: Record<string, any>) {\n\tclassRegistryProvider.registerDirective(modelClass as any);\n}\n\nexport function deleteDirective(selector: string) {\n\tclassRegistryProvider.deleteDirective(selector);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,mBAAmB,EAC7B,0BAA0B,EAAE,cAAc,EAC1C,eAAe,EACf,iBAAiB,EAEO,wBAAwB,EAChD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,UAAU,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAGjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,eAAe,GAAG,gBAAgB,CAAC,WAAW,CAAC,kBAAkB,CAAqB,CA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G,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,MAAM,UAAU,GAAG,OAAO,QAAQ,MAAM,CAAC,OAAO,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACrG,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAqB;IAChD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAa;IACjD,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;QACrC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACP,UAAU,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAA+B;IAC/D,qBAAqB,CAAC,iBAAiB,CAAC,UAAiB,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,qBAAqB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {\n\tBaseNode, createLiveAttribute,\n\tDomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomStructuralDirectiveNodeUpgrade, DomAttributeDirectiveNode,\n\tLocalTemplateVariables, isLocalTemplateVariables\n} from '@ibyar/elements/node.js';\nimport {\n\tIdentifier,\n\tExpressionNode,\n\tMemberExpression,\n\tJavaScriptParser,\n\texpressionVisitor,\n\tPipelineExpression,\n\tVariableDeclarationNode\n} from '@ibyar/expressions';\nimport {\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { classRegistryProvider } from '../providers/provider.js';\n\nconst ThisTextContent = JavaScriptParser.parseScript('this.textContent') as MemberExpression;\nfunction parseLiveText(text: LiveTextContent) {\n\tconst textExpression = JavaScriptParser.parseScript(text.value);\n\ttext.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);\n\ttext.pipelineNames = getPipelineNames(textExpression);\n}\n\nfunction parseLocalTemplateVariables(local: LocalTemplateVariables) {\n\tconst expression = JavaScriptParser.parseScript<VariableDeclarationNode>(`let ${local.declarations}`);\n\tlocal.variables = expression.getDeclarations().map(declaration => {\n\t\tconst expression = new OneWayAssignmentExpression(declaration.getId(), declaration.getInit()!);\n\t\tconst pipelineNames = getPipelineNames(expression.getRight());\n\t\treturn { expression, pipelineNames };\n\t});\n}\n\n/**\n * user-name ==> userName\n * \n * @param source \n * @returns \n */\nfunction convertToMemberAccessStyle(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('-');\n\tif (dashSplits.length === 1) {\n\t\treturn source as string;\n\t}\n\treturn dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');\n}\n\nfunction getAccessNotation(property: string) {\n\tif (property.includes('-')) {\n\t\treturn [`['`, property, `']`];\n\t} else if (Number.isInteger(property.at(0))) {\n\t\treturn ['[', property, ']'];\n\t}\n\treturn ['.', property];\n}\n\n/**\n * user.tel-number ==> user['tel-number']\n * \n * @param source \n * @returns \n */\nfunction escapeMemberExpression(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('.');\n\treturn dashSplits.flatMap(property => getAccessNotation(property)).join('');\n}\n\n/**\n * warp js code with `()` if necessary\n * \n * `{name: 'alex'}` will be `({name: 'alex'})`\n * \n * @param params \n */\nfunction checkAndValidateObjectSyntax(source: string) {\n\tif (source.startsWith('{')) {\n\t\treturn `(${source})`;\n\t}\n\treturn source;\n}\nfunction parseLiveAttribute(attr: LiveAttribute) {\n\tconst elementSource = `this${escapeMemberExpression(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression\n\t\t&& (modelExpression instanceof MemberExpression || modelExpression instanceof Identifier)) {\n\t\tattr.expression = new TwoWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name}=\"${attr.value}\"\" is not a valid MemberExpression or Identifier 'x.y.z'`);\n\t}\n\n}\n\nexport function getPipelineNames(modelExpression: ExpressionNode): string[] | undefined {\n\tconst pipelineNames: string[] = [];\n\texpressionVisitor.visit(modelExpression, (expression, type, control) => {\n\t\tif (type === 'PipelineExpression') {\n\t\t\tconst pipelineName = (expression as PipelineExpression).getRight();\n\t\t\tif (pipelineName instanceof Identifier) {\n\t\t\t\tpipelineNames.push(pipelineName.getName() as string);\n\t\t\t}\n\t\t}\n\t});\n\treturn pipelineNames.length ? pipelineNames : undefined;\n}\n\nfunction parseLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tconst elementSource = attr.name.startsWith('data-')\n\t\t? `this.dataset.${convertToMemberAccessStyle(attr.name.substring(5))}`\n\t\t: `this${escapeMemberExpression(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression) {\n\t\tattr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`[${attr.name}] is not a valid MemberExpression 'x.y.z'`);\n\t}\n\tattr.pipelineNames = getPipelineNames(modelExpression);\n}\n\nfunction parseOutputExpression(attr: ElementAttribute<string, string>) {\n\tattr.expression = JavaScriptParser.parseScript(attr.value);\n}\n\nfunction parseAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(parseOutputExpression);\n\tdirective.twoWayBinding?.forEach(parseLiveAttribute);\n\tdirective.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n}\n\nfunction parseBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(parseOutputExpression);\n\tbase.twoWayBinding?.forEach(parseLiveAttribute);\n\tbase.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(parseAttributeDirectives);\n}\n\nfunction parseChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tparseBaseNode(child);\n\t\tparseDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\tconst expressions: ExpressionNode[] = [];\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = expressions;\n\t\tif (child.value) {\n\t\t\t// use shorthand syntax, possible mixed with input and outputs\n\t\t\tconst info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);\n\t\t\texpressions.push(...info.templateExpressions.map(template => JavaScriptParser.parseScript(template)));\n\t\t\t// <div let-i=\"index\">{{item}}</div>\n\n\t\t\tsearchForLetAttributes(child, expressions);\n\n\t\t\tif (info.directiveInputs.size > 0) {\n\t\t\t\tconst ref = classRegistryProvider.getDirectiveRef(child.name);\n\t\t\t\tif (!ref?.inputs?.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchild.inputs ??= [];\n\t\t\t\tinfo.directiveInputs.forEach((expression, input) => {\n\t\t\t\t\tconst modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;\n\t\t\t\t\tconst attr: LiveAttribute = createLiveAttribute(modelName, expression);\n\t\t\t\t\t(child.inputs ??= []).push(attr);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tsearchForLetAttributes(child, expressions);\n\t\t}\n\t\t// DomDirectiveNode\n\t\t// in case if add input/output support need to handle that here.\n\t\tparseChild(child.node);\n\t\tparseBaseNode(child);\n\t\tchild.successors?.forEach(parseChild);\n\t} else if (isLiveTextContent(child)) {\n\t\tparseLiveText(child);\n\t} else if (isLocalTemplateVariables(child)) {\n\t\tparseLocalTemplateVariables(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tparseDomParentNode(child);\n\t}\n}\n\nfunction searchForLetAttributes(child: DomStructuralDirectiveNode, expressions: ExpressionNode[]) {\n\tconst templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));\n\ttemplateExpressionsFromInput?.forEach(attr => {\n\t\tchild.attributes!.splice(child.attributes!.indexOf(attr), 1);\n\t\tconst attrName = convertToMemberAccessStyle(attr.name.split('-').slice(1));\n\t\tconst expression = `let ${attrName} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;\n\t\texpressions.push(JavaScriptParser.parseScript(expression));\n\t});\n}\n\nfunction parseDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(parseChild);\n}\n\nexport function buildExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tparseDomParentNode(node);\n\t} else {\n\t\tparseChild(node);\n\t}\n}\n\n/**\n * function to skip node checking\n * @param modelClass \n */\nexport function provideDirective(modelClass: Record<string, any>) {\n\tclassRegistryProvider.registerDirective(modelClass as any);\n}\n\nexport function deleteDirective(selector: string) {\n\tclassRegistryProvider.deleteDirective(selector);\n}\n"]}
|
package/html/types.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ declare module '@ibyar/elements/node.js' {
|
|
|
13
13
|
expression: OneWayAssignmentExpression;
|
|
14
14
|
pipelineNames?: string[];
|
|
15
15
|
}
|
|
16
|
+
interface LocalTemplateVariables {
|
|
17
|
+
variables: Array<{
|
|
18
|
+
expression: OneWayAssignmentExpression;
|
|
19
|
+
pipelineNames?: string[];
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
16
22
|
interface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {
|
|
17
23
|
/**
|
|
18
24
|
* create a new scope for a template and bind the new variables to the directive scope.
|
package/html/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/html/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAEvG,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,gBAAgB,CAAC,CAAC,EAAE,CAAC;QAC9B,UAAU,EAAE,cAAc,CAAC;KAC3B;IAED,UAAU,aAAa;QACtB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KACzB;IAED,UAAU,eAAe;QACxB,UAAU,EAAE,0BAA0B,CAAC;QACvC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KACzB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/html/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAEvG,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,gBAAgB,CAAC,CAAC,EAAE,CAAC;QAC9B,UAAU,EAAE,cAAc,CAAC;KAC3B;IAED,UAAU,aAAa;QACtB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KACzB;IAED,UAAU,eAAe;QACxB,UAAU,EAAE,0BAA0B,CAAC;QACvC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KACzB;IAED,UAAU,sBAAsB;QAC/B,SAAS,EAAE,KAAK,CAAC;YAAE,UAAU,EAAE,0BAA0B,CAAC;YAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;SAAE,CAAC,CAAC;KACxF;IAED,UAAU,iCAAkC,SAAQ,0BAA0B;QAC7E;;;;WAIG;QACH,mBAAmB,EAAE,cAAc,EAAE,CAAC;KACtC;IAED,UAAU,gCAAiC,SAAQ,yBAAyB;KAE3E;CACD"}
|
package/html/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/html/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomAttributeDirectiveNode, DomStructuralDirectiveNode } from '@ibyar/elements';\nimport type { ExpressionNode } from '@ibyar/expressions';\nimport type { BindingAssignment, OneWayAssignmentExpression } from '../binding/binding.expressions.js';\n\ndeclare module '@ibyar/elements/node.js' {\n\tinterface ElementAttribute<N, V> {\n\t\texpression: ExpressionNode;\n\t}\n\n\tinterface LiveAttribute {\n\t\texpression: BindingAssignment;\n\t\tpipelineNames?: string[];\n\t}\n\n\tinterface LiveTextContent {\n\t\texpression: OneWayAssignmentExpression;\n\t\tpipelineNames?: string[];\n\t}\n\tinterface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {\n\t\t/**\n\t\t * create a new scope for a template and bind the new variables to the directive scope.\n\t\t * \n\t\t * execution for let-i=\"index\".\n\t\t */\n\t\ttemplateExpressions: ExpressionNode[];\n\t}\n\n\tinterface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {\n\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/html/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomAttributeDirectiveNode, DomStructuralDirectiveNode } from '@ibyar/elements';\nimport type { ExpressionNode } from '@ibyar/expressions';\nimport type { BindingAssignment, OneWayAssignmentExpression } from '../binding/binding.expressions.js';\n\ndeclare module '@ibyar/elements/node.js' {\n\tinterface ElementAttribute<N, V> {\n\t\texpression: ExpressionNode;\n\t}\n\n\tinterface LiveAttribute {\n\t\texpression: BindingAssignment;\n\t\tpipelineNames?: string[];\n\t}\n\n\tinterface LiveTextContent {\n\t\texpression: OneWayAssignmentExpression;\n\t\tpipelineNames?: string[];\n\t}\n\n\tinterface LocalTemplateVariables {\n\t\tvariables: Array<{ expression: OneWayAssignmentExpression; pipelineNames?: string[]; }>;\n\t}\n\n\tinterface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {\n\t\t/**\n\t\t * create a new scope for a template and bind the new variables to the directive scope.\n\t\t * \n\t\t * execution for let-i=\"index\".\n\t\t */\n\t\ttemplateExpressions: ExpressionNode[];\n\t}\n\n\tinterface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {\n\n\t}\n}\n"]}
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './annotation/options.js';
|
|
|
2
2
|
export * from './annotation/decorators.js';
|
|
3
3
|
export * from './signals/signals.js';
|
|
4
4
|
export * from './component/component.js';
|
|
5
|
+
export * from './component/initializer.js';
|
|
5
6
|
export * from './component/reflect.js';
|
|
6
7
|
export * from './component/custom-element.js';
|
|
7
8
|
export * from './component/events.js';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,sBAAsB,CAAC;AAErC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AAErC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './annotation/options.js';
|
|
|
2
2
|
export * from './annotation/decorators.js';
|
|
3
3
|
export * from './signals/signals.js';
|
|
4
4
|
export * from './component/component.js';
|
|
5
|
+
export * from './component/initializer.js';
|
|
5
6
|
export * from './component/reflect.js';
|
|
6
7
|
export * from './component/custom-element.js';
|
|
7
8
|
export * from './component/events.js';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,sBAAsB,CAAC;AAErC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AAErC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC","sourcesContent":["\nexport * from './annotation/options.js';\nexport * from './annotation/decorators.js';\n\nexport * from './signals/signals.js';\n\nexport * from './component/component.js';\nexport * from './component/initializer.js';\nexport * from './component/reflect.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './di/provider.js';\nexport * from './di/inject.js';\nexport * from './di/tokens.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\nexport * from './linker/change-detector-ref.js';\n\nexport * from './directive/directive.js';\nexport * from './html/expression.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/typeof.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/utils.js';\nexport * from './view/view.js';\n\n\nexport * from './zone/bootstrap.js';\nexport * from './zone/zone.js';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/core/initializer/input.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/core/initializer/input.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-detector-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEnE,8BAAsB,iBAAiB;IAEtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,IAAI,IAAI;IAEzB;;;OAGG;IACH,QAAQ,CAAC,YAAY,IAAI,IAAI;IAE7B;;OAEG;IACH,QAAQ,CAAC,aAAa,IAAI,IAAI;IAG9B;;OAEG;IACH,QAAQ,CAAC,cAAc,IAAI,IAAI;CAC/B;
|
|
1
|
+
{"version":3,"file":"change-detector-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEnE,8BAAsB,iBAAiB;IAEtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,IAAI,IAAI;IAEzB;;;OAGG;IACH,QAAQ,CAAC,YAAY,IAAI,IAAI;IAE7B;;OAEG;IACH,QAAQ,CAAC,aAAa,IAAI,IAAI;IAG9B;;OAEG;IACH,QAAQ,CAAC,cAAc,IAAI,IAAI;CAC/B;AAyBD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,OAAO,GAAG,iBAAiB,CAkBvH;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,oBAAoB,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAkBzG"}
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
export class ChangeDetectorRef {
|
|
2
2
|
}
|
|
3
|
+
class ChangeDetectorRefImpl extends ChangeDetectorRef {
|
|
4
|
+
ref;
|
|
5
|
+
constructor(ref) {
|
|
6
|
+
super();
|
|
7
|
+
this.ref = ref;
|
|
8
|
+
}
|
|
9
|
+
detach() {
|
|
10
|
+
this.ref.detach();
|
|
11
|
+
}
|
|
12
|
+
reattach() {
|
|
13
|
+
this.ref.reattach();
|
|
14
|
+
}
|
|
15
|
+
markForCheck() {
|
|
16
|
+
this.ref.markForCheck();
|
|
17
|
+
}
|
|
18
|
+
detectChanges() {
|
|
19
|
+
this.ref.detectChanges();
|
|
20
|
+
}
|
|
21
|
+
checkNoChanges() {
|
|
22
|
+
this.ref.checkNoChanges();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
3
25
|
/**
|
|
4
26
|
* create a change Detector Reference by property key.
|
|
5
27
|
*/
|
|
6
28
|
export function createChangeDetectorRef(scope, propertyKey) {
|
|
7
|
-
return {
|
|
29
|
+
return new ChangeDetectorRefImpl({
|
|
8
30
|
detach() {
|
|
9
31
|
scope.detach();
|
|
10
32
|
},
|
|
@@ -20,10 +42,10 @@ export function createChangeDetectorRef(scope, propertyKey) {
|
|
|
20
42
|
checkNoChanges() {
|
|
21
43
|
scope.checkNoChanges();
|
|
22
44
|
},
|
|
23
|
-
};
|
|
45
|
+
});
|
|
24
46
|
}
|
|
25
47
|
export function createModelChangeDetectorRef(resolver) {
|
|
26
|
-
return {
|
|
48
|
+
return new ChangeDetectorRefImpl({
|
|
27
49
|
detach() {
|
|
28
50
|
resolver().detach();
|
|
29
51
|
},
|
|
@@ -39,6 +61,6 @@ export function createModelChangeDetectorRef(resolver) {
|
|
|
39
61
|
checkNoChanges() {
|
|
40
62
|
resolver().checkNoChanges();
|
|
41
63
|
},
|
|
42
|
-
};
|
|
64
|
+
});
|
|
43
65
|
}
|
|
44
66
|
//# sourceMappingURL=change-detector-ref.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-detector-ref.js","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,iBAAiB;CA6BtC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAgC,EAAE,WAA0B;IACnG,OAAO;
|
|
1
|
+
{"version":3,"file":"change-detector-ref.js","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,iBAAiB;CA6BtC;AAED,MAAM,qBAAsB,SAAQ,iBAAiB;IAEhC;IAApB,YAAoB,GAAsB;QACzC,KAAK,EAAE,CAAC;QADW,QAAG,GAAH,GAAG,CAAmB;IAE1C,CAAC;IAED,MAAM;QACL,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;IACD,QAAQ;QACP,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC;IACD,YAAY;QACX,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;IACzB,CAAC;IACD,aAAa;QACZ,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAC1B,CAAC;IACD,cAAc;QACb,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;IAC3B,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAgC,EAAE,WAA0B;IACnG,OAAO,IAAI,qBAAqB,CAAC;QAChC,MAAM;YACL,KAAK,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;QACD,QAAQ;YACP,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC;QACD,YAAY;YACX,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;QACxD,CAAC;QACD,aAAa;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;QACD,cAAc;YACb,KAAK,CAAC,cAAc,EAAE,CAAC;QACxB,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,QAAyC;IACrF,OAAO,IAAI,qBAAqB,CAAC;QAChC,MAAM;YACL,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC;QACrB,CAAC;QACD,QAAQ;YACP,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;QACvB,CAAC;QACD,YAAY;YACX,QAAQ,EAAE,CAAC,aAAa,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa;YACZ,QAAQ,EAAE,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC;QACD,cAAc;YACb,QAAQ,EAAE,CAAC,cAAc,EAAE,CAAC;QAC7B,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { ReactiveScopeControl, Context } from '@ibyar/expressions';\n\nexport abstract class ChangeDetectorRef {\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tabstract detach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit changes now.\n\t */\n\tabstract reattach(): void;\n\n\t/**\n\t * apply changes now,\n\t * will not effect the state of the detector wither if attached ot not.\n\t */\n\tabstract markForCheck(): void;\n\n\t/**\n\t * apply change detection\n\t */\n\tabstract detectChanges(): void;\n\n\n\t/**\n\t * throw error if any changes has been made\n\t */\n\tabstract checkNoChanges(): void;\n}\n\nclass ChangeDetectorRefImpl extends ChangeDetectorRef {\n\n\tconstructor(private ref: ChangeDetectorRef) {\n\t\tsuper();\n\t}\n\n\tdetach(): void {\n\t\tthis.ref.detach();\n\t}\n\treattach(): void {\n\t\tthis.ref.reattach();\n\t}\n\tmarkForCheck(): void {\n\t\tthis.ref.markForCheck();\n\t}\n\tdetectChanges(): void {\n\t\tthis.ref.detectChanges();\n\t}\n\tcheckNoChanges(): void {\n\t\tthis.ref.checkNoChanges();\n\t}\n}\n\n/**\n * create a change Detector Reference by property key.\n */\nexport function createChangeDetectorRef(scope: ReactiveScopeControl<any>, propertyKey: keyof Context): ChangeDetectorRef {\n\treturn new ChangeDetectorRefImpl({\n\t\tdetach() {\n\t\t\tscope.detach();\n\t\t},\n\t\treattach() {\n\t\t\tscope.reattach();\n\t\t},\n\t\tmarkForCheck() {\n\t\t\tscope.emitChanges(propertyKey, scope.get(propertyKey));\n\t\t},\n\t\tdetectChanges() {\n\t\t\tscope.detectChanges();\n\t\t},\n\t\tcheckNoChanges() {\n\t\t\tscope.checkNoChanges();\n\t\t},\n\t});\n}\n\nexport function createModelChangeDetectorRef(resolver: () => ReactiveScopeControl<any>): ChangeDetectorRef {\n\treturn new ChangeDetectorRefImpl({\n\t\tdetach() {\n\t\t\tresolver().detach();\n\t\t},\n\t\treattach() {\n\t\t\tresolver().reattach();\n\t\t},\n\t\tmarkForCheck() {\n\t\t\tresolver().detectChanges()\n\t\t},\n\t\tdetectChanges() {\n\t\t\tresolver().detectChanges();\n\t\t},\n\t\tcheckNoChanges() {\n\t\t\tresolver().checkNoChanges();\n\t\t},\n\t});\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MetadataClass } from '@ibyar/decorators';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Type } from '../utils/typeof.js';
|
|
3
3
|
import { TemplateRef } from './template-ref.js';
|
|
4
4
|
import { EmbeddedViewRef, ViewRef } from './view-ref.js';
|
|
5
5
|
import { HTMLComponent } from '../component/custom-element.js';
|
|
@@ -73,7 +73,7 @@ export declare abstract class ViewContainerRef {
|
|
|
73
73
|
* @param viewClass the generated aurora view class
|
|
74
74
|
* @param options
|
|
75
75
|
*/
|
|
76
|
-
abstract createComponent<C extends {}>(viewClass:
|
|
76
|
+
abstract createComponent<C extends {}>(viewClass: Type<HTMLComponent<C>>, options?: IndexOptions): C;
|
|
77
77
|
/**
|
|
78
78
|
* Instantiates a single component and inserts its host view into this container.
|
|
79
79
|
*
|
|
@@ -86,7 +86,7 @@ export declare abstract class ViewContainerRef {
|
|
|
86
86
|
*
|
|
87
87
|
* @returns The new `HTMLComponent` which contains the component instance and the host view.
|
|
88
88
|
*/
|
|
89
|
-
abstract createComponent<C extends {}>(componentType:
|
|
89
|
+
abstract createComponent<C extends {}>(componentType: Type<C>, options?: ViewContainerComponentOptions): C;
|
|
90
90
|
/**
|
|
91
91
|
* create an HTMLElement by tag name `selector`.
|
|
92
92
|
* @param selector the tag name for the aurora custom-element
|
|
@@ -99,7 +99,7 @@ export declare abstract class ViewContainerRef {
|
|
|
99
99
|
* @param viewClass the generated aurora view class
|
|
100
100
|
* @param options
|
|
101
101
|
*/
|
|
102
|
-
abstract createElement<C extends HTMLElement>(htmlElementClass:
|
|
102
|
+
abstract createElement<C extends HTMLElement>(htmlElementClass: Type<C>, options?: HTMLElementOptions): C;
|
|
103
103
|
/**
|
|
104
104
|
* create a text node and insert to the view
|
|
105
105
|
* @param data
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"view-container-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/view-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K,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAyB,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;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"]}
|
|
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;IAHtC,MAAM,GAA2B,EAAE,CAAC;IAG5C,YAAoB,OAAgB,EAAU,aAAsB;QACnE,KAAK,EAAE,CAAC;QADW,YAAO,GAAP,OAAO,CAAS;QAAU,kBAAa,GAAb,aAAa,CAAS;IAEpE,CAAC;IACD,IAAa,aAAa;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IACD,IAAa,MAAM;QAClB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KAAK,CAAC,CAAC,CAAyB,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;IACF,CAAC;CAED","sourcesContent":["import type { MetadataClass } from '@ibyar/decorators';\nimport type { Type } 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: Type<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: Type<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: Type<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> | Type<HTMLComponent<C>>, options?: ViewContainerComponentOptions): C {\n\t\tlet ViewClass: Type<HTMLComponent<C>>;\n\t\tif (typeof arg0 === 'string') {\n\t\t\tViewClass = customElements.get(arg0) as Type<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 Type<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 | Type<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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibyar/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.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/decorators": "^2.
|
|
39
|
-
"@ibyar/elements": "^2.
|
|
40
|
-
"@ibyar/expressions": "^2.
|
|
41
|
-
"tslib": "^2.
|
|
38
|
+
"@ibyar/decorators": "^2.5.0",
|
|
39
|
+
"@ibyar/elements": "^2.5.0",
|
|
40
|
+
"@ibyar/expressions": "^2.5.0",
|
|
41
|
+
"tslib": "^2.7.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"zone.js": "~0.
|
|
44
|
+
"zone.js": "~0.15.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"typescript": "^5.
|
|
47
|
+
"typescript": "^5.6.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc --build --verbose",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"typescript",
|
|
79
79
|
"front-end"
|
|
80
80
|
],
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "67b064cb1a4a9c11cf4bf31da7dd7cc8bb3675ce"
|
|
82
82
|
}
|