@ibyar/core 0.5.1 → 0.5.2

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.
@@ -1,4 +1,4 @@
1
- import { InfixExpressionNode, findScopeByEventMap, ReactiveScope, Scope } from '@ibyar/expressions';
1
+ import { InfixExpressionNode, findReactiveScopeByEventMap, Scope } from '@ibyar/expressions';
2
2
  import { AsyncPipeProvider, AsyncPipeScope, PipeProvider } from '../pipe/pipe.js';
3
3
  export class OneWayAssignmentExpression extends InfixExpressionNode {
4
4
  constructor(left, right) {
@@ -30,15 +30,13 @@ export class OneWayAssignmentExpression extends InfixExpressionNode {
30
30
  stack.pushScope(pipeScope);
31
31
  stack.pushScope(asyncPipeScope);
32
32
  }
33
- const map = findScopeByEventMap(this.rightEvents, stack);
33
+ const tuples = findReactiveScopeByEventMap(this.rightEvents, stack);
34
34
  const subscriptions = [];
35
- map.forEach((scope, eventName) => {
36
- if (scope instanceof ReactiveScope) {
37
- const subscription = scope.subscribe(eventName, (newValue, oldValue) => {
38
- this.get(stack);
39
- });
40
- subscriptions.push(subscription);
41
- }
35
+ tuples.forEach(tuple => {
36
+ const subscription = tuple[1].subscribe(tuple[0], (newValue, oldValue) => {
37
+ this.get(stack);
38
+ });
39
+ subscriptions.push(subscription);
42
40
  });
43
41
  return subscriptions;
44
42
  }
@@ -81,23 +79,21 @@ export class TwoWayAssignmentExpression extends InfixExpressionNode {
81
79
  this.getLTR(stack);
82
80
  };
83
81
  }
84
- subscribeToEvents(stack, map, actionCallback) {
82
+ subscribeToEvents(stack, tuples, actionCallback) {
85
83
  const subscriptions = [];
86
- map.forEach((scope, eventName) => {
87
- if (scope instanceof ReactiveScope) {
88
- const subscription = scope.subscribe(eventName, actionCallback);
89
- subscriptions.push(subscription);
90
- }
84
+ tuples.forEach(tuple => {
85
+ const subscription = tuple[1].subscribe(tuple[0], actionCallback);
86
+ subscriptions.push(subscription);
91
87
  });
92
88
  return subscriptions;
93
89
  }
94
90
  subscribe(stack) {
95
- const rightMap = findScopeByEventMap(this.rightEvents, stack);
91
+ const rightTuples = findReactiveScopeByEventMap(this.rightEvents, stack);
96
92
  const rtlAction = this.actionRTL(stack);
97
- const rtlSubscriptions = this.subscribeToEvents(stack, rightMap, rtlAction);
98
- const leftMap = findScopeByEventMap(this.leftEvents, stack);
93
+ const rtlSubscriptions = this.subscribeToEvents(stack, rightTuples, rtlAction);
94
+ const leftTuples = findReactiveScopeByEventMap(this.leftEvents, stack);
99
95
  const ltrAction = this.actionLTR(stack);
100
- const ltrSubscriptions = this.subscribeToEvents(stack, leftMap, ltrAction);
96
+ const ltrSubscriptions = this.subscribeToEvents(stack, leftTuples, ltrAction);
101
97
  return rtlSubscriptions.concat(ltrSubscriptions);
102
98
  }
103
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"binding.expressions.js","sourceRoot":"","sources":["../../../src/core/binding/binding.expressions.ts"],"names":[],"mappings":"AAAA,OAAO,EACU,mBAAmB,EAC5B,mBAAmB,EAAE,aAAa,EACL,KAAK,EAEzC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAWlF,MAAM,OAAO,0BAA2B,SAAQ,mBAAmC;IAGlF,YAAY,IAAsB,EAAE,KAAqB;QACxD,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAFlB,gBAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAG1C,CAAC;IACD,GAAG,CAAC,KAAY,EAAE,KAAU;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,GAAG,CAAC,KAAY;QACf,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,KAAK,E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InfixExpressionNode, ScopeSubscription,\n\tStack, findScopeByEventMap, ReactiveScope,\n\tScopeContext, ValueChangedCallback, Scope,\n\tMemberExpression, Identifier\n} from '@ibyar/expressions';\nimport { AsyncPipeProvider, AsyncPipeScope, PipeProvider } from '../pipe/pipe.js';\n\ntype OneWayOperator = ':=';\ntype TwoWayOperator = ':=:';\ntype BindingOperators = OneWayOperator | TwoWayOperator;\n\nexport interface BindingAssignment extends InfixExpressionNode<BindingOperators> {\n\tsubscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<ScopeContext>[];\n}\n\n\nexport class OneWayAssignmentExpression extends InfixExpressionNode<OneWayOperator> implements BindingAssignment {\n\n\tprivate rightEvents = this.right.events();\n\tconstructor(left: MemberExpression, right: ExpressionNode) {\n\t\tsuper(':=', left, right);\n\t}\n\tset(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\tconst rv = this.right.get(stack);\n\t\tthis.set(stack, rv);\n\t\treturn rv;\n\t}\n\tsubscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<ScopeContext>[] {\n\t\tif (pipelineNames?.length) {\n\t\t\tconst pipeScope = Scope.blockScope();\n\t\t\tconst asyncPipeScope = AsyncPipeScope.blockScope();\n\t\t\tpipelineNames.forEach(pipelineName => {\n\t\t\t\tconst scope = stack.findScope(pipelineName);\n\t\t\t\tconst pipe = scope.get(pipelineName)!;\n\t\t\t\tif (scope instanceof AsyncPipeProvider) {\n\t\t\t\t\tasyncPipeScope.set(pipelineName, pipe);\n\t\t\t\t} else if (scope instanceof PipeProvider) {\n\t\t\t\t\tpipeScope.set(pipelineName, pipe);\n\t\t\t\t}\n\t\t\t});\n\t\t\tstack.pushScope(pipeScope);\n\t\t\tstack.pushScope(asyncPipeScope);\n\t\t}\n\t\tconst map = findScopeByEventMap(this.rightEvents, stack);\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tmap.forEach((scope, eventName) => {\n\t\t\tif (scope instanceof ReactiveScope) {\n\t\t\t\tconst subscription = scope.subscribe(eventName, (newValue: any, oldValue?: any) => {\n\t\t\t\t\tthis.get(stack);\n\t\t\t\t});\n\t\t\t\tsubscriptions.push(subscription);\n\t\t\t}\n\t\t});\n\t\treturn subscriptions;\n\t}\n}\n\n\n/**\n * the default behavior is assign the right hand side to the left hand side.\n * \n * \n */\nexport class TwoWayAssignmentExpression extends InfixExpressionNode<TwoWayOperator> implements BindingAssignment {\n\n\tprotected left: MemberExpression;\n\tprotected right: MemberExpression | Identifier;\n\n\tprivate rightEvents = this.right.events();\n\tprivate leftEvents = this.left.events();\n\tconstructor(left: MemberExpression, right: MemberExpression | Identifier) {\n\t\tsuper(':=:', left, right);\n\t}\n\n\tset(stack: Stack, value: any) {\n\t\treturn this.setRTL(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\treturn this.getRTL(stack);\n\t}\n\n\tprivate setRTL(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tprivate getRTL(stack: Stack): any {\n\t\tconst rv = this.right.get(stack);\n\t\tthis.setRTL(stack, rv);\n\t\treturn rv;\n\t}\n\tprivate actionRTL(stack: Stack): ValueChangedCallback {\n\t\treturn (newValue: any, oldValue?: any) => {\n\t\t\tthis.getRTL(stack);\n\t\t};\n\t}\n\n\tprivate setLTR(stack: Stack, value: any) {\n\t\treturn this.right.set(stack, value);\n\t}\n\tprivate getLTR(stack: Stack): any {\n\t\tconst lv = this.left.get(stack);\n\t\tthis.setLTR(stack, lv);\n\t\treturn lv;\n\t}\n\tprivate actionLTR(stack: Stack): ValueChangedCallback {\n\t\treturn (newValue: any, oldValue?: any) => {\n\t\t\tthis.getLTR(stack);\n\t\t};\n\t}\n\n\tprivate subscribeToEvents(stack: Stack, map: Map<string, Scope<ScopeContext>>, actionCallback: ValueChangedCallback) {\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tmap.forEach((scope, eventName) => {\n\t\t\tif (scope instanceof ReactiveScope) {\n\t\t\t\tconst subscription = scope.subscribe(eventName, actionCallback);\n\t\t\t\tsubscriptions.push(subscription);\n\t\t\t}\n\t\t});\n\t\treturn subscriptions;\n\t}\n\n\tsubscribe(stack: Stack): ScopeSubscription<ScopeContext>[] {\n\n\t\t// right to left\n\t\tconst rightMap = findScopeByEventMap(this.rightEvents, stack);\n\t\tconst rtlAction = this.actionRTL(stack);\n\t\tconst rtlSubscriptions = this.subscribeToEvents(stack, rightMap, rtlAction);\n\n\t\t// left to right \n\t\tconst leftMap = findScopeByEventMap(this.leftEvents, stack);\n\t\tconst ltrAction = this.actionLTR(stack);\n\t\tconst ltrSubscriptions = this.subscribeToEvents(stack, leftMap, ltrAction);\n\n\t\treturn rtlSubscriptions.concat(ltrSubscriptions);\n\t}\n\n}\n"]}
1
+ {"version":3,"file":"binding.expressions.js","sourceRoot":"","sources":["../../../src/core/binding/binding.expressions.ts"],"names":[],"mappings":"AAAA,OAAO,EACU,mBAAmB,EAC5B,2BAA2B,EACE,KAAK,EAEzC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAWlF,MAAM,OAAO,0BAA2B,SAAQ,mBAAmC;IAGlF,YAAY,IAAsB,EAAE,KAAqB;QACxD,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAFlB,gBAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAG1C,CAAC;IACD,GAAG,CAAC,KAAY,EAAE,KAAU;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,GAAG,CAAC,KAAY;QACf,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC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ValueChangedCallback, Scope,\n\tMemberExpression, Identifier\n} from '@ibyar/expressions';\nimport { AsyncPipeProvider, AsyncPipeScope, PipeProvider } from '../pipe/pipe.js';\n\ntype OneWayOperator = ':=';\ntype TwoWayOperator = ':=:';\ntype BindingOperators = OneWayOperator | TwoWayOperator;\n\nexport interface BindingAssignment extends InfixExpressionNode<BindingOperators> {\n\tsubscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<ScopeContext>[];\n}\n\n\nexport class OneWayAssignmentExpression extends InfixExpressionNode<OneWayOperator> implements BindingAssignment {\n\n\tprivate rightEvents = this.right.events();\n\tconstructor(left: MemberExpression, right: ExpressionNode) {\n\t\tsuper(':=', left, right);\n\t}\n\tset(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\tconst rv = this.right.get(stack);\n\t\tthis.set(stack, rv);\n\t\treturn rv;\n\t}\n\tsubscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<ScopeContext>[] {\n\t\tif (pipelineNames?.length) {\n\t\t\tconst pipeScope = Scope.blockScope();\n\t\t\tconst asyncPipeScope = AsyncPipeScope.blockScope();\n\t\t\tpipelineNames.forEach(pipelineName => {\n\t\t\t\tconst scope = stack.findScope(pipelineName);\n\t\t\t\tconst pipe = scope.get(pipelineName)!;\n\t\t\t\tif (scope instanceof AsyncPipeProvider) {\n\t\t\t\t\tasyncPipeScope.set(pipelineName, pipe);\n\t\t\t\t} else if (scope instanceof PipeProvider) {\n\t\t\t\t\tpipeScope.set(pipelineName, pipe);\n\t\t\t\t}\n\t\t\t});\n\t\t\tstack.pushScope(pipeScope);\n\t\t\tstack.pushScope(asyncPipeScope);\n\t\t}\n\t\tconst tuples = findReactiveScopeByEventMap(this.rightEvents, stack);\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\ttuples.forEach(tuple => {\n\t\t\tconst subscription = tuple[1].subscribe(tuple[0], (newValue: any, oldValue?: any) => {\n\t\t\t\tthis.get(stack);\n\t\t\t});\n\t\t\tsubscriptions.push(subscription);\n\t\t});\n\t\treturn subscriptions;\n\t}\n}\n\n\n/**\n * the default behavior is assign the right hand side to the left hand side.\n * \n * \n */\nexport class TwoWayAssignmentExpression extends InfixExpressionNode<TwoWayOperator> implements BindingAssignment {\n\n\tprotected left: MemberExpression;\n\tprotected right: MemberExpression | Identifier;\n\n\tprivate rightEvents = this.right.events();\n\tprivate leftEvents = this.left.events();\n\tconstructor(left: MemberExpression, right: MemberExpression | Identifier) {\n\t\tsuper(':=:', left, right);\n\t}\n\n\tset(stack: Stack, value: any) {\n\t\treturn this.setRTL(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\treturn this.getRTL(stack);\n\t}\n\n\tprivate setRTL(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tprivate getRTL(stack: Stack): any {\n\t\tconst rv = this.right.get(stack);\n\t\tthis.setRTL(stack, rv);\n\t\treturn rv;\n\t}\n\tprivate actionRTL(stack: Stack): ValueChangedCallback {\n\t\treturn (newValue: any, oldValue?: any) => {\n\t\t\tthis.getRTL(stack);\n\t\t};\n\t}\n\n\tprivate setLTR(stack: Stack, value: any) {\n\t\treturn this.right.set(stack, value);\n\t}\n\tprivate getLTR(stack: Stack): any {\n\t\tconst lv = this.left.get(stack);\n\t\tthis.setLTR(stack, lv);\n\t\treturn lv;\n\t}\n\tprivate actionLTR(stack: Stack): ValueChangedCallback {\n\t\treturn (newValue: any, oldValue?: any) => {\n\t\t\tthis.getLTR(stack);\n\t\t};\n\t}\n\n\tprivate subscribeToEvents(stack: Stack, tuples: [string, ReactiveScope<ScopeContext>][], actionCallback: ValueChangedCallback) {\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\ttuples.forEach(tuple => {\n\t\t\tconst subscription = tuple[1].subscribe(tuple[0], actionCallback);\n\t\t\tsubscriptions.push(subscription);\n\t\t});\n\t\treturn subscriptions;\n\t}\n\n\tsubscribe(stack: Stack): ScopeSubscription<ScopeContext>[] {\n\n\t\t// right to left\n\t\tconst rightTuples = findReactiveScopeByEventMap(this.rightEvents, stack);\n\t\tconst rtlAction = this.actionRTL(stack);\n\t\tconst rtlSubscriptions = this.subscribeToEvents(stack, rightTuples, rtlAction);\n\n\t\t// left to right \n\t\tconst leftTuples = findReactiveScopeByEventMap(this.leftEvents, stack);\n\t\tconst ltrAction = this.actionLTR(stack);\n\t\tconst ltrSubscriptions = this.subscribeToEvents(stack, leftTuples, ltrAction);\n\n\t\treturn rtlSubscriptions.concat(ltrSubscriptions);\n\t}\n\n}\n"]}
@@ -8,8 +8,6 @@ export declare class ElementModelReactiveScope<T extends {
8
8
  static classScopeFor<T extends object>(context: T): ElementModelReactiveScope<T>;
9
9
  static moduleScopeFor<T extends object>(context: T): ElementModelReactiveScope<T>;
10
10
  static globalScopeFor<T extends object>(context: T): ElementModelReactiveScope<T>;
11
- private functionProxyMap;
12
11
  private contextProxy;
13
12
  getContextProxy(): T;
14
- get(propertyKey: PropertyKey): any;
15
13
  }
@@ -1,8 +1,7 @@
1
- import { createProxyForContext, FunctionProxyHandler, ReactiveScopeControl } from '@ibyar/expressions';
1
+ import { createProxyForContext, ReactiveScopeControl } from '@ibyar/expressions';
2
2
  export class ElementModelReactiveScope extends ReactiveScopeControl {
3
3
  constructor() {
4
4
  super(...arguments);
5
- this.functionProxyMap = new Map();
6
5
  this.contextProxy = createProxyForContext(this);
7
6
  }
8
7
  static for(context, type) {
@@ -26,17 +25,5 @@ export class ElementModelReactiveScope extends ReactiveScopeControl {
26
25
  getContextProxy() {
27
26
  return this.contextProxy;
28
27
  }
29
- get(propertyKey) {
30
- if (this.functionProxyMap.has(propertyKey)) {
31
- return this.functionProxyMap.get(propertyKey);
32
- }
33
- const value = Reflect.get(this.context, propertyKey);
34
- if (typeof value === 'function') {
35
- const proxy = new Proxy(value, new FunctionProxyHandler(this.contextProxy));
36
- this.functionProxyMap.set(propertyKey, proxy);
37
- return proxy;
38
- }
39
- return value;
40
- }
41
28
  }
42
29
  //# sourceMappingURL=provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/component/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAa,MAAM,oBAAoB,CAAC;AAGlH,MAAM,OAAO,yBAAiE,SAAQ,oBAAuB;IAA7G;;QAmBS,qBAAgB,GAAG,IAAI,GAAG,EAAyB,CAAC;QACpD,iBAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAgBpD,CAAC;IAnCA,MAAM,CAAC,GAAG,CAAmB,OAAU,EAAE,IAAe;QACvD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,CAAC,aAAa,CAAmB,OAAU;QAChD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,CAAC,gBAAgB,CAAmB,OAAU;QACnD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,CAAC,aAAa,CAAmB,OAAU;QAChD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,CAAC,cAAc,CAAmB,OAAU;QACjD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,CAAC,cAAc,CAAmB,OAAU;QACjD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IAGD,eAAe;QACd,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IACD,GAAG,CAAC,WAAwB;QAC3B,IAAI,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAC3C,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;SAC9C;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACrD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YAChC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAW,KAAK,EAAE,IAAI,oBAAoB,CAAW,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;YAChG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;YAC9C,OAAO,KAAK,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["import { createProxyForContext, FunctionProxyHandler, ReactiveScopeControl, ScopeType } from '@ibyar/expressions';\n\n\nexport class ElementModelReactiveScope<T extends { [key: PropertyKey]: any }> extends ReactiveScopeControl<T> {\n\tstatic for<T extends object>(context: T, type: ScopeType) {\n\t\treturn new ElementModelReactiveScope(context, type);\n\t}\n\tstatic blockScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'block');\n\t}\n\tstatic functionScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'function');\n\t}\n\tstatic classScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'class');\n\t}\n\tstatic moduleScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'module');\n\t}\n\tstatic globalScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'global');\n\t}\n\tprivate functionProxyMap = new Map<PropertyKey, Function>();\n\tprivate contextProxy = createProxyForContext(this);\n\tgetContextProxy() {\n\t\treturn this.contextProxy;\n\t}\n\tget(propertyKey: PropertyKey): any {\n\t\tif (this.functionProxyMap.has(propertyKey)) {\n\t\t\treturn this.functionProxyMap.get(propertyKey);\n\t\t}\n\t\tconst value = Reflect.get(this.context, propertyKey);\n\t\tif (typeof value === 'function') {\n\t\t\tconst proxy = new Proxy<Function>(value, new FunctionProxyHandler<Function>(this.contextProxy));\n\t\t\tthis.functionProxyMap.set(propertyKey, proxy);\n\t\t\treturn proxy;\n\t\t}\n\t\treturn value;\n\t}\n}\n"]}
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/component/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAwB,oBAAoB,EAAa,MAAM,oBAAoB,CAAC;AAElH,MAAM,OAAO,yBAAiE,SAAQ,oBAAuB;IAA7G;;QAmBS,iBAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAiBpD,CAAC;IAnCA,MAAM,CAAC,GAAG,CAAmB,OAAU,EAAE,IAAe;QACvD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,CAAC,aAAa,CAAmB,OAAU;QAChD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,CAAC,gBAAgB,CAAmB,OAAU;QACnD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,CAAC,aAAa,CAAmB,OAAU;QAChD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,CAAC,cAAc,CAAmB,OAAU;QACjD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,CAAC,cAAc,CAAmB,OAAU;QACjD,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IAGD,eAAe;QACd,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CAaD","sourcesContent":["import { createProxyForContext, FunctionProxyHandler, ReactiveScopeControl, ScopeType } from '@ibyar/expressions';\n\nexport class ElementModelReactiveScope<T extends { [key: PropertyKey]: any }> extends ReactiveScopeControl<T> {\n\tstatic for<T extends object>(context: T, type: ScopeType) {\n\t\treturn new ElementModelReactiveScope(context, type);\n\t}\n\tstatic blockScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'block');\n\t}\n\tstatic functionScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'function');\n\t}\n\tstatic classScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'class');\n\t}\n\tstatic moduleScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'module');\n\t}\n\tstatic globalScopeFor<T extends object>(context: T) {\n\t\treturn new ElementModelReactiveScope(context, 'global');\n\t}\n\tprivate contextProxy = createProxyForContext(this);\n\t// private functionProxyMap = new Map<PropertyKey, Function>();\n\tgetContextProxy() {\n\t\treturn this.contextProxy;\n\t}\n\t// get(propertyKey: PropertyKey): any {\n\t// \t// if (this.functionProxyMap.has(propertyKey)) {\n\t// \t// \treturn this.functionProxyMap.get(propertyKey);\n\t// \t// }\n\t// \tconst value = Reflect.get(this.context, propertyKey);\n\t// \t// if (typeof value === 'function' && !('constructor' in value)) {\n\t// \t// \tconst proxy = new Proxy<Function>(value, new FunctionProxyHandler<Function>(this.contextProxy));\n\t// \t// \tthis.functionProxyMap.set(propertyKey, proxy);\n\t// \t// \treturn proxy;\n\t// \t// }\n\t// \treturn value;\n\t// }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ScopeSubscription } from '@ibyar/expressions';
2
+ export declare function createSubscriptionDestroyer(unsubscribe: () => void, pause?: () => void, resume?: () => void): ScopeSubscription<void>;
@@ -0,0 +1,14 @@
1
+ export function createSubscriptionDestroyer(unsubscribe, pause, resume) {
2
+ return {
3
+ pause() {
4
+ pause?.();
5
+ },
6
+ resume() {
7
+ resume?.();
8
+ },
9
+ unsubscribe() {
10
+ unsubscribe();
11
+ },
12
+ };
13
+ }
14
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../src/core/context/subscription.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,2BAA2B,CAAC,WAAuB,EAAE,KAAkB,EAAE,MAAmB;IAC3G,OAAO;QACN,KAAK;YACJ,KAAK,EAAE,EAAE,CAAC;QACX,CAAC;QACD,MAAM;YACL,MAAM,EAAE,EAAE,CAAC;QACZ,CAAC;QACD,WAAW;YACV,WAAW,EAAE,CAAC;QACf,CAAC;KAC0B,CAAC;AAC9B,CAAC","sourcesContent":["import { ScopeSubscription } from '@ibyar/expressions';\n\nexport function createSubscriptionDestroyer(unsubscribe: () => void, pause?: () => void, resume?: () => void): ScopeSubscription<void> {\n\treturn {\n\t\tpause(): void {\n\t\t\tpause?.();\n\t\t},\n\t\tresume(): void {\n\t\t\tresume?.();\n\t\t},\n\t\tunsubscribe(): void {\n\t\t\tunsubscribe();\n\t\t},\n\t} as ScopeSubscription<void>;\n}\n"]}
@@ -11,3 +11,7 @@ export declare class AttributeDirective {
11
11
  protected el: HTMLElement;
12
12
  constructor(el: HTMLElement);
13
13
  }
14
+ export declare class AttributeOnStructuralDirective {
15
+ protected directive: StructuralDirective;
16
+ constructor(directive: StructuralDirective);
17
+ }
@@ -10,4 +10,9 @@ export class AttributeDirective {
10
10
  this.el = el;
11
11
  }
12
12
  }
13
+ export class AttributeOnStructuralDirective {
14
+ constructor(directive) {
15
+ this.directive = directive;
16
+ }
17
+ }
13
18
  //# sourceMappingURL=directive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,mBAAmB;IAC/B,YACW,WAAwB,EACxB,gBAAkC,EAClC,IAA8C;QAF9C,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,SAAI,GAAJ,IAAI,CAA0C;IACrD,CAAC;CACL;AAKD,MAAM,OAAO,kBAAkB;IAC9B,YAAsB,EAAe;QAAf,OAAE,GAAF,EAAE,CAAa;IAAI,CAAC;CAC1C","sourcesContent":["\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { TemplateRef } from '../linker/template-ref.js';\nimport { ViewContainerRef } from '../linker/view-container-ref.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) { }\n}\n\n/**\n * An attributes directive selector as '[class] [style]'\n */\nexport class AttributeDirective {\n\tconstructor(protected el: HTMLElement) { }\n}\n"]}
1
+ {"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,mBAAmB;IAC/B,YACW,WAAwB,EACxB,gBAAkC,EAClC,IAA8C;QAF9C,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,SAAI,GAAJ,IAAI,CAA0C;IACrD,CAAC;CACL;AAKD,MAAM,OAAO,kBAAkB;IAC9B,YAAsB,EAAe;QAAf,OAAE,GAAF,EAAE,CAAa;IAAI,CAAC;CAC1C;AAKD,MAAM,OAAO,8BAA8B;IAC1C,YAAsB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAI,CAAC;CACzD","sourcesContent":["\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { TemplateRef } from '../linker/template-ref.js';\nimport { ViewContainerRef } from '../linker/view-container-ref.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) { }\n}\n\n/**\n * An attributes directive selector as '[class] [style]'\n */\nexport class AttributeDirective {\n\tconstructor(protected el: HTMLElement) { }\n}\n\n/**\n * An attributes directive on structural directive\n */\nexport class AttributeOnStructuralDirective {\n\tconstructor(protected directive: StructuralDirective) { }\n}\n"]}
package/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from './providers/injector.js';
14
14
  export * from './providers/provider.js';
15
15
  export * from './utils/elements-util.js';
16
16
  export * from './utils/path.js';
17
+ export * from './utils/typeof.js';
17
18
  export * from './utils/utils.js';
18
19
  export * from './view/mutation.js';
19
20
  export * from './view/render.js';
package/index.js CHANGED
@@ -14,6 +14,7 @@ export * from './providers/injector.js';
14
14
  export * from './providers/provider.js';
15
15
  export * from './utils/elements-util.js';
16
16
  export * from './utils/path.js';
17
+ export * from './utils/typeof.js';
17
18
  export * from './utils/utils.js';
18
19
  export * from './view/mutation.js';
19
20
  export * from './view/render.js';
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './annotation/decorators.js';\n\nexport * from './component/component.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './context/stack.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\n\nexport * from './directive/directive.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/injector.js';\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/view.js';\n\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './annotation/decorators.js';\n\nexport * from './component/component.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './context/stack.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\n\nexport * from './directive/directive.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/injector.js';\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/typeof.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/view.js';\n\n"]}
@@ -4,4 +4,4 @@ export declare abstract class ChangeDetectorRef {
4
4
  abstract reattach(): void;
5
5
  abstract markForCheck(): void;
6
6
  }
7
- export declare function createChangeDetectorRef(scope: ReactiveScopeControl<ScopeContext>, propertyKey?: keyof ScopeContext): ChangeDetectorRef;
7
+ export declare function createChangeDetectorRef(scope: ReactiveScopeControl<ScopeContext>, propertyKey: keyof ScopeContext): ChangeDetectorRef;
@@ -16,7 +16,7 @@ class ChangeDetectorRefImpl extends ChangeDetectorRef {
16
16
  }
17
17
  }
18
18
  export function createChangeDetectorRef(scope, propertyKey) {
19
- return new ChangeDetectorRefImpl({
19
+ const changeDetectorRef = {
20
20
  detach() {
21
21
  scope.detach();
22
22
  },
@@ -24,8 +24,9 @@ export function createChangeDetectorRef(scope, propertyKey) {
24
24
  scope.reattach();
25
25
  },
26
26
  markForCheck() {
27
- scope.emitChanges(propertyKey);
27
+ scope.emitChanges(propertyKey, scope.get(propertyKey));
28
28
  }
29
- });
29
+ };
30
+ return new ChangeDetectorRefImpl(changeDetectorRef);
30
31
  }
31
32
  //# 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;CAkBtC;AAED,MAAM,qBAAsB,SAAQ,iBAAiB;IACpD,YAAoB,iBAAoC;QAAI,KAAK,EAAE,CAAC;QAAhD,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAa,CAAC;IACtE,MAAM;QACL,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IACD,QAAQ;QACP,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IACD,YAAY;QACX,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;CACD;AAED,MAAM,UAAU,uBAAuB,CAAC,KAAyC,EAAE,WAAgC;IAClH,OAAO,IAAI,qBAAqB,CAAC;QAChC,MAAM;YACL,KAAK,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;QACD,QAAQ;YACP,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC;QACD,YAAY;YACX,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAChC,CAAC;KACoB,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import { ReactiveScopeControl, ScopeContext } 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 in time.\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\nclass ChangeDetectorRefImpl extends ChangeDetectorRef {\n\tconstructor(private changeDetectorRef: ChangeDetectorRef) { super(); }\n\tdetach(): void {\n\t\tthis.changeDetectorRef.detach();\n\t}\n\treattach(): void {\n\t\tthis.changeDetectorRef.reattach();\n\t}\n\tmarkForCheck(): void {\n\t\tthis.changeDetectorRef.markForCheck();\n\t}\n}\n\nexport function createChangeDetectorRef(scope: ReactiveScopeControl<ScopeContext>, propertyKey?: keyof ScopeContext): 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);\n\t\t}\n\t} as ChangeDetectorRef);\n}\n"]}
1
+ {"version":3,"file":"change-detector-ref.js","sourceRoot":"","sources":["../../../src/core/linker/change-detector-ref.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,iBAAiB;CAkBtC;AAED,MAAM,qBAAsB,SAAQ,iBAAiB;IACpD,YAAoB,iBAAoC;QAAI,KAAK,EAAE,CAAC;QAAhD,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAa,CAAC;IACtE,MAAM;QACL,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IACD,QAAQ;QACP,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IACD,YAAY;QACX,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;CACD;AAKD,MAAM,UAAU,uBAAuB,CAAC,KAAyC,EAAE,WAA+B;IACjH,MAAM,iBAAiB,GAAsB;QAC5C,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;KACD,CAAC;IACF,OAAO,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { ReactiveScopeControl, ScopeContext } 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 in time.\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\nclass ChangeDetectorRefImpl extends ChangeDetectorRef {\n\tconstructor(private changeDetectorRef: ChangeDetectorRef) { super(); }\n\tdetach(): void {\n\t\tthis.changeDetectorRef.detach();\n\t}\n\treattach(): void {\n\t\tthis.changeDetectorRef.reattach();\n\t}\n\tmarkForCheck(): void {\n\t\tthis.changeDetectorRef.markForCheck();\n\t}\n}\n\n/**\n * create a change Detector Reference by property key.\n */\nexport function createChangeDetectorRef(scope: ReactiveScopeControl<ScopeContext>, propertyKey: keyof ScopeContext): ChangeDetectorRef {\n\tconst changeDetectorRef: ChangeDetectorRef = {\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};\n\treturn new ChangeDetectorRefImpl(changeDetectorRef);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { DomNode } from '@ibyar/elements';
1
+ import { DomNode } from '@ibyar/elements';
2
2
  import { ExpressionNode, Stack } from '@ibyar/expressions';
3
3
  import { HTMLComponent } from '../component/custom-element.js';
4
4
  import { StructuralDirective } from '../directive/directive.js';
@@ -43,9 +43,9 @@ export class TemplateRefImpl extends TemplateRef {
43
43
  const scopeSubscriptions = [];
44
44
  this.templateExpressions.forEach(expression => {
45
45
  const events = expression.events();
46
- const scopeMap = findReactiveScopeByEventMap(events, sandBox);
47
- scopeMap.forEach((scope, eventName) => {
48
- const subscription = scope.subscribe(eventName, () => {
46
+ const scopeTuples = findReactiveScopeByEventMap(events, sandBox);
47
+ scopeTuples.forEach(tuple => {
48
+ const subscription = tuple[1].subscribe(tuple[0], () => {
49
49
  expression.get(sandBox);
50
50
  });
51
51
  scopeSubscriptions.push(subscription);
@@ -1 +1 @@
1
- {"version":3,"file":"template-ref.js","sourceRoot":"","sources":["../../../src/core/linker/template-ref.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EACrB,2BAA2B,EACR,KAAK,EACxB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,E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opeContext,\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\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, parentNode: Node): EmbeddedViewRef<C> {\n\t\tconst directiveStack = this.stack.copyStack();\n\n\t\tconst templateScope = directiveStack.pushBlockReactiveScope();\n\n\t\tconst sandBox = new Stack();\n\t\tconst contextScope = sandBox.pushBlockReactiveScopeFor(context ?? {});\n\t\tsandBox.pushScope(templateScope);\n\n\t\tconst elements: Node[] = [];\n\t\tconst contextProxy = createProxyForContext(contextScope);\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tconst embeddedViewRef = new EmbeddedViewRefImpl(contextProxy, 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\treturn embeddedViewRef;\n\t}\n\tprivate executeTemplateExpressions(sandBox: Stack): ScopeSubscription<ScopeContext>[] | 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 scopeMap = findReactiveScopeByEventMap(events, sandBox);\n\t\t\tscopeMap.forEach((scope, eventName) => {\n\t\t\t\tconst subscription = scope.subscribe(eventName, () => {\n\t\t\t\t\texpression.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,EACN,qBAAqB,EACrB,2BAA2B,EACR,KAAK,EACxB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,OAAgB,WAAW;CAiBhC;AAGD,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAG/C,YACS,MAA4B,EAC5B,IAAa,EACb,KAAY,EACZ,mBAAqC;QAE7C,KAAK,EAAE,CAAC;QALA,WAAM,GAAN,MAAM,CAAsB;QAC5B,SAAI,GAAJ,IAAI,CAAS;QACb,UAAK,GAAL,KAAK,CAAO;QACZ,wBAAmB,GAAnB,mBAAmB,CAAkB;IAG9C,CAAC;IACD,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,IA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BAAmB,EAAE,MAAM,EAAE;YACtC,OAAO;SACP;QAED,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC7C,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAGH,MAAM,kBAAkB,GAAgC,EAAE,CAAC;QAC3D,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC7C,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,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;oBACtD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACzB,CAAC,CAAC,CAAC;gBACH,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, htmlParser } from '@ibyar/elements';\nimport {\n\tcreateProxyForContext, ExpressionNode,\n\tfindReactiveScopeByEventMap, ScopeContext,\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\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, parentNode: Node): EmbeddedViewRef<C> {\n\t\tconst directiveStack = this.stack.copyStack();\n\n\t\tconst templateScope = directiveStack.pushBlockReactiveScope();\n\n\t\tconst sandBox = new Stack();\n\t\tconst contextScope = sandBox.pushBlockReactiveScopeFor(context ?? {});\n\t\tsandBox.pushScope(templateScope);\n\n\t\tconst elements: Node[] = [];\n\t\tconst contextProxy = createProxyForContext(contextScope);\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tconst embeddedViewRef = new EmbeddedViewRefImpl(contextProxy, 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\treturn embeddedViewRef;\n\t}\n\tprivate executeTemplateExpressions(sandBox: Stack): ScopeSubscription<ScopeContext>[] | 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(tuple[0], () => {\n\t\t\t\t\texpression.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"]}
@@ -14,8 +14,8 @@ export declare abstract class ViewContainerRef {
14
14
  abstract clear(): void;
15
15
  abstract get(index: number): ViewRef | undefined;
16
16
  abstract get length(): number;
17
- abstract createEmbeddedView<C extends object>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;
18
- abstract createComponent<C extends object>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;
17
+ abstract createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;
18
+ abstract createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;
19
19
  abstract insert(viewRef: ViewRef, index?: number): ViewRef;
20
20
  abstract move(viewRef: ViewRef, newIndex: number): ViewRef;
21
21
  abstract indexOf(viewRef: ViewRef): number;
@@ -36,6 +36,6 @@ export declare class ViewContainerRefImpl extends ViewContainerRef {
36
36
  remove(index?: number): void;
37
37
  insert(viewRef: EmbeddedViewRef<any>, index?: number): ViewRef;
38
38
  move(viewRef: EmbeddedViewRef<any>, newIndex: number): ViewRef;
39
- createEmbeddedView<C extends object>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;
40
- createComponent<C extends object>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;
39
+ createEmbeddedView<C extends {}>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;
40
+ createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;
41
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"view-container-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-container-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAmB,mBAAmB,EAAW,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAWnD,MAAM,OAAgB,gBAAgB;CAqGrC;AAGD,MAAM,OAAO,oBAAqB,SAAQ,gBAAgB;IAIzD,YACS,MAAe,EACf,YAAqB;QAE7B,KAAK,EAAE,CAAC;QAHA,WAAM,GAAN,MAAM,CAAS;QACf,iBAAY,GAAZ,YAAY,CAAS;QAJtB,UAAK,GAA2B,EAAE,CAAC;IAO3C,CAAC;IACD,IAAa,aAAa;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,IAAa,MAAM;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IACQ,KAAK;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;gBAC7B,GAAG,CAAC,OAAO,EAAE,CAAC;aACd;YACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACrB;IACF,CAAC;IACQ,GAAG,CAAC,KAAa;QACzB,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC/B,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IACQ,MAAM,CAAC,KAAc;QAC7B,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,KAA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AAC,EAAE;YAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACtB;aAAM;YAEN,OAAO,CAAC,MAAM,EAAE,CAAC;SACjB;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IACQ,kBAAkB,CAAmB,WAAwB,EAAE,OAAiC;QACxG,MAAM,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAI,OAAO,EAAE,OAAO,IAAO,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1F,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC;IAChB,CAAC;IACQ,eAAe,CAAmB,aAAwB,EAAE,OAAuC;QAC3G,MAAM,cAAc,GAAG,UAAU,CAAC,eAAe,CAAI,aAAa,CAAC,CAAC,QAAQ,CAAC;QAC7E,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,QAAQ,IAAI,cAAc,CAAC,CAAC;QACvF,IAAI,CAAC,SAAS,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;SAC7E;QACD,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAI,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC,WAAW,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { Components } from '../component/component.js';\nimport { TemplateRef } from './template-ref.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl, ViewRef } from './view-ref.js';\nimport { getComponentView } from '../view/view.js';\n\nexport type ViewContainerOptions<C> = {\n\tindex?: number;\n\tcontext?: C;\n};\n\nexport type ViewContainerComponentOptions = {\n\tindex?: number | undefined;\n\tselector?: string;\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 object>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C>;\n\n\t/**\n * Instantiates a single component and inserts its host view into this container.\n *\n * @param componentType Component Type to use.\n * @param options An object that contains extra parameters:\n * * index: the index at which to insert the new component's host view into this container.\n * If not specified, appends the new view as the last entry.\n * * 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 *\n * @returns The new `HTMLComponent` which contains the component instance and the host view.\n */\n\tabstract createComponent<C extends object>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;\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\n\nexport class ViewContainerRefImpl extends ViewContainerRef {\n\n\tprivate views: EmbeddedViewRef<any>[] = [];\n\n\tconstructor(\n\t\tprivate parent: Element,\n\t\tprivate firstComment: Comment\n\t) {\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 object>(templateRef: TemplateRef, options?: ViewContainerOptions<C>): EmbeddedViewRef<C> {\n\t\tconst viewRef = templateRef.createEmbeddedView<C>(options?.context || <C>{}, this.parent);\n\t\tthis.insert(viewRef, options?.index);\n\t\treturn viewRef;\n\t}\n\toverride createComponent<C extends object>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C {\n\t\tconst defaultTagName = Components.getComponentRef<C>(componentType).selector;\n\t\tconst ViewClass = getComponentView(componentType, options?.selector ?? defaultTagName);\n\t\tif (!ViewClass) {\n\t\t\tthrow new Error(`Can't find View component for class ${componentType.name}`);\n\t\t}\n\t\tconst component = new ViewClass();\n\t\tconst viewRef = new EmbeddedViewRefImpl<C>(component._proxyModel, [component]);\n\t\tthis.insert(viewRef, options?.index);\n\t\treturn component._proxyModel;\n\t}\n\n}\n"]}
1
+ {"version":3,"file":"view-container-ref.js","sourceRoot":"","sources":["../../../src/core/linker/view-container-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jB;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IACQ,kBAAkB,CAAe,WAAwB,EAAE,OAAiC;QACpG,MAAM,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAI,OAAO,EAAE,OAAO,IAAO,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1F,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC;IAChB,CAAC;IACQ,eAAe,CAAe,aAAwB,EAAE,OAAuC;QACvG,MAAM,cAAc,GAAG,UAAU,CAAC,eAAe,CAAI,aAAa,CAAC,CAAC,QAAQ,CAAC;QAC7E,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,QAAQ,IAAI,cAAc,CAAC,CAAC;QACvF,IAAI,CAAC,SAAS,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;SAC7E;QACD,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAI,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QAC/E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC,WAAW,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { Components } from '../component/component.js';\nimport { TemplateRef } from './template-ref.js';\nimport { EmbeddedViewRef, EmbeddedViewRefImpl, ViewRef } from './view-ref.js';\nimport { getComponentView } from '../view/view.js';\n\nexport type ViewContainerOptions<C> = {\n\tindex?: number;\n\tcontext?: C;\n};\n\nexport type ViewContainerComponentOptions = {\n\tindex?: number | undefined;\n\tselector?: string;\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 * Instantiates a single component and inserts its host view into this container.\n *\n * @param componentType Component Type to use.\n * @param options An object that contains extra parameters:\n * * index: the index at which to insert the new component's host view into this container.\n * If not specified, appends the new view as the last entry.\n * * 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 *\n * @returns The new `HTMLComponent` which contains the component instance and the host view.\n */\n\tabstract createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C;\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\n\nexport class ViewContainerRefImpl extends ViewContainerRef {\n\n\tprivate views: EmbeddedViewRef<any>[] = [];\n\n\tconstructor(\n\t\tprivate parent: Element,\n\t\tprivate firstComment: Comment\n\t) {\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\tthis.insert(viewRef, options?.index);\n\t\treturn viewRef;\n\t}\n\toverride createComponent<C extends {}>(componentType: TypeOf<C>, options?: ViewContainerComponentOptions): C {\n\t\tconst defaultTagName = Components.getComponentRef<C>(componentType).selector;\n\t\tconst ViewClass = getComponentView(componentType, options?.selector ?? defaultTagName);\n\t\tif (!ViewClass) {\n\t\t\tthrow new Error(`Can't find View component for class ${componentType.name}`);\n\t\t}\n\t\tconst component = new ViewClass();\n\t\tconst viewRef = new EmbeddedViewRefImpl<C>(component._proxyModel, [component]);\n\t\tthis.insert(viewRef, options?.index);\n\t\treturn component._proxyModel;\n\t}\n\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibyar/core",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "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",
@@ -23,13 +23,13 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@ibyar/elements": "^0.5.1",
27
- "@ibyar/expressions": "^0.5.1",
26
+ "@ibyar/elements": "^0.5.2",
27
+ "@ibyar/expressions": "^0.5.2",
28
28
  "reflect-metadata": "^0.1.13",
29
29
  "tslib": "^2.3.1"
30
30
  },
31
31
  "devDependencies": {
32
- "typescript": "^4.5.2"
32
+ "typescript": "^4.5.4"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "tsc --build --verbose"
@@ -62,5 +62,5 @@
62
62
  "interceptor",
63
63
  "typescript"
64
64
  ],
65
- "gitHead": "5e5951cccc30d333c2629a95d0c8a0627129d43c"
65
+ "gitHead": "9edc86bbc2e99670dda5f9310da83377e68e3535"
66
66
  }
@@ -14,7 +14,7 @@ export declare class ClassRegistry {
14
14
  hasComponent<T>(selector: string): boolean;
15
15
  getComponentRef<T>(selector: string): ComponentRef<T> | undefined;
16
16
  getComponent<T>(selector: string): Function | undefined;
17
- getComponentView(selector: string): (import("../utils/typeof.js").TypeOf<import("../index.js").HTMLComponent<unknown>> & CustomElementConstructor) | undefined;
17
+ getComponentView(selector: string): (import("../index.js").TypeOf<import("../index.js").HTMLComponent<unknown>> & CustomElementConstructor) | undefined;
18
18
  hasOutput<T>(model: Object, eventName: string): PropertyRef | false;
19
19
  hasInput<T>(model: Object, eventName: string): PropertyRef | false;
20
20
  hasDirective<T>(selector: string): boolean;
package/view/base-view.js CHANGED
@@ -3,14 +3,6 @@ import { isAfterContentChecked, isAfterContentInit, isAfterViewChecked, isAfterV
3
3
  import { ComponentRender } from './render.js';
4
4
  import { ElementModelReactiveScope } from '../component/provider.js';
5
5
  const FACTORY_CACHE = new WeakMap();
6
- function defineInstancePropertyMap(instance, names) {
7
- if (typeof instance !== 'object') {
8
- return;
9
- }
10
- names
11
- .filter(key => !Reflect.has(instance, key))
12
- .forEach(key => Reflect.set(instance, key, undefined));
13
- }
14
6
  export function baseFactoryView(htmlElementType) {
15
7
  if (FACTORY_CACHE.has(htmlElementType)) {
16
8
  return FACTORY_CACHE.get(htmlElementType);
@@ -32,11 +24,6 @@ export function baseFactoryView(htmlElementType) {
32
24
  });
33
25
  }
34
26
  const model = new modelClass();
35
- const modelNames = componentRef.inputs.map(input => input.modelProperty)
36
- .concat(componentRef.outputs.map(output => output.modelProperty))
37
- .concat(componentRef.hostBindings.map(host => host.hostPropertyName))
38
- .concat(componentRef.viewChild.map(child => child.modelName));
39
- defineInstancePropertyMap(model, modelNames);
40
27
  this._model = model;
41
28
  const modelScope = ElementModelReactiveScope.blockScopeFor(model);
42
29
  this._proxyModel = modelScope.getContextProxy();
@@ -1 +1 @@
1
- {"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmC,MAAM,oBAAoB,CAAC;AACpF,OAAO,EACN,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAC7D,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAC9D,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,aAAa,GAAG,IAAI,OAAO,EAAmD,CAAC;AAErF,SAAS,yBAAyB,CAAmC,QAAW,EAAE,KAAe;IAChG,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QACjC,OAAO;KACP;IACD,KAAK;SACH,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;SAC1C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,MA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E;gBAC7B,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAY,EAAE,EAAE;oBACjD,QAAqB,CAAC,KAAK,CAAC,CAAC;gBAC/B,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,OAAO;aACP;YACD,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACzD,IAAI,WAAW,EAAE;gBAEhB,WAAW,CAAC,SAAS,CAAC,CAAC,IAAS,EAAE,EAAE;oBAClC,QAAqB,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;aACH;iBACI;gBACJ,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,QAAsB,CAAC,CAAC;aAC9D;QACF,CAAC;QAED,aAAa,CAAC,SAAiB,EAAE,KAAW;YAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACxD,IAAI,UAAU,EAAE;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO;aACP;QACF,CAAC;KACD;IAAA,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope, ScopeContext, ScopeSubscription } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef, PropertyRef } from '../component/component.js';\nimport { BaseComponent, CustomElement, HTMLComponent, ModelType } from '../component/custom-element.js';\nimport { EventEmitter } from '../component/events.js';\nimport { ComponentRender } from './render.js';\nimport { ElementModelReactiveScope } from '../component/provider.js';\n\nconst FACTORY_CACHE = new WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>>();\n\nfunction defineInstancePropertyMap<T extends { [key: string]: any }>(instance: T, names: string[]) {\n\tif (typeof instance !== 'object') {\n\t\treturn;\n\t}\n\tnames\n\t\t.filter(key => !Reflect.has(instance, key))\n\t\t.forEach(key => Reflect.set(instance, key, undefined));\n}\n\nexport function baseFactoryView<T extends object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\n\tif (FACTORY_CACHE.has(htmlElementType)) {\n\t\treturn FACTORY_CACHE.get(htmlElementType) as TypeOf<HTMLComponent<T>>;\n\t}\n\tclass CustomView extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: ModelType<T>;\n\t\t_proxyModel: T;\n\t\t_parentComponent: HTMLComponent<object>;\n\t\t_render: ComponentRender<T>;\n\t\t_shadowRoot: ShadowRoot;\n\n\t\t_componentRef: ComponentRef<T>;\n\n\t\t_modelScope: ReactiveScope<T>;\n\t\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\n\t\tprivate subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper();\n\t\t\tthis._componentRef = componentRef;\n\t\t\tif (componentRef.isShadowDom) {\n\t\t\t\tthis._shadowRoot = this.attachShadow({\n\t\t\t\t\tmode: componentRef.shadowDomMode,\n\t\t\t\t\tdelegatesFocus: componentRef.shadowDomDelegatesFocus\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst model = new modelClass(/* resolve dependency injection*/);\n\t\t\tconst modelNames = componentRef.inputs.map(input => input.modelProperty)\n\t\t\t\t.concat(componentRef.outputs.map(output => output.modelProperty))\n\t\t\t\t.concat(componentRef.hostBindings.map(host => host.hostPropertyName))\n\t\t\t\t.concat(componentRef.viewChild.map(child => child.modelName));\n\t\t\tdefineInstancePropertyMap(model, modelNames);\n\t\t\tthis._model = model;\n\n\t\t\tconst modelScope = ElementModelReactiveScope.blockScopeFor(model);\n\t\t\tthis._proxyModel = modelScope.getContextProxy();\n\t\t\tthis._modelScope = modelScope;\n\n\t\t\tthis._viewScope = ReactiveScope.blockScopeFor<{ 'this': BaseComponent<T> }>({ 'this': this });\n\t\t\tconst elementScope = this._viewScope.getScopeOrCreat('this');\n\t\t\tcomponentRef.inputs.forEach(input => {\n\t\t\t\telementScope.subscribe(input.viewAttribute as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis._modelScope.set(input.modelProperty as any, newValue);\n\t\t\t\t});\n\t\t\t\tthis._modelScope.subscribe(input.modelProperty as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telementScope.emit(input.viewAttribute as any, newValue, oldValue);\n\t\t\t\t});\n\t\t\t});\n\n\n\t\t\t// if property of the model has view decorator\n\t\t\tif (this._componentRef.view) {\n\t\t\t\tReflect.set(this._model, this._componentRef.view, this);\n\t\t\t}\n\t\t\tthis._render = new ComponentRender(this, this.subscriptions);\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t}\n\t\t};\n\n\t\tgetComponentRef(): ComponentRef<T> {\n\t\t\treturn this._componentRef;\n\t\t}\n\n\t\tsetParentComponent(parent: HTMLComponent<any>): void {\n\t\t\tthis._parentComponent = parent;\n\t\t}\n\n\t\tgetParentComponent(): HTMLComponent<any> {\n\t\t\treturn this._parentComponent;\n\t\t}\n\n\t\thasParentComponent(): boolean {\n\t\t\treturn this._parentComponent ? true : false;\n\t\t}\n\n\t\thasInputStartWith(viewProp: string): boolean {\n\t\t\tlet dotIndex = viewProp.indexOf('.');\n\t\t\tif (dotIndex > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, dotIndex);\n\t\t\t}\n\t\t\treturn this.hasInput(viewProp);\n\t\t}\n\n\t\tgetInputStartWith(viewProp: string): PropertyRef | undefined {\n\t\t\tlet index = viewProp.indexOf('.');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\tindex = viewProp.indexOf('[');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\treturn this.getInput(viewProp);\n\t\t}\n\n\t\thasInput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.inputs.some(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.inputs.find(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInputValue(viewProp: string): any {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\treturn this._model[inputRef.modelProperty];\n\t\t\t}\n\t\t}\n\n\t\tsetInputValue(viewProp: PropertyKey, value: any): void {\n\t\t\tconst inputRef = this.getInput(viewProp as string);\n\t\t\tif (inputRef) {\n\t\t\t\t// console.log('about to change input', inputRef.modelProperty, value);\n\t\t\t\t// Reflect.set(this._model, inputRef.modelProperty, value);\n\t\t\t\t// this._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t\tthis._modelScope.set(inputRef.modelProperty as never, value);\n\t\t\t}\n\t\t}\n\n\t\thasOutput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.outputs.some(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetOutput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.outputs.find(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined {\n\t\t\tconst outputRef = this.getOutput(viewProp);\n\t\t\tif (outputRef) {\n\t\t\t\treturn this._model[outputRef.modelProperty] as EventEmitter<V>;\n\t\t\t}\n\t\t}\n\n\t\thasProp(propName: string): boolean {\n\t\t\treturn Reflect.has(this._model, propName);\n\t\t}\n\n\t\tprivate setAttributeHelper(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t}\n\t\t\telse if (typeof value === 'boolean') {\n\t\t\t\tif (value) {\n\t\t\t\t\tsuper.setAttribute(attrViewName, '');\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.setAttribute(attrViewName, value);\n\t\t\t}\n\t\t}\n\n\t\tsetAttribute(attrViewName: string, value: any): void {\n\t\t\tthis.setInputValue(attrViewName, value);\n\t\t\tthis.setAttributeHelper(attrViewName, value);\n\t\t}\n\n\t\tgetAttribute(attrViewName: string): string | null {\n\t\t\treturn this.getInputValue(attrViewName) ?? super.getAttribute(attrViewName);\n\t\t}\n\n\t\tattributeChangedCallback(name: string, oldValue: string, newValue: string) {\n\t\t\tif (newValue === oldValue) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// this._changeObservable.emit(name);\n\t\t\tconst inputRef = this.getInput(name);\n\t\t\tif (inputRef) {\n\t\t\t\t// this._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\t\t\tif (this.subscriptions.length) {\n\t\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\t}\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tthis._componentRef.inputs.forEach(input => {\n\t\t\t\tconst inputDefaultValue = this._model[input.modelProperty];\n\t\t\t\tif (inputDefaultValue !== null && inputDefaultValue !== undefined) {\n\t\t\t\t\tthis.setAttributeHelper(input.viewAttribute, inputDefaultValue);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// if (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t// \tlet oldAttrValues = Array.prototype.slice.call(this.attributes);\n\t\t\t//\toldAttrValues.forEach((attr: Attr) => {\n\t\t\t// \t\tReflect.set(this, attr.name, attr.value);\n\t\t\t// \t});\n\t\t\t// }\n\n\t\t\tif (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t\tlet attrs: Attr[] = Array.prototype.slice.call(this.attributes);\n\t\t\t\tattrs.forEach(attr => this.initOuterAttribute(attr));\n\t\t\t}\n\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._model.onInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._model.afterContentInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t}\n\n\t\t\t// if (!this.hasParentComponent()) {\n\t\t\t// \tArray.prototype.slice.call(this.attributes).forEach((attr: Attr) => {\n\t\t\t// \t\tthis.initOuterAttribute(attr);\n\t\t\t// \t});\n\t\t\t// }\n\n\t\t\t// do once\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\t// setup ui view\n\t\t\t\tthis._render.initView();\n\n\t\t\t\t// init Host Listener events\n\t\t\t\tthis._render.initHostListener();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._model.afterViewInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\t// this.emitRootChanges();\n\t\t\t};\n\t\t\t// this.emitRootChanges();\n\t\t}\n\n\t\t// emitRootChanges(): void {\n\t\t// \tthis.emitChanges(...Object.keys(this._model.__observable).filter(event => event !== 'destroy'));\n\t\t// }\n\n\t\t// emitChanges(...events: string[]): void {\n\t\t// \tconst sources: any[] = [];\n\t\t// \tevents.forEach(key => {\n\t\t// \t\tthis._model.emitChangeModel(key, sources);\n\t\t// \t});\n\t\t// }\n\n\t\tinitOuterAttribute(attr: Attr) {\n\t\t\t// [window, this] scop\n\t\t\tlet elementAttr = attr.name;\n\t\t\tlet modelProperty = attr.value;\n\t\t\tif (elementAttr.startsWith('[')) {\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\tif (Reflect.has(window, modelProperty)) {\n\t\t\t\t\tthis.setInputValue(elementAttr, Reflect.get(window, modelProperty));\n\t\t\t\t}\n\t\t\t\t// else {\n\t\t\t\t// \tlet value: any;\n\t\t\t\t// \tObject.defineProperty(window, modelProperty, {\n\t\t\t\t// \t\tset: (v: any) => {\n\t\t\t\t// \t\t\tvalue = v;\n\t\t\t\t// \t\t\tif (this) {\n\t\t\t\t// \t\t\t\tthis.setInputValue(elementAttr, v);\n\t\t\t\t// \t\t\t\t// fake connect element\n\t\t\t\t// \t\t\t\tthis.connectedCallback();\n\t\t\t\t// \t\t\t}\n\t\t\t\t// \t\t},\n\t\t\t\t// \t\tget: (): any => value\n\t\t\t\t// \t});\n\t\t\t\t// }\n\n\t\t\t}\n\t\t\telse if (elementAttr.startsWith('(')) {\n\t\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\t// this.handleEvent(element, elementAttr, viewProperty);\n\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\tlet callback: Function = Reflect.get(window, modelProperty);\n\t\t\t\tthis.addEventListener(elementAttr, event => {\n\t\t\t\t\tcallback(event);\n\t\t\t\t});\n\t\t\t} else if (elementAttr.startsWith('on')) {\n\t\t\t\tconst modelEvent = this.getEventEmitter<any>(elementAttr.substring(2));\n\t\t\t\tif (modelEvent) {\n\t\t\t\t\t// modelEvent.subscribe(listener);\n\t\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\t\tlet listener: Function = Reflect.get(window, modelProperty);\n\t\t\t\t\tmodelEvent.subscribe((data: any) => {\n\t\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.setInputValue(attr.name, attr.value);\n\t\t\t}\n\t\t}\n\n\t\tadoptedCallback() {\n\t\t\t// restart the process\n\t\t\tthis.innerHTML = '';\n\t\t\tthis.connectedCallback();\n\t\t}\n\t\tdisconnectedCallback() {\n\t\t\t// notify first, then call model.onDestroy func\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._model.onDestroy.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t}\n\n\t\t// events api\n\t\taddEventListener(eventName: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void {\n\t\t\tif ('on' + eventName in this) {\n\t\t\t\tsuper.addEventListener(eventName, (event: Event) => {\n\t\t\t\t\t(listener as Function)(event);\n\t\t\t\t}, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst modelOutput = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelOutput) {\n\t\t\t\t// modelOutput.subscribe(listener);\n\t\t\t\tmodelOutput.subscribe((data: any) => {\n\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._model.subscribeModel(eventName, listener as () => void);\n\t\t\t}\n\t\t}\n\n\t\ttriggerOutput(eventName: string, value?: any): void {\n\t\t\tconst modelEvent = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelEvent) {\n\t\t\t\tmodelEvent.emit(value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\tFACTORY_CACHE.set(htmlElementType, CustomView);\n\treturn CustomView;\n}\n\n// const CustomViewTypes: WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>> = new WeakMap();\n// function createViewClass(elementType: TypeOf<HTMLElement>, isForm: boolean) {\n// if (isForm) {\n// let ViewClass = baseFormFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// else {\n// let ViewClass = baseFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// }\n\n// export function getBaseViewClassByHTMLElementType(elementType?: TypeOf<HTMLElement>, isFormAssociated?: boolean) {\n// if (elementType && CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// }\n// // start to created view class\n// else if (!elementType || elementType === HTMLElement) {\n// return createViewClass(HTMLElement, isFormAssociated || false);\n// }\n// if (CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// } else {\n\n// }\n// }\n"]}
1
+ {"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmC,MAAM,oBAAoB,CAAC;AACpF,OAAO,EACN,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAC7D,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ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AAE;oBAClC,QAAqB,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;aACH;iBACI;gBACJ,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,QAAsB,CAAC,CAAC;aAC9D;QACF,CAAC;QAED,aAAa,CAAC,SAAiB,EAAE,KAAW;YAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACxD,IAAI,UAAU,EAAE;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO;aACP;QACF,CAAC;KACD;IAAA,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope, ScopeContext, ScopeSubscription } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef, PropertyRef } from '../component/component.js';\nimport { BaseComponent, CustomElement, HTMLComponent, ModelType } from '../component/custom-element.js';\nimport { EventEmitter } from '../component/events.js';\nimport { ComponentRender } from './render.js';\nimport { ElementModelReactiveScope } from '../component/provider.js';\n\nconst FACTORY_CACHE = new WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>>();\n\nexport function baseFactoryView<T extends object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\n\tif (FACTORY_CACHE.has(htmlElementType)) {\n\t\treturn FACTORY_CACHE.get(htmlElementType) as TypeOf<HTMLComponent<T>>;\n\t}\n\tclass CustomView extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: ModelType<T>;\n\t\t_proxyModel: T;\n\t\t_parentComponent: HTMLComponent<object>;\n\t\t_render: ComponentRender<T>;\n\t\t_shadowRoot: ShadowRoot;\n\n\t\t_componentRef: ComponentRef<T>;\n\n\t\t_modelScope: ReactiveScope<T>;\n\t\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\n\t\tprivate subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper();\n\t\t\tthis._componentRef = componentRef;\n\t\t\tif (componentRef.isShadowDom) {\n\t\t\t\tthis._shadowRoot = this.attachShadow({\n\t\t\t\t\tmode: componentRef.shadowDomMode,\n\t\t\t\t\tdelegatesFocus: componentRef.shadowDomDelegatesFocus\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst model = new modelClass(/* resolve dependency injection*/);\n\t\t\tthis._model = model;\n\n\t\t\tconst modelScope = ElementModelReactiveScope.blockScopeFor(model);\n\t\t\tthis._proxyModel = modelScope.getContextProxy();\n\t\t\tthis._modelScope = modelScope;\n\n\t\t\tthis._viewScope = ReactiveScope.blockScopeFor<{ 'this': BaseComponent<T> }>({ 'this': this });\n\t\t\tconst elementScope = this._viewScope.getScopeOrCreat('this');\n\t\t\tcomponentRef.inputs.forEach(input => {\n\t\t\t\telementScope.subscribe(input.viewAttribute as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis._modelScope.set(input.modelProperty as any, newValue);\n\t\t\t\t});\n\t\t\t\tthis._modelScope.subscribe(input.modelProperty as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telementScope.emit(input.viewAttribute as any, newValue, oldValue);\n\t\t\t\t});\n\t\t\t});\n\n\n\t\t\t// if property of the model has view decorator\n\t\t\tif (this._componentRef.view) {\n\t\t\t\tReflect.set(this._model, this._componentRef.view, this);\n\t\t\t}\n\t\t\tthis._render = new ComponentRender(this, this.subscriptions);\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t}\n\t\t};\n\n\t\tgetComponentRef(): ComponentRef<T> {\n\t\t\treturn this._componentRef;\n\t\t}\n\n\t\tsetParentComponent(parent: HTMLComponent<any>): void {\n\t\t\tthis._parentComponent = parent;\n\t\t}\n\n\t\tgetParentComponent(): HTMLComponent<any> {\n\t\t\treturn this._parentComponent;\n\t\t}\n\n\t\thasParentComponent(): boolean {\n\t\t\treturn this._parentComponent ? true : false;\n\t\t}\n\n\t\thasInputStartWith(viewProp: string): boolean {\n\t\t\tlet dotIndex = viewProp.indexOf('.');\n\t\t\tif (dotIndex > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, dotIndex);\n\t\t\t}\n\t\t\treturn this.hasInput(viewProp);\n\t\t}\n\n\t\tgetInputStartWith(viewProp: string): PropertyRef | undefined {\n\t\t\tlet index = viewProp.indexOf('.');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\tindex = viewProp.indexOf('[');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\treturn this.getInput(viewProp);\n\t\t}\n\n\t\thasInput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.inputs.some(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.inputs.find(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInputValue(viewProp: string): any {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\treturn this._model[inputRef.modelProperty];\n\t\t\t}\n\t\t}\n\n\t\tsetInputValue(viewProp: PropertyKey, value: any): void {\n\t\t\tconst inputRef = this.getInput(viewProp as string);\n\t\t\tif (inputRef) {\n\t\t\t\t// console.log('about to change input', inputRef.modelProperty, value);\n\t\t\t\t// Reflect.set(this._model, inputRef.modelProperty, value);\n\t\t\t\t// this._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t\tthis._modelScope.set(inputRef.modelProperty as never, value);\n\t\t\t}\n\t\t}\n\n\t\thasOutput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.outputs.some(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetOutput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.outputs.find(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined {\n\t\t\tconst outputRef = this.getOutput(viewProp);\n\t\t\tif (outputRef) {\n\t\t\t\treturn this._model[outputRef.modelProperty] as EventEmitter<V>;\n\t\t\t}\n\t\t}\n\n\t\thasProp(propName: string): boolean {\n\t\t\treturn Reflect.has(this._model, propName);\n\t\t}\n\n\t\tprivate setAttributeHelper(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t}\n\t\t\telse if (typeof value === 'boolean') {\n\t\t\t\tif (value) {\n\t\t\t\t\tsuper.setAttribute(attrViewName, '');\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.setAttribute(attrViewName, value);\n\t\t\t}\n\t\t}\n\n\t\tsetAttribute(attrViewName: string, value: any): void {\n\t\t\tthis.setInputValue(attrViewName, value);\n\t\t\tthis.setAttributeHelper(attrViewName, value);\n\t\t}\n\n\t\tgetAttribute(attrViewName: string): string | null {\n\t\t\treturn this.getInputValue(attrViewName) ?? super.getAttribute(attrViewName);\n\t\t}\n\n\t\tattributeChangedCallback(name: string, oldValue: string, newValue: string) {\n\t\t\tif (newValue === oldValue) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// this._changeObservable.emit(name);\n\t\t\tconst inputRef = this.getInput(name);\n\t\t\tif (inputRef) {\n\t\t\t\t// this._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\t\t\tif (this.subscriptions.length) {\n\t\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\t}\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tthis._componentRef.inputs.forEach(input => {\n\t\t\t\tconst inputDefaultValue = this._model[input.modelProperty];\n\t\t\t\tif (inputDefaultValue !== null && inputDefaultValue !== undefined) {\n\t\t\t\t\tthis.setAttributeHelper(input.viewAttribute, inputDefaultValue);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// if (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t// \tlet oldAttrValues = Array.prototype.slice.call(this.attributes);\n\t\t\t//\toldAttrValues.forEach((attr: Attr) => {\n\t\t\t// \t\tReflect.set(this, attr.name, attr.value);\n\t\t\t// \t});\n\t\t\t// }\n\n\t\t\tif (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t\tlet attrs: Attr[] = Array.prototype.slice.call(this.attributes);\n\t\t\t\tattrs.forEach(attr => this.initOuterAttribute(attr));\n\t\t\t}\n\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._model.onInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._model.afterContentInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t}\n\n\t\t\t// if (!this.hasParentComponent()) {\n\t\t\t// \tArray.prototype.slice.call(this.attributes).forEach((attr: Attr) => {\n\t\t\t// \t\tthis.initOuterAttribute(attr);\n\t\t\t// \t});\n\t\t\t// }\n\n\t\t\t// do once\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\t// setup ui view\n\t\t\t\tthis._render.initView();\n\n\t\t\t\t// init Host Listener events\n\t\t\t\tthis._render.initHostListener();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._model.afterViewInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\t// this.emitRootChanges();\n\t\t\t};\n\t\t\t// this.emitRootChanges();\n\t\t}\n\n\t\t// emitRootChanges(): void {\n\t\t// \tthis.emitChanges(...Object.keys(this._model.__observable).filter(event => event !== 'destroy'));\n\t\t// }\n\n\t\t// emitChanges(...events: string[]): void {\n\t\t// \tconst sources: any[] = [];\n\t\t// \tevents.forEach(key => {\n\t\t// \t\tthis._model.emitChangeModel(key, sources);\n\t\t// \t});\n\t\t// }\n\n\t\tinitOuterAttribute(attr: Attr) {\n\t\t\t// [window, this] scop\n\t\t\tlet elementAttr = attr.name;\n\t\t\tlet modelProperty = attr.value;\n\t\t\tif (elementAttr.startsWith('[')) {\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\tif (Reflect.has(window, modelProperty)) {\n\t\t\t\t\tthis.setInputValue(elementAttr, Reflect.get(window, modelProperty));\n\t\t\t\t}\n\t\t\t\t// else {\n\t\t\t\t// \tlet value: any;\n\t\t\t\t// \tObject.defineProperty(window, modelProperty, {\n\t\t\t\t// \t\tset: (v: any) => {\n\t\t\t\t// \t\t\tvalue = v;\n\t\t\t\t// \t\t\tif (this) {\n\t\t\t\t// \t\t\t\tthis.setInputValue(elementAttr, v);\n\t\t\t\t// \t\t\t\t// fake connect element\n\t\t\t\t// \t\t\t\tthis.connectedCallback();\n\t\t\t\t// \t\t\t}\n\t\t\t\t// \t\t},\n\t\t\t\t// \t\tget: (): any => value\n\t\t\t\t// \t});\n\t\t\t\t// }\n\n\t\t\t}\n\t\t\telse if (elementAttr.startsWith('(')) {\n\t\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\t// this.handleEvent(element, elementAttr, viewProperty);\n\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\tlet callback: Function = Reflect.get(window, modelProperty);\n\t\t\t\tthis.addEventListener(elementAttr, event => {\n\t\t\t\t\tcallback(event);\n\t\t\t\t});\n\t\t\t} else if (elementAttr.startsWith('on')) {\n\t\t\t\tconst modelEvent = this.getEventEmitter<any>(elementAttr.substring(2));\n\t\t\t\tif (modelEvent) {\n\t\t\t\t\t// modelEvent.subscribe(listener);\n\t\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\t\tlet listener: Function = Reflect.get(window, modelProperty);\n\t\t\t\t\tmodelEvent.subscribe((data: any) => {\n\t\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.setInputValue(attr.name, attr.value);\n\t\t\t}\n\t\t}\n\n\t\tadoptedCallback() {\n\t\t\t// restart the process\n\t\t\tthis.innerHTML = '';\n\t\t\tthis.connectedCallback();\n\t\t}\n\t\tdisconnectedCallback() {\n\t\t\t// notify first, then call model.onDestroy func\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._model.onDestroy.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t}\n\n\t\t// events api\n\t\taddEventListener(eventName: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void {\n\t\t\tif ('on' + eventName in this) {\n\t\t\t\tsuper.addEventListener(eventName, (event: Event) => {\n\t\t\t\t\t(listener as Function)(event);\n\t\t\t\t}, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst modelOutput = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelOutput) {\n\t\t\t\t// modelOutput.subscribe(listener);\n\t\t\t\tmodelOutput.subscribe((data: any) => {\n\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._model.subscribeModel(eventName, listener as () => void);\n\t\t\t}\n\t\t}\n\n\t\ttriggerOutput(eventName: string, value?: any): void {\n\t\t\tconst modelEvent = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelEvent) {\n\t\t\t\tmodelEvent.emit(value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\tFACTORY_CACHE.set(htmlElementType, CustomView);\n\treturn CustomView;\n}\n\n// const CustomViewTypes: WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>> = new WeakMap();\n// function createViewClass(elementType: TypeOf<HTMLElement>, isForm: boolean) {\n// if (isForm) {\n// let ViewClass = baseFormFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// else {\n// let ViewClass = baseFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// }\n\n// export function getBaseViewClassByHTMLElementType(elementType?: TypeOf<HTMLElement>, isFormAssociated?: boolean) {\n// if (elementType && CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// }\n// // start to created view class\n// else if (!elementType || elementType === HTMLElement) {\n// return createViewClass(HTMLElement, isFormAssociated || false);\n// }\n// if (CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// } else {\n\n// }\n// }\n"]}
package/view/render.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ScopeContext, ScopeSubscription, Stack } from '@ibyar/expressions';
2
2
  import { CommentNode, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, DomNode, LiveTextContent, TextContent, DomAttributeDirectiveNode } from '@ibyar/elements';
3
3
  import { ListenerRef } from '../component/component.js';
4
4
  import { HTMLComponent } from '../component/custom-element.js';
5
- import { AttributeDirective, StructuralDirective } from '../directive/directive.js';
5
+ import { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';
6
6
  export declare class ComponentRender<T extends object> {
7
7
  view: HTMLComponent<T>;
8
8
  private subscriptions;
@@ -18,7 +18,7 @@ export declare class ComponentRender<T extends object> {
18
18
  handelHostListener(listener: ListenerRef): void;
19
19
  addNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function): void;
20
20
  getElementByName(name: string): any;
21
- createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void;
21
+ createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void;
22
22
  createComment(node: CommentNode): Comment;
23
23
  createText(node: TextContent): Text;
24
24
  createLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[]): Text;
@@ -28,7 +28,8 @@ export declare class ComponentRender<T extends object> {
28
28
  tagName: string;
29
29
  is?: string;
30
30
  }): HTMLElement;
31
- createElement(node: DomElementNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective): HTMLElement;
31
+ createElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): HTMLElement;
32
+ private initAttributeDirectives;
32
33
  initAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<ScopeContext>[];
33
- initDirectiveAttributes(directive: StructuralDirective | AttributeDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<ScopeContext>[];
34
+ initStructuralDirective(directive: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<ScopeContext>[];
34
35
  }
package/view/render.js CHANGED
@@ -2,11 +2,12 @@ import { CommentNode, DomStructuralDirectiveNode, DomElementNode, DomFragmentNod
2
2
  import { isHTMLComponent } from '../component/custom-element.js';
3
3
  import { documentStack } from '../context/stack.js';
4
4
  import { ClassRegistryProvider } from '../providers/provider.js';
5
- import { isOnInit } from '../component/lifecycle.js';
5
+ import { isOnDestroy, isOnInit } from '../component/lifecycle.js';
6
6
  import { hasAttr } from '../utils/elements-util.js';
7
- import { AttributeDirective } from '../directive/directive.js';
7
+ import { AttributeDirective, AttributeOnStructuralDirective } from '../directive/directive.js';
8
8
  import { TemplateRefImpl } from '../linker/template-ref.js';
9
9
  import { ViewContainerRefImpl } from '../linker/view-container-ref.js';
10
+ import { createSubscriptionDestroyer } from '../context/subscription.js';
10
11
  function getInputEventName(element) {
11
12
  switch (true) {
12
13
  case element instanceof HTMLInputElement:
@@ -137,7 +138,7 @@ export class ComponentRender {
137
138
  getElementByName(name) {
138
139
  return Reflect.get(this.view, name);
139
140
  }
140
- createStructuralDirective(directive, comment, directiveStack, parentNode, host) {
141
+ createStructuralDirective(directive, comment, directiveStack, subscriptions, parentNode, host) {
141
142
  const directiveRef = ClassRegistryProvider.getDirectiveRef(directive.name);
142
143
  if (directiveRef) {
143
144
  const stack = directiveStack.copyStack();
@@ -147,10 +148,17 @@ export class ComponentRender {
147
148
  const structural = new StructuralDirectiveClass(templateRef, viewContainerRef, host);
148
149
  templateRef.host = structural;
149
150
  stack.pushBlockReactiveScopeFor({ 'this': structural });
150
- const subscriptions = this.initDirectiveAttributes(structural, directive, stack);
151
+ const dSubs = this.initStructuralDirective(structural, directive, stack);
152
+ subscriptions.push(...dSubs);
151
153
  if (isOnInit(structural)) {
152
154
  structural.onInit();
153
155
  }
156
+ if (directive.attributeDirectives?.length) {
157
+ this.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);
158
+ }
159
+ if (isOnDestroy(structural)) {
160
+ subscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));
161
+ }
154
162
  }
155
163
  else {
156
164
  }
@@ -183,7 +191,7 @@ export class ComponentRender {
183
191
  this.templateNameScope.set(templateRefName.name, templateRef);
184
192
  return;
185
193
  }
186
- fragmentParent.append(this.createElement(child, contextStack, parentNode, subscriptions, host));
194
+ fragmentParent.append(this.createElement(child, contextStack, subscriptions, parentNode, host));
187
195
  }
188
196
  else if (child instanceof DomStructuralDirectiveNode) {
189
197
  const commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');
@@ -191,7 +199,7 @@ export class ComponentRender {
191
199
  fragmentParent.append(comment);
192
200
  const lastComment = document.createComment(`end ${commentText}`);
193
201
  comment.after(lastComment);
194
- this.createStructuralDirective(child, comment, contextStack, parentNode, host);
202
+ this.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);
195
203
  }
196
204
  else if (isLiveTextContent(child)) {
197
205
  fragmentParent.append(this.createLiveText(child, contextStack, parentNode, subscriptions));
@@ -231,26 +239,11 @@ export class ComponentRender {
231
239
  }
232
240
  return element;
233
241
  }
234
- createElement(node, contextStack, parentNode, subscriptions, host) {
242
+ createElement(node, contextStack, subscriptions, parentNode, host) {
235
243
  const element = this.createElementByTagName(node);
236
244
  const elementStack = contextStack.copyStack();
237
245
  const elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.pushBlockReactiveScopeFor({ 'this': element });
238
246
  elementStack.pushScope(elementScope);
239
- if (node.attributeDirectives?.length) {
240
- node.attributeDirectives.forEach(directiveNode => {
241
- const directiveRef = ClassRegistryProvider.getDirectiveRef(directiveNode.name);
242
- if (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {
243
- const directive = new directiveRef.modelClass(element);
244
- const stack = contextStack.copyStack();
245
- stack.pushBlockReactiveScopeFor({ 'this': directive });
246
- const directiveSubscriptions = this.initDirectiveAttributes(directive, directiveNode, stack);
247
- subscriptions.push(...directiveSubscriptions);
248
- if (isOnInit(directive)) {
249
- directive.onInit();
250
- }
251
- }
252
- });
253
- }
254
247
  const attributesSubscriptions = this.initAttribute(element, node, elementStack);
255
248
  subscriptions.push(...attributesSubscriptions);
256
249
  const eventName = getInputEventName(element);
@@ -273,8 +266,31 @@ export class ComponentRender {
273
266
  this.appendChildToParent(element, child, elementStack, element, subscriptions, host);
274
267
  }
275
268
  }
269
+ if (node.attributeDirectives?.length) {
270
+ this.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);
271
+ }
276
272
  return element;
277
273
  }
274
+ initAttributeDirectives(attributeDirectives, element, contextStack, subscriptions) {
275
+ attributeDirectives?.forEach(directiveNode => {
276
+ const directiveRef = ClassRegistryProvider.getDirectiveRef(directiveNode.name);
277
+ if (directiveRef &&
278
+ (directiveRef.modelClass.prototype instanceof AttributeDirective
279
+ || directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective)) {
280
+ const directive = new directiveRef.modelClass(element);
281
+ const stack = contextStack.copyStack();
282
+ stack.pushBlockReactiveScopeFor({ 'this': directive });
283
+ const directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);
284
+ subscriptions.push(...directiveSubscriptions);
285
+ if (isOnInit(directive)) {
286
+ directive.onInit();
287
+ }
288
+ if (isOnDestroy(directive)) {
289
+ subscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));
290
+ }
291
+ }
292
+ });
293
+ }
278
294
  initAttribute(element, node, contextStack) {
279
295
  const subscriptions = [];
280
296
  if (node.attributes?.length) {
@@ -335,7 +351,7 @@ export class ComponentRender {
335
351
  }
336
352
  return subscriptions;
337
353
  }
338
- initDirectiveAttributes(directive, node, contextStack) {
354
+ initStructuralDirective(directive, node, contextStack) {
339
355
  const subscriptions = [];
340
356
  if (node.attributes?.length) {
341
357
  node.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,WAAW,EAAE,0BAA0B,EACvC,cAAc,EAAE,eAAe,EAAW,iBAAiB,EAC3D,eAAe,EAAE,wBAAwB,EACzC,WAAW,EACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAuB,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAe,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,SAAS,iBAAiB,CAAC,OAAoB;IAC9C,QAAQ,IAAI,EAAE;QACb,KAAK,OAAO,YAAY,gBAAgB;YACvC,OAAO,OAAO,CAAC;QAChB,KAAK,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UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC5B,MAAM,QAAQ,GAAG,CAAC,MAAa,EAAE,EAAE;oBAClC,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;oBACvC,KAAK,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;oBACpC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACpD,CAAC,CAAC;gBACK,SAAU,CAAC,KAAK,CAAC,IAAI,CAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YAC/B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACpD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QACD,OAAO,aAAa,CAAC;IACtB,CAAC;CAED","sourcesContent":["import {\n\tReactiveScope, ScopeContext, ScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport {\n\tCommentNode, DomStructuralDirectiveNode, DomStructuralDirectiveNodeUpgrade,\n\tDomElementNode, DomFragmentNode, DomNode, isLiveTextContent,\n\tisTagNameNative, isValidCustomElementName, LiveTextContent,\n\tTextContent, DomAttributeDirectiveNode\n} from '@ibyar/elements';\nimport { ComponentRef, ListenerRef } from '../component/component.js';\nimport { HTMLComponent, isHTMLComponent } from '../component/custom-element.js';\nimport { documentStack } from '../context/stack.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { EventEmitter } from '../component/events.js';\nimport { isOnInit } from '../component/lifecycle.js';\nimport { hasAttr } from '../utils/elements-util.js';\nimport { AttributeDirective, StructuralDirective } from '../directive/directive.js';\nimport { TemplateRef, TemplateRefImpl } from '../linker/template-ref.js';\nimport { ViewContainerRefImpl } from '../linker/view-container-ref.js';\n\nfunction getInputEventName(element: HTMLElement): 'input' | 'change' | undefined {\n\tswitch (true) {\n\t\tcase element instanceof HTMLInputElement:\n\t\t\treturn 'input';\n\t\tcase element instanceof HTMLTextAreaElement:\n\t\tcase element instanceof HTMLSelectElement:\n\t\t\treturn 'change';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\nexport class ComponentRender<T extends object> {\n\tprivate componentRef: ComponentRef<T>;\n\tprivate template: DomNode;\n\tprivate contextStack: Stack;\n\tprivate templateNameScope: ReactiveScope<{ [templateName: string]: TemplateRef }>;\n\n\tconstructor(public view: HTMLComponent<T>, private subscriptions: ScopeSubscription<ScopeContext>[]) {\n\t\tthis.componentRef = this.view.getComponentRef();\n\t\tthis.contextStack = documentStack.copyStack();\n\t\tthis.contextStack.pushScope<ScopeContext>(this.view._modelScope);\n\t\tthis.templateNameScope = this.contextStack.pushBlockReactiveScope();\n\t}\n\tinitView(): void {\n\t\tif (this.componentRef.template) {\n\t\t\tif (typeof this.componentRef.template === 'function') {\n\t\t\t\tthis.template = this.componentRef.template(this.view._model);\n\t\t\t} else {\n\t\t\t\tthis.template = this.componentRef.template;\n\t\t\t}\n\n\t\t\tlet rootRef: HTMLElement | ShadowRoot;\n\t\t\tif (this.componentRef.isShadowDom) {\n\t\t\t\tif (this.view.shadowRoot /* OPEN MODE */) {\n\t\t\t\t\trootRef = this.view.shadowRoot;\n\t\t\t\t} else /* CLOSED MODE*/ {\n\t\t\t\t\trootRef = Reflect.get(this.view, '_shadowRoot') as ShadowRoot;\n\t\t\t\t\tReflect.deleteProperty(this.view, '_shadowRoot');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trootRef = this.view;\n\t\t\t}\n\t\t\tthis.initTemplateRefMap(this.template);\n\t\t\tlet rootFragment: DocumentFragment;\n\t\t\tif (this.template instanceof DomFragmentNode) {\n\t\t\t\trootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t} else {\n\t\t\t\trootFragment = document.createDocumentFragment();\n\t\t\t\tthis.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t}\n\t\t\trootRef.append(rootFragment);\n\t\t}\n\t}\n\tisTemplateRefName(template: DomNode): template is DomElementNode {\n\t\tif (template instanceof DomElementNode) {\n\t\t\tif (template.tagName === 'template' && template.templateRefName) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tinitTemplateRefMap(domNode: DomNode) {\n\t\tif (domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) {\n\t\t\tif (domNode.children) {\n\t\t\t\tfor (let index = 0; index < domNode.children.length; index++) {\n\t\t\t\t\tconst child = domNode.children[index];\n\t\t\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\t\t\tthis.templateNameScope.set(child.templateRefName!.name, undefined);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.initTemplateRefMap(child);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinitHostListener(): void {\n\t\tthis.componentRef.hostListeners?.forEach(\n\t\t\tlistener => this.handelHostListener(listener)\n\t\t);\n\t}\n\thandelHostListener(listener: ListenerRef) {\n\t\tlet eventName: string = listener.eventName, source: HTMLElement | Window;\n\t\tif (listener.eventName.includes(':')) {\n\t\t\tconst eventSource = eventName.substring(0, eventName.indexOf(':'));\n\t\t\teventName = eventName.substring(eventName.indexOf(':') + 1);\n\t\t\tif ('window' === eventSource.toLowerCase()) {\n\t\t\t\tsource = window;\n\t\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t} else if (eventSource in this.view) {\n\t\t\t\tsource = Reflect.get(this.view, eventSource);\n\t\t\t\tif (!Reflect.has(source, '_model')) {\n\t\t\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsource = this.view;\n\t\t\t}\n\t\t} else {\n\t\t\tsource = this.view;\n\t\t}\n\t\tconst sourceModel = Reflect.get(source, '_model') as { [key: string]: EventEmitter<any> };\n\t\tconst output = ClassRegistryProvider.hasOutput(sourceModel, eventName);\n\t\tif (output) {\n\t\t\tsourceModel[output.modelProperty].subscribe((value: any) => {\n\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, value);\n\t\t\t});\n\t\t}\n\t\telse if (Reflect.has(source, 'on' + eventName)) {\n\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t});\n\t\t}\n\t\t// else if (this.componentRef.encapsulation === 'template' && !this.view.hasParentComponent()) {\n\t\t// \tthis.addNativeEventListener(this.view, eventName, eventCallback);\n\t\t// }\n\t\telse {\n\t\t\t// listen to internal changes\n\t\t\t// TODO: need to resolve parameter\n\t\t\t// addChangeListener(sourceModel, eventName, () => (this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel));\n\t\t}\n\t}\n\taddNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function) {\n\t\tsource.addEventListener(eventName, (event: Event) => {\n\t\t\tfuncCallback.call(this.view._proxyModel, event);\n\t\t});\n\t}\n\tgetElementByName(name: string) {\n\t\treturn Reflect.get(this.view, name);\n\t}\n\tcreateStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<T>(directive.name);\n\t\tif (directiveRef) {\n\t\t\tconst stack = directiveStack.copyStack();\n\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\tthis,\n\t\t\t\tdirective.node,\n\t\t\t\tstack,\n\t\t\t\t(directive as DomStructuralDirectiveNodeUpgrade).templateExpressions ?? [],\n\t\t\t);\n\t\t\tconst viewContainerRef = new ViewContainerRefImpl(parentNode as Element, comment);\n\n\t\t\t// structural directive selector\n\t\t\tconst StructuralDirectiveClass = directiveRef.modelClass as typeof StructuralDirective;\n\t\t\tconst structural = new StructuralDirectiveClass(\n\t\t\t\ttemplateRef,\n\t\t\t\tviewContainerRef,\n\t\t\t\thost\n\t\t\t);\n\t\t\ttemplateRef.host = structural;\n\t\t\tstack.pushBlockReactiveScopeFor({ 'this': structural });\n\t\t\tconst subscriptions = this.initDirectiveAttributes(structural, directive, stack);\n\t\t\t// const removeSubscription = this.nativeElementMutation.subscribeOnRemoveNode(parentNode, comment, () => {\n\t\t\t// \tremoveSubscription.unsubscribe();\n\t\t\t// \tsubscriptions.forEach(subscription => subscription.unsubscribe());\n\t\t\t// \tif (isOnDestroy(structural)) {\n\t\t\t// \t\tstructural.onDestroy();\n\t\t\t// \t}\n\t\t\t// });\n\t\t\tif (isOnInit(structural)) {\n\t\t\t\tstructural.onInit();\n\t\t\t}\n\t\t} else {\n\t\t\t// didn't find directive or it is not define yet.\n\t\t\t// class registry should have 'when defined' callback\n\t\t}\n\t}\n\tcreateComment(node: CommentNode): Comment {\n\t\treturn document.createComment(`${node.comment}`);\n\t}\n\tcreateText(node: TextContent): Text {\n\t\treturn new Text(node.value);\n\t}\n\tcreateLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[]): Text {\n\t\tconst liveText = new Text('');\n\t\tcontextStack = contextStack.copyStack();\n\t\tcontextStack.pushBlockScopeFor({ this: liveText });\n\t\tconst textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);\n\t\tsubscriptions.push(...textSubscriptions);\n\t\ttextNode.expression.get(contextStack);\n\t\treturn liveText;\n\t}\n\tcreateDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment {\n\t\tconst fragment = document.createDocumentFragment();\n\t\tnode.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));\n\t\treturn fragment;\n\t}\n\tappendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective) {\n\t\tif (child instanceof DomElementNode) {\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tconst templateRefName = child.templateRefName!;\n\t\t\t\t// const oldRef = this.templateNameScope.get(templateRefName.name);\n\t\t\t\t// if (oldRef) {\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\t// TODO: extract template expression\n\t\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\t\tthis,\n\t\t\t\t\tnew DomFragmentNode(child.children),\n\t\t\t\t\tcontextStack.copyStack(),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tthis.templateNameScope.set(templateRefName.name, templateRef);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfragmentParent.append(this.createElement(child, contextStack, parentNode, subscriptions, host));\n\t\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t\tconst commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');\n\t\t\tconst comment = document.createComment(`start ${commentText}`);\n\t\t\tfragmentParent.append(comment);\n\t\t\tconst lastComment = document.createComment(`end ${commentText}`);\n\t\t\tcomment.after(lastComment);\n\t\t\tthis.createStructuralDirective(child, comment, contextStack, parentNode, host);\n\t\t} else if (isLiveTextContent(child)) {\n\t\t\tfragmentParent.append(this.createLiveText(child, contextStack, parentNode, subscriptions));\n\t\t} else if (child instanceof TextContent) {\n\t\t\tfragmentParent.append(this.createText(child));\n\t\t} else if (child instanceof CommentNode) {\n\t\t\tfragmentParent.append(this.createComment(child));\n\t\t} else if (child instanceof DomFragmentNode) {\n\t\t\tfragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));\n\t\t}\n\t}\n\tcreateElementByTagName(node: { tagName: string, is?: string }): HTMLElement {\n\t\tlet element: HTMLElement;\n\t\tif (isValidCustomElementName(node.tagName)) {\n\t\t\tconst ViewClass = customElements.get(node.tagName) as ((new () => HTMLElement) | undefined);\n\t\t\tif (ViewClass) {\n\t\t\t\telement = new ViewClass();\n\t\t\t} else {\n\t\t\t\telement = document.createElement(node.tagName);\n\t\t\t\tif (element.constructor.name === 'HTMLElement') {\n\t\t\t\t\tcustomElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isTagNameNative(node.tagName)) {\n\t\t\t// native tags // and custom tags can be used her\n\t\t\telement = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);\n\t\t} else {\n\t\t\t// html unknown element\n\t\t\telement = document.createElement(node.tagName);\n\t\t}\n\t\tif (isHTMLComponent(element)) {\n\t\t\telement.setParentComponent(this.view);\n\t\t}\n\t\treturn element;\n\t}\n\tcreateElement(node: DomElementNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective): HTMLElement {\n\t\tconst element = this.createElementByTagName(node);\n\t\tconst elementStack = contextStack.copyStack();\n\t\tconst elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.pushBlockReactiveScopeFor({ 'this': element });\n\t\telementStack.pushScope<ScopeContext>(elementScope);\n\t\tif (node.attributeDirectives?.length) {\n\t\t\tnode.attributeDirectives.forEach(directiveNode => {\n\t\t\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(directiveNode.name);\n\t\t\t\tif (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {\n\t\t\t\t\tconst directive = new directiveRef.modelClass(element) as AttributeDirective;\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockReactiveScopeFor({ 'this': directive });\n\t\t\t\t\tconst directiveSubscriptions = this.initDirectiveAttributes(directive, directiveNode, stack);\n\t\t\t\t\tsubscriptions.push(...directiveSubscriptions);\n\t\t\t\t\tif (isOnInit(directive)) {\n\t\t\t\t\t\tdirective.onInit();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tconst attributesSubscriptions = this.initAttribute(element, node, elementStack);\n\t\tsubscriptions.push(...attributesSubscriptions);\n\t\tconst eventName = getInputEventName(element);\n\t\tlet listener: ((event: HTMLElementEventMap['input' | 'change']) => any) | undefined;\n\t\tif (eventName) {\n\t\t\tconst inputScope = elementScope.getScopeOrCreat('this');\n\t\t\tlistener = (event) => inputScope.emit('value', (element as HTMLInputElement).value);\n\t\t\telement.addEventListener(eventName, listener);\n\t\t}\n\n\t\tconst templateRefName = node.templateRefName;\n\t\tif (templateRefName) {\n\t\t\tReflect.set(this.view, templateRefName.name, element);\n\t\t\tconst view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);\n\t\t\tif (view) {\n\t\t\t\tReflect.set(this.view._model, view.modelName, element);\n\t\t\t}\n\t\t}\n\t\tif (node.children) {\n\t\t\tfor (const child of node.children) {\n\t\t\t\tthis.appendChildToParent(element, child, elementStack, element, subscriptions, host);\n\t\t\t}\n\t\t}\n\t\treturn element;\n\t}\n\tinitAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<ScopeContext>[] {\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => {\n\t\t\t\t/**\n\t\t\t\t * <input id=\"23\" name=\"person-name\" />\n\t\t\t\t */\n\t\t\t\tconst isAttr = hasAttr(element, attr.name);\n\t\t\t\tif (isAttr) {\n\t\t\t\t\tif (attr.value === false) {\n\t\t\t\t\t\telement.removeAttribute(attr.name);\n\t\t\t\t\t} else if (attr.value === true) {\n\t\t\t\t\t\telement.setAttribute(attr.name, '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.setAttribute(attr.name, attr.value as string);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tReflect.set(element, attr.name, attr.value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tlet listener: Function;\n\t\t\t\t/**\n\t\t\t\t * <a (click)=\"onLinkClick($event)\"></a>\n\t\t\t\t * <a @click=\"onLinkClick($event)\"></a>\n\t\t\t\t * <input [(value)]=\"person.name\" />\n\t\t\t\t * <input (value)=\"person.name\" />\n\t\t\t\t * <!-- <input (value)=\"person.name = $event\" /> -->\n\t\t\t\t * \n\t\t\t\t * TODO: diff of event listener and back-way data binding\n\t\t\t\t */\n\t\t\t\tif (typeof event.value === 'string') {\n\t\t\t\t\tlistener = ($event: Event) => {\n\t\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\t\tevent.expression.get(stack, this.view._proxyModel);\n\t\t\t\t\t};\n\t\t\t\t} else /* if (typeof event.sourceHandler === 'function')*/ {\n\t\t\t\t\t// let eventName: keyof HTMLElementEventMap = event.eventName;\n\t\t\t\t\tlistener = event.value;\n\t\t\t\t}\n\t\t\t\telement.addEventListener(event.name as any, listener as any);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\n\tinitDirectiveAttributes(directive: StructuralDirective | AttributeDirective,\n\t\tnode: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<ScopeContext>[] {\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tconst listener = ($event: Event) => {\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\tevent.expression.get(stack, this.view._proxyModel);\n\t\t\t\t};\n\t\t\t\t((<any>directive)[event.name] as any).subscribe(listener);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\n}\n"]}
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,WAAW,EAAE,0BAA0B,EACvC,cAAc,EAAE,eAAe,EAAW,iBAAiB,EAC3D,eAAe,EAAE,wBAAwB,EACzC,WAAW,EACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,8BAA8B,EAAuB,MAAM,2BAA2B,CAAC;AACpH,OAAO,EAAe,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEzE,SAAS,iBAAiB,CAAC,OAAoB;IAC9C,QAAQ,IAAI,EAAE;QACb,KAAK,OAAO,YAAY,gBAAgB;YACvC,OAAO,OAAO,CAAC;QAChB,KAAK,OAAO,YAAY,mBAAmB,CAAC;QAC5C,KAAK,OAAO,YAAY,iBAAiB;YACxC,OAAO,QAAQ,CAAC;QACjB;YACC,OAAO,S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AC3D,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YAC/B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACpD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QAGD,OAAO,aAAa,CAAC;IACtB,CAAC;CAED","sourcesContent":["import {\n\tReactiveScope, ScopeContext, ScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport {\n\tCommentNode, DomStructuralDirectiveNode, DomStructuralDirectiveNodeUpgrade,\n\tDomElementNode, DomFragmentNode, DomNode, isLiveTextContent,\n\tisTagNameNative, isValidCustomElementName, LiveTextContent,\n\tTextContent, DomAttributeDirectiveNode\n} from '@ibyar/elements';\nimport { ComponentRef, ListenerRef } from '../component/component.js';\nimport { HTMLComponent, isHTMLComponent } from '../component/custom-element.js';\nimport { documentStack } from '../context/stack.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { EventEmitter } from '../component/events.js';\nimport { isOnDestroy, isOnInit } from '../component/lifecycle.js';\nimport { hasAttr } from '../utils/elements-util.js';\nimport { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';\nimport { TemplateRef, TemplateRefImpl } from '../linker/template-ref.js';\nimport { ViewContainerRefImpl } from '../linker/view-container-ref.js';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\n\nfunction getInputEventName(element: HTMLElement): 'input' | 'change' | undefined {\n\tswitch (true) {\n\t\tcase element instanceof HTMLInputElement:\n\t\t\treturn 'input';\n\t\tcase element instanceof HTMLTextAreaElement:\n\t\tcase element instanceof HTMLSelectElement:\n\t\t\treturn 'change';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\nexport class ComponentRender<T extends object> {\n\tprivate componentRef: ComponentRef<T>;\n\tprivate template: DomNode;\n\tprivate contextStack: Stack;\n\tprivate templateNameScope: ReactiveScope<{ [templateName: string]: TemplateRef }>;\n\n\tconstructor(public view: HTMLComponent<T>, private subscriptions: ScopeSubscription<ScopeContext>[]) {\n\t\tthis.componentRef = this.view.getComponentRef();\n\t\tthis.contextStack = documentStack.copyStack();\n\t\tthis.contextStack.pushScope<ScopeContext>(this.view._modelScope);\n\t\tthis.templateNameScope = this.contextStack.pushBlockReactiveScope();\n\t}\n\tinitView(): void {\n\t\tif (this.componentRef.template) {\n\t\t\tif (typeof this.componentRef.template === 'function') {\n\t\t\t\tthis.template = this.componentRef.template(this.view._model);\n\t\t\t} else {\n\t\t\t\tthis.template = this.componentRef.template;\n\t\t\t}\n\n\t\t\tlet rootRef: HTMLElement | ShadowRoot;\n\t\t\tif (this.componentRef.isShadowDom) {\n\t\t\t\tif (this.view.shadowRoot /* OPEN MODE */) {\n\t\t\t\t\trootRef = this.view.shadowRoot;\n\t\t\t\t} else /* CLOSED MODE*/ {\n\t\t\t\t\trootRef = Reflect.get(this.view, '_shadowRoot') as ShadowRoot;\n\t\t\t\t\tReflect.deleteProperty(this.view, '_shadowRoot');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trootRef = this.view;\n\t\t\t}\n\t\t\tthis.initTemplateRefMap(this.template);\n\t\t\tlet rootFragment: DocumentFragment;\n\t\t\tif (this.template instanceof DomFragmentNode) {\n\t\t\t\trootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t} else {\n\t\t\t\trootFragment = document.createDocumentFragment();\n\t\t\t\tthis.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t}\n\t\t\trootRef.append(rootFragment);\n\t\t}\n\t}\n\tisTemplateRefName(template: DomNode): template is DomElementNode {\n\t\tif (template instanceof DomElementNode) {\n\t\t\tif (template.tagName === 'template' && template.templateRefName) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tinitTemplateRefMap(domNode: DomNode) {\n\t\tif (domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) {\n\t\t\tif (domNode.children) {\n\t\t\t\tfor (let index = 0; index < domNode.children.length; index++) {\n\t\t\t\t\tconst child = domNode.children[index];\n\t\t\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\t\t\tthis.templateNameScope.set(child.templateRefName!.name, undefined);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.initTemplateRefMap(child);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinitHostListener(): void {\n\t\tthis.componentRef.hostListeners?.forEach(\n\t\t\tlistener => this.handelHostListener(listener)\n\t\t);\n\t}\n\thandelHostListener(listener: ListenerRef) {\n\t\tlet eventName: string = listener.eventName, source: HTMLElement | Window;\n\t\tif (listener.eventName.includes(':')) {\n\t\t\tconst eventSource = eventName.substring(0, eventName.indexOf(':'));\n\t\t\teventName = eventName.substring(eventName.indexOf(':') + 1);\n\t\t\tif ('window' === eventSource.toLowerCase()) {\n\t\t\t\tsource = window;\n\t\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t} else if (eventSource in this.view) {\n\t\t\t\tsource = Reflect.get(this.view, eventSource);\n\t\t\t\tif (!Reflect.has(source, '_model')) {\n\t\t\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsource = this.view;\n\t\t\t}\n\t\t} else {\n\t\t\tsource = this.view;\n\t\t}\n\t\tconst sourceModel = Reflect.get(source, '_model') as { [key: string]: EventEmitter<any> };\n\t\tconst output = ClassRegistryProvider.hasOutput(sourceModel, eventName);\n\t\tif (output) {\n\t\t\tsourceModel[output.modelProperty].subscribe((value: any) => {\n\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, value);\n\t\t\t});\n\t\t}\n\t\telse if (Reflect.has(source, 'on' + eventName)) {\n\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t});\n\t\t}\n\t\t// else if (this.componentRef.encapsulation === 'template' && !this.view.hasParentComponent()) {\n\t\t// \tthis.addNativeEventListener(this.view, eventName, eventCallback);\n\t\t// }\n\t\telse {\n\t\t\t// listen to internal changes\n\t\t\t// TODO: need to resolve parameter\n\t\t\t// addChangeListener(sourceModel, eventName, () => (this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel));\n\t\t}\n\t}\n\taddNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function) {\n\t\tsource.addEventListener(eventName, (event: Event) => {\n\t\t\tfuncCallback.call(this.view._proxyModel, event);\n\t\t});\n\t}\n\tgetElementByName(name: string) {\n\t\treturn Reflect.get(this.view, name);\n\t}\n\tcreateStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<T>(directive.name);\n\t\tif (directiveRef) {\n\t\t\tconst stack = directiveStack.copyStack();\n\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\tthis,\n\t\t\t\tdirective.node,\n\t\t\t\tstack,\n\t\t\t\t(directive as DomStructuralDirectiveNodeUpgrade).templateExpressions ?? [],\n\t\t\t);\n\t\t\tconst viewContainerRef = new ViewContainerRefImpl(parentNode as Element, comment);\n\n\t\t\t// structural directive selector\n\t\t\tconst StructuralDirectiveClass = directiveRef.modelClass as typeof StructuralDirective;\n\t\t\tconst structural = new StructuralDirectiveClass(\n\t\t\t\ttemplateRef,\n\t\t\t\tviewContainerRef,\n\t\t\t\thost\n\t\t\t);\n\t\t\ttemplateRef.host = structural;\n\t\t\tstack.pushBlockReactiveScopeFor({ 'this': structural });\n\t\t\tconst dSubs = this.initStructuralDirective(structural, directive, stack);\n\t\t\tsubscriptions.push(...dSubs);\n\t\t\tif (isOnInit(structural)) {\n\t\t\t\tstructural.onInit();\n\t\t\t}\n\t\t\tif (directive.attributeDirectives?.length) {\n\t\t\t\tthis.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);\n\t\t\t}\n\t\t\tif (isOnDestroy(structural)) {\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));\n\t\t\t}\n\t\t} else {\n\t\t\t// didn't find directive or it is not define yet.\n\t\t\t// class registry should have 'when defined' callback\n\t\t}\n\t}\n\tcreateComment(node: CommentNode): Comment {\n\t\treturn document.createComment(`${node.comment}`);\n\t}\n\tcreateText(node: TextContent): Text {\n\t\treturn new Text(node.value);\n\t}\n\tcreateLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[]): Text {\n\t\tconst liveText = new Text('');\n\t\tcontextStack = contextStack.copyStack();\n\t\tcontextStack.pushBlockScopeFor({ this: liveText });\n\t\tconst textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);\n\t\tsubscriptions.push(...textSubscriptions);\n\t\ttextNode.expression.get(contextStack);\n\t\treturn liveText;\n\t}\n\tcreateDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment {\n\t\tconst fragment = document.createDocumentFragment();\n\t\tnode.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));\n\t\treturn fragment;\n\t}\n\tappendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective) {\n\t\tif (child instanceof DomElementNode) {\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tconst templateRefName = child.templateRefName!;\n\t\t\t\t// const oldRef = this.templateNameScope.get(templateRefName.name);\n\t\t\t\t// if (oldRef) {\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\t// TODO: extract template expression\n\t\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\t\tthis,\n\t\t\t\t\tnew DomFragmentNode(child.children),\n\t\t\t\t\tcontextStack.copyStack(),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tthis.templateNameScope.set(templateRefName.name, templateRef);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfragmentParent.append(this.createElement(child, contextStack, subscriptions, parentNode, host));\n\t\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t\tconst commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');\n\t\t\tconst comment = document.createComment(`start ${commentText}`);\n\t\t\tfragmentParent.append(comment);\n\t\t\tconst lastComment = document.createComment(`end ${commentText}`);\n\t\t\tcomment.after(lastComment);\n\t\t\tthis.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);\n\t\t} else if (isLiveTextContent(child)) {\n\t\t\tfragmentParent.append(this.createLiveText(child, contextStack, parentNode, subscriptions));\n\t\t} else if (child instanceof TextContent) {\n\t\t\tfragmentParent.append(this.createText(child));\n\t\t} else if (child instanceof CommentNode) {\n\t\t\tfragmentParent.append(this.createComment(child));\n\t\t} else if (child instanceof DomFragmentNode) {\n\t\t\tfragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));\n\t\t}\n\t}\n\tcreateElementByTagName(node: { tagName: string, is?: string }): HTMLElement {\n\t\tlet element: HTMLElement;\n\t\tif (isValidCustomElementName(node.tagName)) {\n\t\t\tconst ViewClass = customElements.get(node.tagName) as ((new () => HTMLElement) | undefined);\n\t\t\tif (ViewClass) {\n\t\t\t\telement = new ViewClass();\n\t\t\t} else {\n\t\t\t\telement = document.createElement(node.tagName);\n\t\t\t\tif (element.constructor.name === 'HTMLElement') {\n\t\t\t\t\tcustomElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isTagNameNative(node.tagName)) {\n\t\t\t// native tags // and custom tags can be used her\n\t\t\telement = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);\n\t\t} else {\n\t\t\t// html unknown element\n\t\t\telement = document.createElement(node.tagName);\n\t\t}\n\t\tif (isHTMLComponent(element)) {\n\t\t\telement.setParentComponent(this.view);\n\t\t}\n\t\treturn element;\n\t}\n\tcreateElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): HTMLElement {\n\t\tconst element = this.createElementByTagName(node);\n\t\tconst elementStack = contextStack.copyStack();\n\t\tconst elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.pushBlockReactiveScopeFor({ 'this': element });\n\t\telementStack.pushScope<ScopeContext>(elementScope);\n\t\tconst attributesSubscriptions = this.initAttribute(element, node, elementStack);\n\t\tsubscriptions.push(...attributesSubscriptions);\n\t\tconst eventName = getInputEventName(element);\n\t\tlet listener: ((event: HTMLElementEventMap['input' | 'change']) => any) | undefined;\n\t\tif (eventName) {\n\t\t\tconst inputScope = elementScope.getScopeOrCreat('this');\n\t\t\tlistener = (event) => inputScope.emit('value', (element as HTMLInputElement).value);\n\t\t\telement.addEventListener(eventName, listener);\n\t\t}\n\n\t\tconst templateRefName = node.templateRefName;\n\t\tif (templateRefName) {\n\t\t\tReflect.set(this.view, templateRefName.name, element);\n\t\t\tconst view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);\n\t\t\tif (view) {\n\t\t\t\tReflect.set(this.view._model, view.modelName, element);\n\t\t\t}\n\t\t}\n\t\tif (node.children) {\n\t\t\tfor (const child of node.children) {\n\t\t\t\tthis.appendChildToParent(element, child, elementStack, element, subscriptions, host);\n\t\t\t}\n\t\t}\n\t\tif (node.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);\n\t\t}\n\t\treturn element;\n\t}\n\tprivate initAttributeDirectives(\n\t\tattributeDirectives: DomAttributeDirectiveNode[],\n\t\telement: HTMLElement | StructuralDirective,\n\t\tcontextStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[]) {\n\t\tattributeDirectives?.forEach(directiveNode => {\n\t\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(directiveNode.name);\n\t\t\tif (directiveRef &&\n\t\t\t\t(directiveRef.modelClass.prototype instanceof AttributeDirective\n\t\t\t\t\t|| directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective\n\t\t\t\t)) {\n\t\t\t\tconst directive = new directiveRef.modelClass(element) as AttributeDirective | AttributeOnStructuralDirective;\n\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\tstack.pushBlockReactiveScopeFor({ 'this': directive });\n\t\t\t\tconst directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);\n\t\t\t\tsubscriptions.push(...directiveSubscriptions);\n\t\t\t\tif (isOnInit(directive)) {\n\t\t\t\t\tdirective.onInit();\n\t\t\t\t}\n\t\t\t\tif (isOnDestroy(directive)) {\n\t\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tinitAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<ScopeContext>[] {\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => {\n\t\t\t\t/**\n\t\t\t\t * <input id=\"23\" name=\"person-name\" />\n\t\t\t\t */\n\t\t\t\tconst isAttr = hasAttr(element, attr.name);\n\t\t\t\tif (isAttr) {\n\t\t\t\t\tif (attr.value === false) {\n\t\t\t\t\t\telement.removeAttribute(attr.name);\n\t\t\t\t\t} else if (attr.value === true) {\n\t\t\t\t\t\telement.setAttribute(attr.name, '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.setAttribute(attr.name, attr.value as string);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tReflect.set(element, attr.name, attr.value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tlet listener: Function;\n\t\t\t\t/**\n\t\t\t\t * <a (click)=\"onLinkClick($event)\"></a>\n\t\t\t\t * <a @click=\"onLinkClick($event)\"></a>\n\t\t\t\t * <input [(value)]=\"person.name\" />\n\t\t\t\t * <input (value)=\"person.name\" />\n\t\t\t\t * <!-- <input (value)=\"person.name = $event\" /> -->\n\t\t\t\t * \n\t\t\t\t * TODO: diff of event listener and back-way data binding\n\t\t\t\t */\n\t\t\t\tif (typeof event.value === 'string') {\n\t\t\t\t\tlistener = ($event: Event) => {\n\t\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\t\tevent.expression.get(stack, this.view._proxyModel);\n\t\t\t\t\t};\n\t\t\t\t} else /* if (typeof event.sourceHandler === 'function')*/ {\n\t\t\t\t\t// let eventName: keyof HTMLElementEventMap = event.eventName;\n\t\t\t\t\tlistener = event.value;\n\t\t\t\t}\n\t\t\t\telement.addEventListener(event.name as any, listener as any);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\n\tinitStructuralDirective(\n\t\tdirective: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective,\n\t\tnode: DomStructuralDirectiveNode | DomAttributeDirectiveNode,\n\t\tcontextStack: Stack): ScopeSubscription<ScopeContext>[] {\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tconst listener = ($event: Event) => {\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\tevent.expression.get(stack, this.view._proxyModel);\n\t\t\t\t};\n\t\t\t\t((<any>directive)[event.name] as any).subscribe(listener);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\t// TODO: \n\t\t// check host binding\n\t\treturn subscriptions;\n\t}\n\n}\n"]}
package/view/view.js CHANGED
@@ -60,6 +60,11 @@ export function initCustomElementView(modelClass, componentRef) {
60
60
  enumerable: true
61
61
  });
62
62
  });
63
+ componentRef.inputs.map(input => input.modelProperty)
64
+ .concat(componentRef.outputs.map(output => output.modelProperty))
65
+ .concat(componentRef.hostBindings.map(host => host.hostPropertyName))
66
+ .concat(componentRef.viewChild.map(child => child.modelName))
67
+ .forEach(modelName => modelClass.prototype[modelName] = undefined);
63
68
  const defaultAttributes = getAllAttributes(componentRef.extend.name);
64
69
  const observedAttributes = componentRef.inputs.map(input => input.viewAttribute);
65
70
  Reflect.set(viewClass, 'observedAttributes', observedAttributes);
package/view/view.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/core/view/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIlE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAOrD,MAAM,UAAU,qBAAqB,CAAmB,UAAqB,EAAE,YAA6B;IAC3G,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,QAA+B,CAAC;IACvE,IAAI,SAAmC,CAAC;IACxC,MAAM,aAAa,GAAG,8BAA8B,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC5E,MAAM,iBAAiB,GAAG,OAAO,aAAa,SAAS,CAAC;I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B,CAAmB,UAAqB,EAAE,QAAiB;IAC1F,IAAI,qBAAqB,CAAC,UAAU,CAAC,EAAE;QACtC,IAAI,aAAqB,CAAC;QAC1B,IAAI,QAAQ,EAAE;YACb,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,CAAC,aAAa,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,iBAAiB,QAAQ,UAAU,CAAC,CAAC;aACvE;SACD;aAAM;YACN,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;SACrD;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;KAC9C;AACF,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { getAllAttributes, isFormElement } from '@ibyar/elements';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { EventEmitter, Subscription } from '../component/events.js';\nimport { ToCamelCase } from '../utils/utils.js';\nimport { Constructable } from '../providers/injector.js';\nimport { baseFactoryView } from './base-view.js';\nimport { baseFormFactoryView } from './form-view.js';\n\n/**\n * \n * @param modelClass \n * @param componentRef \n */\nexport function initCustomElementView<T extends Object>(modelClass: TypeOf<T>, componentRef: ComponentRef<T>): TypeOf<HTMLComponent<T>> {\n\tconst htmlParent = componentRef.extend.classRef as TypeOf<HTMLElement>;\n\tlet viewClass: TypeOf<HTMLComponent<T>>;\n\tconst viewClassName = buildViewClassNameFromSelector(componentRef.selector);\n\tconst htmlViewClassName = `HTML${viewClassName}Element`;\n\tconst parentClass = componentRef.extend.name\n\t\t? (isFormElement(componentRef.extend.name)\n\t\t\t? baseFormFactoryView<T>(htmlParent)\n\t\t\t: baseFactoryView<T>(htmlParent)\n\t\t)\n\t\t: baseFactoryView<T>(HTMLElement);\n\tviewClass = ({\n\t\t[htmlViewClassName]: class extends parentClass { constructor() { super(componentRef, modelClass); } }\n\t})[htmlViewClassName];\n\n\tcomponentRef.inputs.forEach((input) => {\n\t\tObject.defineProperty(viewClass.prototype, input.viewAttribute, {\n\t\t\tget(this: HTMLComponent<T>): any {\n\t\t\t\treturn this._modelScope.get(input.modelProperty);\n\t\t\t},\n\t\t\tset(this: HTMLComponent<{ [key: string]: any; }>, value: any) {\n\t\t\t\tthis._modelScope.set(input.modelProperty, value);\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t});\n\t});\n\n\tcomponentRef.outputs.forEach(output => {\n\t\tObject.defineProperty(viewClass.prototype, output.viewAttribute, {\n\t\t\tget(): EventEmitter<any> {\n\t\t\t\treturn this._model[output.modelProperty];\n\t\t\t},\n\t\t\tenumerable: true\n\t\t});\n\t\tlet eventListener: Function | undefined;\n\t\tlet subscription: Subscription<any>;\n\t\tObject.defineProperty(viewClass.prototype, 'on' + ToCamelCase(output.viewAttribute), {\n\t\t\tget(): Function | undefined {\n\t\t\t\treturn eventListener;\n\t\t\t},\n\t\t\tset(this: HTMLComponent<T>, event: string | Function): void {\n\t\t\t\tif (!event) {\n\t\t\t\t\tif (subscription) {\n\t\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\t\teventListener = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof event === 'string') {\n\t\t\t\t\tif (event.endsWith('()')) {\n\t\t\t\t\t\tevent = event.substring(0, event.length - 2);\n\t\t\t\t\t}\n\t\t\t\t\tevent = Reflect.get(window, event);\n\t\t\t\t}\n\t\t\t\teventListener = event as Function;\n\t\t\t\tsubscription = (this._model[output.modelProperty] as EventEmitter<any>).subscribe(event);\n\t\t\t},\n\t\t\tenumerable: true\n\t\t});\n\t});\n\n\tconst defaultAttributes = getAllAttributes(componentRef.extend.name);\n\tconst observedAttributes = componentRef.inputs.map(input => input.viewAttribute)\n\tReflect.set(viewClass, 'observedAttributes', observedAttributes);\n\tReflect.set(viewClass, 'allAttributes', defaultAttributes.concat(observedAttributes));\n\t// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example\n\tif (false) {\n\t\tObject.defineProperty(viewClass, 'formAssociated', {\n\t\t\tget() {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t});\n\t}\n\taddViewToModelClass<T>(modelClass, componentRef.selector, viewClass, htmlViewClassName);\n\tif (!Reflect.has(window, htmlViewClassName)) {\n\t\tReflect.set(window, htmlViewClassName, viewClass);\n\t}\n\treturn viewClass;\n}\n\nexport type ComponentModelClass = Constructable & { [key: string]: string } & { component: { [key: string]: string } };\n\nexport function isComponentModelClass(target: Constructable): target is ComponentModelClass {\n\treturn Reflect.has(target, 'component');\n}\n\nexport function addViewToModelClass<T extends object>(modelClass: TypeOf<T>, selector: string, viewClass: TypeOf<HTMLComponent<T>>, htmlViewClassName: string) {\n\tObject.defineProperty(modelClass, htmlViewClassName, { value: viewClass });\n\n\tif (!isComponentModelClass(modelClass)) {\n\t\tReflect.set(modelClass, 'component', {});\n\t}\n\n\tif (isComponentModelClass(modelClass)) {\n\t\tmodelClass.component[selector] = htmlViewClassName;\n\t}\n}\n\nexport function buildViewClassNameFromSelector(selector: string) {\n\treturn selector\n\t\t.split('-')\n\t\t.map(name => name.replace(/^\\w/, char => char.toUpperCase()))\n\t\t.join('');\n}\n\nexport function getComponentView<T extends object>(modelClass: TypeOf<T>, selector?: string): TypeOf<HTMLComponent<T>> | undefined {\n\tif (isComponentModelClass(modelClass)) {\n\t\tlet viewClassName: string;\n\t\tif (selector) {\n\t\t\tviewClassName = modelClass.component[selector];\n\t\t\tif (!viewClassName) {\n\t\t\t\tthrow new Error(`${modelClass.name} doesn't have ${selector} as view`);\n\t\t\t}\n\t\t} else {\n\t\t\tviewClassName = Object.keys(modelClass.component)[0];\n\t\t}\n\t\treturn Reflect.get(modelClass, viewClassName);\n\t}\n}\n"]}
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/core/view/view.ts"],"names":[],"mappings":"AACA,O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M,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,iBAAiB,QAAQ,UAAU,CAAC,CAAC;aACvE;SACD;aAAM;YACN,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;SACrD;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;KAC9C;AACF,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { getAllAttributes, isFormElement } from '@ibyar/elements';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { EventEmitter, Subscription } from '../component/events.js';\nimport { ToCamelCase } from '../utils/utils.js';\nimport { Constructable } from '../providers/injector.js';\nimport { baseFactoryView } from './base-view.js';\nimport { baseFormFactoryView } from './form-view.js';\n\n/**\n * \n * @param modelClass \n * @param componentRef \n */\nexport function initCustomElementView<T extends Object>(modelClass: TypeOf<T>, componentRef: ComponentRef<T>): TypeOf<HTMLComponent<T>> {\n\tconst htmlParent = componentRef.extend.classRef as TypeOf<HTMLElement>;\n\tlet viewClass: TypeOf<HTMLComponent<T>>;\n\tconst viewClassName = buildViewClassNameFromSelector(componentRef.selector);\n\tconst htmlViewClassName = `HTML${viewClassName}Element`;\n\tconst parentClass = componentRef.extend.name\n\t\t? (isFormElement(componentRef.extend.name)\n\t\t\t? baseFormFactoryView<T>(htmlParent)\n\t\t\t: baseFactoryView<T>(htmlParent)\n\t\t)\n\t\t: baseFactoryView<T>(HTMLElement);\n\tviewClass = ({\n\t\t[htmlViewClassName]: class extends parentClass { constructor() { super(componentRef, modelClass); } }\n\t})[htmlViewClassName];\n\n\tcomponentRef.inputs.forEach((input) => {\n\t\tObject.defineProperty(viewClass.prototype, input.viewAttribute, {\n\t\t\tget(this: HTMLComponent<T>): any {\n\t\t\t\treturn this._modelScope.get(input.modelProperty);\n\t\t\t},\n\t\t\tset(this: HTMLComponent<{ [key: string]: any; }>, value: any) {\n\t\t\t\tthis._modelScope.set(input.modelProperty, value);\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t});\n\t});\n\n\tcomponentRef.outputs.forEach(output => {\n\t\tObject.defineProperty(viewClass.prototype, output.viewAttribute, {\n\t\t\tget(): EventEmitter<any> {\n\t\t\t\treturn this._model[output.modelProperty];\n\t\t\t},\n\t\t\tenumerable: true\n\t\t});\n\t\tlet eventListener: Function | undefined;\n\t\tlet subscription: Subscription<any>;\n\t\tObject.defineProperty(viewClass.prototype, 'on' + ToCamelCase(output.viewAttribute), {\n\t\t\tget(): Function | undefined {\n\t\t\t\treturn eventListener;\n\t\t\t},\n\t\t\tset(this: HTMLComponent<T>, event: string | Function): void {\n\t\t\t\tif (!event) {\n\t\t\t\t\tif (subscription) {\n\t\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\t\teventListener = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof event === 'string') {\n\t\t\t\t\tif (event.endsWith('()')) {\n\t\t\t\t\t\tevent = event.substring(0, event.length - 2);\n\t\t\t\t\t}\n\t\t\t\t\tevent = Reflect.get(window, event);\n\t\t\t\t}\n\t\t\t\teventListener = event as Function;\n\t\t\t\tsubscription = (this._model[output.modelProperty] as EventEmitter<any>).subscribe(event);\n\t\t\t},\n\t\t\tenumerable: true\n\t\t});\n\t});\n\n\tcomponentRef.inputs.map(input => input.modelProperty)\n\t\t.concat(componentRef.outputs.map(output => output.modelProperty))\n\t\t.concat(componentRef.hostBindings.map(host => host.hostPropertyName))\n\t\t.concat(componentRef.viewChild.map(child => child.modelName))\n\t\t.forEach(modelName => modelClass.prototype[modelName] = undefined);\n\n\tconst defaultAttributes = getAllAttributes(componentRef.extend.name);\n\tconst observedAttributes = componentRef.inputs.map(input => input.viewAttribute)\n\tReflect.set(viewClass, 'observedAttributes', observedAttributes);\n\tReflect.set(viewClass, 'allAttributes', defaultAttributes.concat(observedAttributes));\n\t// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example\n\tif (false) {\n\t\tObject.defineProperty(viewClass, 'formAssociated', {\n\t\t\tget() {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t});\n\t}\n\taddViewToModelClass<T>(modelClass, componentRef.selector, viewClass, htmlViewClassName);\n\tif (!Reflect.has(window, htmlViewClassName)) {\n\t\tReflect.set(window, htmlViewClassName, viewClass);\n\t}\n\treturn viewClass;\n}\n\nexport type ComponentModelClass = Constructable & { [key: string]: string } & { component: { [key: string]: string } };\n\nexport function isComponentModelClass(target: Constructable): target is ComponentModelClass {\n\treturn Reflect.has(target, 'component');\n}\n\nexport function addViewToModelClass<T extends object>(modelClass: TypeOf<T>, selector: string, viewClass: TypeOf<HTMLComponent<T>>, htmlViewClassName: string) {\n\tObject.defineProperty(modelClass, htmlViewClassName, { value: viewClass });\n\n\tif (!isComponentModelClass(modelClass)) {\n\t\tReflect.set(modelClass, 'component', {});\n\t}\n\n\tif (isComponentModelClass(modelClass)) {\n\t\tmodelClass.component[selector] = htmlViewClassName;\n\t}\n}\n\nexport function buildViewClassNameFromSelector(selector: string) {\n\treturn selector\n\t\t.split('-')\n\t\t.map(name => name.replace(/^\\w/, char => char.toUpperCase()))\n\t\t.join('');\n}\n\nexport function getComponentView<T extends object>(modelClass: TypeOf<T>, selector?: string): TypeOf<HTMLComponent<T>> | undefined {\n\tif (isComponentModelClass(modelClass)) {\n\t\tlet viewClassName: string;\n\t\tif (selector) {\n\t\t\tviewClassName = modelClass.component[selector];\n\t\t\tif (!viewClassName) {\n\t\t\t\tthrow new Error(`${modelClass.name} doesn't have ${selector} as view`);\n\t\t\t}\n\t\t} else {\n\t\t\tviewClassName = Object.keys(modelClass.component)[0];\n\t\t}\n\t\treturn Reflect.get(modelClass, viewClassName);\n\t}\n}\n"]}