@ibyar/core 0.5.1 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +1 -1
  2. package/binding/binding.expressions.d.ts +3 -2
  3. package/binding/binding.expressions.js +52 -30
  4. package/binding/binding.expressions.js.map +1 -1
  5. package/component/component.js +8 -8
  6. package/component/component.js.map +1 -1
  7. package/component/provider.d.ts +4 -9
  8. package/component/provider.js +5 -30
  9. package/component/provider.js.map +1 -1
  10. package/context/stack.js +1 -1
  11. package/context/stack.js.map +1 -1
  12. package/context/subscription.d.ts +2 -0
  13. package/context/subscription.js +14 -0
  14. package/context/subscription.js.map +1 -0
  15. package/directive/directive.d.ts +4 -0
  16. package/directive/directive.js +5 -0
  17. package/directive/directive.js.map +1 -1
  18. package/directive/parser.d.ts +1 -1
  19. package/directive/parser.js +14 -11
  20. package/directive/parser.js.map +1 -1
  21. package/directive/providers.d.ts +2 -0
  22. package/directive/providers.js +4 -1
  23. package/directive/providers.js.map +1 -1
  24. package/html/expression.js +10 -10
  25. package/html/expression.js.map +1 -1
  26. package/index.d.ts +1 -0
  27. package/index.js +1 -0
  28. package/index.js.map +1 -1
  29. package/linker/change-detector-ref.d.ts +1 -1
  30. package/linker/change-detector-ref.js +4 -3
  31. package/linker/change-detector-ref.js.map +1 -1
  32. package/linker/template-ref.d.ts +1 -1
  33. package/linker/template-ref.js +5 -5
  34. package/linker/template-ref.js.map +1 -1
  35. package/linker/view-container-ref.d.ts +4 -4
  36. package/linker/view-container-ref.js +3 -3
  37. package/linker/view-container-ref.js.map +1 -1
  38. package/package.json +6 -6
  39. package/pipe/pipe.d.ts +3 -0
  40. package/pipe/pipe.js +14 -4
  41. package/pipe/pipe.js.map +1 -1
  42. package/providers/provider.d.ts +1 -1
  43. package/providers/provider.js +2 -0
  44. package/providers/provider.js.map +1 -1
  45. package/render/host-listener.handler.d.ts +26 -0
  46. package/render/host-listener.handler.js +69 -0
  47. package/render/host-listener.handler.js.map +1 -0
  48. package/render/render-handler.d.ts +5 -0
  49. package/render/render-handler.js +2 -0
  50. package/render/render-handler.js.map +1 -0
  51. package/view/base-view.js +3 -21
  52. package/view/base-view.js.map +1 -1
  53. package/view/render.d.ts +6 -6
  54. package/view/render.js +69 -72
  55. package/view/render.js.map +1 -1
  56. package/view/view.js +6 -0
  57. package/view/view.js.map +1 -1
package/pipe/pipe.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../../src/core/pipe/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAqB,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAcjE,MAAM,OAAgB,kBAAkB;IACvC,YAAsB,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAI,CAAC;CAG/D;AAED,MAAM,UAAU,eAAe,CAA+B,IAAS;IACtE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,OAAO,YAAa,SAAQ,aAA+C;IAChF;QACC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC;IACD,GAAG,CAAC,QAAgB;QACnB,IAAI,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;YAC7B,OAAO,IAAI,CAAC;SACZ;QACD,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAA0B,QAAQ,CAAC,CAAC;QACjF,OAAO,OAAO,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;IACvD,CAAC;IACD,GAAG,CAAC,QAAgB;QACnB,IAAI,aAAmC,CAAC;QACxC,IAAI,aAAa,GAAG,IAA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AC7B,CAAC;IAKQ,GAAG,CAAC,WAAoB,EAAE,SAA+C,EAAE,QAAc;QACjG,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACtD,IAAI,MAAM,EAAE;YACX,IAAI,CAAC,OAAO,CAAC,WAAqB,CAAC,GAAG,CAAC,KAAU,EAAE,GAAG,IAAW,EAAE,EAAE;gBACpE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAA;YACtC,CAAC,CAAC;SACF;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IACQ,GAAG,CAAC,WAAoB;QAChC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC;IACQ,WAAW,CAAC,WAAoB,EAAE,YAAmC;QAC7E,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;CACD","sourcesContent":["import { ReactiveScopeControl, ReadOnlyScope, ScopeSubscription } from '@ibyar/expressions';\nimport { OnDestroy } from '../component/lifecycle.js';\nimport { ChangeDetectorRef, createChangeDetectorRef } from '../linker/change-detector-ref.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { TypeOf } from '../utils/typeof.js';\n\n/**\n * Pipes are used as singleton\n * it will be created if it needed, had no life cycle\n * \n * * no dependency injection applied on filters for now,\n * TODO: add support of dependency injection\n */\nexport interface PipeTransform<T, U> {\n\ttransform(value: T, ...args: any[]): U;\n}\n\nexport abstract class AsyncPipeTransform<T, U> implements PipeTransform<T, U>, OnDestroy {\n\tconstructor(protected changeDetectorRef: ChangeDetectorRef) { }\n\tabstract transform(value: T, ...args: any[]): U;\n\tabstract onDestroy(): void;\n}\n\nexport function isPipeTransform<T extends any, U extends any>(pipe: any): pipe is PipeTransform<T, U> {\n\treturn Reflect.has(Object.getPrototypeOf(pipe), 'transform');\n}\n\nexport class PipeProvider extends ReadOnlyScope<{ [pipeName: string]: Function }> {\n\tconstructor() {\n\t\tsuper({}, 'block');\n\t}\n\thas(pipeName: string): boolean {\n\t\tif (pipeName in this.context) {\n\t\t\treturn true;\n\t\t}\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<PipeTransform<any, any>>(pipeName);\n\t\treturn pipeRef !== undefined && !pipeRef.asynchronous;\n\t}\n\tget(pipeName: string): any {\n\t\tlet transformFunc: Function | undefined;\n\t\tif (transformFunc = this.context[pipeName]) {\n\t\t\treturn transformFunc;\n\t\t}\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<PipeTransform<any, any>>(pipeName);\n\t\tif (pipeRef !== undefined && !pipeRef.asynchronous) {\n\t\t\tconst pipe = new pipeRef.modelClass();\n\t\t\ttransformFunc = (value: any, ...args: any[]) => pipe.transform(value, ...args);\n\t\t\tthis.context[pipeRef.name] = transformFunc;\n\t\t\treturn transformFunc;\n\t\t}\n\t\treturn void 0;\n\t}\n}\n\nexport class AsyncPipeProvider extends ReadOnlyScope<object> {\n\tconstructor() {\n\t\tsuper({}, 'block');\n\t}\n\thas(pipeName: string): boolean {\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<AsyncPipeTransform<any, any>>(pipeName);\n\t\treturn pipeRef?.asynchronous ? true : false;\n\t}\n\tget(pipeName: string): TypeOf<AsyncPipeTransform<any, any>> | undefined {\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<AsyncPipeTransform<any, any>>(pipeName);\n\t\tif (pipeRef?.asynchronous) {\n\t\t\treturn pipeRef.modelClass;\n\t\t}\n\t}\n}\n\nexport class AsyncPipeScope<T extends { [key: string]: AsyncPipeTransform<any, any> }> extends ReactiveScopeControl<T> {\n\tstatic blockScope<P extends { [key: string]: AsyncPipeTransform<any, any> }>(): AsyncPipeScope<P> {\n\t\treturn new AsyncPipeScope();\n\t}\n\tprivate wrapper: { [key: string]: Function } = {};\n\tconstructor() {\n\t\tsuper({} as T, 'block');\n\t}\n\toverride set(propertyKey: keyof T, pipeClass: TypeOf<AsyncPipeTransform<any, any>>, receiver?: any): boolean {\n\t\tconst detector = createChangeDetectorRef(this, propertyKey);\n\t\tconst pipe = new pipeClass(detector);\n\t\tconst result = super.set(propertyKey, pipe, receiver);\n\t\tif (result) {\n\t\t\tthis.wrapper[propertyKey as string] = (value: any, ...args: any[]) => {\n\t\t\t\treturn pipe.transform(value, ...args)\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t}\n\toverride get(propertyKey: keyof T): any {\n\t\treturn Reflect.get(this.wrapper, propertyKey);\n\t}\n\toverride unsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tthis.unsubscribe(propertyKey, subscription);\n\t\tconst pipe = this.context[propertyKey];\n\t\tpipe.onDestroy();\n\t}\n}\n"]}
1
+ {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../../src/core/pipe/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAqB,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAcjE,MAAM,OAAgB,kBAAkB;IACvC,YAAsB,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAI,CAAC;CAG/D;AAED,MAAM,UAAU,eAAe,CAA+B,IAAS;IACtE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;AA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AW,EAAE,YAAY,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;IACD,QAAQ;QACP,OAAO,cAAc,CAAC;IACvB,CAAC;CACD","sourcesContent":["import { ReactiveScopeControl, ReadOnlyScope, ScopeSubscription } from '@ibyar/expressions';\nimport { OnDestroy } from '../component/lifecycle.js';\nimport { ChangeDetectorRef, createChangeDetectorRef } from '../linker/change-detector-ref.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { TypeOf } from '../utils/typeof.js';\n\n/**\n * Pipes are used as singleton\n * it will be created if it needed, had no life cycle\n * \n * * no dependency injection applied on filters for now,\n * TODO: add support of dependency injection\n */\nexport interface PipeTransform<T, U> {\n\ttransform(value: T, ...args: any[]): U;\n}\n\nexport abstract class AsyncPipeTransform<T, U> implements PipeTransform<T, U>, OnDestroy {\n\tconstructor(protected changeDetectorRef: ChangeDetectorRef) { }\n\tabstract transform(value: T, ...args: any[]): U;\n\tabstract onDestroy(): void;\n}\n\nexport function isPipeTransform<T extends any, U extends any>(pipe: any): pipe is PipeTransform<T, U> {\n\treturn Reflect.has(Object.getPrototypeOf(pipe), 'transform');\n}\n\nexport class PipeProvider extends ReadOnlyScope<{ [pipeName: string]: Function }> {\n\tconstructor() {\n\t\tsuper({});\n\t}\n\thas(pipeName: string): boolean {\n\t\tif (pipeName in this.context) {\n\t\t\treturn true;\n\t\t}\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<PipeTransform<any, any>>(pipeName);\n\t\treturn pipeRef !== undefined && !pipeRef.asynchronous;\n\t}\n\tget(pipeName: string): any {\n\t\tlet transformFunc: Function | undefined;\n\t\tif (transformFunc = this.context[pipeName]) {\n\t\t\treturn transformFunc;\n\t\t}\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<PipeTransform<any, any>>(pipeName);\n\t\tif (pipeRef !== undefined && !pipeRef.asynchronous) {\n\t\t\tconst pipe = new pipeRef.modelClass();\n\t\t\ttransformFunc = (value: any, ...args: any[]) => pipe.transform(value, ...args);\n\t\t\tthis.context[pipeRef.name] = transformFunc;\n\t\t\treturn transformFunc;\n\t\t}\n\t\treturn void 0;\n\t}\n\tgetClass(): TypeOf<PipeProvider> {\n\t\treturn PipeProvider;\n\t}\n}\n\nexport class AsyncPipeProvider extends ReadOnlyScope<object> {\n\tconstructor() {\n\t\tsuper({});\n\t}\n\thas(pipeName: string): boolean {\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<AsyncPipeTransform<any, any>>(pipeName);\n\t\treturn pipeRef?.asynchronous ? true : false;\n\t}\n\tget(pipeName: string): TypeOf<AsyncPipeTransform<any, any>> | undefined {\n\t\tconst pipeRef = ClassRegistryProvider.getPipe<AsyncPipeTransform<any, any>>(pipeName);\n\t\tif (pipeRef?.asynchronous) {\n\t\t\treturn pipeRef.modelClass;\n\t\t}\n\t\treturn;\n\t}\n\tgetClass(): TypeOf<AsyncPipeProvider> {\n\t\treturn AsyncPipeProvider;\n\t}\n}\n\nexport class AsyncPipeScope<T extends { [key: string]: AsyncPipeTransform<any, any> }> extends ReactiveScopeControl<T> {\n\tstatic blockScope<P extends { [key: string]: AsyncPipeTransform<any, any> }>(): AsyncPipeScope<P> {\n\t\treturn new AsyncPipeScope();\n\t}\n\tprivate wrapper: { [key: string]: Function } = {};\n\tconstructor() {\n\t\tsuper({} as T);\n\t}\n\toverride set(propertyKey: keyof T, pipeClass: TypeOf<AsyncPipeTransform<any, any>>, receiver?: any): boolean {\n\t\tconst detector = createChangeDetectorRef(this, propertyKey);\n\t\tconst pipe = new pipeClass(detector);\n\t\tconst result = super.set(propertyKey, pipe, receiver);\n\t\tif (result) {\n\t\t\tthis.wrapper[propertyKey as string] = (value: any, ...args: any[]) => {\n\t\t\t\treturn pipe.transform(value, ...args)\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t}\n\toverride get(propertyKey: keyof T): any {\n\t\treturn Reflect.get(this.wrapper, propertyKey);\n\t}\n\toverride unsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tsuper.unsubscribe(propertyKey, subscription);\n\t\tconst pipe = this.context[propertyKey];\n\t\tpipe.onDestroy();\n\t}\n\tgetClass(): TypeOf<AsyncPipeScope<T>> {\n\t\treturn AsyncPipeScope;\n\t}\n}\n"]}
@@ -14,7 +14,7 @@ export declare class ClassRegistry {
14
14
  hasComponent<T>(selector: string): boolean;
15
15
  getComponentRef<T>(selector: string): ComponentRef<T> | undefined;
16
16
  getComponent<T>(selector: string): Function | undefined;
17
- getComponentView(selector: string): (import("../utils/typeof.js").TypeOf<import("../index.js").HTMLComponent<unknown>> & CustomElementConstructor) | undefined;
17
+ getComponentView(selector: string): (import("../index.js").TypeOf<import("../index.js").HTMLComponent<unknown>> & CustomElementConstructor) | undefined;
18
18
  hasOutput<T>(model: Object, eventName: string): PropertyRef | false;
19
19
  hasInput<T>(model: Object, eventName: string): PropertyRef | false;
20
20
  hasDirective<T>(selector: string): boolean;
@@ -38,6 +38,7 @@ export class ClassRegistry {
38
38
  return componentRef;
39
39
  }
40
40
  }
41
+ return;
41
42
  }
42
43
  getComponent(selector) {
43
44
  for (const modelClass of this.componentSet) {
@@ -46,6 +47,7 @@ export class ClassRegistry {
46
47
  return modelClass;
47
48
  }
48
49
  }
50
+ return;
49
51
  }
50
52
  getComponentView(selector) {
51
53
  return this.getComponentRef(selector)?.viewClass;
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/providers/provider.ts"],"names":[],"mappings":"AACA,OAAO,EACN,UAAU,EAEV,MAAM,2BAA2B,CAAC;AAGnC,MAAM,OAAO,aAAa;IAA1B;QACC,YAAO,GAAkB,IAAI,GAAG,EAAE,CAAC;QACnC,iBAAY,GAAkB,IAAI,GAAG,EAAE,CAAC;QACxC,eAAU,GAAkB,IAAI,GAAG,EAAE,CAAC;QACtC,iBAAY,GAAkB,IAAI,G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AED,UAAU,CAAI,WAAmB;QAChC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,UAAU,EAAE;YAC3C,MAAM,UAAU,GAAkB,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAClF,IAAI,UAAU,CAAC,IAAI,KAAK,WAAW,EAAE;gBACpC,OAAO,UAAU,CAAC;aAClB;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["\nimport {\n\tComponents, ComponentRef, DirectiveRef,\n\tPipeRef, PropertyRef, ServiceRef\n} from '../component/component.js';\nexport type ProviderType = 'component' | 'service' | 'directive' | 'pipe' | 'self';\n\nexport class ClassRegistry {\n\tviewSet: Set<Function> = new Set();\n\tcomponentSet: Set<Function> = new Set();\n\tserviceSet: Set<Function> = new Set();\n\tdirectiveSet: Set<Function> = new Set();\n\tpipeSet: Set<Function> = new Set();\n\n\tregisterView(classRef: Function): void {\n\t\tthis.viewSet.add(classRef);\n\t}\n\tregisterComponent(classRef: Function): void {\n\t\tthis.componentSet.add(classRef);\n\t}\n\tregisterService(classRef: Function): void {\n\t\tthis.serviceSet.add(classRef);\n\t}\n\tregisterDirective(classRef: Function): void {\n\t\tthis.directiveSet.add(classRef);\n\t}\n\tregisterPipe(classRef: Function): void {\n\t\tthis.pipeSet.add(classRef);\n\t}\n\n\thasComponent<T>(selector: string): boolean {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tgetComponentRef<T>(selector: string): ComponentRef<T> | undefined {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn componentRef;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetComponent<T>(selector: string) {\n\t\t// this.componentSet.\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn modelClass;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetComponentView(selector: string) {\n\t\treturn this.getComponentRef(selector)?.viewClass;\n\t}\n\n\thasOutput<T>(model: Object, eventName: string): PropertyRef | false {\n\t\tif (Reflect.has(model, 'bootstrap')) {\n\t\t\tconst componentRef: ComponentRef<T> = Reflect.get(model, 'bootstrap');\n\t\t\tif (componentRef.outputs) {\n\t\t\t\tfor (const out of componentRef.outputs) {\n\t\t\t\t\tif (out.viewAttribute === eventName) {\n\t\t\t\t\t\treturn out;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\thasInput<T>(model: Object, eventName: string): PropertyRef | false {\n\t\tif (Reflect.has(model, 'bootstrap')) {\n\t\t\tconst componentRef: ComponentRef<T> = Reflect.get(model, 'bootstrap');\n\t\t\tif (componentRef.inputs) {\n\t\t\t\tfor (const input of componentRef.inputs) {\n\t\t\t\t\tif (input.viewAttribute === eventName) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\thasDirective<T>(selector: string): boolean {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif (directiveRef.selector === selector) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tdirectiveHasInput<T>(input: string, directiveType: 'attributes' | 'structural' = 'attributes'): boolean {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif ((directiveType === 'attributes' && !directiveRef.selector.startsWith('*'))\n\t\t\t\t|| (directiveType === 'structural' && directiveRef.selector.startsWith('*'))) {\n\t\t\t\tif (directiveRef.inputs?.filter(ref => ref.viewAttribute === input).length > 0) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetDirectiveRef<T>(selector: string): DirectiveRef<T> | undefined {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif (directiveRef.selector === selector) {\n\t\t\t\treturn directiveRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\n\tgetPipe<T>(pipeName: string): PipeRef<T> | undefined {\n\t\tfor (const pipeClass of this.pipeSet) {\n\t\t\tconst pipeRef: PipeRef<T> = Components.getBootstrap(pipeClass.prototype);\n\t\t\tif (pipeRef.name === pipeName) {\n\t\t\t\treturn pipeRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tgetService<T>(serviceName: string): ServiceRef<T> | undefined {\n\t\tfor (const serviceClass of this.serviceSet) {\n\t\t\tconst serviceRef: ServiceRef<T> = Components.getBootstrap(serviceClass.prototype);\n\t\t\tif (serviceRef.name === serviceName) {\n\t\t\t\treturn serviceRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n\nexport const ClassRegistryProvider = new ClassRegistry();\n"]}
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/providers/provider.ts"],"names":[],"mappings":"AACA,OAAO,EACN,UAAU,EAEV,MAAM,2BAA2B,CAAC;AAGnC,MAAM,OAAO,aAAa;IAA1B;QACC,YAAO,GAAkB,IAAI,GAAG,EAAE,CAAC;QACnC,iBAAY,GAAkB,IAAI,GAAG,EAAE,CAAC;QACxC,eAAU,GAAkB,IAAI,GAAG,EAAE,CAAC;QACtC,iBAAY,GAAkB,IAA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SAAS,CAAC;IAClB,CAAC;IAED,UAAU,CAAI,WAAmB;QAChC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,UAAU,EAAE;YAC3C,MAAM,UAAU,GAAkB,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAClF,IAAI,UAAU,CAAC,IAAI,KAAK,WAAW,EAAE;gBACpC,OAAO,UAAU,CAAC;aAClB;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["\nimport {\n\tComponents, ComponentRef, DirectiveRef,\n\tPipeRef, PropertyRef, ServiceRef\n} from '../component/component.js';\nexport type ProviderType = 'component' | 'service' | 'directive' | 'pipe' | 'self';\n\nexport class ClassRegistry {\n\tviewSet: Set<Function> = new Set();\n\tcomponentSet: Set<Function> = new Set();\n\tserviceSet: Set<Function> = new Set();\n\tdirectiveSet: Set<Function> = new Set();\n\tpipeSet: Set<Function> = new Set();\n\n\tregisterView(classRef: Function): void {\n\t\tthis.viewSet.add(classRef);\n\t}\n\tregisterComponent(classRef: Function): void {\n\t\tthis.componentSet.add(classRef);\n\t}\n\tregisterService(classRef: Function): void {\n\t\tthis.serviceSet.add(classRef);\n\t}\n\tregisterDirective(classRef: Function): void {\n\t\tthis.directiveSet.add(classRef);\n\t}\n\tregisterPipe(classRef: Function): void {\n\t\tthis.pipeSet.add(classRef);\n\t}\n\n\thasComponent<T>(selector: string): boolean {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tgetComponentRef<T>(selector: string): ComponentRef<T> | undefined {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn componentRef;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tgetComponent<T>(selector: string) {\n\t\tfor (const modelClass of this.componentSet) {\n\t\t\tconst componentRef: ComponentRef<T> = Components.getComponentRef(modelClass);\n\t\t\tif (componentRef.selector === selector) {\n\t\t\t\treturn modelClass;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tgetComponentView(selector: string) {\n\t\treturn this.getComponentRef(selector)?.viewClass;\n\t}\n\n\thasOutput<T>(model: Object, eventName: string): PropertyRef | false {\n\t\tif (Reflect.has(model, 'bootstrap')) {\n\t\t\tconst componentRef: ComponentRef<T> = Reflect.get(model, 'bootstrap');\n\t\t\tif (componentRef.outputs) {\n\t\t\t\tfor (const out of componentRef.outputs) {\n\t\t\t\t\tif (out.viewAttribute === eventName) {\n\t\t\t\t\t\treturn out;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\thasInput<T>(model: Object, eventName: string): PropertyRef | false {\n\t\tif (Reflect.has(model, 'bootstrap')) {\n\t\t\tconst componentRef: ComponentRef<T> = Reflect.get(model, 'bootstrap');\n\t\t\tif (componentRef.inputs) {\n\t\t\t\tfor (const input of componentRef.inputs) {\n\t\t\t\t\tif (input.viewAttribute === eventName) {\n\t\t\t\t\t\treturn input;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\thasDirective<T>(selector: string): boolean {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif (directiveRef.selector === selector) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tdirectiveHasInput<T>(input: string, directiveType: 'attributes' | 'structural' = 'attributes'): boolean {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif ((directiveType === 'attributes' && !directiveRef.selector.startsWith('*'))\n\t\t\t\t|| (directiveType === 'structural' && directiveRef.selector.startsWith('*'))) {\n\t\t\t\tif (directiveRef.inputs?.filter(ref => ref.viewAttribute === input).length > 0) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetDirectiveRef<T>(selector: string): DirectiveRef<T> | undefined {\n\t\tfor (const directiveClass of this.directiveSet) {\n\t\t\tconst directiveRef: DirectiveRef<T> = Components.getBootstrap(directiveClass.prototype);\n\t\t\tif (directiveRef.selector === selector) {\n\t\t\t\treturn directiveRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\n\tgetPipe<T>(pipeName: string): PipeRef<T> | undefined {\n\t\tfor (const pipeClass of this.pipeSet) {\n\t\t\tconst pipeRef: PipeRef<T> = Components.getBootstrap(pipeClass.prototype);\n\t\t\tif (pipeRef.name === pipeName) {\n\t\t\t\treturn pipeRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tgetService<T>(serviceName: string): ServiceRef<T> | undefined {\n\t\tfor (const serviceClass of this.serviceSet) {\n\t\t\tconst serviceRef: ServiceRef<T> = Components.getBootstrap(serviceClass.prototype);\n\t\t\tif (serviceRef.name === serviceName) {\n\t\t\t\treturn serviceRef;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n\nexport const ClassRegistryProvider = new ClassRegistry();\n"]}
@@ -0,0 +1,26 @@
1
+ import { ReactiveScope } from '@ibyar/expressions';
2
+ import { ListenerRef } from '../component/component.js';
3
+ import { HTMLComponent } from '../component/custom-element.js';
4
+ import { RenderHandler } from './render-handler.js';
5
+ declare type ElementScope = {
6
+ [element: string]: HTMLElement;
7
+ };
8
+ export declare class HostListenerHandler implements RenderHandler {
9
+ private listenerRef;
10
+ private element;
11
+ private elementScope;
12
+ private source;
13
+ private eventName;
14
+ private argumentsExpression;
15
+ private stack;
16
+ private scopeSubscription?;
17
+ private listener;
18
+ constructor(listenerRef: ListenerRef, element: HTMLComponent<any>, elementScope: ReactiveScope<ElementScope>);
19
+ onInit(): void;
20
+ private addEventListener;
21
+ private removeEventListener;
22
+ onConnect(): void;
23
+ onDisconnect(): void;
24
+ onDestroy(): void;
25
+ }
26
+ export {};
@@ -0,0 +1,69 @@
1
+ import { JavaScriptParser, Stack } from '@ibyar/expressions';
2
+ export class HostListenerHandler {
3
+ constructor(listenerRef, element, elementScope) {
4
+ this.listenerRef = listenerRef;
5
+ this.element = element;
6
+ this.elementScope = elementScope;
7
+ this.listener = (event) => {
8
+ const method = this.element._proxyModel[this.listenerRef.modelCallbackName];
9
+ if (typeof method === 'function') {
10
+ const eventScope = this.stack.pushBlockScopeFor({ $event: event });
11
+ const params = this.argumentsExpression.get(this.stack);
12
+ this.stack.clearTo(eventScope);
13
+ method.apply(this.element._proxyModel, params);
14
+ typeof event.preventDefault === 'function' && event.preventDefault();
15
+ }
16
+ };
17
+ this.stack = new Stack(elementScope);
18
+ }
19
+ onInit() {
20
+ const args = this.listenerRef.args ?? [];
21
+ const array = `[${args.join(', ')}]`;
22
+ this.argumentsExpression = JavaScriptParser.parseScript(array);
23
+ if (this.listenerRef.eventName.includes(':')) {
24
+ const [eventSource, eventName] = this.listenerRef.eventName.split(':', 2);
25
+ this.eventName = eventName;
26
+ if ('window' === eventSource.toLowerCase()) {
27
+ this.source = window;
28
+ }
29
+ else {
30
+ let source = this.elementScope.get(eventSource);
31
+ this.scopeSubscription = this.elementScope.subscribe(eventSource, (newValue) => {
32
+ if (source !== newValue) {
33
+ if (source) {
34
+ this.removeEventListener();
35
+ }
36
+ }
37
+ else if (!newValue) {
38
+ this.removeEventListener();
39
+ }
40
+ source = newValue;
41
+ this.addEventListener();
42
+ });
43
+ this.source = source;
44
+ }
45
+ }
46
+ else {
47
+ this.eventName = this.listenerRef.eventName;
48
+ this.source = this.element;
49
+ }
50
+ this.addEventListener();
51
+ }
52
+ addEventListener() {
53
+ this.source?.addEventListener(this.eventName, this.listener);
54
+ }
55
+ removeEventListener() {
56
+ this.source?.removeEventListener(this.eventName, this.listener);
57
+ }
58
+ onConnect() {
59
+ this.scopeSubscription?.resume();
60
+ }
61
+ onDisconnect() {
62
+ this.scopeSubscription?.pause();
63
+ }
64
+ onDestroy() {
65
+ this.scopeSubscription?.unsubscribe();
66
+ this.removeEventListener();
67
+ }
68
+ }
69
+ //# sourceMappingURL=host-listener.handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-listener.handler.js","sourceRoot":"","sources":["../../../src/core/render/host-listener.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,gBAAgB,EAAoC,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAwBhH,MAAM,OAAO,mBAAmB;IAsB/B,YAAoB,WAAwB,EAAU,OAA2B,EAAU,YAAyC;QAAhH,gBAAW,GAAX,WAAW,CAAa;QAAU,YAAO,GAAP,OAAO,CAAoB;QAAU,iBAAY,GAAZ,YAAY,CAA6B;QAX5H,aAAQ,GAAG,CAAC,KAAY,EAAE,EAAE;YACnC,MAAM,MAAM,GAAyB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;YAClG,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;gBACjC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;gBACnE,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC/B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;gBAC/C,OAAO,KAAK,CAA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AAC,CAAC;gBACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;aACrB;SACD;aAAM;YACN,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;SAC3B;QACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACzB,CAAC;IAEO,gBAAgB;QACvB,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB;QAC1B,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,SAAS;QACR,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,YAAY;QACX,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,SAAS;QACR,IAAI,CAAC,iBAAiB,EAAE,WAAW,EAAE,CAAC;QACtC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC5B,CAAC;CAED","sourcesContent":["import { ArrayExpression, JavaScriptParser, ReactiveScope, ScopeSubscription, Stack } from '@ibyar/expressions';\nimport { ListenerRef } from '../component/component.js';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { RenderHandler } from './render-handler.js';\n\ntype ElementScope = { [element: string]: HTMLElement };\n\n/**\n * ```ts\n * class View {\n * \n *\t@HostListener('window:load', ['$event.target', '\"load\"'])\n * \t@HostListener('click', ['$event.target', '\"click\"'])\n * \tpublic onClick(target: any, type: string){\n * \t\tconsole.log(target, type);\n * \t}\n * }\n * ```\n * \n * window.addEventListener('load', $event => listener($event.target, 'load'));\n * \n * view.addEventListener('click', $event => listener($event.target, 'click'));\n * \n */\nexport class HostListenerHandler implements RenderHandler {\n\n\tprivate source: HTMLElement | Window;\n\tprivate eventName: string;\n\n\tprivate argumentsExpression: ArrayExpression;\n\tprivate stack: Stack;\n\n\tprivate scopeSubscription?: ScopeSubscription<ElementScope>;\n\n\n\tprivate listener = (event: Event) => {\n\t\tconst method: Function | undefined = this.element._proxyModel[this.listenerRef.modelCallbackName];\n\t\tif (typeof method === 'function') {\n\t\t\tconst eventScope = this.stack.pushBlockScopeFor({ $event: event });\n\t\t\tconst params = this.argumentsExpression.get(this.stack);\n\t\t\tthis.stack.clearTo(eventScope);\n\t\t\tmethod.apply(this.element._proxyModel, params);\n\t\t\ttypeof event.preventDefault === 'function' && event.preventDefault();\n\t\t}\n\t};\n\n\tconstructor(private listenerRef: ListenerRef, private element: HTMLComponent<any>, private elementScope: ReactiveScope<ElementScope>) {\n\t\tthis.stack = new Stack(elementScope);\n\t}\n\tonInit(): void {\n\t\tconst args = this.listenerRef.args ?? [];\n\t\tconst array = `[${args.join(', ')}]`;\n\t\tthis.argumentsExpression = JavaScriptParser.parseScript(array) as ArrayExpression;\n\t\tif (this.listenerRef.eventName.includes(':')) {\n\t\t\tconst [eventSource, eventName] = this.listenerRef.eventName.split(':', 2);\n\t\t\tthis.eventName = eventName;\n\t\t\tif ('window' === eventSource.toLowerCase()) {\n\t\t\t\tthis.source = window;\n\t\t\t} else {\n\t\t\t\tlet source = this.elementScope.get(eventSource) as HTMLElement;\n\t\t\t\tthis.scopeSubscription = this.elementScope.subscribe(eventSource, (newValue: HTMLElement) => {\n\t\t\t\t\tif (source !== newValue) {\n\t\t\t\t\t\tif (source) {\n\t\t\t\t\t\t\tthis.removeEventListener();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!newValue) {\n\t\t\t\t\t\tthis.removeEventListener();\n\t\t\t\t\t}\n\t\t\t\t\tsource = newValue;\n\t\t\t\t\tthis.addEventListener();\n\t\t\t\t});\n\t\t\t\tthis.source = source;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.eventName = this.listenerRef.eventName;\n\t\t\tthis.source = this.element;\n\t\t}\n\t\tthis.addEventListener();\n\t}\n\n\tprivate addEventListener() {\n\t\tthis.source?.addEventListener(this.eventName, this.listener);\n\t}\n\n\tprivate removeEventListener() {\n\t\tthis.source?.removeEventListener(this.eventName, this.listener);\n\t}\n\n\tonConnect() {\n\t\tthis.scopeSubscription?.resume();\n\t}\n\n\tonDisconnect() {\n\t\tthis.scopeSubscription?.pause();\n\t}\n\n\tonDestroy(): void {\n\t\tthis.scopeSubscription?.unsubscribe();\n\t\tthis.removeEventListener();\n\t}\n\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { OnDestroy, OnInit } from '../component/lifecycle.js';
2
+ export interface RenderHandler extends Partial<OnInit>, Partial<OnDestroy> {
3
+ onConnect?(): void;
4
+ onDisconnect?(): void;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=render-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-handler.js","sourceRoot":"","sources":["../../../src/core/render/render-handler.ts"],"names":[],"mappings":"","sourcesContent":["import { OnDestroy, OnInit } from '../component/lifecycle.js';\n\nexport interface RenderHandler extends Partial<OnInit>, Partial<OnDestroy> {\n\n\t/**\n\t * execute when element attached to parent from ui\n\t */\n\tonConnect?(): void;\n\n\t/**\n\t * execute when element disconnected from ui\n\t */\n\tonDisconnect?(): void;\n\n}\n"]}
package/view/base-view.js CHANGED
@@ -3,14 +3,6 @@ import { isAfterContentChecked, isAfterContentInit, isAfterViewChecked, isAfterV
3
3
  import { ComponentRender } from './render.js';
4
4
  import { ElementModelReactiveScope } from '../component/provider.js';
5
5
  const FACTORY_CACHE = new WeakMap();
6
- function defineInstancePropertyMap(instance, names) {
7
- if (typeof instance !== 'object') {
8
- return;
9
- }
10
- names
11
- .filter(key => !Reflect.has(instance, key))
12
- .forEach(key => Reflect.set(instance, key, undefined));
13
- }
14
6
  export function baseFactoryView(htmlElementType) {
15
7
  if (FACTORY_CACHE.has(htmlElementType)) {
16
8
  return FACTORY_CACHE.get(htmlElementType);
@@ -32,16 +24,11 @@ export function baseFactoryView(htmlElementType) {
32
24
  });
33
25
  }
34
26
  const model = new modelClass();
35
- const modelNames = componentRef.inputs.map(input => input.modelProperty)
36
- .concat(componentRef.outputs.map(output => output.modelProperty))
37
- .concat(componentRef.hostBindings.map(host => host.hostPropertyName))
38
- .concat(componentRef.viewChild.map(child => child.modelName));
39
- defineInstancePropertyMap(model, modelNames);
40
27
  this._model = model;
41
- const modelScope = ElementModelReactiveScope.blockScopeFor(model);
28
+ const modelScope = ElementModelReactiveScope.for(model);
42
29
  this._proxyModel = modelScope.getContextProxy();
43
30
  this._modelScope = modelScope;
44
- this._viewScope = ReactiveScope.blockScopeFor({ 'this': this });
31
+ this._viewScope = ReactiveScope.for({ 'this': this });
45
32
  const elementScope = this._viewScope.getScopeOrCreat('this');
46
33
  componentRef.inputs.forEach(input => {
47
34
  elementScope.subscribe(input.viewAttribute, (newValue, oldValue) => {
@@ -121,6 +108,7 @@ export function baseFactoryView(htmlElementType) {
121
108
  if (outputRef) {
122
109
  return this._model[outputRef.modelProperty];
123
110
  }
111
+ return;
124
112
  }
125
113
  hasProp(propName) {
126
114
  return Reflect.has(this._model, propName);
@@ -152,9 +140,6 @@ export function baseFactoryView(htmlElementType) {
152
140
  if (newValue === oldValue) {
153
141
  return;
154
142
  }
155
- const inputRef = this.getInput(name);
156
- if (inputRef) {
157
- }
158
143
  if (isOnChanges(this._model)) {
159
144
  this._model.onChanges.call(this._proxyModel);
160
145
  }
@@ -269,9 +254,6 @@ export function baseFactoryView(htmlElementType) {
269
254
  listener(data);
270
255
  });
271
256
  }
272
- else {
273
- this._model.subscribeModel(eventName, listener);
274
- }
275
257
  }
276
258
  triggerOutput(eventName, value) {
277
259
  const modelEvent = this.getEventEmitter(eventName);
@@ -1 +1 @@
1
- {"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmC,MAAM,o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,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\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\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\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, 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\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\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\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\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\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// } else {\n\n// }\n// }\n"]}
1
+ {"version":3,"file":"base-view.js","sourceRoot":"","sources":["../../../src/core/view/base-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmC,MAAM,oBAAoB,CAAC;AACpF,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,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;QAcvC,YAAY,YAA6B,EAAE,UAAqB;YAC/D,KAAK,EAAE,CAAC;YAHD,kBAAa,GAAsC,EAAE,CAAC;YA2C9D,oBAAe,GAAG,GAAS,EAAE;gBAC5B,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;oBAC3B,IAAI,CAAC,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,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;QACzD,CAAC;QAGD,gBAAgB,CAAC,SAAiB,EAAE,QAAmD,EAAE,OAA2C;YACnI,IAAI,IAAI,GAAG,SAAS,IAAI,IAAI,EAAE;gBAC7B,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAY,EAAE,EAAE;oBACjD,QAAqB,CAAC,KAAK,CAAC,CAAC;gBAC/B,CAAC,EAAE,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,8 +1,7 @@
1
1
  import { ScopeContext, ScopeSubscription, Stack } from '@ibyar/expressions';
2
2
  import { CommentNode, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, DomNode, LiveTextContent, TextContent, DomAttributeDirectiveNode } from '@ibyar/elements';
3
- import { ListenerRef } from '../component/component.js';
4
3
  import { HTMLComponent } from '../component/custom-element.js';
5
- import { AttributeDirective, StructuralDirective } from '../directive/directive.js';
4
+ import { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';
6
5
  export declare class ComponentRender<T extends object> {
7
6
  view: HTMLComponent<T>;
8
7
  private subscriptions;
@@ -10,15 +9,15 @@ export declare class ComponentRender<T extends object> {
10
9
  private template;
11
10
  private contextStack;
12
11
  private templateNameScope;
12
+ private viewScope;
13
13
  constructor(view: HTMLComponent<T>, subscriptions: ScopeSubscription<ScopeContext>[]);
14
14
  initView(): void;
15
15
  isTemplateRefName(template: DomNode): template is DomElementNode;
16
16
  initTemplateRefMap(domNode: DomNode): void;
17
17
  initHostListener(): void;
18
- handelHostListener(listener: ListenerRef): void;
19
18
  addNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function): void;
20
19
  getElementByName(name: string): any;
21
- createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void;
20
+ createStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void;
22
21
  createComment(node: CommentNode): Comment;
23
22
  createText(node: TextContent): Text;
24
23
  createLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[]): Text;
@@ -28,7 +27,8 @@ export declare class ComponentRender<T extends object> {
28
27
  tagName: string;
29
28
  is?: string;
30
29
  }): HTMLElement;
31
- createElement(node: DomElementNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective): HTMLElement;
30
+ createElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): HTMLElement;
31
+ private initAttributeDirectives;
32
32
  initAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<ScopeContext>[];
33
- initDirectiveAttributes(directive: StructuralDirective | AttributeDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<ScopeContext>[];
33
+ initStructuralDirective(directive: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective, node: DomStructuralDirectiveNode | DomAttributeDirectiveNode, contextStack: Stack): ScopeSubscription<ScopeContext>[];
34
34
  }