@ibyar/core 0.5.0 → 0.5.4
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/binding/binding.expressions.d.ts +3 -2
- package/binding/binding.expressions.js +45 -29
- package/binding/binding.expressions.js.map +1 -1
- package/component/component.js +8 -8
- package/component/component.js.map +1 -1
- package/component/provider.d.ts +5 -10
- package/component/provider.js +6 -31
- package/component/provider.js.map +1 -1
- package/context/stack.js +1 -1
- package/context/stack.js.map +1 -1
- package/context/subscription.d.ts +2 -0
- package/context/subscription.js +14 -0
- package/context/subscription.js.map +1 -0
- package/directive/directive.d.ts +7 -1
- package/directive/directive.js +7 -1
- package/directive/directive.js.map +1 -1
- package/directive/parser.d.ts +1 -1
- package/directive/parser.js +13 -10
- package/directive/parser.js.map +1 -1
- package/directive/providers.d.ts +2 -0
- package/directive/providers.js +4 -1
- package/directive/providers.js.map +1 -1
- package/html/expression.js +5 -4
- package/html/expression.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/linker/change-detector-ref.d.ts +7 -0
- package/linker/change-detector-ref.js +32 -0
- package/linker/change-detector-ref.js.map +1 -0
- package/linker/template-ref.d.ts +5 -1
- package/linker/template-ref.js +13 -15
- package/linker/template-ref.js.map +1 -1
- package/linker/view-container-ref.d.ts +12 -10
- package/linker/view-container-ref.js +7 -7
- package/linker/view-container-ref.js.map +1 -1
- package/linker/view-ref.d.ts +4 -2
- package/linker/view-ref.js +9 -6
- package/linker/view-ref.js.map +1 -1
- package/package.json +6 -6
- package/pipe/pipe.d.ts +18 -8
- package/pipe/pipe.js +30 -15
- package/pipe/pipe.js.map +1 -1
- package/providers/provider.d.ts +1 -1
- package/providers/provider.js +2 -0
- package/providers/provider.js.map +1 -1
- package/render/host-listener.handler.d.ts +26 -0
- package/render/host-listener.handler.js +69 -0
- package/render/host-listener.handler.js.map +1 -0
- package/render/render-handler.d.ts +5 -0
- package/render/render-handler.js +2 -0
- package/render/render-handler.js.map +1 -0
- package/view/base-view.js +11 -22
- package/view/base-view.js.map +1 -1
- package/view/render.d.ts +16 -20
- package/view/render.js +84 -103
- package/view/render.js.map +1 -1
- package/view/view.js +6 -0
- package/view/view.js.map +1 -1
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,MAAM,oBAAoB,CAAC;AACnD,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,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,aAAa,GAAG,IAAI,OAAO,EAAmD,CAAC;AAErF,SAAS,yBAAyB,CAAmC,QAAW,EAAE,KAAe;IAChG,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QACjC,OAAO;KACP;IACD,KAAK;SACH,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;SAC1C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,eAAe,CAAmB,eAAoC;IAErF,IAAI,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;QACvC,OAAO,aAAa,CAAC,GAAG,CAAC,eAAe,CAA6B,CAAC;KACtE;IACD,MAAM,UAAW,SAAQ,eAAe;QAYvC,YAAY,YAA6B,EAAE,UAAqB;YAC/D,KAAK,EAAE,CAAC;YA6CT,oBA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AC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef, PropertyRef } 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 { ElementModelReactiveScope } from '../component/provider.js';\n\nconst FACTORY_CACHE = new WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>>();\n\nfunction defineInstancePropertyMap<T extends { [key: string]: any }>(instance: T, names: string[]) {\n\tif (typeof instance !== 'object') {\n\t\treturn;\n\t}\n\tnames\n\t\t.filter(key => !Reflect.has(instance, key))\n\t\t.forEach(key => Reflect.set(instance, key, undefined));\n}\n\nexport function baseFactoryView<T extends object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\n\tif (FACTORY_CACHE.has(htmlElementType)) {\n\t\treturn FACTORY_CACHE.get(htmlElementType) as TypeOf<HTMLComponent<T>>;\n\t}\n\tclass CustomView extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: ModelType<T>;\n\t\t_proxyModel: 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: ReactiveScope<T>;\n\t\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\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 model = new modelClass(/* resolve dependency injection*/);\n\t\t\tconst modelNames = componentRef.inputs.map(input => input.modelProperty)\n\t\t\t\t.concat(componentRef.outputs.map(output => output.modelProperty))\n\t\t\t\t.concat(componentRef.hostBindings.map(host => host.hostPropertyName))\n\t\t\t\t.concat(componentRef.viewChild.map(child => child.modelName));\n\t\t\tdefineInstancePropertyMap(model, modelNames);\n\t\t\tthis._model = model;\n\n\t\t\tconst modelScope = ElementModelReactiveScope.blockScopeFor(model);\n\t\t\tthis._proxyModel = modelScope.getContextProxy();\n\t\t\tthis._modelScope = modelScope;\n\n\t\t\tthis._viewScope = ReactiveScope.blockScopeFor<{ 'this': BaseComponent<T> }>({ 'this': this });\n\t\t\tconst elementScope = this._viewScope.getScopeOrCreat('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\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);\n\t\t}\n\n\t\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\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\t// console.log('about to change input', inputRef.modelProperty, value);\n\t\t\t\t// Reflect.set(this._model, inputRef.modelProperty, value);\n\t\t\t\t// this._model.emitChangeModel(inputRef.modelProperty);\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}\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\t// this._changeObservable.emit(name);\n\t\t\tconst inputRef = this.getInput(name);\n\t\t\tif (inputRef) {\n\t\t\t\t// this._model.emitChangeModel(inputRef.modelProperty);\n\t\t\t}\n\t\t\tif (isOnChanges(this._model)) {\n\t\t\t\tthis._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback();\n\t\t}\n\n\t\tconnectedCallback() {\n\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\t// if (!this.hasParentComponent() && this.attributes.length > 0) {\n\t\t\t// \tlet oldAttrValues = Array.prototype.slice.call(this.attributes);\n\t\t\t//\toldAttrValues.forEach((attr: Attr) => {\n\t\t\t// \t\tReflect.set(this, attr.name, attr.value);\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._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._model.onInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._model.afterContentInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t}\n\n\t\t\t// if (!this.hasParentComponent()) {\n\t\t\t// \tArray.prototype.slice.call(this.attributes).forEach((attr: Attr) => {\n\t\t\t// \t\tthis.initOuterAttribute(attr);\n\t\t\t// \t});\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 Host Listener events\n\t\t\t\tthis._render.initHostListener();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._model.afterViewInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\t// this.emitRootChanges();\n\t\t\t};\n\t\t\t// this.emitRootChanges();\n\t\t}\n\n\t\t// emitRootChanges(): void {\n\t\t// \tthis.emitChanges(...Object.keys(this._model.__observable).filter(event => event !== 'destroy'));\n\t\t// }\n\n\t\t// emitChanges(...events: string[]): void {\n\t\t// \tconst sources: any[] = [];\n\t\t// \tevents.forEach(key => {\n\t\t// \t\tthis._model.emitChangeModel(key, sources);\n\t\t// \t});\n\t\t// }\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\t// else {\n\t\t\t\t// \tlet value: any;\n\t\t\t\t// \tObject.defineProperty(window, modelProperty, {\n\t\t\t\t// \t\tset: (v: any) => {\n\t\t\t\t// \t\t\tvalue = v;\n\t\t\t\t// \t\t\tif (this) {\n\t\t\t\t// \t\t\t\tthis.setInputValue(elementAttr, v);\n\t\t\t\t// \t\t\t\t// fake connect element\n\t\t\t\t// \t\t\t\tthis.connectedCallback();\n\t\t\t\t// \t\t\t}\n\t\t\t\t// \t\t},\n\t\t\t\t// \t\tget: (): any => value\n\t\t\t\t// \t});\n\t\t\t\t// }\n\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\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\t// this._changeObservable.emit('destroy');\n\t\t\tif (isOnDestroy(this._model)) {\n\t\t\t\tthis._model.onDestroy.call(this._proxyModel);\n\t\t\t}\n\t\t\t// this.emitChanges('destroy');\n\t\t}\n\n\t\t// events api\n\t\taddEventListener(eventName: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void {\n\t\t\tif ('on' + eventName in this) {\n\t\t\t\tsuper.addEventListener(eventName, (event: Event) => {\n\t\t\t\t\t(listener as Function)(event);\n\t\t\t\t}, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst modelOutput = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelOutput) {\n\t\t\t\t// modelOutput.subscribe(listener);\n\t\t\t\tmodelOutput.subscribe((data: any) => {\n\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._model.subscribeModel(eventName, listener as () => void);\n\t\t\t}\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\tFACTORY_CACHE.set(htmlElementType, CustomView);\n\treturn CustomView;\n}\n\n// const CustomViewTypes: WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>> = new WeakMap();\n// function createViewClass(elementType: TypeOf<HTMLElement>, isForm: boolean) {\n// if (isForm) {\n// let ViewClass = baseFormFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// else {\n// let ViewClass = baseFactoryView(elementType);\n// CustomViewTypes.set(elementType, ViewClass);\n// return ViewClass;\n// }\n// }\n\n// export function getBaseViewClassByHTMLElementType(elementType?: TypeOf<HTMLElement>, isFormAssociated?: boolean) {\n// if (elementType && CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n// }\n// // start to created view class\n// else if (!elementType || elementType === HTMLElement) {\n// return createViewClass(HTMLElement, isFormAssociated || false);\n// }\n// if (CustomViewTypes.has(elementType)) {\n// return CustomViewTypes.get(elementType);\n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,OAAO,CAAC,CAAC;gBACZ,OAAO;aACP;YACD,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAM,SAAS,CAAC,CAAC;YACzD,IAAI,WAAW,EAAE;gBAChB,WAAW,CAAC,SAAS,CAAC,CAAC,IAAS,EAAE,EAAE;oBAClC,QAAqB,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;aACH;QACF,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;IAAA,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { ReactiveScope, ScopeContext, ScopeSubscription } from '@ibyar/expressions';\nimport {\n\tisAfterContentChecked, isAfterContentInit, isAfterViewChecked,\n\tisAfterViewInit, isDoCheck, isOnChanges, isOnDestroy, isOnInit\n} from '../component/lifecycle.js';\nimport { ComponentRef, PropertyRef } 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 { ElementModelReactiveScope } from '../component/provider.js';\n\nconst FACTORY_CACHE = new WeakMap<TypeOf<HTMLElement>, TypeOf<HTMLComponent<any>>>();\n\nexport function baseFactoryView<T extends object>(htmlElementType: TypeOf<HTMLElement>): TypeOf<HTMLComponent<T>> {\n\n\tif (FACTORY_CACHE.has(htmlElementType)) {\n\t\treturn FACTORY_CACHE.get(htmlElementType) as TypeOf<HTMLComponent<T>>;\n\t}\n\tclass CustomView extends htmlElementType implements BaseComponent<T>, CustomElement {\n\t\t_model: ModelType<T>;\n\t\t_proxyModel: 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: ReactiveScope<T>;\n\t\t_viewScope: ReactiveScope<{ 'this': BaseComponent<T> }>;\n\n\t\tprivate subscriptions: ScopeSubscription<ScopeContext>[] = [];\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 model = new modelClass(/* resolve dependency injection*/);\n\t\t\tthis._model = model;\n\n\t\t\tconst modelScope = ElementModelReactiveScope.for(model);\n\t\t\tthis._proxyModel = modelScope.getContextProxy();\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.getScopeOrCreat('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\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\tdoBlockCallback = (): void => {\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\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._model.onChanges.call(this._proxyModel);\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\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._model.onChanges.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isOnInit(this._model)) {\n\t\t\t\tthis._model.onInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentInit(this._model)) {\n\t\t\t\tthis._model.afterContentInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\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 Host Listener events\n\t\t\t\tthis._render.initHostListener();\n\t\t\t}\n\n\t\t\tif (isAfterViewInit(this._model)) {\n\t\t\t\tthis._model.afterViewInit.call(this._proxyModel);\n\t\t\t}\n\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\n\t\t\t}\n\t\t\tthis.doBlockCallback = () => {\n\t\t\t\tif (isDoCheck(this._model)) {\n\t\t\t\t\tthis._model.doCheck.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterContentChecked(this._model)) {\n\t\t\t\t\tthis._model.afterContentChecked.call(this._proxyModel);\n\t\t\t\t}\n\t\t\t\tif (isAfterViewChecked(this._model)) {\n\t\t\t\t\tthis._model.afterViewChecked.call(this._proxyModel);\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\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._model.onDestroy.call(this._proxyModel);\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}\n\n\t\t// events api\n\t\taddEventListener(eventName: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void {\n\t\t\tif ('on' + eventName in this) {\n\t\t\t\tsuper.addEventListener(eventName, (event: Event) => {\n\t\t\t\t\t(listener as Function)(event);\n\t\t\t\t}, options);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst modelOutput = this.getEventEmitter<any>(eventName);\n\t\t\tif (modelOutput) {\n\t\t\t\tmodelOutput.subscribe((data: any) => {\n\t\t\t\t\t(listener as Function)(data);\n\t\t\t\t});\n\t\t\t}\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\tFACTORY_CACHE.set(htmlElementType, CustomView);\n\treturn CustomView;\n}\n"]}
|
package/view/render.d.ts
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScopeContext, ScopeSubscription, Stack } from '@ibyar/expressions';
|
|
2
2
|
import { CommentNode, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, DomNode, LiveTextContent, TextContent, DomAttributeDirectiveNode } from '@ibyar/elements';
|
|
3
|
-
import { ComponentRef, ListenerRef } from '../component/component.js';
|
|
4
|
-
import { ElementMutation } from './mutation.js';
|
|
5
3
|
import { HTMLComponent } from '../component/custom-element.js';
|
|
6
|
-
import { AttributeDirective, StructuralDirective } from '../directive/directive.js';
|
|
7
|
-
import { TemplateRef } from '../linker/template-ref.js';
|
|
4
|
+
import { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';
|
|
8
5
|
export declare class ComponentRender<T extends object> {
|
|
9
6
|
view: HTMLComponent<T>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
contextStack
|
|
14
|
-
templateNameScope
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
constructor(view: HTMLComponent<T>);
|
|
7
|
+
private subscriptions;
|
|
8
|
+
private componentRef;
|
|
9
|
+
private template;
|
|
10
|
+
private contextStack;
|
|
11
|
+
private templateNameScope;
|
|
12
|
+
private viewScope;
|
|
13
|
+
constructor(view: HTMLComponent<T>, subscriptions: ScopeSubscription<ScopeContext>[]);
|
|
18
14
|
initView(): void;
|
|
19
15
|
isTemplateRefName(template: DomNode): template is DomElementNode;
|
|
20
16
|
initTemplateRefMap(domNode: DomNode): void;
|
|
21
17
|
initHostListener(): void;
|
|
22
|
-
handelHostListener(listener: ListenerRef): void;
|
|
23
18
|
addNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function): void;
|
|
24
19
|
getElementByName(name: string): any;
|
|
25
|
-
createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, parentNode: Node): void;
|
|
20
|
+
createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void;
|
|
26
21
|
createComment(node: CommentNode): Comment;
|
|
27
22
|
createText(node: TextContent): Text;
|
|
28
|
-
createLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node): Text;
|
|
29
|
-
createDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node): DocumentFragment;
|
|
30
|
-
appendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node): void;
|
|
23
|
+
createLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[]): Text;
|
|
24
|
+
createDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment;
|
|
25
|
+
appendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective): void;
|
|
31
26
|
createElementByTagName(node: {
|
|
32
27
|
tagName: string;
|
|
33
28
|
is?: string;
|
|
34
29
|
}): HTMLElement;
|
|
35
|
-
createElement(node: DomElementNode, contextStack: Stack, parentNode: Node): HTMLElement;
|
|
30
|
+
createElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): HTMLElement;
|
|
31
|
+
private initAttributeDirectives;
|
|
36
32
|
initAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<ScopeContext>[];
|
|
37
|
-
|
|
33
|
+
initStructuralDirective(directive: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<ScopeContext>[];
|
|
38
34
|
}
|
package/view/render.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { ReactiveScope } from '@ibyar/expressions';
|
|
1
2
|
import { CommentNode, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent, isTagNameNative, isValidCustomElementName, TextContent } from '@ibyar/elements';
|
|
2
|
-
import { ElementMutation } from './mutation.js';
|
|
3
3
|
import { isHTMLComponent } from '../component/custom-element.js';
|
|
4
4
|
import { documentStack } from '../context/stack.js';
|
|
5
5
|
import { ClassRegistryProvider } from '../providers/provider.js';
|
|
6
6
|
import { isOnDestroy, isOnInit } from '../component/lifecycle.js';
|
|
7
7
|
import { hasAttr } from '../utils/elements-util.js';
|
|
8
|
-
import { AttributeDirective } from '../directive/directive.js';
|
|
8
|
+
import { AttributeDirective, AttributeOnStructuralDirective } from '../directive/directive.js';
|
|
9
9
|
import { TemplateRefImpl } from '../linker/template-ref.js';
|
|
10
10
|
import { ViewContainerRefImpl } from '../linker/view-container-ref.js';
|
|
11
|
+
import { createSubscriptionDestroyer } from '../context/subscription.js';
|
|
12
|
+
import { HostListenerHandler } from '../render/host-listener.handler.js';
|
|
11
13
|
function getInputEventName(element) {
|
|
12
14
|
switch (true) {
|
|
13
15
|
case element instanceof HTMLInputElement:
|
|
@@ -20,13 +22,14 @@ function getInputEventName(element) {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
export class ComponentRender {
|
|
23
|
-
constructor(view) {
|
|
25
|
+
constructor(view, subscriptions) {
|
|
24
26
|
this.view = view;
|
|
27
|
+
this.subscriptions = subscriptions;
|
|
28
|
+
this.viewScope = new ReactiveScope({});
|
|
25
29
|
this.componentRef = this.view.getComponentRef();
|
|
26
30
|
this.contextStack = documentStack.copyStack();
|
|
27
31
|
this.contextStack.pushScope(this.view._modelScope);
|
|
28
|
-
this.templateNameScope = this.contextStack.
|
|
29
|
-
this.nativeElementMutation = new ElementMutation();
|
|
32
|
+
this.templateNameScope = this.contextStack.pushReactiveScope();
|
|
30
33
|
}
|
|
31
34
|
initView() {
|
|
32
35
|
if (this.componentRef.template) {
|
|
@@ -52,11 +55,11 @@ export class ComponentRender {
|
|
|
52
55
|
this.initTemplateRefMap(this.template);
|
|
53
56
|
let rootFragment;
|
|
54
57
|
if (this.template instanceof DomFragmentNode) {
|
|
55
|
-
rootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef);
|
|
58
|
+
rootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
58
61
|
rootFragment = document.createDocumentFragment();
|
|
59
|
-
this.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef);
|
|
62
|
+
this.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);
|
|
60
63
|
}
|
|
61
64
|
rootRef.append(rootFragment);
|
|
62
65
|
}
|
|
@@ -85,50 +88,9 @@ export class ComponentRender {
|
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
initHostListener() {
|
|
88
|
-
this.componentRef.hostListeners
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
let eventName = listener.eventName, source;
|
|
92
|
-
if (listener.eventName.includes(':')) {
|
|
93
|
-
const eventSource = eventName.substring(0, eventName.indexOf(':'));
|
|
94
|
-
eventName = eventName.substring(eventName.indexOf(':') + 1);
|
|
95
|
-
if ('window' === eventSource.toLowerCase()) {
|
|
96
|
-
source = window;
|
|
97
|
-
this.addNativeEventListener(source, eventName, (event) => {
|
|
98
|
-
this.view._model[listener.modelCallbackName].call(this.view._proxyModel, event);
|
|
99
|
-
});
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
else if (eventSource in this.view) {
|
|
103
|
-
source = Reflect.get(this.view, eventSource);
|
|
104
|
-
if (!Reflect.has(source, '_model')) {
|
|
105
|
-
this.addNativeEventListener(source, eventName, (event) => {
|
|
106
|
-
this.view._model[listener.modelCallbackName].call(this.view._proxyModel, event);
|
|
107
|
-
});
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
source = this.view;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
source = this.view;
|
|
117
|
-
}
|
|
118
|
-
const sourceModel = Reflect.get(source, '_model');
|
|
119
|
-
const output = ClassRegistryProvider.hasOutput(sourceModel, eventName);
|
|
120
|
-
if (output) {
|
|
121
|
-
sourceModel[output.modelProperty].subscribe((value) => {
|
|
122
|
-
this.view._model[listener.modelCallbackName].call(this.view._proxyModel, value);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
else if (Reflect.has(source, 'on' + eventName)) {
|
|
126
|
-
this.addNativeEventListener(source, eventName, (event) => {
|
|
127
|
-
this.view._model[listener.modelCallbackName].call(this.view._proxyModel, event);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
}
|
|
91
|
+
const handlers = this.componentRef.hostListeners.map(listenerRef => new HostListenerHandler(listenerRef, this.view, this.viewScope));
|
|
92
|
+
handlers.forEach(handler => handler.onInit());
|
|
93
|
+
handlers.forEach(handler => this.subscriptions.push(createSubscriptionDestroyer(() => handler.onDestroy(), () => handler.onDisconnect(), () => handler.onConnect())));
|
|
132
94
|
}
|
|
133
95
|
addNativeEventListener(source, eventName, funcCallback) {
|
|
134
96
|
source.addEventListener(eventName, (event) => {
|
|
@@ -138,26 +100,27 @@ export class ComponentRender {
|
|
|
138
100
|
getElementByName(name) {
|
|
139
101
|
return Reflect.get(this.view, name);
|
|
140
102
|
}
|
|
141
|
-
createStructuralDirective(directive, comment, directiveStack, parentNode) {
|
|
103
|
+
createStructuralDirective(directive, comment, directiveStack, subscriptions, parentNode, host) {
|
|
142
104
|
const directiveRef = ClassRegistryProvider.getDirectiveRef(directive.name);
|
|
143
105
|
if (directiveRef) {
|
|
144
|
-
const StructuralDirectiveClass = directiveRef.modelClass;
|
|
145
106
|
const stack = directiveStack.copyStack();
|
|
146
107
|
const templateRef = new TemplateRefImpl(this, directive.node, stack, directive.templateExpressions ?? []);
|
|
147
108
|
const viewContainerRef = new ViewContainerRefImpl(parentNode, comment);
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (isOnDestroy(structural)) {
|
|
155
|
-
structural.onDestroy();
|
|
156
|
-
}
|
|
157
|
-
});
|
|
109
|
+
const StructuralDirectiveClass = directiveRef.modelClass;
|
|
110
|
+
const structural = new StructuralDirectiveClass(templateRef, viewContainerRef, host);
|
|
111
|
+
templateRef.host = structural;
|
|
112
|
+
stack.pushReactiveScopeFor({ 'this': structural });
|
|
113
|
+
const dSubs = this.initStructuralDirective(structural, directive, stack);
|
|
114
|
+
subscriptions.push(...dSubs);
|
|
158
115
|
if (isOnInit(structural)) {
|
|
159
116
|
structural.onInit();
|
|
160
117
|
}
|
|
118
|
+
if (directive.attributeDirectives?.length) {
|
|
119
|
+
this.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);
|
|
120
|
+
}
|
|
121
|
+
if (isOnDestroy(structural)) {
|
|
122
|
+
subscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));
|
|
123
|
+
}
|
|
161
124
|
}
|
|
162
125
|
else {
|
|
163
126
|
}
|
|
@@ -168,24 +131,23 @@ export class ComponentRender {
|
|
|
168
131
|
createText(node) {
|
|
169
132
|
return new Text(node.value);
|
|
170
133
|
}
|
|
171
|
-
createLiveText(textNode, contextStack, parentNode) {
|
|
134
|
+
createLiveText(textNode, contextStack, parentNode, subscriptions) {
|
|
172
135
|
const liveText = new Text('');
|
|
173
136
|
contextStack = contextStack.copyStack();
|
|
174
137
|
contextStack.pushBlockScopeFor({ this: liveText });
|
|
175
|
-
const
|
|
138
|
+
const textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);
|
|
139
|
+
subscriptions.push(...textSubscriptions);
|
|
140
|
+
contextStack.detach();
|
|
176
141
|
textNode.expression.get(contextStack);
|
|
177
|
-
|
|
178
|
-
removeSubscription.unsubscribe();
|
|
179
|
-
subscriptions.forEach(subscription => subscription.unsubscribe());
|
|
180
|
-
});
|
|
142
|
+
contextStack.reattach();
|
|
181
143
|
return liveText;
|
|
182
144
|
}
|
|
183
|
-
createDocumentFragment(node, contextStack, parentNode) {
|
|
145
|
+
createDocumentFragment(node, contextStack, parentNode, subscriptions, host) {
|
|
184
146
|
const fragment = document.createDocumentFragment();
|
|
185
|
-
node.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode));
|
|
147
|
+
node.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));
|
|
186
148
|
return fragment;
|
|
187
149
|
}
|
|
188
|
-
appendChildToParent(fragmentParent, child, contextStack, parentNode) {
|
|
150
|
+
appendChildToParent(fragmentParent, child, contextStack, parentNode, subscriptions, host) {
|
|
189
151
|
if (child instanceof DomElementNode) {
|
|
190
152
|
if (this.isTemplateRefName(child)) {
|
|
191
153
|
const templateRefName = child.templateRefName;
|
|
@@ -193,7 +155,7 @@ export class ComponentRender {
|
|
|
193
155
|
this.templateNameScope.set(templateRefName.name, templateRef);
|
|
194
156
|
return;
|
|
195
157
|
}
|
|
196
|
-
fragmentParent.append(this.createElement(child, contextStack, parentNode));
|
|
158
|
+
fragmentParent.append(this.createElement(child, contextStack, subscriptions, parentNode, host));
|
|
197
159
|
}
|
|
198
160
|
else if (child instanceof DomStructuralDirectiveNode) {
|
|
199
161
|
const commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');
|
|
@@ -201,10 +163,10 @@ export class ComponentRender {
|
|
|
201
163
|
fragmentParent.append(comment);
|
|
202
164
|
const lastComment = document.createComment(`end ${commentText}`);
|
|
203
165
|
comment.after(lastComment);
|
|
204
|
-
this.createStructuralDirective(child, comment, contextStack, parentNode);
|
|
166
|
+
this.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);
|
|
205
167
|
}
|
|
206
168
|
else if (isLiveTextContent(child)) {
|
|
207
|
-
fragmentParent.append(this.createLiveText(child, contextStack, parentNode));
|
|
169
|
+
fragmentParent.append(this.createLiveText(child, contextStack, parentNode, subscriptions));
|
|
208
170
|
}
|
|
209
171
|
else if (child instanceof TextContent) {
|
|
210
172
|
fragmentParent.append(this.createText(child));
|
|
@@ -213,7 +175,7 @@ export class ComponentRender {
|
|
|
213
175
|
fragmentParent.append(this.createComment(child));
|
|
214
176
|
}
|
|
215
177
|
else if (child instanceof DomFragmentNode) {
|
|
216
|
-
fragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode));
|
|
178
|
+
fragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));
|
|
217
179
|
}
|
|
218
180
|
}
|
|
219
181
|
createElementByTagName(node) {
|
|
@@ -241,27 +203,11 @@ export class ComponentRender {
|
|
|
241
203
|
}
|
|
242
204
|
return element;
|
|
243
205
|
}
|
|
244
|
-
createElement(node, contextStack, parentNode) {
|
|
206
|
+
createElement(node, contextStack, subscriptions, parentNode, host) {
|
|
245
207
|
const element = this.createElementByTagName(node);
|
|
246
208
|
const elementStack = contextStack.copyStack();
|
|
247
|
-
const elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.
|
|
209
|
+
const elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.pushReactiveScopeFor({ 'this': element });
|
|
248
210
|
elementStack.pushScope(elementScope);
|
|
249
|
-
const subscriptions = [];
|
|
250
|
-
if (node.attributeDirectives?.length) {
|
|
251
|
-
node.attributeDirectives.forEach(directiveNode => {
|
|
252
|
-
const directiveRef = ClassRegistryProvider.getDirectiveRef(directiveNode.name);
|
|
253
|
-
if (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {
|
|
254
|
-
const directive = new directiveRef.modelClass(element);
|
|
255
|
-
const stack = contextStack.copyStack();
|
|
256
|
-
stack.pushBlockReactiveScopeFor({ 'this': directive });
|
|
257
|
-
const directiveSubscriptions = this.initDirectiveAttributes(directive, directiveNode, stack);
|
|
258
|
-
subscriptions.push(...directiveSubscriptions);
|
|
259
|
-
if (isOnInit(directive)) {
|
|
260
|
-
directive.onInit();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
211
|
const attributesSubscriptions = this.initAttribute(element, node, elementStack);
|
|
266
212
|
subscriptions.push(...attributesSubscriptions);
|
|
267
213
|
const eventName = getInputEventName(element);
|
|
@@ -271,14 +217,10 @@ export class ComponentRender {
|
|
|
271
217
|
listener = (event) => inputScope.emit('value', element.value);
|
|
272
218
|
element.addEventListener(eventName, listener);
|
|
273
219
|
}
|
|
274
|
-
const removeSubscription = this.nativeElementMutation.subscribeOnRemoveNode(parentNode, element, () => {
|
|
275
|
-
removeSubscription.unsubscribe();
|
|
276
|
-
listener && element.removeEventListener(eventName, listener);
|
|
277
|
-
subscriptions.forEach(subscription => subscription.unsubscribe());
|
|
278
|
-
});
|
|
279
220
|
const templateRefName = node.templateRefName;
|
|
280
221
|
if (templateRefName) {
|
|
281
222
|
Reflect.set(this.view, templateRefName.name, element);
|
|
223
|
+
this.viewScope.set(templateRefName.name, element);
|
|
282
224
|
const view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);
|
|
283
225
|
if (view) {
|
|
284
226
|
Reflect.set(this.view._model, view.modelName, element);
|
|
@@ -286,11 +228,34 @@ export class ComponentRender {
|
|
|
286
228
|
}
|
|
287
229
|
if (node.children) {
|
|
288
230
|
for (const child of node.children) {
|
|
289
|
-
this.appendChildToParent(element, child, elementStack, element);
|
|
231
|
+
this.appendChildToParent(element, child, elementStack, element, subscriptions, host);
|
|
290
232
|
}
|
|
291
233
|
}
|
|
234
|
+
if (node.attributeDirectives?.length) {
|
|
235
|
+
this.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);
|
|
236
|
+
}
|
|
292
237
|
return element;
|
|
293
238
|
}
|
|
239
|
+
initAttributeDirectives(attributeDirectives, element, contextStack, subscriptions) {
|
|
240
|
+
attributeDirectives?.forEach(directiveNode => {
|
|
241
|
+
const directiveRef = ClassRegistryProvider.getDirectiveRef(directiveNode.name);
|
|
242
|
+
if (directiveRef &&
|
|
243
|
+
(directiveRef.modelClass.prototype instanceof AttributeDirective
|
|
244
|
+
|| directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective)) {
|
|
245
|
+
const directive = new directiveRef.modelClass(element);
|
|
246
|
+
const stack = contextStack.copyStack();
|
|
247
|
+
stack.pushReactiveScopeFor({ 'this': directive });
|
|
248
|
+
const directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);
|
|
249
|
+
subscriptions.push(...directiveSubscriptions);
|
|
250
|
+
if (isOnInit(directive)) {
|
|
251
|
+
directive.onInit();
|
|
252
|
+
}
|
|
253
|
+
if (isOnDestroy(directive)) {
|
|
254
|
+
subscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
294
259
|
initAttribute(element, node, contextStack) {
|
|
295
260
|
const subscriptions = [];
|
|
296
261
|
if (node.attributes?.length) {
|
|
@@ -316,14 +281,18 @@ export class ComponentRender {
|
|
|
316
281
|
node.twoWayBinding.forEach(attr => {
|
|
317
282
|
const sub = attr.expression.subscribe(contextStack);
|
|
318
283
|
subscriptions.push(...sub);
|
|
284
|
+
contextStack.detach();
|
|
319
285
|
attr.expression.get(contextStack);
|
|
286
|
+
contextStack.reattach();
|
|
320
287
|
});
|
|
321
288
|
}
|
|
322
289
|
if (node.inputs?.length) {
|
|
323
290
|
node.inputs.forEach(attr => {
|
|
324
291
|
const sub = attr.expression.subscribe(contextStack, attr.pipelineNames);
|
|
325
292
|
subscriptions.push(...sub);
|
|
293
|
+
contextStack.detach();
|
|
326
294
|
attr.expression.get(contextStack);
|
|
295
|
+
contextStack.reattach();
|
|
327
296
|
});
|
|
328
297
|
}
|
|
329
298
|
if (node.outputs?.length) {
|
|
@@ -333,7 +302,9 @@ export class ComponentRender {
|
|
|
333
302
|
listener = ($event) => {
|
|
334
303
|
const stack = contextStack.copyStack();
|
|
335
304
|
stack.pushBlockScopeFor({ $event });
|
|
336
|
-
|
|
305
|
+
stack.detach();
|
|
306
|
+
event.expression.get(stack);
|
|
307
|
+
stack.reattach();
|
|
337
308
|
};
|
|
338
309
|
}
|
|
339
310
|
else {
|
|
@@ -346,12 +317,14 @@ export class ComponentRender {
|
|
|
346
317
|
node.templateAttrs.forEach(attr => {
|
|
347
318
|
const sub = attr.expression.subscribe(contextStack);
|
|
348
319
|
subscriptions.push(...sub);
|
|
320
|
+
contextStack.detach();
|
|
349
321
|
attr.expression.get(contextStack);
|
|
322
|
+
contextStack.reattach();
|
|
350
323
|
});
|
|
351
324
|
}
|
|
352
325
|
return subscriptions;
|
|
353
326
|
}
|
|
354
|
-
|
|
327
|
+
initStructuralDirective(directive, node, contextStack) {
|
|
355
328
|
const subscriptions = [];
|
|
356
329
|
if (node.attributes?.length) {
|
|
357
330
|
node.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));
|
|
@@ -360,14 +333,18 @@ export class ComponentRender {
|
|
|
360
333
|
node.twoWayBinding.forEach(attr => {
|
|
361
334
|
const sub = attr.expression.subscribe(contextStack);
|
|
362
335
|
subscriptions.push(...sub);
|
|
336
|
+
contextStack.detach();
|
|
363
337
|
attr.expression.get(contextStack);
|
|
338
|
+
contextStack.reattach();
|
|
364
339
|
});
|
|
365
340
|
}
|
|
366
341
|
if (node.inputs?.length) {
|
|
367
342
|
node.inputs.forEach(attr => {
|
|
368
343
|
const sub = attr.expression.subscribe(contextStack, attr.pipelineNames);
|
|
369
344
|
subscriptions.push(...sub);
|
|
345
|
+
contextStack.detach();
|
|
370
346
|
attr.expression.get(contextStack);
|
|
347
|
+
contextStack.reattach();
|
|
371
348
|
});
|
|
372
349
|
}
|
|
373
350
|
if (node.outputs?.length) {
|
|
@@ -375,7 +352,9 @@ export class ComponentRender {
|
|
|
375
352
|
const listener = ($event) => {
|
|
376
353
|
const stack = contextStack.copyStack();
|
|
377
354
|
stack.pushBlockScopeFor({ $event });
|
|
378
|
-
|
|
355
|
+
stack.detach();
|
|
356
|
+
event.expression.get(stack);
|
|
357
|
+
stack.reattach();
|
|
379
358
|
};
|
|
380
359
|
directive[event.name].subscribe(listener);
|
|
381
360
|
});
|
|
@@ -384,7 +363,9 @@ export class ComponentRender {
|
|
|
384
363
|
node.templateAttrs.forEach(attr => {
|
|
385
364
|
const sub = attr.expression.subscribe(contextStack);
|
|
386
365
|
subscriptions.push(...sub);
|
|
366
|
+
contextStack.detach();
|
|
387
367
|
attr.expression.get(contextStack);
|
|
368
|
+
contextStack.reattach();
|
|
388
369
|
});
|
|
389
370
|
}
|
|
390
371
|
return subscriptions;
|