@ibyar/core 0.5.1 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +1 -1
  2. package/binding/binding.expressions.d.ts +3 -2
  3. package/binding/binding.expressions.js +52 -30
  4. package/binding/binding.expressions.js.map +1 -1
  5. package/component/component.js +8 -8
  6. package/component/component.js.map +1 -1
  7. package/component/provider.d.ts +4 -9
  8. package/component/provider.js +5 -30
  9. package/component/provider.js.map +1 -1
  10. package/context/stack.js +1 -1
  11. package/context/stack.js.map +1 -1
  12. package/context/subscription.d.ts +2 -0
  13. package/context/subscription.js +14 -0
  14. package/context/subscription.js.map +1 -0
  15. package/directive/directive.d.ts +4 -0
  16. package/directive/directive.js +5 -0
  17. package/directive/directive.js.map +1 -1
  18. package/directive/parser.d.ts +1 -1
  19. package/directive/parser.js +14 -11
  20. package/directive/parser.js.map +1 -1
  21. package/directive/providers.d.ts +2 -0
  22. package/directive/providers.js +4 -1
  23. package/directive/providers.js.map +1 -1
  24. package/html/expression.js +10 -10
  25. package/html/expression.js.map +1 -1
  26. package/index.d.ts +1 -0
  27. package/index.js +1 -0
  28. package/index.js.map +1 -1
  29. package/linker/change-detector-ref.d.ts +1 -1
  30. package/linker/change-detector-ref.js +4 -3
  31. package/linker/change-detector-ref.js.map +1 -1
  32. package/linker/template-ref.d.ts +1 -1
  33. package/linker/template-ref.js +5 -5
  34. package/linker/template-ref.js.map +1 -1
  35. package/linker/view-container-ref.d.ts +4 -4
  36. package/linker/view-container-ref.js +3 -3
  37. package/linker/view-container-ref.js.map +1 -1
  38. package/package.json +6 -6
  39. package/pipe/pipe.d.ts +3 -0
  40. package/pipe/pipe.js +14 -4
  41. package/pipe/pipe.js.map +1 -1
  42. package/providers/provider.d.ts +1 -1
  43. package/providers/provider.js +2 -0
  44. package/providers/provider.js.map +1 -1
  45. package/render/host-listener.handler.d.ts +26 -0
  46. package/render/host-listener.handler.js +69 -0
  47. package/render/host-listener.handler.js.map +1 -0
  48. package/render/render-handler.d.ts +5 -0
  49. package/render/render-handler.js +2 -0
  50. package/render/render-handler.js.map +1 -0
  51. package/view/base-view.js +3 -21
  52. package/view/base-view.js.map +1 -1
  53. package/view/render.d.ts +6 -6
  54. package/view/render.js +69 -72
  55. package/view/render.js.map +1 -1
  56. package/view/view.js +6 -0
  57. package/view/view.js.map +1 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2021 @ibyar/core
3
+ Copyright (c) 2020-2022 @ibyar/core
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,11 +1,12 @@
1
1
  import { ExpressionNode, InfixExpressionNode, ScopeSubscription, Stack, ScopeContext, MemberExpression, Identifier } from '@ibyar/expressions';
2
- declare type OneWayOperator = ':=';
3
- declare type TwoWayOperator = ':=:';
2
+ declare type OneWayOperator = '.=';
3
+ declare type TwoWayOperator = ':=';
4
4
  declare type BindingOperators = OneWayOperator | TwoWayOperator;
5
5
  export interface BindingAssignment extends InfixExpressionNode<BindingOperators> {
6
6
  subscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<ScopeContext>[];
7
7
  }
8
8
  export declare class OneWayAssignmentExpression extends InfixExpressionNode<OneWayOperator> implements BindingAssignment {
9
+ protected left: MemberExpression;
9
10
  private rightEvents;
10
11
  constructor(left: MemberExpression, right: ExpressionNode);
11
12
  set(stack: Stack, value: any): any;
@@ -1,8 +1,11 @@
1
- import { InfixExpressionNode, findScopeByEventMap, ReactiveScope, Scope } from '@ibyar/expressions';
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { InfixExpressionNode, findReactiveScopeByEventMap, Scope, MemberExpression, Deserializer } from '@ibyar/expressions';
3
+ import { createSubscriptionDestroyer } from '../context/subscription.js';
4
+ import { isOnDestroy } from '../component/lifecycle.js';
2
5
  import { AsyncPipeProvider, AsyncPipeScope, PipeProvider } from '../pipe/pipe.js';
3
- export class OneWayAssignmentExpression extends InfixExpressionNode {
6
+ let OneWayAssignmentExpression = class OneWayAssignmentExpression extends InfixExpressionNode {
4
7
  constructor(left, right) {
5
- super(':=', left, right);
8
+ super('.=', left, right);
6
9
  this.rightEvents = this.right.events();
7
10
  }
8
11
  set(stack, value) {
@@ -14,38 +17,50 @@ export class OneWayAssignmentExpression extends InfixExpressionNode {
14
17
  return rv;
15
18
  }
16
19
  subscribe(stack, pipelineNames) {
20
+ const subscriptions = [];
17
21
  if (pipelineNames?.length) {
18
- const pipeScope = Scope.blockScope();
22
+ const syncPipeScope = Scope.blockScope();
19
23
  const asyncPipeScope = AsyncPipeScope.blockScope();
24
+ let hasAsync = false, hasSync = false;
20
25
  pipelineNames.forEach(pipelineName => {
21
26
  const scope = stack.findScope(pipelineName);
22
27
  const pipe = scope.get(pipelineName);
23
28
  if (scope instanceof AsyncPipeProvider) {
29
+ hasAsync = true;
24
30
  asyncPipeScope.set(pipelineName, pipe);
31
+ if (isOnDestroy(pipe.prototype)) {
32
+ subscriptions.push(createSubscriptionDestroyer(() => asyncPipeScope.unsubscribe(pipelineName)));
33
+ }
25
34
  }
26
35
  else if (scope instanceof PipeProvider) {
27
- pipeScope.set(pipelineName, pipe);
36
+ hasSync = true;
37
+ syncPipeScope.set(pipelineName, pipe);
28
38
  }
29
39
  });
30
- stack.pushScope(pipeScope);
31
- stack.pushScope(asyncPipeScope);
40
+ hasSync && stack.pushScope(syncPipeScope);
41
+ hasAsync && stack.pushScope(asyncPipeScope);
32
42
  }
33
- const map = findScopeByEventMap(this.rightEvents, stack);
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
- }
43
+ const tuples = findReactiveScopeByEventMap(this.rightEvents, stack);
44
+ const callback = (newValue, oldValue) => {
45
+ stack.detach();
46
+ this.get(stack);
47
+ stack.reattach();
48
+ };
49
+ tuples.forEach(tuple => {
50
+ const subscription = tuple[1].subscribe(tuple[0], callback);
51
+ subscriptions.push(subscription);
42
52
  });
43
53
  return subscriptions;
44
54
  }
45
- }
46
- export class TwoWayAssignmentExpression extends InfixExpressionNode {
55
+ };
56
+ OneWayAssignmentExpression = __decorate([
57
+ Deserializer('OneWayAssignment'),
58
+ __metadata("design:paramtypes", [MemberExpression, Object])
59
+ ], OneWayAssignmentExpression);
60
+ export { OneWayAssignmentExpression };
61
+ let TwoWayAssignmentExpression = class TwoWayAssignmentExpression extends InfixExpressionNode {
47
62
  constructor(left, right) {
48
- super(':=:', left, right);
63
+ super(':=', left, right);
49
64
  this.rightEvents = this.right.events();
50
65
  this.leftEvents = this.left.events();
51
66
  }
@@ -65,7 +80,9 @@ export class TwoWayAssignmentExpression extends InfixExpressionNode {
65
80
  }
66
81
  actionRTL(stack) {
67
82
  return (newValue, oldValue) => {
83
+ stack.detach();
68
84
  this.getRTL(stack);
85
+ stack.reattach();
69
86
  };
70
87
  }
71
88
  setLTR(stack, value) {
@@ -78,27 +95,32 @@ export class TwoWayAssignmentExpression extends InfixExpressionNode {
78
95
  }
79
96
  actionLTR(stack) {
80
97
  return (newValue, oldValue) => {
98
+ stack.detach();
81
99
  this.getLTR(stack);
100
+ stack.reattach();
82
101
  };
83
102
  }
84
- subscribeToEvents(stack, map, actionCallback) {
103
+ subscribeToEvents(stack, tuples, actionCallback) {
85
104
  const subscriptions = [];
86
- map.forEach((scope, eventName) => {
87
- if (scope instanceof ReactiveScope) {
88
- const subscription = scope.subscribe(eventName, actionCallback);
89
- subscriptions.push(subscription);
90
- }
105
+ tuples.forEach(tuple => {
106
+ const subscription = tuple[1].subscribe(tuple[0], actionCallback);
107
+ subscriptions.push(subscription);
91
108
  });
92
109
  return subscriptions;
93
110
  }
94
111
  subscribe(stack) {
95
- const rightMap = findScopeByEventMap(this.rightEvents, stack);
112
+ const rightTuples = findReactiveScopeByEventMap(this.rightEvents, stack);
96
113
  const rtlAction = this.actionRTL(stack);
97
- const rtlSubscriptions = this.subscribeToEvents(stack, rightMap, rtlAction);
98
- const leftMap = findScopeByEventMap(this.leftEvents, stack);
114
+ const rtlSubscriptions = this.subscribeToEvents(stack, rightTuples, rtlAction);
115
+ const leftTuples = findReactiveScopeByEventMap(this.leftEvents, stack);
99
116
  const ltrAction = this.actionLTR(stack);
100
- const ltrSubscriptions = this.subscribeToEvents(stack, leftMap, ltrAction);
117
+ const ltrSubscriptions = this.subscribeToEvents(stack, leftTuples, ltrAction);
101
118
  return rtlSubscriptions.concat(ltrSubscriptions);
102
119
  }
103
- }
120
+ };
121
+ TwoWayAssignmentExpression = __decorate([
122
+ Deserializer('TwoWayAssignment'),
123
+ __metadata("design:paramtypes", [MemberExpression, Object])
124
+ ], TwoWayAssignmentExpression);
125
+ export { TwoWayAssignmentExpression };
104
126
  //# sourceMappingURL=binding.expressions.js.map
@@ -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;QAC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AC,CAAC;QAE3E,OAAO,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAClD,CAAC;CAED","sourcesContent":["import {\n\tExpressionNode, 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,EACzC,gBAAgB,EAAc,YAAY,EAC1C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAYlF,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,mBAAmC;IAIlF,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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AAsC,EAAE,CAAC;QAC5D,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACtB,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;YAClE,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,aAAa,CAAC;IACtB,CAAC;IAED,SAAS,CAAC,KAAY;QAGrB,MAAM,WAAW,GAAG,2BAA2B,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACxC,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAG/E,MAAM,UAAU,GAAG,2BAA2B,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACxC,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAE9E,OAAO,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAClD,CAAC;CAED,CAAA;AA1EY,0BAA0B;IADtC,YAAY,CAAC,kBAAkB,CAAC;qCAQd,gBAAgB;GAPtB,0BAA0B,CA0EtC;SA1EY,0BAA0B","sourcesContent":["import {\n\tExpressionNode, InfixExpressionNode, ScopeSubscription,\n\tStack, findReactiveScopeByEventMap, ReactiveScope,\n\tScopeContext, ValueChangedCallback, Scope,\n\tMemberExpression, Identifier, Deserializer\n} from '@ibyar/expressions';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\nimport { isOnDestroy } from '../component/lifecycle.js';\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\n@Deserializer('OneWayAssignment')\nexport class OneWayAssignmentExpression extends InfixExpressionNode<OneWayOperator> implements BindingAssignment {\n\n\tdeclare protected left: MemberExpression;\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\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tif (pipelineNames?.length) {\n\t\t\tconst syncPipeScope = Scope.blockScope();\n\t\t\tconst asyncPipeScope = AsyncPipeScope.blockScope();\n\t\t\tlet hasAsync = false, hasSync = false;\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\thasAsync = true;\n\t\t\t\t\tasyncPipeScope.set(pipelineName, pipe);\n\t\t\t\t\tif (isOnDestroy(pipe.prototype)) {\n\t\t\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => asyncPipeScope.unsubscribe(pipelineName)));\n\t\t\t\t\t}\n\t\t\t\t} else if (scope instanceof PipeProvider) {\n\t\t\t\t\thasSync = true;\n\t\t\t\t\tsyncPipeScope.set(pipelineName, pipe);\n\t\t\t\t}\n\t\t\t});\n\t\t\thasSync && stack.pushScope(syncPipeScope);\n\t\t\thasAsync && stack.pushScope(asyncPipeScope);\n\t\t}\n\t\tconst tuples = findReactiveScopeByEventMap(this.rightEvents, stack);\n\t\tconst callback: ValueChangedCallback = (newValue: any, oldValue?: any) => {\n\t\t\tstack.detach();\n\t\t\tthis.get(stack);\n\t\t\tstack.reattach();\n\t\t};\n\t\ttuples.forEach(tuple => {\n\t\t\tconst subscription = tuple[1].subscribe(tuple[0], callback);\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 */\n@Deserializer('TwoWayAssignment')\nexport class TwoWayAssignmentExpression extends InfixExpressionNode<TwoWayOperator> implements BindingAssignment {\n\n\tdeclare protected left: MemberExpression;\n\tdeclare protected 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\tstack.detach();\n\t\t\tthis.getRTL(stack);\n\t\t\tstack.reattach();\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\tstack.detach();\n\t\t\tthis.getLTR(stack);\n\t\t\tstack.reattach();\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"]}
@@ -142,15 +142,15 @@ export class Components {
142
142
  else {
143
143
  }
144
144
  }
145
- componentRef.inputs ||= [];
146
- componentRef.outputs ||= [];
147
- componentRef.viewChild ||= [];
148
- componentRef.ViewChildren ||= [];
149
- componentRef.hostBindings ||= [];
150
- componentRef.hostListeners ||= [];
151
- componentRef.encapsulation ||= 'custom';
145
+ componentRef.inputs || (componentRef.inputs = []);
146
+ componentRef.outputs || (componentRef.outputs = []);
147
+ componentRef.viewChild || (componentRef.viewChild = []);
148
+ componentRef.ViewChildren || (componentRef.ViewChildren = []);
149
+ componentRef.hostBindings || (componentRef.hostBindings = []);
150
+ componentRef.hostListeners || (componentRef.hostListeners = []);
151
+ componentRef.encapsulation || (componentRef.encapsulation = 'custom');
152
152
  componentRef.isShadowDom = /shadow-dom/g.test(componentRef.encapsulation);
153
- componentRef.shadowDomMode ||= 'open';
153
+ componentRef.shadowDomMode || (componentRef.shadowDomMode = 'open');
154
154
  componentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;
155
155
  if (componentRef.isShadowDom && componentRef.extend.name) {
156
156
  componentRef.isShadowDom = canAttachShadow(componentRef.extend.name);
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AACA,OAAO,EACN,aAAa,EAAO,UAAU,EAAE,cAAc,EACtB,eAAe,EAAE,iBAAiB,EAC1D,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAM7D,MAAM,OAAO,WAAW;IACvB,YAAmB,aAAqB,EAAU,SAAkB;QAAjD,kBAAa,GAAb,aAAa,CAAQ;QAAU,cAAS,GAAT,SAAS,CAAS;IAAI,CAAC;IACzE,IAAI,aAAa;QAChB,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC;IAC7C,CAAC;CACD;AAED,MAAM,OAAO,QAAQ;IACpB,YACQ,SAAiB,EACjB,QAA4F,EAC5F,YAA2B;QAF3B,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAoF;QAC5F,iBAAY,GAAZ,YAAY,CAAe;IAC/B,CAAC;CACL;AAED,MAAM,OAAO,WAAW;IACvB,YAAmB,SAAiB,EAAS,IAAc,EAAS,iBAAyB;QAA1E,cAAS,GAAT,SAAS,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAU;QAAS,sBAAiB,GAAjB,iBAAiB,CAAQ;IAAI,CAAC;CAClG;AAED,MAAM,OAAO,cAAc;IAC1B,YAAmB,YAAoB,EAAS,gBAAwB;QAArD,iBAAY,GAAZ,YA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uBAAuB,KAAK,IAAI,IAAI,KAAK,CAAC;QAE9F,IAAI,YAAY,CAAC,WAAW,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE;YACzD,YAAY,CAAC,WAAW,GAAG,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACrE;QAED,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC;QACrC,YAAY,CAAC,SAAS,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACzE,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAClE,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAEjE,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAExD,MAAM,OAAO,GAA6B,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;QAChD,IAAI,aAAa,EAAE;YAClB,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC/D,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;aAChC;SACD;QAGD,cAAc,CAAC,MAAM,CACpB,YAAY,CAAC,QAAkB,EAC/B,YAAY,CAAC,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;CACD","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow, directiveRegistry\n} from '@ibyar/elements';\n\nimport { HTMLComponent } from './custom-element.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective, StructuralDirective } from '../directive/directive.js';\nimport { initCustomElementView } from '../view/view.js';\nimport { buildExpressionNodes } from '../html/expression.js';\nimport {\n\tComponentOptions, ChildOptions, PipeOptions,\n\tServiceOptions, DirectiveOptions\n} from '../annotation/decorators.js';\n\nexport class PropertyRef {\n\tconstructor(public modelProperty: string, private _viewName?: string) { }\n\tget viewAttribute(): string {\n\t\treturn this._viewName || this.modelProperty;\n\t}\n}\n\nexport class ChildRef {\n\tconstructor(\n\t\tpublic modelName: string,\n\t\tpublic selector: string | { new(): HTMLElement; prototype: HTMLElement } | CustomElementConstructor,\n\t\tpublic childOptions?: ChildOptions\n\t) { }\n}\n\nexport class ListenerRef {\n\tconstructor(public eventName: string, public args: string[], public modelCallbackName: string) { }\n}\n\nexport class HostBindingRef {\n\tconstructor(public viewProperty: string, public hostPropertyName: string) { }\n}\n\nexport interface BootstrapMetadata {\n\t[key: string]: any;\n}\n\nexport interface ServiceRef<T> {\n\tprovideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: TypeOf<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: TypeOf<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\n\tmodelClass: TypeOf<StructuralDirective> | TypeOf<AttributeDirective>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostListeners: ListenerRef[];\n\thostBindings: HostBindingRef[];\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\t// attrTemplate: JsxAttrComponent;\n\tstyles: string;\n\textend: Tag;\n\n\tviewClass: TypeOf<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\tisShadowDom: boolean;\n\tshadowDomMode: ShadowRootMode;\n\tshadowDomDelegatesFocus: boolean;\n}\n\nconst AuroraBootstrap = Symbol.for('aurora:bootstrap');\nconst AuroraMetadata = Symbol.for('aurora:metadata');\n\nexport class Components {\n\n\tstatic getOrCreateBootstrap<T extends {}>(target: Object): T {\n\t\tlet bootstrap: T = Reflect.getMetadata(AuroraBootstrap, target);\n\t\tif (!bootstrap) {\n\t\t\tbootstrap = {} as T;\n\t\t\tReflect.defineMetadata(AuroraBootstrap, bootstrap, target);\n\t\t}\n\t\treturn bootstrap;\n\t}\n\n\tstatic getBootstrap<T extends {}>(target: Object): T {\n\t\treturn Reflect.getMetadata(AuroraBootstrap, target);\n\t}\n\n\tstatic getComponentRef<T>(target: object): ComponentRef<T> {\n\t\treturn Reflect.getMetadata(AuroraMetadata, target);\n\t}\n\n\tstatic setComponentRef<T>(target: object, componentRef: ComponentRef<T>): void {\n\t\tReflect.defineMetadata(AuroraMetadata, componentRef, target);\n\t}\n\n\tstatic addOptional(modelProperty: Object) {\n\t}\n\n\tstatic addInput(modelProperty: Object, modelName: string, viewName: string) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.inputs = bootstrap.inputs || [];\n\t\tbootstrap.inputs.push(new PropertyRef(modelName, viewName));\n\t}\n\n\tstatic addOutput(modelProperty: Object, modelName: string, viewName: string) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.outputs = bootstrap.outputs || [];\n\t\tbootstrap.outputs.push(new PropertyRef(modelName, viewName));\n\t}\n\n\tstatic setComponentView(modelProperty: Object, modelName: string) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.view = modelName;\n\t}\n\n\tstatic addViewChild(modelProperty: Object, modelName: string, selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.viewChild = bootstrap.viewChild || [];\n\t\tbootstrap.viewChild.push(new ChildRef(modelName, selector, childOptions));\n\t}\n\n\tstatic addViewChildren(modelProperty: Object, modelName: string, selector: string | typeof HTMLElement | CustomElementConstructor) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.ViewChildren = bootstrap.ViewChildren || [];\n\t\tbootstrap.ViewChildren.push(new ChildRef(modelName, selector));\n\t}\n\n\tstatic addHostListener(modelProperty: Object, propertyKey: string, eventName: string, args: string[]) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.hostListeners = bootstrap.hostListeners || [];\n\t\tbootstrap.hostListeners.push(new ListenerRef(eventName, args, propertyKey));\n\t}\n\n\tstatic addHostBinding(modelProperty: Object, propertyKey: string, hostPropertyName: string) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.hostBinding = bootstrap.hostBinding || [];\n\t\tbootstrap.hostBinding.push(\n\t\t\tnew HostBindingRef(propertyKey, hostPropertyName)\n\t\t);\n\t}\n\n\tstatic defineDirective(modelClass: Function, opts: DirectiveOptions) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelClass.prototype);\n\t\tfor (const key in opts) {\n\t\t\tbootstrap[key] = Reflect.get(opts, key);\n\t\t}\n\t\tbootstrap.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (bootstrap.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (bootstrap.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t});\n\t}\n\n\tstatic definePipe(modelClass: Function, opts: PipeOptions) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelClass.prototype);\n\t\tfor (const key in opts) {\n\t\t\tbootstrap[key] = Reflect.get(opts, key);\n\t\t}\n\t\tbootstrap.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineService(modelClass: Function, opts: ServiceOptions) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelClass.prototype);\n\t\tfor (const key in opts) {\n\t\t\tbootstrap[key] = Reflect.get(opts, key);\n\t\t}\n\t\tbootstrap.modelClass = modelClass;\n\t\tbootstrap.name = modelClass.name;\n\t\tClassRegistryProvider.registerService(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Object>(modelClass: TypeOf<T>, opts: ComponentOptions<T>) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelClass.prototype);\n\n\t\tvar componentRef: ComponentRef<T> = opts as unknown as ComponentRef<T>;\n\t\tfor (const key in bootstrap) {\n\t\t\tReflect.set(componentRef, key, bootstrap[key]);\n\t\t}\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\n\t\tif (typeof componentRef.template === 'string') {\n\t\t\tif (componentRef.styles) {\n\t\t\t\tconst template = `<style>${componentRef.styles}</style>${componentRef.template}`;\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(template);\n\t\t\t} else {\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(componentRef.template);\n\t\t\t}\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t}\n\n\t\tif (!componentRef.template && /template/g.test(componentRef.encapsulation)) {\n\t\t\tconst template = document.querySelector('#' + componentRef.selector);\n\t\t\tif (template && template instanceof HTMLTemplateElement) {\n\t\t\t\tcomponentRef.template = templateParser.parse(template);\n\t\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t\t} else {\n\t\t\t\t// didn't find this template in 'index.html' document\n\t\t\t}\n\t\t}\n\n\t\tcomponentRef.inputs ||= [];\n\t\tcomponentRef.outputs ||= [];\n\t\tcomponentRef.viewChild ||= [];\n\t\tcomponentRef.ViewChildren ||= [];\n\t\tcomponentRef.hostBindings ||= [];\n\t\tcomponentRef.hostListeners ||= [];\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow-dom/g.test(componentRef.encapsulation);\n\t\tcomponentRef.shadowDomMode ||= 'open';\n\t\tcomponentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;\n\n\t\tif (componentRef.isShadowDom && componentRef.extend.name) {\n\t\t\tcomponentRef.isShadowDom = canAttachShadow(componentRef.extend.name);\n\t\t}\n\n\t\tcomponentRef.modelClass = modelClass;\n\t\tcomponentRef.viewClass = initCustomElementView(modelClass, componentRef);\n\t\tComponents.setComponentRef(componentRef.modelClass, componentRef);\n\t\tComponents.setComponentRef(componentRef.viewClass, componentRef);\n\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(bootstrap.viewClass);\n\n\t\tconst options: ElementDefinitionOptions = {};\n\t\tconst parentTagName = componentRef.extend?.name;\n\t\tif (parentTagName) {\n\t\t\tif (parentTagName !== '!' && parentTagName.indexOf('-') === -1) {\n\t\t\t\toptions.extends = parentTagName;\n\t\t\t}\n\t\t}\n\n\n\t\tcustomElements.define(\n\t\t\tcomponentRef.selector as string,\n\t\t\tcomponentRef.viewClass as CustomElementConstructor,\n\t\t\toptions\n\t\t);\n\n\t}\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AACA,OAAO,EACN,aAAa,EAAO,UAAU,EAAE,cAAc,EACtB,eAAe,EAAE,iBAAiB,EAC1D,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAu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AC,eAAe,CAAC,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAClE,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAEjE,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAExD,MAAM,OAAO,GAA6B,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;QAChD,IAAI,aAAa,EAAE;YAClB,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC/D,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;aAChC;SACD;QAGD,cAAc,CAAC,MAAM,CACpB,YAAY,CAAC,QAAkB,EAC/B,YAAY,CAAC,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;CACD","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow, directiveRegistry\n} from '@ibyar/elements';\n\nimport { HTMLComponent } from './custom-element.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective, StructuralDirective } from '../directive/directive.js';\nimport { initCustomElementView } from '../view/view.js';\nimport { buildExpressionNodes } from '../html/expression.js';\nimport {\n\tComponentOptions, ChildOptions, PipeOptions,\n\tServiceOptions, DirectiveOptions\n} from '../annotation/decorators.js';\n\nexport class PropertyRef {\n\tconstructor(public modelProperty: string, private _viewName?: string) { }\n\tget viewAttribute(): string {\n\t\treturn this._viewName || this.modelProperty;\n\t}\n}\n\nexport class ChildRef {\n\tconstructor(\n\t\tpublic modelName: string,\n\t\tpublic selector: string | { new(): HTMLElement; prototype: HTMLElement } | CustomElementConstructor,\n\t\tpublic childOptions?: ChildOptions\n\t) { }\n}\n\nexport class ListenerRef {\n\tconstructor(public eventName: string, public args: string[], public modelCallbackName: string) { }\n}\n\nexport class HostBindingRef {\n\tconstructor(public viewProperty: string, public hostPropertyName: string) { }\n}\n\nexport interface BootstrapMetadata {\n\t[key: string]: any;\n}\n\nexport interface ServiceRef<T> {\n\tprovideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: TypeOf<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: TypeOf<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\n\tmodelClass: TypeOf<StructuralDirective> | TypeOf<AttributeDirective>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostListeners: ListenerRef[];\n\thostBindings: HostBindingRef[];\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\t// attrTemplate: JsxAttrComponent;\n\tstyles: string;\n\textend: Tag;\n\n\tviewClass: TypeOf<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\tisShadowDom: boolean;\n\tshadowDomMode: ShadowRootMode;\n\tshadowDomDelegatesFocus: boolean;\n}\n\nconst AuroraBootstrap = Symbol.for('aurora:bootstrap');\nconst AuroraMetadata = Symbol.for('aurora:metadata');\n\nexport class Components {\n\n\tstatic getOrCreateBootstrap<T extends {}>(target: Object): T {\n\t\tlet bootstrap: T = Reflect.getMetadata(AuroraBootstrap, target);\n\t\tif (!bootstrap) {\n\t\t\tbootstrap = {} as T;\n\t\t\tReflect.defineMetadata(AuroraBootstrap, bootstrap, target);\n\t\t}\n\t\treturn bootstrap;\n\t}\n\n\tstatic getBootstrap<T extends {}>(target: Object): T {\n\t\treturn Reflect.getMetadata(AuroraBootstrap, target);\n\t}\n\n\tstatic getComponentRef<T>(target: object): ComponentRef<T> {\n\t\treturn Reflect.getMetadata(AuroraMetadata, target);\n\t}\n\n\tstatic setComponentRef<T>(target: object, componentRef: ComponentRef<T>): void {\n\t\tReflect.defineMetadata(AuroraMetadata, componentRef, target);\n\t}\n\n\tstatic addOptional(modelProperty: Object) {\n\t}\n\n\tstatic addInput(modelProperty: Object, modelName: string, viewName: string) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.inputs = bootstrap.inputs || [];\n\t\tbootstrap.inputs.push(new PropertyRef(modelName, viewName));\n\t}\n\n\tstatic addOutput(modelProperty: Object, modelName: string, viewName: string) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.outputs = bootstrap.outputs || [];\n\t\tbootstrap.outputs.push(new PropertyRef(modelName, viewName));\n\t}\n\n\tstatic setComponentView(modelProperty: Object, modelName: string) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.view = modelName;\n\t}\n\n\tstatic addViewChild(modelProperty: Object, modelName: string, selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.viewChild = bootstrap.viewChild || [];\n\t\tbootstrap.viewChild.push(new ChildRef(modelName, selector, childOptions));\n\t}\n\n\tstatic addViewChildren(modelProperty: Object, modelName: string, selector: string | typeof HTMLElement | CustomElementConstructor) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.ViewChildren = bootstrap.ViewChildren || [];\n\t\tbootstrap.ViewChildren.push(new ChildRef(modelName, selector));\n\t}\n\n\tstatic addHostListener(modelProperty: Object, propertyKey: string, eventName: string, args: string[]) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.hostListeners = bootstrap.hostListeners || [];\n\t\tbootstrap.hostListeners.push(new ListenerRef(eventName, args, propertyKey));\n\t}\n\n\tstatic addHostBinding(modelProperty: Object, propertyKey: string, hostPropertyName: string) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelProperty);\n\t\tbootstrap.hostBinding = bootstrap.hostBinding || [];\n\t\tbootstrap.hostBinding.push(\n\t\t\tnew HostBindingRef(propertyKey, hostPropertyName)\n\t\t);\n\t}\n\n\tstatic defineDirective(modelClass: Function, opts: DirectiveOptions) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelClass.prototype);\n\t\tfor (const key in opts) {\n\t\t\tbootstrap[key] = Reflect.get(opts, key);\n\t\t}\n\t\tbootstrap.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (bootstrap.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (bootstrap.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t});\n\t}\n\n\tstatic definePipe(modelClass: Function, opts: PipeOptions) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelClass.prototype);\n\t\tfor (const key in opts) {\n\t\t\tbootstrap[key] = Reflect.get(opts, key);\n\t\t}\n\t\tbootstrap.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineService(modelClass: Function, opts: ServiceOptions) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelClass.prototype);\n\t\tfor (const key in opts) {\n\t\t\tbootstrap[key] = Reflect.get(opts, key);\n\t\t}\n\t\tbootstrap.modelClass = modelClass;\n\t\tbootstrap.name = modelClass.name;\n\t\tClassRegistryProvider.registerService(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Object>(modelClass: TypeOf<T>, opts: ComponentOptions<T>) {\n\t\tconst bootstrap: BootstrapMetadata = Components.getOrCreateBootstrap(modelClass.prototype);\n\n\t\tvar componentRef: ComponentRef<T> = opts as unknown as ComponentRef<T>;\n\t\tfor (const key in bootstrap) {\n\t\t\tReflect.set(componentRef, key, bootstrap[key]);\n\t\t}\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\n\t\tif (typeof componentRef.template === 'string') {\n\t\t\tif (componentRef.styles) {\n\t\t\t\tconst template = `<style>${componentRef.styles}</style>${componentRef.template}`;\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(template);\n\t\t\t} else {\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(componentRef.template);\n\t\t\t}\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t}\n\n\t\tif (!componentRef.template && /template/g.test(componentRef.encapsulation)) {\n\t\t\tconst template = document.querySelector('#' + componentRef.selector);\n\t\t\tif (template && template instanceof HTMLTemplateElement) {\n\t\t\t\tcomponentRef.template = templateParser.parse(template);\n\t\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t\t} else {\n\t\t\t\t// didn't find this template in 'index.html' document\n\t\t\t}\n\t\t}\n\n\t\tcomponentRef.inputs ||= [];\n\t\tcomponentRef.outputs ||= [];\n\t\tcomponentRef.viewChild ||= [];\n\t\tcomponentRef.ViewChildren ||= [];\n\t\tcomponentRef.hostBindings ||= [];\n\t\tcomponentRef.hostListeners ||= [];\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow-dom/g.test(componentRef.encapsulation);\n\t\tcomponentRef.shadowDomMode ||= 'open';\n\t\tcomponentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;\n\n\t\tif (componentRef.isShadowDom && componentRef.extend.name) {\n\t\t\tcomponentRef.isShadowDom = canAttachShadow(componentRef.extend.name);\n\t\t}\n\n\t\tcomponentRef.modelClass = modelClass;\n\t\tcomponentRef.viewClass = initCustomElementView(modelClass, componentRef);\n\t\tComponents.setComponentRef(componentRef.modelClass, componentRef);\n\t\tComponents.setComponentRef(componentRef.viewClass, componentRef);\n\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(bootstrap.viewClass);\n\n\t\tconst options: ElementDefinitionOptions = {};\n\t\tconst parentTagName = componentRef.extend?.name;\n\t\tif (parentTagName) {\n\t\t\tif (parentTagName !== '!' && parentTagName.indexOf('-') === -1) {\n\t\t\t\toptions.extends = parentTagName;\n\t\t\t}\n\t\t}\n\n\n\t\tcustomElements.define(\n\t\t\tcomponentRef.selector as string,\n\t\t\tcomponentRef.viewClass as CustomElementConstructor,\n\t\t\toptions\n\t\t);\n\n\t}\n}\n"]}
@@ -1,15 +1,10 @@
1
- import { ReactiveScopeControl, ScopeType } from '@ibyar/expressions';
1
+ import { ReactiveScopeControl } from '@ibyar/expressions';
2
+ import { TypeOf } from '@ibyar/expressions/api/utils';
2
3
  export declare class ElementModelReactiveScope<T extends {
3
4
  [key: PropertyKey]: any;
4
5
  }> extends ReactiveScopeControl<T> {
5
- static for<T extends object>(context: T, type: ScopeType): ElementModelReactiveScope<T>;
6
- static blockScopeFor<T extends object>(context: T): ElementModelReactiveScope<T>;
7
- static functionScopeFor<T extends object>(context: T): ElementModelReactiveScope<T>;
8
- static classScopeFor<T extends object>(context: T): ElementModelReactiveScope<T>;
9
- static moduleScopeFor<T extends object>(context: T): ElementModelReactiveScope<T>;
10
- static globalScopeFor<T extends object>(context: T): ElementModelReactiveScope<T>;
11
- private functionProxyMap;
6
+ static for<T extends object>(context: T, propertyKeys?: (keyof T)[]): ElementModelReactiveScope<T>;
12
7
  private contextProxy;
13
8
  getContextProxy(): T;
14
- get(propertyKey: PropertyKey): any;
9
+ getClass(): TypeOf<ElementModelReactiveScope<T>>;
15
10
  }
@@ -1,42 +1,17 @@
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
- static for(context, type) {
9
- return new ElementModelReactiveScope(context, type);
10
- }
11
- static blockScopeFor(context) {
12
- return new ElementModelReactiveScope(context, 'block');
13
- }
14
- static functionScopeFor(context) {
15
- return new ElementModelReactiveScope(context, 'function');
16
- }
17
- static classScopeFor(context) {
18
- return new ElementModelReactiveScope(context, 'class');
19
- }
20
- static moduleScopeFor(context) {
21
- return new ElementModelReactiveScope(context, 'module');
22
- }
23
- static globalScopeFor(context) {
24
- return new ElementModelReactiveScope(context, 'global');
7
+ static for(context, propertyKeys) {
8
+ return new ElementModelReactiveScope(context, propertyKeys);
25
9
  }
26
10
  getContextProxy() {
27
11
  return this.contextProxy;
28
12
  }
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;
13
+ getClass() {
14
+ return ElementModelReactiveScope;
40
15
  }
41
16
  }
42
17
  //# 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,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AAY,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,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGjF,MAAM,OAAO,yBAAiE,SAAQ,oBAAuB;IAA7G;;QAIS,iBAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAOpD,CAAC;IAVA,MAAM,CAAC,GAAG,CAAmB,OAAU,EAAE,YAA0B;QAClE,OAAO,IAAI,yBAAyB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC7D,CAAC;IAED,eAAe;QACd,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IACD,QAAQ;QACP,OAAO,yBAAyB,CAAC;IAClC,CAAC;CACD","sourcesContent":["import { createProxyForContext, ReactiveScopeControl } from '@ibyar/expressions';\nimport { TypeOf } from '@ibyar/expressions/api/utils';\n\nexport class ElementModelReactiveScope<T extends { [key: PropertyKey]: any }> extends ReactiveScopeControl<T> {\n\tstatic for<T extends object>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ElementModelReactiveScope(context, propertyKeys);\n\t}\n\tprivate contextProxy = createProxyForContext(this);\n\tgetContextProxy(): T {\n\t\treturn this.contextProxy;\n\t}\n\tgetClass(): TypeOf<ElementModelReactiveScope<T>> {\n\t\treturn ElementModelReactiveScope;\n\t}\n}\n"]}
package/context/stack.js CHANGED
@@ -60,7 +60,7 @@ const Constant = {
60
60
  String,
61
61
  Number,
62
62
  };
63
- const CONSTANT_SCOPE = new ReadOnlyScope(Constant, 'block');
63
+ const CONSTANT_SCOPE = new ReadOnlyScope(Constant);
64
64
  export const documentStack = new Stack([
65
65
  CONSTANT_SCOPE,
66
66
  new PipeProvider(),
@@ -1 +1 @@
1
- {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/core/context/stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,QAAQ,G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IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;KACf;IAED,MAAM;IAEN,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,GAAG;IACH,KAAK;IACL,QAAQ;IAER,KAAK,EAAE;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;KACtB;IACD,MAAM;IACN,MAAM;IACN,MAAM;CACN,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,KAAK,CACrC;IACC,cAAc;IACd,IAAI,YAAY,EAAE;IAClB,IAAI,iBAAiB,EAAE;CACvB,CACD,CAAC","sourcesContent":["import { ReadOnlyScope, Scope, Stack } from '@ibyar/expressions';\nimport { PipeProvider, AsyncPipeProvider } from '../pipe/pipe.js';\n\nconst Constant: { [k: string]: any } = {\n\t// math\n\tMath: {\n\t\tE: Math.E,\n\t\tLN10: Math.LN10,\n\t\tLN2: Math.LN2,\n\t\tLOG10E: Math.LOG10E,\n\t\tLOG2E: Math.LOG2E,\n\t\tPI: Math.PI,\n\t\tSQRT1_2: Math.SQRT1_2,\n\t\tSQRT2: Math.SQRT2,\n\n\t\tabs: Math.abs,\n\t\tacos: Math.acos,\n\t\tasin: Math.asin,\n\t\tatan: Math.atan,\n\t\tatan2: Math.atan2,\n\t\tceil: Math.ceil,\n\t\tcos: Math.cos,\n\t\texp: Math.exp,\n\t\tfloor: Math.floor,\n\t\tlog: Math.log,\n\t\tmax: Math.max,\n\t\tmin: Math.min,\n\t\tpow: Math.pow,\n\t\trandom: Math.random,\n\t\tround: Math.round,\n\t\tsin: Math.sin,\n\t\tsqrt: Math.sqrt,\n\t\ttan: Math.tan,\n\t\tclz32: Math.clz32,\n\t\timul: Math.imul,\n\t\tsign: Math.sign,\n\t\tlog10: Math.log10,\n\t\tlog2: Math.log2,\n\t\tlog1p: Math.log1p,\n\t\texpm1: Math.expm1,\n\t\tcosh: Math.cosh,\n\t\tsinh: Math.sinh,\n\t\ttanh: Math.tanh,\n\t\tacosh: Math.acosh,\n\t\tasinh: Math.asinh,\n\t\tatanh: Math.atanh,\n\t\thypot: Math.hypot,\n\t\ttrunc: Math.trunc,\n\t\tfround: Math.fround,\n\t\tcbrt: Math.cbrt,\n\t},\n\t// object\n\tObject,\n\t// number\n\tparseFloat,\n\tparseInt,\n\tInfinity,\n\tNaN,\n\tisNaN,\n\tisFinite,\n\t// array\n\tArray: {\n\t\tisArray: Array.isArray,\n\t},\n\tSymbol,\n\tString,\n\tNumber,\n};\n\nconst CONSTANT_SCOPE = new ReadOnlyScope(Constant, 'block');\nexport const documentStack = new Stack(\n\t[\n\t\tCONSTANT_SCOPE,\n\t\tnew PipeProvider(),\n\t\tnew AsyncPipeProvider()\n\t]\n);\n"]}
1
+ {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/core/context/stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,QAAQ,GAAyB;IAEtC,IAAI,EAAE;QACL,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,EAAE,EAAE,IAAI,CAAC,EA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AAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;KACf;IAED,MAAM;IAEN,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,GAAG;IACH,KAAK;IACL,QAAQ;IAER,KAAK,EAAE;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;KACtB;IACD,MAAM;IACN,MAAM;IACN,MAAM;CACN,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,KAAK,CACrC;IACC,cAAc;IACd,IAAI,YAAY,EAAE;IAClB,IAAI,iBAAiB,EAAE;CACvB,CACD,CAAC","sourcesContent":["import { ReadOnlyScope, Scope, Stack } from '@ibyar/expressions';\nimport { PipeProvider, AsyncPipeProvider } from '../pipe/pipe.js';\n\nconst Constant: { [k: string]: any } = {\n\t// math\n\tMath: {\n\t\tE: Math.E,\n\t\tLN10: Math.LN10,\n\t\tLN2: Math.LN2,\n\t\tLOG10E: Math.LOG10E,\n\t\tLOG2E: Math.LOG2E,\n\t\tPI: Math.PI,\n\t\tSQRT1_2: Math.SQRT1_2,\n\t\tSQRT2: Math.SQRT2,\n\n\t\tabs: Math.abs,\n\t\tacos: Math.acos,\n\t\tasin: Math.asin,\n\t\tatan: Math.atan,\n\t\tatan2: Math.atan2,\n\t\tceil: Math.ceil,\n\t\tcos: Math.cos,\n\t\texp: Math.exp,\n\t\tfloor: Math.floor,\n\t\tlog: Math.log,\n\t\tmax: Math.max,\n\t\tmin: Math.min,\n\t\tpow: Math.pow,\n\t\trandom: Math.random,\n\t\tround: Math.round,\n\t\tsin: Math.sin,\n\t\tsqrt: Math.sqrt,\n\t\ttan: Math.tan,\n\t\tclz32: Math.clz32,\n\t\timul: Math.imul,\n\t\tsign: Math.sign,\n\t\tlog10: Math.log10,\n\t\tlog2: Math.log2,\n\t\tlog1p: Math.log1p,\n\t\texpm1: Math.expm1,\n\t\tcosh: Math.cosh,\n\t\tsinh: Math.sinh,\n\t\ttanh: Math.tanh,\n\t\tacosh: Math.acosh,\n\t\tasinh: Math.asinh,\n\t\tatanh: Math.atanh,\n\t\thypot: Math.hypot,\n\t\ttrunc: Math.trunc,\n\t\tfround: Math.fround,\n\t\tcbrt: Math.cbrt,\n\t},\n\t// object\n\tObject,\n\t// number\n\tparseFloat,\n\tparseInt,\n\tInfinity,\n\tNaN,\n\tisNaN,\n\tisFinite,\n\t// array\n\tArray: {\n\t\tisArray: Array.isArray,\n\t},\n\tSymbol,\n\tString,\n\tNumber,\n};\n\nconst CONSTANT_SCOPE = new ReadOnlyScope(Constant);\nexport const documentStack = new Stack(\n\t[\n\t\tCONSTANT_SCOPE,\n\t\tnew PipeProvider(),\n\t\tnew AsyncPipeProvider()\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"]}
@@ -16,7 +16,7 @@ export declare class DirectiveExpressionParser {
16
16
  protected check(token: Token): boolean;
17
17
  protected consumeToList(token: Token, list: TokenExpression[]): void;
18
18
  protected consumeIfToken(token: Token, list: TokenExpression[]): boolean;
19
- protected isLet(): boolean;
19
+ protected isDeclareKeyword(): boolean;
20
20
  protected isIdentifier(): boolean;
21
21
  protected isAsKeyword(): boolean;
22
22
  protected consumeAsKeyword(): void;
@@ -31,7 +31,7 @@ export class DirectiveExpressionParser {
31
31
  };
32
32
  }
33
33
  scan() {
34
- if (this.isLet()) {
34
+ if (this.isDeclareKeyword()) {
35
35
  this.parseTemplateInput();
36
36
  }
37
37
  else {
@@ -75,8 +75,9 @@ export class DirectiveExpressionParser {
75
75
  this.stream.next();
76
76
  return true;
77
77
  }
78
- isLet() {
79
- return this.stream.peek().isType(Token.LET);
78
+ isDeclareKeyword() {
79
+ const peek = this.stream.peek();
80
+ return peek.isType(Token.LET) || peek.isType(Token.CONST) || peek.isType(Token.VAR);
80
81
  }
81
82
  isIdentifier() {
82
83
  return this.stream.peek().isType(Token.IDENTIFIER);
@@ -102,21 +103,22 @@ export class DirectiveExpressionParser {
102
103
  }
103
104
  }
104
105
  parseTemplateInput() {
105
- if (this.isLet()) {
106
- const list = [];
107
- this.consumeToList(Token.LET, list);
108
- const peek = this.stream.peek();
109
- if (Token.isOpenPair(peek.token) && peek.isNotType(Token.L_PARENTHESES)) {
106
+ if (this.isDeclareKeyword()) {
107
+ let peek = this.stream.peek();
108
+ const list = [peek];
109
+ this.consume(peek.token);
110
+ peek = this.stream.peek();
111
+ if (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {
110
112
  this.stream.readTill(Token.closeOf(peek.token), list);
111
113
  }
112
114
  else if (peek.isType(Token.IDENTIFIER)) {
113
115
  this.consumeToList(Token.IDENTIFIER, list);
114
116
  }
115
117
  else {
116
- throw new Error(this.stream.createError(`Can't parse let {IDENTIFIER/ObjectPattern}`));
118
+ throw new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));
117
119
  }
118
120
  if (this.consumeIfToken(Token.ASSIGN, list)) {
119
- this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);
121
+ this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);
120
122
  }
121
123
  else {
122
124
  list.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);
@@ -152,8 +154,9 @@ export class DirectiveExpressionParser {
152
154
  this.templateExpressions.push(aliasList);
153
155
  return;
154
156
  }
157
+ this.check(Token.ASSIGN) || this.check(Token.COLON);
155
158
  const list = [];
156
- this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);
159
+ this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);
157
160
  if (this.isAsKeyword()) {
158
161
  this.consumeAsKeyword();
159
162
  const aliasToken = this.stream.next();