@ibyar/core 0.6.0 → 0.8.2-dev.20221008

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +3 -2
  2. package/annotation/decorators.d.ts +101 -5
  3. package/annotation/decorators.js +48 -21
  4. package/annotation/decorators.js.map +1 -1
  5. package/binding/binding.expressions.d.ts +7 -3
  6. package/binding/binding.expressions.js +21 -6
  7. package/binding/binding.expressions.js.map +1 -1
  8. package/component/component.d.ts +10 -48
  9. package/component/component.js +24 -90
  10. package/component/component.js.map +1 -1
  11. package/component/custom-element.d.ts +87 -6
  12. package/component/custom-element.js +6 -0
  13. package/component/custom-element.js.map +1 -1
  14. package/component/reflect.d.ts +54 -0
  15. package/component/reflect.js +95 -0
  16. package/component/reflect.js.map +1 -0
  17. package/html/deserialize.d.ts +2 -0
  18. package/html/deserialize.js +68 -0
  19. package/html/deserialize.js.map +1 -0
  20. package/html/expression.d.ts +2 -25
  21. package/html/expression.js +2 -2
  22. package/html/expression.js.map +1 -1
  23. package/html/types.d.ts +26 -0
  24. package/html/types.js +2 -0
  25. package/html/types.js.map +1 -0
  26. package/index.d.ts +3 -0
  27. package/index.js +3 -0
  28. package/index.js.map +1 -1
  29. package/linker/view-container-ref.js +3 -3
  30. package/linker/view-container-ref.js.map +1 -1
  31. package/node.d.ts +2 -0
  32. package/node.js +3 -0
  33. package/node.js.map +1 -0
  34. package/package.json +10 -8
  35. package/providers/provider.d.ts +2 -1
  36. package/providers/provider.js +9 -9
  37. package/providers/provider.js.map +1 -1
  38. package/render/host-listener.handler.d.ts +1 -1
  39. package/render/host-listener.handler.js.map +1 -1
  40. package/view/base-view.js +32 -29
  41. package/view/base-view.js.map +1 -1
  42. package/view/form-view.d.ts +14 -2
  43. package/view/form-view.js +90 -44
  44. package/view/form-view.js.map +1 -1
  45. package/view/render.js +9 -8
  46. package/view/render.js.map +1 -1
  47. package/view/utils.d.ts +6 -0
  48. package/view/utils.js +20 -0
  49. package/view/utils.js.map +1 -0
  50. package/view/view.d.ts +0 -2
  51. package/view/view.js +8 -34
  52. package/view/view.js.map +1 -1
  53. package/zone/bootstrap.d.ts +1 -1
  54. package/zone/proxy.d.ts +4 -4
  55. package/zone/proxy.js +13 -4
  56. package/zone/proxy.js.map +1 -1
  57. package/zone/zone.d.ts +2 -0
  58. package/zone/zone.js +9 -14
  59. package/zone/zone.js.map +1 -1
@@ -0,0 +1,68 @@
1
+ import { DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent } from '@ibyar/elements';
2
+ import { deserialize } from '@ibyar/expressions';
3
+ import { getPipelineNames } from './expression.js';
4
+ function deserializeLiveText(text) {
5
+ if (text.expression) {
6
+ text.expression = deserialize(text.expression);
7
+ text.pipelineNames = getPipelineNames(text.expression.getRight());
8
+ }
9
+ }
10
+ function deserializeLiveAttribute(attr) {
11
+ if (attr.expression) {
12
+ attr.expression = deserialize(attr.expression);
13
+ }
14
+ }
15
+ function deserializeLiveAttributeUpdateElement(attr) {
16
+ if (attr.expression) {
17
+ attr.expression = deserialize(attr.expression);
18
+ attr.pipelineNames = getPipelineNames(attr.expression.getRight());
19
+ }
20
+ }
21
+ function deserializeOutputExpression(attr) {
22
+ if (attr.expression) {
23
+ attr.expression = deserialize(attr.expression);
24
+ }
25
+ }
26
+ function deserializeAttributeDirectives(directive) {
27
+ directive.inputs?.forEach(deserializeLiveAttributeUpdateElement);
28
+ directive.outputs?.forEach(deserializeOutputExpression);
29
+ directive.twoWayBinding?.forEach(deserializeLiveAttribute);
30
+ directive.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);
31
+ }
32
+ function deserializeBaseNode(base) {
33
+ base.inputs?.forEach(deserializeLiveAttributeUpdateElement);
34
+ base.outputs?.forEach(deserializeOutputExpression);
35
+ base.twoWayBinding?.forEach(deserializeLiveAttribute);
36
+ base.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);
37
+ base.attributeDirectives?.forEach(deserializeAttributeDirectives);
38
+ }
39
+ function deserializeChild(child) {
40
+ if (child instanceof DomElementNode) {
41
+ // DomElementNode
42
+ deserializeBaseNode(child);
43
+ deserializeDomParentNode(child);
44
+ }
45
+ else if (child instanceof DomStructuralDirectiveNode) {
46
+ child.templateExpressions = child.templateExpressions.map(deserialize);
47
+ deserializeChild(child.node);
48
+ deserializeBaseNode(child);
49
+ }
50
+ else if (isLiveTextContent(child)) {
51
+ deserializeLiveText(child);
52
+ }
53
+ else if (child instanceof DomFragmentNode) {
54
+ deserializeDomParentNode(child);
55
+ }
56
+ }
57
+ function deserializeDomParentNode(parent) {
58
+ parent.children?.forEach(deserializeChild);
59
+ }
60
+ export function deserializeExpressionNodes(node) {
61
+ if (node instanceof DomFragmentNode) {
62
+ deserializeDomParentNode(node);
63
+ }
64
+ else {
65
+ deserializeChild(node);
66
+ }
67
+ }
68
+ //# sourceMappingURL=deserialize.js.map
@@ -0,0 +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,EAEjB,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;QACpB,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;KAClE;AACF,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAmB;IACpD,IAAI,IAAI,CAAC,UAAU,EAAE;QACpB,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,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B,wBAAwB,CAAC,KAAK,CAAC,CAAC;KAChC;SAAM,IAAI,KAAK,YAAY,0BAA0B,EAAE;QACtD,KAA2C,CAAC,mBAAmB,GAAI,KAA2C,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACrJ,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,mBAAmB,CAAC,KAAK,CAAC,CAAC;KAC3B;SAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE;QACpC,mBAAmB,CAAC,KAAK,CAAC,CAAC;KAC3B;SAAM,IAAI,KAAK,YAAY,eAAe,EAAE;QAC5C,wBAAwB,CAAC,KAAK,CAAC,CAAC;KAChC;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;QACpC,wBAAwB,CAAC,IAAI,CAAC,CAAC;KAC/B;SAAM;QACN,gBAAgB,CAAC,IAAI,CAAC,CAAC;KACvB;AACF,CAAC","sourcesContent":["import {\n\tBaseNode, DomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomAttributeDirectiveNode\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 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} else if (isLiveTextContent(child)) {\n\t\tdeserializeLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tdeserializeDomParentNode(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"]}
@@ -1,27 +1,4 @@
1
- import { DomStructuralDirectiveNode, DomNode, DomAttributeDirectiveNode } from '@ibyar/elements';
1
+ import { DomNode } from '@ibyar/elements/node.js';
2
2
  import { ExpressionNode } from '@ibyar/expressions';
3
- import { BindingAssignment, OneWayAssignmentExpression } from '../binding/binding.expressions.js';
4
- declare module '@ibyar/elements' {
5
- interface ElementAttribute<N, V> {
6
- expression: ExpressionNode;
7
- }
8
- interface LiveAttribute {
9
- expression: BindingAssignment;
10
- pipelineNames?: string[];
11
- }
12
- interface LiveTextContent {
13
- expression: OneWayAssignmentExpression;
14
- pipelineNames?: string[];
15
- }
16
- interface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {
17
- /**
18
- * create a new scope for a template and bind the new variables to the directive scope.
19
- *
20
- * execution for let-i="index".
21
- */
22
- templateExpressions: ExpressionNode[];
23
- }
24
- interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {
25
- }
26
- }
3
+ export declare function getPipelineNames(modelExpression: ExpressionNode): string[] | undefined;
27
4
  export declare function buildExpressionNodes(node: DomNode): void;
@@ -1,4 +1,4 @@
1
- import { createLiveAttribute, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent } from '@ibyar/elements';
1
+ import { createLiveAttribute, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent } from '@ibyar/elements/node.js';
2
2
  import { expressionVisitor, Identifier, JavaScriptParser, MemberExpression } from '@ibyar/expressions';
3
3
  import { OneWayAssignmentExpression, TwoWayAssignmentExpression } from '../binding/binding.expressions.js';
4
4
  import { DirectiveExpressionParser } from '../directive/parser.js';
@@ -41,7 +41,7 @@ function parseLiveAttribute(attr) {
41
41
  console.error(`${attr.name}="${attr.value}"" is not a valid MemberExpression or Identifier 'x.y.z'`);
42
42
  }
43
43
  }
44
- function getPipelineNames(modelExpression) {
44
+ export function getPipelineNames(modelExpression) {
45
45
  const pipelineNames = [];
46
46
  expressionVisitor.visit(modelExpression, (expression, type, control) => {
47
47
  if (type === 'PipelineExpression') {
@@ -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,iBAAiB,CAAC;AACzB,OAAO,EACU,iBAAiB,EAAE,UAAU,EAC7C,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEN,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AA8BjE,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,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;QAC5B,OAAO,MAAgB,CAAC;KACxB;IACD,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC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CAAC,OAAO,CAAC,IAAI,CAAC,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;QACpC,kBAAkB,CAAC,IAAI,CAAC,CAAC;KACzB;SAAM;QACN,UAAU,CAAC,IAAI,CAAC,CAAC;KACjB;AACF,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';\nimport {\n\tExpressionNode, expressionVisitor, Identifier,\n\tJavaScriptParser, MemberExpression, PipelineExpression\n} from '@ibyar/expressions';\nimport {\n\tBindingAssignment,\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\n\ndeclare module '@ibyar/elements' {\n\texport interface ElementAttribute<N, V> {\n\t\texpression: ExpressionNode;\n\t}\n\n\texport interface LiveAttribute {\n\t\texpression: BindingAssignment;\n\t\tpipelineNames?: string[];\n\t}\n\n\texport interface LiveTextContent {\n\t\texpression: OneWayAssignmentExpression;\n\t\tpipelineNames?: string[];\n\t}\n\texport interface 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\texport interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {\n\n\t}\n}\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 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\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.${convertToMemberAccessStyle(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\nfunction 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 = `this.${convertToMemberAccessStyle(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\tlet 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} 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"]}
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,SAAS,0BAA0B,CAAC,MAAyB;IAC5D,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,M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K,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACpG,4BAA4B,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE;QAC5C,KAAK,CAAC,UAAW,CAAC,MAAM,CAAC,KAAK,CAAC,UAAW,CAAC,OAAO,CAAC,IAAI,CAAC,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;QACpC,kBAAkB,CAAC,IAAI,CAAC,CAAC;KACzB;SAAM;QACN,UAAU,CAAC,IAAI,CAAC,CAAC;KACjB;AACF,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\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\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.${convertToMemberAccessStyle(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 = `this.${convertToMemberAccessStyle(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\tlet 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} 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"]}
@@ -0,0 +1,26 @@
1
+ import type { DomAttributeDirectiveNode, DomStructuralDirectiveNode } from '@ibyar/elements';
2
+ import type { ExpressionNode } from '@ibyar/expressions';
3
+ import type { BindingAssignment, OneWayAssignmentExpression } from '../binding/binding.expressions.js';
4
+ declare module '@ibyar/elements/node.js' {
5
+ interface ElementAttribute<N, V> {
6
+ expression: ExpressionNode;
7
+ }
8
+ interface LiveAttribute {
9
+ expression: BindingAssignment;
10
+ pipelineNames?: string[];
11
+ }
12
+ interface LiveTextContent {
13
+ expression: OneWayAssignmentExpression;
14
+ pipelineNames?: string[];
15
+ }
16
+ interface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {
17
+ /**
18
+ * create a new scope for a template and bind the new variables to the directive scope.
19
+ *
20
+ * execution for let-i="index".
21
+ */
22
+ templateExpressions: ExpressionNode[];
23
+ }
24
+ interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {
25
+ }
26
+ }
package/html/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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"]}
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  export * from './annotation/decorators.js';
3
3
  export * from './component/component.js';
4
+ export * from './component/reflect.js';
4
5
  export * from './component/custom-element.js';
5
6
  export * from './component/events.js';
6
7
  export * from './component/lifecycle.js';
@@ -10,6 +11,7 @@ export * from './linker/template-ref.js';
10
11
  export * from './linker/view-container-ref.js';
11
12
  export * from './linker/change-detector-ref.js';
12
13
  export * from './directive/directive.js';
14
+ export * from './html/expression.js';
13
15
  export * from './pipe/pipe.js';
14
16
  export * from './providers/injector.js';
15
17
  export * from './providers/provider.js';
@@ -19,6 +21,7 @@ export * from './utils/typeof.js';
19
21
  export * from './utils/utils.js';
20
22
  export * from './view/mutation.js';
21
23
  export * from './view/render.js';
24
+ export * from './view/utils.js';
22
25
  export * from './view/view.js';
23
26
  export * from './zone/bootstrap.js';
24
27
  export * from './zone/task.js';
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  export * from './annotation/decorators.js';
3
3
  export * from './component/component.js';
4
+ export * from './component/reflect.js';
4
5
  export * from './component/custom-element.js';
5
6
  export * from './component/events.js';
6
7
  export * from './component/lifecycle.js';
@@ -10,6 +11,7 @@ export * from './linker/template-ref.js';
10
11
  export * from './linker/view-container-ref.js';
11
12
  export * from './linker/change-detector-ref.js';
12
13
  export * from './directive/directive.js';
14
+ export * from './html/expression.js';
13
15
  export * from './pipe/pipe.js';
14
16
  export * from './providers/injector.js';
15
17
  export * from './providers/provider.js';
@@ -19,6 +21,7 @@ export * from './utils/typeof.js';
19
21
  export * from './utils/utils.js';
20
22
  export * from './view/mutation.js';
21
23
  export * from './view/render.js';
24
+ export * from './view/utils.js';
22
25
  export * from './view/view.js';
23
26
  export * from './zone/bootstrap.js';
24
27
  export * from './zone/task.js';
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AACxC,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,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './annotation/decorators.js';\n\nexport * from './component/component.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './context/stack.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';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/injector.js';\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/view.js';\n\n\nexport * from './zone/bootstrap.js';\nexport * from './zone/task.js';\nexport * from './zone/zone.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,oBAAoB,CAAC;AAEnC,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;AACxC,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;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './annotation/decorators.js';\n\nexport * from './component/component.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 './context/stack.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/injector.js';\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/task.js';\nexport * from './zone/zone.js';\n"]}
@@ -1,6 +1,6 @@
1
- import { Components } from '../component/component.js';
1
+ import { ReflectComponents } from '../component/reflect.js';
2
2
  import { EmbeddedViewRefImpl } from './view-ref.js';
3
- import { getComponentView } from '../view/view.js';
3
+ import { getComponentView } from '../view/utils.js';
4
4
  import { ReactiveScopeControl } from '@ibyar/expressions';
5
5
  ;
6
6
  ;
@@ -82,7 +82,7 @@ export class ViewContainerRefImpl extends ViewContainerRef {
82
82
  }
83
83
  else {
84
84
  const componentType = arg0;
85
- const defaultTagName = Components.getComponentRef(componentType).selector;
85
+ const defaultTagName = ReflectComponents.getComponentRef(componentType).selector;
86
86
  const view = getComponentView(componentType, options?.selector ?? defaultTagName);
87
87
  if (!view) {
88
88
  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":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAmB,mBAAmB,EAAW,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAezD,CAAC;AAID,CAAC;AAMF,MAAM,OAAgB,gBAAgB;CA+IrC;AAGD,MAAM,OAAO,oBAAqB,SAAQ,gBAAgB;IAKzD,YAAoB,OAAgB,EAAU,aAAsB;Q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,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 { Components } from '../component/component.js';\nimport { TemplateRef } from './template-ref.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl, ViewRef } from './view-ref.js';\nimport { getComponentView } from '../view/view.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 = Components.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":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAmB,mBAAmB,EAAW,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAezD,CAAC;AAID,CAAC;AAMF,MAAM,OAAgB,gBAAgB;CA+IrC;AAGD,MAAM,OAAO,oBAAqB,SAAQ,gBAAgB;IAKzD,YAAoB,OAAgB,EAAU,aAAsB;QACnE,KAAK,EAAE,CAAC;QADW,YAAO,GAAP,OAAO,CAAS;QAAU,kBAAa,GAAb,aAAa,CAAS;QAH5D,WAAM,GAA2B,EAAE,CAAC;IAK5C,CAAC;IACD,IAAa,aAAa;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IACD,IAAa,MAAM;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC3B,CAAC;IACQ,KAAK;QACb,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,KAAK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AAI,KAAK,CAAC,uCAAuC,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;SAC3E;QACD,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,CAAI,OAAO,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAI,KAAK,EAAE,CAAC,OAAO,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,OAAO,CAAC;IAChB,CAAC;IACQ,cAAc,CAAC,IAAY,EAAE,OAAsB;QAC3D,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,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"]}
package/node.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './html/expression.js';
2
+ export * from './utils/utils.js';
package/node.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './html/expression.js';
2
+ export * from './utils/utils.js';
3
+ //# sourceMappingURL=node.js.map
package/node.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/core/node.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './html/expression.js';\nexport * from './utils/utils.js';"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ibyar/core",
3
- "version": "0.6.0",
4
- "description": "Implements Aurora's core functionality, low-level services, and utilities",
3
+ "version": "0.8.2-dev.20221008",
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",
7
7
  "repository": {
@@ -14,7 +14,9 @@
14
14
  "types": "./index.d.ts",
15
15
  "type": "module",
16
16
  "exports": {
17
- ".": "./index.js"
17
+ ".": "./index.js",
18
+ "./node": "./node.js",
19
+ "./node.js": "./node.js"
18
20
  },
19
21
  "files": [
20
22
  "*"
@@ -23,16 +25,16 @@
23
25
  "access": "public"
24
26
  },
25
27
  "dependencies": {
26
- "@ibyar/elements": "^0.6.0",
27
- "@ibyar/expressions": "^0.6.0",
28
+ "@ibyar/elements": "^0.8.2-dev.20221008",
29
+ "@ibyar/expressions": "^0.8.2-dev.20221008",
28
30
  "reflect-metadata": "^0.1.13",
29
31
  "tslib": "^2.4.0"
30
32
  },
31
33
  "peerDependencies": {
32
- "zone.js": "^0.11.6"
34
+ "zone.js": "^0.11.8"
33
35
  },
34
36
  "devDependencies": {
35
- "typescript": "^4.7.4"
37
+ "typescript": "^4.8.4"
36
38
  },
37
39
  "scripts": {
38
40
  "build": "tsc --build --verbose"
@@ -66,5 +68,5 @@
66
68
  "typescript",
67
69
  "front-end"
68
70
  ],
69
- "gitHead": "543b42bc87e268480e497c5e25c0215641d2c252"
71
+ "gitHead": "abe877ef8e4d4914a0b9bc12dc88154ba9f0b2b9"
70
72
  }
@@ -1,4 +1,5 @@
1
- import { ComponentRef, DirectiveRef, PipeRef, PropertyRef, ServiceRef } from '../component/component.js';
1
+ import type { ComponentRef, DirectiveRef, PipeRef, ServiceRef } from '../component/component.js';
2
+ import { PropertyRef } from '../component/reflect.js';
2
3
  export declare type ProviderType = 'component' | 'service' | 'directive' | 'pipe' | 'self';
3
4
  export declare class ClassRegistry {
4
5
  viewSet: Set<Function>;
@@ -1,4 +1,4 @@
1
- import { Components } from '../component/component.js';
1
+ import { ReflectComponents } from '../component/reflect.js';
2
2
  export class ClassRegistry {
3
3
  constructor() {
4
4
  this.viewSet = new Set();
@@ -24,7 +24,7 @@ export class ClassRegistry {
24
24
  }
25
25
  hasComponent(selector) {
26
26
  for (const modelClass of this.componentSet) {
27
- const componentRef = Components.getComponentRef(modelClass);
27
+ const componentRef = ReflectComponents.getComponentRef(modelClass);
28
28
  if (componentRef.selector === selector) {
29
29
  return true;
30
30
  }
@@ -33,7 +33,7 @@ export class ClassRegistry {
33
33
  }
34
34
  getComponentRef(selector) {
35
35
  for (const modelClass of this.componentSet) {
36
- const componentRef = Components.getComponentRef(modelClass);
36
+ const componentRef = ReflectComponents.getComponentRef(modelClass);
37
37
  if (componentRef.selector === selector) {
38
38
  return componentRef;
39
39
  }
@@ -42,7 +42,7 @@ export class ClassRegistry {
42
42
  }
43
43
  getComponent(selector) {
44
44
  for (const modelClass of this.componentSet) {
45
- const componentRef = Components.getComponentRef(modelClass);
45
+ const componentRef = ReflectComponents.getComponentRef(modelClass);
46
46
  if (componentRef.selector === selector) {
47
47
  return modelClass;
48
48
  }
@@ -80,7 +80,7 @@ export class ClassRegistry {
80
80
  }
81
81
  hasDirective(selector) {
82
82
  for (const directiveClass of this.directiveSet) {
83
- const directiveRef = Components.getBootstrap(directiveClass.prototype);
83
+ const directiveRef = ReflectComponents.getBootstrap(directiveClass.prototype);
84
84
  if (directiveRef.selector === selector) {
85
85
  return true;
86
86
  }
@@ -89,7 +89,7 @@ export class ClassRegistry {
89
89
  }
90
90
  directiveHasInput(input, directiveType = 'attributes') {
91
91
  for (const directiveClass of this.directiveSet) {
92
- const directiveRef = Components.getBootstrap(directiveClass.prototype);
92
+ const directiveRef = ReflectComponents.getBootstrap(directiveClass.prototype);
93
93
  if ((directiveType === 'attributes' && !directiveRef.selector.startsWith('*'))
94
94
  || (directiveType === 'structural' && directiveRef.selector.startsWith('*'))) {
95
95
  if (directiveRef.inputs?.filter(ref => ref.viewAttribute === input).length > 0) {
@@ -101,7 +101,7 @@ export class ClassRegistry {
101
101
  }
102
102
  getDirectiveRef(selector) {
103
103
  for (const directiveClass of this.directiveSet) {
104
- const directiveRef = Components.getBootstrap(directiveClass.prototype);
104
+ const directiveRef = ReflectComponents.getBootstrap(directiveClass.prototype);
105
105
  if (directiveRef.selector === selector) {
106
106
  return directiveRef;
107
107
  }
@@ -110,7 +110,7 @@ export class ClassRegistry {
110
110
  }
111
111
  getPipe(pipeName) {
112
112
  for (const pipeClass of this.pipeSet) {
113
- const pipeRef = Components.getBootstrap(pipeClass.prototype);
113
+ const pipeRef = ReflectComponents.getBootstrap(pipeClass.prototype);
114
114
  if (pipeRef.name === pipeName) {
115
115
  return pipeRef;
116
116
  }
@@ -119,7 +119,7 @@ export class ClassRegistry {
119
119
  }
120
120
  getService(serviceName) {
121
121
  for (const serviceClass of this.serviceSet) {
122
- const serviceRef = Components.getBootstrap(serviceClass.prototype);
122
+ const serviceRef = ReflectComponents.getBootstrap(serviceClass.prototype);
123
123
  if (serviceRef.name === serviceName) {
124
124
  return serviceRef;
125
125
  }
@@ -1 +1 @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,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,GAAe,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YACzE,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,GAAkB,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAClF,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":["\nimport {\n\tComponents, ComponentRef, DirectiveRef,\n\tPipeRef, PropertyRef, ServiceRef\n} from '../component/component.js';\nexport type ProviderType = 'component' | 'service' | 'directive' | 'pipe' | 'self';\n\nexport class ClassRegistry {\n\tviewSet: Set<Function> = new Set();\n\tcomponentSet: Set<Function> = new Set();\n\tserviceSet: Set<Function> = new Set();\n\tdirectiveSet: Set<Function> = new Set();\n\tpipeSet: Set<Function> = new Set();\n\n\tregisterView(classRef: Function): void {\n\t\tthis.viewSet.add(classRef);\n\t}\n\tregisterComponent(classRef: Function): void {\n\t\tthis.componentSet.add(classRef);\n\t}\n\tregisterService(classRef: Function): void {\n\t\tthis.serviceSet.add(classRef);\n\t}\n\tregisterDirective(classRef: Function): void {\n\t\tthis.directiveSet.add(classRef);\n\t}\n\tregisterPipe(classRef: Function): 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: ComponentRef<T> = Components.getComponentRef(modelClass);\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: ComponentRef<T> = Components.getComponentRef(modelClass);\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: ComponentRef<T> = Components.getComponentRef(modelClass);\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: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\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: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\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: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\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: PipeRef<T> = Components.getBootstrap(pipeClass.prototype);\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: ServiceRef<T> = Components.getBootstrap(serviceClass.prototype);\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"]}
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/providers/provider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGzE,MAAM,OAAO,aAAa;IAA1B;QACC,YAAO,GAAkB,IAAI,GAAG,EAAE,CAAC;QACnC,iBAAY,GAAkB,IAAI,GAAG,EAAE,CAAC;QACxC,eAAU,GAAkB,IAAI,GAAG,EAAE,CAAC;QACtC,iBAAY,GAAkB,IAAI,GAAG,EAAE,CAAC;QACxC,YAAO,GAAkB,IAAI,GAAG,EAAE,CAAC;IAmIpC,CAAC;IAjIA,YAAY,CAAC,QAAkB;QAC9B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IACD,iBAAiB,CAAC,QAAkB;QACnC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IACD,eAAe,CAAC,QAAkB;QACjC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IACD,iBAAiB,CAAC,QAAkB;QACnC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IACD,YAAY,CAAC,QAAkB;QAC9B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,YAAY,CAAI,QAAgB;QAC/B,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY,EAAE;YAC3C,MAAM,YAAY,GAAoB,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YACpF,IAAI,YAAY,CAAC,QAAQ,KAAK,QAAQ,EAAE;gBACvC,OAAO,IAAI,CAAC;aACZ;SACD;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,eAAe,CAAI,QAAgB;QAClC,KAAK,MAA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AAC,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,GAAe,iBAAiB,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YAChF,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,GAAkB,iBAAiB,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YACzF,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":["\nimport type {\n\tComponentRef, DirectiveRef, PipeRef, ServiceRef\n} from '../component/component.js';\nimport { PropertyRef, ReflectComponents } from '../component/reflect.js';\nexport type ProviderType = 'component' | 'service' | 'directive' | 'pipe' | 'self';\n\nexport class ClassRegistry {\n\tviewSet: Set<Function> = new Set();\n\tcomponentSet: Set<Function> = new Set();\n\tserviceSet: Set<Function> = new Set();\n\tdirectiveSet: Set<Function> = new Set();\n\tpipeSet: Set<Function> = new Set();\n\n\tregisterView(classRef: Function): void {\n\t\tthis.viewSet.add(classRef);\n\t}\n\tregisterComponent(classRef: Function): void {\n\t\tthis.componentSet.add(classRef);\n\t}\n\tregisterService(classRef: Function): void {\n\t\tthis.serviceSet.add(classRef);\n\t}\n\tregisterDirective(classRef: Function): void {\n\t\tthis.directiveSet.add(classRef);\n\t}\n\tregisterPipe(classRef: Function): 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: ComponentRef<T> = ReflectComponents.getComponentRef(modelClass);\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: ComponentRef<T> = ReflectComponents.getComponentRef(modelClass);\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: ComponentRef<T> = ReflectComponents.getComponentRef(modelClass);\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: DirectiveRef<T> = ReflectComponents.getBootstrap(directiveClass.prototype);\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: DirectiveRef<T> = ReflectComponents.getBootstrap(directiveClass.prototype);\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: DirectiveRef<T> = ReflectComponents.getBootstrap(directiveClass.prototype);\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: PipeRef<T> = ReflectComponents.getBootstrap(pipeClass.prototype);\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: ServiceRef<T> = ReflectComponents.getBootstrap(serviceClass.prototype);\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"]}
@@ -1,5 +1,5 @@
1
1
  import { ReactiveScope } from '@ibyar/expressions';
2
- import { ListenerRef } from '../component/component.js';
2
+ import { ListenerRef } from '../component/reflect.js';
3
3
  import { HTMLComponent } from '../component/custom-element.js';
4
4
  import { RenderHandler } from './render-handler.js';
5
5
  declare type ElementScope = {