@ibyar/core 0.8.6 → 1.0.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.
Files changed (134) hide show
  1. package/annotation/context.d.ts +41 -0
  2. package/annotation/context.d.ts.map +1 -0
  3. package/annotation/context.js +79 -0
  4. package/annotation/context.js.map +1 -0
  5. package/annotation/decorators.d.ts +20 -285
  6. package/annotation/decorators.d.ts.map +1 -0
  7. package/annotation/decorators.js +92 -84
  8. package/annotation/decorators.js.map +1 -1
  9. package/annotation/options.d.ts +275 -0
  10. package/annotation/options.d.ts.map +1 -0
  11. package/annotation/options.js +2 -0
  12. package/annotation/options.js.map +1 -0
  13. package/binding/binding.expressions.d.ts +1 -0
  14. package/binding/binding.expressions.d.ts.map +1 -0
  15. package/binding/binding.expressions.js +138 -125
  16. package/binding/binding.expressions.js.map +1 -1
  17. package/component/component.d.ts +12 -11
  18. package/component/component.d.ts.map +1 -0
  19. package/component/component.js +37 -44
  20. package/component/component.js.map +1 -1
  21. package/component/custom-element.d.ts +1 -0
  22. package/component/custom-element.d.ts.map +1 -0
  23. package/component/events.d.ts +1 -0
  24. package/component/events.d.ts.map +1 -0
  25. package/component/events.js +4 -3
  26. package/component/events.js.map +1 -1
  27. package/component/lifecycle.d.ts +1 -0
  28. package/component/lifecycle.d.ts.map +1 -0
  29. package/component/reflect.d.ts +12 -15
  30. package/component/reflect.d.ts.map +1 -0
  31. package/component/reflect.js +27 -47
  32. package/component/reflect.js.map +1 -1
  33. package/context/stack.d.ts +1 -0
  34. package/context/stack.d.ts.map +1 -0
  35. package/context/subscription.d.ts +1 -0
  36. package/context/subscription.d.ts.map +1 -0
  37. package/directive/directive.d.ts +1 -0
  38. package/directive/directive.d.ts.map +1 -0
  39. package/directive/directive.js +8 -0
  40. package/directive/directive.js.map +1 -1
  41. package/directive/parser.d.ts +1 -0
  42. package/directive/parser.d.ts.map +1 -0
  43. package/directive/parser.js +9 -7
  44. package/directive/parser.js.map +1 -1
  45. package/directive/providers.d.ts +1 -0
  46. package/directive/providers.d.ts.map +1 -0
  47. package/directive/providers.js +2 -1
  48. package/directive/providers.js.map +1 -1
  49. package/html/deserialize.d.ts +1 -0
  50. package/html/deserialize.d.ts.map +1 -0
  51. package/html/expression.d.ts +1 -0
  52. package/html/expression.d.ts.map +1 -0
  53. package/html/expression.js +2 -2
  54. package/html/expression.js.map +1 -1
  55. package/html/types.d.ts +1 -0
  56. package/html/types.d.ts.map +1 -0
  57. package/index.d.ts +2 -2
  58. package/index.d.ts.map +1 -0
  59. package/index.js +1 -2
  60. package/index.js.map +1 -1
  61. package/linker/change-detector-ref.d.ts +1 -0
  62. package/linker/change-detector-ref.d.ts.map +1 -0
  63. package/linker/template-ref.d.ts +1 -0
  64. package/linker/template-ref.d.ts.map +1 -0
  65. package/linker/template-ref.js +5 -0
  66. package/linker/template-ref.js.map +1 -1
  67. package/linker/view-container-ref.d.ts +4 -2
  68. package/linker/view-container-ref.d.ts.map +1 -0
  69. package/linker/view-container-ref.js +8 -7
  70. package/linker/view-container-ref.js.map +1 -1
  71. package/linker/view-ref.d.ts +1 -0
  72. package/linker/view-ref.d.ts.map +1 -0
  73. package/linker/view-ref.js +5 -2
  74. package/linker/view-ref.js.map +1 -1
  75. package/node.d.ts +1 -0
  76. package/node.d.ts.map +1 -0
  77. package/package.json +6 -7
  78. package/pipe/pipe.d.ts +1 -0
  79. package/pipe/pipe.d.ts.map +1 -0
  80. package/pipe/pipe.js +2 -1
  81. package/pipe/pipe.js.map +1 -1
  82. package/providers/provider.d.ts +15 -13
  83. package/providers/provider.d.ts.map +1 -0
  84. package/providers/provider.js +13 -16
  85. package/providers/provider.js.map +1 -1
  86. package/utils/elements-util.d.ts +1 -0
  87. package/utils/elements-util.d.ts.map +1 -0
  88. package/utils/path.d.ts +1 -0
  89. package/utils/path.d.ts.map +1 -0
  90. package/utils/typeof.d.ts +3 -0
  91. package/utils/typeof.d.ts.map +1 -0
  92. package/utils/typeof.js.map +1 -1
  93. package/utils/utils.d.ts +1 -0
  94. package/utils/utils.d.ts.map +1 -0
  95. package/view/base-view.d.ts +1 -0
  96. package/view/base-view.d.ts.map +1 -0
  97. package/view/base-view.js +30 -16
  98. package/view/base-view.js.map +1 -1
  99. package/view/form-view.d.ts +1 -0
  100. package/view/form-view.d.ts.map +1 -0
  101. package/view/form-view.js +70 -67
  102. package/view/form-view.js.map +1 -1
  103. package/view/mutation.d.ts +1 -0
  104. package/view/mutation.d.ts.map +1 -0
  105. package/view/mutation.js +37 -36
  106. package/view/mutation.js.map +1 -1
  107. package/view/render.d.ts +1 -0
  108. package/view/render.d.ts.map +1 -0
  109. package/view/render.js +9 -8
  110. package/view/render.js.map +1 -1
  111. package/view/utils.d.ts +4 -3
  112. package/view/utils.d.ts.map +1 -0
  113. package/view/utils.js.map +1 -1
  114. package/view/view.d.ts +5 -4
  115. package/view/view.d.ts.map +1 -0
  116. package/view/view.js +19 -3
  117. package/view/view.js.map +1 -1
  118. package/zone/bootstrap.d.ts +1 -0
  119. package/zone/bootstrap.d.ts.map +1 -0
  120. package/zone/proxy.d.ts +1 -0
  121. package/zone/proxy.d.ts.map +1 -0
  122. package/zone/proxy.js +1 -0
  123. package/zone/proxy.js.map +1 -1
  124. package/zone/task.d.ts +1 -0
  125. package/zone/task.d.ts.map +1 -0
  126. package/zone/task.js +11 -3
  127. package/zone/task.js.map +1 -1
  128. package/zone/zone.d.ts +1 -0
  129. package/zone/zone.d.ts.map +1 -0
  130. package/zone/zone.js +8 -6
  131. package/zone/zone.js.map +1 -1
  132. package/providers/injector.d.ts +0 -10
  133. package/providers/injector.js +0 -27
  134. package/providers/injector.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/core/directive/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,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,EAAE,KAAK,CAAC,CAAC;YAC1D,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE;gBACxB,SAAS,CAAC,MAAM,EAAE,CAAC;aACnB;YACD,OAAO,MAAM,CAAC;SACd;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,GAAG,CAAC,WAAmB;QACtB,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE;YAC7B,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACvC,OAAO,IAAI,CAAC;SACZ;QACD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE;YACnD,IAAI,WAAW,IAAI,SAAS,EAAE;gBAC7B,OAAO,IAAI,CAAC;aACZ;SACD;QACD,IAAI,qBAAqB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;YACpD,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,QAAQ;QACP,OAAO,oBAAoB,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { ReactiveScope } from '@ibyar/expressions';\nimport { TypeOf } from '@ibyar/expressions/api/utils';\nimport { isOnInit } from '../component/lifecycle.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective } from './directive.js';\n\nexport type ElementContext = { this: HTMLElement } & { [key: string]: AttributeDirective | undefined; };\nexport class ElementReactiveScope extends ReactiveScope<ElementContext> {\n\tprivate directiveMap: Map<string, AttributeDirective> = new Map();\n\tconstructor(private el: HTMLElement) {\n\t\tsuper({} as ElementContext);\n\t\tthis._ctx.this = el;\n\t}\n\tgetElement() {\n\t\treturn this.el;\n\t}\n\tgetDirectives() {\n\t\treturn this.directiveMap;\n\t}\n\tget(propertyKey: PropertyKey): any {\n\t\tif (propertyKey === 'this') {\n\t\t\treturn this.el;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn directive;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.get(directive, propertyKey);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tthis._ctx[propertyKey as string] = directive;\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn Reflect.get(directive, propertyKey as string);\n\t\t}\n\t\treturn void 0;\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\tif (propertyKey in this.el) {\n\t\t\treturn Reflect.set(this.el, propertyKey, value);\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tconst result = Reflect.set(directive, propertyKey, value);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn false;\n\t}\n\thas(propertyKey: string): boolean {\n\t\tif (propertyKey in this._ctx) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (ClassRegistryProvider.hasDirective(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (ClassRegistryProvider.directiveHasInput(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ElementReactiveScope> {\n\t\treturn ElementReactiveScope;\n\t}\n}\n"]}
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/core/directive/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,oBAAqB,SAAQ,aAA6B;IAElD;IADZ,YAAY,GAAoC,IAAI,GAAG,EAAE,CAAC;IAClE,YAAoB,EAAe;QAClC,KAAK,CAAC,EAAoB,CAAC,CAAC;QADT,OAAE,GAAF,EAAE,CAAa;QAElC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACrB,CAAC;IACD,UAAU;QACT,OAAO,IAAI,CAAC,EAAE,CAAC;IAChB,CAAC;IACD,aAAa;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IACD,GAAG,CAAC,WAAwB;QAC3B,IAAI,WAAW,KAAK,MAAM,EAAE;YAC3B,OAAO,IAAI,CAAC,EAAE,CAAC;SACf;QACD,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WA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,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,QAAQ;QACP,OAAO,oBAAoB,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { ReactiveScope } from '@ibyar/expressions';\nimport { TypeOf } from '@ibyar/expressions/api/utils';\nimport { isOnInit } from '../component/lifecycle.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective } from './directive.js';\n\nexport type ElementContext = { this: HTMLElement } & { [key: string]: AttributeDirective | undefined; };\nexport class ElementReactiveScope extends ReactiveScope<ElementContext> {\n\tprivate directiveMap: Map<string, AttributeDirective> = new Map();\n\tconstructor(private el: HTMLElement) {\n\t\tsuper({} as ElementContext);\n\t\tthis._ctx.this = el;\n\t}\n\tgetElement() {\n\t\treturn this.el;\n\t}\n\tgetDirectives() {\n\t\treturn this.directiveMap;\n\t}\n\tget(propertyKey: PropertyKey): any {\n\t\tif (propertyKey === 'this') {\n\t\t\treturn this.el;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn directive;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.get(directive, propertyKey);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tthis._ctx[propertyKey as string] = directive;\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn Reflect.get(directive, propertyKey as string);\n\t\t}\n\t\treturn void 0;\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\tif (propertyKey in this.el) {\n\t\t\treturn Reflect.set(this.el, propertyKey, value);\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tconst result = Reflect.set(directive, propertyKey, value);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn false;\n\t}\n\thas(propertyKey: string): boolean {\n\t\tif (propertyKey in this._ctx) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (ClassRegistryProvider.hasDirective(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (ClassRegistryProvider.directiveHasInput(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ElementReactiveScope> {\n\t\treturn ElementReactiveScope;\n\t}\n}\n"]}
@@ -1,2 +1,3 @@
1
1
  import { DomNode } from '@ibyar/elements';
2
2
  export declare function deserializeExpressionNodes(node: DomNode): void;
3
+ //# sourceMappingURL=deserialize.d.ts.map
@@ -0,0 +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;AAmEzB,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,QAMvD"}
@@ -2,3 +2,4 @@ import { DomNode } from '@ibyar/elements/node.js';
2
2
  import { ExpressionNode } from '@ibyar/expressions';
3
3
  export declare function getPipelineNames(modelExpression: ExpressionNode): string[] | undefined;
4
4
  export declare function buildExpressionNodes(node: DomNode): void;
5
+ //# sourceMappingURL=expression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAEsC,OAAO,EAInD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,cAAc,EAEd,MAAM,oBAAoB,CAAC;AA2E5B,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,cAAc,GAAG,MAAM,EAAE,GAAG,SAAS,CAWtF;AA2FD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,QAMjD"}
@@ -128,11 +128,11 @@ function parseChild(child) {
128
128
  if (!ref?.inputs?.length) {
129
129
  return;
130
130
  }
131
- child.inputs ?? (child.inputs = []);
131
+ child.inputs ??= [];
132
132
  info.directiveInputs.forEach((expression, input) => {
133
133
  const modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;
134
134
  const attr = createLiveAttribute(modelName, expression);
135
- (child.inputs ?? (child.inputs = [])).push(attr);
135
+ (child.inputs ??= []).push(attr);
136
136
  });
137
137
  }
138
138
  }
@@ -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,UAA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ACpC,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\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\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,MA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TextContent, 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\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"]}
package/html/types.d.ts CHANGED
@@ -24,3 +24,4 @@ declare module '@ibyar/elements/node.js' {
24
24
  interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {
25
25
  }
26
26
  }
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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;IACD,UAAU,iCAAkC,SAAQ,0BAA0B;QAC7E;;;;WAIG;QACH,mBAAmB,EAAE,cAAc,EAAE,CAAC;KACtC;IAED,UAAU,gCAAiC,SAAQ,yBAAyB;KAE3E;CACD"}
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import 'reflect-metadata';
1
+ export * from './annotation/options.js';
2
2
  export * from './annotation/decorators.js';
3
3
  export * from './component/component.js';
4
4
  export * from './component/reflect.js';
@@ -12,7 +12,6 @@ export * from './linker/change-detector-ref.js';
12
12
  export * from './directive/directive.js';
13
13
  export * from './html/expression.js';
14
14
  export * from './pipe/pipe.js';
15
- export * from './providers/injector.js';
16
15
  export * from './providers/provider.js';
17
16
  export * from './utils/elements-util.js';
18
17
  export * from './utils/path.js';
@@ -25,3 +24,4 @@ export * from './view/view.js';
25
24
  export * from './zone/bootstrap.js';
26
25
  export * from './zone/task.js';
27
26
  export * from './zone/zone.js';
27
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
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,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,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;AAC/B,cAAc,gBAAgB,CAAC"}
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import 'reflect-metadata';
1
+ export * from './annotation/options.js';
2
2
  export * from './annotation/decorators.js';
3
3
  export * from './component/component.js';
4
4
  export * from './component/reflect.js';
@@ -12,7 +12,6 @@ export * from './linker/change-detector-ref.js';
12
12
  export * from './directive/directive.js';
13
13
  export * from './html/expression.js';
14
14
  export * from './pipe/pipe.js';
15
- export * from './providers/injector.js';
16
15
  export * from './providers/provider.js';
17
16
  export * from './utils/elements-util.js';
18
17
  export * from './utils/path.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,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,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 './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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,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,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;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["\nexport * from './annotation/options.js';\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 './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/task.js';\nexport * from './zone/zone.js';\n"]}
@@ -28,3 +28,4 @@ export declare abstract class ChangeDetectorRef {
28
28
  */
29
29
  export declare function createChangeDetectorRef(scope: ReactiveScopeControl<any>, propertyKey: keyof Context): ChangeDetectorRef;
30
30
  export declare function createModelChangeDetectorRef(resolver: () => ReactiveScopeControl<any>): ChangeDetectorRef;
31
+ //# sourceMappingURL=change-detector-ref.d.ts.map
@@ -0,0 +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;AAED;;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"}
@@ -32,3 +32,4 @@ export declare class TemplateRefImpl extends TemplateRef {
32
32
  createEmbeddedView<C extends object>(context: C | undefined, parentNode: Node): EmbeddedViewRef<C>;
33
33
  private executeTemplateExpressions;
34
34
  }
35
+ //# sourceMappingURL=template-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/template-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACN,cAAc,EAEK,KAAK,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAuB,MAAM,eAAe,CAAC;AAErE,8BAAsB,WAAW;IAEhC;;OAEG;IACH,QAAQ,KAAK,OAAO,IAAI,OAAO,CAAC;IAEhC;;;;;;;;OAQG;IACH,QAAQ,CAAC,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC;CAC/F;AAGD,qBAAa,eAAgB,SAAQ,WAAW;IAW9C,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,oBAAoB;IAb7B,OAAO,CAAC,KAAK,CAA2C;gBAGvD,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,EAC5B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,KAAK,EACZ,mBAAmB,EAAE,cAAc,EAAE;IAWtC,IAAI,OAAO,IAAI,OAAO,CAErB;IACD,IAAI,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,mBAAmB,EAEtD;IACD,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,eAAa,EAAE,UAAU,EAAE,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC;IAwBhG,OAAO,CAAC,0BAA0B;CAwBlC"}
@@ -3,6 +3,11 @@ import { EmbeddedViewRefImpl } from './view-ref.js';
3
3
  export class TemplateRef {
4
4
  }
5
5
  export class TemplateRefImpl extends TemplateRef {
6
+ _render;
7
+ _node;
8
+ _stack;
9
+ _templateExpressions;
10
+ _host;
6
11
  constructor(_render, _node, _stack, _templateExpressions) {
7
12
  super();
8
13
  this._render = _render;
@@ -1 +1 @@
1
- {"version":3,"file":"template-ref.js","sourceRoot":"","sources":["../../../src/core/linker/template-ref.ts"],"names":[],"mappings":"AACA,OAAO,EACU,2BAA2B,EAC3C,oBAAoB,EACD,KAAK,EACxB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,OAAgB,WAAW;CAiBhC;AAGD,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAU/C,YACS,OAA6B,EAC7B,KA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AE,UAAU,EAAE,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE9G,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,4GAA4G;QAC5G,sEAAsE;QACtE,OAAO,eAAe,CAAC;IACxB,CAAC;IACO,0BAA0B,CAAC,OAAc;QAChD,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE;YACvC,OAAO;SACP;QACD,aAAa;QACb,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC9C,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,uBAAuB;QACvB,MAAM,kBAAkB,GAAgC,EAAE,CAAC;QAC3D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC9C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,WAAW,GAAG,2BAA2B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACjE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC3B,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CACtC,KAAK,CAAC,CAAC,CAAC,EACR,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAC7B,CAAC;gBACF,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,kBAAkB,CAAC;IAC3B,CAAC;CACD","sourcesContent":["import { DomNode } from '@ibyar/elements';\nimport {\n\tExpressionNode, findReactiveScopeByEventMap,\n\tReactiveScopeControl, Context,\n\tScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { StructuralDirective } from '../directive/directive.js';\nimport { ComponentRender } from '../view/render.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl } from './view-ref.js';\n\nexport abstract class TemplateRef {\n\n\t/**\n\t * get the current ref of this template\n\t */\n\tabstract get astNode(): DomNode;\n\n\t/**\n\t * Instantiates an embedded view based on this template,\n\t * `Not attached to the view`.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<template>` usage.\n\t * \n\t * To insert it to a view need to use a `ViewContainerRef.createEmbeddedView()`\n\t * @returns The new embedded view object.\n\t */\n\tabstract createEmbeddedView<C extends object>(context: C, parentNode: Node): EmbeddedViewRef<C>;\n}\n\n\nexport class TemplateRefImpl extends TemplateRef {\n\tprivate _host: HTMLComponent<any> | StructuralDirective;\n\n\tconstructor(\n\t\trender: ComponentRender<any>,\n\t\tnode: DomNode,\n\t\tstack: Stack,\n\t\ttemplateExpressions: ExpressionNode[],\n\t);\n\n\tconstructor(\n\t\tprivate _render: ComponentRender<any>,\n\t\tprivate _node: DomNode,\n\t\tprivate _stack: Stack,\n\t\tprivate _templateExpressions: ExpressionNode[],\n\t) {\n\t\tsuper();\n\t}\n\tget astNode(): DomNode {\n\t\treturn this._node;\n\t}\n\tset host(host: HTMLComponent<any> | StructuralDirective) {\n\t\tthis._host = host;\n\t}\n\tcreateEmbeddedView<C extends object>(context: C = {} as C, parentNode: Node): EmbeddedViewRef<C> {\n\t\tconst directiveStack = this._stack.copyStack();\n\t\tconst templateScope = ReactiveScopeControl.blockScope<C>();\n\t\tdirectiveStack.pushScope(templateScope);\n\n\t\tconst sandBox = new Stack();\n\t\tconst contextScope = ReactiveScopeControl.for<C>(context);\n\t\tsandBox.pushScope(contextScope);\n\t\tsandBox.pushScope(templateScope);\n\n\t\tconst elements: Node[] = [];\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tconst embeddedViewRef = new EmbeddedViewRefImpl(contextScope, elements, subscriptions);\n\t\tconst scopeSubscriptions = this.executeTemplateExpressions(sandBox);\n\t\tscopeSubscriptions && subscriptions.push(...scopeSubscriptions);\n\n\t\tconst fragment = document.createDocumentFragment();\n\t\tthis._render.appendChildToParent(fragment, this._node, directiveStack, parentNode, subscriptions, this._host);\n\n\t\tfragment.childNodes.forEach(item => elements.push(item));\n\t\t// const updateSubscriptions = this.render.view._zone.onFinal.subscribe(() => contextScope.detectChanges());\n\t\t// embeddedViewRef.onDestroy(() => updateSubscriptions.unsubscribe());\n\t\treturn embeddedViewRef;\n\t}\n\tprivate executeTemplateExpressions(sandBox: Stack): ScopeSubscription<Context>[] | undefined {\n\t\tif (!this._templateExpressions?.length) {\n\t\t\treturn;\n\t\t}\n\t\t// init value\n\t\tthis._templateExpressions.forEach(expression => {\n\t\t\texpression.get(sandBox);\n\t\t});\n\n\t\t// subscribe to changes\n\t\tconst scopeSubscriptions: ScopeSubscription<object>[] = [];\n\t\tthis._templateExpressions.forEach(expression => {\n\t\t\tconst events = expression.events();\n\t\t\tconst scopeTuples = findReactiveScopeByEventMap(events, sandBox);\n\t\t\tscopeTuples.forEach(tuple => {\n\t\t\t\tconst subscription = tuple[1].subscribe(\n\t\t\t\t\ttuple[0],\n\t\t\t\t\t() => expression.get(sandBox)\n\t\t\t\t);\n\t\t\t\tscopeSubscriptions.push(subscription);\n\t\t\t});\n\t\t});\n\t\treturn scopeSubscriptions;\n\t}\n}\n"]}
1
+ {"version":3,"file":"template-ref.js","sourceRoot":"","sources":["../../../src/core/linker/template-ref.ts"],"names":[],"mappings":"AACA,OAAO,EACU,2BAA2B,EAC3C,oBAAoB,EACD,KAAK,EACxB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,OAAgB,WAAW;CAiBhC;AAGD,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAWtC;IACA;IACA;IACA;IAbD,KAAK,CAA2C;IASxD,YACS,OAA6B,EAC7B,KAAc,EACd,MAAa,EACb,oBAAsC;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IAAI,CAAC,KAAK,CAAC,CAAC;QAE9G,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,4GAA4G;QAC5G,sEAAsE;QACtE,OAAO,eAAe,CAAC;IACxB,CAAC;IACO,0BAA0B,CAAC,OAAc;QAChD,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE;YACvC,OAAO;SACP;QACD,aAAa;QACb,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC9C,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,uBAAuB;QACvB,MAAM,kBAAkB,GAAgC,EAAE,CAAC;QAC3D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC9C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,WAAW,GAAG,2BAA2B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACjE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC3B,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CACtC,KAAK,CAAC,CAAC,CAAC,EACR,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAC7B,CAAC;gBACF,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,kBAAkB,CAAC;IAC3B,CAAC;CACD","sourcesContent":["import { DomNode } from '@ibyar/elements';\nimport {\n\tExpressionNode, findReactiveScopeByEventMap,\n\tReactiveScopeControl, Context,\n\tScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { StructuralDirective } from '../directive/directive.js';\nimport { ComponentRender } from '../view/render.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl } from './view-ref.js';\n\nexport abstract class TemplateRef {\n\n\t/**\n\t * get the current ref of this template\n\t */\n\tabstract get astNode(): DomNode;\n\n\t/**\n\t * Instantiates an embedded view based on this template,\n\t * `Not attached to the view`.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<template>` usage.\n\t * \n\t * To insert it to a view need to use a `ViewContainerRef.createEmbeddedView()`\n\t * @returns The new embedded view object.\n\t */\n\tabstract createEmbeddedView<C extends object>(context: C, parentNode: Node): EmbeddedViewRef<C>;\n}\n\n\nexport class TemplateRefImpl extends TemplateRef {\n\tprivate _host: HTMLComponent<any> | StructuralDirective;\n\n\tconstructor(\n\t\trender: ComponentRender<any>,\n\t\tnode: DomNode,\n\t\tstack: Stack,\n\t\ttemplateExpressions: ExpressionNode[],\n\t);\n\n\tconstructor(\n\t\tprivate _render: ComponentRender<any>,\n\t\tprivate _node: DomNode,\n\t\tprivate _stack: Stack,\n\t\tprivate _templateExpressions: ExpressionNode[],\n\t) {\n\t\tsuper();\n\t}\n\tget astNode(): DomNode {\n\t\treturn this._node;\n\t}\n\tset host(host: HTMLComponent<any> | StructuralDirective) {\n\t\tthis._host = host;\n\t}\n\tcreateEmbeddedView<C extends object>(context: C = {} as C, parentNode: Node): EmbeddedViewRef<C> {\n\t\tconst directiveStack = this._stack.copyStack();\n\t\tconst templateScope = ReactiveScopeControl.blockScope<C>();\n\t\tdirectiveStack.pushScope(templateScope);\n\n\t\tconst sandBox = new Stack();\n\t\tconst contextScope = ReactiveScopeControl.for<C>(context);\n\t\tsandBox.pushScope(contextScope);\n\t\tsandBox.pushScope(templateScope);\n\n\t\tconst elements: Node[] = [];\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tconst embeddedViewRef = new EmbeddedViewRefImpl(contextScope, elements, subscriptions);\n\t\tconst scopeSubscriptions = this.executeTemplateExpressions(sandBox);\n\t\tscopeSubscriptions && subscriptions.push(...scopeSubscriptions);\n\n\t\tconst fragment = document.createDocumentFragment();\n\t\tthis._render.appendChildToParent(fragment, this._node, directiveStack, parentNode, subscriptions, this._host);\n\n\t\tfragment.childNodes.forEach(item => elements.push(item));\n\t\t// const updateSubscriptions = this.render.view._zone.onFinal.subscribe(() => contextScope.detectChanges());\n\t\t// embeddedViewRef.onDestroy(() => updateSubscriptions.unsubscribe());\n\t\treturn embeddedViewRef;\n\t}\n\tprivate executeTemplateExpressions(sandBox: Stack): ScopeSubscription<Context>[] | undefined {\n\t\tif (!this._templateExpressions?.length) {\n\t\t\treturn;\n\t\t}\n\t\t// init value\n\t\tthis._templateExpressions.forEach(expression => {\n\t\t\texpression.get(sandBox);\n\t\t});\n\n\t\t// subscribe to changes\n\t\tconst scopeSubscriptions: ScopeSubscription<object>[] = [];\n\t\tthis._templateExpressions.forEach(expression => {\n\t\t\tconst events = expression.events();\n\t\t\tconst scopeTuples = findReactiveScopeByEventMap(events, sandBox);\n\t\t\tscopeTuples.forEach(tuple => {\n\t\t\t\tconst subscription = tuple[1].subscribe(\n\t\t\t\t\ttuple[0],\n\t\t\t\t\t() => expression.get(sandBox)\n\t\t\t\t);\n\t\t\t\tscopeSubscriptions.push(subscription);\n\t\t\t});\n\t\t});\n\t\treturn scopeSubscriptions;\n\t}\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { MetadataClass } from '@ibyar/decorators';
1
2
  import type { TypeOf } from '../utils/typeof.js';
2
3
  import { TemplateRef } from './template-ref.js';
3
4
  import { EmbeddedViewRef, ViewRef } from './view-ref.js';
@@ -163,11 +164,12 @@ export declare class ViewContainerRefImpl extends ViewContainerRef {
163
164
  move(viewRef: EmbeddedViewRef<any>, newIndex: number): ViewRef;
164
165
  createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;
165
166
  createComponent<C extends {}>(selector: string, options?: IndexOptions): C;
166
- createComponent<C extends {}>(viewClass: TypeOf<HTMLComponent<C>>, options?: IndexOptions): C;
167
- createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;
167
+ createComponent<C extends {}>(viewClass: MetadataClass<HTMLComponent<C>>, options?: IndexOptions): C;
168
+ createComponent<C extends {}>(componentType: MetadataClass<C>, options?: ViewContainerComponentOptions): C;
168
169
  createElement<K extends keyof HTMLElementTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementTagNameMap[K];
169
170
  createElement<K extends keyof HTMLElementDeprecatedTagNameMap>(selector: K, options?: HTMLElementOptions): HTMLElementDeprecatedTagNameMap[K];
170
171
  createTextNode(data: string, options?: IndexOptions): Text;
171
172
  updateViews(views: ViewRef[]): void;
172
173
  }
173
174
  export {};
175
+ //# sourceMappingURL=view-container-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-container-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/view-container-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAuB,OAAO,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,UAAU,YAAY;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,CAAE,SAAQ,YAAY;IAC5D,OAAO,CAAC,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,WAAW,6BAA8B,SAAQ,YAAY;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB,EAAE,YAAY;CAE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
@@ -1,17 +1,18 @@
1
- import { ReflectComponents } from '../component/reflect.js';
1
+ import { ReactiveScopeControl } from '@ibyar/expressions';
2
2
  import { EmbeddedViewRefImpl } from './view-ref.js';
3
3
  import { getComponentView } from '../view/utils.js';
4
- import { ReactiveScopeControl } from '@ibyar/expressions';
5
4
  ;
6
5
  ;
7
6
  export class ViewContainerRef {
8
7
  }
9
8
  export class ViewContainerRefImpl extends ViewContainerRef {
9
+ _parent;
10
+ _firstComment;
11
+ _views = [];
10
12
  constructor(_parent, _firstComment) {
11
13
  super();
12
14
  this._parent = _parent;
13
15
  this._firstComment = _firstComment;
14
- this._views = [];
15
16
  }
16
17
  get anchorElement() {
17
18
  return this._parent;
@@ -34,7 +35,7 @@ export class ViewContainerRefImpl extends ViewContainerRef {
34
35
  return this._views[index];
35
36
  }
36
37
  detach(index) {
37
- index ?? (index = this._views.length - 1);
38
+ index ??= this._views.length - 1;
38
39
  const viewRef = this._views[index];
39
40
  viewRef.detach();
40
41
  this._views.splice(index, 1);
@@ -44,12 +45,12 @@ export class ViewContainerRefImpl extends ViewContainerRef {
44
45
  return this._views.indexOf(viewRef);
45
46
  }
46
47
  remove(index) {
47
- index ?? (index = this._views.length - 1);
48
+ index ??= this._views.length - 1;
48
49
  this._views[index].destroy();
49
50
  this._views.splice(index, 1);
50
51
  }
51
52
  insert(viewRef, index) {
52
- index = ((index ?? (index = this._views.length)) > this._views.length) ? this._views.length : index;
53
+ index = ((index ??= this._views.length) > this._views.length) ? this._views.length : index;
53
54
  const lastNode = index == 0 ? this._firstComment : this._views[index - 1].last;
54
55
  this._views.splice(index, 0, viewRef);
55
56
  viewRef.after(lastNode);
@@ -82,7 +83,7 @@ export class ViewContainerRefImpl extends ViewContainerRef {
82
83
  }
83
84
  else {
84
85
  const componentType = arg0;
85
- const defaultTagName = ReflectComponents.getComponentRef(componentType).selector;
86
+ const defaultTagName = componentType[Symbol.metadata].selector;
86
87
  const view = getComponentView(componentType, options?.selector ?? defaultTagName);
87
88
  if (!view) {
88
89
  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,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,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC9B,GAAG,CAAC,OAAO,EAAE,CAAC;aACd;YACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACtB;IACF,CAAC;IACQ,GAAG,CAAC,KAAa;QACzB,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAChC,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACQ,MAAM,CAAC,KAAc;QAC7B,KAAK,KAA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,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"]}
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;AAgBnD,CAAC;AAID,CAAC;AAMF,MAA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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 { 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';\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 = componentType[Symbol.metadata].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"]}
@@ -80,3 +80,4 @@ export declare class EmbeddedViewRefImpl<C extends object> extends EmbeddedViewR
80
80
  unsubscribe(): void;
81
81
  };
82
82
  }
83
+ //# sourceMappingURL=view-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/view-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,8BAAsB,OAAQ,SAAQ,iBAAiB;IACtD;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,IAAI;IAExB;;;OAGG;IACH,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC;IAElC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG;QAAE,WAAW,IAAI,IAAI,CAAA;KAAE;CAC/D;AAGD,8BAAsB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,OAAO;IACtE;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AAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG;QAAE,WAAW,IAAI,IAAI,CAAC;KAAE;CAYzD"}
@@ -4,13 +4,16 @@ export class ViewRef extends ChangeDetectorRef {
4
4
  export class EmbeddedViewRef extends ViewRef {
5
5
  }
6
6
  export class EmbeddedViewRefImpl extends EmbeddedViewRef {
7
+ _scope;
8
+ _rootNodes;
9
+ _subscriptions;
10
+ _destroyed = false;
11
+ _onDestroySubscribes = [];
7
12
  constructor(_scope, _rootNodes, _subscriptions) {
8
13
  super();
9
14
  this._scope = _scope;
10
15
  this._rootNodes = _rootNodes;
11
16
  this._subscriptions = _subscriptions;
12
- this._destroyed = false;
13
- this._onDestroySubscribes = [];
14
17
  }
15
18
  get context() {
16
19
  return this._scope.getContext();
@@ -1 +1 @@
1
- {"version":3,"file":"view-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,OAAgB,OAAQ,SAAQ,iBAAiB;CAmBtD;AAGD,MAAM,OAAgB,eAAkC,SAAQ,OAAO;CAwCtE;AAED,MAAM,OAAO,mBAAsC,SAAQ,eAAkB;IAK5E,YACS,MAA+B,EAC/B,UAAkB,EAClB,cAA6C;QACrD,KAAK,EAAE,CAAC;QAHA,WAAM,GAAN,MAAM,CAAyB;QAC/B,eAAU,GAAV,UAAU,CAAQ;QAClB,mBAAc,GAAd,cAAc,CAA+B;QAN9C,eAAU,GAAY,KAAK,CAAC;QAC5B,yBAAoB,GAAmB,EAAE,CAAC;IAOlD,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACjC,CAAC;IAED,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IACD,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAY,CAAC;IACtC,C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,CAAC;IAC/B,CAAC;IACD,MAAM,CAAC,IAAe;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,MAAM;QACL,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;YACzB,IAAK,CAAC,MAAM,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;IACD,QAAQ;QACP,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;IACD,YAAY;QACX,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;IACD,aAAa;QACZ,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IACD,cAAc;QACb,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IAC9B,CAAC;IACD,SAAS,CAAC,QAAoB;QAC7B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO;YACN,WAAW,EAAE,GAAG,EAAE;gBACjB,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;oBACf,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBAC3C;YACF,CAAC;SACD,CAAC;IACH,CAAC;CAED","sourcesContent":["import { ReactiveScopeControl, Context, ScopeSubscription } from '@ibyar/expressions';\nimport { ChangeDetectorRef } from './change-detector-ref.js';\n\nexport abstract class ViewRef extends ChangeDetectorRef {\n\t/**\n\t * Destroys this view and all of the data structures associated with it.\n\t */\n\tabstract destroy(): void;\n\n\t/**\n\t * Reports whether this view has been destroyed.\n\t * @returns True after the `destroy()` method has been called, false otherwise.\n\t */\n\tabstract get destroyed(): boolean;\n\n\t/**\n\t * A lifecycle hook that provides additional developer-defined cleanup\n\t * functionality for views.\n\t * @param callback A handler function that cleans up developer-defined data\n\t * associated with a view. Called when the `destroy()` method is invoked.\n\t */\n\tabstract onDestroy(callback: Function): { unsubscribe(): void };\n}\n\n\nexport abstract class EmbeddedViewRef<C extends object> extends ViewRef {\n\t/**\n\t * The context for this view, inherited from the anchor element.\n\t */\n\tabstract get context(): C;\n\n\t/**\n\t * The root nodes for this embedded view.\n\t */\n\tabstract get rootNodes(): Node[];\n\n\t/**\n\t * the first node for this embedded view.\n\t */\n\tabstract get first(): ChildNode;\n\n\t/**\n\t * the last node for this embedded view.\n\t */\n\tabstract get last(): ChildNode;\n\n\t/**\n\t * insert view after the node.\n\t * @param node \n\t */\n\tabstract after(node: ChildNode): void;\n\n\t/**\n\t * insert view before the node.\n\t * @param node \n\t */\n\tabstract before(node: ChildNode): void;\n\n\t/**\n\t * remove the root nodes from the view, but keep reference to them.\n\t * \n\t * Detaches a view from this container without destroying it.\n\t * Use along with after()/before() to move a view within the current container.\n\t */\n\tabstract detach(): void;\n}\n\nexport class EmbeddedViewRefImpl<C extends object> extends EmbeddedViewRef<C> {\n\n\tprivate _destroyed: boolean = false;\n\tprivate _onDestroySubscribes: (() => void)[] = [];\n\n\tconstructor(\n\t\tprivate _scope: ReactiveScopeControl<C>,\n\t\tprivate _rootNodes: Node[],\n\t\tprivate _subscriptions?: ScopeSubscription<Context>[]) {\n\t\tsuper();\n\t}\n\n\tget context(): C {\n\t\treturn this._scope.getContext();\n\t}\n\n\tget rootNodes(): Node[] {\n\t\treturn this._rootNodes;\n\t}\n\tget first(): Element {\n\t\treturn this._rootNodes[0] as Element;\n\t}\n\tget last(): Element {\n\t\treturn this._rootNodes[this._rootNodes.length - 1] as Element;\n\t}\n\tget destroyed(): boolean {\n\t\treturn this._destroyed;\n\t}\n\tdestroy(): void {\n\t\tif (!this._destroyed) {\n\t\t\tthis._subscriptions?.forEach(sub => sub.unsubscribe());\n\t\t\tthis._subscriptions?.splice(0, this._subscriptions.length);\n\t\t\tfor (const node of this._rootNodes) {\n\t\t\t\t(<Element>node).remove();\n\t\t\t}\n\t\t\tthis._onDestroySubscribes.forEach(callback => {\n\t\t\t\ttry {\n\t\t\t\t\tcallback();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._destroyed = true;\n\t\t}\n\t}\n\tprivate getAsANode() {\n\t\tif (this._rootNodes.length == 1) {\n\t\t\treturn this._rootNodes[0];\n\t\t}\n\t\tconst fragment = document.createDocumentFragment();\n\t\tthis._rootNodes.forEach(node => fragment.append(node));\n\t\treturn fragment;\n\t}\n\tafter(node: ChildNode): void {\n\t\tnode.after(this.getAsANode());\n\t}\n\tbefore(node: ChildNode): void {\n\t\tnode.before(this.getAsANode());\n\t}\n\tdetach(): void {\n\t\tfor (const node of this._rootNodes) {\n\t\t\t(<Element>node).remove();\n\t\t}\n\t\tthis._scope.detach();\n\t}\n\treattach(): void {\n\t\tthis._scope.emitChanges();\n\t}\n\tmarkForCheck(): void {\n\t\tthis._scope.emitChanges();\n\t}\n\tdetectChanges(): void {\n\t\tthis._scope.detectChanges();\n\t}\n\tcheckNoChanges(): void {\n\t\tthis._scope.checkNoChanges();\n\t}\n\tonDestroy(callback: () => void): { unsubscribe(): void; } {\n\t\tthis._onDestroySubscribes.push(callback);\n\t\treturn {\n\t\t\tunsubscribe: () => {\n\t\t\t\tconst index = this._onDestroySubscribes.indexOf(callback);\n\t\t\t\tif (index > -1) {\n\t\t\t\t\tthis._onDestroySubscribes.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n}\n"]}
1
+ {"version":3,"file":"view-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,OAAgB,OAAQ,SAAQ,iBAAiB;CAmBtD;AAGD,MAA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AO;YACN,WAAW,EAAE,GAAG,EAAE;gBACjB,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;oBACf,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBAC3C;YACF,CAAC;SACD,CAAC;IACH,CAAC;CAED","sourcesContent":["import { ReactiveScopeControl, Context, ScopeSubscription } from '@ibyar/expressions';\nimport { ChangeDetectorRef } from './change-detector-ref.js';\n\nexport abstract class ViewRef extends ChangeDetectorRef {\n\t/**\n\t * Destroys this view and all of the data structures associated with it.\n\t */\n\tabstract destroy(): void;\n\n\t/**\n\t * Reports whether this view has been destroyed.\n\t * @returns True after the `destroy()` method has been called, false otherwise.\n\t */\n\tabstract get destroyed(): boolean;\n\n\t/**\n\t * A lifecycle hook that provides additional developer-defined cleanup\n\t * functionality for views.\n\t * @param callback A handler function that cleans up developer-defined data\n\t * associated with a view. Called when the `destroy()` method is invoked.\n\t */\n\tabstract onDestroy(callback: Function): { unsubscribe(): void };\n}\n\n\nexport abstract class EmbeddedViewRef<C extends object> extends ViewRef {\n\t/**\n\t * The context for this view, inherited from the anchor element.\n\t */\n\tabstract get context(): C;\n\n\t/**\n\t * The root nodes for this embedded view.\n\t */\n\tabstract get rootNodes(): Node[];\n\n\t/**\n\t * the first node for this embedded view.\n\t */\n\tabstract get first(): ChildNode;\n\n\t/**\n\t * the last node for this embedded view.\n\t */\n\tabstract get last(): ChildNode;\n\n\t/**\n\t * insert view after the node.\n\t * @param node \n\t */\n\tabstract after(node: ChildNode): void;\n\n\t/**\n\t * insert view before the node.\n\t * @param node \n\t */\n\tabstract before(node: ChildNode): void;\n\n\t/**\n\t * remove the root nodes from the view, but keep reference to them.\n\t * \n\t * Detaches a view from this container without destroying it.\n\t * Use along with after()/before() to move a view within the current container.\n\t */\n\tabstract detach(): void;\n}\n\nexport class EmbeddedViewRefImpl<C extends object> extends EmbeddedViewRef<C> {\n\n\tprivate _destroyed: boolean = false;\n\tprivate _onDestroySubscribes: (() => void)[] = [];\n\n\tconstructor(\n\t\tprivate _scope: ReactiveScopeControl<C>,\n\t\tprivate _rootNodes: Node[],\n\t\tprivate _subscriptions?: ScopeSubscription<Context>[]) {\n\t\tsuper();\n\t}\n\n\tget context(): C {\n\t\treturn this._scope.getContext();\n\t}\n\n\tget rootNodes(): Node[] {\n\t\treturn this._rootNodes;\n\t}\n\tget first(): Element {\n\t\treturn this._rootNodes[0] as Element;\n\t}\n\tget last(): Element {\n\t\treturn this._rootNodes[this._rootNodes.length - 1] as Element;\n\t}\n\tget destroyed(): boolean {\n\t\treturn this._destroyed;\n\t}\n\tdestroy(): void {\n\t\tif (!this._destroyed) {\n\t\t\tthis._subscriptions?.forEach(sub => sub.unsubscribe());\n\t\t\tthis._subscriptions?.splice(0, this._subscriptions.length);\n\t\t\tfor (const node of this._rootNodes) {\n\t\t\t\t(<Element>node).remove();\n\t\t\t}\n\t\t\tthis._onDestroySubscribes.forEach(callback => {\n\t\t\t\ttry {\n\t\t\t\t\tcallback();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._destroyed = true;\n\t\t}\n\t}\n\tprivate getAsANode() {\n\t\tif (this._rootNodes.length == 1) {\n\t\t\treturn this._rootNodes[0];\n\t\t}\n\t\tconst fragment = document.createDocumentFragment();\n\t\tthis._rootNodes.forEach(node => fragment.append(node));\n\t\treturn fragment;\n\t}\n\tafter(node: ChildNode): void {\n\t\tnode.after(this.getAsANode());\n\t}\n\tbefore(node: ChildNode): void {\n\t\tnode.before(this.getAsANode());\n\t}\n\tdetach(): void {\n\t\tfor (const node of this._rootNodes) {\n\t\t\t(<Element>node).remove();\n\t\t}\n\t\tthis._scope.detach();\n\t}\n\treattach(): void {\n\t\tthis._scope.emitChanges();\n\t}\n\tmarkForCheck(): void {\n\t\tthis._scope.emitChanges();\n\t}\n\tdetectChanges(): void {\n\t\tthis._scope.detectChanges();\n\t}\n\tcheckNoChanges(): void {\n\t\tthis._scope.checkNoChanges();\n\t}\n\tonDestroy(callback: () => void): { unsubscribe(): void; } {\n\t\tthis._onDestroySubscribes.push(callback);\n\t\treturn {\n\t\t\tunsubscribe: () => {\n\t\t\t\tconst index = this._onDestroySubscribes.indexOf(callback);\n\t\t\t\tif (index > -1) {\n\t\t\t\t\tthis._onDestroySubscribes.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n}\n"]}
package/node.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './html/expression.js';
2
2
  export * from './utils/utils.js';
3
+ //# sourceMappingURL=node.d.ts.map
package/node.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/core/node.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibyar/core",
3
- "version": "0.8.6",
3
+ "version": "1.0.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/elements": "^0.8.6",
39
- "@ibyar/expressions": "^0.8.6",
40
- "reflect-metadata": "^0.1.13",
38
+ "@ibyar/decorators": "^1.0.0",
39
+ "@ibyar/elements": "^1.0.0",
40
+ "@ibyar/expressions": "^1.0.0",
41
41
  "tslib": "^2.5.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "zone.js": "~0.11.4 || ~0.12.0"
45
45
  },
46
46
  "devDependencies": {
47
- "typescript": "^4.9.5"
47
+ "typescript": "^5.0.4"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsc --build --verbose"
@@ -58,7 +58,6 @@
58
58
  "shadow-dom",
59
59
  "shadowdom",
60
60
  "dependency-injection",
61
- "reflect-metadata",
62
61
  "services",
63
62
  "component",
64
63
  "directive",
@@ -78,5 +77,5 @@
78
77
  "typescript",
79
78
  "front-end"
80
79
  ],
81
- "gitHead": "68473e88cb933d2f7d25ee7ea15e73c60630fc81"
80
+ "gitHead": "f7c358a00514b4fad30772373e34ea6b6a7a8972"
82
81
  }
package/pipe/pipe.d.ts CHANGED
@@ -46,3 +46,4 @@ export declare class AsyncPipeScope<T extends {
46
46
  unsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>): void;
47
47
  getClass(): TypeOf<AsyncPipeScope<T>>;
48
48
  }
49
+ //# sourceMappingURL=pipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../../src/core/pipe/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAA2B,MAAM,kCAAkC,CAAC;AAE9F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,EAAE,CAAC;IAClC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;CACvC;AAED,8BAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS;IAC3E,SAAS,CAAC,iBAAiB,EAAE,iBAAiB;gBAApC,iBAAiB,EAAE,iBAAiB;IAC1D,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EA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AC,CAAC,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,OAAO;IAWnG,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,GAAG;IAG9B,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAK9E,QAAQ,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CAGrC"}
package/pipe/pipe.js CHANGED
@@ -2,6 +2,7 @@ import { ReactiveScopeControl, ReadOnlyScope } from '@ibyar/expressions';
2
2
  import { createChangeDetectorRef } from '../linker/change-detector-ref.js';
3
3
  import { ClassRegistryProvider } from '../providers/provider.js';
4
4
  export class AsyncPipeTransform {
5
+ changeDetectorRef;
5
6
  constructor(changeDetectorRef) {
6
7
  this.changeDetectorRef = changeDetectorRef;
7
8
  }
@@ -61,9 +62,9 @@ export class AsyncPipeScope extends ReactiveScopeControl {
61
62
  static blockScope() {
62
63
  return new AsyncPipeScope();
63
64
  }
65
+ wrapper = {};
64
66
  constructor() {
65
67
  super({});
66
- this.wrapper = {};
67
68
  }
68
69
  set(propertyKey, pipeClass, receiver) {
69
70
  const detector = createChangeDetectorRef(this, propertyKey);