@ibyar/core 0.2.0 → 0.3.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 (50) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +18 -0
  3. package/annotation/decorators.d.ts +1 -1
  4. package/annotation/decorators.js +12 -2
  5. package/annotation/decorators.js.map +1 -1
  6. package/component/component.d.ts +4 -0
  7. package/component/component.js +45 -24
  8. package/component/component.js.map +1 -1
  9. package/component/custom-element.d.ts +6 -0
  10. package/component/custom-element.js.map +1 -1
  11. package/component/events.d.ts +1 -1
  12. package/component/events.js +11 -11
  13. package/component/events.js.map +1 -1
  14. package/component/provider.d.ts +12 -0
  15. package/component/provider.js +29 -0
  16. package/component/provider.js.map +1 -0
  17. package/context/stack.d.ts +2 -18
  18. package/context/stack.js +9 -48
  19. package/context/stack.js.map +1 -1
  20. package/directive/directive.d.ts +5 -4
  21. package/directive/directive.js +3 -0
  22. package/directive/directive.js.map +1 -1
  23. package/directive/providers.d.ts +7 -4
  24. package/directive/providers.js +3 -5
  25. package/directive/providers.js.map +1 -1
  26. package/html/expression.js +24 -12
  27. package/html/expression.js.map +1 -1
  28. package/html/update.d.ts +12 -0
  29. package/html/update.js +24 -0
  30. package/html/update.js.map +1 -0
  31. package/index.d.ts +1 -0
  32. package/index.js +1 -0
  33. package/index.js.map +1 -1
  34. package/package.json +11 -8
  35. package/pipe/pipe.d.ts +3 -3
  36. package/pipe/pipe.js +5 -5
  37. package/pipe/pipe.js.map +1 -1
  38. package/providers/injector.js.map +1 -1
  39. package/providers/provider.js +9 -9
  40. package/providers/provider.js.map +1 -1
  41. package/view/base-view.js +43 -28
  42. package/view/base-view.js.map +1 -1
  43. package/view/form-view.js +1 -1
  44. package/view/form-view.js.map +1 -1
  45. package/view/render.d.ts +15 -13
  46. package/view/render.js +65 -35
  47. package/view/render.js.map +1 -1
  48. package/view/view.d.ts +2 -1
  49. package/view/view.js +26 -33
  50. 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/aurora
3
+ Copyright (c) 2020-2021 @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
package/README.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Aurora Core
2
2
 
3
+ [![NPM Version][npm-image]][npm-url]
4
+ [![NPM Downloads][downloads-image]][downloads-url]
5
+ [![LICENSE][license-img]][license-url]
6
+ ![npm-dependencies][npm-dep-url]
7
+ [![lerna][lerna-img]][lerna-url]
8
+ ![GitHub contributors][contributors]
9
+
10
+ [npm-image]: https://img.shields.io/npm/v/@ibyar/core.svg
11
+ [npm-url]: https://npmjs.org/package/@ibyar/core
12
+ [downloads-image]: https://img.shields.io/npm/dt/@ibyar/core
13
+ [downloads-url]: https://npmjs.org/package/@ibyar/core
14
+ [license-img]: https://img.shields.io/github/license/ibyar/aurora
15
+ [license-url]: https://github.com/ibyar/aurora/blob/master/LICENSE
16
+ [npm-dep-url]: https://img.shields.io/david/ibyar/aurora?path=packages%2Fcore
17
+ [lerna-img]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg
18
+ [lerna-url]: https://lerna.js.org/
19
+ [contributors]: https://img.shields.io/github/contributors/ibyar/aurora
20
+
3
21
  Aurora API is the base of this project
4
22
  Implements Aurora's core functionality, low-level services, and utilities.
5
23
  - Defines the class infrastructure for components, view, model change detection, rendering, and event handling.
@@ -15,7 +15,7 @@ export interface PipeOptions {
15
15
  export interface ComponentOptions<T = Function> {
16
16
  selector: string;
17
17
  templateUrl?: TemplateUrl | string;
18
- template?: string | DOMNode<ExpressionNode> | DOMRenderNode<T, ExpressionNode>;
18
+ template?: string | DOMNode<ExpressionNode> | DOMRenderNode<T, ExpressionNode> | Promise<string>;
19
19
  styles?: string | {
20
20
  [key: string]: string;
21
21
  }[];
@@ -75,12 +75,22 @@ export function Component(opt) {
75
75
  }
76
76
  export function SelfSkip(name) {
77
77
  return (target, propertyKey, index) => {
78
- Reflect.defineMetadata('selfskip', { name, index }, target, propertyKey);
78
+ let metadata = Reflect.getMetadata('selfskip', target, propertyKey);
79
+ if (!metadata) {
80
+ metadata = {};
81
+ Reflect.defineMetadata('selfskip', metadata, target, propertyKey);
82
+ }
83
+ metadata[index] = name;
79
84
  };
80
85
  }
81
86
  export function Optional() {
82
87
  return (target, propertyKey, index) => {
83
- Reflect.defineMetadata('optional', { index }, target, propertyKey);
88
+ let metadata = Reflect.getMetadata('optional', target, propertyKey);
89
+ if (!metadata) {
90
+ metadata = {};
91
+ Reflect.defineMetadata('optional', metadata, target, propertyKey);
92
+ }
93
+ metadata[index] = true;
84
94
  };
85
95
  }
86
96
  //# sourceMappingURL=decorators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAe,MAAM,kBAAkB,CAAC;AAwI1D,MAAM,UAAU,KAAK,CAAC,IAAa;IAClC,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC;IAC/D,CAAC,CAAC;AACH,CAAC;AACD,MAAM,UAAU,MAAM,CAAC,IAAa;IACnC,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC;IAChE,CAAC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,IAAI;IACnB,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,UAAU,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC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,WAAW,CAAC,CAAC;IACpE,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport type { ExpressionNode } from '@ibyar/expressions';\nimport { DOMNode, DOMRenderNode } from '@ibyar/elements';\nimport { Components } from '../component/component.js';\nimport { fetchHtml, TemplateUrl } from '../utils/path.js';\n\nexport interface DirectiveOptions {\n\tselector: string;\n}\n\nexport interface ServiceOptions {\n\tprovideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Function> {\n\t/**\n\t * a tag name for the component,\n\t * if the tag name is valid custom element name, the view class will be a custom element,\n\t * otherwise an HTMLUnknownElement will be created\n\t */\n\tselector: string;\n\n\t/**\n\t * add html file url path to fetch,\n\t * templateUrl had propriety than template, and will override it.\n\t *\n\t * Can provide file name as \"person-view.html\" will resolved \n\t * as 'http://site-address.org/persin-view.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }\n\t * let (import.meta = '/person/person.js') will resolved \n\t * as 'http://site-address.org/person/person-edit.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta }\n\t * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.\n\t * \n\t * if url not found, component will not be defined,\n\t * \n\t * if you didn't use webpack or rollup.js or any bundler, \n\t * you should copy the html files to its folder by yourself. \n\t */\n\ttemplateUrl?: TemplateUrl | string;\n\t/**\n\t * template: typeof 'string' ==> html string,\n\t * \t\t\t TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory\n\t * \tif template === null || undefined ==> it had nothing to render, \n\t * and may be inherit from an html element\n\t * \n\t * 2 possible way to write a template, as inline string, represent a a valid html, \n\t * or us aurora jsx factory \n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DOMNode<ExpressionNode> | DOMRenderNode<T, ExpressionNode>;\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\t/**\n\t * what basic element should the new component inherit from,\n\t * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...\n\t */\n\textend?: string;\n\n\t/**\n\t * An encapsulation policy for the template and CSS styles. One of:\n\t * 'custom': Use global CSS without any encapsulation.\n\t * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.\n\t * \n\t * 'template': like 'custom', with load the template from the document ('index.html' file)\n\t * \t \t\t\tthat had the same id as the component \"selector\".\n\t * 'shadow-dom-template': like 'shadowDom', and load template by selector id.\n\t * \n\t * Both 'template' & 'shadow-dom-template' encapsulation type:\n\t * should had attributes name like lowercase,\n\t * \tthe browser itself, will convert all attributes to lowercase\n\t * \n\t * ```typescript\n\t *\t\t@Input('personage') personAge: number;\n\t *\t\t@Input('propname') propName: string;\n\t *\t\t@Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();\n\t *\t\t@View('personform') personForm: HTMLFormElement;\n\t * ```\n\t * \n\t * any root element as \n\t * \n\t * ```html\n\t * <root-app></root-app>\n\t * ```\n\t * \n\t * the supported bind options is 'One way binding *(as passing data only)'\n\t * and 'template parsing' and 'event binding' syntax, HTML (angular) like.\n\t * it load its attributes from 'window object'\n\t * \n\t * so to pass date to A root element, \n\t * \n\t * ```html\n\t * <script>\n\t * \tlet appVersion = '0.1.504';\n\t * \tfunction onRootAppClick() {\n\t *\t\tconsole.log('root app clicked');\n\t * \t}\n\t * \tfunction onSave(data){\n\t *\t\tconsole.log('root app save', data);\n\t * \t}\n\t * </script>\n\t * <root-app [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" ></root-app>\n\t * ```\n\t * \n\t * default is 'custom'\n\t * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}\n\t */\n\tencapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\n\t/**\n\t * default: 'open'\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n}\n\nexport interface ChildOptions {\n\t[key: string]: any;\n}\n\nexport interface ViewChildOpt {\n\tselector: string | typeof HTMLElement | CustomElementConstructor;\n\tchildOptions?: ChildOptions;\n}\n\nexport function Input(name?: string): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addInput(target, propertyKey, name || propertyKey);\n\t};\n}\nexport function Output(name?: string): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addOutput(target, propertyKey, name || propertyKey);\n\t};\n}\n\nexport function View(): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.setComponentView(target, propertyKey);\n\t};\n}\n\nexport function ViewChild(selector: string | typeof HTMLElement | CustomElementConstructor,\n\tchildOptions?: ChildOptions): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addViewChild(target, propertyKey, selector, childOptions);\n\t};\n}\n\nexport function ViewChildren(selector: string | typeof HTMLElement | CustomElementConstructor): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addViewChildren(target, propertyKey, selector);\n\t};\n}\n\nexport function HostListener(eventName: string, args?: string[]): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addHostListener(\n\t\t\ttarget,\n\t\t\tpropertyKey,\n\t\t\teventName,\n\t\t\targs || []\n\t\t);\n\t};\n}\n\nexport function HostBinding(hostPropertyName: string): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addHostBinding(target, propertyKey, hostPropertyName);\n\t};\n}\n\nexport function Pipe(opt: PipeOptions): Function {\n\treturn (target: Function) => {\n\t\tComponents.definePipe(target, opt);\n\t\treturn target;\n\t};\n}\n\nexport function Service(opt: ServiceOptions): Function {\n\treturn (target: Function) => {\n\t\tComponents.defineService(target, opt);\n\t\treturn target;\n\t};\n}\nexport function Directive(opt: DirectiveOptions): Function {\n\treturn (target: Function) => {\n\t\tComponents.defineDirective(target, opt);\n\t\treturn target;\n\t};\n}\n\nexport function Component<T extends object>(opt: ComponentOptions<T>): Function {\n\treturn (target: TypeOf<T>) => {\n\t\tif (opt.templateUrl) {\n\t\t\tfetchHtml(opt.templateUrl)\n\t\t\t\t.then(htmlTemplate => {\n\t\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\t\tComponents.defineComponent(target, opt);\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(reason => {\n\t\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t\t});\n\t\t} else {\n\t\t\tComponents.defineComponent(target, opt);\n\t\t}\n\t\treturn target;\n\t};\n}\n\nexport function SelfSkip(name?: string): Function {\n\treturn (target: Function, propertyKey: string, index: number) => {\n\t\tReflect.defineMetadata('selfskip', { name, index }, target, propertyKey);\n\t};\n}\n\nexport function Optional(): Function {\n\treturn (target: Function, propertyKey: string, index: number) => {\n\t\tReflect.defineMetadata('optional', { index }, target, propertyKey);\n\t};\n}\n"]}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAe,MAAM,kBAAkB,CAAC;AAwI1D,MAAM,UAAU,KAAK,CAAC,IAAa;IAClC,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC;IAC/D,CAAC,CAAC;AACH,CAAC;AACD,MAAM,UAAU,MAAM,CAAC,IAAa;IACnC,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC;IAChE,CAAC,CAAC;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CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;SAClE;QACD,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACxB,CAAC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ;IACvB,OAAO,CAAC,MAAgB,EAAE,WAAmB,EAAE,KAAa,EAAE,EAAE;QAC/D,IAAI,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACpE,IAAI,CAAC,QAAQ,EAAE;YACd,QAAQ,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;SAClE;QACD,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACxB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport type { ExpressionNode } from '@ibyar/expressions';\nimport { DOMNode, DOMRenderNode } from '@ibyar/elements';\nimport { Components } from '../component/component.js';\nimport { fetchHtml, TemplateUrl } from '../utils/path.js';\n\nexport interface DirectiveOptions {\n\tselector: string;\n}\n\nexport interface ServiceOptions {\n\tprovideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Function> {\n\t/**\n\t * a tag name for the component,\n\t * if the tag name is valid custom element name, the view class will be a custom element,\n\t * otherwise an HTMLUnknownElement will be created\n\t */\n\tselector: string;\n\n\t/**\n\t * add html file url path to fetch,\n\t * templateUrl had propriety than template, and will override it.\n\t *\n\t * Can provide file name as \"person-view.html\" will resolved \n\t * as 'http://site-address.org/persin-view.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }\n\t * let (import.meta = '/person/person.js') will resolved \n\t * as 'http://site-address.org/person/person-edit.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta }\n\t * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.\n\t * \n\t * if url not found, component will not be defined,\n\t * \n\t * if you didn't use webpack or rollup.js or any bundler, \n\t * you should copy the html files to its folder by yourself. \n\t */\n\ttemplateUrl?: TemplateUrl | string;\n\t/**\n\t * template: typeof 'string' ==> html string,\n\t * \t\t\t TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory\n\t * \tif template === null || undefined ==> it had nothing to render, \n\t * and may be inherit from an html element\n\t * \n\t * 2 possible way to write a template, as inline string, represent a a valid html, \n\t * or us aurora jsx factory \n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DOMNode<ExpressionNode> | DOMRenderNode<T, ExpressionNode> | Promise<string>;\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\t/**\n\t * what basic element should the new component inherit from,\n\t * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...\n\t */\n\textend?: string;\n\n\t/**\n\t * An encapsulation policy for the template and CSS styles. One of:\n\t * 'custom': Use global CSS without any encapsulation.\n\t * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.\n\t * \n\t * 'template': like 'custom', with load the template from the document ('index.html' file)\n\t * \t \t\t\tthat had the same id as the component \"selector\".\n\t * 'shadow-dom-template': like 'shadowDom', and load template by selector id.\n\t * \n\t * Both 'template' & 'shadow-dom-template' encapsulation type:\n\t * should had attributes name like lowercase,\n\t * \tthe browser itself, will convert all attributes to lowercase\n\t * \n\t * ```typescript\n\t *\t\t@Input('personage') personAge: number;\n\t *\t\t@Input('propname') propName: string;\n\t *\t\t@Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();\n\t *\t\t@View('personform') personForm: HTMLFormElement;\n\t * ```\n\t * \n\t * any root element as \n\t * \n\t * ```html\n\t * <root-app></root-app>\n\t * ```\n\t * \n\t * the supported bind options is 'One way binding *(as passing data only)'\n\t * and 'template parsing' and 'event binding' syntax, HTML (angular) like.\n\t * it load its attributes from 'window object'\n\t * \n\t * so to pass date to A root element, \n\t * \n\t * ```html\n\t * <script>\n\t * \tlet appVersion = '0.1.504';\n\t * \tfunction onRootAppClick() {\n\t *\t\tconsole.log('root app clicked');\n\t * \t}\n\t * \tfunction onSave(data){\n\t *\t\tconsole.log('root app save', data);\n\t * \t}\n\t * </script>\n\t * <root-app [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" ></root-app>\n\t * ```\n\t * \n\t * default is 'custom'\n\t * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}\n\t */\n\tencapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\n\t/**\n\t * default: 'open'\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n}\n\nexport interface ChildOptions {\n\t[key: string]: any;\n}\n\nexport interface ViewChildOpt {\n\tselector: string | typeof HTMLElement | CustomElementConstructor;\n\tchildOptions?: ChildOptions;\n}\n\nexport function Input(name?: string): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addInput(target, propertyKey, name || propertyKey);\n\t};\n}\nexport function Output(name?: string): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addOutput(target, propertyKey, name || propertyKey);\n\t};\n}\n\nexport function View(): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.setComponentView(target, propertyKey);\n\t};\n}\n\nexport function ViewChild(selector: string | typeof HTMLElement | CustomElementConstructor,\n\tchildOptions?: ChildOptions): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addViewChild(target, propertyKey, selector, childOptions);\n\t};\n}\n\nexport function ViewChildren(selector: string | typeof HTMLElement | CustomElementConstructor): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addViewChildren(target, propertyKey, selector);\n\t};\n}\n\nexport function HostListener(eventName: string, args?: string[]): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addHostListener(\n\t\t\ttarget,\n\t\t\tpropertyKey,\n\t\t\teventName,\n\t\t\targs || []\n\t\t);\n\t};\n}\n\nexport function HostBinding(hostPropertyName: string): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tComponents.addHostBinding(target, propertyKey, hostPropertyName);\n\t};\n}\n\nexport function Pipe(opt: PipeOptions): Function {\n\treturn (target: Function) => {\n\t\tComponents.definePipe(target, opt);\n\t\treturn target;\n\t};\n}\n\nexport function Service(opt: ServiceOptions): Function {\n\treturn (target: Function) => {\n\t\tComponents.defineService(target, opt);\n\t\treturn target;\n\t};\n}\nexport function Directive(opt: DirectiveOptions): Function {\n\treturn (target: Function) => {\n\t\tComponents.defineDirective(target, opt);\n\t\treturn target;\n\t};\n}\n\nexport function Component<T extends object>(opt: ComponentOptions<T>): Function {\n\treturn (target: TypeOf<T>) => {\n\t\tif (opt.templateUrl) {\n\t\t\tfetchHtml(opt.templateUrl)\n\t\t\t\t.then(htmlTemplate => {\n\t\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\t\tComponents.defineComponent(target, opt);\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(reason => {\n\t\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t\t});\n\t\t} else {\n\t\t\tComponents.defineComponent(target, opt);\n\t\t}\n\t\treturn target;\n\t};\n}\n\nexport function SelfSkip(name?: string): Function {\n\treturn (target: Function, propertyKey: string, index: number) => {\n\t\tlet metadata = Reflect.getMetadata('selfskip', target, propertyKey);\n\t\tif (!metadata) {\n\t\t\tmetadata = {};\n\t\t\tReflect.defineMetadata('selfskip', metadata, target, propertyKey);\n\t\t}\n\t\tmetadata[index] = name;\n\t};\n}\n\nexport function Optional(): Function {\n\treturn (target: Function, propertyKey: string, index: number) => {\n\t\tlet metadata = Reflect.getMetadata('optional', target, propertyKey);\n\t\tif (!metadata) {\n\t\t\tmetadata = {};\n\t\t\tReflect.defineMetadata('optional', metadata, target, propertyKey);\n\t\t}\n\t\tmetadata[index] = true;\n\t};\n}\n"]}
@@ -77,6 +77,10 @@ export interface ComponentRef<T> {
77
77
  shadowDomDelegatesFocus: boolean;
78
78
  }
79
79
  export declare class Components {
80
+ static getOrCreateBootstrap<T extends {}>(target: Object): T;
81
+ static getBootstrap<T extends {}>(target: Object): T;
82
+ static getComponentRef<T>(target: object): ComponentRef<T>;
83
+ static setComponentRef<T>(target: object, componentRef: ComponentRef<T>): void;
80
84
  static addOptional(modelProperty: Object): void;
81
85
  static addInput(modelProperty: Object, modelName: string, viewName: string): void;
82
86
  static addOutput(modelProperty: Object, modelName: string, viewName: string): void;
@@ -1,5 +1,4 @@
1
- import { findByTagName, htmlParser, templateParser } from '@ibyar/elements';
2
- import { findByModelClassOrCreat, setBootstrapTagNameMetadata } from '@ibyar/metadata';
1
+ import { findByTagName, htmlParser, templateParser, canAttachShadow } from '@ibyar/elements';
3
2
  import { ClassRegistryProvider } from '../providers/provider.js';
4
3
  import { initCustomElementView } from '../view/view.js';
5
4
  import { buildExpressionNodes } from '../html/expression.js';
@@ -32,45 +31,64 @@ export class HostBindingRef {
32
31
  this.hostPropertyName = hostPropertyName;
33
32
  }
34
33
  }
34
+ const AuroraBootstrap = Symbol.for('aurora:bootstrap');
35
+ const AuroraMetadata = Symbol.for('aurora:metadata');
35
36
  export class Components {
37
+ static getOrCreateBootstrap(target) {
38
+ let bootstrap = Reflect.getMetadata(AuroraBootstrap, target);
39
+ if (!bootstrap) {
40
+ bootstrap = {};
41
+ Reflect.defineMetadata(AuroraBootstrap, bootstrap, target);
42
+ }
43
+ return bootstrap;
44
+ }
45
+ static getBootstrap(target) {
46
+ return Reflect.getMetadata(AuroraBootstrap, target);
47
+ }
48
+ static getComponentRef(target) {
49
+ return Reflect.getMetadata(AuroraMetadata, target);
50
+ }
51
+ static setComponentRef(target, componentRef) {
52
+ Reflect.defineMetadata(AuroraMetadata, componentRef, target);
53
+ }
36
54
  static addOptional(modelProperty) {
37
55
  }
38
56
  static addInput(modelProperty, modelName, viewName) {
39
- var bootstrap = findByModelClassOrCreat(modelProperty);
57
+ const bootstrap = Components.getOrCreateBootstrap(modelProperty);
40
58
  bootstrap.inputs = bootstrap.inputs || [];
41
59
  bootstrap.inputs.push(new PropertyRef(modelName, viewName));
42
60
  }
43
61
  static addOutput(modelProperty, modelName, viewName) {
44
- var bootstrap = findByModelClassOrCreat(modelProperty);
62
+ const bootstrap = Components.getOrCreateBootstrap(modelProperty);
45
63
  bootstrap.outputs = bootstrap.outputs || [];
46
64
  bootstrap.outputs.push(new PropertyRef(modelName, viewName));
47
65
  }
48
66
  static setComponentView(modelProperty, modelName) {
49
- var bootstrap = findByModelClassOrCreat(modelProperty);
67
+ const bootstrap = Components.getOrCreateBootstrap(modelProperty);
50
68
  bootstrap.view = modelName;
51
69
  }
52
70
  static addViewChild(modelProperty, modelName, selector, childOptions) {
53
- var bootstrap = findByModelClassOrCreat(modelProperty);
71
+ const bootstrap = Components.getOrCreateBootstrap(modelProperty);
54
72
  bootstrap.viewChild = bootstrap.viewChild || [];
55
73
  bootstrap.viewChild.push(new ChildRef(modelName, selector, childOptions));
56
74
  }
57
75
  static addViewChildren(modelProperty, modelName, selector) {
58
- var bootstrap = findByModelClassOrCreat(modelProperty);
76
+ const bootstrap = Components.getOrCreateBootstrap(modelProperty);
59
77
  bootstrap.ViewChildren = bootstrap.ViewChildren || [];
60
78
  bootstrap.ViewChildren.push(new ChildRef(modelName, selector));
61
79
  }
62
80
  static addHostListener(modelProperty, propertyKey, eventName, args) {
63
- var bootstrap = findByModelClassOrCreat(modelProperty);
81
+ const bootstrap = Components.getOrCreateBootstrap(modelProperty);
64
82
  bootstrap.hostListeners = bootstrap.hostListeners || [];
65
83
  bootstrap.hostListeners.push(new ListenerRef(eventName, args, propertyKey));
66
84
  }
67
85
  static addHostBinding(modelProperty, propertyKey, hostPropertyName) {
68
- var bootstrap = findByModelClassOrCreat(modelProperty);
86
+ const bootstrap = Components.getOrCreateBootstrap(modelProperty);
69
87
  bootstrap.hostBinding = bootstrap.hostBinding || [];
70
88
  bootstrap.hostBinding.push(new HostBindingRef(propertyKey, hostPropertyName));
71
89
  }
72
90
  static defineDirective(modelClass, opts) {
73
- var bootstrap = findByModelClassOrCreat(modelClass.prototype);
91
+ const bootstrap = Components.getOrCreateBootstrap(modelClass.prototype);
74
92
  for (const key in opts) {
75
93
  bootstrap[key] = Reflect.get(opts, key);
76
94
  }
@@ -78,7 +96,7 @@ export class Components {
78
96
  ClassRegistryProvider.registerDirective(modelClass);
79
97
  }
80
98
  static definePipe(modelClass, opts) {
81
- var bootstrap = findByModelClassOrCreat(modelClass.prototype);
99
+ const bootstrap = Components.getOrCreateBootstrap(modelClass.prototype);
82
100
  for (const key in opts) {
83
101
  bootstrap[key] = Reflect.get(opts, key);
84
102
  }
@@ -86,7 +104,7 @@ export class Components {
86
104
  ClassRegistryProvider.registerPipe(modelClass);
87
105
  }
88
106
  static defineService(modelClass, opts) {
89
- var bootstrap = findByModelClassOrCreat(modelClass.prototype);
107
+ const bootstrap = Components.getOrCreateBootstrap(modelClass.prototype);
90
108
  for (const key in opts) {
91
109
  bootstrap[key] = Reflect.get(opts, key);
92
110
  }
@@ -95,7 +113,7 @@ export class Components {
95
113
  ClassRegistryProvider.registerService(modelClass);
96
114
  }
97
115
  static defineComponent(modelClass, opts) {
98
- var bootstrap = findByModelClassOrCreat(modelClass.prototype);
116
+ const bootstrap = Components.getOrCreateBootstrap(modelClass.prototype);
99
117
  var componentRef = opts;
100
118
  for (const key in bootstrap) {
101
119
  Reflect.set(componentRef, key, bootstrap[key]);
@@ -120,20 +138,23 @@ export class Components {
120
138
  else {
121
139
  }
122
140
  }
123
- componentRef.inputs = componentRef.inputs || [];
124
- componentRef.outputs = componentRef.outputs || [];
125
- componentRef.viewChild = componentRef.viewChild || [];
126
- componentRef.ViewChildren = componentRef.ViewChildren || [];
127
- componentRef.hostBindings = componentRef.hostBindings || [];
128
- componentRef.hostListeners = componentRef.hostListeners || [];
129
- componentRef.encapsulation = componentRef.encapsulation || 'custom';
141
+ componentRef.inputs ||= [];
142
+ componentRef.outputs ||= [];
143
+ componentRef.viewChild ||= [];
144
+ componentRef.ViewChildren ||= [];
145
+ componentRef.hostBindings ||= [];
146
+ componentRef.hostListeners ||= [];
147
+ componentRef.encapsulation ||= 'custom';
130
148
  componentRef.isShadowDom = /shadow-dom/g.test(componentRef.encapsulation);
131
- componentRef.shadowDomMode = componentRef.shadowDomMode || 'open';
149
+ componentRef.shadowDomMode ||= 'open';
132
150
  componentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;
151
+ if (componentRef.isShadowDom && componentRef.extend.name) {
152
+ componentRef.isShadowDom = canAttachShadow(componentRef.extend.name);
153
+ }
133
154
  componentRef.modelClass = modelClass;
134
155
  componentRef.viewClass = initCustomElementView(modelClass, componentRef);
135
- const componentRefName = componentRef.viewClass.name + 'ComponentRef';
136
- setBootstrapTagNameMetadata(modelClass, componentRefName, componentRef);
156
+ Components.setComponentRef(componentRef.modelClass, componentRef);
157
+ Components.setComponentRef(componentRef.viewClass, componentRef);
137
158
  ClassRegistryProvider.registerComponent(modelClass);
138
159
  ClassRegistryProvider.registerView(bootstrap.viewClass);
139
160
  const options = {};
@@ -143,7 +164,7 @@ export class Components {
143
164
  options.extends = parentTagName;
144
165
  }
145
166
  }
146
- customElements.define(componentRef?.selector, componentRef.viewClass, options);
167
+ customElements.define(componentRef.selector, componentRef.viewClass, options);
147
168
  }
148
169
  }
149
170
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,aAAa,EACR,UAAU,EAAE,cAAc,EAC/B,MAAM,iBAAiB,CAAC;AAC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Y,CAAC,SAAS,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACzE,MAAM,gBAAgB,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,GAAG,cAAc,CAAC;QACtE,2BAA2B,CAAC,UAAU,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;QAExE,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAGxD,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;QAED,cAAc,CAAC,MAAM,CACpB,YAAY,EAAE,QAAkB,EAChC,YAAY,CAAC,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;CACD","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport type { ExpressionNode } from '@ibyar/expressions';\nimport {\n\tfindByTagName,\n\tTag, htmlParser, templateParser, DOMNode, DOMRenderNode\n} from '@ibyar/elements';\nimport { findByModelClassOrCreat, setBootstrapTagNameMetadata } from '@ibyar/metadata';\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(public modelName: string, public selector: string | { new(): HTMLElement; prototype: HTMLElement } | CustomElementConstructor, public childOptions?: ChildOptions) { }\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<T>> | 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<ExpressionNode> | DOMRenderNode<T, ExpressionNode>;\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\n\nexport class Components {\n\n\tstatic addOptional(modelProperty: Object) {\n\t}\n\n\tstatic addInput(modelProperty: Object, modelName: string, viewName: string) {\n\t\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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}\n\n\tstatic definePipe(modelClass: Function, opts: PipeOptions) {\n\t\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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\tvar bootstrap: BootstrapMetadata = findByModelClassOrCreat(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 = componentRef.inputs || [];\n\t\tcomponentRef.outputs = componentRef.outputs || [];\n\t\tcomponentRef.viewChild = componentRef.viewChild || [];\n\t\tcomponentRef.ViewChildren = componentRef.ViewChildren || [];\n\t\tcomponentRef.hostBindings = componentRef.hostBindings || [];\n\t\tcomponentRef.hostListeners = componentRef.hostListeners || [];\n\t\tcomponentRef.encapsulation = componentRef.encapsulation || 'custom';\n\t\tcomponentRef.isShadowDom = /shadow-dom/g.test(componentRef.encapsulation);\n\t\tcomponentRef.shadowDomMode = componentRef.shadowDomMode || 'open';\n\t\tcomponentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;\n\n\t\tcomponentRef.modelClass = modelClass;\n\t\tcomponentRef.viewClass = initCustomElementView(modelClass, componentRef);\n\t\tconst componentRefName = componentRef.viewClass.name + 'ComponentRef';\n\t\tsetBootstrapTagNameMetadata(modelClass, componentRefName, componentRef);\n\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(bootstrap.viewClass);\n\t\t// setBootstrapMetadata(modelClass.prototype, componentRef);\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\t\tcustomElements.define(\n\t\t\tcomponentRef?.selector as string,\n\t\t\tcomponentRef.viewClass as CustomElementConstructor,\n\t\t\toptions\n\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AiB,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 type { ExpressionNode } from '@ibyar/expressions';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDOMNode, DOMRenderNode, canAttachShadow\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<T>> | 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<ExpressionNode> | DOMRenderNode<T, ExpressionNode>;\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}\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,4 +1,6 @@
1
+ import type { ReactiveScope } from '@ibyar/expressions';
1
2
  import type { TypeOf } from '../utils/typeof.js';
3
+ import type { ElementReactiveScope } from '../directive/providers.js';
2
4
  import { EventEmitter } from './events.js';
3
5
  import { PropertyRef, ComponentRef } from './component.js';
4
6
  import { Model } from '../model/change-detection.js';
@@ -12,6 +14,10 @@ export interface BaseComponent<T extends Object> extends CustomElement {
12
14
  _model: T & Model & {
13
15
  [key: string]: any;
14
16
  };
17
+ _modelScope: ReactiveScope<T & Model & {
18
+ [key: string]: any;
19
+ }>;
20
+ _viewScope: ElementReactiveScope;
15
21
  getComponentRef(): ComponentRef<T>;
16
22
  setParentComponent<V>(parent: HTMLComponent<V>): void;
17
23
  getParentComponent<V>(): HTMLComponent<V>;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-element.js","sourceRoot":"","sources":["../../../src/core/component/custom-element.ts"],"names":[],"mappings":"AA4CA,MAAM,UAAU,eAAe,CAAC,MAAW;IAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;WAChC,MAAM,YAAY,WAAW,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAW,EAAE,SAAyB;IAC3E,OAAO,eAAe,CAAC,MAAM,CAAC;WAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,SAAS,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAoB;IACjD,OAAO,OAAO,IAAI,OAAO,YAAY,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACxD,OAAO,OAAO,IAAI,OAAO,YAAY,kBAAkB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { EventEmitter } from './events.js';\nimport { PropertyRef, ComponentRef } from './component.js';\nimport { Model } from '../model/change-detection.js';\n\nexport interface CustomElement {\n\tadoptedCallback(): void;\n\tattributeChangedCallback(name: string, oldValue: any, newValue: any): void;\n\tconnectedCallback(): void;\n\tdisconnectedCallback(): void;\n}\n\nexport interface BaseComponent<T extends Object> extends CustomElement {\n\n\t_model: T & Model & { [key: string]: any };\n\n\tgetComponentRef(): ComponentRef<T>;\n\n\tsetParentComponent<V>(parent: HTMLComponent<V>): void;\n\tgetParentComponent<V>(): HTMLComponent<V>;\n\thasParentComponent(): boolean;\n\n\thasInputStartWith(viewProp: string): boolean;\n\tgetInputStartWith(viewProp: string): PropertyRef | undefined;\n\tgetInput(viewProp: string): PropertyRef | undefined;\n\tgetInputValue(viewProp: string): any;\n\tsetInputValue(viewProp: string, value: any): void;\n\n\thasInput(viewProp: string): boolean;\n\thasProp(propName: string): boolean;\n\thasOutput(viewProp: string): boolean;\n\n\tgetOutput(viewProp: string): PropertyRef | undefined;\n\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined;\n\n\ttriggerOutput(eventName: string, value?: any): void;\n\ttriggerModelChange(eventName: string, value?: any, source?: HTMLElement): void;\n\temitRootChanges(): void;\n\temitChanges(...events: string[]): void;\n\n}\n\nexport interface HTMLComponent<T extends Object> extends BaseComponent<T>, HTMLElement { }\n\nexport function isHTMLComponent(object: any): object is HTMLComponent<any> {\n\treturn Reflect.has(object, '_model')\n\t\t&& object instanceof HTMLElement;\n}\n\nexport function isHTMLComponentOfType(object: any, typeClass: TypeOf<Object>): object is HTMLComponent<any> {\n\treturn isHTMLComponent(object)\n\t\t&& Reflect.get(object, '_model') instanceof typeClass;\n}\n\nexport function isHTMLElement(element: HTMLElement): element is HTMLElement {\n\treturn element && element instanceof HTMLElement && !element.tagName?.includes('-');\n}\n\nexport function isHTMLUnknownElement(element: HTMLElement): element is HTMLElement {\n\treturn element && element instanceof HTMLUnknownElement && !element.tagName?.includes('-');\n}\n\n/**\n * Lifecycle callbacks\n * A map, whose keys are the strings \"connectedCallback\", \"disconnectedCallback\", \"adoptedCallback\", \"attributeChangedCallback\", \n * \"formAssociatedCallback\", \"formDisabledCallback\", \"formResetCallback\", and \"formStateRestoreCallback\" \n * https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-lifecycle-callbacks\n * \n * A form-associated custom element API includes a set of extra lifecycle callbacks to tie in to the form lifecycle.\n * The callbacks are optional: only implement a callback if your element needs to do something at that point in the lifecycle.\n * https://html.spec.whatwg.org/multipage/custom-elements.html#the-elementinternals-interface \n * https://docs.google.com/document/d/1JO8puctCSpW-ZYGU8lF-h4FWRIDQNDVexzHoOQ2iQmY/edit\n */\nexport interface CustomFormElement extends CustomElement {\n\n\t/**\n\t * Called when the browser associates the element with a form element,\n\t * or disassociates the element from a form element.\n\t * @param form \n\t */\n\tformAssociatedCallback(form: HTMLFormElement): void;\n\n\t/**\n\t * Called after the disabled state of the element changes,\n\t * either because the disabled attribute of this element was added or removed;\n\t * or because the disabled state changed on a <fieldset> that's an ancestor of this element.\n\t * The disabled parameter represents the new disabled state of the element.\n\t * The element may, for example, disable elements in its shadow DOM when it is disabled.\n\t * @param disabled \n\t */\n\tformDisabledCallback(disabled: boolean): void;\n\n\t/**\n\t * Called after the form is reset.\n\t * The element should reset itself to some kind of default state.\n\t * For <input> elements, this usually involves setting the value property to\n\t * match the value attribute set in markup (or in the case of a checkbox,\n\t * setting the checked property to match the checked attribute.\n\t */\n\tformResetCallback(): void;\n\n\t/**\n\t * Called in one of two circumstances:\n\t * When the browser restores the state of the element (for example, after a navigation, or when the browser restarts).\n\t * The mode argument is \"restore\" in this case.\n\t * \n\t * When the browser's input-assist features such as form autofilling sets a value.\n\t * The mode argument is \"autocomplete\" in this case.\n\t * \n\t * The type of the first argument depends on how the setFormValue() method was called.\n\t * For more details, see Restoring form state.\n\t */\n\tformStateRestoreCallback(value: any, mode: 'restore' | 'autocomplete'): void;\n}\n\nexport interface BaseFormElementComponent<T extends Object> extends BaseComponent<T>, CustomFormElement { }\n\nexport interface HTMLFormElementComponent<T extends Object> extends BaseFormElementComponent<T>, HTMLComponent<T> { }\n\nexport type HTMLFormElement = HTMLButtonElement | HTMLDataListElement | HTMLFieldSetElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n"]}
1
+ {"version":3,"file":"custom-element.js","sourceRoot":"","sources":["../../../src/core/component/custom-element.ts"],"names":[],"mappings":"AAgDA,MAAM,UAAU,eAAe,CAAC,MAAW;IAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;WAChC,MAAM,YAAY,WAAW,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAW,EAAE,SAAyB;IAC3E,OAAO,eAAe,CAAC,MAAM,CAAC;WAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,SAAS,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAoB;IACjD,OAAO,OAAO,IAAI,OAAO,YAAY,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACxD,OAAO,OAAO,IAAI,OAAO,YAAY,kBAAkB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["import type { ReactiveScope } from '@ibyar/expressions';\nimport type { TypeOf } from '../utils/typeof.js';\nimport type { ElementReactiveScope } from '../directive/providers.js';\nimport { EventEmitter } from './events.js';\nimport { PropertyRef, ComponentRef } from './component.js';\nimport { Model } from '../model/change-detection.js';\n\nexport interface CustomElement {\n\tadoptedCallback(): void;\n\tattributeChangedCallback(name: string, oldValue: any, newValue: any): void;\n\tconnectedCallback(): void;\n\tdisconnectedCallback(): void;\n}\n\nexport interface BaseComponent<T extends Object> extends CustomElement {\n\n\t_model: T & Model & { [key: string]: any };\n\t_modelScope: ReactiveScope<T & Model & { [key: string]: any; }>;\n\t_viewScope: ElementReactiveScope;\n\n\tgetComponentRef(): ComponentRef<T>;\n\n\tsetParentComponent<V>(parent: HTMLComponent<V>): void;\n\tgetParentComponent<V>(): HTMLComponent<V>;\n\thasParentComponent(): boolean;\n\n\thasInputStartWith(viewProp: string): boolean;\n\tgetInputStartWith(viewProp: string): PropertyRef | undefined;\n\tgetInput(viewProp: string): PropertyRef | undefined;\n\tgetInputValue(viewProp: string): any;\n\tsetInputValue(viewProp: string, value: any): void;\n\n\thasInput(viewProp: string): boolean;\n\thasProp(propName: string): boolean;\n\thasOutput(viewProp: string): boolean;\n\n\tgetOutput(viewProp: string): PropertyRef | undefined;\n\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined;\n\n\ttriggerOutput(eventName: string, value?: any): void;\n\ttriggerModelChange(eventName: string, value?: any, source?: HTMLElement): void;\n\temitRootChanges(): void;\n\temitChanges(...events: string[]): void;\n\n}\n\nexport interface HTMLComponent<T extends Object> extends BaseComponent<T>, HTMLElement { }\n\nexport function isHTMLComponent(object: any): object is HTMLComponent<any> {\n\treturn Reflect.has(object, '_model')\n\t\t&& object instanceof HTMLElement;\n}\n\nexport function isHTMLComponentOfType(object: any, typeClass: TypeOf<Object>): object is HTMLComponent<any> {\n\treturn isHTMLComponent(object)\n\t\t&& Reflect.get(object, '_model') instanceof typeClass;\n}\n\nexport function isHTMLElement(element: HTMLElement): element is HTMLElement {\n\treturn element && element instanceof HTMLElement && !element.tagName?.includes('-');\n}\n\nexport function isHTMLUnknownElement(element: HTMLElement): element is HTMLElement {\n\treturn element && element instanceof HTMLUnknownElement && !element.tagName?.includes('-');\n}\n\n/**\n * Lifecycle callbacks\n * A map, whose keys are the strings \"connectedCallback\", \"disconnectedCallback\", \"adoptedCallback\", \"attributeChangedCallback\", \n * \"formAssociatedCallback\", \"formDisabledCallback\", \"formResetCallback\", and \"formStateRestoreCallback\" \n * https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-lifecycle-callbacks\n * \n * A form-associated custom element API includes a set of extra lifecycle callbacks to tie in to the form lifecycle.\n * The callbacks are optional: only implement a callback if your element needs to do something at that point in the lifecycle.\n * https://html.spec.whatwg.org/multipage/custom-elements.html#the-elementinternals-interface \n * https://docs.google.com/document/d/1JO8puctCSpW-ZYGU8lF-h4FWRIDQNDVexzHoOQ2iQmY/edit\n */\nexport interface CustomFormElement extends CustomElement {\n\n\t/**\n\t * Called when the browser associates the element with a form element,\n\t * or disassociates the element from a form element.\n\t * @param form \n\t */\n\tformAssociatedCallback(form: HTMLFormElement): void;\n\n\t/**\n\t * Called after the disabled state of the element changes,\n\t * either because the disabled attribute of this element was added or removed;\n\t * or because the disabled state changed on a <fieldset> that's an ancestor of this element.\n\t * The disabled parameter represents the new disabled state of the element.\n\t * The element may, for example, disable elements in its shadow DOM when it is disabled.\n\t * @param disabled \n\t */\n\tformDisabledCallback(disabled: boolean): void;\n\n\t/**\n\t * Called after the form is reset.\n\t * The element should reset itself to some kind of default state.\n\t * For <input> elements, this usually involves setting the value property to\n\t * match the value attribute set in markup (or in the case of a checkbox,\n\t * setting the checked property to match the checked attribute.\n\t */\n\tformResetCallback(): void;\n\n\t/**\n\t * Called in one of two circumstances:\n\t * When the browser restores the state of the element (for example, after a navigation, or when the browser restarts).\n\t * The mode argument is \"restore\" in this case.\n\t * \n\t * When the browser's input-assist features such as form autofilling sets a value.\n\t * The mode argument is \"autocomplete\" in this case.\n\t * \n\t * The type of the first argument depends on how the setFormValue() method was called.\n\t * For more details, see Restoring form state.\n\t */\n\tformStateRestoreCallback(value: any, mode: 'restore' | 'autocomplete'): void;\n}\n\nexport interface BaseFormElementComponent<T extends Object> extends BaseComponent<T>, CustomFormElement { }\n\nexport interface HTMLFormElementComponent<T extends Object> extends BaseFormElementComponent<T>, HTMLComponent<T> { }\n\nexport type HTMLFormElement = HTMLButtonElement | HTMLDataListElement | HTMLFieldSetElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n"]}
@@ -6,7 +6,7 @@ export declare class Subscription<T> {
6
6
  unsubscribe(): void;
7
7
  }
8
8
  export declare class EventEmitter<T> {
9
- private subscripers;
9
+ private subscribers;
10
10
  constructor();
11
11
  emit(value?: T): void;
12
12
  subscribe(next?: any, error?: any, complete?: any): Subscription<T>;
@@ -19,42 +19,42 @@ export class Subscription {
19
19
  }
20
20
  export class EventEmitter {
21
21
  constructor() {
22
- this.subscripers = new Map();
22
+ this.subscribers = new Map();
23
23
  }
24
24
  emit(value) {
25
- this.subscripers.forEach((subscrip) => {
25
+ this.subscribers.forEach((subscribe) => {
26
26
  try {
27
- subscrip.next(value);
27
+ subscribe.next(value);
28
28
  }
29
29
  catch (error) {
30
30
  try {
31
- if (subscrip.error) {
32
- subscrip.error(error);
31
+ if (subscribe.error) {
32
+ subscribe.error(error);
33
33
  }
34
34
  }
35
35
  catch (error) {
36
- console.error('error: handeling event');
36
+ console.error('error: handling event', error);
37
37
  }
38
38
  }
39
39
  finally {
40
40
  try {
41
- if (subscrip.complete) {
42
- subscrip.complete();
41
+ if (subscribe.complete) {
42
+ subscribe.complete();
43
43
  }
44
44
  }
45
45
  catch (error) {
46
- console.error('error: handeling event');
46
+ console.error('error: handling event', error);
47
47
  }
48
48
  }
49
49
  });
50
50
  }
51
51
  subscribe(next, error, complete) {
52
52
  const subscription = new Subscription(this);
53
- this.subscripers.set(subscription, { next, error, complete });
53
+ this.subscribers.set(subscription, { next, error, complete });
54
54
  return subscription;
55
55
  }
56
56
  remove(subscription) {
57
- this.subscripers.delete(subscription);
57
+ this.subscribers.delete(subscription);
58
58
  }
59
59
  }
60
60
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/core/component/events.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAExB,YAAoB,YAA6B;QAA7B,iBAAY,GAAZ,YAAY,CAAiB;IAAI,CAAC;IACtD,GAAG,CAAC,YAA+B;QAClC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC7B,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;SAC7B;QACD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IACD,WAAW;QACV,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC5B,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;gBAChD,YAAY,CAAC,WAAW,EAAE,CAAC;YAC5B,CAAC,CAAC,CAAC;SACH;IACF,CAAC;CACD;AAQD,MAAM,OAAO,YAAY;IAExB;QADQ,gBAAW,GAAmC,IAAI,GAAG,EAAE,CAAC;IAChD,CAAC;IACjB,IAAI,CAAC,KAAS;QACb,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACrC,IAAI;gBACH,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;YAAC,OAAO,KAAK,EAAE;gBACf,IAAI;oBACH,IAAI,QAAQ,CAAC,KAAK,EAAE;wBACnB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;qBACtB;iBACD;gBAAC,OAAO,KAAK,EAAE;oBACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;iBACxC;aACD;oBAAS;gBACT,IAAI;oBACH,IAAI,QAAQ,CAAC,QAAQ,EAAE;wBACtB,QAAQ,CAAC,QAAQ,EAAE,CAAC;qBACpB;iBACD;gBAAC,OAAO,KAAK,EAAE;oBACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;iBACxC;aACD;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,SAAS,CAAC,IAAU,EAAE,KAAW,EAAE,QAAc;QAChD,MAAM,YAAY,GAAoB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,YAA6B;QACnC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CACD","sourcesContent":["export class Subscription<T> {\n\tprivate othersSubscription: Subscription<any>[];\n\tconstructor(private eventEmitter: EventEmitter<T>) { }\n\tadd(subscription: Subscription<any>) {\n\t\tif (!this.othersSubscription) {\n\t\t\tthis.othersSubscription = [];\n\t\t}\n\t\tthis.othersSubscription.push(subscription);\n\t}\n\tunsubscribe(): void {\n\t\tthis.eventEmitter.remove(this);\n\t\tif (this.othersSubscription) {\n\t\t\tthis.othersSubscription.forEach((subscription) => {\n\t\t\t\tsubscription.unsubscribe();\n\t\t\t});\n\t\t}\n\t}\n}\n\ninterface Subscrip {\n\tnext?: any;\n\terror?: any;\n\tcomplete?: any;\n}\n\nexport class EventEmitter<T> {\n\tprivate subscripers: Map<Subscription<T>, Subscrip> = new Map();\n\tconstructor() { }\n\temit(value?: T): void {\n\t\tthis.subscripers.forEach((subscrip) => {\n\t\t\ttry {\n\t\t\t\tsubscrip.next(value);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tif (subscrip.error) {\n\t\t\t\t\t\tsubscrip.error(error);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handeling event');\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (subscrip.complete) {\n\t\t\t\t\t\tsubscrip.complete();\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handeling event');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\tsubscribe(next?: any, error?: any, complete?: any): Subscription<T> {\n\t\tconst subscription: Subscription<T> = new Subscription(this);\n\t\tthis.subscripers.set(subscription, { next, error, complete });\n\t\treturn subscription;\n\t}\n\n\tremove(subscription: Subscription<T>) {\n\t\tthis.subscripers.delete(subscription);\n\t}\n}\n"]}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/core/component/events.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAExB,YAAoB,YAA6B;QAA7B,iBAAY,GAAZ,YAAY,CAAiB;IAAI,CAAC;IACtD,GAAG,CAAC,YAA+B;QAClC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC7B,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;SAC7B;QACD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IACD,WAAW;QACV,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC5B,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;gBAChD,YAAY,CAAC,WAAW,EAAE,CAAC;YAC5B,CAAC,CAAC,CAAC;SACH;IACF,CAAC;CACD;AAQD,MAAM,OAAO,YAAY;IAExB;QADQ,gBAAW,GAAoC,IAAI,GAAG,EAAE,CAAC;IACjD,CAAC;IACjB,IAAI,CAAC,KAAS;QACb,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACtC,IAAI;gBACH,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACtB;YAAC,OAAO,KAAK,EAAE;gBACf,IAAI;oBACH,IAAI,SAAS,CAAC,KAAK,EAAE;wBACpB,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;qBACvB;iBACD;gBAAC,OAAO,KAAK,EAAE;oBACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;iBAC9C;aACD;oBAAS;gBACT,IAAI;oBACH,IAAI,SAAS,CAAC,QAAQ,EAAE;wBACvB,SAAS,CAAC,QAAQ,EAAE,CAAC;qBACrB;iBACD;gBAAC,OAAO,KAAK,EAAE;oBACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;iBAC9C;aACD;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,SAAS,CAAC,IAAU,EAAE,KAAW,EAAE,QAAc;QAChD,MAAM,YAAY,GAAoB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,YAA6B;QACnC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CACD","sourcesContent":["export class Subscription<T> {\n\tprivate othersSubscription: Subscription<any>[];\n\tconstructor(private eventEmitter: EventEmitter<T>) { }\n\tadd(subscription: Subscription<any>) {\n\t\tif (!this.othersSubscription) {\n\t\t\tthis.othersSubscription = [];\n\t\t}\n\t\tthis.othersSubscription.push(subscription);\n\t}\n\tunsubscribe(): void {\n\t\tthis.eventEmitter.remove(this);\n\t\tif (this.othersSubscription) {\n\t\t\tthis.othersSubscription.forEach((subscription) => {\n\t\t\t\tsubscription.unsubscribe();\n\t\t\t});\n\t\t}\n\t}\n}\n\ninterface Subscribe {\n\tnext?: any;\n\terror?: any;\n\tcomplete?: any;\n}\n\nexport class EventEmitter<T> {\n\tprivate subscribers: Map<Subscription<T>, Subscribe> = new Map();\n\tconstructor() { }\n\temit(value?: T): void {\n\t\tthis.subscribers.forEach((subscribe) => {\n\t\t\ttry {\n\t\t\t\tsubscribe.next(value);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tif (subscribe.error) {\n\t\t\t\t\t\tsubscribe.error(error);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handling event', error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (subscribe.complete) {\n\t\t\t\t\t\tsubscribe.complete();\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handling event', error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\tsubscribe(next?: any, error?: any, complete?: any): Subscription<T> {\n\t\tconst subscription: Subscription<T> = new Subscription(this);\n\t\tthis.subscribers.set(subscription, { next, error, complete });\n\t\treturn subscription;\n\t}\n\n\tremove(subscription: Subscription<T>) {\n\t\tthis.subscribers.delete(subscription);\n\t}\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { ReactiveScope, ScopeType } from '@ibyar/expressions';
2
+ export declare class ElementModelReactiveScope<T extends {
3
+ [key: PropertyKey]: any;
4
+ }> extends ReactiveScope<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
+ get(propertyKey: PropertyKey): any;
12
+ }
@@ -0,0 +1,29 @@
1
+ import { ReactiveScope } from '@ibyar/expressions';
2
+ export class ElementModelReactiveScope extends ReactiveScope {
3
+ static for(context, type) {
4
+ return new ElementModelReactiveScope(context, type);
5
+ }
6
+ static blockScopeFor(context) {
7
+ return new ElementModelReactiveScope(context, 'block');
8
+ }
9
+ static functionScopeFor(context) {
10
+ return new ElementModelReactiveScope(context, 'function');
11
+ }
12
+ static classScopeFor(context) {
13
+ return new ElementModelReactiveScope(context, 'class');
14
+ }
15
+ static moduleScopeFor(context) {
16
+ return new ElementModelReactiveScope(context, 'module');
17
+ }
18
+ static globalScopeFor(context) {
19
+ return new ElementModelReactiveScope(context, 'global');
20
+ }
21
+ get(propertyKey) {
22
+ let value = Reflect.get(this.context, propertyKey);
23
+ if (typeof value === 'function') {
24
+ value = value.bind(this.context);
25
+ }
26
+ return value;
27
+ }
28
+ }
29
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/component/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,oBAAoB,CAAC;AAG9D,MAAM,OAAO,yBAAiE,SAAQ,aAAgB;IACrG,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;IACD,GAAG,CAAC,WAAwB;QAC3B,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YAChC,KAAK,GAAI,KAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC/C;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["import { ReactiveScope, ScopeType } from '@ibyar/expressions';\n\n\nexport class ElementModelReactiveScope<T extends { [key: PropertyKey]: any }> extends ReactiveScope<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\tget(propertyKey: PropertyKey): any {\n\t\tlet value = Reflect.get(this.context, propertyKey);\n\t\tif (typeof value === 'function') {\n\t\t\tvalue = (value as Function).bind(this.context);\n\t\t}\n\t\treturn value;\n\t}\n}\n"]}
@@ -1,18 +1,2 @@
1
- import { ContextProvider, ScopeProvider } from '@ibyar/expressions';
2
- export declare const documentStack: ScopeProvider;
3
- export declare class BindingNotification {
4
- notification: Array<PropertyKey>;
5
- notify(propertyKey: PropertyKey): void;
6
- }
7
- export declare class BindingContextProvider<T extends object> implements ContextProvider {
8
- protected context: T;
9
- private notifier;
10
- static contextMapping: WeakMap<object, BindingContextProvider<object>>;
11
- static createOrGetProvider<T extends object>(object: T): BindingContextProvider<T>;
12
- constructor(context: T, notifier: BindingNotification);
13
- getNotifier(): BindingNotification;
14
- get(propertyKey: PropertyKey): any;
15
- set(propertyKey: PropertyKey, value: any, receiver?: any): boolean;
16
- has(propertyKey: PropertyKey): boolean;
17
- getProviderBy(): T | undefined;
18
- }
1
+ import { Stack } from '@ibyar/expressions';
2
+ export declare const documentStack: Stack;