@ibyar/core 0.5.2 → 0.5.62

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 (64) hide show
  1. package/LICENSE +1 -1
  2. package/annotation/decorators.d.ts +97 -0
  3. package/binding/binding.expressions.d.ts +8 -2
  4. package/binding/binding.expressions.js +48 -15
  5. package/binding/binding.expressions.js.map +1 -1
  6. package/component/component.js +9 -8
  7. package/component/component.js.map +1 -1
  8. package/component/custom-element.d.ts +42 -0
  9. package/component/provider.d.ts +4 -7
  10. package/component/provider.js +5 -17
  11. package/component/provider.js.map +1 -1
  12. package/context/stack.js +5 -1
  13. package/context/stack.js.map +1 -1
  14. package/directive/directive.d.ts +9 -0
  15. package/directive/directive.js +9 -0
  16. package/directive/directive.js.map +1 -1
  17. package/directive/parser.d.ts +5 -1
  18. package/directive/parser.js +33 -11
  19. package/directive/parser.js.map +1 -1
  20. package/directive/providers.d.ts +2 -0
  21. package/directive/providers.js +4 -1
  22. package/directive/providers.js.map +1 -1
  23. package/html/expression.d.ts +5 -0
  24. package/html/expression.js +22 -10
  25. package/html/expression.js.map +1 -1
  26. package/linker/change-detector-ref.d.ts +14 -0
  27. package/linker/change-detector-ref.js +3 -0
  28. package/linker/change-detector-ref.js.map +1 -1
  29. package/linker/template-ref.d.ts +12 -0
  30. package/linker/template-ref.js +4 -2
  31. package/linker/template-ref.js.map +1 -1
  32. package/linker/view-container-ref.d.ts +78 -0
  33. package/linker/view-container-ref.js +4 -3
  34. package/linker/view-container-ref.js.map +1 -1
  35. package/linker/view-ref.d.ts +39 -0
  36. package/package.json +6 -6
  37. package/pipe/pipe.d.ts +10 -0
  38. package/pipe/pipe.js +14 -4
  39. package/pipe/pipe.js.map +1 -1
  40. package/providers/injector.js +1 -0
  41. package/providers/injector.js.map +1 -1
  42. package/providers/provider.js +2 -0
  43. package/providers/provider.js.map +1 -1
  44. package/render/host-listener.handler.d.ts +43 -0
  45. package/render/host-listener.handler.js +86 -0
  46. package/render/host-listener.handler.js.map +1 -0
  47. package/render/render-handler.d.ts +11 -0
  48. package/render/render-handler.js +2 -0
  49. package/render/render-handler.js.map +1 -0
  50. package/utils/typeof.d.ts +3 -0
  51. package/utils/utils.js +1 -0
  52. package/utils/utils.js.map +1 -1
  53. package/view/base-view.js +15 -9
  54. package/view/base-view.js.map +1 -1
  55. package/view/form-view.js +21 -0
  56. package/view/form-view.js.map +1 -1
  57. package/view/mutation.js +1 -0
  58. package/view/mutation.js.map +1 -1
  59. package/view/render.d.ts +1 -2
  60. package/view/render.js +59 -53
  61. package/view/render.js.map +1 -1
  62. package/view/view.d.ts +5 -0
  63. package/view/view.js +7 -0
  64. 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
@@ -12,15 +12,112 @@ export interface PipeOptions {
12
12
  asynchronous?: boolean;
13
13
  }
14
14
  export interface ComponentOptions<T = Function> {
15
+ /**
16
+ * a tag name for the component,
17
+ * if the tag name is valid custom element name, the view class will be a custom element,
18
+ * otherwise an HTMLUnknownElement will be created
19
+ */
15
20
  selector: string;
21
+ /**
22
+ * add html file url path to fetch,
23
+ * templateUrl had propriety than template, and will override it.
24
+ *
25
+ * Can provide file name as "person-view.html" will resolved
26
+ * as 'http://site-address.org/persin-view.html',
27
+ *
28
+ * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }
29
+ * let (import.meta = '/person/person.js') will resolved
30
+ * as 'http://site-address.org/person/person-edit.html',
31
+ *
32
+ * OR as an object { moduleMeta: import.meta }
33
+ * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.
34
+ *
35
+ * if url not found, component will not be defined,
36
+ *
37
+ * if you didn't use webpack or rollup.js or any bundler,
38
+ * you should copy the html files to its folder by yourself.
39
+ */
16
40
  templateUrl?: TemplateUrl | string;
41
+ /**
42
+ * template: typeof 'string' ==> html string,
43
+ * TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory
44
+ * if template === null || undefined ==> it had nothing to render,
45
+ * and may be inherit from an html element
46
+ *
47
+ * 2 possible way to write a template, as inline string, represent a a valid html,
48
+ * or us aurora jsx factory
49
+ *
50
+ */
17
51
  template?: string | DomNode | DomRenderNode<T> | Promise<string>;
52
+ /**
53
+ * style for this element
54
+ */
18
55
  styles?: string | {
19
56
  [key: string]: string;
20
57
  }[];
58
+ /**
59
+ * what basic element should the new component inherit from,
60
+ * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...
61
+ */
21
62
  extend?: string;
63
+ /**
64
+ * An encapsulation policy for the template and CSS styles. One of:
65
+ * 'custom': Use global CSS without any encapsulation.
66
+ * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.
67
+ *
68
+ * 'template': like 'custom', with load the template from the document ('index.html' file)
69
+ * that had the same id as the component "selector".
70
+ * 'shadow-dom-template': like 'shadowDom', and load template by selector id.
71
+ *
72
+ * Both 'template' & 'shadow-dom-template' encapsulation type:
73
+ * should had attributes name like lowercase,
74
+ * the browser itself, will convert all attributes to lowercase
75
+ *
76
+ * ```typescript
77
+ * @Input('personage') personAge: number;
78
+ * @Input('propname') propName: string;
79
+ * @Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();
80
+ * @View('personform') personForm: HTMLFormElement;
81
+ * ```
82
+ *
83
+ * any root element as
84
+ *
85
+ * ```html
86
+ * <root-app></root-app>
87
+ * ```
88
+ *
89
+ * the supported bind options is 'One way binding *(as passing data only)'
90
+ * and 'template parsing' and 'event binding' syntax, HTML (angular) like.
91
+ * it load its attributes from 'window object'
92
+ *
93
+ * so to pass date to A root element,
94
+ *
95
+ * ```html
96
+ * <script>
97
+ * let appVersion = '0.1.504';
98
+ * function onRootAppClick() {
99
+ * console.log('root app clicked');
100
+ * }
101
+ * function onSave(data){
102
+ * console.log('root app save', data);
103
+ * }
104
+ * </script>
105
+ * <root-app [version]="appVersion"
106
+ * onclick="onRootAppClick()"
107
+ * (save)="onSave()" ></root-app>
108
+ * ```
109
+ *
110
+ * default is 'custom'
111
+ * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}
112
+ */
22
113
  encapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';
114
+ /**
115
+ * default: 'open'
116
+ */
23
117
  shadowDomMode?: ShadowRootMode;
118
+ /**
119
+ * default: false
120
+ */
24
121
  shadowDomDelegatesFocus?: boolean;
25
122
  }
26
123
  export interface ChildOptions {
@@ -1,17 +1,23 @@
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;
12
13
  get(stack: Stack): any;
13
14
  subscribe(stack: Stack, pipelineNames?: string[]): ScopeSubscription<ScopeContext>[];
14
15
  }
16
+ /**
17
+ * the default behavior is assign the right hand side to the left hand side.
18
+ *
19
+ *
20
+ */
15
21
  export declare class TwoWayAssignmentExpression extends InfixExpressionNode<TwoWayOperator> implements BindingAssignment {
16
22
  protected left: MemberExpression;
17
23
  protected right: MemberExpression | Identifier;
@@ -1,8 +1,11 @@
1
- import { InfixExpressionNode, findReactiveScopeByEventMap, 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,36 +17,55 @@ 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
43
  const tuples = findReactiveScopeByEventMap(this.rightEvents, stack);
34
- const subscriptions = [];
44
+ const callback = (newValue, oldValue) => {
45
+ stack.detach();
46
+ this.get(stack);
47
+ stack.reattach();
48
+ };
35
49
  tuples.forEach(tuple => {
36
- const subscription = tuple[1].subscribe(tuple[0], (newValue, oldValue) => {
37
- this.get(stack);
38
- });
50
+ const subscription = tuple[1].subscribe(tuple[0], callback);
39
51
  subscriptions.push(subscription);
40
52
  });
41
53
  return subscriptions;
42
54
  }
43
- }
44
- export class TwoWayAssignmentExpression extends InfixExpressionNode {
55
+ };
56
+ OneWayAssignmentExpression = __decorate([
57
+ Deserializer('OneWayAssignment'),
58
+ __metadata("design:paramtypes", [MemberExpression, Object])
59
+ ], OneWayAssignmentExpression);
60
+ export { OneWayAssignmentExpression };
61
+ /**
62
+ * the default behavior is assign the right hand side to the left hand side.
63
+ *
64
+ *
65
+ */
66
+ let TwoWayAssignmentExpression = class TwoWayAssignmentExpression extends InfixExpressionNode {
45
67
  constructor(left, right) {
46
- super(':=:', left, right);
68
+ super(':=', left, right);
47
69
  this.rightEvents = this.right.events();
48
70
  this.leftEvents = this.left.events();
49
71
  }
@@ -63,7 +85,9 @@ export class TwoWayAssignmentExpression extends InfixExpressionNode {
63
85
  }
64
86
  actionRTL(stack) {
65
87
  return (newValue, oldValue) => {
88
+ stack.detach();
66
89
  this.getRTL(stack);
90
+ stack.reattach();
67
91
  };
68
92
  }
69
93
  setLTR(stack, value) {
@@ -76,7 +100,9 @@ export class TwoWayAssignmentExpression extends InfixExpressionNode {
76
100
  }
77
101
  actionLTR(stack) {
78
102
  return (newValue, oldValue) => {
103
+ stack.detach();
79
104
  this.getLTR(stack);
105
+ stack.reattach();
80
106
  };
81
107
  }
82
108
  subscribeToEvents(stack, tuples, actionCallback) {
@@ -88,13 +114,20 @@ export class TwoWayAssignmentExpression extends InfixExpressionNode {
88
114
  return subscriptions;
89
115
  }
90
116
  subscribe(stack) {
117
+ // right to left
91
118
  const rightTuples = findReactiveScopeByEventMap(this.rightEvents, stack);
92
119
  const rtlAction = this.actionRTL(stack);
93
120
  const rtlSubscriptions = this.subscribeToEvents(stack, rightTuples, rtlAction);
121
+ // left to right
94
122
  const leftTuples = findReactiveScopeByEventMap(this.leftEvents, stack);
95
123
  const ltrAction = this.actionLTR(stack);
96
124
  const ltrSubscriptions = this.subscribeToEvents(stack, leftTuples, ltrAction);
97
125
  return rtlSubscriptions.concat(ltrSubscriptions);
98
126
  }
99
- }
127
+ };
128
+ TwoWayAssignmentExpression = __decorate([
129
+ Deserializer('TwoWayAssignment'),
130
+ __metadata("design:paramtypes", [MemberExpression, Object])
131
+ ], TwoWayAssignmentExpression);
132
+ export { TwoWayAssignmentExpression };
100
133
  //# 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,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,CAAC;QACpB,OAAO,EAAE,CAAC;IACX,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C;IACO,SAAS,CAAC,KAAY;QAC7B,OAAO,CAAC,QAAa,EAAE,QAAc,EAAE,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC;IACH,CAAC;IAEO,iBAAiB,CAAC,KAAY,EAAE,MAA+C,EAAE,cAAoC;QAC5H,MAAM,aAAa,GAAsC,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","sourcesContent":["import {\n\tExpressionNode, InfixExpressionNode, ScopeSubscription,\n\tStack, findReactiveScopeByEventMap, 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 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"]}
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,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,CAAC;QACpB,OAAO,EA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,aAAa,CAAC;IACtB,CAAC;IAED,SAAS,CAAC,KAAY;QAErB,gBAAgB;QAChB,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;QAE/E,iBAAiB;QACjB,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"]}
@@ -140,17 +140,18 @@ export class Components {
140
140
  buildExpressionNodes(componentRef.template);
141
141
  }
142
142
  else {
143
+ // didn't find this template in 'index.html' document
143
144
  }
144
145
  }
145
- componentRef.inputs ||= [];
146
- componentRef.outputs ||= [];
147
- componentRef.viewChild ||= [];
148
- componentRef.ViewChildren ||= [];
149
- componentRef.hostBindings ||= [];
150
- componentRef.hostListeners ||= [];
151
- componentRef.encapsulation ||= 'custom';
146
+ componentRef.inputs || (componentRef.inputs = []);
147
+ componentRef.outputs || (componentRef.outputs = []);
148
+ componentRef.viewChild || (componentRef.viewChild = []);
149
+ componentRef.ViewChildren || (componentRef.ViewChildren = []);
150
+ componentRef.hostBindings || (componentRef.hostBindings = []);
151
+ componentRef.hostListeners || (componentRef.hostListeners = []);
152
+ componentRef.encapsulation || (componentRef.encapsulation = 'custom');
152
153
  componentRef.isShadowDom = /shadow-dom/g.test(componentRef.encapsulation);
153
- componentRef.shadowDomMode ||= 'open';
154
+ componentRef.shadowDomMode || (componentRef.shadowDomMode = 'open');
154
155
  componentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;
155
156
  if (componentRef.isShadowDom && componentRef.extend.name) {
156
157
  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,YAAY,CAAQ;QAAS,qBAAgB,GAAhB,gBAAgB,CAAQ;IAAI,CAAC;CAC7E;AAuDD,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AACvD,MAAM,cAAc,GAAG,MAAM,CAAC,GA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C,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,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,IA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AAC,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"]}
@@ -41,10 +41,52 @@ export declare function isHTMLComponent(object: any): object is HTMLComponent<an
41
41
  export declare function isHTMLComponentOfType<T extends object>(object: any, typeClass: TypeOf<T>): object is HTMLComponent<T>;
42
42
  export declare function isHTMLElement(element: HTMLElement): element is HTMLElement;
43
43
  export declare function isHTMLUnknownElement(element: HTMLElement): element is HTMLElement;
44
+ /**
45
+ * Lifecycle callbacks
46
+ * A map, whose keys are the strings "connectedCallback", "disconnectedCallback", "adoptedCallback", "attributeChangedCallback",
47
+ * "formAssociatedCallback", "formDisabledCallback", "formResetCallback", and "formStateRestoreCallback"
48
+ * https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-lifecycle-callbacks
49
+ *
50
+ * A form-associated custom element API includes a set of extra lifecycle callbacks to tie in to the form lifecycle.
51
+ * The callbacks are optional: only implement a callback if your element needs to do something at that point in the lifecycle.
52
+ * https://html.spec.whatwg.org/multipage/custom-elements.html#the-elementinternals-interface
53
+ * https://docs.google.com/document/d/1JO8puctCSpW-ZYGU8lF-h4FWRIDQNDVexzHoOQ2iQmY/edit
54
+ */
44
55
  export interface CustomFormElement extends CustomElement {
56
+ /**
57
+ * Called when the browser associates the element with a form element,
58
+ * or disassociates the element from a form element.
59
+ * @param form
60
+ */
45
61
  formAssociatedCallback(form: HTMLFormElement): void;
62
+ /**
63
+ * Called after the disabled state of the element changes,
64
+ * either because the disabled attribute of this element was added or removed;
65
+ * or because the disabled state changed on a <fieldset> that's an ancestor of this element.
66
+ * The disabled parameter represents the new disabled state of the element.
67
+ * The element may, for example, disable elements in its shadow DOM when it is disabled.
68
+ * @param disabled
69
+ */
46
70
  formDisabledCallback(disabled: boolean): void;
71
+ /**
72
+ * Called after the form is reset.
73
+ * The element should reset itself to some kind of default state.
74
+ * For <input> elements, this usually involves setting the value property to
75
+ * match the value attribute set in markup (or in the case of a checkbox,
76
+ * setting the checked property to match the checked attribute.
77
+ */
47
78
  formResetCallback(): void;
79
+ /**
80
+ * Called in one of two circumstances:
81
+ * When the browser restores the state of the element (for example, after a navigation, or when the browser restarts).
82
+ * The mode argument is "restore" in this case.
83
+ *
84
+ * When the browser's input-assist features such as form autofilling sets a value.
85
+ * The mode argument is "autocomplete" in this case.
86
+ *
87
+ * The type of the first argument depends on how the setFormValue() method was called.
88
+ * For more details, see Restoring form state.
89
+ */
48
90
  formStateRestoreCallback(value: any, mode: 'restore' | 'autocomplete'): void;
49
91
  }
50
92
  export interface BaseFormElementComponent<T extends Object> extends BaseComponent<T>, CustomFormElement {
@@ -1,13 +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>;
6
+ static for<T extends object>(context: T, propertyKeys?: (keyof T)[]): ElementModelReactiveScope<T>;
11
7
  private contextProxy;
12
8
  getContextProxy(): T;
9
+ getClass(): TypeOf<ElementModelReactiveScope<T>>;
13
10
  }
@@ -4,26 +4,14 @@ export class ElementModelReactiveScope extends ReactiveScopeControl {
4
4
  super(...arguments);
5
5
  this.contextProxy = createProxyForContext(this);
6
6
  }
7
- static for(context, type) {
8
- return new ElementModelReactiveScope(context, type);
9
- }
10
- static blockScopeFor(context) {
11
- return new ElementModelReactiveScope(context, 'block');
12
- }
13
- static functionScopeFor(context) {
14
- return new ElementModelReactiveScope(context, 'function');
15
- }
16
- static classScopeFor(context) {
17
- return new ElementModelReactiveScope(context, 'class');
18
- }
19
- static moduleScopeFor(context) {
20
- return new ElementModelReactiveScope(context, 'module');
21
- }
22
- static globalScopeFor(context) {
23
- return new ElementModelReactiveScope(context, 'global');
7
+ static for(context, propertyKeys) {
8
+ return new ElementModelReactiveScope(context, propertyKeys);
24
9
  }
25
10
  getContextProxy() {
26
11
  return this.contextProxy;
27
12
  }
13
+ getClass() {
14
+ return ElementModelReactiveScope;
15
+ }
28
16
  }
29
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,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"]}
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
@@ -1,6 +1,7 @@
1
1
  import { ReadOnlyScope, Stack } from '@ibyar/expressions';
2
2
  import { PipeProvider, AsyncPipeProvider } from '../pipe/pipe.js';
3
3
  const Constant = {
4
+ // math
4
5
  Math: {
5
6
  E: Math.E,
6
7
  LN10: Math.LN10,
@@ -46,13 +47,16 @@ const Constant = {
46
47
  fround: Math.fround,
47
48
  cbrt: Math.cbrt,
48
49
  },
50
+ // object
49
51
  Object,
52
+ // number
50
53
  parseFloat,
51
54
  parseInt,
52
55
  Infinity,
53
56
  NaN,
54
57
  isNaN,
55
58
  isFinite,
59
+ // array
56
60
  Array: {
57
61
  isArray: Array.isArray,
58
62
  },
@@ -60,7 +64,7 @@ const Constant = {
60
64
  String,
61
65
  Number,
62
66
  };
63
- const CONSTANT_SCOPE = new ReadOnlyScope(Constant, 'block');
67
+ const CONSTANT_SCOPE = new ReadOnlyScope(Constant);
64
68
  export const documentStack = new Stack([
65
69
  CONSTANT_SCOPE,
66
70
  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,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,EAAE;QACX,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QAEjB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,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AO,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;IACtC,OAAO;IACP,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,EAAE;QACX,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QAEjB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,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;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"]}
@@ -1,16 +1,25 @@
1
1
  import { HTMLComponent } from '../component/custom-element.js';
2
2
  import { TemplateRef } from '../linker/template-ref.js';
3
3
  import { ViewContainerRef } from '../linker/view-container-ref.js';
4
+ /**
5
+ * A structural directive selector as '*if' '*for'
6
+ */
4
7
  export declare class StructuralDirective {
5
8
  protected templateRef: TemplateRef;
6
9
  protected viewContainerRef: ViewContainerRef;
7
10
  protected host: HTMLComponent<any> | StructuralDirective;
8
11
  constructor(templateRef: TemplateRef, viewContainerRef: ViewContainerRef, host: HTMLComponent<any> | StructuralDirective);
9
12
  }
13
+ /**
14
+ * An attributes directive selector as '[class] [style]'
15
+ */
10
16
  export declare class AttributeDirective {
11
17
  protected el: HTMLElement;
12
18
  constructor(el: HTMLElement);
13
19
  }
20
+ /**
21
+ * An attributes directive on structural directive
22
+ */
14
23
  export declare class AttributeOnStructuralDirective {
15
24
  protected directive: StructuralDirective;
16
25
  constructor(directive: StructuralDirective);