@ibyar/core 2.4.0 → 3.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 (123) hide show
  1. package/annotation/decorators.d.ts +4 -11
  2. package/annotation/decorators.d.ts.map +1 -1
  3. package/annotation/decorators.js +2 -71
  4. package/annotation/decorators.js.map +1 -1
  5. package/annotation/options.d.ts +16 -11
  6. package/annotation/options.d.ts.map +1 -1
  7. package/annotation/options.js.map +1 -1
  8. package/binding/binding.expressions copy.d.ts +43 -0
  9. package/binding/binding.expressions copy.d.ts.map +1 -0
  10. package/binding/binding.expressions copy.js +161 -0
  11. package/binding/binding.expressions copy.js.map +1 -0
  12. package/binding/signal.expressions.d.ts +50 -0
  13. package/binding/signal.expressions.d.ts.map +1 -0
  14. package/binding/signal.expressions.js +182 -0
  15. package/binding/signal.expressions.js.map +1 -0
  16. package/component/component.d.ts +15 -11
  17. package/component/component.d.ts.map +1 -1
  18. package/component/component.js +34 -0
  19. package/component/component.js.map +1 -1
  20. package/component/custom-element.d.ts +10 -17
  21. package/component/custom-element.d.ts.map +1 -1
  22. package/component/custom-element.js +1 -2
  23. package/component/custom-element.js.map +1 -1
  24. package/component/events.js.map +1 -1
  25. package/component/initializer.d.ts +79 -0
  26. package/component/initializer.d.ts.map +1 -0
  27. package/component/initializer.js +77 -0
  28. package/component/initializer.js.map +1 -0
  29. package/component/reflect.d.ts.map +1 -1
  30. package/component/reflect.js +8 -2
  31. package/component/reflect.js.map +1 -1
  32. package/di/inject.d.ts +11 -4
  33. package/di/inject.d.ts.map +1 -1
  34. package/di/inject.js +18 -2
  35. package/di/inject.js.map +1 -1
  36. package/di/provider.d.ts +8 -5
  37. package/di/provider.d.ts.map +1 -1
  38. package/di/provider.js +40 -13
  39. package/di/provider.js.map +1 -1
  40. package/directive/directive.d.ts +21 -12
  41. package/directive/directive.d.ts.map +1 -1
  42. package/directive/directive.js +76 -27
  43. package/directive/directive.js.map +1 -1
  44. package/html/deserialize.d.ts.map +1 -1
  45. package/html/deserialize.js +7 -0
  46. package/html/deserialize.js.map +1 -1
  47. package/html/expression.d.ts.map +1 -1
  48. package/html/expression.js +41 -8
  49. package/html/expression.js.map +1 -1
  50. package/index.d.ts +1 -0
  51. package/index.d.ts.map +1 -1
  52. package/index.js +1 -0
  53. package/index.js.map +1 -1
  54. package/initializer/input.d.ts +1 -0
  55. package/initializer/input.d.ts.map +1 -0
  56. package/initializer/input.js +2 -0
  57. package/initializer/input.js.map +1 -0
  58. package/linker/change-detector-ref.d.ts +3 -3
  59. package/linker/change-detector-ref.d.ts.map +1 -1
  60. package/linker/change-detector-ref.js +26 -4
  61. package/linker/change-detector-ref.js.map +1 -1
  62. package/linker/template-ref.js +3 -3
  63. package/linker/template-ref.js.map +1 -1
  64. package/linker/view-container-ref.d.ts +4 -4
  65. package/linker/view-container-ref.d.ts.map +1 -1
  66. package/linker/view-container-ref.js +4 -4
  67. package/linker/view-container-ref.js.map +1 -1
  68. package/linker/view-ref.d.ts +2 -2
  69. package/linker/view-ref.js.map +1 -1
  70. package/package.json +7 -7
  71. package/pipe/pipe.d.ts +8 -8
  72. package/pipe/pipe.d.ts.map +1 -1
  73. package/pipe/pipe.js +2 -2
  74. package/pipe/pipe.js.map +1 -1
  75. package/signals/factory.d.ts +19 -0
  76. package/signals/factory.d.ts.map +1 -0
  77. package/signals/factory.js +59 -0
  78. package/signals/factory.js.map +1 -0
  79. package/signals/initializer.d.ts +26 -0
  80. package/signals/initializer.d.ts.map +1 -0
  81. package/signals/initializer.js +19 -0
  82. package/signals/initializer.js.map +1 -0
  83. package/signals/input.d.ts +1 -0
  84. package/signals/input.d.ts.map +1 -0
  85. package/signals/input.js +2 -0
  86. package/signals/input.js.map +1 -0
  87. package/signals/runtime.d.ts +37 -0
  88. package/signals/runtime.d.ts.map +1 -0
  89. package/signals/runtime.js +176 -0
  90. package/signals/runtime.js.map +1 -0
  91. package/signals/scopes.d.ts +4 -0
  92. package/signals/scopes.d.ts.map +1 -0
  93. package/signals/scopes.js +4 -0
  94. package/signals/scopes.js.map +1 -0
  95. package/signals/signals.d.ts +9 -12
  96. package/signals/signals.d.ts.map +1 -1
  97. package/signals/signals.js +17 -44
  98. package/signals/signals.js.map +1 -1
  99. package/utils/elements-util.d.ts +0 -1
  100. package/utils/elements-util.d.ts.map +1 -1
  101. package/utils/elements-util.js +0 -9
  102. package/utils/elements-util.js.map +1 -1
  103. package/utils/typeof.d.ts +4 -2
  104. package/utils/typeof.d.ts.map +1 -1
  105. package/utils/typeof.js.map +1 -1
  106. package/view/base-view.d.ts +2 -2
  107. package/view/base-view.d.ts.map +1 -1
  108. package/view/base-view.js +72 -100
  109. package/view/base-view.js.map +1 -1
  110. package/view/form-view.d.ts +2 -2
  111. package/view/form-view.d.ts.map +1 -1
  112. package/view/form-view.js.map +1 -1
  113. package/view/render.d.ts +7 -3
  114. package/view/render.d.ts.map +1 -1
  115. package/view/render.js +80 -30
  116. package/view/render.js.map +1 -1
  117. package/view/utils.d.ts +2 -2
  118. package/view/utils.d.ts.map +1 -1
  119. package/view/utils.js.map +1 -1
  120. package/view/view.d.ts +3 -3
  121. package/view/view.d.ts.map +1 -1
  122. package/view/view.js +3 -3
  123. package/view/view.js.map +1 -1
@@ -1,19 +1,21 @@
1
+ import { isReactive, isSignal, ReactiveScope, ReadOnlyScope, Scope } from '@ibyar/expressions';
2
+ import { inject } from '../di/inject.js';
3
+ import { InjectionToken } from '../di/provider.js';
4
+ import { TemplateRef } from '../linker/template-ref.js';
5
+ import { ViewContainerRef } from '../linker/view-container-ref.js';
6
+ import { AuroraZone } from '../zone/zone.js';
7
+ export const NATIVE_HOST_TOKEN = new InjectionToken('NATIVE_HOST');
8
+ export const DIRECTIVE_HOST_TOKEN = new InjectionToken('DIRECTIVE_HOST');
9
+ export const SUCCESSORS_TOKEN = new InjectionToken('SUCCESSORS_TOKEN');
1
10
  /**
2
11
  * A structural directive selector as '*if' '*for'
3
12
  */
4
13
  export class StructuralDirective {
5
- templateRef;
6
- viewContainerRef;
7
- host;
8
- _zone;
9
- successors;
10
- constructor(templateRef, viewContainerRef, host, _zone, successors) {
11
- this.templateRef = templateRef;
12
- this.viewContainerRef = viewContainerRef;
13
- this.host = host;
14
- this._zone = _zone;
15
- this.successors = successors;
16
- }
14
+ zone = inject(AuroraZone);
15
+ templateRef = inject(TemplateRef);
16
+ host = inject(DIRECTIVE_HOST_TOKEN);
17
+ successors = inject(SUCCESSORS_TOKEN);
18
+ viewContainerRef = inject(ViewContainerRef);
17
19
  getSuccessor(name) {
18
20
  return this.successors[name];
19
21
  }
@@ -22,22 +24,69 @@ export class StructuralDirective {
22
24
  * An attributes directive selector as '[class] [style]'
23
25
  */
24
26
  export class AttributeDirective {
25
- el;
26
- _zone;
27
- constructor(el, _zone) {
28
- this.el = el;
29
- this._zone = _zone;
30
- }
27
+ el = inject(NATIVE_HOST_TOKEN);
28
+ zone = inject(AuroraZone);
31
29
  }
32
- /**
33
- * An attributes directive on structural directive
34
- */
35
- export class AttributeOnStructuralDirective {
36
- directive;
37
- _zone;
38
- constructor(directive, _zone) {
39
- this.directive = directive;
40
- this._zone = _zone;
30
+ export class ReactiveSignalScope extends ReactiveScope {
31
+ static for(context, propertyKeys) {
32
+ return new ReactiveSignalScope(context, propertyKeys);
33
+ }
34
+ static blockScope(propertyKeys) {
35
+ return new ReactiveSignalScope({}, propertyKeys);
36
+ }
37
+ static scopeForThis(ctx, propertyKeys) {
38
+ const thisScope = ReactiveSignalScope.for(ctx, propertyKeys);
39
+ const thisCtx = {
40
+ 'this': ctx,
41
+ };
42
+ const rootScope = Scope.for(thisCtx, ['this']);
43
+ rootScope.setInnerScope('this', thisScope);
44
+ return rootScope;
45
+ }
46
+ static readOnlyScopeForThis(ctx, propertyKeys) {
47
+ const thisScope = ReactiveSignalScope.for(ctx, propertyKeys);
48
+ const thisCtx = {
49
+ 'this': ctx,
50
+ };
51
+ const rootScope = ReadOnlyScope.for(thisCtx, ['this']);
52
+ rootScope.setInnerScope('this', thisScope);
53
+ return rootScope;
54
+ }
55
+ get(propertyKey) {
56
+ const value = super.get(propertyKey);
57
+ if (isReactive(value)) {
58
+ return value.get();
59
+ }
60
+ return value;
61
+ }
62
+ set(propertyKey, newValue, receiver) {
63
+ const value = Reflect.get(this._ctx, propertyKey);
64
+ if (isSignal(value)) {
65
+ value.set(newValue);
66
+ return true;
67
+ }
68
+ else {
69
+ return super.set(propertyKey, newValue, receiver);
70
+ }
71
+ }
72
+ subscribe(propertyKey, callback) {
73
+ const value = Reflect.get(this._ctx, propertyKey);
74
+ if (isReactive(value)) {
75
+ return value.subscribe(callback);
76
+ }
77
+ else {
78
+ return super.subscribe(propertyKey, callback);
79
+ }
80
+ }
81
+ unsubscribe(propertyKey, subscription) {
82
+ if (propertyKey) {
83
+ const value = Reflect.get(this._ctx, propertyKey);
84
+ if (isReactive(value)) {
85
+ value.getScope().unsubscribe(value.getIndex(), subscription);
86
+ return;
87
+ }
88
+ }
89
+ super.unsubscribe(propertyKey, subscription);
41
90
  }
42
91
  }
43
92
  //# sourceMappingURL=directive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAEpB;IACA;IACA;IACA;IACF;IALT,YACW,WAAwB,EACxB,gBAAkC,EAClC,IAA8C,EAC9C,KAAiB,EACnB,UAAuC;QAJrC,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,SAAI,GAAJ,IAAI,CAA0C;QAC9C,UAAK,GAAL,KAAK,CAAY;QACnB,eAAU,GAAV,UAAU,CAA6B;IAC5C,CAAC;IAEL,YAAY,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CAED;AAED;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACR;IAA2B;IAAjD,YAAsB,EAAe,EAAY,KAAiB;QAA5C,OAAE,GAAF,EAAE,CAAa;QAAY,UAAK,GAAL,KAAK,CAAY;IAAI,CAAC;CACvE;AAED;;GAEG;AACH,MAAM,OAAO,8BAA8B;IACpB;IAA0C;IAAhE,YAAsB,SAA8B,EAAY,KAAiB;QAA3D,cAAS,GAAT,SAAS,CAAqB;QAAY,UAAK,GAAL,KAAK,CAAY;IAAI,CAAC;CACtF","sourcesContent":["\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { TemplateRef } from '../linker/template-ref.js';\nimport { ViewContainerRef } from '../linker/view-container-ref.js';\nimport { AuroraZone } from '../zone/zone.js';\n\n/**\n * A structural directive selector as '*if' '*for'\n */\nexport class StructuralDirective {\n\tconstructor(\n\t\tprotected templateRef: TemplateRef,\n\t\tprotected viewContainerRef: ViewContainerRef,\n\t\tprotected host: HTMLComponent<any> | StructuralDirective,\n\t\tprotected _zone: AuroraZone,\n\t\tprivate successors: Record<string, TemplateRef>,\n\t) { }\n\n\tgetSuccessor(name: string): TemplateRef | undefined {\n\t\treturn this.successors[name];\n\t}\n\n}\n\n/**\n * An attributes directive selector as '[class] [style]'\n */\nexport class AttributeDirective {\n\tconstructor(protected el: HTMLElement, protected _zone: AuroraZone) { }\n}\n\n/**\n * An attributes directive on structural directive\n */\nexport class AttributeOnStructuralDirective {\n\tconstructor(protected directive: StructuralDirective, protected _zone: AuroraZone) { }\n}\n"]}
1
+ {"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAAA,OAAO,EACG,UAAU,EAAE,QAAQ,EAC7B,aAAa,EAAE,aAAa,EAAE,KAAK,EAEnC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAg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AC,CAAC;QACnD,CAAC;IACF,CAAC;IAEQ,SAAS,CAAC,WAAoB,EAAE,QAA8B;QACtE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAQ,CAAC;QACzD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACP,OAAO,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC;IAEQ,WAAW,CAAC,WAAiC,EAAE,YAA+C;QACtG,IAAI,WAAW,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAQ,CAAC;YACzD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,YAAY,CAAC,CAAC;gBAC7D,OAAO;YACR,CAAC;QACF,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAC9C,CAAC;CAED","sourcesContent":["import {\n\tContext, isReactive, isSignal,\n\tReactiveScope, ReadOnlyScope, Scope,\n\tScopeSubscription, ValueChangedCallback\n} from '@ibyar/expressions';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { inject } from '../di/inject.js';\nimport { InjectionToken } from '../di/provider.js';\nimport { TemplateRef } from '../linker/template-ref.js';\nimport { ViewContainerRef } from '../linker/view-container-ref.js';\nimport { AuroraZone } from '../zone/zone.js';\n\nexport const NATIVE_HOST_TOKEN = new InjectionToken<HTMLElement>('NATIVE_HOST');\nexport const DIRECTIVE_HOST_TOKEN = new InjectionToken<HTMLComponent<any> | StructuralDirective>('DIRECTIVE_HOST');\nexport const SUCCESSORS_TOKEN = new InjectionToken<Record<string, TemplateRef>>('SUCCESSORS_TOKEN');\n\n/**\n * A structural directive selector as '*if' '*for'\n */\nexport class StructuralDirective {\n\tprotected zone = inject(AuroraZone);\n\tprotected templateRef = inject(TemplateRef);\n\tprotected host = inject(DIRECTIVE_HOST_TOKEN)!;\n\tprivate successors = inject(SUCCESSORS_TOKEN)!;\n\tprotected viewContainerRef = inject(ViewContainerRef);\n\n\tgetSuccessor(name: string): TemplateRef | undefined {\n\t\treturn this.successors[name];\n\t}\n\n}\n\n/**\n * An attributes directive selector as '[class] [style]'\n */\nexport class AttributeDirective {\n\tprotected el = inject(NATIVE_HOST_TOKEN)!;\n\tprotected zone = inject(AuroraZone);\n}\n\n\nexport class ReactiveSignalScope<T extends Context> extends ReactiveScope<T> {\n\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveSignalScope(context, propertyKeys);\n\t}\n\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveSignalScope({} as T, propertyKeys);\n\t}\n\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveSignalScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveSignalScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\n\toverride get(propertyKey: keyof T) {\n\t\tconst value = super.get(propertyKey);\n\t\tif (isReactive(value)) {\n\t\t\treturn value.get();\n\t\t}\n\t\treturn value;\n\t}\n\n\toverride set(propertyKey: keyof T, newValue: any, receiver?: any): boolean {\n\t\tconst value = Reflect.get(this._ctx, propertyKey) as any;\n\t\tif (isSignal(value)) {\n\t\t\tvalue.set(newValue);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn super.set(propertyKey, newValue, receiver);\n\t\t}\n\t}\n\n\toverride subscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\tconst value = Reflect.get(this._ctx, propertyKey) as any;\n\t\tif (isReactive(value)) {\n\t\t\treturn value.subscribe(callback);\n\t\t} else {\n\t\t\treturn super.subscribe(propertyKey, callback);\n\t\t}\n\t}\n\n\toverride unsubscribe(propertyKey?: keyof T | undefined, subscription?: ScopeSubscription<T> | undefined): void {\n\t\tif (propertyKey) {\n\t\t\tconst value = Reflect.get(this._ctx, propertyKey) as any;\n\t\t\tif (isReactive(value)) {\n\t\t\t\tvalue.getScope().unsubscribe(value.getIndex(), subscription);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tsuper.unsubscribe(propertyKey, subscription);\n\t}\n\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../src/core/html/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACgD,OAAO,EAI7D,MAAM,iBAAiB,CAAC;AA6EzB,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,QAMvD"}
1
+ {"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../src/core/html/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACgD,OAAO,EAI7D,MAAM,iBAAiB,CAAC;AAqFzB,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,QAMvD"}
@@ -18,6 +18,11 @@ function deserializeLiveAttribute(attr) {
18
18
  attr.expression = deserialize(attr.expression);
19
19
  }
20
20
  }
21
+ function deserializeAssignmentAttributeUpdateElement(attr) {
22
+ if (attr.expression) {
23
+ attr.expression = deserialize(attr.expression);
24
+ }
25
+ }
21
26
  function deserializeLiveAttributeUpdateElement(attr) {
22
27
  if (attr.expression) {
23
28
  attr.expression = deserialize(attr.expression);
@@ -34,6 +39,7 @@ function deserializeAttributeDirectives(directive) {
34
39
  directive.outputs?.forEach(deserializeOutputExpression);
35
40
  directive.twoWayBinding?.forEach(deserializeLiveAttribute);
36
41
  directive.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);
42
+ directive.attributes?.forEach(deserializeAssignmentAttributeUpdateElement);
37
43
  }
38
44
  function deserializeBaseNode(base) {
39
45
  base.inputs?.forEach(deserializeLiveAttributeUpdateElement);
@@ -41,6 +47,7 @@ function deserializeBaseNode(base) {
41
47
  base.twoWayBinding?.forEach(deserializeLiveAttribute);
42
48
  base.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);
43
49
  base.attributeDirectives?.forEach(deserializeAttributeDirectives);
50
+ base.attributes?.forEach(deserializeAssignmentAttributeUpdateElement);
44
51
  }
45
52
  function deserializeChild(child) {
46
53
  if (child instanceof DomElementNode) {
@@ -1 +1 @@
1
- {"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../src/core/html/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,0BAA0B,EAAE,cAAc,EACpD,eAAe,EACf,iBAAiB,EACU,sBAAsB,EACjD,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,SAAS,mBAAmB,CAAC,IAAqB;IACjD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAA2B,CAAC;QACzE,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;AACF,CAAC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C;AAC5C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAa;IACvD,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;QACrC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACP,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["import {\n\tBaseNode, DomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomAttributeDirectiveNode, LocalTemplateVariables\n} from '@ibyar/elements';\n\nimport type { DomStructuralDirectiveNodeUpgrade } from '@ibyar/elements/node.js';\nimport { deserialize } from '@ibyar/expressions';\nimport { getPipelineNames } from './expression.js';\n\nfunction deserializeLiveText(text: LiveTextContent) {\n\tif (text.expression) {\n\t\ttext.expression = deserialize(text.expression) as typeof text.expression;\n\t\ttext.pipelineNames = getPipelineNames(text.expression.getRight());\n\t}\n}\n\nfunction deserializeLocalTemplateVariables(local: LocalTemplateVariables) {\n\tlocal.variables?.forEach(variable => {\n\t\tvariable.expression = deserialize(variable.expression) as typeof variable.expression;\n\t\tvariable.pipelineNames = getPipelineNames(variable.expression.getRight());\n\t});\n}\n\nfunction deserializeLiveAttribute(attr: LiveAttribute) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t}\n}\n\nfunction deserializeLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t\tattr.pipelineNames = getPipelineNames(attr.expression.getRight());\n\t}\n}\n\nfunction deserializeOutputExpression(attr: ElementAttribute<string, string>) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t}\n}\n\nfunction deserializeAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(deserializeLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(deserializeOutputExpression);\n\tdirective.twoWayBinding?.forEach(deserializeLiveAttribute);\n\tdirective.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);\n}\n\nfunction deserializeBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(deserializeLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(deserializeOutputExpression);\n\tbase.twoWayBinding?.forEach(deserializeLiveAttribute);\n\tbase.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(deserializeAttributeDirectives);\n}\n\nfunction deserializeChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tdeserializeBaseNode(child);\n\t\tdeserializeDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = (child as DomStructuralDirectiveNodeUpgrade).templateExpressions?.map(deserialize) ?? [];\n\t\tdeserializeChild(child.node);\n\t\tdeserializeBaseNode(child);\n\t\tchild.successors?.forEach(deserializeChild);\n\t} else if (isLiveTextContent(child)) {\n\t\tdeserializeLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tdeserializeDomParentNode(child);\n\t} else if (child instanceof LocalTemplateVariables) {\n\t\tdeserializeLocalTemplateVariables(child);\n\t}\n}\n\nfunction deserializeDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(deserializeChild);\n}\n\nexport function deserializeExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tdeserializeDomParentNode(node);\n\t} else {\n\t\tdeserializeChild(node);\n\t}\n}\n"]}
1
+ {"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../src/core/html/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,0BAA0B,EAAE,cAAc,EACpD,eAAe,EACf,iBAAiB,EACU,sBAAsB,EACjD,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,WAAW,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B,GAAI,KAA2C,CAAC,mBAAmB,EAAE,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAC5J,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC3B,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;SAAM,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;QAC7C,wBAAwB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;SAAM,IAAI,KAAK,YAAY,sBAAsB,EAAE,CAAC;QACpD,iCAAiC,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;AACF,CAAC;AAED,SAAS,wBAAwB,CAAC,MAAqB;IACtD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAa;IACvD,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;QACrC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACP,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["import {\n\tBaseNode, DomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomAttributeDirectiveNode, LocalTemplateVariables\n} from '@ibyar/elements';\n\nimport type { DomStructuralDirectiveNodeUpgrade } from '@ibyar/elements/node.js';\nimport { deserialize } from '@ibyar/expressions';\nimport { getPipelineNames } from './expression.js';\n\nfunction deserializeLiveText(text: LiveTextContent) {\n\tif (text.expression) {\n\t\ttext.expression = deserialize(text.expression) as typeof text.expression;\n\t\ttext.pipelineNames = getPipelineNames(text.expression.getRight());\n\t}\n}\n\nfunction deserializeLocalTemplateVariables(local: LocalTemplateVariables) {\n\tlocal.variables?.forEach(variable => {\n\t\tvariable.expression = deserialize(variable.expression) as typeof variable.expression;\n\t\tvariable.pipelineNames = getPipelineNames(variable.expression.getRight());\n\t});\n}\n\nfunction deserializeLiveAttribute(attr: LiveAttribute) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t}\n}\n\nfunction deserializeAssignmentAttributeUpdateElement(attr: ElementAttribute<string, string | number | boolean | object>) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t}\n}\n\nfunction deserializeLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t\tattr.pipelineNames = getPipelineNames(attr.expression.getRight());\n\t}\n}\n\nfunction deserializeOutputExpression(attr: ElementAttribute<string, string>) {\n\tif (attr.expression) {\n\t\tattr.expression = deserialize(attr.expression) as typeof attr.expression;\n\t}\n}\n\nfunction deserializeAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(deserializeLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(deserializeOutputExpression);\n\tdirective.twoWayBinding?.forEach(deserializeLiveAttribute);\n\tdirective.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);\n\tdirective.attributes?.forEach(deserializeAssignmentAttributeUpdateElement);\n}\n\nfunction deserializeBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(deserializeLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(deserializeOutputExpression);\n\tbase.twoWayBinding?.forEach(deserializeLiveAttribute);\n\tbase.templateAttrs?.forEach(deserializeLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(deserializeAttributeDirectives);\n\tbase.attributes?.forEach(deserializeAssignmentAttributeUpdateElement);\n}\n\nfunction deserializeChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tdeserializeBaseNode(child);\n\t\tdeserializeDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = (child as DomStructuralDirectiveNodeUpgrade).templateExpressions?.map(deserialize) ?? [];\n\t\tdeserializeChild(child.node);\n\t\tdeserializeBaseNode(child);\n\t\tchild.successors?.forEach(deserializeChild);\n\t} else if (isLiveTextContent(child)) {\n\t\tdeserializeLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tdeserializeDomParentNode(child);\n\t} else if (child instanceof LocalTemplateVariables) {\n\t\tdeserializeLocalTemplateVariables(child);\n\t}\n}\n\nfunction deserializeDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(deserializeChild);\n}\n\nexport function deserializeExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tdeserializeDomParentNode(node);\n\t} else {\n\t\tdeserializeChild(node);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAEsC,OAAO,EAKnD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,cAAc,EAMd,MAAM,oBAAoB,CAAC;AAoF5B,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,cAAc,GAAG,MAAM,EAAE,GAAG,SAAS,CAWtF;AA8FD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,QAMjD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAE/D;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,QAE/C"}
1
+ {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAEsC,OAAO,EAKnD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,cAAc,EAMd,MAAM,oBAAoB,CAAC;AAoF5B,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,cAAc,GAAG,MAAM,EAAE,GAAG,SAAS,CAWtF;AA8HD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,QAMjD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAE/D;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,QAE/C"}
@@ -57,7 +57,7 @@ function escapeMemberExpression(source) {
57
57
  * @param params
58
58
  */
59
59
  function checkAndValidateObjectSyntax(source) {
60
- if (source.startsWith('{')) {
60
+ if (source.trimStart().startsWith('{')) {
61
61
  return `(${source})`;
62
62
  }
63
63
  return source;
@@ -71,7 +71,7 @@ function parseLiveAttribute(attr) {
71
71
  attr.expression = new TwoWayAssignmentExpression(elementExpression, modelExpression);
72
72
  }
73
73
  else {
74
- console.error(`${attr.name}="${attr.value}"" is not a valid MemberExpression or Identifier 'x.y.z'`);
74
+ console.error(`[(${attr.name})]="${attr.value}" is not a valid MemberExpression or Identifier 'x.y.z'`);
75
75
  }
76
76
  }
77
77
  export function getPipelineNames(modelExpression) {
@@ -86,17 +86,48 @@ export function getPipelineNames(modelExpression) {
86
86
  });
87
87
  return pipelineNames.length ? pipelineNames : undefined;
88
88
  }
89
+ function parseAssignmentAttributeUpdateElement(attr) {
90
+ let left = attr.name;
91
+ let right = attr.value?.toString();
92
+ if (right?.startsWith('javascript:')) {
93
+ right = right.substring(11);
94
+ }
95
+ if (attr.name.startsWith('data-')) {
96
+ left = `this.dataset.${convertToMemberAccessStyle(attr.name.substring(5))}`;
97
+ }
98
+ else {
99
+ left = `this${escapeMemberExpression(attr.name)}`;
100
+ const elements = left.split(/\.|\[|]/).filter(s => !!s);
101
+ if (elements.length > 2) {
102
+ left = `this${escapeMemberExpression(elements[1])}`;
103
+ right = `({${elements[2]}: ${right}})`;
104
+ }
105
+ }
106
+ right = checkAndValidateObjectSyntax(right);
107
+ const assignment = `${left} = '${right}'`;
108
+ attr.expression = JavaScriptParser.parseScript(assignment);
109
+ }
89
110
  function parseLiveAttributeUpdateElement(attr) {
90
- const elementSource = attr.name.startsWith('data-')
91
- ? `this.dataset.${convertToMemberAccessStyle(attr.name.substring(5))}`
92
- : `this${escapeMemberExpression(attr.name)}`;
93
- const elementExpression = JavaScriptParser.parseScript(elementSource);
94
- const modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));
111
+ let left = attr.name;
112
+ let right = attr.value;
113
+ if (attr.name.startsWith('data-')) {
114
+ left = `this.dataset.${convertToMemberAccessStyle(attr.name.substring(5))}`;
115
+ }
116
+ else {
117
+ left = `this${escapeMemberExpression(attr.name)}`;
118
+ const elements = left.split(/\.|\[|]/).filter(s => !!s);
119
+ if (elements.length > 2) {
120
+ left = `this${escapeMemberExpression(elements[1])}`;
121
+ right = `({${elements[2]}: ${right}})`;
122
+ }
123
+ }
124
+ const elementExpression = JavaScriptParser.parseScript(left);
125
+ const modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(right));
95
126
  if (elementExpression instanceof MemberExpression) {
96
127
  attr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);
97
128
  }
98
129
  else {
99
- console.error(`[${attr.name}] is not a valid MemberExpression 'x.y.z'`);
130
+ console.error(`[${attr.name}]="${attr.value}" is not a valid MemberExpression 'x.y.z'`);
100
131
  }
101
132
  attr.pipelineNames = getPipelineNames(modelExpression);
102
133
  }
@@ -108,12 +139,14 @@ function parseAttributeDirectives(directive) {
108
139
  directive.outputs?.forEach(parseOutputExpression);
109
140
  directive.twoWayBinding?.forEach(parseLiveAttribute);
110
141
  directive.templateAttrs?.forEach(parseLiveAttributeUpdateElement);
142
+ directive.attributes?.forEach(parseAssignmentAttributeUpdateElement);
111
143
  }
112
144
  function parseBaseNode(base) {
113
145
  base.inputs?.forEach(parseLiveAttributeUpdateElement);
114
146
  base.outputs?.forEach(parseOutputExpression);
115
147
  base.twoWayBinding?.forEach(parseLiveAttribute);
116
148
  base.templateAttrs?.forEach(parseLiveAttributeUpdateElement);
149
+ base.attributes?.forEach(parseAssignmentAttributeUpdateElement);
117
150
  base.attributeDirectives?.forEach(parseAttributeDirectives);
118
151
  }
119
152
  function parseChild(child) {
@@ -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,EAEO,wBAAwB,EAChD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,UAAU,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAGjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,eAAe,GAAG,gBAAgB,CAAC,WAAW,CAAC,kBAAkB,CAAqB,CAAC;AAC7F,SAAS,aAAa,CAAC,IAAqB;IAC3C,MAAM,cAAc,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChE,IAAI,CAAC,UAAU,GAAG,IAAI,0BAA0B,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IAClF,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,2BAA2B,CAAC,KAA6B;IACjE,MAAM,UAAU,GAAG,gBAAgB,CAAC,WAAW,CAA0B,OAAO,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IACtG,KAAK,CAAC,SAA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,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAa;IACjD,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;QACrC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACP,UAAU,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAA+B;IAC/D,qBAAqB,CAAC,iBAAiB,CAAC,UAAiB,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,qBAAqB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {\n\tBaseNode, createLiveAttribute,\n\tDomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomStructuralDirectiveNodeUpgrade, DomAttributeDirectiveNode,\n\tLocalTemplateVariables, isLocalTemplateVariables\n} from '@ibyar/elements/node.js';\nimport {\n\tIdentifier,\n\tExpressionNode,\n\tMemberExpression,\n\tJavaScriptParser,\n\texpressionVisitor,\n\tPipelineExpression,\n\tVariableDeclarationNode\n} from '@ibyar/expressions';\nimport {\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { classRegistryProvider } from '../providers/provider.js';\n\nconst ThisTextContent = JavaScriptParser.parseScript('this.textContent') as MemberExpression;\nfunction parseLiveText(text: LiveTextContent) {\n\tconst textExpression = JavaScriptParser.parseScript(text.value);\n\ttext.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);\n\ttext.pipelineNames = getPipelineNames(textExpression);\n}\n\nfunction parseLocalTemplateVariables(local: LocalTemplateVariables) {\n\tconst expression = JavaScriptParser.parseScript<VariableDeclarationNode>(`let ${local.declarations}`);\n\tlocal.variables = expression.getDeclarations().map(declaration => {\n\t\tconst expression = new OneWayAssignmentExpression(declaration.getId(), declaration.getInit()!);\n\t\tconst pipelineNames = getPipelineNames(expression.getRight());\n\t\treturn { expression, pipelineNames };\n\t});\n}\n\n/**\n * user-name ==> userName\n * \n * @param source \n * @returns \n */\nfunction convertToMemberAccessStyle(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('-');\n\tif (dashSplits.length === 1) {\n\t\treturn source as string;\n\t}\n\treturn dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');\n}\n\nfunction getAccessNotation(property: string) {\n\tif (property.includes('-')) {\n\t\treturn [`['`, property, `']`];\n\t} else if (Number.isInteger(property.at(0))) {\n\t\treturn ['[', property, ']'];\n\t}\n\treturn ['.', property];\n}\n\n/**\n * user.tel-number ==> user['tel-number']\n * \n * @param source \n * @returns \n */\nfunction escapeMemberExpression(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('.');\n\treturn dashSplits.flatMap(property => getAccessNotation(property)).join('');\n}\n\n/**\n * warp js code with `()` if necessary\n * \n * `{name: 'alex'}` will be `({name: 'alex'})`\n * \n * @param params \n */\nfunction checkAndValidateObjectSyntax(source: string) {\n\tif (source.startsWith('{')) {\n\t\treturn `(${source})`;\n\t}\n\treturn source;\n}\nfunction parseLiveAttribute(attr: LiveAttribute) {\n\tconst elementSource = `this${escapeMemberExpression(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression\n\t\t&& (modelExpression instanceof MemberExpression || modelExpression instanceof Identifier)) {\n\t\tattr.expression = new TwoWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name}=\"${attr.value}\"\" is not a valid MemberExpression or Identifier 'x.y.z'`);\n\t}\n\n}\n\nexport function getPipelineNames(modelExpression: ExpressionNode): string[] | undefined {\n\tconst pipelineNames: string[] = [];\n\texpressionVisitor.visit(modelExpression, (expression, type, control) => {\n\t\tif (type === 'PipelineExpression') {\n\t\t\tconst pipelineName = (expression as PipelineExpression).getRight();\n\t\t\tif (pipelineName instanceof Identifier) {\n\t\t\t\tpipelineNames.push(pipelineName.getName() as string);\n\t\t\t}\n\t\t}\n\t});\n\treturn pipelineNames.length ? pipelineNames : undefined;\n}\n\nfunction parseLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tconst elementSource = attr.name.startsWith('data-')\n\t\t? `this.dataset.${convertToMemberAccessStyle(attr.name.substring(5))}`\n\t\t: `this${escapeMemberExpression(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression) {\n\t\tattr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`[${attr.name}] is not a valid MemberExpression 'x.y.z'`);\n\t}\n\tattr.pipelineNames = getPipelineNames(modelExpression);\n}\n\nfunction parseOutputExpression(attr: ElementAttribute<string, string>) {\n\tattr.expression = JavaScriptParser.parseScript(attr.value);\n}\n\nfunction parseAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(parseOutputExpression);\n\tdirective.twoWayBinding?.forEach(parseLiveAttribute);\n\tdirective.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n}\n\nfunction parseBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(parseOutputExpression);\n\tbase.twoWayBinding?.forEach(parseLiveAttribute);\n\tbase.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(parseAttributeDirectives);\n}\n\nfunction parseChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tparseBaseNode(child);\n\t\tparseDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\tconst expressions: ExpressionNode[] = [];\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = expressions;\n\t\tif (child.value) {\n\t\t\t// use shorthand syntax, possible mixed with input and outputs\n\t\t\tconst info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);\n\t\t\texpressions.push(...info.templateExpressions.map(template => JavaScriptParser.parseScript(template)));\n\t\t\t// <div let-i=\"index\">{{item}}</div>\n\n\t\t\tsearchForLetAttributes(child, expressions);\n\n\t\t\tif (info.directiveInputs.size > 0) {\n\t\t\t\tconst ref = classRegistryProvider.getDirectiveRef(child.name);\n\t\t\t\tif (!ref?.inputs?.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchild.inputs ??= [];\n\t\t\t\tinfo.directiveInputs.forEach((expression, input) => {\n\t\t\t\t\tconst modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;\n\t\t\t\t\tconst attr: LiveAttribute = createLiveAttribute(modelName, expression);\n\t\t\t\t\t(child.inputs ??= []).push(attr);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tsearchForLetAttributes(child, expressions);\n\t\t}\n\t\t// DomDirectiveNode\n\t\t// in case if add input/output support need to handle that here.\n\t\tparseChild(child.node);\n\t\tparseBaseNode(child);\n\t\tchild.successors?.forEach(parseChild);\n\t} else if (isLiveTextContent(child)) {\n\t\tparseLiveText(child);\n\t} else if (isLocalTemplateVariables(child)) {\n\t\tparseLocalTemplateVariables(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tparseDomParentNode(child);\n\t}\n}\n\nfunction searchForLetAttributes(child: DomStructuralDirectiveNode, expressions: ExpressionNode[]) {\n\tconst templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));\n\ttemplateExpressionsFromInput?.forEach(attr => {\n\t\tchild.attributes!.splice(child.attributes!.indexOf(attr), 1);\n\t\tconst attrName = convertToMemberAccessStyle(attr.name.split('-').slice(1));\n\t\tconst expression = `let ${attrName} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;\n\t\texpressions.push(JavaScriptParser.parseScript(expression));\n\t});\n}\n\nfunction parseDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(parseChild);\n}\n\nexport function buildExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tparseDomParentNode(node);\n\t} else {\n\t\tparseChild(node);\n\t}\n}\n\n/**\n * function to skip node checking\n * @param modelClass \n */\nexport function provideDirective(modelClass: Record<string, any>) {\n\tclassRegistryProvider.registerDirective(modelClass as any);\n}\n\nexport function deleteDirective(selector: string) {\n\tclassRegistryProvider.deleteDirective(selector);\n}\n"]}
1
+ {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,mBAAmB,EAC7B,0BAA0B,EAAE,cAAc,EAC1C,eAAe,EACf,iBAAiB,EAEO,wBAAwB,EAChD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,UAAU,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAGjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,eAAe,GAAG,gBAAgB,CAAC,WAAW,CAAC,kBAAkB,CAAqB,CAAC;AAC7F,SAAS,aAAa,CAAC,IAAqB;IAC3C,MAAM,cAAc,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChE,IAAI,CAAC,UAAU,GAAG,IAAI,0BAA0B,CAAC,eAAe,EAAE,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\n\tBaseNode, createLiveAttribute,\n\tDomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomStructuralDirectiveNodeUpgrade, DomAttributeDirectiveNode,\n\tLocalTemplateVariables, isLocalTemplateVariables\n} from '@ibyar/elements/node.js';\nimport {\n\tIdentifier,\n\tExpressionNode,\n\tMemberExpression,\n\tJavaScriptParser,\n\texpressionVisitor,\n\tPipelineExpression,\n\tVariableDeclarationNode\n} from '@ibyar/expressions';\nimport {\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { classRegistryProvider } from '../providers/provider.js';\n\nconst ThisTextContent = JavaScriptParser.parseScript('this.textContent') as MemberExpression;\nfunction parseLiveText(text: LiveTextContent) {\n\tconst textExpression = JavaScriptParser.parseScript(text.value);\n\ttext.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);\n\ttext.pipelineNames = getPipelineNames(textExpression);\n}\n\nfunction parseLocalTemplateVariables(local: LocalTemplateVariables) {\n\tconst expression = JavaScriptParser.parseScript<VariableDeclarationNode>(`let ${local.declarations}`);\n\tlocal.variables = expression.getDeclarations().map(declaration => {\n\t\tconst expression = new OneWayAssignmentExpression(declaration.getId(), declaration.getInit()!);\n\t\tconst pipelineNames = getPipelineNames(expression.getRight());\n\t\treturn { expression, pipelineNames };\n\t});\n}\n\n/**\n * user-name ==> userName\n * \n * @param source \n * @returns \n */\nfunction convertToMemberAccessStyle(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('-');\n\tif (dashSplits.length === 1) {\n\t\treturn source as string;\n\t}\n\treturn dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');\n}\n\nfunction getAccessNotation(property: string) {\n\tif (property.includes('-')) {\n\t\treturn [`['`, property, `']`];\n\t} else if (Number.isInteger(property.at(0))) {\n\t\treturn ['[', property, ']'];\n\t}\n\treturn ['.', property];\n}\n\n/**\n * user.tel-number ==> user['tel-number']\n * \n * @param source \n * @returns \n */\nfunction escapeMemberExpression(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('.');\n\treturn dashSplits.flatMap(property => getAccessNotation(property)).join('');\n}\n\n/**\n * warp js code with `()` if necessary\n * \n * `{name: 'alex'}` will be `({name: 'alex'})`\n * \n * @param params \n */\nfunction checkAndValidateObjectSyntax(source: string) {\n\tif (source.trimStart().startsWith('{')) {\n\t\treturn `(${source})`;\n\t}\n\treturn source;\n}\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\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 parseAssignmentAttributeUpdateElement(attr: ElementAttribute<string, string | number | boolean | object>) {\n\tlet left = attr.name;\n\tlet right = attr.value?.toString();\n\tif (right?.startsWith('javascript:')) {\n\t\tright = right.substring(11);\n\t}\n\tif (attr.name.startsWith('data-')) {\n\t\tleft = `this.dataset.${convertToMemberAccessStyle(attr.name.substring(5))}`;\n\t} else {\n\t\tleft = `this${escapeMemberExpression(attr.name)}`;\n\t\tconst elements = left.split(/\\.|\\[|]/).filter(s => !!s);\n\t\tif (elements.length > 2) {\n\t\t\tleft = `this${escapeMemberExpression(elements[1])}`;\n\t\t\tright = `({${elements[2]}: ${right}})`;\n\t\t}\n\t}\n\tright = checkAndValidateObjectSyntax(right);\n\tconst assignment = `${left} = '${right}'`;\n\tattr.expression = JavaScriptParser.parseScript(assignment);\n}\n\nfunction parseLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tlet left = attr.name;\n\tlet right = attr.value;\n\tif (attr.name.startsWith('data-')) {\n\t\tleft = `this.dataset.${convertToMemberAccessStyle(attr.name.substring(5))}`;\n\t} else {\n\t\tleft = `this${escapeMemberExpression(attr.name)}`;\n\t\tconst elements = left.split(/\\.|\\[|]/).filter(s => !!s);\n\t\tif (elements.length > 2) {\n\t\t\tleft = `this${escapeMemberExpression(elements[1])}`;\n\t\t\tright = `({${elements[2]}: ${right}})`;\n\t\t}\n\t}\n\tconst elementExpression = JavaScriptParser.parseScript(left);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(right));\n\tif (elementExpression instanceof MemberExpression) {\n\t\tattr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`[${attr.name}]=\"${attr.value}\" 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\tdirective.attributes?.forEach(parseAssignmentAttributeUpdateElement);\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.attributes?.forEach(parseAssignmentAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(parseAttributeDirectives);\n}\n\nfunction parseChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tparseBaseNode(child);\n\t\tparseDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\tconst expressions: ExpressionNode[] = [];\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = expressions;\n\t\tif (child.value) {\n\t\t\t// use shorthand syntax, possible mixed with input and outputs\n\t\t\tconst info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);\n\t\t\texpressions.push(...info.templateExpressions.map(template => JavaScriptParser.parseScript(template)));\n\t\t\t// <div let-i=\"index\">{{item}}</div>\n\n\t\t\tsearchForLetAttributes(child, expressions);\n\n\t\t\tif (info.directiveInputs.size > 0) {\n\t\t\t\tconst ref = classRegistryProvider.getDirectiveRef(child.name);\n\t\t\t\tif (!ref?.inputs?.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchild.inputs ??= [];\n\t\t\t\tinfo.directiveInputs.forEach((expression, input) => {\n\t\t\t\t\tconst modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;\n\t\t\t\t\tconst attr: LiveAttribute = createLiveAttribute(modelName, expression);\n\t\t\t\t\t(child.inputs ??= []).push(attr);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tsearchForLetAttributes(child, expressions);\n\t\t}\n\t\t// DomDirectiveNode\n\t\t// in case if add input/output support need to handle that here.\n\t\tparseChild(child.node);\n\t\tparseBaseNode(child);\n\t\tchild.successors?.forEach(parseChild);\n\t} else if (isLiveTextContent(child)) {\n\t\tparseLiveText(child);\n\t} else if (isLocalTemplateVariables(child)) {\n\t\tparseLocalTemplateVariables(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tparseDomParentNode(child);\n\t}\n}\n\nfunction searchForLetAttributes(child: DomStructuralDirectiveNode, expressions: ExpressionNode[]) {\n\tconst templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));\n\ttemplateExpressionsFromInput?.forEach(attr => {\n\t\tchild.attributes!.splice(child.attributes!.indexOf(attr), 1);\n\t\tconst attrName = convertToMemberAccessStyle(attr.name.split('-').slice(1));\n\t\tconst expression = `let ${attrName} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;\n\t\texpressions.push(JavaScriptParser.parseScript(expression));\n\t});\n}\n\nfunction parseDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(parseChild);\n}\n\nexport function buildExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tparseDomParentNode(node);\n\t} else {\n\t\tparseChild(node);\n\t}\n}\n\n/**\n * function to skip node checking\n * @param modelClass \n */\nexport function provideDirective(modelClass: Record<string, any>) {\n\tclassRegistryProvider.registerDirective(modelClass as any);\n}\n\nexport function deleteDirective(selector: string) {\n\tclassRegistryProvider.deleteDirective(selector);\n}\n"]}
package/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './annotation/options.js';
2
2
  export * from './annotation/decorators.js';
3
3
  export * from './signals/signals.js';
4
4
  export * from './component/component.js';
5
+ export * from './component/initializer.js';
5
6
  export * from './component/reflect.js';
6
7
  export * from './component/custom-element.js';
7
8
  export * from './component/events.js';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBA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,CAAC;AACzC,cAAc,sBAAsB,CAAC;AAErC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
package/index.js CHANGED
@@ -2,6 +2,7 @@ export * from './annotation/options.js';
2
2
  export * from './annotation/decorators.js';
3
3
  export * from './signals/signals.js';
4
4
  export * from './component/component.js';
5
+ export * from './component/initializer.js';
5
6
  export * from './component/reflect.js';
6
7
  export * from './component/custom-element.js';
7
8
  export * from './component/events.js';
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AAErC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AAErC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC","sourcesContent":["\nexport * from './annotation/options.js';\nexport * from './annotation/decorators.js';\nexport * from './signals/signals.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 './di/provider.js';\nexport * from './di/inject.js';\nexport * from './di/tokens.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\nexport * from './linker/change-detector-ref.js';\n\nexport * from './directive/directive.js';\nexport * from './html/expression.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/typeof.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/utils.js';\nexport * from './view/view.js';\n\n\nexport * from './zone/bootstrap.js';\nexport * from './zone/zone.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,sBAAsB,CAAC;AAErC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AAErC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC","sourcesContent":["\nexport * from './annotation/options.js';\nexport * from './annotation/decorators.js';\n\nexport * from './signals/signals.js';\n\nexport * from './component/component.js';\nexport * from './component/initializer.js';\nexport * from './component/reflect.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './di/provider.js';\nexport * from './di/inject.js';\nexport * from './di/tokens.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\nexport * from './linker/change-detector-ref.js';\n\nexport * from './directive/directive.js';\nexport * from './html/expression.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/typeof.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/utils.js';\nexport * from './view/view.js';\n\n\nexport * from './zone/bootstrap.js';\nexport * from './zone/zone.js';\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/core/initializer/input.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/core/initializer/input.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -1,4 +1,4 @@
1
- import { ReactiveScopeControl, Context } from '@ibyar/expressions';
1
+ import { ReactiveControlScope, Context } from '@ibyar/expressions';
2
2
  export declare abstract class ChangeDetectorRef {
3
3
  /**
4
4
  * used when want to update ui-view like, you want to replace an array with another
@@ -26,6 +26,6 @@ export declare abstract class ChangeDetectorRef {
26
26
  /**
27
27
  * create a change Detector Reference by property key.
28
28
  */
29
- export declare function createChangeDetectorRef(scope: ReactiveScopeControl<any>, propertyKey: keyof Context): ChangeDetectorRef;
30
- export declare function createModelChangeDetectorRef(resolver: () => ReactiveScopeControl<any>): ChangeDetectorRef;
29
+ export declare function createChangeDetectorRef(scope: ReactiveControlScope<any>, propertyKey: keyof Context): ChangeDetectorRef;
30
+ export declare function createModelChangeDetectorRef(resolver: () => ReactiveControlScope<any>): ChangeDetectorRef;
31
31
  //# sourceMappingURL=change-detector-ref.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"change-detector-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEnE,8BAAsB,iBAAiB;IAEtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,IAAI,IAAI;IAEzB;;;OAGG;IACH,QAAQ,CAAC,YAAY,IAAI,IAAI;IAE7B;;OAEG;IACH,QAAQ,CAAC,aAAa,IAAI,IAAI;IAG9B;;OAEG;IACH,QAAQ,CAAC,cAAc,IAAI,IAAI;CAC/B;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"}
1
+ {"version":3,"file":"change-detector-ref.d.ts","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEnE,8BAAsB,iBAAiB;IAEtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,IAAI,IAAI;IAEzB;;;OAGG;IACH,QAAQ,CAAC,YAAY,IAAI,IAAI;IAE7B;;OAEG;IACH,QAAQ,CAAC,aAAa,IAAI,IAAI;IAG9B;;OAEG;IACH,QAAQ,CAAC,cAAc,IAAI,IAAI;CAC/B;AAyBD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,OAAO,GAAG,iBAAiB,CAkBvH;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,oBAAoB,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAkBzG"}
@@ -1,10 +1,32 @@
1
1
  export class ChangeDetectorRef {
2
2
  }
3
+ class ChangeDetectorRefImpl extends ChangeDetectorRef {
4
+ ref;
5
+ constructor(ref) {
6
+ super();
7
+ this.ref = ref;
8
+ }
9
+ detach() {
10
+ this.ref.detach();
11
+ }
12
+ reattach() {
13
+ this.ref.reattach();
14
+ }
15
+ markForCheck() {
16
+ this.ref.markForCheck();
17
+ }
18
+ detectChanges() {
19
+ this.ref.detectChanges();
20
+ }
21
+ checkNoChanges() {
22
+ this.ref.checkNoChanges();
23
+ }
24
+ }
3
25
  /**
4
26
  * create a change Detector Reference by property key.
5
27
  */
6
28
  export function createChangeDetectorRef(scope, propertyKey) {
7
- return {
29
+ return new ChangeDetectorRefImpl({
8
30
  detach() {
9
31
  scope.detach();
10
32
  },
@@ -20,10 +42,10 @@ export function createChangeDetectorRef(scope, propertyKey) {
20
42
  checkNoChanges() {
21
43
  scope.checkNoChanges();
22
44
  },
23
- };
45
+ });
24
46
  }
25
47
  export function createModelChangeDetectorRef(resolver) {
26
- return {
48
+ return new ChangeDetectorRefImpl({
27
49
  detach() {
28
50
  resolver().detach();
29
51
  },
@@ -39,6 +61,6 @@ export function createModelChangeDetectorRef(resolver) {
39
61
  checkNoChanges() {
40
62
  resolver().checkNoChanges();
41
63
  },
42
- };
64
+ });
43
65
  }
44
66
  //# sourceMappingURL=change-detector-ref.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"change-detector-ref.js","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,iBAAiB;CA6BtC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAgC,EAAE,WAA0B;IACnG,OAAO;QACN,MAAM;YACL,KAAK,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;QACD,QAAQ;YACP,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC;QACD,YAAY;YACX,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;QACxD,CAAC;QACD,aAAa;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;QACD,cAAc;YACb,KAAK,CAAC,cAAc,EAAE,CAAC;QACxB,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,QAAyC;IACrF,OAAO;QACN,MAAM;YACL,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC;QACrB,CAAC;QACD,QAAQ;YACP,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;QACvB,CAAC;QACD,YAAY;YACX,QAAQ,EAAE,CAAC,aAAa,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa;YACZ,QAAQ,EAAE,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC;QACD,cAAc;YACb,QAAQ,EAAE,CAAC,cAAc,EAAE,CAAC;QAC7B,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { ReactiveScopeControl, Context } from '@ibyar/expressions';\n\nexport abstract class ChangeDetectorRef {\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tabstract detach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit changes now.\n\t */\n\tabstract reattach(): void;\n\n\t/**\n\t * apply changes now,\n\t * will not effect the state of the detector wither if attached ot not.\n\t */\n\tabstract markForCheck(): void;\n\n\t/**\n\t * apply change detection\n\t */\n\tabstract detectChanges(): void;\n\n\n\t/**\n\t * throw error if any changes has been made\n\t */\n\tabstract checkNoChanges(): void;\n}\n\n/**\n * create a change Detector Reference by property key.\n */\nexport function createChangeDetectorRef(scope: ReactiveScopeControl<any>, propertyKey: keyof Context): ChangeDetectorRef {\n\treturn {\n\t\tdetach() {\n\t\t\tscope.detach();\n\t\t},\n\t\treattach() {\n\t\t\tscope.reattach();\n\t\t},\n\t\tmarkForCheck() {\n\t\t\tscope.emitChanges(propertyKey, scope.get(propertyKey));\n\t\t},\n\t\tdetectChanges() {\n\t\t\tscope.detectChanges();\n\t\t},\n\t\tcheckNoChanges() {\n\t\t\tscope.checkNoChanges();\n\t\t},\n\t};\n}\n\nexport function createModelChangeDetectorRef(resolver: () => ReactiveScopeControl<any>): ChangeDetectorRef {\n\treturn {\n\t\tdetach() {\n\t\t\tresolver().detach();\n\t\t},\n\t\treattach() {\n\t\t\tresolver().reattach();\n\t\t},\n\t\tmarkForCheck() {\n\t\t\tresolver().detectChanges()\n\t\t},\n\t\tdetectChanges() {\n\t\t\tresolver().detectChanges();\n\t\t},\n\t\tcheckNoChanges() {\n\t\t\tresolver().checkNoChanges();\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"change-detector-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QAAQ,EAAE,CAAC;QACvB,CAAC;QACD,YAAY;YACX,QAAQ,EAAE,CAAC,aAAa,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa;YACZ,QAAQ,EAAE,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC;QACD,cAAc;YACb,QAAQ,EAAE,CAAC,cAAc,EAAE,CAAC;QAC7B,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { ReactiveControlScope, Context } from '@ibyar/expressions';\n\nexport abstract class ChangeDetectorRef {\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tabstract detach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit changes now.\n\t */\n\tabstract reattach(): void;\n\n\t/**\n\t * apply changes now,\n\t * will not effect the state of the detector wither if attached ot not.\n\t */\n\tabstract markForCheck(): void;\n\n\t/**\n\t * apply change detection\n\t */\n\tabstract detectChanges(): void;\n\n\n\t/**\n\t * throw error if any changes has been made\n\t */\n\tabstract checkNoChanges(): void;\n}\n\nclass ChangeDetectorRefImpl extends ChangeDetectorRef {\n\n\tconstructor(private ref: ChangeDetectorRef) {\n\t\tsuper();\n\t}\n\n\tdetach(): void {\n\t\tthis.ref.detach();\n\t}\n\treattach(): void {\n\t\tthis.ref.reattach();\n\t}\n\tmarkForCheck(): void {\n\t\tthis.ref.markForCheck();\n\t}\n\tdetectChanges(): void {\n\t\tthis.ref.detectChanges();\n\t}\n\tcheckNoChanges(): void {\n\t\tthis.ref.checkNoChanges();\n\t}\n}\n\n/**\n * create a change Detector Reference by property key.\n */\nexport function createChangeDetectorRef(scope: ReactiveControlScope<any>, propertyKey: keyof Context): ChangeDetectorRef {\n\treturn new ChangeDetectorRefImpl({\n\t\tdetach() {\n\t\t\tscope.detach();\n\t\t},\n\t\treattach() {\n\t\t\tscope.reattach();\n\t\t},\n\t\tmarkForCheck() {\n\t\t\tscope.emitChanges(propertyKey, scope.get(propertyKey));\n\t\t},\n\t\tdetectChanges() {\n\t\t\tscope.detectChanges();\n\t\t},\n\t\tcheckNoChanges() {\n\t\t\tscope.checkNoChanges();\n\t\t},\n\t});\n}\n\nexport function createModelChangeDetectorRef(resolver: () => ReactiveControlScope<any>): ChangeDetectorRef {\n\treturn new ChangeDetectorRefImpl({\n\t\tdetach() {\n\t\t\tresolver().detach();\n\t\t},\n\t\treattach() {\n\t\t\tresolver().reattach();\n\t\t},\n\t\tmarkForCheck() {\n\t\t\tresolver().detectChanges()\n\t\t},\n\t\tdetectChanges() {\n\t\t\tresolver().detectChanges();\n\t\t},\n\t\tcheckNoChanges() {\n\t\t\tresolver().checkNoChanges();\n\t\t},\n\t});\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { findReactiveScopeByEventMap, ReactiveScopeControl, Stack } from '@ibyar/expressions';
1
+ import { findReactiveScopeByEventMap, ReactiveControlScope, Stack } from '@ibyar/expressions';
2
2
  import { EmbeddedViewRefImpl } from './view-ref.js';
3
3
  export class TemplateRef {
4
4
  }
@@ -23,10 +23,10 @@ export class TemplateRefImpl extends TemplateRef {
23
23
  }
24
24
  createEmbeddedView(context = {}, parentNode) {
25
25
  const directiveStack = this._stack.copyStack();
26
- const templateScope = ReactiveScopeControl.blockScope();
26
+ const templateScope = ReactiveControlScope.blockScope();
27
27
  directiveStack.pushScope(templateScope);
28
28
  const sandBox = new Stack();
29
- const contextScope = ReactiveScopeControl.for(context);
29
+ const contextScope = ReactiveControlScope.for(context);
30
30
  sandBox.pushScope(contextScope);
31
31
  sandBox.pushScope(templateScope);
32
32
  const elements = [];
@@ -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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ements';\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,OA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ressionNode, findReactiveScopeByEventMap,\n\tReactiveControlScope, 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 = ReactiveControlScope.blockScope<C>();\n\t\tdirectiveStack.pushScope(templateScope);\n\n\t\tconst sandBox = new Stack();\n\t\tconst contextScope = ReactiveControlScope.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"]}