@ibyar/core 0.8.5 → 0.8.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.
- package/annotation/decorators.js.map +1 -1
- package/component/component.d.ts +4 -1
- package/component/component.js +78 -12
- package/component/component.js.map +1 -1
- package/package.json +6 -6
- package/view/base-view.js +4 -0
- package/view/base-view.js.map +1 -1
- package/view/render.d.ts +1 -2
- package/view/render.js +12 -13
- package/view/render.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAe,MAAM,kBAAkB,CAAC;AAmR1D,MAAM,UAAU,KAAK,CAAC,IAAa;IAClC,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,iBAAiB,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC;IACtE,CAAC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS;IACxB,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,iBAAiB,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC,CAAC;AACH,CAAC;AAOD,MAAM,UAAU,MAAM,CAAC,IAA6B,EAAE,OAAyB;IAC9E,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9D,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IAC5D,OAAO,CA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AC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAwB,GAAoD;IACxG,OAAO,CAAC,MAAiB,EAAE,EAAE;QAC5B,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACnC,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { Components } from '../component/component.js';\nimport { ReflectComponents } from '../component/reflect.js';\nimport { fetchHtml, 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 * - 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 = 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;\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?: keyof HTMLElementTagNameMap;\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\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@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 function Input(name?: string): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tReflectComponents.addInput(target, propertyKey, name || propertyKey);\n\t};\n}\n\nexport function FormValue(): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tReflectComponents.addInput(target, propertyKey, 'value');\n\t};\n}\n\nexport type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n\nexport function Output(options?: OutputOptions): Function;\nexport function Output(name?: string, options?: OutputEventInit): Function;\nexport function Output(name?: string | OutputOptions, options?: OutputEventInit): Function {\n\tconst eventType = typeof name === 'object' ? name.name : name;\n\tconst eventOpts = typeof name === 'object' ? name : options;\n\treturn (target: Object, propertyKey: string) => {\n\t\tReflectComponents.addOutput(\n\t\t\ttarget,\n\t\t\tpropertyKey, eventType || propertyKey,\n\t\t\t{\n\t\t\t\tbubbles: eventOpts?.bubbles ?? false,\n\t\t\t\tcomposed: eventOpts?.composed ?? false\n\t\t\t}\n\t\t);\n\t};\n}\n\nexport function View(): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tReflectComponents.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\tReflectComponents.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\tReflectComponents.addViewChildren(target, propertyKey, selector);\n\t};\n}\n\nexport function HostListener(eventName: string, args?: string | string[]): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\targs = typeof args === 'string' ? [args] : args;\n\t\tReflectComponents.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\tReflectComponents.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\nfunction generateComponent<T extends { new(...args: any[]): {} }>(target: TypeOf<T>, opt: ComponentOptions<T>) {\n\tif (opt.templateUrl) {\n\t\tfetchHtml(opt.templateUrl)\n\t\t\t.then(htmlTemplate => {\n\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\tComponents.defineComponent(target, opt);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(reason => {\n\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t});\n\t} else {\n\t\tComponents.defineComponent(target, opt);\n\t}\n}\n\nexport function Component<T extends { new(...args: any[]): {} }>(opt: ComponentOptions<T> | ComponentOptions<T>[]): Function {\n\treturn (target: TypeOf<T>) => {\n\t\tif (Array.isArray(opt)) {\n\t\t\tfor (const comp of opt) {\n\t\t\t\tgenerateComponent(target, comp);\n\t\t\t}\n\t\t} else if (typeof opt === 'object') {\n\t\t\tgenerateComponent(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\nexport function customElement<T extends HTMLElement>(opt: { selector: string } & ElementDefinitionOptions): Function {\n\treturn (target: TypeOf<T>) => {\n\t\tComponents.defineView(target, opt);\n\t\treturn target;\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAe,MAAM,kBAAkB,CAAC;AAmR1D,MAAM,UAAU,KAAK,CAAC,IAAa;IAClC,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,iBAAiB,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC;IACtE,CAAC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS;IACxB,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC9C,iBAA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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;AAED,MAAM,UAAU,aAAa,CAAwB,GAAoD;IACxG,OAAO,CAAC,MAAiB,EAAE,EAAE;QAC5B,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACnC,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { Components } from '../component/component.js';\nimport { ReflectComponents } from '../component/reflect.js';\nimport { fetchHtml, 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 * - 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 = 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;\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?: keyof HTMLElementTagNameMap;\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\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@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 function Input(name?: string): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tReflectComponents.addInput(target, propertyKey, name || propertyKey);\n\t};\n}\n\nexport function FormValue(): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tReflectComponents.addInput(target, propertyKey, 'value');\n\t};\n}\n\nexport type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n\nexport function Output(options?: OutputOptions): Function;\nexport function Output(name?: string, options?: OutputEventInit): Function;\nexport function Output(name?: string | OutputOptions, options?: OutputEventInit): Function {\n\tconst eventType = typeof name === 'object' ? name.name : name;\n\tconst eventOpts = typeof name === 'object' ? name : options;\n\treturn (target: Object, propertyKey: string) => {\n\t\tReflectComponents.addOutput(\n\t\t\ttarget,\n\t\t\tpropertyKey, eventType || propertyKey,\n\t\t\t{\n\t\t\t\tbubbles: eventOpts?.bubbles ?? false,\n\t\t\t\tcomposed: eventOpts?.composed ?? false\n\t\t\t}\n\t\t);\n\t};\n}\n\nexport function View(): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\tReflectComponents.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\tReflectComponents.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\tReflectComponents.addViewChildren(target, propertyKey, selector);\n\t};\n}\n\nexport function HostListener(eventName: string, args?: string | string[]): Function {\n\treturn (target: Object, propertyKey: string) => {\n\t\targs = typeof args === 'string' ? [args] : args;\n\t\tReflectComponents.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\tReflectComponents.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}\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\nfunction generateComponent<T extends { new(...args: any[]): {} }>(target: TypeOf<T>, opt: ComponentOptions<T>) {\n\tif (opt.templateUrl) {\n\t\tfetchHtml(opt.templateUrl)\n\t\t\t.then(htmlTemplate => {\n\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\tComponents.defineComponent(target, opt);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(reason => {\n\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t});\n\t} else {\n\t\tComponents.defineComponent(target, opt);\n\t}\n}\n\nexport function Component<T extends { new(...args: any[]): {} }>(opt: ComponentOptions<T> | ComponentOptions<T>[]): Function {\n\treturn (target: TypeOf<T>) => {\n\t\tif (Array.isArray(opt)) {\n\t\t\tfor (const comp of opt) {\n\t\t\t\tgenerateComponent(target, comp);\n\t\t\t}\n\t\t} else if (typeof opt === 'object') {\n\t\t\tgenerateComponent(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\nexport function customElement<T extends HTMLElement>(opt: { selector: string } & ElementDefinitionOptions): Function {\n\treturn (target: TypeOf<T>) => {\n\t\tComponents.defineView(target, opt);\n\t\treturn target;\n\t};\n}\n"]}
|
package/component/component.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export interface ComponentRef<T> {
|
|
|
44
44
|
hostBindings: HostBindingRef[];
|
|
45
45
|
hostListeners: ListenerRef[];
|
|
46
46
|
viewBindings?: DomElementNode;
|
|
47
|
+
windowBindings?: DomElementNode;
|
|
47
48
|
encapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';
|
|
48
49
|
isShadowDom: boolean;
|
|
49
50
|
shadowDomMode: ShadowRootMode;
|
|
@@ -54,7 +55,9 @@ export interface ComponentRef<T> {
|
|
|
54
55
|
export declare class Components {
|
|
55
56
|
private static EMPTY_LIST;
|
|
56
57
|
private static emptyList;
|
|
57
|
-
private static
|
|
58
|
+
private static patchTemplate;
|
|
59
|
+
private static createOutputs;
|
|
60
|
+
private static parseHostNode;
|
|
58
61
|
static defineDirective(modelClass: Function, opts: DirectiveOptions): void;
|
|
59
62
|
static definePipe(modelClass: Function, opts: PipeOptions): void;
|
|
60
63
|
static defineService(modelClass: Function, opts: ServiceOptions): void;
|
package/component/component.js
CHANGED
|
@@ -1,37 +1,88 @@
|
|
|
1
|
-
import { findByTagName, htmlParser, templateParser, canAttachShadow, directiveRegistry } from '@ibyar/elements';
|
|
1
|
+
import { findByTagName, htmlParser, templateParser, canAttachShadow, directiveRegistry, DomElementNode, DomFragmentNode, DomParentNode } from '@ibyar/elements';
|
|
2
2
|
import { ClassRegistryProvider } from '../providers/provider.js';
|
|
3
3
|
import { initCustomElementView } from '../view/view.js';
|
|
4
4
|
import { buildExpressionNodes } from '../html/expression.js';
|
|
5
|
-
import { ReflectComponents } from './reflect.js';
|
|
5
|
+
import { ListenerRef, ReflectComponents } from './reflect.js';
|
|
6
6
|
import { deserializeExpressionNodes } from '../html/deserialize.js';
|
|
7
7
|
export class Components {
|
|
8
8
|
static emptyList() {
|
|
9
9
|
return Components.EMPTY_LIST;
|
|
10
10
|
}
|
|
11
|
-
static
|
|
11
|
+
static patchTemplate(child, templates) {
|
|
12
|
+
if (child instanceof DomElementNode && child.templateRefName?.name) {
|
|
13
|
+
const ref = templates.find(node => child.templateRefName?.name === node.templateRefName?.name);
|
|
14
|
+
if (ref?.outputs) {
|
|
15
|
+
(child.outputs ?? (child.outputs = [])).push(...ref.outputs);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (child instanceof DomParentNode) {
|
|
19
|
+
child.children?.forEach(node => Components.patchTemplate(node, templates));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
static createOutputs(Listeners) {
|
|
23
|
+
return Listeners?.map(listener => `(${listener.eventName})="${listener.modelCallbackName}(${listener.args.join(', ')})"`).join(' ') ?? '';
|
|
24
|
+
}
|
|
25
|
+
static parseHostNode(option) {
|
|
12
26
|
const inputs = option.hostBindings?.map(binding => {
|
|
13
27
|
const descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);
|
|
14
28
|
if (typeof descriptor?.value === 'function') {
|
|
15
29
|
return `[${binding.hostPropertyName}]="${binding.modelPropertyName}()"`;
|
|
16
30
|
}
|
|
17
31
|
return `[${binding.hostPropertyName}]="${binding.modelPropertyName}"`;
|
|
18
|
-
}) ??
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
}).join(' ') ?? '';
|
|
33
|
+
const hostListeners = [];
|
|
34
|
+
const windowListeners = [];
|
|
35
|
+
const templateListeners = {};
|
|
36
|
+
option.hostListeners?.forEach(listener => {
|
|
37
|
+
const [host, event] = listener.eventName.split(':', 2);
|
|
38
|
+
if (event === undefined) {
|
|
39
|
+
hostListeners.push(listener);
|
|
40
|
+
}
|
|
41
|
+
else if ('window' === host.toLowerCase()) {
|
|
42
|
+
windowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
(templateListeners[host] ?? (templateListeners[host] = [])).push(new ListenerRef(event, listener.args, listener.modelCallbackName));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const result = {};
|
|
49
|
+
if (hostListeners.length) {
|
|
50
|
+
const hostOutputs = Components.createOutputs(hostListeners);
|
|
51
|
+
const selector = option.selector ?? 'div';
|
|
52
|
+
const hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;
|
|
53
|
+
result.host = htmlParser.toDomRootNode(hostTemplate);
|
|
54
|
+
buildExpressionNodes(result.host);
|
|
55
|
+
}
|
|
56
|
+
if (windowListeners.length) {
|
|
57
|
+
const windowOutputs = Components.createOutputs(windowListeners);
|
|
58
|
+
const windowTemplate = `<window ${windowOutputs}></window>`;
|
|
59
|
+
result.window = htmlParser.toDomRootNode(windowTemplate);
|
|
60
|
+
buildExpressionNodes(result.window);
|
|
61
|
+
}
|
|
62
|
+
const templateHosts = Object.keys(templateListeners);
|
|
63
|
+
if (templateHosts.length) {
|
|
64
|
+
const template = templateHosts.map(host => {
|
|
65
|
+
const hostOutputs = Components.createOutputs(templateListeners[host]);
|
|
66
|
+
return `<template #${host} ${hostOutputs}></template>`;
|
|
67
|
+
}).join('');
|
|
68
|
+
const templateNodes = htmlParser.toDomRootNode(template);
|
|
69
|
+
buildExpressionNodes(templateNodes);
|
|
70
|
+
result.template = templateNodes instanceof DomFragmentNode
|
|
71
|
+
? templateNodes.children?.filter(child => child instanceof DomElementNode) ?? []
|
|
72
|
+
: [templateNodes];
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
25
75
|
}
|
|
26
76
|
static defineDirective(modelClass, opts) {
|
|
27
77
|
const bootstrap = ReflectComponents.getOrCreateBootstrap(modelClass.prototype);
|
|
28
78
|
Object.assign(bootstrap, opts);
|
|
29
79
|
if (bootstrap.hostListeners?.length || bootstrap.hostBindings?.length) {
|
|
30
|
-
|
|
80
|
+
const hostNode = Components.parseHostNode({
|
|
31
81
|
prototype: modelClass.prototype,
|
|
32
82
|
hostBindings: bootstrap.hostBindings,
|
|
33
83
|
hostListeners: bootstrap.hostListeners,
|
|
34
84
|
});
|
|
85
|
+
bootstrap.viewBindings = hostNode.host;
|
|
35
86
|
}
|
|
36
87
|
bootstrap.modelClass = modelClass;
|
|
37
88
|
ClassRegistryProvider.registerDirective(modelClass);
|
|
@@ -101,12 +152,27 @@ export class Components {
|
|
|
101
152
|
componentRef.shadowDomMode || (componentRef.shadowDomMode = 'open');
|
|
102
153
|
componentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;
|
|
103
154
|
if (componentRef.hostListeners.length || componentRef.hostBindings.length) {
|
|
104
|
-
|
|
155
|
+
const hostNode = Components.parseHostNode({
|
|
105
156
|
prototype: modelClass.prototype,
|
|
106
157
|
selector: componentRef.selector,
|
|
107
158
|
hostBindings: componentRef.hostBindings,
|
|
108
159
|
hostListeners: componentRef.hostListeners,
|
|
109
160
|
});
|
|
161
|
+
componentRef.viewBindings = hostNode.host;
|
|
162
|
+
componentRef.windowBindings = hostNode.window;
|
|
163
|
+
if (typeof componentRef.template === 'function') {
|
|
164
|
+
const creator = componentRef.template;
|
|
165
|
+
componentRef.template = (model) => {
|
|
166
|
+
const template = creator(model);
|
|
167
|
+
if (hostNode.template) {
|
|
168
|
+
Components.patchTemplate(template, hostNode.template);
|
|
169
|
+
}
|
|
170
|
+
return template;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
else if (hostNode.template) {
|
|
174
|
+
Components.patchTemplate(componentRef.template, hostNode.template);
|
|
175
|
+
}
|
|
110
176
|
}
|
|
111
177
|
if (!(componentRef.formAssociated === true || typeof componentRef.formAssociated === 'function')) {
|
|
112
178
|
componentRef.formAssociated = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,aAAa,EAAO,UAAU,EAAE,cAAc,EACtB,eAAe,EACvC,iBAAiB,EACjB,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,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Y,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAExE,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAExD,MAAM,OAAO,GAA6B,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;QAChD,IAAI,aAAa,EAAE;YAClB,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC/D,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;aAChC;SACD;QAGD,cAAc,CAAC,MAAM,CACpB,YAAY,CAAC,QAAkB,EAC/B,YAAY,CAAC,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;IAED,MAAM,CAAC,UAAU,CAAwB,SAAoB,EAAE,GAAoD;QAClH,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC9C,cAAc,CAAC,MAAM,CACpB,GAAG,CAAC,QAAkB,EACtB,SAAS,EACT,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAC/C,CAAC;IACH,CAAC;;AAxJc,qBAAU,GAAG,MAAM,CAAC,MAAM,CAAM,EAAE,CAAC,CAAC","sourcesContent":["import type { 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} 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/decorators.js';\nimport {\n\tBootstrapMetadata, ChildRef, HostBindingRef,\n\tInputPropertyRef, ListenerRef, OutputPropertyRef,\n\tPropertyRef, ReflectComponents\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\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\n\tviewClass: TypeOf<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\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\tisShadowDom: boolean;\n\tshadowDomMode: ShadowRootMode;\n\tshadowDomDelegatesFocus: boolean;\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\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 parseHostBinding(option: ViewBindingOption): DomElementNode {\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}) ?? [];\n\t\tconst outputs = option.hostListeners?.map(\n\t\t\tlistener => `(${listener.eventName})=\"${listener.modelCallbackName}(${listener.args.join(', ')})\"`\n\t\t) ?? [];\n\t\toption.selector ??= 'div';\n\t\tconst template = `<${option.selector} ${inputs.join(' ')} ${outputs.join(' ')}></${option.selector}>`;\n\t\tconst viewBindings = htmlParser.toDomRootNode(template) as DomElementNode;\n\t\tbuildExpressionNodes(viewBindings);\n\t\treturn viewBindings;\n\t}\n\n\tstatic defineDirective(modelClass: Function, opts: DirectiveOptions) {\n\t\tconst bootstrap: BootstrapMetadata = ReflectComponents.getOrCreateBootstrap(modelClass.prototype);\n\t\tObject.assign(bootstrap, opts);\n\t\tif (bootstrap.hostListeners?.length || bootstrap.hostBindings?.length) {\n\t\t\tbootstrap.viewBindings = Components.parseHostBinding({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: bootstrap.hostBindings,\n\t\t\t\thostListeners: bootstrap.hostListeners,\n\t\t\t});\n\t\t}\n\t\tbootstrap.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (bootstrap.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (bootstrap.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t});\n\t}\n\n\tstatic definePipe(modelClass: Function, opts: PipeOptions) {\n\t\tconst bootstrap: BootstrapMetadata = ReflectComponents.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 = ReflectComponents.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 = ReflectComponents.getOrCreateBootstrap(modelClass.prototype);\n\t\tconst componentRef = Object.assign({}, opts, bootstrap) as any as ComponentRef<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} 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-dom/g.test(componentRef.encapsulation);\n\t\tcomponentRef.shadowDomMode ||= 'open';\n\t\tcomponentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tcomponentRef.viewBindings = Components.parseHostBinding({\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}\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\t\tReflectComponents.setComponentRef(componentRef.modelClass, componentRef);\n\t\tReflectComponents.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\tstatic defineView<T extends HTMLElement>(viewClass: TypeOf<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tcustomElements.define(\n\t\t\topt.selector as string,\n\t\t\tviewClass,\n\t\t\tObject.assign({}, opt, { selector: undefined }),\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,aAAa,EAAO,UAAU,EAAE,cAAc,EACtB,eAAe,EACvC,iBAAiB,EAAE,cAAc,EACjC,eAAe,EAAE,aAAa,EAC9B,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,EAEY,WAAW,EAChB,iBAAiB,EAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAwEpE,MAAM,OAAO,UAAU;IAGd,MAAM,CAAC,SAAS;QACvB,OAAO,UAAU,CAAC,UAAiB,CAAC;IACrC,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,KAAc,EAAE,SAA2B;QACvE,IAAI,KAAK,YAAY,cA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AM,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAC/C,CAAC;IACH,CAAC;;AAjOc,qBAAU,GAAG,MAAM,CAAC,MAAM,CAAM,EAAE,CAAC,CAAC","sourcesContent":["import type { 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} 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/decorators.js';\nimport {\n\tBootstrapMetadata, ChildRef, HostBindingRef,\n\tInputPropertyRef, ListenerRef, OutputPropertyRef,\n\tPropertyRef, ReflectComponents\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\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\n\tviewClass: TypeOf<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';\n\tisShadowDom: boolean;\n\tshadowDomMode: ShadowRootMode;\n\tshadowDomDelegatesFocus: boolean;\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\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: Function, opts: DirectiveOptions) {\n\t\tconst bootstrap: BootstrapMetadata = ReflectComponents.getOrCreateBootstrap(modelClass.prototype);\n\t\tObject.assign(bootstrap, opts);\n\t\tif (bootstrap.hostListeners?.length || bootstrap.hostBindings?.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: bootstrap.hostBindings,\n\t\t\t\thostListeners: bootstrap.hostListeners,\n\t\t\t});\n\t\t\tbootstrap.viewBindings = hostNode.host;\n\t\t}\n\t\tbootstrap.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (bootstrap.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (bootstrap.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t});\n\t}\n\n\tstatic definePipe(modelClass: Function, opts: PipeOptions) {\n\t\tconst bootstrap: BootstrapMetadata = ReflectComponents.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 = ReflectComponents.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 = ReflectComponents.getOrCreateBootstrap(modelClass.prototype);\n\t\tconst componentRef = Object.assign({}, opts, bootstrap) as any as ComponentRef<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} 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-dom/g.test(componentRef.encapsulation);\n\t\tcomponentRef.shadowDomMode ||= 'open';\n\t\tcomponentRef.shadowDomDelegatesFocus = componentRef.shadowDomDelegatesFocus === true || false;\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\t\tReflectComponents.setComponentRef(componentRef.modelClass, componentRef);\n\t\tReflectComponents.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\tstatic defineView<T extends HTMLElement>(viewClass: TypeOf<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tcustomElements.define(\n\t\t\topt.selector as string,\n\t\t\tviewClass,\n\t\t\tObject.assign({}, opt, { selector: undefined }),\n\t\t);\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibyar/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "Ibyar core, Implements Aurora's core functionality, low-level services, and utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ibyar/aurora/tree/dev/packages/core",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ibyar/elements": "^0.8.
|
|
39
|
-
"@ibyar/expressions": "^0.8.
|
|
38
|
+
"@ibyar/elements": "^0.8.6",
|
|
39
|
+
"@ibyar/expressions": "^0.8.6",
|
|
40
40
|
"reflect-metadata": "^0.1.13",
|
|
41
|
-
"tslib": "^2.
|
|
41
|
+
"tslib": "^2.5.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"zone.js": "~0.11.4 || ~0.12.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"typescript": "^4.9.
|
|
47
|
+
"typescript": "^4.9.5"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc --build --verbose"
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"typescript",
|
|
79
79
|
"front-end"
|
|
80
80
|
],
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "68473e88cb933d2f7d25ee7ea15e73c60630fc81"
|
|
82
82
|
}
|
package/view/base-view.js
CHANGED
|
@@ -223,6 +223,8 @@ export function baseFactoryView(htmlElementType) {
|
|
|
223
223
|
this._zone.run(this._model.afterViewChecked, this._modelScope.getContextProxy());
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
|
+
const event = new CustomEvent('connected', { cancelable: true, bubbles: false, composed: false });
|
|
227
|
+
this.dispatchEvent(event);
|
|
226
228
|
}
|
|
227
229
|
initOuterAttribute(attr) {
|
|
228
230
|
// [window, this] scop
|
|
@@ -285,6 +287,8 @@ export function baseFactoryView(htmlElementType) {
|
|
|
285
287
|
}
|
|
286
288
|
});
|
|
287
289
|
this.onDestroyCalls.splice(0, this.onDestroyCalls.length);
|
|
290
|
+
const event = new CustomEvent('disconnected', { cancelable: true, bubbles: false, composed: false });
|
|
291
|
+
this.dispatchEvent(event);
|
|
288
292
|
}
|
|
289
293
|
triggerOutput(eventName, value) {
|
|
290
294
|
const modelEvent = this.getEventEmitter(eventName);
|
package/view/base-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAA8B,MAAM,oBAAoB,CAAC;AACrG,OAAO,EACN,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAC7D,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAC9D,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,eAAe,EAA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,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,eAAgB,EAAE,CAAC,CAAC;aAC3E;YACD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACxD,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBACtC,IAAI;oBACH,QAAQ,EAAE,CAAC;iBACX;gBAAC,OAAO,KAAK,EAAE;oBACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACrB;YACF,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC3D,CAAC;QAED,aAAa,CAAC,SAAiB,EAAE,KAAW;YAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACxD,IAAI,UAAU,EAAE;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO;aACP;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope, ReactiveScopeControl, Context, ScopeSubscription } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef } from '../component/component.js';\nimport { BaseComponent, CustomElement, HTMLComponent, ModelType } from '../component/custom-element.js';\nimport { EventEmitter } from '../component/events.js';\nimport { ComponentRender } from './render.js';\nimport { getRootZone } from '../zone/bootstrap.js';\nimport { AuroraZone, ProxyAuroraZone } from '../zone/zone.js';\nimport { createModelChangeDetectorRef } from '../linker/change-detector-ref.js';\nimport { createProxyZone } from '../zone/proxy.js';\nimport { PropertyRef } from '../component/reflect.js';\n\nexport function baseFactoryView<T extends object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\treturn class CustomView extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: ModelType<T>;\n\t\t_parentComponent: HTMLComponent<object>;\n\t\t_render: ComponentRender<T>;\n\t\t_shadowRoot: ShadowRoot;\n\n\t\t_componentRef: ComponentRef<T>;\n\n\t\t_modelScope: ReactiveScopeControl<T>;\n\t\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\t\t_zone: AuroraZone;\n\n\t\tprivate subscriptions: ScopeSubscription<Context>[] = [];\n\t\tprivate onDestroyCalls: (() => void)[] = [];\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper();\n\t\t\tthis._componentRef = componentRef;\n\t\t\tif (componentRef.isShadowDom) {\n\t\t\t\tthis._shadowRoot = this.attachShadow({\n\t\t\t\t\tmode: componentRef.shadowDomMode,\n\t\t\t\t\tdelegatesFocus: componentRef.shadowDomDelegatesFocus\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst args = []; /* resolve dependency injection*/\n\t\t\tconst detector = createModelChangeDetectorRef(() => this._modelScope);\n\t\t\targs.push(detector)\n\t\t\tthis._zone = getRootZone().fork(componentRef.zone);\n\t\t\targs.push(this._zone);\n\t\t\tconst model = new modelClass(...args);\n\t\t\tthis._model = model;\n\n\t\t\tconst modelScope = ReactiveScopeControl.for(model);\n\t\t\tconst modelProxyRef = this._zone instanceof ProxyAuroraZone\n\t\t\t\t? createProxyZone(model, this._zone)\n\t\t\t\t: model;\n\t\t\tmodelScope.getContextProxy = () => modelProxyRef;\n\t\t\tthis._modelScope = modelScope;\n\n\t\t\tthis._viewScope = ReactiveScope.for<{ 'this': BaseComponent<T> }>({ 'this': this });\n\t\t\tconst elementScope = this._viewScope.getInnerScope<ReactiveScope<BaseComponent<T>>>('this')!;\n\t\t\tcomponentRef.inputs.forEach(input => {\n\t\t\t\telementScope.subscribe(input.viewAttribute as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis._modelScope.set(input.modelProperty as any, newValue);\n\t\t\t\t});\n\t\t\t\tthis._modelScope.subscribe(input.modelProperty as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telementScope.emit(input.viewAttribute as any, newValue, oldValue);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tcomponentRef.outputs.forEach(output =>\n\t\t\t\t(model[output.modelProperty as keyof T] as any as EventEmitter<any>)\n\t\t\t\t\t.subscribe((value: any) => {\n\t\t\t\t\t\tconst event = new CustomEvent(\n\t\t\t\t\t\t\toutput.viewAttribute,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdetail: value,\n\t\t\t\t\t\t\t\tcancelable: false,\n\t\t\t\t\t\t\t\tbubbles: output.options?.bubbles,\n\t\t\t\t\t\t\t\tcomposed: output.options?.bubbles,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.dispatchEvent(event);\n\t\t\t\t\t})\n\t\t\t);\n\t\t\t// if property of the model has view decorator\n\t\t\tif (this._componentRef.view) {\n\t\t\t\tReflect.set(this._model, this._componentRef.view, this);\n\t\t\t}\n\t\t\tthis._render = new ComponentRender(this, this.subscriptions);\n\t\t}\n\n\t\tdetectChanges(): void {\n\t\t\tthis._modelScope.detectChanges();\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._zone.run(this._model.doCheck, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t};\n\n\t\tgetComponentRef(): ComponentRef<T> {\n\t\t\treturn this._componentRef;\n\t\t}\n\n\t\tsetParentComponent(parent: HTMLComponent<any>): void {\n\t\t\tthis._parentComponent = parent;\n\t\t}\n\n\t\tgetParentComponent(): HTMLComponent<any> {\n\t\t\treturn this._parentComponent;\n\t\t}\n\n\t\thasParentComponent(): boolean {\n\t\t\treturn this._parentComponent ? true : false;\n\t\t}\n\n\t\thasInputStartWith(viewProp: string): boolean {\n\t\t\tlet dotIndex = viewProp.indexOf('.');\n\t\t\tif (dotIndex > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, dotIndex);\n\t\t\t}\n\t\t\treturn this.hasInput(viewProp);\n\t\t}\n\n\t\tgetInputStartWith(viewProp: string): PropertyRef | undefined {\n\t\t\tlet index = viewProp.indexOf('.');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\tindex = viewProp.indexOf('[');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\treturn this.getInput(viewProp);\n\t\t}\n\n\t\thasInput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.inputs.some(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.inputs.find(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInputValue(viewProp: string): any {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\treturn this._model[inputRef.modelProperty];\n\t\t\t}\n\t\t}\n\n\t\tsetInputValue(viewProp: PropertyKey, value: any): void {\n\t\t\tconst inputRef = this.getInput(viewProp as string);\n\t\t\tif (inputRef) {\n\t\t\t\tthis._modelScope.set(inputRef.modelProperty as never, value);\n\t\t\t}\n\t\t}\n\n\t\thasOutput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.outputs.some(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetOutput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.outputs.find(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined {\n\t\t\tconst outputRef = this.getOutput(viewProp);\n\t\t\tif (outputRef) {\n\t\t\t\treturn this._model[outputRef.modelProperty] as EventEmitter<V>;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\thasProp(propName: string): boolean {\n\t\t\treturn Reflect.has(this._model, propName);\n\t\t}\n\n\t\tprivate setAttributeHelper(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t}\n\t\t\telse if (typeof value === 'boolean') {\n\t\t\t\tif (value) {\n\t\t\t\t\tsuper.setAttribute(attrViewName, '');\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.setAttribute(attrViewName, value);\n\t\t\t}\n\t\t}\n\n\t\tsetAttribute(attrViewName: string, value: any): void {\n\t\t\tthis.setInputValue(attrViewName, value);\n\t\t\tthis.setAttributeHelper(attrViewName, value);\n\t\t}\n\n\t\tgetAttribute(attrViewName: string): string | null {\n\t\t\treturn this.getInputValue(attrViewName) ?? super.getAttribute(attrViewName);\n\t\t}\n\n\t\tattributeChangedCallback(name: string, oldValue: string, newValue: string) {\n\t\t\tif (newValue === oldValue) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onChanges, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\t\t\tif (this.subscriptions.length) {\n\t\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\t}\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tconst cds = this._zone.onEmpty.subscribe(() => this._modelScope.detectChanges());\n\t\t\tthis.onDestroy(() => cds.unsubscribe());\n\t\t\tthis._componentRef.inputs.forEach(input => {\n\t\t\t\tconst inputDefaultValue = this._model[input.modelProperty];\n\t\t\t\tif (inputDefaultValue !== null && inputDefaultValue !== undefined) {\n\t\t\t\t\tthis.setAttributeHelper(input.viewAttribute, inputDefaultValue);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t\tlet attrs: Attr[] = Array.prototype.slice.call(this.attributes);\n\t\t\t\tattrs.forEach(attr => this.initOuterAttribute(attr));\n\t\t\t}\n\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onChanges, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onInit, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._zone.run(this._model.doCheck, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterContentInit, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterContentChecked, this._modelScope.getContextProxy!());\n\t\t\t}\n\n\t\t\t// do once\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\t// setup ui view\n\t\t\t\tthis._render.initView();\n\n\t\t\t\t// init view binding\n\t\t\t\tthis._render.initViewBinding();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterViewInit, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterViewChecked, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.doCheck, this._modelScope.getContextProxy!());\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.afterContentChecked, this._modelScope.getContextProxy!());\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.afterViewChecked, this._modelScope.getContextProxy!());\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\n\t\tinitOuterAttribute(attr: Attr) {\n\t\t\t// [window, this] scop\n\t\t\tlet elementAttr = attr.name;\n\t\t\tlet modelProperty = attr.value;\n\t\t\tif (elementAttr.startsWith('[')) {\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\tif (Reflect.has(window, modelProperty)) {\n\t\t\t\t\tthis.setInputValue(elementAttr, Reflect.get(window, modelProperty));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (elementAttr.startsWith('(')) {\n\t\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\t// this.handleEvent(element, elementAttr, viewProperty);\n\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\tlet callback: Function = Reflect.get(window, modelProperty);\n\t\t\t\tthis.addEventListener(elementAttr, event => {\n\t\t\t\t\tcallback(event);\n\t\t\t\t});\n\t\t\t} else if (elementAttr.startsWith('on')) {\n\t\t\t\tconst modelEvent = this.getEventEmitter<any>(elementAttr.substring(2));\n\t\t\t\tif (modelEvent) {\n\t\t\t\t\t// modelEvent.subscribe(listener);\n\t\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\t\tlet listener: Function = Reflect.get(window, modelProperty);\n\t\t\t\t\tmodelEvent.subscribe((data: any) => {\n\t\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.setInputValue(attr.name, attr.value);\n\t\t\t}\n\t\t}\n\t\tonDestroy(callback: () => void) {\n\t\t\tthis.onDestroyCalls.push(callback);\n\t\t}\n\t\tadoptedCallback() {\n\t\t\t// restart the process\n\t\t\tthis.innerHTML = '';\n\t\t\tthis.connectedCallback();\n\t\t}\n\t\tdisconnectedCallback() {\n\t\t\t// notify first, then call model.onDestroy func\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onDestroy, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tthis.onDestroyCalls.forEach(callback => {\n\t\t\t\ttry {\n\t\t\t\t\tcallback();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.onDestroyCalls.splice(0, this.onDestroyCalls.length);\n\t\t}\n\n\t\ttriggerOutput(eventName: string, value?: any): void {\n\t\t\tconst modelEvent = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelEvent) {\n\t\t\t\tmodelEvent.emit(value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAA8B,MAAM,oBAAoB,CAAC;AACrG,OAAO,EACN,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAC7D,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAC9D,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACn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YACnB,+CAA+C;YAC/C,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,eAAgB,EAAE,CAAC,CAAC;aAC3E;YACD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACxD,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBACtC,IAAI;oBACH,QAAQ,EAAE,CAAC;iBACX;gBAAC,OAAO,KAAK,EAAE;oBACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACrB;YACF,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAC1D,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YACrG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAED,aAAa,CAAC,SAAiB,EAAE,KAAW;YAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACxD,IAAI,UAAU,EAAE;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO;aACP;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope, ReactiveScopeControl, Context, ScopeSubscription } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef } from '../component/component.js';\nimport { BaseComponent, CustomElement, HTMLComponent, ModelType } from '../component/custom-element.js';\nimport { EventEmitter } from '../component/events.js';\nimport { ComponentRender } from './render.js';\nimport { getRootZone } from '../zone/bootstrap.js';\nimport { AuroraZone, ProxyAuroraZone } from '../zone/zone.js';\nimport { createModelChangeDetectorRef } from '../linker/change-detector-ref.js';\nimport { createProxyZone } from '../zone/proxy.js';\nimport { PropertyRef } from '../component/reflect.js';\n\nexport function baseFactoryView<T extends object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\treturn class CustomView extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: ModelType<T>;\n\t\t_parentComponent: HTMLComponent<object>;\n\t\t_render: ComponentRender<T>;\n\t\t_shadowRoot: ShadowRoot;\n\n\t\t_componentRef: ComponentRef<T>;\n\n\t\t_modelScope: ReactiveScopeControl<T>;\n\t\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\t\t_zone: AuroraZone;\n\n\t\tprivate subscriptions: ScopeSubscription<Context>[] = [];\n\t\tprivate onDestroyCalls: (() => void)[] = [];\n\n\t\tconstructor(componentRef: ComponentRef<T>, modelClass: TypeOf<T>) {\n\t\t\tsuper();\n\t\t\tthis._componentRef = componentRef;\n\t\t\tif (componentRef.isShadowDom) {\n\t\t\t\tthis._shadowRoot = this.attachShadow({\n\t\t\t\t\tmode: componentRef.shadowDomMode,\n\t\t\t\t\tdelegatesFocus: componentRef.shadowDomDelegatesFocus\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst args = []; /* resolve dependency injection*/\n\t\t\tconst detector = createModelChangeDetectorRef(() => this._modelScope);\n\t\t\targs.push(detector)\n\t\t\tthis._zone = getRootZone().fork(componentRef.zone);\n\t\t\targs.push(this._zone);\n\t\t\tconst model = new modelClass(...args);\n\t\t\tthis._model = model;\n\n\t\t\tconst modelScope = ReactiveScopeControl.for(model);\n\t\t\tconst modelProxyRef = this._zone instanceof ProxyAuroraZone\n\t\t\t\t? createProxyZone(model, this._zone)\n\t\t\t\t: model;\n\t\t\tmodelScope.getContextProxy = () => modelProxyRef;\n\t\t\tthis._modelScope = modelScope;\n\n\t\t\tthis._viewScope = ReactiveScope.for<{ 'this': BaseComponent<T> }>({ 'this': this });\n\t\t\tconst elementScope = this._viewScope.getInnerScope<ReactiveScope<BaseComponent<T>>>('this')!;\n\t\t\tcomponentRef.inputs.forEach(input => {\n\t\t\t\telementScope.subscribe(input.viewAttribute as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis._modelScope.set(input.modelProperty as any, newValue);\n\t\t\t\t});\n\t\t\t\tthis._modelScope.subscribe(input.modelProperty as any, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue === oldValue) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telementScope.emit(input.viewAttribute as any, newValue, oldValue);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tcomponentRef.outputs.forEach(output =>\n\t\t\t\t(model[output.modelProperty as keyof T] as any as EventEmitter<any>)\n\t\t\t\t\t.subscribe((value: any) => {\n\t\t\t\t\t\tconst event = new CustomEvent(\n\t\t\t\t\t\t\toutput.viewAttribute,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdetail: value,\n\t\t\t\t\t\t\t\tcancelable: false,\n\t\t\t\t\t\t\t\tbubbles: output.options?.bubbles,\n\t\t\t\t\t\t\t\tcomposed: output.options?.bubbles,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.dispatchEvent(event);\n\t\t\t\t\t})\n\t\t\t);\n\t\t\t// if property of the model has view decorator\n\t\t\tif (this._componentRef.view) {\n\t\t\t\tReflect.set(this._model, this._componentRef.view, this);\n\t\t\t}\n\t\t\tthis._render = new ComponentRender(this, this.subscriptions);\n\t\t}\n\n\t\tdetectChanges(): void {\n\t\t\tthis._modelScope.detectChanges();\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._zone.run(this._model.doCheck, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t};\n\n\t\tgetComponentRef(): ComponentRef<T> {\n\t\t\treturn this._componentRef;\n\t\t}\n\n\t\tsetParentComponent(parent: HTMLComponent<any>): void {\n\t\t\tthis._parentComponent = parent;\n\t\t}\n\n\t\tgetParentComponent(): HTMLComponent<any> {\n\t\t\treturn this._parentComponent;\n\t\t}\n\n\t\thasParentComponent(): boolean {\n\t\t\treturn this._parentComponent ? true : false;\n\t\t}\n\n\t\thasInputStartWith(viewProp: string): boolean {\n\t\t\tlet dotIndex = viewProp.indexOf('.');\n\t\t\tif (dotIndex > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, dotIndex);\n\t\t\t}\n\t\t\treturn this.hasInput(viewProp);\n\t\t}\n\n\t\tgetInputStartWith(viewProp: string): PropertyRef | undefined {\n\t\t\tlet index = viewProp.indexOf('.');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\tindex = viewProp.indexOf('[');\n\t\t\tif (index > 0) {\n\t\t\t\tviewProp = viewProp.substring(0, index);\n\t\t\t}\n\t\t\treturn this.getInput(viewProp);\n\t\t}\n\n\t\thasInput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.inputs.some(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.inputs.find(input => input.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetInputValue(viewProp: string): any {\n\t\t\tconst inputRef = this.getInput(viewProp);\n\t\t\tif (inputRef) {\n\t\t\t\treturn this._model[inputRef.modelProperty];\n\t\t\t}\n\t\t}\n\n\t\tsetInputValue(viewProp: PropertyKey, value: any): void {\n\t\t\tconst inputRef = this.getInput(viewProp as string);\n\t\t\tif (inputRef) {\n\t\t\t\tthis._modelScope.set(inputRef.modelProperty as never, value);\n\t\t\t}\n\t\t}\n\n\t\thasOutput(viewProp: string): boolean {\n\t\t\treturn this._componentRef.outputs.some(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetOutput(viewProp: string): PropertyRef | undefined {\n\t\t\treturn this._componentRef.outputs.find(output => output.viewAttribute === viewProp);\n\t\t}\n\n\t\tgetEventEmitter<V>(viewProp: string): EventEmitter<V> | undefined {\n\t\t\tconst outputRef = this.getOutput(viewProp);\n\t\t\tif (outputRef) {\n\t\t\t\treturn this._model[outputRef.modelProperty] as EventEmitter<V>;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\thasProp(propName: string): boolean {\n\t\t\treturn Reflect.has(this._model, propName);\n\t\t}\n\n\t\tprivate setAttributeHelper(attrViewName: string, value: any): void {\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t}\n\t\t\telse if (typeof value === 'boolean') {\n\t\t\t\tif (value) {\n\t\t\t\t\tsuper.setAttribute(attrViewName, '');\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeAttribute(attrViewName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.setAttribute(attrViewName, value);\n\t\t\t}\n\t\t}\n\n\t\tsetAttribute(attrViewName: string, value: any): void {\n\t\t\tthis.setInputValue(attrViewName, value);\n\t\t\tthis.setAttributeHelper(attrViewName, value);\n\t\t}\n\n\t\tgetAttribute(attrViewName: string): string | null {\n\t\t\treturn this.getInputValue(attrViewName) ?? super.getAttribute(attrViewName);\n\t\t}\n\n\t\tattributeChangedCallback(name: string, oldValue: string, newValue: string) {\n\t\t\tif (newValue === oldValue) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onChanges, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\t\t\tif (this.subscriptions.length) {\n\t\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\t}\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tconst cds = this._zone.onEmpty.subscribe(() => this._modelScope.detectChanges());\n\t\t\tthis.onDestroy(() => cds.unsubscribe());\n\t\t\tthis._componentRef.inputs.forEach(input => {\n\t\t\t\tconst inputDefaultValue = this._model[input.modelProperty];\n\t\t\t\tif (inputDefaultValue !== null && inputDefaultValue !== undefined) {\n\t\t\t\t\tthis.setAttributeHelper(input.viewAttribute, inputDefaultValue);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t\tlet attrs: Attr[] = Array.prototype.slice.call(this.attributes);\n\t\t\t\tattrs.forEach(attr => this.initOuterAttribute(attr));\n\t\t\t}\n\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onChanges, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onInit, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._zone.run(this._model.doCheck, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterContentInit, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterContentChecked, this._modelScope.getContextProxy!());\n\t\t\t}\n\n\t\t\t// do once\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\t// setup ui view\n\t\t\t\tthis._render.initView();\n\n\t\t\t\t// init view binding\n\t\t\t\tthis._render.initViewBinding();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterViewInit, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._zone.run(this._model.afterViewChecked, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.doCheck, this._modelScope.getContextProxy!());\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.afterContentChecked, this._modelScope.getContextProxy!());\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._zone.run(this._model.afterViewChecked, this._modelScope.getContextProxy!());\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst event = new CustomEvent('connected', { cancelable: true, bubbles: false, composed: false });\n\t\t\tthis.dispatchEvent(event);\n\t\t}\n\n\n\t\tinitOuterAttribute(attr: Attr) {\n\t\t\t// [window, this] scop\n\t\t\tlet elementAttr = attr.name;\n\t\t\tlet modelProperty = attr.value;\n\t\t\tif (elementAttr.startsWith('[')) {\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\tif (Reflect.has(window, modelProperty)) {\n\t\t\t\t\tthis.setInputValue(elementAttr, Reflect.get(window, modelProperty));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (elementAttr.startsWith('(')) {\n\t\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\t\telementAttr = elementAttr.substring(1, elementAttr.length - 1);\n\t\t\t\t// this.handleEvent(element, elementAttr, viewProperty);\n\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\tlet callback: Function = Reflect.get(window, modelProperty);\n\t\t\t\tthis.addEventListener(elementAttr, event => {\n\t\t\t\t\tcallback(event);\n\t\t\t\t});\n\t\t\t} else if (elementAttr.startsWith('on')) {\n\t\t\t\tconst modelEvent = this.getEventEmitter<any>(elementAttr.substring(2));\n\t\t\t\tif (modelEvent) {\n\t\t\t\t\t// modelEvent.subscribe(listener);\n\t\t\t\t\tmodelProperty = modelProperty.endsWith('()') ?\n\t\t\t\t\t\tmodelProperty.substring(0, modelProperty.length - 2) : modelProperty;\n\t\t\t\t\tlet listener: Function = Reflect.get(window, modelProperty);\n\t\t\t\t\tmodelEvent.subscribe((data: any) => {\n\t\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.setInputValue(attr.name, attr.value);\n\t\t\t}\n\t\t}\n\t\tonDestroy(callback: () => void) {\n\t\t\tthis.onDestroyCalls.push(callback);\n\t\t}\n\t\tadoptedCallback() {\n\t\t\t// restart the process\n\t\t\tthis.innerHTML = '';\n\t\t\tthis.connectedCallback();\n\t\t}\n\t\tdisconnectedCallback() {\n\t\t\t// notify first, then call model.onDestroy func\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._zone.run(this._model.onDestroy, this._modelScope.getContextProxy!());\n\t\t\t}\n\t\t\tthis.subscriptions.forEach(sub => sub.unsubscribe());\n\t\t\tthis.subscriptions.splice(0, this.subscriptions.length);\n\t\t\tthis.onDestroyCalls.forEach(callback => {\n\t\t\t\ttry {\n\t\t\t\t\tcallback();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.onDestroyCalls.splice(0, this.onDestroyCalls.length);\n\t\t\tconst event = new CustomEvent('disconnected', { cancelable: true, bubbles: false, composed: false });\n\t\t\tthis.dispatchEvent(event);\n\t\t}\n\n\t\ttriggerOutput(eventName: string, value?: any): void {\n\t\t\tconst modelEvent = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelEvent) {\n\t\t\t\tmodelEvent.emit(value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
|
package/view/render.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare class ComponentRender<T extends object> {
|
|
|
15
15
|
isTemplateRefName(template: DomNode): template is DomElementNode;
|
|
16
16
|
initTemplateRefMap(domNode: DomNode): void;
|
|
17
17
|
initViewBinding(): void;
|
|
18
|
-
addNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function): void;
|
|
19
18
|
getElementByName(name: string): any;
|
|
20
19
|
createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void;
|
|
21
20
|
createComment(node: CommentNode): Comment;
|
|
@@ -47,5 +46,5 @@ export declare class ComponentRender<T extends object> {
|
|
|
47
46
|
initHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): void;
|
|
48
47
|
private initAttributeDirectives;
|
|
49
48
|
initAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<Context>[];
|
|
50
|
-
|
|
49
|
+
initDirective(directive: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<Context>[];
|
|
51
50
|
}
|
package/view/render.js
CHANGED
|
@@ -88,15 +88,12 @@ export class ComponentRender {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
initViewBinding() {
|
|
91
|
-
if (
|
|
92
|
-
|
|
91
|
+
if (this.componentRef.viewBindings) {
|
|
92
|
+
this.initHtmlElement(this.view, this.componentRef.viewBindings, this.contextStack, this.subscriptions);
|
|
93
|
+
}
|
|
94
|
+
if (this.componentRef.windowBindings) {
|
|
95
|
+
this.subscriptions.push(...this.initAttribute(window, this.componentRef.windowBindings, this.contextStack));
|
|
93
96
|
}
|
|
94
|
-
this.initHtmlElement(this.view, this.componentRef.viewBindings, this.contextStack, this.subscriptions);
|
|
95
|
-
}
|
|
96
|
-
addNativeEventListener(source, eventName, funcCallback) {
|
|
97
|
-
source.addEventListener(eventName, (event) => {
|
|
98
|
-
this.view._zone.run(funcCallback, this.view._model);
|
|
99
|
-
});
|
|
100
97
|
}
|
|
101
98
|
getElementByName(name) {
|
|
102
99
|
return Reflect.get(this.view, name);
|
|
@@ -123,8 +120,7 @@ export class ComponentRender {
|
|
|
123
120
|
templateRef.host = structural;
|
|
124
121
|
const scope = ReactiveScope.readOnlyScopeForThis(structural);
|
|
125
122
|
stack.pushScope(scope);
|
|
126
|
-
|
|
127
|
-
subscriptions.push(...dSubs);
|
|
123
|
+
subscriptions.push(...this.initDirective(structural, directive, stack));
|
|
128
124
|
if (isOnInit(structural)) {
|
|
129
125
|
directiveZone.run(structural.onInit, structural);
|
|
130
126
|
}
|
|
@@ -236,6 +232,7 @@ export class ComponentRender {
|
|
|
236
232
|
const inputScope = elementScope.getInnerScope('this');
|
|
237
233
|
const listener = (event) => inputScope.emit('value', element.value);
|
|
238
234
|
element.addEventListener(changeEventName, listener);
|
|
235
|
+
subscriptions.push(createSubscriptionDestroyer(() => element.removeEventListener(changeEventName, listener)));
|
|
239
236
|
}
|
|
240
237
|
const templateRefName = node.templateRefName;
|
|
241
238
|
if (templateRefName) {
|
|
@@ -267,7 +264,7 @@ export class ComponentRender {
|
|
|
267
264
|
const directive = directiveZone.run(() => new directiveRef.modelClass(element, directiveZone));
|
|
268
265
|
const stack = contextStack.copyStack();
|
|
269
266
|
const thisScope = stack.pushReactiveScopeFor({ 'this': directive });
|
|
270
|
-
const directiveSubscriptions = this.
|
|
267
|
+
const directiveSubscriptions = this.initDirective(directive, directiveNode, stack);
|
|
271
268
|
subscriptions.push(...directiveSubscriptions);
|
|
272
269
|
if (isOnInit(directive)) {
|
|
273
270
|
directiveZone.run(directive.onInit, directive);
|
|
@@ -352,6 +349,7 @@ export class ComponentRender {
|
|
|
352
349
|
listener = event.value;
|
|
353
350
|
}
|
|
354
351
|
element.addEventListener(event.name, listener);
|
|
352
|
+
subscriptions.push(createSubscriptionDestroyer(() => element.removeEventListener(event.name, listener)));
|
|
355
353
|
});
|
|
356
354
|
}
|
|
357
355
|
if (node.templateAttrs?.length) {
|
|
@@ -363,7 +361,7 @@ export class ComponentRender {
|
|
|
363
361
|
}
|
|
364
362
|
return subscriptions;
|
|
365
363
|
}
|
|
366
|
-
|
|
364
|
+
initDirective(directive, node, contextStack) {
|
|
367
365
|
const subscriptions = [];
|
|
368
366
|
if (node.attributes?.length) {
|
|
369
367
|
node.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));
|
|
@@ -389,7 +387,8 @@ export class ComponentRender {
|
|
|
389
387
|
stack.pushBlockScopeFor({ $event });
|
|
390
388
|
this.view._zone.run(event.expression.get, event.expression, [stack]);
|
|
391
389
|
};
|
|
392
|
-
directive[event.name].subscribe(listener);
|
|
390
|
+
const subscription = directive[event.name].subscribe(listener);
|
|
391
|
+
subscriptions.push(createSubscriptionDestroyer(() => directive[event.name].remove(subscription)));
|
|
393
392
|
});
|
|
394
393
|
}
|
|
395
394
|
if (node.templateAttrs?.length) {
|
package/view/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAqC,MAAM,oBAAoB,CAAC;AACtF,OAAO,EACN,WAAW,EAAE,0BAA0B,EACvC,cAAc,EAAE,eAAe,EAAW,iBAAiB,EAC3D,eAAe,EAAE,wBAAwB,EACzC,WAAW,EAA6B,kCAAkC,EAC1E,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,qBA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IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC5B,MAAM,QAAQ,GAAG,CAAC,MAAa,EAAE,EAAE;oBAClC,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;oBACvC,KAAK,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;oBACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtE,CAAC,CAAC;gBACK,SAAU,CAAC,KAAK,CAAC,IAAI,CAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YAC/B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACpD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QACD,SAAS;QACT,qBAAqB;QACrB,OAAO,aAAa,CAAC;IACtB,CAAC;CAED","sourcesContent":["import { ReactiveScope, Context, ScopeSubscription, Stack } from '@ibyar/expressions';\nimport {\n\tCommentNode, DomStructuralDirectiveNode,\n\tDomElementNode, DomFragmentNode, DomNode, isLiveTextContent,\n\tisTagNameNative, isValidCustomElementName, LiveTextContent,\n\tTextContent, DomAttributeDirectiveNode, isFormAssociatedCustomElementByTag\n} from '@ibyar/elements';\nimport type { DomStructuralDirectiveNodeUpgrade } from '@ibyar/elements/node.js';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent, isHTMLComponent } from '../component/custom-element.js';\nimport { documentStack } from '../context/stack.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { isOnDestroy, isOnInit } from '../component/lifecycle.js';\nimport { hasAttr } from '../utils/elements-util.js';\nimport { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';\nimport { TemplateRef, TemplateRefImpl } from '../linker/template-ref.js';\nimport { ViewContainerRefImpl } from '../linker/view-container-ref.js';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\n\ntype ViewContext = { [element: string]: HTMLElement };\n\nfunction getChangeEventName(tagName: string): 'input' | 'change' | undefined {\n\tswitch (true) {\n\t\tcase tagName === 'input':\n\t\t\treturn 'input';\n\t\tcase tagName === 'textarea':\n\t\tcase tagName === 'select':\n\t\tcase isFormAssociatedCustomElementByTag(tagName):\n\t\t\treturn 'change';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\nexport class ComponentRender<T extends object> {\n\tprivate componentRef: ComponentRef<T>;\n\tprivate template: DomNode;\n\tprivate contextStack: Stack;\n\tprivate templateNameScope: ReactiveScope<{ [templateName: string]: TemplateRef }>;\n\tprivate viewScope: ReactiveScope<ViewContext> = new ReactiveScope({});\n\n\tconstructor(public view: HTMLComponent<T>, private subscriptions: ScopeSubscription<Context>[]) {\n\t\tthis.componentRef = this.view.getComponentRef();\n\t\tthis.contextStack = documentStack.copyStack();\n\t\tthis.contextStack.pushScope<Context>(this.view._modelScope);\n\t\tthis.templateNameScope = this.contextStack.pushReactiveScope();\n\t}\n\tinitView(): void {\n\t\tif (!this.componentRef.template) {\n\t\t\treturn;\n\t\t}\n\t\tif (typeof this.componentRef.template === 'function') {\n\t\t\tthis.template = this.componentRef.template(this.view._model);\n\t\t} else {\n\t\t\tthis.template = this.componentRef.template;\n\t\t}\n\n\t\tlet rootRef: HTMLElement | ShadowRoot;\n\t\tif (this.componentRef.isShadowDom) {\n\t\t\tif (this.view.shadowRoot /* OPEN MODE */) {\n\t\t\t\trootRef = this.view.shadowRoot;\n\t\t\t} else /* CLOSED MODE*/ {\n\t\t\t\trootRef = Reflect.get(this.view, '_shadowRoot') as ShadowRoot;\n\t\t\t\tReflect.deleteProperty(this.view, '_shadowRoot');\n\t\t\t}\n\t\t} else {\n\t\t\trootRef = this.view;\n\t\t}\n\t\tthis.initTemplateRefMap(this.template);\n\t\tlet rootFragment: DocumentFragment;\n\t\tif (this.template instanceof DomFragmentNode) {\n\t\t\trootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t} else {\n\t\t\trootFragment = document.createDocumentFragment();\n\t\t\tthis.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t}\n\t\trootRef.append(rootFragment);\n\t}\n\tisTemplateRefName(template: DomNode): template is DomElementNode {\n\t\tif (template instanceof DomElementNode) {\n\t\t\tif (template.tagName === 'template' && template.templateRefName) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tinitTemplateRefMap(domNode: DomNode) {\n\t\tif (!(domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) || !domNode.children) {\n\t\t\treturn;\n\t\t}\n\t\tfor (let index = 0; index < domNode.children.length; index++) {\n\t\t\tconst child = domNode.children[index];\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tthis.templateNameScope.set(child.templateRefName!.name, undefined);\n\t\t\t} else {\n\t\t\t\tthis.initTemplateRefMap(child);\n\t\t\t}\n\t\t}\n\t}\n\tinitViewBinding() {\n\t\tif (!this.componentRef.viewBindings) {\n\t\t\treturn;\n\t\t}\n\t\tthis.initHtmlElement(this.view, this.componentRef.viewBindings, this.contextStack, this.subscriptions);\n\t}\n\taddNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function) {\n\t\tsource.addEventListener(eventName, (event: Event) => {\n\t\t\tthis.view._zone.run(funcCallback as () => void, this.view._model);\n\t\t});\n\t}\n\tgetElementByName(name: string) {\n\t\treturn Reflect.get(this.view, name);\n\t}\n\tcreateStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<T>(directive.name);\n\t\tif (!directiveRef) {\n\t\t\t// didn't find directive or it is not define yet.\n\t\t\t// class registry should have 'when defined' callback\n\t\t\treturn;\n\t\t}\n\t\tconst stack = directiveStack.copyStack();\n\t\tconst templateRef = new TemplateRefImpl(\n\t\t\tthis,\n\t\t\tdirective.node,\n\t\t\tstack,\n\t\t\t(directive as DomStructuralDirectiveNodeUpgrade).templateExpressions ?? [],\n\t\t);\n\t\tconst directiveZone = this.view._zone.fork(directiveRef.zone);\n\t\tconst viewContainerRef = new ViewContainerRefImpl(parentNode as Element, comment);\n\n\t\tdirectiveZone.onEmpty.subscribe(() => {\n\t\t\tconst length = viewContainerRef.length;\n\t\t\tfor (let index = 0; index < length; index++) {\n\t\t\t\tviewContainerRef.get(index)?.detectChanges();\n\t\t\t}\n\t\t});\n\n\t\tconst StructuralDirectiveClass = directiveRef.modelClass as typeof StructuralDirective;\n\t\tconst structural = directiveZone.run(() => new StructuralDirectiveClass(\n\t\t\ttemplateRef,\n\t\t\tviewContainerRef,\n\t\t\thost,\n\t\t\tdirectiveZone,\n\t\t));\n\t\ttemplateRef.host = structural;\n\t\tconst scope = ReactiveScope.readOnlyScopeForThis(structural);\n\t\tstack.pushScope(scope);\n\n\t\tconst dSubs = this.initStructuralDirective(structural, directive, stack);\n\t\tsubscriptions.push(...dSubs);\n\t\tif (isOnInit(structural)) {\n\t\t\tdirectiveZone.run(structural.onInit, structural);\n\t\t}\n\t\tif (directive.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);\n\t\t}\n\t\tif (isOnDestroy(structural)) {\n\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));\n\t\t}\n\n\t}\n\tcreateComment(node: CommentNode): Comment {\n\t\treturn document.createComment(`${node.comment}`);\n\t}\n\tcreateText(node: TextContent): Text {\n\t\treturn new Text(node.value);\n\t}\n\tcreateLiveText(textNode: LiveTextContent, contextStack: Stack, subscriptions: ScopeSubscription<Context>[]): Text {\n\t\tconst liveText = new Text('');\n\t\tcontextStack = contextStack.copyStack();\n\t\tcontextStack.pushBlockScopeFor({ this: liveText });\n\t\tconst textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);\n\t\tsubscriptions.push(...textSubscriptions);\n\t\ttextNode.expression.get(contextStack);\n\t\treturn liveText;\n\t}\n\tcreateDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment {\n\t\tconst fragment = document.createDocumentFragment();\n\t\tnode.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));\n\t\treturn fragment;\n\t}\n\tappendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective) {\n\t\tif (child instanceof DomElementNode) {\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tconst templateRefName = child.templateRefName!;\n\t\t\t\t// const oldRef = this.templateNameScope.get(templateRefName.name);\n\t\t\t\t// if (oldRef) {\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\t// TODO: extract template expression\n\t\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\t\tthis,\n\t\t\t\t\tnew DomFragmentNode(child.children),\n\t\t\t\t\tcontextStack.copyStack(),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tthis.templateNameScope.set(templateRefName.name, templateRef);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfragmentParent.append(this.createElement(child, contextStack, subscriptions, host));\n\t\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t\tconst commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');\n\t\t\tconst comment = document.createComment(`start ${commentText}`);\n\t\t\tfragmentParent.append(comment);\n\t\t\tconst lastComment = document.createComment(`end ${commentText}`);\n\t\t\tcomment.after(lastComment);\n\t\t\tthis.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);\n\t\t} else if (isLiveTextContent(child)) {\n\t\t\tfragmentParent.append(this.createLiveText(child, contextStack, subscriptions));\n\t\t} else if (child instanceof TextContent) {\n\t\t\tfragmentParent.append(this.createText(child));\n\t\t} else if (child instanceof CommentNode) {\n\t\t\tfragmentParent.append(this.createComment(child));\n\t\t} else if (child instanceof DomFragmentNode) {\n\t\t\tfragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));\n\t\t}\n\t}\n\tcreateElementByTagName(node: { tagName: string, is?: string }): HTMLElement {\n\t\tlet element: HTMLElement;\n\t\tif (isValidCustomElementName(node.tagName)) {\n\t\t\tconst ViewClass = customElements.get(node.tagName) as ((new () => HTMLElement) | undefined);\n\t\t\tif (ViewClass) {\n\t\t\t\telement = new ViewClass();\n\t\t\t} else {\n\t\t\t\telement = document.createElement(node.tagName);\n\t\t\t\tif (element.constructor.name === 'HTMLElement') {\n\t\t\t\t\tcustomElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isTagNameNative(node.tagName)) {\n\t\t\t// native tags // and custom tags can be used her\n\t\t\telement = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);\n\t\t} else {\n\t\t\t// html unknown element\n\t\t\telement = document.createElement(node.tagName);\n\t\t}\n\t\tif (isHTMLComponent(element)) {\n\t\t\telement.setParentComponent(this.view);\n\t\t}\n\t\treturn element;\n\t}\n\tcreateElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): HTMLElement {\n\t\tconst element = this.createElementByTagName(node);\n\t\tthis.initHtmlElement(element, node, contextStack, subscriptions, host);\n\t\treturn element;\n\t}\n\n\t/**\n\t * use for init host bindings\n\t * @param element \n\t * @param node \n\t * @param contextStack \n\t * @param subscriptions \n\t */\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[]): void;\n\n\t/**\n\t * use to init a new create html element\n\t * @param element \n\t * @param node \n\t * @param contextStack \n\t * @param subscriptions \n\t * @param host is the direct html element `this.view` or a sub `structural directive` like `*if` or `*for`, etc...\n\t */\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): void;\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host?: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst elementStack = contextStack.copyStack();\n\t\tconst elementScope = isHTMLComponent(element)\n\t\t\t? element._viewScope\n\t\t\t: ReactiveScope.readOnlyScopeForThis(element);\n\t\telementStack.pushScope<Context>(elementScope);\n\t\tconst attributesSubscriptions = this.initAttribute(element, node, elementStack);\n\t\tsubscriptions.push(...attributesSubscriptions);\n\t\tconst changeEventName = getChangeEventName(node.tagName);\n\t\tif (changeEventName) {\n\t\t\tconst inputScope = elementScope.getInnerScope<ReactiveScope<HTMLInputElement>>('this')!;\n\t\t\tconst listener = (event: HTMLElementEventMap['input' | 'change']) => inputScope.emit('value', (element as HTMLInputElement).value);\n\t\t\telement.addEventListener(changeEventName, listener);\n\t\t}\n\n\t\tconst templateRefName = node.templateRefName;\n\t\tif (templateRefName) {\n\t\t\tReflect.set(this.view, templateRefName.name, element);\n\t\t\tthis.viewScope.set(templateRefName.name, element);\n\t\t\tconst view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);\n\t\t\tif (view) {\n\t\t\t\tReflect.set(this.view._model, view.modelName, element);\n\t\t\t}\n\t\t}\n\t\tif (node.children) {\n\t\t\tfor (const child of node.children) {\n\t\t\t\tthis.appendChildToParent(element, child, elementStack, element, subscriptions, host!);\n\t\t\t}\n\t\t}\n\t\tif (node.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);\n\t\t}\n\t}\n\tprivate initAttributeDirectives(\n\t\tattributeDirectives: DomAttributeDirectiveNode[],\n\t\telement: HTMLElement | StructuralDirective,\n\t\tcontextStack: Stack,\n\t\tsubscriptions: ScopeSubscription<Context>[]) {\n\t\tattributeDirectives?.forEach(directiveNode => {\n\t\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(directiveNode.name);\n\t\t\tif (!directiveRef\n\t\t\t\t|| !((directiveRef.modelClass.prototype instanceof AttributeDirective)\n\t\t\t\t\t|| (directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective))) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst directiveZone = this.view._zone.fork(directiveRef.zone);\n\t\t\tconst directive = directiveZone.run(() => new directiveRef.modelClass(element, directiveZone) as AttributeDirective | AttributeOnStructuralDirective);\n\t\t\tconst stack = contextStack.copyStack();\n\t\t\tconst thisScope = stack.pushReactiveScopeFor({ 'this': directive });\n\n\t\t\tconst directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);\n\t\t\tsubscriptions.push(...directiveSubscriptions);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirectiveZone.run(directive.onInit, directive);\n\t\t\t}\n\t\t\tif (isOnDestroy(directive)) {\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));\n\t\t\t}\n\t\t\tif (!(element instanceof HTMLElement)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst attributeName = directiveRef.selector.replace(/[A-Z]/g, m => '-' + m.toLowerCase());\n\t\t\tif (!element.hasAttribute(attributeName)) {\n\t\t\t\telement.setAttribute(attributeName, '');\n\t\t\t}\n\t\t\tif (directiveRef.viewBindings) {\n\t\t\t\tconst directiveStack = stack.copyStack();\n\t\t\t\tconst directiveScope = thisScope.getInnerScope<ReactiveScope<any>>('this')!;\n\t\t\t\tdirectiveStack.pushScope(directiveScope);\n\t\t\t\tthis.initHtmlElement(element, directiveRef.viewBindings, directiveStack, subscriptions);\n\t\t\t}\n\t\t});\n\t}\n\n\tinitAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => {\n\t\t\t\t/**\n\t\t\t\t * <input id=\"23\" name=\"person-name\" data-id=\"1234567890\" data-user=\"carinaanand\" data-date-of-birth />\n\t\t\t\t */\n\t\t\t\tconst isAttr = hasAttr(element, attr.name);\n\t\t\t\tif (isAttr) {\n\t\t\t\t\tif (attr.value === false) {\n\t\t\t\t\t\telement.removeAttribute(attr.name);\n\t\t\t\t\t} else if (attr.value === true) {\n\t\t\t\t\t\telement.setAttribute(attr.name, '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.setAttribute(attr.name, attr.value as string);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tReflect.set(element, attr.name, attr.value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tlet listener: Function;\n\t\t\t\t/**\n\t\t\t\t * <a (click)=\"onLinkClick($event)\"></a>\n\t\t\t\t * <a @click=\"onLinkClick($event)\"></a>\n\t\t\t\t * <input [(value)]=\"person.name\" />\n\t\t\t\t * <input (value)=\"person.name\" />\n\t\t\t\t * <!-- <input (value)=\"person.name = $event\" /> -->\n\t\t\t\t * \n\t\t\t\t * TODO: diff of event listener and back-way data binding\n\t\t\t\t */\n\t\t\t\tif (typeof event.value === 'string') {\n\t\t\t\t\tlistener = ($event: Event) => {\n\t\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t\t};\n\t\t\t\t} else /* if (typeof event.sourceHandler === 'function')*/ {\n\t\t\t\t\t// let eventName: keyof HTMLElementEventMap = event.eventName;\n\t\t\t\t\tlistener = event.value;\n\t\t\t\t}\n\t\t\t\telement.addEventListener(event.name as any, listener as any);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\tinitStructuralDirective(\n\t\tdirective: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective,\n\t\tnode: DomStructuralDirectiveNode | DomAttributeDirectiveNode,\n\t\tcontextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tconst listener = ($event: Event) => {\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t};\n\t\t\t\t((<any>directive)[event.name] as any).subscribe(listener);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\t// TODO: \n\t\t// check host binding\n\t\treturn subscriptions;\n\t}\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAqC,MAAM,oBAAoB,CAAC;AACtF,OAAO,EACN,WAAW,EAAE,0BAA0B,EACvC,cAAc,EAAE,eAAe,EAAW,iBAAiB,EAC3D,eAAe,EAAE,wBAAwB,EACzC,WAAW,EAA6B,kCAAkC,EAC1E,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE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C,CAAC;gBACpD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QACD,SAAS;QACT,qBAAqB;QACrB,OAAO,aAAa,CAAC;IACtB,CAAC;CAED","sourcesContent":["import { ReactiveScope, Context, ScopeSubscription, Stack } from '@ibyar/expressions';\nimport {\n\tCommentNode, DomStructuralDirectiveNode,\n\tDomElementNode, DomFragmentNode, DomNode, isLiveTextContent,\n\tisTagNameNative, isValidCustomElementName, LiveTextContent,\n\tTextContent, DomAttributeDirectiveNode, isFormAssociatedCustomElementByTag\n} from '@ibyar/elements';\nimport type { DomStructuralDirectiveNodeUpgrade } from '@ibyar/elements/node.js';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent, isHTMLComponent } from '../component/custom-element.js';\nimport { documentStack } from '../context/stack.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { isOnDestroy, isOnInit } from '../component/lifecycle.js';\nimport { hasAttr } from '../utils/elements-util.js';\nimport { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';\nimport { TemplateRef, TemplateRefImpl } from '../linker/template-ref.js';\nimport { ViewContainerRefImpl } from '../linker/view-container-ref.js';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\nimport { EventEmitter } from '../component/events.js';\n\ntype ViewContext = { [element: string]: HTMLElement };\n\nfunction getChangeEventName(tagName: string): 'input' | 'change' | undefined {\n\tswitch (true) {\n\t\tcase tagName === 'input':\n\t\t\treturn 'input';\n\t\tcase tagName === 'textarea':\n\t\tcase tagName === 'select':\n\t\tcase isFormAssociatedCustomElementByTag(tagName):\n\t\t\treturn 'change';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\nexport class ComponentRender<T extends object> {\n\tprivate componentRef: ComponentRef<T>;\n\tprivate template: DomNode;\n\tprivate contextStack: Stack;\n\tprivate templateNameScope: ReactiveScope<{ [templateName: string]: TemplateRef }>;\n\tprivate viewScope: ReactiveScope<ViewContext> = new ReactiveScope({});\n\n\tconstructor(public view: HTMLComponent<T>, private subscriptions: ScopeSubscription<Context>[]) {\n\t\tthis.componentRef = this.view.getComponentRef();\n\t\tthis.contextStack = documentStack.copyStack();\n\t\tthis.contextStack.pushScope<Context>(this.view._modelScope);\n\t\tthis.templateNameScope = this.contextStack.pushReactiveScope();\n\t}\n\tinitView(): void {\n\t\tif (!this.componentRef.template) {\n\t\t\treturn;\n\t\t}\n\t\tif (typeof this.componentRef.template === 'function') {\n\t\t\tthis.template = this.componentRef.template(this.view._model);\n\t\t} else {\n\t\t\tthis.template = this.componentRef.template;\n\t\t}\n\n\t\tlet rootRef: HTMLElement | ShadowRoot;\n\t\tif (this.componentRef.isShadowDom) {\n\t\t\tif (this.view.shadowRoot /* OPEN MODE */) {\n\t\t\t\trootRef = this.view.shadowRoot;\n\t\t\t} else /* CLOSED MODE*/ {\n\t\t\t\trootRef = Reflect.get(this.view, '_shadowRoot') as ShadowRoot;\n\t\t\t\tReflect.deleteProperty(this.view, '_shadowRoot');\n\t\t\t}\n\t\t} else {\n\t\t\trootRef = this.view;\n\t\t}\n\t\tthis.initTemplateRefMap(this.template);\n\t\tlet rootFragment: DocumentFragment;\n\t\tif (this.template instanceof DomFragmentNode) {\n\t\t\trootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t} else {\n\t\t\trootFragment = document.createDocumentFragment();\n\t\t\tthis.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t}\n\t\trootRef.append(rootFragment);\n\t}\n\tisTemplateRefName(template: DomNode): template is DomElementNode {\n\t\tif (template instanceof DomElementNode) {\n\t\t\tif (template.tagName === 'template' && template.templateRefName) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tinitTemplateRefMap(domNode: DomNode) {\n\t\tif (!(domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) || !domNode.children) {\n\t\t\treturn;\n\t\t}\n\t\tfor (let index = 0; index < domNode.children.length; index++) {\n\t\t\tconst child = domNode.children[index];\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tthis.templateNameScope.set(child.templateRefName!.name, undefined);\n\t\t\t} else {\n\t\t\t\tthis.initTemplateRefMap(child);\n\t\t\t}\n\t\t}\n\t}\n\tinitViewBinding() {\n\t\tif (this.componentRef.viewBindings) {\n\t\t\tthis.initHtmlElement(this.view, this.componentRef.viewBindings, this.contextStack, this.subscriptions);\n\t\t}\n\t\tif (this.componentRef.windowBindings) {\n\t\t\tthis.subscriptions.push(...this.initAttribute(window as any, this.componentRef.windowBindings, this.contextStack));\n\t\t}\n\t}\n\tgetElementByName(name: string) {\n\t\treturn Reflect.get(this.view, name);\n\t}\n\tcreateStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<T>(directive.name);\n\t\tif (!directiveRef) {\n\t\t\t// didn't find directive or it is not define yet.\n\t\t\t// class registry should have 'when defined' callback\n\t\t\treturn;\n\t\t}\n\t\tconst stack = directiveStack.copyStack();\n\t\tconst templateRef = new TemplateRefImpl(\n\t\t\tthis,\n\t\t\tdirective.node,\n\t\t\tstack,\n\t\t\t(directive as DomStructuralDirectiveNodeUpgrade).templateExpressions ?? [],\n\t\t);\n\t\tconst directiveZone = this.view._zone.fork(directiveRef.zone);\n\t\tconst viewContainerRef = new ViewContainerRefImpl(parentNode as Element, comment);\n\n\t\tdirectiveZone.onEmpty.subscribe(() => {\n\t\t\tconst length = viewContainerRef.length;\n\t\t\tfor (let index = 0; index < length; index++) {\n\t\t\t\tviewContainerRef.get(index)?.detectChanges();\n\t\t\t}\n\t\t});\n\n\t\tconst StructuralDirectiveClass = directiveRef.modelClass as typeof StructuralDirective;\n\t\tconst structural = directiveZone.run(() => new StructuralDirectiveClass(\n\t\t\ttemplateRef,\n\t\t\tviewContainerRef,\n\t\t\thost,\n\t\t\tdirectiveZone,\n\t\t));\n\t\ttemplateRef.host = structural;\n\t\tconst scope = ReactiveScope.readOnlyScopeForThis(structural);\n\t\tstack.pushScope(scope);\n\t\tsubscriptions.push(...this.initDirective(structural, directive, stack));\n\t\tif (isOnInit(structural)) {\n\t\t\tdirectiveZone.run(structural.onInit, structural);\n\t\t}\n\t\tif (directive.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);\n\t\t}\n\t\tif (isOnDestroy(structural)) {\n\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));\n\t\t}\n\n\t}\n\tcreateComment(node: CommentNode): Comment {\n\t\treturn document.createComment(`${node.comment}`);\n\t}\n\tcreateText(node: TextContent): Text {\n\t\treturn new Text(node.value);\n\t}\n\tcreateLiveText(textNode: LiveTextContent, contextStack: Stack, subscriptions: ScopeSubscription<Context>[]): Text {\n\t\tconst liveText = new Text('');\n\t\tcontextStack = contextStack.copyStack();\n\t\tcontextStack.pushBlockScopeFor({ this: liveText });\n\t\tconst textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);\n\t\tsubscriptions.push(...textSubscriptions);\n\t\ttextNode.expression.get(contextStack);\n\t\treturn liveText;\n\t}\n\tcreateDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment {\n\t\tconst fragment = document.createDocumentFragment();\n\t\tnode.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));\n\t\treturn fragment;\n\t}\n\tappendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective) {\n\t\tif (child instanceof DomElementNode) {\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tconst templateRefName = child.templateRefName!;\n\t\t\t\t// const oldRef = this.templateNameScope.get(templateRefName.name);\n\t\t\t\t// if (oldRef) {\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\t// TODO: extract template expression\n\t\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\t\tthis,\n\t\t\t\t\tnew DomFragmentNode(child.children),\n\t\t\t\t\tcontextStack.copyStack(),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tthis.templateNameScope.set(templateRefName.name, templateRef);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfragmentParent.append(this.createElement(child, contextStack, subscriptions, host));\n\t\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t\tconst commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');\n\t\t\tconst comment = document.createComment(`start ${commentText}`);\n\t\t\tfragmentParent.append(comment);\n\t\t\tconst lastComment = document.createComment(`end ${commentText}`);\n\t\t\tcomment.after(lastComment);\n\t\t\tthis.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);\n\t\t} else if (isLiveTextContent(child)) {\n\t\t\tfragmentParent.append(this.createLiveText(child, contextStack, subscriptions));\n\t\t} else if (child instanceof TextContent) {\n\t\t\tfragmentParent.append(this.createText(child));\n\t\t} else if (child instanceof CommentNode) {\n\t\t\tfragmentParent.append(this.createComment(child));\n\t\t} else if (child instanceof DomFragmentNode) {\n\t\t\tfragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));\n\t\t}\n\t}\n\tcreateElementByTagName(node: { tagName: string, is?: string }): HTMLElement {\n\t\tlet element: HTMLElement;\n\t\tif (isValidCustomElementName(node.tagName)) {\n\t\t\tconst ViewClass = customElements.get(node.tagName) as ((new () => HTMLElement) | undefined);\n\t\t\tif (ViewClass) {\n\t\t\t\telement = new ViewClass();\n\t\t\t} else {\n\t\t\t\telement = document.createElement(node.tagName);\n\t\t\t\tif (element.constructor.name === 'HTMLElement') {\n\t\t\t\t\tcustomElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isTagNameNative(node.tagName)) {\n\t\t\t// native tags // and custom tags can be used her\n\t\t\telement = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);\n\t\t} else {\n\t\t\t// html unknown element\n\t\t\telement = document.createElement(node.tagName);\n\t\t}\n\t\tif (isHTMLComponent(element)) {\n\t\t\telement.setParentComponent(this.view);\n\t\t}\n\t\treturn element;\n\t}\n\tcreateElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): HTMLElement {\n\t\tconst element = this.createElementByTagName(node);\n\t\tthis.initHtmlElement(element, node, contextStack, subscriptions, host);\n\t\treturn element;\n\t}\n\n\t/**\n\t * use for init host bindings\n\t * @param element \n\t * @param node \n\t * @param contextStack \n\t * @param subscriptions \n\t */\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[]): void;\n\n\t/**\n\t * use to init a new create html element\n\t * @param element \n\t * @param node \n\t * @param contextStack \n\t * @param subscriptions \n\t * @param host is the direct html element `this.view` or a sub `structural directive` like `*if` or `*for`, etc...\n\t */\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): void;\n\tinitHtmlElement(element: HTMLElement, node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], host?: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst elementStack = contextStack.copyStack();\n\t\tconst elementScope = isHTMLComponent(element)\n\t\t\t? element._viewScope\n\t\t\t: ReactiveScope.readOnlyScopeForThis(element);\n\t\telementStack.pushScope<Context>(elementScope);\n\t\tconst attributesSubscriptions = this.initAttribute(element, node, elementStack);\n\t\tsubscriptions.push(...attributesSubscriptions);\n\t\tconst changeEventName = getChangeEventName(node.tagName);\n\t\tif (changeEventName) {\n\t\t\tconst inputScope = elementScope.getInnerScope<ReactiveScope<HTMLInputElement>>('this')!;\n\t\t\tconst listener = (event: HTMLElementEventMap['input' | 'change']) => inputScope.emit('value', (element as HTMLInputElement).value);\n\t\t\telement.addEventListener(changeEventName, listener);\n\t\t\tsubscriptions.push(createSubscriptionDestroyer(\n\t\t\t\t() => element.removeEventListener(changeEventName, listener),\n\t\t\t));\n\t\t}\n\n\t\tconst templateRefName = node.templateRefName;\n\t\tif (templateRefName) {\n\t\t\tReflect.set(this.view, templateRefName.name, element);\n\t\t\tthis.viewScope.set(templateRefName.name, element);\n\t\t\tconst view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);\n\t\t\tif (view) {\n\t\t\t\tReflect.set(this.view._model, view.modelName, element);\n\t\t\t}\n\t\t}\n\t\tif (node.children) {\n\t\t\tfor (const child of node.children) {\n\t\t\t\tthis.appendChildToParent(element, child, elementStack, element, subscriptions, host!);\n\t\t\t}\n\t\t}\n\t\tif (node.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);\n\t\t}\n\t}\n\tprivate initAttributeDirectives(\n\t\tattributeDirectives: DomAttributeDirectiveNode[],\n\t\telement: HTMLElement | StructuralDirective,\n\t\tcontextStack: Stack,\n\t\tsubscriptions: ScopeSubscription<Context>[]) {\n\t\tattributeDirectives?.forEach(directiveNode => {\n\t\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(directiveNode.name);\n\t\t\tif (!directiveRef\n\t\t\t\t|| !((directiveRef.modelClass.prototype instanceof AttributeDirective)\n\t\t\t\t\t|| (directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective))) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst directiveZone = this.view._zone.fork(directiveRef.zone);\n\t\t\tconst directive = directiveZone.run(() => new directiveRef.modelClass(element, directiveZone) as AttributeDirective | AttributeOnStructuralDirective);\n\t\t\tconst stack = contextStack.copyStack();\n\t\t\tconst thisScope = stack.pushReactiveScopeFor({ 'this': directive });\n\n\t\t\tconst directiveSubscriptions = this.initDirective(directive, directiveNode, stack);\n\t\t\tsubscriptions.push(...directiveSubscriptions);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirectiveZone.run(directive.onInit, directive);\n\t\t\t}\n\t\t\tif (isOnDestroy(directive)) {\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));\n\t\t\t}\n\t\t\tif (!(element instanceof HTMLElement)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst attributeName = directiveRef.selector.replace(/[A-Z]/g, m => '-' + m.toLowerCase());\n\t\t\tif (!element.hasAttribute(attributeName)) {\n\t\t\t\telement.setAttribute(attributeName, '');\n\t\t\t}\n\t\t\tif (directiveRef.viewBindings) {\n\t\t\t\tconst directiveStack = stack.copyStack();\n\t\t\t\tconst directiveScope = thisScope.getInnerScope<ReactiveScope<any>>('this')!;\n\t\t\t\tdirectiveStack.pushScope(directiveScope);\n\t\t\t\tthis.initHtmlElement(element, directiveRef.viewBindings, directiveStack, subscriptions);\n\t\t\t}\n\t\t});\n\t}\n\n\tinitAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => {\n\t\t\t\t/**\n\t\t\t\t * <input id=\"23\" name=\"person-name\" data-id=\"1234567890\" data-user=\"carinaanand\" data-date-of-birth />\n\t\t\t\t */\n\t\t\t\tconst isAttr = hasAttr(element, attr.name);\n\t\t\t\tif (isAttr) {\n\t\t\t\t\tif (attr.value === false) {\n\t\t\t\t\t\telement.removeAttribute(attr.name);\n\t\t\t\t\t} else if (attr.value === true) {\n\t\t\t\t\t\telement.setAttribute(attr.name, '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.setAttribute(attr.name, attr.value as string);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tReflect.set(element, attr.name, attr.value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tlet listener: Function;\n\t\t\t\t/**\n\t\t\t\t * <a (click)=\"onLinkClick($event)\"></a>\n\t\t\t\t * <a @click=\"onLinkClick($event)\"></a>\n\t\t\t\t * <input [(value)]=\"person.name\" />\n\t\t\t\t * <input (value)=\"person.name\" />\n\t\t\t\t * <!-- <input (value)=\"person.name = $event\" /> -->\n\t\t\t\t * \n\t\t\t\t * TODO: diff of event listener and back-way data binding\n\t\t\t\t */\n\t\t\t\tif (typeof event.value === 'string') {\n\t\t\t\t\tlistener = ($event: Event) => {\n\t\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t\t};\n\t\t\t\t} else /* if (typeof event.sourceHandler === 'function')*/ {\n\t\t\t\t\t// let eventName: keyof HTMLElementEventMap = event.eventName;\n\t\t\t\t\tlistener = event.value;\n\t\t\t\t}\n\t\t\t\telement.addEventListener(event.name as any, listener as any);\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(\n\t\t\t\t\t() => element.removeEventListener(event.name as any, listener as any),\n\t\t\t\t));\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\tinitDirective(\n\t\tdirective: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective,\n\t\tnode: DomStructuralDirectiveNode | DomAttributeDirectiveNode,\n\t\tcontextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tconst listener = ($event: Event) => {\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t};\n\t\t\t\tconst subscription = ((directive as any)[event.name] as EventEmitter<T>).subscribe(listener);\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(\n\t\t\t\t\t() => ((directive as any)[event.name] as EventEmitter<T>).remove(subscription),\n\t\t\t\t));\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\t// TODO: \n\t\t// check host binding\n\t\treturn subscriptions;\n\t}\n\n}\n"]}
|