@ibyar/core 1.2.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/annotation/decorators.d.ts.map +1 -1
- package/annotation/options.d.ts +6 -4
- package/annotation/options.d.ts.map +1 -1
- package/annotation/options.js.map +1 -1
- package/component/component.d.ts.map +1 -1
- package/component/component.js +1 -0
- package/component/component.js.map +1 -1
- package/component/reflect.d.ts.map +1 -1
- package/di/inject.d.ts +3 -0
- package/di/inject.d.ts.map +1 -0
- package/di/inject.js +10 -0
- package/di/inject.js.map +1 -0
- package/directive/directive.d.ts +2 -1
- package/directive/directive.d.ts.map +1 -1
- package/directive/directive.js +3 -1
- package/directive/directive.js.map +1 -1
- package/directive/parser.d.ts +2 -1
- package/directive/parser.d.ts.map +1 -1
- package/directive/parser.js +26 -19
- package/directive/parser.js.map +1 -1
- package/html/expression.d.ts.map +1 -1
- package/html/expression.js +4 -1
- package/html/expression.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/linker/template-ref.d.ts.map +1 -1
- package/linker/view-ref.d.ts.map +1 -1
- package/package.json +9 -8
- package/signals/proposal-signals.d.ts +4 -0
- package/signals/proposal-signals.d.ts.map +1 -0
- package/signals/proposal-signals.js +11 -0
- package/signals/proposal-signals.js.map +1 -0
- package/signals/proposal-sugnal.d.ts +1 -0
- package/signals/proposal-sugnal.d.ts.map +1 -0
- package/signals/proposal-sugnal.js +2 -0
- package/signals/proposal-sugnal.js.map +1 -0
- package/signals/signals.js +8 -8
- package/signals/signals.js.map +1 -1
- package/typedoc.json +8 -0
- package/view/base-view.js.map +1 -1
- package/view/render.d.ts.map +1 -1
- package/view/render.js +7 -3
- package/view/render.js.map +1 -1
- package/zone/task.d.ts +0 -61
- package/zone/task.d.ts.map +1 -1
- package/zone/task.js +127 -116
- package/zone/task.js.map +1 -1
package/LICENSE
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0B,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;AAyB5J,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,wIAY/B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,WAAW,GAAG,wBAAwB,EAAE,YAAY,CAAC,EAAE,YAAY,sIAYnI;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,WAAW,GAAG,wBAAwB,sIAYzG;AAGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,+GAe9H;AAGD,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;AAEhD,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,6KAYhE;AAED,eAAO,MAAM,IAAI,iFA5Hb,GAAC,0BAgIJ,CAAC;AAGF,eAAO,MAAM,SAAS,sFAnIlB,GAAC,0BAuIJ,CAAC;AAoBF,eAAO,MAAM,SAAS,yHA3JlB,GAAC,0BAqKJ,CAAC;AAEF,eAAO,MAAM,aAAa;cAAkC,MAAM;wFAvK9D,GAAC,0BA2KJ,CAAC"}
|
package/annotation/options.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export interface DirectiveOptions {
|
|
|
51
51
|
* - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.
|
|
52
52
|
*/
|
|
53
53
|
zone?: ZoneType;
|
|
54
|
+
/**
|
|
55
|
+
* name of possible structure directive successor
|
|
56
|
+
*/
|
|
57
|
+
successor?: string;
|
|
54
58
|
}
|
|
55
59
|
export interface ServiceOptions {
|
|
56
60
|
provideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';
|
|
@@ -87,13 +91,11 @@ export interface ComponentOptions<T = Class> {
|
|
|
87
91
|
*/
|
|
88
92
|
templateUrl?: TemplateUrl | string;
|
|
89
93
|
/**
|
|
90
|
-
* template:
|
|
91
|
-
* TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory
|
|
94
|
+
* template: html string
|
|
92
95
|
* if template === null || undefined ==> it had nothing to render,
|
|
93
96
|
* and may be inherit from an html element
|
|
94
97
|
*
|
|
95
|
-
*
|
|
96
|
-
* or us aurora jsx factory
|
|
98
|
+
* write a template, as inline string, represent a a valid html.
|
|
97
99
|
*
|
|
98
100
|
*/
|
|
99
101
|
template?: string | DomNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG9D,MAAM,WAAW,gBAAgB;IAEhC;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IAEH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC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H,aAAa,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,qBAAqB,CAAC;IAE7E;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC;IAE/B;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmFG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAErD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,GAAG,OAAO,WAAW,GAAG,wBAAwB,CAAC;IACjE,YAAY,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { Class, TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { TemplateUrl } from '../utils/path.js';\nimport { ZoneType } from '../zone/bootstrap.js';\nimport { ValueControl } from '../component/custom-element.js';\n\n\nexport interface DirectiveOptions {\n\n\t/**\n\t * the name of the directive which is used in the template\n\t * \n\t * a structural directive name should start with `*`,\n\t * and an attributes directive should not.\n\t */\n\tselector: string;\n\n\t/**\n\t * export this directive to the HTML template scope,\n\t * \n\t * it can be accessed by the template reference name \n\t * ex:\n\t * ```ts\n\t * \n\t * \n\t * \n\t * Directive({\n\t * \tselector: '*tooltip',\n\t * \texportAs: 'tooltip'\n\t * })\n\t * ```\n\t * \n\t * in your component\n\t * \n\t * ```html\n\t * <a tooltip=\"I'm a tooltip!!\" #tooltip=\"tooltip\">I'm a link</a>\n\t * <button (click)=\"tooltip.toggleTooltip()\">Toggle tooltip</button>\n\t * ```\n\t * \n\t */\n\n\texportAs?: string;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * if no value specified, the value will be initialized by the custom element `web component` zone,\n\t * - if the web component zone is `manual`, the directive zone also will be `manual`, expect weird behavior.\n\t * - if the web component zone is `proxy`, the directive zone also will be `proxy`.\n\t * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.\n\t */\n\tzone?: ZoneType;\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 = Class> {\n\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\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;\n\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\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 * also, support extends a custom element tag name.\n\t */\n\textend?: keyof HTMLElementTagNameMap | `${string}-${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 app root element as \n\t * \n\t * ```html\n\t * <app-root></app-root>\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 * \tconst 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 * <app-root [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" >\n\t * </app-root>\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' when encapsulation used,\n\t * otherwise it is undefined and will not attach shadow root element.\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n\n\t/**\n\t * shadow root initialization options,\n\t * default mode: `open`, delegatesFocus: `false` and slotAssignment: `manual`\n\t */\n\tshadowRootInit?: Partial<ShadowRootInit>;\n\n\t/**\n\t * Create a custom form-associated element with HTMLElement.attachInternals\n\t * default: false\n\t * \n\t * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface\n\t * \n\t * otherwise you can register another class that implement `ValueControl<T>`,\n\t * in case if you want split the model and the value controller.\n\t * \n\t * #### Usage Notes:\n\t * \n\t * ```ts\n\t * \n\t * @Component({\n\t * \tselector: 'custom-message',\n\t * \ttemplate: `\n\t * \t\t<label for=\"message\">Message</label>\n\t * \t\t<textarea id=\"message\" [(value)]=\"message\" [disabled]=\"disabled\" (change)=\"onMessageChange($event.target.value)\"></textarea>\n\t * \t`,\n\t * \tformAssociated: true,\n\t * \t// formAssociated: CustomMessage,\n\t * })\n\t * export class CustomMessage implements ValueControl<string> {\n\t * \n\t * \tprivate message: string | null = '';\n\t * \tprivate disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<string>) {\n\t * \t\tthis.message = mode !== 'reset' ? value : '';\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis.disabled = isDisabled;\n\t * \t}\n\t * \n\t * \tonMessageChange(message: string) {\n\t * \t\tthis._onChange(message);\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * \n\t * export class CustomInputValueControl implements ValueControl<number> {\n\t * \n\t * \tprivate _value: number | null = null;\n\t * \tprivate _disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<number>) {\n\t * \t\tthis._value = mode !== 'reset' ? value : null;\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis._disabled = isDisabled;\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * @Component({\n\t * \tselector: 'custom-input',\n\t * \textend: 'input',\n\t * \tformAssociated: CustomInputValueControl,\n\t * })\n\t * export class CustomInputElement {\n\t * \t\n\t * @View()\n\t * \tview: HTMLInputElement;\n\t * \n\t * \tonInit() {\n\t * \t\tthis.view.type = 'number';\n\t * \t}\n\t * }\n\t * \n\t * ```\n\t */\n\tformAssociated?: boolean | TypeOf<ValueControl<any>>;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * the default value is the platform zone type which can be changed by:\n\t * \n\t * ```js\n\t * bootstrapZone('manual')\n\t * bootstrapZone('proxy')\n\t * bootstrapZone('aurora')\n\t * ```\n\t * \n\t * if `bootstrapZone` never been called, then the default zone is a `manual`.\n\t */\n\tzone?: ZoneType;\n\n\t/**\n\t * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.\n\t */\n\timports?: (TypeOf<any> | ReadonlyArray<any>)[];\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 type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n"]}
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { Class, TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { TemplateUrl } from '../utils/path.js';\nimport { ZoneType } from '../zone/bootstrap.js';\nimport { ValueControl } from '../component/custom-element.js';\n\n\nexport interface DirectiveOptions {\n\n\t/**\n\t * the name of the directive which is used in the template\n\t * \n\t * a structural directive name should start with `*`,\n\t * and an attributes directive should not.\n\t */\n\tselector: string;\n\n\t/**\n\t * export this directive to the HTML template scope,\n\t * \n\t * it can be accessed by the template reference name \n\t * ex:\n\t * ```ts\n\t * \n\t * \n\t * \n\t * Directive({\n\t * \tselector: '*tooltip',\n\t * \texportAs: 'tooltip'\n\t * })\n\t * ```\n\t * \n\t * in your component\n\t * \n\t * ```html\n\t * <a tooltip=\"I'm a tooltip!!\" #tooltip=\"tooltip\">I'm a link</a>\n\t * <button (click)=\"tooltip.toggleTooltip()\">Toggle tooltip</button>\n\t * ```\n\t * \n\t */\n\n\texportAs?: string;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * if no value specified, the value will be initialized by the custom element `web component` zone,\n\t * - if the web component zone is `manual`, the directive zone also will be `manual`, expect weird behavior.\n\t * - if the web component zone is `proxy`, the directive zone also will be `proxy`.\n\t * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.\n\t */\n\tzone?: ZoneType;\n\n\n\t/**\n\t * name of possible structure directive successor\n\t */\n\tsuccessor?: 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 = Class> {\n\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\n\t/**\n\t * template: html string\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 * write a template, as inline string, represent a a valid html.\n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DomNode;\n\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\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 * also, support extends a custom element tag name.\n\t */\n\textend?: keyof HTMLElementTagNameMap | `${string}-${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 app root element as \n\t * \n\t * ```html\n\t * <app-root></app-root>\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 * \tconst 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 * <app-root [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" >\n\t * </app-root>\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' when encapsulation used,\n\t * otherwise it is undefined and will not attach shadow root element.\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n\n\t/**\n\t * shadow root initialization options,\n\t * default mode: `open`, delegatesFocus: `false` and slotAssignment: `manual`\n\t */\n\tshadowRootInit?: Partial<ShadowRootInit>;\n\n\t/**\n\t * Create a custom form-associated element with HTMLElement.attachInternals\n\t * default: false\n\t * \n\t * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface\n\t * \n\t * otherwise you can register another class that implement `ValueControl<T>`,\n\t * in case if you want split the model and the value controller.\n\t * \n\t * #### Usage Notes:\n\t * \n\t * ```ts\n\t * \n\t * @Component({\n\t * \tselector: 'custom-message',\n\t * \ttemplate: `\n\t * \t\t<label for=\"message\">Message</label>\n\t * \t\t<textarea id=\"message\" [(value)]=\"message\" [disabled]=\"disabled\" (change)=\"onMessageChange($event.target.value)\"></textarea>\n\t * \t`,\n\t * \tformAssociated: true,\n\t * \t// formAssociated: CustomMessage,\n\t * })\n\t * export class CustomMessage implements ValueControl<string> {\n\t * \n\t * \tprivate message: string | null = '';\n\t * \tprivate disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<string>) {\n\t * \t\tthis.message = mode !== 'reset' ? value : '';\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis.disabled = isDisabled;\n\t * \t}\n\t * \n\t * \tonMessageChange(message: string) {\n\t * \t\tthis._onChange(message);\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * \n\t * export class CustomInputValueControl implements ValueControl<number> {\n\t * \n\t * \tprivate _value: number | null = null;\n\t * \tprivate _disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<number>) {\n\t * \t\tthis._value = mode !== 'reset' ? value : null;\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis._disabled = isDisabled;\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * @Component({\n\t * \tselector: 'custom-input',\n\t * \textend: 'input',\n\t * \tformAssociated: CustomInputValueControl,\n\t * })\n\t * export class CustomInputElement {\n\t * \t\n\t * @View()\n\t * \tview: HTMLInputElement;\n\t * \n\t * \tonInit() {\n\t * \t\tthis.view.type = 'number';\n\t * \t}\n\t * }\n\t * \n\t * ```\n\t */\n\tformAssociated?: boolean | TypeOf<ValueControl<any>>;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * the default value is the platform zone type which can be changed by:\n\t * \n\t * ```js\n\t * bootstrapZone('manual')\n\t * bootstrapZone('proxy')\n\t * bootstrapZone('aurora')\n\t * ```\n\t * \n\t * if `bootstrapZone` never been called, then the default zone is a `manual`.\n\t */\n\tzone?: ZoneType;\n\n\t/**\n\t * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.\n\t */\n\timports?: (TypeOf<any> | ReadonlyArray<any>)[];\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 type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACS,GAAG,EAClB,OAAO,EAAE,aAAa,EACH,cAAc,EAGjC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGpF,OAAO,EACN,gBAAgB,EAAE,WAAW,EAC7B,cAAc,EAAE,gBAAgB,EAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAC1C,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAC3C,MAAM,cAAc,CAAC;AAItB,MAAM,WAAW,UAAU,CAAC,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC,wBAAwB,CAAC,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;IAC1E,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,OAAO,CAAC;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aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe;IAM7G,MAAM,CAAC,aAAa,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe;IAOnH,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe;IAoG1H,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,wBAAwB;CAU1H"}
|
package/component/component.js
CHANGED
|
@@ -90,6 +90,7 @@ export class Components {
|
|
|
90
90
|
directiveRegistry.register(opts.selector, {
|
|
91
91
|
inputs: metadata.inputs?.map(input => input.viewAttribute),
|
|
92
92
|
outputs: metadata.outputs?.map(output => output.viewAttribute),
|
|
93
|
+
successor: metadata.successor,
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
static definePipe(modelClass, opts, metadata) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,aAAa,EAAO,UAAU,EAAE,cAAc,EACtB,eAAe,EACvC,iBAAiB,EAAE,cAAc,EACjC,eAAe,EAAE,aAAa,EAC9B,wBAAwB,EACxB,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;AAK7D,OAA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oD;QACzH,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,GAAG,CAAC;QACxC,cAAc,CAAC,MAAM,CACpB,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CAAC;IACH,CAAC","sourcesContent":["import type { MetadataClass, MetadataContext } from '@ibyar/decorators';\nimport type { Class, TypeOf } from '../utils/typeof.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow,\n\tdirectiveRegistry, DomElementNode,\n\tDomFragmentNode, DomParentNode,\n\tisValidCustomElementName\n} from '@ibyar/elements';\n\nimport { HTMLComponent, ValueControl } 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, PipeOptions,\n\tServiceOptions, DirectiveOptions\n} from '../annotation/options.js';\nimport {\n\tChildRef, HostBindingRef, InputPropertyRef,\n\tListenerRef, OutputPropertyRef, PropertyRef\n} from './reflect.js';\nimport { deserializeExpressionNodes } from '../html/deserialize.js';\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\texportAs?: string;\n\tzone?: ZoneType;\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\tviewBindings?: DomElementNode;\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\tcompiledTemplate?: DomNode;\n\t// attrTemplate: JsxAttrComponent;\n\tstyles: string;\n\textend: Tag;\n\textendCustomElement: boolean;\n\n\tviewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: InputPropertyRef[];\n\toutputs: OutputPropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\tviewBindings?: DomElementNode;\n\twindowBindings?: DomElementNode;\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template' | 'shadow-slot';\n\tisShadowDom: boolean;\n\tshadowRootInit: ShadowRootInit;\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\n}\n\ntype ViewBindingOption = {\n\tprototype: Record<PropertyKey, any>;\n\thostBindings?: HostBindingRef[];\n\thostListeners?: ListenerRef[];\n\tselector?: string;\n};\n\ntype HostNode = {\n\thost?: DomElementNode;\n\twindow?: DomElementNode;\n\ttemplate?: DomElementNode[];\n};\n\nconst DEFAULT_SHADOW_ROOT_INIT: ShadowRootInit = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };\n\nexport class Components {\n\n\tprivate static EMPTY_LIST = Object.freeze<any>([]);\n\tprivate static emptyList<T>(): T[] {\n\t\treturn Components.EMPTY_LIST as T[];\n\t}\n\n\tprivate static patchTemplate(child: DomNode, templates: DomElementNode[]): void {\n\t\tif (child instanceof DomElementNode && child.templateRefName?.name) {\n\t\t\tconst ref = templates.find(node => child.templateRefName?.name === node.templateRefName?.name);\n\t\t\tif (ref?.outputs) {\n\t\t\t\t(child.outputs ??= []).push(...ref.outputs);\n\t\t\t}\n\t\t}\n\t\tif (child instanceof DomParentNode) {\n\t\t\tchild.children?.forEach(node => Components.patchTemplate(node, templates));\n\t\t}\n\t}\n\n\tprivate static createOutputs(Listeners?: ListenerRef[]) {\n\t\treturn Listeners?.map(\n\t\t\tlistener => `(${listener.eventName})=\"${listener.modelCallbackName}(${listener.args.join(', ')})\"`\n\t\t).join(' ') ?? ''\n\t}\n\n\tprivate static parseHostNode(option: ViewBindingOption): HostNode {\n\t\tconst inputs = option.hostBindings?.map(binding => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);\n\t\t\tif (typeof descriptor?.value === 'function') {\n\t\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}()\"`\n\t\t\t}\n\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}\"`;\n\t\t}).join(' ') ?? '';\n\n\t\tconst hostListeners: ListenerRef[] = [];\n\t\tconst windowListeners: ListenerRef[] = [];\n\t\tconst templateListeners: Record<string, ListenerRef[]> = {};\n\n\t\toption.hostListeners?.forEach(listener => {\n\t\t\tconst [host, event] = listener.eventName.split(':', 2);\n\t\t\tif (event === undefined) {\n\t\t\t\thostListeners.push(listener);\n\t\t\t} else if ('window' === host.toLowerCase()) {\n\t\t\t\twindowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t} else {\n\t\t\t\t(templateListeners[host] ??= []).push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t}\n\t\t});\n\n\t\tconst result: HostNode = {};\n\n\t\tif (hostListeners.length) {\n\t\t\tconst hostOutputs = Components.createOutputs(hostListeners);\n\t\t\tconst selector = option.selector ?? 'div';\n\t\t\tconst hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;\n\t\t\tresult.host = htmlParser.toDomRootNode(hostTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.host);\n\t\t}\n\n\t\tif (windowListeners.length) {\n\t\t\tconst windowOutputs = Components.createOutputs(windowListeners);\n\t\t\tconst windowTemplate = `<window ${windowOutputs}></window>`;\n\t\t\tresult.window = htmlParser.toDomRootNode(windowTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.window);\n\t\t}\n\n\t\tconst templateHosts = Object.keys(templateListeners);\n\t\tif (templateHosts.length) {\n\t\t\tconst template = templateHosts.map(host => {\n\t\t\t\tconst hostOutputs = Components.createOutputs(templateListeners[host]);\n\t\t\t\treturn `<template #${host} ${hostOutputs}></template>`;\n\t\t\t}).join('');\n\t\t\tconst templateNodes = htmlParser.toDomRootNode(template) as DomElementNode | DomFragmentNode;\n\t\t\tbuildExpressionNodes(templateNodes);\n\t\t\tresult.template = templateNodes instanceof DomFragmentNode\n\t\t\t\t? templateNodes.children?.filter(child => child instanceof DomElementNode) as DomElementNode[] ?? []\n\t\t\t\t: [templateNodes];\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tif (metadata.hostListeners?.length || metadata.hostBindings?.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: metadata.hostBindings,\n\t\t\t\thostListeners: metadata.hostListeners,\n\t\t\t});\n\t\t\tmetadata.viewBindings = hostNode.host;\n\t\t}\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (metadata.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (metadata.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineService<T extends Class>(modelClass: MetadataClass<T>, opts: ServiceOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tmetadata.name = modelClass.name;\n\t\tClassRegistryProvider.registerService(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tconst componentRef = Object.assign(metadata, opts) as any as ComponentRef<T>;\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\t\tcomponentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(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} else if (typeof componentRef.template === 'object') {\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.compiledTemplate === 'object') {\n\t\t\thtmlParser.deserializeNode(componentRef.compiledTemplate);\n\t\t\tdeserializeExpressionNodes(componentRef.compiledTemplate);\n\t\t\tcomponentRef.template = componentRef.compiledTemplate;\n\t\t\tcomponentRef.compiledTemplate = undefined;\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 ||= Components.emptyList();\n\t\tcomponentRef.outputs ||= Components.emptyList();\n\t\tcomponentRef.viewChild ||= Components.emptyList();\n\t\tcomponentRef.ViewChildren ||= Components.emptyList();\n\t\tcomponentRef.hostBindings ||= Components.emptyList();\n\t\tcomponentRef.hostListeners ||= Components.emptyList();\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow/g.test(componentRef.encapsulation);\n\t\tif (componentRef.isShadowDom) {\n\t\t\tcomponentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));\n\t\t}\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\tselector: componentRef.selector,\n\t\t\t\thostBindings: componentRef.hostBindings,\n\t\t\t\thostListeners: componentRef.hostListeners,\n\t\t\t});\n\t\t\tcomponentRef.viewBindings = hostNode.host;\n\t\t\tcomponentRef.windowBindings = hostNode.window;\n\n\t\t\tif (typeof componentRef.template === 'function') {\n\t\t\t\tconst creator = componentRef.template;\n\t\t\t\tcomponentRef.template = (model: T) => {\n\t\t\t\t\tconst template = creator(model);\n\t\t\t\t\tif (hostNode.template) {\n\t\t\t\t\t\tComponents.patchTemplate(template, hostNode.template);\n\t\t\t\t\t}\n\t\t\t\t\treturn template;\n\t\t\t\t};\n\t\t\t} else if (hostNode.template) {\n\t\t\t\tComponents.patchTemplate(componentRef.template, hostNode.template);\n\t\t\t}\n\n\t\t}\n\n\t\tif (!(componentRef.formAssociated === true || typeof componentRef.formAssociated === 'function')) {\n\t\t\tcomponentRef.formAssociated = false;\n\t\t}\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\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(componentRef.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\tstatic defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tconst { selector, ...definition } = opt;\n\t\tcustomElements.define(\n\t\t\tselector,\n\t\t\tviewClass,\n\t\t\tdefinition,\n\t\t);\n\t}\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,aAAa,EAAO,UAAU,EAAE,cAAc,EACtB,eAAe,EACvC,iBAAiB,EAAE,cAAc,EACjC,eAAe,EAAE,aAAa,EAC9B,wBAAwB,EACxB,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;AAK7D,OAAO,EAEN,WAAW,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAwEpE,MAAM,wBAAwB,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AAElH,MAAM,OAAO,UAAU;IAEd,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAM,EAAE,CAAC,CAAC;IAC3C,MAAM,CAAC,SAAS;QACvB,OAAO,UAAU,CAAC,UAAiB,CAAC;IACrC,CAAC;IAEO,MAAM,CAAC,aA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QACrC,CAAC;QAED,IAAI,YAAY,CAAC,WAAW,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC1D,YAAY,CAAC,WAAW,GAAG,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtE,CAAC;QAED,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC;QACrC,YAAY,CAAC,SAAS,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAEzE,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,qBAAqB,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAE3D,MAAM,OAAO,GAA6B,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;QAChD,IAAI,aAAa,EAAE,CAAC;YACnB,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAChE,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;YACjC,CAAC;QACF,CAAC;QAGD,cAAc,CAAC,MAAM,CACpB,YAAY,CAAC,QAAkB,EAC/B,YAAY,CAAC,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;IAED,MAAM,CAAC,UAAU,CAAwB,SAA2B,EAAE,GAAoD;QACzH,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,GAAG,CAAC;QACxC,cAAc,CAAC,MAAM,CACpB,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CAAC;IACH,CAAC","sourcesContent":["import type { MetadataClass, MetadataContext } from '@ibyar/decorators';\nimport type { Class, TypeOf } from '../utils/typeof.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow,\n\tdirectiveRegistry, DomElementNode,\n\tDomFragmentNode, DomParentNode,\n\tisValidCustomElementName\n} from '@ibyar/elements';\n\nimport { HTMLComponent, ValueControl } 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, PipeOptions,\n\tServiceOptions, DirectiveOptions\n} from '../annotation/options.js';\nimport {\n\tChildRef, HostBindingRef, InputPropertyRef,\n\tListenerRef, OutputPropertyRef, PropertyRef\n} from './reflect.js';\nimport { deserializeExpressionNodes } from '../html/deserialize.js';\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\texportAs?: string;\n\tzone?: ZoneType;\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\tviewBindings?: DomElementNode;\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\tcompiledTemplate?: DomNode;\n\tstyles: string;\n\textend: Tag;\n\textendCustomElement: boolean;\n\n\tviewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: InputPropertyRef[];\n\toutputs: OutputPropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\tviewBindings?: DomElementNode;\n\twindowBindings?: DomElementNode;\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template' | 'shadow-slot';\n\tisShadowDom: boolean;\n\tshadowRootInit: ShadowRootInit;\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\n}\n\ntype ViewBindingOption = {\n\tprototype: Record<PropertyKey, any>;\n\thostBindings?: HostBindingRef[];\n\thostListeners?: ListenerRef[];\n\tselector?: string;\n};\n\ntype HostNode = {\n\thost?: DomElementNode;\n\twindow?: DomElementNode;\n\ttemplate?: DomElementNode[];\n};\n\nconst DEFAULT_SHADOW_ROOT_INIT: ShadowRootInit = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };\n\nexport class Components {\n\n\tprivate static EMPTY_LIST = Object.freeze<any>([]);\n\tprivate static emptyList<T>(): T[] {\n\t\treturn Components.EMPTY_LIST as T[];\n\t}\n\n\tprivate static patchTemplate(child: DomNode, templates: DomElementNode[]): void {\n\t\tif (child instanceof DomElementNode && child.templateRefName?.name) {\n\t\t\tconst ref = templates.find(node => child.templateRefName?.name === node.templateRefName?.name);\n\t\t\tif (ref?.outputs) {\n\t\t\t\t(child.outputs ??= []).push(...ref.outputs);\n\t\t\t}\n\t\t}\n\t\tif (child instanceof DomParentNode) {\n\t\t\tchild.children?.forEach(node => Components.patchTemplate(node, templates));\n\t\t}\n\t}\n\n\tprivate static createOutputs(Listeners?: ListenerRef[]) {\n\t\treturn Listeners?.map(\n\t\t\tlistener => `(${listener.eventName})=\"${listener.modelCallbackName}(${listener.args.join(', ')})\"`\n\t\t).join(' ') ?? ''\n\t}\n\n\tprivate static parseHostNode(option: ViewBindingOption): HostNode {\n\t\tconst inputs = option.hostBindings?.map(binding => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);\n\t\t\tif (typeof descriptor?.value === 'function') {\n\t\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}()\"`\n\t\t\t}\n\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}\"`;\n\t\t}).join(' ') ?? '';\n\n\t\tconst hostListeners: ListenerRef[] = [];\n\t\tconst windowListeners: ListenerRef[] = [];\n\t\tconst templateListeners: Record<string, ListenerRef[]> = {};\n\n\t\toption.hostListeners?.forEach(listener => {\n\t\t\tconst [host, event] = listener.eventName.split(':', 2);\n\t\t\tif (event === undefined) {\n\t\t\t\thostListeners.push(listener);\n\t\t\t} else if ('window' === host.toLowerCase()) {\n\t\t\t\twindowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t} else {\n\t\t\t\t(templateListeners[host] ??= []).push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t}\n\t\t});\n\n\t\tconst result: HostNode = {};\n\n\t\tif (hostListeners.length) {\n\t\t\tconst hostOutputs = Components.createOutputs(hostListeners);\n\t\t\tconst selector = option.selector ?? 'div';\n\t\t\tconst hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;\n\t\t\tresult.host = htmlParser.toDomRootNode(hostTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.host);\n\t\t}\n\n\t\tif (windowListeners.length) {\n\t\t\tconst windowOutputs = Components.createOutputs(windowListeners);\n\t\t\tconst windowTemplate = `<window ${windowOutputs}></window>`;\n\t\t\tresult.window = htmlParser.toDomRootNode(windowTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.window);\n\t\t}\n\n\t\tconst templateHosts = Object.keys(templateListeners);\n\t\tif (templateHosts.length) {\n\t\t\tconst template = templateHosts.map(host => {\n\t\t\t\tconst hostOutputs = Components.createOutputs(templateListeners[host]);\n\t\t\t\treturn `<template #${host} ${hostOutputs}></template>`;\n\t\t\t}).join('');\n\t\t\tconst templateNodes = htmlParser.toDomRootNode(template) as DomElementNode | DomFragmentNode;\n\t\t\tbuildExpressionNodes(templateNodes);\n\t\t\tresult.template = templateNodes instanceof DomFragmentNode\n\t\t\t\t? templateNodes.children?.filter(child => child instanceof DomElementNode) as DomElementNode[] ?? []\n\t\t\t\t: [templateNodes];\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tif (metadata.hostListeners?.length || metadata.hostBindings?.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: metadata.hostBindings,\n\t\t\t\thostListeners: metadata.hostListeners,\n\t\t\t});\n\t\t\tmetadata.viewBindings = hostNode.host;\n\t\t}\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (metadata.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (metadata.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t\tsuccessor: (metadata.successor as string | undefined),\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineService<T extends Class>(modelClass: MetadataClass<T>, opts: ServiceOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tmetadata.name = modelClass.name;\n\t\tClassRegistryProvider.registerService(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tconst componentRef = Object.assign(metadata, opts) as any as ComponentRef<T>;\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\t\tcomponentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(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} else if (typeof componentRef.template === 'object') {\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.compiledTemplate === 'object') {\n\t\t\thtmlParser.deserializeNode(componentRef.compiledTemplate);\n\t\t\tdeserializeExpressionNodes(componentRef.compiledTemplate);\n\t\t\tcomponentRef.template = componentRef.compiledTemplate;\n\t\t\tcomponentRef.compiledTemplate = undefined;\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 ||= Components.emptyList();\n\t\tcomponentRef.outputs ||= Components.emptyList();\n\t\tcomponentRef.viewChild ||= Components.emptyList();\n\t\tcomponentRef.ViewChildren ||= Components.emptyList();\n\t\tcomponentRef.hostBindings ||= Components.emptyList();\n\t\tcomponentRef.hostListeners ||= Components.emptyList();\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow/g.test(componentRef.encapsulation);\n\t\tif (componentRef.isShadowDom) {\n\t\t\tcomponentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));\n\t\t}\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\tselector: componentRef.selector,\n\t\t\t\thostBindings: componentRef.hostBindings,\n\t\t\t\thostListeners: componentRef.hostListeners,\n\t\t\t});\n\t\t\tcomponentRef.viewBindings = hostNode.host;\n\t\t\tcomponentRef.windowBindings = hostNode.window;\n\n\t\t\tif (typeof componentRef.template === 'function') {\n\t\t\t\tconst creator = componentRef.template;\n\t\t\t\tcomponentRef.template = (model: T) => {\n\t\t\t\t\tconst template = creator(model);\n\t\t\t\t\tif (hostNode.template) {\n\t\t\t\t\t\tComponents.patchTemplate(template, hostNode.template);\n\t\t\t\t\t}\n\t\t\t\t\treturn template;\n\t\t\t\t};\n\t\t\t} else if (hostNode.template) {\n\t\t\t\tComponents.patchTemplate(componentRef.template, hostNode.template);\n\t\t\t}\n\n\t\t}\n\n\t\tif (!(componentRef.formAssociated === true || typeof componentRef.formAssociated === 'function')) {\n\t\t\tcomponentRef.formAssociated = false;\n\t\t}\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\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(componentRef.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\tstatic defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tconst { selector, ...definition } = opt;\n\t\tcustomElements.define(\n\t\t\tselector,\n\t\t\tviewClass,\n\t\t\tdefinition,\n\t\t);\n\t}\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../../src/core/component/reflect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE9E,qBAAa,WAAW;IACJ,aAAa,EAAE,MAAM;IAAE,SAAS,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../../src/core/component/reflect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE9E,qBAAa,WAAW;IACJ,aAAa,EAAE,MAAM;IAAE,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM;gBAAnD,aAAa,EAAE,MAAM,EAAY,SAAS,CAAC,EAAE,MAAM,YAAA;IACtE,IAAI,aAAa,IAAI,MAAM,CAE1B;CACD;AAED,qBAAa,gBAAiB,SAAQ,WAAW;CAEhD;AAED,qBAAa,iBAAkB,SAAQ,WAAW;IACY,OAAO,CAAC,EAAE,eAAe;gBAA1E,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAS,OAAO,CAAC,EAAE,eAAe,YAAA;CAGtF;AAED,qBAAa,QAAQ;IAEZ,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM,GAAG;QAAE,QAAO,WAAW,CAAC;QAAC,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,wBAAwB;IAC5F,YAAY,CAAC,EAAE,YAAY;gBAF3B,SA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B;IAIrI,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAIxG,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;CAG9F"}
|
package/di/inject.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../../../src/core/di/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAOxC"}
|
package/di/inject.js
ADDED
package/di/inject.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/core/di/inject.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,IAAI,OAAO,EAAoB,CAAC;AAElD,MAAM,UAAU,MAAM,CAAI,IAAe;IACxC,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzB,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["import { TypeOf } from '../utils/typeof.js';\n\nconst instances = new WeakMap<TypeOf<any>, any>();\n\nexport function inject<T>(type: TypeOf<T>) {\n\tif (instances.has(type)) {\n\t\treturn instances.get(type);\n\t}\n\tconst ref = new type();\n\tinstances.set(type, ref);\n\treturn ref;\n}\n"]}
|
package/directive/directive.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare class StructuralDirective {
|
|
|
10
10
|
protected viewContainerRef: ViewContainerRef;
|
|
11
11
|
protected host: HTMLComponent<any> | StructuralDirective;
|
|
12
12
|
protected _zone: AuroraZone;
|
|
13
|
-
|
|
13
|
+
protected successor?: TemplateRef | undefined;
|
|
14
|
+
constructor(templateRef: TemplateRef, viewContainerRef: ViewContainerRef, host: HTMLComponent<any> | StructuralDirective, _zone: AuroraZone, successor?: TemplateRef | undefined);
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* An attributes directive selector as '[class] [style]'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,qBAAa,mBAAmB;IAE9B,SAAS,CAAC,WAAW,EAAE,WAAW;IAClC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB;IAC5C,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,mBAAmB;IACxD,SAAS,CAAC,KAAK,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,qBAAa,mBAAmB;IAE9B,SAAS,CAAC,WAAW,EAAE,WAAW;IAClC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB;IAC5C,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,mBAAmB;IACxD,SAAS,CAAC,KAAK,EAAE,UAAU;IAC3B,SAAS,CAAC,SAAS,CAAC,EAAE,WAAW;gBAJvB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,mBAAmB,EAC9C,KAAK,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,WAAW,YAAA;CAElC;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAClB,SAAS,CAAC,EAAE,EAAE,WAAW;IAAE,SAAS,CAAC,KAAK,EAAE,UAAU;gBAA5C,EAAE,EAAE,WAAW,EAAY,KAAK,EAAE,UAAU;CAClE;AAED;;GAEG;AACH,qBAAa,8BAA8B;IAC9B,SAAS,CAAC,SAAS,EAAE,mBAAmB;IAAE,SAAS,CAAC,KAAK,EAAE,UAAU;gBAA3D,SAAS,EAAE,mBAAmB,EAAY,KAAK,EAAE,UAAU;CACjF"}
|
package/directive/directive.js
CHANGED
|
@@ -6,11 +6,13 @@ export class StructuralDirective {
|
|
|
6
6
|
viewContainerRef;
|
|
7
7
|
host;
|
|
8
8
|
_zone;
|
|
9
|
-
|
|
9
|
+
successor;
|
|
10
|
+
constructor(templateRef, viewContainerRef, host, _zone, successor) {
|
|
10
11
|
this.templateRef = templateRef;
|
|
11
12
|
this.viewContainerRef = viewContainerRef;
|
|
12
13
|
this.host = host;
|
|
13
14
|
this._zone = _zone;
|
|
15
|
+
this.successor = successor;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAEpB;IACA;IACA;IACA;
|
|
1
|
+
{"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAEpB;IACA;IACA;IACA;IACA;IALX,YACW,WAAwB,EACxB,gBAAkC,EAClC,IAA8C,EAC9C,KAAiB,EACjB,SAAuB;QAJvB,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,SAAI,GAAJ,IAAI,CAA0C;QAC9C,UAAK,GAAL,KAAK,CAAY;QACjB,cAAS,GAAT,SAAS,CAAc;IAC9B,CAAC;CACL;AAED;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACR;IAA2B;IAAjD,YAAsB,EAAe,EAAY,KAAiB;QAA5C,OAAE,GAAF,EAAE,CAAa;QAAY,UAAK,GAAL,KAAK,CAAY;IAAI,CAAC;CACvE;AAED;;GAEG;AACH,MAAM,OAAO,8BAA8B;IACpB;IAA0C;IAAhE,YAAsB,SAA8B,EAAY,KAAiB;QAA3D,cAAS,GAAT,SAAS,CAAqB;QAAY,UAAK,GAAL,KAAK,CAAY;IAAI,CAAC;CACtF","sourcesContent":["\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { TemplateRef } from '../linker/template-ref.js';\nimport { ViewContainerRef } from '../linker/view-container-ref.js';\nimport { AuroraZone } from '../zone/zone.js';\n\n/**\n * A structural directive selector as '*if' '*for'\n */\nexport class StructuralDirective {\n\tconstructor(\n\t\tprotected templateRef: TemplateRef,\n\t\tprotected viewContainerRef: ViewContainerRef,\n\t\tprotected host: HTMLComponent<any> | StructuralDirective,\n\t\tprotected _zone: AuroraZone,\n\t\tprotected successor?: TemplateRef,\n\t) { }\n}\n\n/**\n * An attributes directive selector as '[class] [style]'\n */\nexport class AttributeDirective {\n\tconstructor(protected el: HTMLElement, protected _zone: AuroraZone) { }\n}\n\n/**\n * An attributes directive on structural directive\n */\nexport class AttributeOnStructuralDirective {\n\tconstructor(protected directive: StructuralDirective, protected _zone: AuroraZone) { }\n}\n"]}
|
package/directive/parser.d.ts
CHANGED
|
@@ -23,7 +23,8 @@ export declare class DirectiveExpressionParser {
|
|
|
23
23
|
protected isSemicolon(): boolean;
|
|
24
24
|
protected isComma(): boolean;
|
|
25
25
|
protected consumeSemicolonOrComma(): void;
|
|
26
|
-
protected parseTemplateInput(): boolean;
|
|
26
|
+
protected parseTemplateInput(allowComma: boolean): boolean;
|
|
27
|
+
private consumeDeclarations;
|
|
27
28
|
protected parseExpression(inputName: string): void;
|
|
28
29
|
/**
|
|
29
30
|
* check if the first is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAErF,MAAM,MAAM,uBAAuB,GAAG;IACrC,mBAAmB,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9C,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,CAAC;AAUF,qBAAa,yBAAyB;IAiBzB,SAAS,CAAC,aAAa,EAAE,MAAM;IAAE,SAAS,CAAC,MAAM,EAAE,WAAW;WAd5D,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,uBAAuB;IAWvF,SAAS,CAAC,mBAAmB,sBAAkC;IAC/D,SAAS,CAAC,eAAe,sBAA6B;gBAEhC,aAAa,EAAE,MAAM,EAAY,MAAM,EAAE,WAAW;IAE1E,0BAA0B,IAAI,uBAAuB;IAMrD,IAAI,IAAI,IAAI;IAmBZ,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK;IAK9B,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAQtC,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,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AK,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,OAAO;IAUxE,SAAS,CAAC,gBAAgB,IAAI,OAAO;IAKrC,SAAS,CAAC,YAAY,IAAI,OAAO;IAIjC,SAAS,CAAC,WAAW,IAAI,OAAO;IAKhC,SAAS,CAAC,gBAAgB;IAG1B,SAAS,CAAC,WAAW;IAGrB,SAAS,CAAC,OAAO;IAGjB,SAAS,CAAC,uBAAuB;IAQjC,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,OAAO;IAiBhD,OAAO,CAAC,mBAAmB;IAiB3B,SAAS,CAAC,eAAe,CAAC,SAAS,EAAE,MAAM;IAM3C;;;OAGG;IACH,SAAS,CAAC,+BAA+B;IAiDzC,OAAO,CAAC,gBAAgB;CAOxB"}
|
package/directive/parser.js
CHANGED
|
@@ -35,7 +35,7 @@ export class DirectiveExpressionParser {
|
|
|
35
35
|
scan() {
|
|
36
36
|
// parse 'let/const/var' if found, or switch to expression mode.
|
|
37
37
|
if (this.isDeclareKeyword()) {
|
|
38
|
-
this.parseTemplateInput();
|
|
38
|
+
this.parseTemplateInput(false);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
41
|
// parse expression, possible ends is semicolon, comma, let and 'EOS'
|
|
@@ -47,7 +47,7 @@ export class DirectiveExpressionParser {
|
|
|
47
47
|
this.consumeSemicolonOrComma();
|
|
48
48
|
// parse let and parseDirectiveAndTemplateInputs
|
|
49
49
|
while (this.stream.peek().isNotType(Token.EOS)) {
|
|
50
|
-
this.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();
|
|
50
|
+
this.parseTemplateInput(true) || this.parseDirectiveAndTemplateInputs();
|
|
51
51
|
this.consumeSemicolonOrComma();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -107,34 +107,41 @@ export class DirectiveExpressionParser {
|
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
parseTemplateInput() {
|
|
110
|
+
parseTemplateInput(allowComma) {
|
|
111
111
|
// let = "let" :local "=" :export ";"?
|
|
112
112
|
if (this.isDeclareKeyword()) {
|
|
113
113
|
let peek = this.stream.peek();
|
|
114
114
|
const list = [peek];
|
|
115
115
|
this.consume(peek.token);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
}
|
|
121
|
-
else if (peek.isType(Token.IDENTIFIER)) {
|
|
122
|
-
this.consumeToList(Token.IDENTIFIER, list);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
throw new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));
|
|
126
|
-
}
|
|
127
|
-
if (this.consumeIfToken(Token.ASSIGN, list)) {
|
|
128
|
-
this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
list.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);
|
|
116
|
+
this.consumeDeclarations(list);
|
|
117
|
+
while (allowComma && this.stream.currentToken().isType(Token.COMMA)) {
|
|
118
|
+
list.push(TokenConstant.COMMA);
|
|
119
|
+
this.consumeDeclarations(list);
|
|
132
120
|
}
|
|
133
121
|
this.templateExpressions.push(list);
|
|
134
122
|
return true;
|
|
135
123
|
}
|
|
136
124
|
return false;
|
|
137
125
|
}
|
|
126
|
+
consumeDeclarations(list) {
|
|
127
|
+
const peek = this.stream.peek();
|
|
128
|
+
if (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {
|
|
129
|
+
// object and array pattern, destructing
|
|
130
|
+
this.stream.readTill(Token.closeOf(peek.token), list);
|
|
131
|
+
}
|
|
132
|
+
else if (peek.isType(Token.IDENTIFIER)) {
|
|
133
|
+
this.consumeToList(Token.IDENTIFIER, list);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
throw new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));
|
|
137
|
+
}
|
|
138
|
+
if (this.consumeIfToken(Token.ASSIGN, list)) {
|
|
139
|
+
this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
list.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
138
145
|
parseExpression(inputName) {
|
|
139
146
|
const list = [];
|
|
140
147
|
this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);
|
package/directive/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOrF,MAAM,aAAa;IAClB,MAAM,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,KAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/F,MAAM,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAA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M,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,SAAS,GAAsB,EAAE,CAAC;YACxC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;YACnG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,CAAC;QACD,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,EAAc,CAAC,OAAO,EAAY,CAAC;QACxE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhF,CAAC;IAEO,gBAAgB,CAAC,KAAsB;QAC9C,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import { Identifier, Token, TokenExpression, TokenStream } from '@ibyar/expressions';\n\nexport type DirectiveExpressionType = {\n\ttemplateExpressions: Array<TokenExpression[]>;\n\tdirectiveInputs: Map<string, string>;\n};\n\nclass TokenConstant {\n\tstatic LET = new TokenExpression(Token.LET, [-1, -1]);\n\tstatic COMMA = new TokenExpression(Token.COMMA, [-1, -1]);\n\tstatic ASSIGN = new TokenExpression(Token.ASSIGN, [-1, -1]);\n\tstatic IMPLICIT = new TokenExpression(Token.IDENTIFIER, [-1, -1], new Identifier('$implicit'));\n\tstatic EOS = new TokenExpression(Token.EOS, [-1, -1]);\n}\n\nexport class DirectiveExpressionParser {\n\n\n\tpublic static parse(directiveName: string, expression: string): DirectiveExpressionType {\n\t\tconst stream = TokenStream.getTokenStream(expression);\n\t\tconst parser = new DirectiveExpressionParser(directiveName, stream);\n\t\ttry {\n\t\t\tparser.scan();\n\t\t} catch (error) {\n\t\t\tconsole.error('error parsing template expression', expression, parser, error);\n\t\t}\n\t\treturn parser.getDirectiveExpressionType();\n\t}\n\n\tprotected templateExpressions = new Array<TokenExpression[]>();\n\tprotected directiveInputs = new Map<string, string>();\n\n\tconstructor(protected directiveName: string, protected stream: TokenStream) { }\n\n\tgetDirectiveExpressionType(): DirectiveExpressionType {\n\t\treturn {\n\t\t\ttemplateExpressions: this.templateExpressions,\n\t\t\tdirectiveInputs: this.directiveInputs\n\t\t};\n\t}\n\tscan(): void {\n\t\t// parse 'let/const/var' if found, or switch to expression mode.\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tthis.parseTemplateInput();\n\t\t} else {\n\t\t\t// parse expression, possible ends is semicolon, comma, let and 'EOS'\n\t\t\tthis.parseExpression(this.directiveName);\n\t\t}\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.consumeSemicolonOrComma();\n\n\t\t// parse let and parseDirectiveAndTemplateInputs\n\t\twhile (this.stream.peek().isNotType(Token.EOS)) {\n\t\t\tthis.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();\n\t\t\tthis.consumeSemicolonOrComma();\n\t\t}\n\t}\n\tprotected consume(token: Token) {\n\t\tif (this.stream.next().isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t}\n\tprotected check(token: Token): boolean {\n\t\tconst peek = this.stream.peek();\n\t\tif (peek.isType(token)) {\n\t\t\tthis.stream.next();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprotected consumeToList(token: Token, list: TokenExpression[]) {\n\t\tconst next = this.stream.next();\n\t\tif (next.isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t\tlist.push(next);\n\t}\n\n\tprotected consumeIfToken(token: Token, list: TokenExpression[]): boolean {\n\t\tconst next = this.stream.peek();\n\t\tif (next.isNotType(token)) {\n\t\t\treturn false;\n\t\t}\n\t\tlist.push(next);\n\t\tthis.stream.next();\n\t\treturn true;\n\t}\n\n\tprotected isDeclareKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.LET) || peek.isType(Token.CONST) || peek.isType(Token.VAR);\n\t}\n\n\tprotected isIdentifier(): boolean {\n\t\treturn this.stream.peek().isType(Token.IDENTIFIER);\n\t}\n\n\tprotected isAsKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.IDENTIFIER) && (peek.getValue<Identifier>().getName() == 'as');\n\t}\n\n\tprotected consumeAsKeyword() {\n\t\tthis.consume(Token.IDENTIFIER);\n\t}\n\tprotected isSemicolon() {\n\t\treturn this.stream.peek().isType(Token.SEMICOLON);\n\t}\n\tprotected isComma() {\n\t\treturn this.stream.peek().isType(Token.COMMA);\n\t}\n\tprotected consumeSemicolonOrComma() {\n\t\tlet peek = this.stream.peek();\n\t\tif (peek.isType(Token.SEMICOLON) || peek.isType(Token.COMMA)) {\n\t\t\tthis.stream.next();\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected parseTemplateInput() {\n\t\t// let = \"let\" :local \"=\" :export \";\"?\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tlet peek = this.stream.peek();\n\t\t\tconst list: TokenExpression[] = [peek];\n\t\t\tthis.consume(peek.token);\n\t\t\tpeek = this.stream.peek();\n\t\t\tif (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {\n\t\t\t\t// object and array pattern, destructing\n\t\t\t\tthis.stream.readTill(Token.closeOf(peek.token), list);\n\t\t\t} else if (peek.isType(Token.IDENTIFIER)) {\n\t\t\t\tthis.consumeToList(Token.IDENTIFIER, list);\n\t\t\t} else {\n\t\t\t\tthrow new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));\n\t\t\t}\n\t\t\tif (this.consumeIfToken(Token.ASSIGN, list)) {\n\t\t\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\t\t\t} else {\n\t\t\t\tlist.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);\n\t\t\t}\n\t\t\tthis.templateExpressions.push(list);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected parseExpression(inputName: string) {\n\t\tconst list: TokenExpression[] = [];\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\t/**\n\t * check if the first is\n\t * @returns `boolean`\n\t */\n\tprotected parseDirectiveAndTemplateInputs() {\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputToken: TokenExpression;\n\t\tif (this.isIdentifier()) {\n\t\t\tinputToken = this.stream.next();\n\t\t} else {\n\t\t\tinputToken = this.stream.next();\n\t\t\tconst identifierName = inputToken.token.getName();\n\t\t\tinputToken = new TokenExpression(Token.IDENTIFIER, [-1, -1], new Identifier(identifierName));\n\t\t}\n\n\t\t// only template input\n\t\t// mapping from directive scope(context) to template scope\n\t\tif (this.isAsKeyword()) {\n\t\t\t// as = :export \"as\" :local \";\"?\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input as alias`\n\t\t\t// ==> in template -> alias = input\n\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.check(Token.ASSIGN) || this.check(Token.COLON);\n\n\t\tconst list: TokenExpression[] = [];\n\t\t// keyExp = :key \":\"? :expression (\"as\" :local)? \";\"?\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\n\t\t// mix for directive input and template input\n\t\tif (this.isAsKeyword()) {\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input {x: 7, y: 9} as alias` \n\t\t\t// ==> in directive ->`input = {x: 7, y: 9}`\n\t\t\t// ==> or in template -> let alias = input\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t}\n\t\tconst inputName = inputToken.getValue<Identifier>().getName() as string;\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\n\t}\n\n\tprivate mapTokenToString(token: TokenExpression): String {\n\t\tif (token.value) {\n\t\t\treturn token.value.toString();\n\t\t}\n\t\treturn token.token.getName();\n\t}\n\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOrF,MAAM,aAAa;IAClB,MAAM,CAAC,GAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,KAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,QAAQ,GAAG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AAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import { Identifier, Token, TokenExpression, TokenStream } from '@ibyar/expressions';\n\nexport type DirectiveExpressionType = {\n\ttemplateExpressions: Array<TokenExpression[]>;\n\tdirectiveInputs: Map<string, string>;\n};\n\nclass TokenConstant {\n\tstatic LET = new TokenExpression(Token.LET, [-1, -1]);\n\tstatic COMMA = new TokenExpression(Token.COMMA, [-1, -1]);\n\tstatic ASSIGN = new TokenExpression(Token.ASSIGN, [-1, -1]);\n\tstatic IMPLICIT = new TokenExpression(Token.IDENTIFIER, [-1, -1], new Identifier('$implicit'));\n\tstatic EOS = new TokenExpression(Token.EOS, [-1, -1]);\n}\n\nexport class DirectiveExpressionParser {\n\n\n\tpublic static parse(directiveName: string, expression: string): DirectiveExpressionType {\n\t\tconst stream = TokenStream.getTokenStream(expression);\n\t\tconst parser = new DirectiveExpressionParser(directiveName, stream);\n\t\ttry {\n\t\t\tparser.scan();\n\t\t} catch (error) {\n\t\t\tconsole.error('error parsing template expression', expression, parser, error);\n\t\t}\n\t\treturn parser.getDirectiveExpressionType();\n\t}\n\n\tprotected templateExpressions = new Array<TokenExpression[]>();\n\tprotected directiveInputs = new Map<string, string>();\n\n\tconstructor(protected directiveName: string, protected stream: TokenStream) { }\n\n\tgetDirectiveExpressionType(): DirectiveExpressionType {\n\t\treturn {\n\t\t\ttemplateExpressions: this.templateExpressions,\n\t\t\tdirectiveInputs: this.directiveInputs\n\t\t};\n\t}\n\tscan(): void {\n\t\t// parse 'let/const/var' if found, or switch to expression mode.\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tthis.parseTemplateInput(false);\n\t\t} else {\n\t\t\t// parse expression, possible ends is semicolon, comma, let and 'EOS'\n\t\t\tthis.parseExpression(this.directiveName);\n\t\t}\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.consumeSemicolonOrComma();\n\n\t\t// parse let and parseDirectiveAndTemplateInputs\n\t\twhile (this.stream.peek().isNotType(Token.EOS)) {\n\t\t\tthis.parseTemplateInput(true) || this.parseDirectiveAndTemplateInputs();\n\t\t\tthis.consumeSemicolonOrComma();\n\t\t}\n\t}\n\tprotected consume(token: Token) {\n\t\tif (this.stream.next().isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t}\n\tprotected check(token: Token): boolean {\n\t\tconst peek = this.stream.peek();\n\t\tif (peek.isType(token)) {\n\t\t\tthis.stream.next();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprotected consumeToList(token: Token, list: TokenExpression[]) {\n\t\tconst next = this.stream.next();\n\t\tif (next.isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t\tlist.push(next);\n\t}\n\n\tprotected consumeIfToken(token: Token, list: TokenExpression[]): boolean {\n\t\tconst next = this.stream.peek();\n\t\tif (next.isNotType(token)) {\n\t\t\treturn false;\n\t\t}\n\t\tlist.push(next);\n\t\tthis.stream.next();\n\t\treturn true;\n\t}\n\n\tprotected isDeclareKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.LET) || peek.isType(Token.CONST) || peek.isType(Token.VAR);\n\t}\n\n\tprotected isIdentifier(): boolean {\n\t\treturn this.stream.peek().isType(Token.IDENTIFIER);\n\t}\n\n\tprotected isAsKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.IDENTIFIER) && (peek.getValue<Identifier>().getName() == 'as');\n\t}\n\n\tprotected consumeAsKeyword() {\n\t\tthis.consume(Token.IDENTIFIER);\n\t}\n\tprotected isSemicolon() {\n\t\treturn this.stream.peek().isType(Token.SEMICOLON);\n\t}\n\tprotected isComma() {\n\t\treturn this.stream.peek().isType(Token.COMMA);\n\t}\n\tprotected consumeSemicolonOrComma() {\n\t\tlet peek = this.stream.peek();\n\t\tif (peek.isType(Token.SEMICOLON) || peek.isType(Token.COMMA)) {\n\t\t\tthis.stream.next();\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprotected parseTemplateInput(allowComma: boolean) {\n\t\t// let = \"let\" :local \"=\" :export \";\"?\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tlet peek = this.stream.peek();\n\t\t\tconst list: TokenExpression[] = [peek];\n\t\t\tthis.consume(peek.token);\n\t\t\tthis.consumeDeclarations(list);\n\t\t\twhile (allowComma && this.stream.currentToken().isType(Token.COMMA)) {\n\t\t\t\tlist.push(TokenConstant.COMMA);\n\t\t\t\tthis.consumeDeclarations(list);\n\t\t\t}\n\t\t\tthis.templateExpressions.push(list);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate consumeDeclarations(list: TokenExpression[]) {\n\t\tconst peek = this.stream.peek();\n\t\tif (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {\n\t\t\t// object and array pattern, destructing\n\t\t\tthis.stream.readTill(Token.closeOf(peek.token), list);\n\t\t} else if (peek.isType(Token.IDENTIFIER)) {\n\t\t\tthis.consumeToList(Token.IDENTIFIER, list);\n\t\t} else {\n\t\t\tthrow new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));\n\t\t}\n\t\tif (this.consumeIfToken(Token.ASSIGN, list)) {\n\t\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\t\t} else {\n\t\t\tlist.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);\n\t\t}\n\t}\n\n\tprotected parseExpression(inputName: string) {\n\t\tconst list: TokenExpression[] = [];\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\t/**\n\t * check if the first is\n\t * @returns `boolean`\n\t */\n\tprotected parseDirectiveAndTemplateInputs() {\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputToken: TokenExpression;\n\t\tif (this.isIdentifier()) {\n\t\t\tinputToken = this.stream.next();\n\t\t} else {\n\t\t\tinputToken = this.stream.next();\n\t\t\tconst identifierName = inputToken.token.getName();\n\t\t\tinputToken = new TokenExpression(Token.IDENTIFIER, [-1, -1], new Identifier(identifierName));\n\t\t}\n\n\t\t// only template input\n\t\t// mapping from directive scope(context) to template scope\n\t\tif (this.isAsKeyword()) {\n\t\t\t// as = :export \"as\" :local \";\"?\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input as alias`\n\t\t\t// ==> in template -> alias = input\n\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.check(Token.ASSIGN) || this.check(Token.COLON);\n\n\t\tconst list: TokenExpression[] = [];\n\t\t// keyExp = :key \":\"? :expression (\"as\" :local)? \";\"?\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\n\t\t// mix for directive input and template input\n\t\tif (this.isAsKeyword()) {\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input {x: 7, y: 9} as alias` \n\t\t\t// ==> in directive ->`input = {x: 7, y: 9}`\n\t\t\t// ==> or in template -> let alias = input\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t}\n\t\tconst inputName = inputToken.getValue<Identifier>().getName() as string;\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\tprivate mapTokenToString(token: TokenExpression): String {\n\t\tif (token.value) {\n\t\t\treturn token.value.toString();\n\t\t}\n\t\treturn token.token.getName();\n\t}\n\n}\n\n"]}
|
package/html/expression.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAEsC,OAAO,EAInD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,cAAc,EAEd,MAAM,oBAAoB,CAAC;AA2E5B,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,cAAc,GAAG,MAAM,EAAE,GAAG,SAAS,CAWtF;
|
|
1
|
+
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAEsC,OAAO,EAInD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,cAAc,EAEd,MAAM,oBAAoB,CAAC;AA2E5B,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,cAAc,GAAG,MAAM,EAAE,GAAG,SAAS,CAWtF;AA8FD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,QAMjD"}
|
package/html/expression.js
CHANGED
|
@@ -88,7 +88,7 @@ function parseLiveAttributeUpdateElement(attr) {
|
|
|
88
88
|
attr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
console.error(
|
|
91
|
+
console.error(`[${attr.name}] is not a valid MemberExpression 'x.y.z'`);
|
|
92
92
|
}
|
|
93
93
|
attr.pipelineNames = getPipelineNames(modelExpression);
|
|
94
94
|
}
|
|
@@ -143,6 +143,9 @@ function parseChild(child) {
|
|
|
143
143
|
// in case if add input/output support need to handle that here.
|
|
144
144
|
parseChild(child.node);
|
|
145
145
|
parseBaseNode(child);
|
|
146
|
+
if (child.successor) {
|
|
147
|
+
parseChild(child.successor);
|
|
148
|
+
}
|
|
146
149
|
}
|
|
147
150
|
else if (isLiveTextContent(child)) {
|
|
148
151
|
parseLiveText(child);
|