@ibyar/core 1.2.2 → 2.0.1

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 (74) hide show
  1. package/LICENSE +1 -1
  2. package/annotation/decorators.d.ts +2 -1
  3. package/annotation/decorators.d.ts.map +1 -1
  4. package/annotation/decorators.js +3 -0
  5. package/annotation/decorators.js.map +1 -1
  6. package/annotation/options.d.ts +7 -5
  7. package/annotation/options.d.ts.map +1 -1
  8. package/annotation/options.js.map +1 -1
  9. package/component/component.d.ts +2 -2
  10. package/component/component.d.ts.map +1 -1
  11. package/component/component.js +5 -2
  12. package/component/component.js.map +1 -1
  13. package/component/reflect.d.ts.map +1 -1
  14. package/di/inject.d.ts +7 -0
  15. package/di/inject.d.ts.map +1 -0
  16. package/di/inject.js +9 -0
  17. package/di/inject.js.map +1 -0
  18. package/di/provider.d.ts +21 -0
  19. package/di/provider.d.ts.map +1 -0
  20. package/di/provider.js +57 -0
  21. package/di/provider.js.map +1 -0
  22. package/di/token.d.ts +7 -0
  23. package/di/token.d.ts.map +1 -0
  24. package/di/token.js +11 -0
  25. package/di/token.js.map +1 -0
  26. package/di/tokens.d.ts +8 -0
  27. package/di/tokens.d.ts.map +1 -0
  28. package/di/tokens.js +8 -0
  29. package/di/tokens.js.map +1 -0
  30. package/di/types.d.ts +1 -0
  31. package/di/types.d.ts.map +1 -0
  32. package/di/types.js +2 -0
  33. package/di/types.js.map +1 -0
  34. package/directive/directive.d.ts +2 -1
  35. package/directive/directive.d.ts.map +1 -1
  36. package/directive/directive.js +3 -1
  37. package/directive/directive.js.map +1 -1
  38. package/directive/parser.d.ts +2 -1
  39. package/directive/parser.d.ts.map +1 -1
  40. package/directive/parser.js +26 -19
  41. package/directive/parser.js.map +1 -1
  42. package/html/expression.d.ts.map +1 -1
  43. package/html/expression.js +4 -1
  44. package/html/expression.js.map +1 -1
  45. package/index.d.ts +3 -1
  46. package/index.d.ts.map +1 -1
  47. package/index.js +3 -1
  48. package/index.js.map +1 -1
  49. package/linker/template-ref.d.ts.map +1 -1
  50. package/linker/view-ref.d.ts.map +1 -1
  51. package/package.json +9 -8
  52. package/providers/provider.d.ts +2 -2
  53. package/providers/provider.d.ts.map +1 -1
  54. package/providers/provider.js +4 -4
  55. package/providers/provider.js.map +1 -1
  56. package/signals/proposal-signals.d.ts +4 -0
  57. package/signals/proposal-signals.d.ts.map +1 -0
  58. package/signals/proposal-signals.js +11 -0
  59. package/signals/proposal-signals.js.map +1 -0
  60. package/signals/proposal-sugnal.d.ts +1 -0
  61. package/signals/proposal-sugnal.d.ts.map +1 -0
  62. package/signals/proposal-sugnal.js +2 -0
  63. package/signals/proposal-sugnal.js.map +1 -0
  64. package/signals/signals.js +8 -8
  65. package/signals/signals.js.map +1 -1
  66. package/typedoc.json +8 -0
  67. package/view/base-view.js.map +1 -1
  68. package/view/render.d.ts.map +1 -1
  69. package/view/render.js +7 -3
  70. package/view/render.js.map +1 -1
  71. package/zone/task.d.ts +0 -61
  72. package/zone/task.d.ts.map +1 -1
  73. package/zone/task.js +127 -116
  74. package/zone/task.js.map +1 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2022 @ibyar/core
3
+ Copyright (c) 2020-2024 @ibyar/core
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  import type { Class } from '../utils/typeof.js';
2
- import { ChildOptions, ComponentOptions, DirectiveOptions, OutputEventInit, OutputOptions, PipeOptions } from './options.js';
2
+ import { ChildOptions, ComponentOptions, DirectiveOptions, OutputEventInit, OutputOptions, PipeOptions, InjectableOptions } from './options.js';
3
3
  type PropertyValue<T> = T | ((value: T) => void) | undefined;
4
4
  export declare function Input<This, Value>(name?: string): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
5
5
  export declare function FormValue<This, Value>(): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
@@ -13,6 +13,7 @@ type ValueGetter<T> = T | (() => T) | undefined;
13
13
  export declare function HostBinding<This, Value>(hostPropertyName: string): (value: ValueGetter<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassMethodDecoratorContext<This, any> | ClassGetterDecoratorContext<This, Value>) => void;
14
14
  export declare const Pipe: (param: PipeOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
15
15
  export declare const Directive: (param: DirectiveOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
16
+ export declare const Injectable: (param: InjectableOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
16
17
  export declare const Component: (param: ComponentOptions<Class> | ComponentOptions<Class>[]) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
17
18
  export declare const customElement: (param: {
18
19
  selector: string;
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAQhD,OAAO,EACN,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAChD,eAAe,EAAE,aAAa,EAAE,WAAW,EAC3C,MAAM,cAAc,CAAC;AAItB,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;AAG7D,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,sIAY/C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,wIAYpC;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,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EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,+GAe9H;AAGD,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;AAEhD,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,6KAYhE;AAED,eAAO,MAAM,IAAI,iFA7HO,GACvB,0BAgIA,CAAC;AAGF,eAAO,MAAM,SAAS,sFApIE,GACvB,0BAuIA,CAAC;AAEF,eAAO,MAAM,UAAU,uFA1IC,GACvB,0BA6IA,CAAC;AAmBF,eAAO,MAAM,SAAS,yHAjKE,GACvB,0BA0KA,CAAC;AAEF,eAAO,MAAM,aAAa;cAAkC,MAAM;wFA7K1C,GACvB,0BAgLA,CAAC"}
@@ -99,6 +99,9 @@ export const Pipe = makeClassDecorator((opt, constructor, context, metadata) =>
99
99
  export const Directive = makeClassDecorator((opt, constructor, context, metadata) => {
100
100
  Components.defineDirective(constructor, opt, metadata);
101
101
  });
102
+ export const Injectable = makeClassDecorator((opt, constructor, context) => {
103
+ Components.defineInjectable(constructor, opt, context.metadata);
104
+ });
102
105
  function generateComponent(target, opt, metadata) {
103
106
  if (opt.templateUrl) {
104
107
  fetchHtml(opt.templateUrl)
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,kBAAkB,EAAE,wBAAwB,EAC5C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAW7C,MAAM,UAAU,KAAK,CAAc,IAAa;IAC/C,OAAO,wBAAwB,CAC9B,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,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vC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;YACxB,iBAAiB,CAAC,WAAkB,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC;IACF,CAAC;SAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,iBAAiB,CAAC,WAAkB,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;AACF,CAAC,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAC9C,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;IAC7B,UAAU,CAAC,UAAU,CAAC,WAAkB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC,CACD,CAAC","sourcesContent":["import type { Class } from '../utils/typeof.js';\nimport {\n\tMetadataClass, MetadataContext,\n\tmakeClassDecorator, makeClassMemberDecorator\n} from '@ibyar/decorators';\nimport { Components } from '../component/component.js';\nimport { ReflectComponents } from '../component/reflect.js';\nimport { fetchHtml } from '../utils/path.js';\nimport {\n\tChildOptions, ComponentOptions, DirectiveOptions,\n\tOutputEventInit, OutputOptions, PipeOptions, ServiceOptions\n} from './options.js';\n\n\n\ntype PropertyValue<T> = T | ((value: T) => void) | undefined;\n\n\nexport function Input<This, Value>(name?: string) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (!name && typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addInput(metadata, context.name as string, name || context.name as string);\n\t\t}\n\t);\n}\n\nexport function FormValue<This, Value>() {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addInput(metadata, context.name, 'value');\n\t\t}\n\t);\n}\n\nexport function Output<This, Value>(options?: OutputOptions): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\nexport function Output<This, Value>(name?: string, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\nexport function Output<This, Value>(name?: string | OutputOptions, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void {\n\tconst eventType = typeof name === 'object' ? name.name : name;\n\tconst eventOpts = typeof name === 'object' ? name : options;\n\treturn makeClassMemberDecorator<undefined, ClassFieldDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addOutput(\n\t\t\t\tmetadata,\n\t\t\t\tcontext.name,\n\t\t\t\teventType || context.name,\n\t\t\t\t{\n\t\t\t\t\tbubbles: eventOpts?.bubbles ?? false,\n\t\t\t\t\tcomposed: eventOpts?.composed ?? false\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n}\n\nexport function View<This, Value>() {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.setComponentView(metadata, context.name);\n\t\t}\n\t);\n}\n\nexport function ViewChild<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addViewChild(metadata, context.name, selector, childOptions);\n\t\t}\n\t);\n}\n\nexport function ViewChildren<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addViewChildren(metadata, context.name, selector);\n\t\t}\n\t);\n}\n\n\nexport function HostListener<This, Value extends (this: This, ...args: any) => any>(eventName: string, args?: string | string[]) {\n\treturn makeClassMemberDecorator<Value, ClassMethodDecoratorContext>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\targs = typeof args === 'string' ? [args] : args;\n\t\t\tReflectComponents.addHostListener(\n\t\t\t\tmetadata,\n\t\t\t\tcontext.name,\n\t\t\t\teventName,\n\t\t\t\targs || []\n\t\t\t);\n\t\t}\n\t);\n}\n\n\ntype ValueGetter<T> = T | (() => T) | undefined;\n\nexport function HostBinding<This, Value>(hostPropertyName: string) {\n\treturn makeClassMemberDecorator<ValueGetter<Value>, ClassFieldDecoratorContext<This, Value> | ClassMethodDecoratorContext<This, any> | ClassGetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addHostBinding(metadata, context.name, hostPropertyName);\n\t\t}\n\t);\n}\n\nexport const Pipe = makeClassDecorator<PipeOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.definePipe(constructor as any, opt, metadata);\n\t}\n);\n\n\nexport const Directive = makeClassDecorator<DirectiveOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.defineDirective(constructor as any, opt, metadata);\n\t}\n);\n\n\nfunction generateComponent<T extends Class>(target: MetadataClass<T>, opt: ComponentOptions<T>, metadata: MetadataContext) {\n\tif (opt.templateUrl) {\n\t\tfetchHtml(opt.templateUrl)\n\t\t\t.then(htmlTemplate => {\n\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\tComponents.defineComponent(target, opt, metadata);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(reason => {\n\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t});\n\t} else {\n\t\tComponents.defineComponent(target, opt, metadata);\n\t}\n}\n\nexport const Component = makeClassDecorator<ComponentOptions | ComponentOptions[]>(\n\t(opt, constructor, context, metadata) => {\n\t\tif (Array.isArray(opt)) {\n\t\t\tfor (const comp of opt) {\n\t\t\t\tgenerateComponent(constructor as any, comp, metadata);\n\t\t\t}\n\t\t} else if (typeof opt === 'object') {\n\t\t\tgenerateComponent(constructor as any, opt, metadata);\n\t\t}\n\t}\n);\n\nexport const customElement = makeClassDecorator<{ selector: string } & ElementDefinitionOptions, Class<HTMLElement>>(\n\t(opt, constructor, context) => {\n\t\tComponents.defineView(constructor as any, opt);\n\t}\n);\n"]}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,kBAAkB,EAAE,wBAAwB,EAC5C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAY7C,MAAM,UAAU,KAAK,CAAc,IAAa;IAC/C,OAAO,wBAAwB,CAC9B,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC5B,IAAI,CAAC,IAAI,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC/C,MAAM,IAAI,SAAS,CAAC,QAAQ,OAAO,OAAO,CAAC,IAAI,QAAQ,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACrG,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,IAAI,WAAW,CAAC,oBAAoB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;QACzF,CAAC;QACD,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAc,EAAE,IAAI,IAAI,OA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AiB,CAAC,WAAkB,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;AACF,CAAC,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAC9C,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;IAC7B,UAAU,CAAC,UAAU,CAAC,WAAkB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC,CACD,CAAC","sourcesContent":["import type { Class } from '../utils/typeof.js';\nimport {\n\tMetadataClass, MetadataContext,\n\tmakeClassDecorator, makeClassMemberDecorator\n} from '@ibyar/decorators';\nimport { Components } from '../component/component.js';\nimport { ReflectComponents } from '../component/reflect.js';\nimport { fetchHtml } from '../utils/path.js';\nimport {\n\tChildOptions, ComponentOptions, DirectiveOptions,\n\tOutputEventInit, OutputOptions, PipeOptions,\n\tInjectableOptions\n} from './options.js';\n\n\n\ntype PropertyValue<T> = T | ((value: T) => void) | undefined;\n\n\nexport function Input<This, Value>(name?: string) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (!name && typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addInput(metadata, context.name as string, name || context.name as string);\n\t\t}\n\t);\n}\n\nexport function FormValue<This, Value>() {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addInput(metadata, context.name, 'value');\n\t\t}\n\t);\n}\n\nexport function Output<This, Value>(options?: OutputOptions): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\nexport function Output<This, Value>(name?: string, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\nexport function Output<This, Value>(name?: string | OutputOptions, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void {\n\tconst eventType = typeof name === 'object' ? name.name : name;\n\tconst eventOpts = typeof name === 'object' ? name : options;\n\treturn makeClassMemberDecorator<undefined, ClassFieldDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addOutput(\n\t\t\t\tmetadata,\n\t\t\t\tcontext.name,\n\t\t\t\teventType || context.name,\n\t\t\t\t{\n\t\t\t\t\tbubbles: eventOpts?.bubbles ?? false,\n\t\t\t\t\tcomposed: eventOpts?.composed ?? false\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n}\n\nexport function View<This, Value>() {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.setComponentView(metadata, context.name);\n\t\t}\n\t);\n}\n\nexport function ViewChild<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addViewChild(metadata, context.name, selector, childOptions);\n\t\t}\n\t);\n}\n\nexport function ViewChildren<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor) {\n\treturn makeClassMemberDecorator<PropertyValue<Value>, ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addViewChildren(metadata, context.name, selector);\n\t\t}\n\t);\n}\n\n\nexport function HostListener<This, Value extends (this: This, ...args: any) => any>(eventName: string, args?: string | string[]) {\n\treturn makeClassMemberDecorator<Value, ClassMethodDecoratorContext>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\targs = typeof args === 'string' ? [args] : args;\n\t\t\tReflectComponents.addHostListener(\n\t\t\t\tmetadata,\n\t\t\t\tcontext.name,\n\t\t\t\teventName,\n\t\t\t\targs || []\n\t\t\t);\n\t\t}\n\t);\n}\n\n\ntype ValueGetter<T> = T | (() => T) | undefined;\n\nexport function HostBinding<This, Value>(hostPropertyName: string) {\n\treturn makeClassMemberDecorator<ValueGetter<Value>, ClassFieldDecoratorContext<This, Value> | ClassMethodDecoratorContext<This, any> | ClassGetterDecoratorContext<This, Value>>(\n\t\t(value, context, metadata) => {\n\t\t\tif (typeof context.name !== 'string') {\n\t\t\t\tthrow new TypeError(`type ${typeof context.name} of '${context.name.toString()}' is not supported`);\n\t\t\t}\n\t\t\tif (context.private) {\n\t\t\t\tthrow new SyntaxError(`private members '${context.name.toString()}' is not supported.`);\n\t\t\t}\n\t\t\tReflectComponents.addHostBinding(metadata, context.name, hostPropertyName);\n\t\t}\n\t);\n}\n\nexport const Pipe = makeClassDecorator<PipeOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.definePipe(constructor as any, opt, metadata);\n\t}\n);\n\n\nexport const Directive = makeClassDecorator<DirectiveOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.defineDirective(constructor as any, opt, metadata);\n\t}\n);\n\nexport const Injectable = makeClassDecorator<InjectableOptions>(\n\t(opt, constructor, context) => {\n\t\tComponents.defineInjectable(constructor as any, opt, context.metadata);\n\t}\n);\n\nfunction generateComponent<T extends Class>(target: MetadataClass<T>, opt: ComponentOptions<T>, metadata: MetadataContext) {\n\tif (opt.templateUrl) {\n\t\tfetchHtml(opt.templateUrl)\n\t\t\t.then(htmlTemplate => {\n\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\tComponents.defineComponent(target, opt, metadata);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(reason => {\n\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t});\n\t} else {\n\t\tComponents.defineComponent(target, opt, metadata);\n\t}\n}\n\nexport const Component = makeClassDecorator<ComponentOptions | ComponentOptions[]>(\n\t(opt, constructor, context, metadata) => {\n\t\tif (Array.isArray(opt)) {\n\t\t\tfor (const comp of opt) {\n\t\t\t\tgenerateComponent(constructor as any, comp, metadata);\n\t\t\t}\n\t\t} else if (typeof opt === 'object') {\n\t\t\tgenerateComponent(constructor as any, opt, metadata);\n\t\t}\n\t}\n);\n\nexport const customElement = makeClassDecorator<{ selector: string } & ElementDefinitionOptions, Class<HTMLElement>>(\n\t(opt, constructor, context) => {\n\t\tComponents.defineView(constructor as any, opt);\n\t}\n);\n"]}
@@ -51,8 +51,12 @@ export interface DirectiveOptions {
51
51
  * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.
52
52
  */
53
53
  zone?: ZoneType;
54
+ /**
55
+ * name of possible structure directive successor
56
+ */
57
+ successor?: string;
54
58
  }
55
- export interface ServiceOptions {
59
+ export interface InjectableOptions {
56
60
  provideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';
57
61
  }
58
62
  export interface PipeOptions {
@@ -87,13 +91,11 @@ export interface ComponentOptions<T = Class> {
87
91
  */
88
92
  templateUrl?: TemplateUrl | string;
89
93
  /**
90
- * template: typeof 'string' ==> html string,
91
- * TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory
94
+ * template: html string
92
95
  * if template === null || undefined ==> it had nothing to render,
93
96
  * and may be inherit from an html element
94
97
  *
95
- * 2 possible way to write a template, as inline string, represent a a valid html,
96
- * or us aurora jsx factory
98
+ * write a template, as inline string, represent a a valid html.
97
99
  *
98
100
  */
99
101
  template?: string | DomNode;
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG9D,MAAM,WA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;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAErD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,GAAG,OAAO,WAAW,GAAG,wBAAwB,CAAC;IACjE,YAAY,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { Class, TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { TemplateUrl } from '../utils/path.js';\nimport { ZoneType } from '../zone/bootstrap.js';\nimport { ValueControl } from '../component/custom-element.js';\n\n\nexport interface DirectiveOptions {\n\n\t/**\n\t * the name of the directive which is used in the template\n\t * \n\t * a structural directive name should start with `*`,\n\t * and an attributes directive should not.\n\t */\n\tselector: string;\n\n\t/**\n\t * export this directive to the HTML template scope,\n\t * \n\t * it can be accessed by the template reference name \n\t * ex:\n\t * ```ts\n\t * \n\t * \n\t * \n\t * Directive({\n\t * \tselector: '*tooltip',\n\t * \texportAs: 'tooltip'\n\t * })\n\t * ```\n\t * \n\t * in your component\n\t * \n\t * ```html\n\t * <a tooltip=\"I'm a tooltip!!\" #tooltip=\"tooltip\">I'm a link</a>\n\t * <button (click)=\"tooltip.toggleTooltip()\">Toggle tooltip</button>\n\t * ```\n\t * \n\t */\n\n\texportAs?: string;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * if no value specified, the value will be initialized by the custom element `web component` zone,\n\t * - if the web component zone is `manual`, the directive zone also will be `manual`, expect weird behavior.\n\t * - if the web component zone is `proxy`, the directive zone also will be `proxy`.\n\t * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.\n\t */\n\tzone?: ZoneType;\n}\n\nexport interface ServiceOptions {\n\tprovideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Class> {\n\n\t/**\n\t * a tag name for the component,\n\t * if the tag name is valid custom element name, the view class will be a custom element,\n\t * otherwise an HTMLUnknownElement will be created\n\t */\n\tselector: string;\n\n\t/**\n\t * add html file url path to fetch,\n\t * templateUrl had propriety than template, and will override it.\n\t *\n\t * Can provide file name as \"person-view.html\" will resolved \n\t * as 'http://site-address.org/persin-view.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }\n\t * let (import.meta = '/person/person.js') will resolved \n\t * as 'http://site-address.org/person/person-edit.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta }\n\t * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.\n\t * \n\t * if url not found, component will not be defined,\n\t * \n\t * if you didn't use webpack or rollup.js or any bundler, \n\t * you should copy the html files to its folder by yourself. \n\t */\n\ttemplateUrl?: TemplateUrl | string;\n\n\t/**\n\t * template: typeof 'string' ==> html string,\n\t * \t\t\t TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory\n\t * \tif template === null || undefined ==> it had nothing to render, \n\t * and may be inherit from an html element\n\t * \n\t * 2 possible way to write a template, as inline string, represent a a valid html, \n\t * or us aurora jsx factory \n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DomNode;\n\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\n\t/**\n\t * what basic element should the new component inherit from,\n\t * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...\n\t * also, support extends a custom element tag name.\n\t */\n\textend?: keyof HTMLElementTagNameMap | `${string}-${string}`;\n\n\t/**\n\t * An encapsulation policy for the template and CSS styles. One of:\n\t * 'custom': Use global CSS without any encapsulation.\n\t * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.\n\t * \n\t * 'template': like 'custom', with load the template from the document ('index.html' file)\n\t * \t \t\t\tthat had the same id as the component \"selector\".\n\t * 'shadow-dom-template': like 'shadowDom', and load template by selector id.\n\t * \n\t * Both 'template' & 'shadow-dom-template' encapsulation type:\n\t * should had attributes name like lowercase,\n\t * \tthe browser itself, will convert all attributes to lowercase\n\t * \n\t * ```typescript\n\t *\t\t@Input('personage') personAge: number;\n\t *\t\t@Input('propname') propName: string;\n\t *\t\t@Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();\n\t *\t\t@View('personform') personForm: HTMLFormElement;\n\t * ```\n\t * \n\t * any app root element as \n\t * \n\t * ```html\n\t * <app-root></app-root>\n\t * ```\n\t * \n\t * the supported bind options is 'One way binding *(as passing data only)'\n\t * and 'template parsing' and 'event binding' syntax, HTML (angular) like.\n\t * it load its attributes from 'window object'\n\t * \n\t * so to pass date to A root element, \n\t * \n\t * ```html\n\t * <script>\n\t * \tconst appVersion = '0.1.504';\n\t * \tfunction onRootAppClick() {\n\t *\t\tconsole.log('root app clicked');\n\t * \t}\n\t * \tfunction onSave(data){\n\t *\t\tconsole.log('root app save', data);\n\t * \t}\n\t * </script>\n\t * <app-root [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" >\n\t * </app-root>\n\t * ```\n\t * \n\t * default is 'custom'\n\t * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}\n\t */\n\tencapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\n\t/**\n\t * default: 'open' when encapsulation used,\n\t * otherwise it is undefined and will not attach shadow root element.\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n\n\t/**\n\t * shadow root initialization options,\n\t * default mode: `open`, delegatesFocus: `false` and slotAssignment: `manual`\n\t */\n\tshadowRootInit?: Partial<ShadowRootInit>;\n\n\t/**\n\t * Create a custom form-associated element with HTMLElement.attachInternals\n\t * default: false\n\t * \n\t * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface\n\t * \n\t * otherwise you can register another class that implement `ValueControl<T>`,\n\t * in case if you want split the model and the value controller.\n\t * \n\t * #### Usage Notes:\n\t * \n\t * ```ts\n\t * \n\t * @Component({\n\t * \tselector: 'custom-message',\n\t * \ttemplate: `\n\t * \t\t<label for=\"message\">Message</label>\n\t * \t\t<textarea id=\"message\" [(value)]=\"message\" [disabled]=\"disabled\" (change)=\"onMessageChange($event.target.value)\"></textarea>\n\t * \t`,\n\t * \tformAssociated: true,\n\t * \t// formAssociated: CustomMessage,\n\t * })\n\t * export class CustomMessage implements ValueControl<string> {\n\t * \n\t * \tprivate message: string | null = '';\n\t * \tprivate disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<string>) {\n\t * \t\tthis.message = mode !== 'reset' ? value : '';\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis.disabled = isDisabled;\n\t * \t}\n\t * \n\t * \tonMessageChange(message: string) {\n\t * \t\tthis._onChange(message);\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * \n\t * export class CustomInputValueControl implements ValueControl<number> {\n\t * \n\t * \tprivate _value: number | null = null;\n\t * \tprivate _disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<number>) {\n\t * \t\tthis._value = mode !== 'reset' ? value : null;\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis._disabled = isDisabled;\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * @Component({\n\t * \tselector: 'custom-input',\n\t * \textend: 'input',\n\t * \tformAssociated: CustomInputValueControl,\n\t * })\n\t * export class CustomInputElement {\n\t * \t\n\t * @View()\n\t * \tview: HTMLInputElement;\n\t * \n\t * \tonInit() {\n\t * \t\tthis.view.type = 'number';\n\t * \t}\n\t * }\n\t * \n\t * ```\n\t */\n\tformAssociated?: boolean | TypeOf<ValueControl<any>>;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * the default value is the platform zone type which can be changed by:\n\t * \n\t * ```js\n\t * bootstrapZone('manual')\n\t * bootstrapZone('proxy')\n\t * bootstrapZone('aurora')\n\t * ```\n\t * \n\t * if `bootstrapZone` never been called, then the default zone is a `manual`.\n\t */\n\tzone?: ZoneType;\n\n\t/**\n\t * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.\n\t */\n\timports?: (TypeOf<any> | ReadonlyArray<any>)[];\n}\n\nexport interface ChildOptions {\n\t[key: string]: any;\n}\n\nexport interface ViewChildOpt {\n\tselector: string | typeof HTMLElement | CustomElementConstructor;\n\tchildOptions?: ChildOptions;\n}\n\nexport type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { Class, TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { TemplateUrl } from '../utils/path.js';\nimport { ZoneType } from '../zone/bootstrap.js';\nimport { ValueControl } from '../component/custom-element.js';\n\n\nexport interface DirectiveOptions {\n\n\t/**\n\t * the name of the directive which is used in the template\n\t * \n\t * a structural directive name should start with `*`,\n\t * and an attributes directive should not.\n\t */\n\tselector: string;\n\n\t/**\n\t * export this directive to the HTML template scope,\n\t * \n\t * it can be accessed by the template reference name \n\t * ex:\n\t * ```ts\n\t * \n\t * \n\t * \n\t * Directive({\n\t * \tselector: '*tooltip',\n\t * \texportAs: 'tooltip'\n\t * })\n\t * ```\n\t * \n\t * in your component\n\t * \n\t * ```html\n\t * <a tooltip=\"I'm a tooltip!!\" #tooltip=\"tooltip\">I'm a link</a>\n\t * <button (click)=\"tooltip.toggleTooltip()\">Toggle tooltip</button>\n\t * ```\n\t * \n\t */\n\n\texportAs?: string;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * if no value specified, the value will be initialized by the custom element `web component` zone,\n\t * - if the web component zone is `manual`, the directive zone also will be `manual`, expect weird behavior.\n\t * - if the web component zone is `proxy`, the directive zone also will be `proxy`.\n\t * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.\n\t */\n\tzone?: ZoneType;\n\n\n\t/**\n\t * name of possible structure directive successor\n\t */\n\tsuccessor?: string;\n}\n\nexport interface InjectableOptions {\n\tprovideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Class> {\n\n\t/**\n\t * a tag name for the component,\n\t * if the tag name is valid custom element name, the view class will be a custom element,\n\t * otherwise an HTMLUnknownElement will be created\n\t */\n\tselector: string;\n\n\t/**\n\t * add html file url path to fetch,\n\t * templateUrl had propriety than template, and will override it.\n\t *\n\t * Can provide file name as \"person-view.html\" will resolved \n\t * as 'http://site-address.org/persin-view.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }\n\t * let (import.meta = '/person/person.js') will resolved \n\t * as 'http://site-address.org/person/person-edit.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta }\n\t * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.\n\t * \n\t * if url not found, component will not be defined,\n\t * \n\t * if you didn't use webpack or rollup.js or any bundler, \n\t * you should copy the html files to its folder by yourself. \n\t */\n\ttemplateUrl?: TemplateUrl | string;\n\n\t/**\n\t * template: html string\n\t * \tif template === null || undefined ==> it had nothing to render, \n\t * and may be inherit from an html element\n\t * \n\t * write a template, as inline string, represent a a valid html.\n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DomNode;\n\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\n\t/**\n\t * what basic element should the new component inherit from,\n\t * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...\n\t * also, support extends a custom element tag name.\n\t */\n\textend?: keyof HTMLElementTagNameMap | `${string}-${string}`;\n\n\t/**\n\t * An encapsulation policy for the template and CSS styles. One of:\n\t * 'custom': Use global CSS without any encapsulation.\n\t * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.\n\t * \n\t * 'template': like 'custom', with load the template from the document ('index.html' file)\n\t * \t \t\t\tthat had the same id as the component \"selector\".\n\t * 'shadow-dom-template': like 'shadowDom', and load template by selector id.\n\t * \n\t * Both 'template' & 'shadow-dom-template' encapsulation type:\n\t * should had attributes name like lowercase,\n\t * \tthe browser itself, will convert all attributes to lowercase\n\t * \n\t * ```typescript\n\t *\t\t@Input('personage') personAge: number;\n\t *\t\t@Input('propname') propName: string;\n\t *\t\t@Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();\n\t *\t\t@View('personform') personForm: HTMLFormElement;\n\t * ```\n\t * \n\t * any app root element as \n\t * \n\t * ```html\n\t * <app-root></app-root>\n\t * ```\n\t * \n\t * the supported bind options is 'One way binding *(as passing data only)'\n\t * and 'template parsing' and 'event binding' syntax, HTML (angular) like.\n\t * it load its attributes from 'window object'\n\t * \n\t * so to pass date to A root element, \n\t * \n\t * ```html\n\t * <script>\n\t * \tconst appVersion = '0.1.504';\n\t * \tfunction onRootAppClick() {\n\t *\t\tconsole.log('root app clicked');\n\t * \t}\n\t * \tfunction onSave(data){\n\t *\t\tconsole.log('root app save', data);\n\t * \t}\n\t * </script>\n\t * <app-root [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" >\n\t * </app-root>\n\t * ```\n\t * \n\t * default is 'custom'\n\t * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}\n\t */\n\tencapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\n\t/**\n\t * default: 'open' when encapsulation used,\n\t * otherwise it is undefined and will not attach shadow root element.\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n\n\t/**\n\t * shadow root initialization options,\n\t * default mode: `open`, delegatesFocus: `false` and slotAssignment: `manual`\n\t */\n\tshadowRootInit?: Partial<ShadowRootInit>;\n\n\t/**\n\t * Create a custom form-associated element with HTMLElement.attachInternals\n\t * default: false\n\t * \n\t * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface\n\t * \n\t * otherwise you can register another class that implement `ValueControl<T>`,\n\t * in case if you want split the model and the value controller.\n\t * \n\t * #### Usage Notes:\n\t * \n\t * ```ts\n\t * \n\t * @Component({\n\t * \tselector: 'custom-message',\n\t * \ttemplate: `\n\t * \t\t<label for=\"message\">Message</label>\n\t * \t\t<textarea id=\"message\" [(value)]=\"message\" [disabled]=\"disabled\" (change)=\"onMessageChange($event.target.value)\"></textarea>\n\t * \t`,\n\t * \tformAssociated: true,\n\t * \t// formAssociated: CustomMessage,\n\t * })\n\t * export class CustomMessage implements ValueControl<string> {\n\t * \n\t * \tprivate message: string | null = '';\n\t * \tprivate disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<string>) {\n\t * \t\tthis.message = mode !== 'reset' ? value : '';\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis.disabled = isDisabled;\n\t * \t}\n\t * \n\t * \tonMessageChange(message: string) {\n\t * \t\tthis._onChange(message);\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * \n\t * export class CustomInputValueControl implements ValueControl<number> {\n\t * \n\t * \tprivate _value: number | null = null;\n\t * \tprivate _disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<number>) {\n\t * \t\tthis._value = mode !== 'reset' ? value : null;\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis._disabled = isDisabled;\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * @Component({\n\t * \tselector: 'custom-input',\n\t * \textend: 'input',\n\t * \tformAssociated: CustomInputValueControl,\n\t * })\n\t * export class CustomInputElement {\n\t * \t\n\t * @View()\n\t * \tview: HTMLInputElement;\n\t * \n\t * \tonInit() {\n\t * \t\tthis.view.type = 'number';\n\t * \t}\n\t * }\n\t * \n\t * ```\n\t */\n\tformAssociated?: boolean | TypeOf<ValueControl<any>>;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * the default value is the platform zone type which can be changed by:\n\t * \n\t * ```js\n\t * bootstrapZone('manual')\n\t * bootstrapZone('proxy')\n\t * bootstrapZone('aurora')\n\t * ```\n\t * \n\t * if `bootstrapZone` never been called, then the default zone is a `manual`.\n\t */\n\tzone?: ZoneType;\n\n\t/**\n\t * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.\n\t */\n\timports?: (TypeOf<any> | ReadonlyArray<any>)[];\n}\n\nexport interface ChildOptions {\n\t[key: string]: any;\n}\n\nexport interface ViewChildOpt {\n\tselector: string | typeof HTMLElement | CustomElementConstructor;\n\tchildOptions?: ChildOptions;\n}\n\nexport type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n"]}
@@ -4,7 +4,7 @@ import type { ZoneType } from '../zone/bootstrap.js';
4
4
  import { Tag, DomNode, DomRenderNode, DomElementNode } from '@ibyar/elements';
5
5
  import { HTMLComponent, ValueControl } from './custom-element.js';
6
6
  import { AttributeDirective, StructuralDirective } from '../directive/directive.js';
7
- import { ComponentOptions, PipeOptions, ServiceOptions, DirectiveOptions } from '../annotation/options.js';
7
+ import { ComponentOptions, PipeOptions, InjectableOptions, DirectiveOptions } from '../annotation/options.js';
8
8
  import { ChildRef, HostBindingRef, InputPropertyRef, ListenerRef, OutputPropertyRef, PropertyRef } from './reflect.js';
9
9
  export interface ServiceRef<T> {
10
10
  provideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';
@@ -62,7 +62,7 @@ export declare class Components {
62
62
  private static parseHostNode;
63
63
  static defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext): void;
64
64
  static definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext): void;
65
- static defineService<T extends Class>(modelClass: MetadataClass<T>, opts: ServiceOptions, metadata: MetadataContext): void;
65
+ static defineInjectable<T extends Class>(modelClass: MetadataClass<T>, opts: InjectableOptions, metadata: MetadataContext): void;
66
66
  static defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext): void;
67
67
  static defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: {
68
68
  selector: string;
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACS,GAAG,EAClB,OAAO,EAAE,aAAa,EACH,cAAc,EAGjC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGpF,OA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AE,eAAe;IAQzH,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe;IAoG1H,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,wBAAwB;CAU1H"}
@@ -4,6 +4,7 @@ import { initCustomElementView } from '../view/view.js';
4
4
  import { buildExpressionNodes } from '../html/expression.js';
5
5
  import { ListenerRef } from './reflect.js';
6
6
  import { deserializeExpressionNodes } from '../html/deserialize.js';
7
+ import { provide } from '../di/inject.js';
7
8
  const DEFAULT_SHADOW_ROOT_INIT = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };
8
9
  export class Components {
9
10
  static EMPTY_LIST = Object.freeze([]);
@@ -90,6 +91,7 @@ export class Components {
90
91
  directiveRegistry.register(opts.selector, {
91
92
  inputs: metadata.inputs?.map(input => input.viewAttribute),
92
93
  outputs: metadata.outputs?.map(output => output.viewAttribute),
94
+ successor: metadata.successor,
93
95
  });
94
96
  }
95
97
  static definePipe(modelClass, opts, metadata) {
@@ -97,11 +99,12 @@ export class Components {
97
99
  metadata.modelClass = modelClass;
98
100
  ClassRegistryProvider.registerPipe(modelClass);
99
101
  }
100
- static defineService(modelClass, opts, metadata) {
102
+ static defineInjectable(modelClass, opts, metadata) {
101
103
  Object.assign(metadata, opts);
102
104
  metadata.modelClass = modelClass;
103
105
  metadata.name = modelClass.name;
104
- ClassRegistryProvider.registerService(modelClass);
106
+ ClassRegistryProvider.registerInjectable(modelClass);
107
+ provide(modelClass);
105
108
  }
106
109
  static defineComponent(modelClass, opts, metadata) {
107
110
  const componentRef = Object.assign(metadata, opts);
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot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,CAAC;QAChD,IAAI,aAAa,EAAE,CAAC;YACnB,IAAI,aAAa,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAChE,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;YACjC,CAAC;QACF,CAAC;QAGD,cAAc,CAAC,MAAM,CACpB,YAAY,CAAC,QAAkB,EAC/B,YAAY,CAAC,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;IAED,MAAM,CAAC,UAAU,CAAwB,SAA2B,EAAE,GAAoD;QACzH,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,GAAG,CAAC;QACxC,cAAc,CAAC,MAAM,CACpB,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CAAC;IACH,CAAC","sourcesContent":["import type { MetadataClass, MetadataContext } from '@ibyar/decorators';\nimport type { Class, TypeOf } from '../utils/typeof.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow,\n\tdirectiveRegistry, DomElementNode,\n\tDomFragmentNode, DomParentNode,\n\tisValidCustomElementName\n} from '@ibyar/elements';\n\nimport { HTMLComponent, ValueControl } from './custom-element.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective, StructuralDirective } from '../directive/directive.js';\nimport { initCustomElementView } from '../view/view.js';\nimport { buildExpressionNodes } from '../html/expression.js';\nimport {\n\tComponentOptions, PipeOptions,\n\tServiceOptions, DirectiveOptions\n} from '../annotation/options.js';\nimport {\n\tChildRef, HostBindingRef, InputPropertyRef,\n\tListenerRef, OutputPropertyRef, PropertyRef\n} from './reflect.js';\nimport { deserializeExpressionNodes } from '../html/deserialize.js';\n\n\nexport interface ServiceRef<T> {\n\tprovideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: TypeOf<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: TypeOf<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\texportAs?: string;\n\tzone?: ZoneType;\n\n\tmodelClass: TypeOf<StructuralDirective> | TypeOf<AttributeDirective>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostListeners: ListenerRef[];\n\thostBindings: HostBindingRef[];\n\tviewBindings?: DomElementNode;\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\tcompiledTemplate?: DomNode;\n\t// attrTemplate: JsxAttrComponent;\n\tstyles: string;\n\textend: Tag;\n\textendCustomElement: boolean;\n\n\tviewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: InputPropertyRef[];\n\toutputs: OutputPropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\tviewBindings?: DomElementNode;\n\twindowBindings?: DomElementNode;\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template' | 'shadow-slot';\n\tisShadowDom: boolean;\n\tshadowRootInit: ShadowRootInit;\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\n}\n\ntype ViewBindingOption = {\n\tprototype: Record<PropertyKey, any>;\n\thostBindings?: HostBindingRef[];\n\thostListeners?: ListenerRef[];\n\tselector?: string;\n};\n\ntype HostNode = {\n\thost?: DomElementNode;\n\twindow?: DomElementNode;\n\ttemplate?: DomElementNode[];\n};\n\nconst DEFAULT_SHADOW_ROOT_INIT: ShadowRootInit = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };\n\nexport class Components {\n\n\tprivate static EMPTY_LIST = Object.freeze<any>([]);\n\tprivate static emptyList<T>(): T[] {\n\t\treturn Components.EMPTY_LIST as T[];\n\t}\n\n\tprivate static patchTemplate(child: DomNode, templates: DomElementNode[]): void {\n\t\tif (child instanceof DomElementNode && child.templateRefName?.name) {\n\t\t\tconst ref = templates.find(node => child.templateRefName?.name === node.templateRefName?.name);\n\t\t\tif (ref?.outputs) {\n\t\t\t\t(child.outputs ??= []).push(...ref.outputs);\n\t\t\t}\n\t\t}\n\t\tif (child instanceof DomParentNode) {\n\t\t\tchild.children?.forEach(node => Components.patchTemplate(node, templates));\n\t\t}\n\t}\n\n\tprivate static createOutputs(Listeners?: ListenerRef[]) {\n\t\treturn Listeners?.map(\n\t\t\tlistener => `(${listener.eventName})=\"${listener.modelCallbackName}(${listener.args.join(', ')})\"`\n\t\t).join(' ') ?? ''\n\t}\n\n\tprivate static parseHostNode(option: ViewBindingOption): HostNode {\n\t\tconst inputs = option.hostBindings?.map(binding => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);\n\t\t\tif (typeof descriptor?.value === 'function') {\n\t\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}()\"`\n\t\t\t}\n\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}\"`;\n\t\t}).join(' ') ?? '';\n\n\t\tconst hostListeners: ListenerRef[] = [];\n\t\tconst windowListeners: ListenerRef[] = [];\n\t\tconst templateListeners: Record<string, ListenerRef[]> = {};\n\n\t\toption.hostListeners?.forEach(listener => {\n\t\t\tconst [host, event] = listener.eventName.split(':', 2);\n\t\t\tif (event === undefined) {\n\t\t\t\thostListeners.push(listener);\n\t\t\t} else if ('window' === host.toLowerCase()) {\n\t\t\t\twindowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t} else {\n\t\t\t\t(templateListeners[host] ??= []).push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t}\n\t\t});\n\n\t\tconst result: HostNode = {};\n\n\t\tif (hostListeners.length) {\n\t\t\tconst hostOutputs = Components.createOutputs(hostListeners);\n\t\t\tconst selector = option.selector ?? 'div';\n\t\t\tconst hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;\n\t\t\tresult.host = htmlParser.toDomRootNode(hostTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.host);\n\t\t}\n\n\t\tif (windowListeners.length) {\n\t\t\tconst windowOutputs = Components.createOutputs(windowListeners);\n\t\t\tconst windowTemplate = `<window ${windowOutputs}></window>`;\n\t\t\tresult.window = htmlParser.toDomRootNode(windowTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.window);\n\t\t}\n\n\t\tconst templateHosts = Object.keys(templateListeners);\n\t\tif (templateHosts.length) {\n\t\t\tconst template = templateHosts.map(host => {\n\t\t\t\tconst hostOutputs = Components.createOutputs(templateListeners[host]);\n\t\t\t\treturn `<template #${host} ${hostOutputs}></template>`;\n\t\t\t}).join('');\n\t\t\tconst templateNodes = htmlParser.toDomRootNode(template) as DomElementNode | DomFragmentNode;\n\t\t\tbuildExpressionNodes(templateNodes);\n\t\t\tresult.template = templateNodes instanceof DomFragmentNode\n\t\t\t\t? templateNodes.children?.filter(child => child instanceof DomElementNode) as DomElementNode[] ?? []\n\t\t\t\t: [templateNodes];\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tif (metadata.hostListeners?.length || metadata.hostBindings?.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: metadata.hostBindings,\n\t\t\t\thostListeners: metadata.hostListeners,\n\t\t\t});\n\t\t\tmetadata.viewBindings = hostNode.host;\n\t\t}\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (metadata.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (metadata.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineService<T extends Class>(modelClass: MetadataClass<T>, opts: ServiceOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tmetadata.name = modelClass.name;\n\t\tClassRegistryProvider.registerService(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tconst componentRef = Object.assign(metadata, opts) as any as ComponentRef<T>;\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\t\tcomponentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(opts.extend);\n\n\t\tif (typeof componentRef.template === 'string') {\n\t\t\tif (componentRef.styles) {\n\t\t\t\tconst template = `<style>${componentRef.styles}</style>${componentRef.template}`;\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(template);\n\t\t\t} else {\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(componentRef.template);\n\t\t\t}\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.template === 'object') {\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.compiledTemplate === 'object') {\n\t\t\thtmlParser.deserializeNode(componentRef.compiledTemplate);\n\t\t\tdeserializeExpressionNodes(componentRef.compiledTemplate);\n\t\t\tcomponentRef.template = componentRef.compiledTemplate;\n\t\t\tcomponentRef.compiledTemplate = undefined;\n\t\t}\n\n\t\tif (!componentRef.template && /template/g.test(componentRef.encapsulation)) {\n\t\t\tconst template = document.querySelector('#' + componentRef.selector);\n\t\t\tif (template && template instanceof HTMLTemplateElement) {\n\t\t\t\tcomponentRef.template = templateParser.parse(template);\n\t\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t\t} else {\n\t\t\t\t// didn't find this template in 'index.html' document\n\t\t\t}\n\t\t}\n\n\t\tcomponentRef.inputs ||= Components.emptyList();\n\t\tcomponentRef.outputs ||= Components.emptyList();\n\t\tcomponentRef.viewChild ||= Components.emptyList();\n\t\tcomponentRef.ViewChildren ||= Components.emptyList();\n\t\tcomponentRef.hostBindings ||= Components.emptyList();\n\t\tcomponentRef.hostListeners ||= Components.emptyList();\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow/g.test(componentRef.encapsulation);\n\t\tif (componentRef.isShadowDom) {\n\t\t\tcomponentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));\n\t\t}\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\tselector: componentRef.selector,\n\t\t\t\thostBindings: componentRef.hostBindings,\n\t\t\t\thostListeners: componentRef.hostListeners,\n\t\t\t});\n\t\t\tcomponentRef.viewBindings = hostNode.host;\n\t\t\tcomponentRef.windowBindings = hostNode.window;\n\n\t\t\tif (typeof componentRef.template === 'function') {\n\t\t\t\tconst creator = componentRef.template;\n\t\t\t\tcomponentRef.template = (model: T) => {\n\t\t\t\t\tconst template = creator(model);\n\t\t\t\t\tif (hostNode.template) {\n\t\t\t\t\t\tComponents.patchTemplate(template, hostNode.template);\n\t\t\t\t\t}\n\t\t\t\t\treturn template;\n\t\t\t\t};\n\t\t\t} else if (hostNode.template) {\n\t\t\t\tComponents.patchTemplate(componentRef.template, hostNode.template);\n\t\t\t}\n\n\t\t}\n\n\t\tif (!(componentRef.formAssociated === true || typeof componentRef.formAssociated === 'function')) {\n\t\t\tcomponentRef.formAssociated = false;\n\t\t}\n\n\t\tif (componentRef.isShadowDom && componentRef.extend.name) {\n\t\t\tcomponentRef.isShadowDom = canAttachShadow(componentRef.extend.name);\n\t\t}\n\n\t\tcomponentRef.modelClass = modelClass;\n\t\tcomponentRef.viewClass = initCustomElementView(modelClass, componentRef);\n\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(componentRef.viewClass);\n\n\t\tconst options: ElementDefinitionOptions = {};\n\t\tconst parentTagName = componentRef.extend?.name;\n\t\tif (parentTagName) {\n\t\t\tif (parentTagName !== '!' && parentTagName.indexOf('-') === -1) {\n\t\t\t\toptions.extends = parentTagName;\n\t\t\t}\n\t\t}\n\n\n\t\tcustomElements.define(\n\t\t\tcomponentRef.selector as string,\n\t\t\tcomponentRef.viewClass as CustomElementConstructor,\n\t\t\toptions\n\t\t);\n\n\t}\n\n\tstatic defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tconst { selector, ...definition } = opt;\n\t\tcustomElements.define(\n\t\t\tselector,\n\t\t\tviewClass,\n\t\t\tdefinition,\n\t\t);\n\t}\n\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/core/component/component.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,aAAa,EAAO,UAAU,EAAE,cAAc,EACtB,eAAe,EACvC,iBAAiB,EAAE,cAAc,EACjC,eAAe,EAAE,aAAa,EAC9B,wBAAwB,EACxB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAK7D,OAAO,EAEN,WAAW,EACX,MAAM,cAAc,CAAC;AAC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,SAAqC,EAClD,OAAO,CACP,CAAC;IAEH,CAAC;IAED,MAAM,CAAC,UAAU,CAAwB,SAA2B,EAAE,GAAoD;QACzH,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,GAAG,CAAC;QACxC,cAAc,CAAC,MAAM,CACpB,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CAAC;IACH,CAAC","sourcesContent":["import type { MetadataClass, MetadataContext } from '@ibyar/decorators';\nimport type { Class, TypeOf } from '../utils/typeof.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow,\n\tdirectiveRegistry, DomElementNode,\n\tDomFragmentNode, DomParentNode,\n\tisValidCustomElementName\n} from '@ibyar/elements';\n\nimport { HTMLComponent, ValueControl } from './custom-element.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective, StructuralDirective } from '../directive/directive.js';\nimport { initCustomElementView } from '../view/view.js';\nimport { buildExpressionNodes } from '../html/expression.js';\nimport {\n\tComponentOptions, PipeOptions,\n\tInjectableOptions, DirectiveOptions\n} from '../annotation/options.js';\nimport {\n\tChildRef, HostBindingRef, InputPropertyRef,\n\tListenerRef, OutputPropertyRef, PropertyRef\n} from './reflect.js';\nimport { deserializeExpressionNodes } from '../html/deserialize.js';\nimport { provide } from '../di/inject.js';\n\n\nexport interface ServiceRef<T> {\n\tprovideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: TypeOf<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: TypeOf<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\texportAs?: string;\n\tzone?: ZoneType;\n\n\tmodelClass: TypeOf<StructuralDirective> | TypeOf<AttributeDirective>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostListeners: ListenerRef[];\n\thostBindings: HostBindingRef[];\n\tviewBindings?: DomElementNode;\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\tcompiledTemplate?: DomNode;\n\tstyles: string;\n\textend: Tag;\n\textendCustomElement: boolean;\n\n\tviewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: InputPropertyRef[];\n\toutputs: OutputPropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\tviewBindings?: DomElementNode;\n\twindowBindings?: DomElementNode;\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template' | 'shadow-slot';\n\tisShadowDom: boolean;\n\tshadowRootInit: ShadowRootInit;\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\n}\n\ntype ViewBindingOption = {\n\tprototype: Record<PropertyKey, any>;\n\thostBindings?: HostBindingRef[];\n\thostListeners?: ListenerRef[];\n\tselector?: string;\n};\n\ntype HostNode = {\n\thost?: DomElementNode;\n\twindow?: DomElementNode;\n\ttemplate?: DomElementNode[];\n};\n\nconst DEFAULT_SHADOW_ROOT_INIT: ShadowRootInit = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };\n\nexport class Components {\n\n\tprivate static EMPTY_LIST = Object.freeze<any>([]);\n\tprivate static emptyList<T>(): T[] {\n\t\treturn Components.EMPTY_LIST as T[];\n\t}\n\n\tprivate static patchTemplate(child: DomNode, templates: DomElementNode[]): void {\n\t\tif (child instanceof DomElementNode && child.templateRefName?.name) {\n\t\t\tconst ref = templates.find(node => child.templateRefName?.name === node.templateRefName?.name);\n\t\t\tif (ref?.outputs) {\n\t\t\t\t(child.outputs ??= []).push(...ref.outputs);\n\t\t\t}\n\t\t}\n\t\tif (child instanceof DomParentNode) {\n\t\t\tchild.children?.forEach(node => Components.patchTemplate(node, templates));\n\t\t}\n\t}\n\n\tprivate static createOutputs(Listeners?: ListenerRef[]) {\n\t\treturn Listeners?.map(\n\t\t\tlistener => `(${listener.eventName})=\"${listener.modelCallbackName}(${listener.args.join(', ')})\"`\n\t\t).join(' ') ?? ''\n\t}\n\n\tprivate static parseHostNode(option: ViewBindingOption): HostNode {\n\t\tconst inputs = option.hostBindings?.map(binding => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);\n\t\t\tif (typeof descriptor?.value === 'function') {\n\t\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}()\"`\n\t\t\t}\n\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}\"`;\n\t\t}).join(' ') ?? '';\n\n\t\tconst hostListeners: ListenerRef[] = [];\n\t\tconst windowListeners: ListenerRef[] = [];\n\t\tconst templateListeners: Record<string, ListenerRef[]> = {};\n\n\t\toption.hostListeners?.forEach(listener => {\n\t\t\tconst [host, event] = listener.eventName.split(':', 2);\n\t\t\tif (event === undefined) {\n\t\t\t\thostListeners.push(listener);\n\t\t\t} else if ('window' === host.toLowerCase()) {\n\t\t\t\twindowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t} else {\n\t\t\t\t(templateListeners[host] ??= []).push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t}\n\t\t});\n\n\t\tconst result: HostNode = {};\n\n\t\tif (hostListeners.length) {\n\t\t\tconst hostOutputs = Components.createOutputs(hostListeners);\n\t\t\tconst selector = option.selector ?? 'div';\n\t\t\tconst hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;\n\t\t\tresult.host = htmlParser.toDomRootNode(hostTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.host);\n\t\t}\n\n\t\tif (windowListeners.length) {\n\t\t\tconst windowOutputs = Components.createOutputs(windowListeners);\n\t\t\tconst windowTemplate = `<window ${windowOutputs}></window>`;\n\t\t\tresult.window = htmlParser.toDomRootNode(windowTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.window);\n\t\t}\n\n\t\tconst templateHosts = Object.keys(templateListeners);\n\t\tif (templateHosts.length) {\n\t\t\tconst template = templateHosts.map(host => {\n\t\t\t\tconst hostOutputs = Components.createOutputs(templateListeners[host]);\n\t\t\t\treturn `<template #${host} ${hostOutputs}></template>`;\n\t\t\t}).join('');\n\t\t\tconst templateNodes = htmlParser.toDomRootNode(template) as DomElementNode | DomFragmentNode;\n\t\t\tbuildExpressionNodes(templateNodes);\n\t\t\tresult.template = templateNodes instanceof DomFragmentNode\n\t\t\t\t? templateNodes.children?.filter(child => child instanceof DomElementNode) as DomElementNode[] ?? []\n\t\t\t\t: [templateNodes];\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tif (metadata.hostListeners?.length || metadata.hostBindings?.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: metadata.hostBindings,\n\t\t\t\thostListeners: metadata.hostListeners,\n\t\t\t});\n\t\t\tmetadata.viewBindings = hostNode.host;\n\t\t}\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (metadata.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (metadata.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t\tsuccessor: (metadata.successor as string | undefined),\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineInjectable<T extends Class>(modelClass: MetadataClass<T>, opts: InjectableOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tmetadata.name = modelClass.name;\n\t\tClassRegistryProvider.registerInjectable(modelClass);\n\t\tprovide(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tconst componentRef = Object.assign(metadata, opts) as any as ComponentRef<T>;\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\t\tcomponentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(opts.extend);\n\n\t\tif (typeof componentRef.template === 'string') {\n\t\t\tif (componentRef.styles) {\n\t\t\t\tconst template = `<style>${componentRef.styles}</style>${componentRef.template}`;\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(template);\n\t\t\t} else {\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(componentRef.template);\n\t\t\t}\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.template === 'object') {\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.compiledTemplate === 'object') {\n\t\t\thtmlParser.deserializeNode(componentRef.compiledTemplate);\n\t\t\tdeserializeExpressionNodes(componentRef.compiledTemplate);\n\t\t\tcomponentRef.template = componentRef.compiledTemplate;\n\t\t\tcomponentRef.compiledTemplate = undefined;\n\t\t}\n\n\t\tif (!componentRef.template && /template/g.test(componentRef.encapsulation)) {\n\t\t\tconst template = document.querySelector('#' + componentRef.selector);\n\t\t\tif (template && template instanceof HTMLTemplateElement) {\n\t\t\t\tcomponentRef.template = templateParser.parse(template);\n\t\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t\t} else {\n\t\t\t\t// didn't find this template in 'index.html' document\n\t\t\t}\n\t\t}\n\n\t\tcomponentRef.inputs ||= Components.emptyList();\n\t\tcomponentRef.outputs ||= Components.emptyList();\n\t\tcomponentRef.viewChild ||= Components.emptyList();\n\t\tcomponentRef.ViewChildren ||= Components.emptyList();\n\t\tcomponentRef.hostBindings ||= Components.emptyList();\n\t\tcomponentRef.hostListeners ||= Components.emptyList();\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow/g.test(componentRef.encapsulation);\n\t\tif (componentRef.isShadowDom) {\n\t\t\tcomponentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));\n\t\t}\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\tselector: componentRef.selector,\n\t\t\t\thostBindings: componentRef.hostBindings,\n\t\t\t\thostListeners: componentRef.hostListeners,\n\t\t\t});\n\t\t\tcomponentRef.viewBindings = hostNode.host;\n\t\t\tcomponentRef.windowBindings = hostNode.window;\n\n\t\t\tif (typeof componentRef.template === 'function') {\n\t\t\t\tconst creator = componentRef.template;\n\t\t\t\tcomponentRef.template = (model: T) => {\n\t\t\t\t\tconst template = creator(model);\n\t\t\t\t\tif (hostNode.template) {\n\t\t\t\t\t\tComponents.patchTemplate(template, hostNode.template);\n\t\t\t\t\t}\n\t\t\t\t\treturn template;\n\t\t\t\t};\n\t\t\t} else if (hostNode.template) {\n\t\t\t\tComponents.patchTemplate(componentRef.template, hostNode.template);\n\t\t\t}\n\n\t\t}\n\n\t\tif (!(componentRef.formAssociated === true || typeof componentRef.formAssociated === 'function')) {\n\t\t\tcomponentRef.formAssociated = false;\n\t\t}\n\n\t\tif (componentRef.isShadowDom && componentRef.extend.name) {\n\t\t\tcomponentRef.isShadowDom = canAttachShadow(componentRef.extend.name);\n\t\t}\n\n\t\tcomponentRef.modelClass = modelClass;\n\t\tcomponentRef.viewClass = initCustomElementView(modelClass, componentRef);\n\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(componentRef.viewClass);\n\n\t\tconst options: ElementDefinitionOptions = {};\n\t\tconst parentTagName = componentRef.extend?.name;\n\t\tif (parentTagName) {\n\t\t\tif (parentTagName !== '!' && parentTagName.indexOf('-') === -1) {\n\t\t\t\toptions.extends = parentTagName;\n\t\t\t}\n\t\t}\n\n\n\t\tcustomElements.define(\n\t\t\tcomponentRef.selector as string,\n\t\t\tcomponentRef.viewClass as CustomElementConstructor,\n\t\t\toptions\n\t\t);\n\n\t}\n\n\tstatic defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tconst { selector, ...definition } = opt;\n\t\tcustomElements.define(\n\t\t\tselector,\n\t\t\tviewClass,\n\t\t\tdefinition,\n\t\t);\n\t}\n\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../../src/core/component/reflect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE9E,qBAAa,WAAW;IACJ,aAAa,EAAE,MAAM;IAAE,SAAS,CAAC,SAAS,CAAC;gBAA3C,aAAa,EAAE,MAAM,EAAY,SAAS,CAAC,oBAAQ;IACtE,IAAI,aAAa,IAAI,MAAM,CAE1B;CACD;AAED,qBAAa,gBAAiB,SAAQ,WAAW;CAEhD;AAED,qBAAa,iBAAkB,SAAQ,WAAW;IACY,OAAO,CAAC;gBAAzD,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAS,OAAO,CAAC,6BAAiB;CAGtF;AAED,qBAAa,QAAQ;IAEZ,SAAS,EAAE,MAAM;IACjB,QAAQ,EAA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AAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAIxG,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;CAG9F"}
package/di/inject.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { TypeOf } from '../utils/typeof.js';
2
+ import { InjectionToken } from './provider.js';
3
+ export declare function provide<T>(type: TypeOf<T>): void;
4
+ export declare function provide<T>(token: InjectionToken<T>, value: T): void;
5
+ export declare function inject<T>(type: TypeOf<T>): T;
6
+ export declare function inject<T>(token: InjectionToken<T>): T | undefined;
7
+ //# sourceMappingURL=inject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../../../src/core/di/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAqB,cAAc,EAAY,MAAM,eAAe,CAAC;AAM5E,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAClD,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;AAKrE,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC9C,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC"}
package/di/inject.js ADDED
@@ -0,0 +1,9 @@
1
+ import { InjectionProvider } from './provider.js';
2
+ const ROOT_PROVIDER = new InjectionProvider();
3
+ export function provide(provider, value) {
4
+ ROOT_PROVIDER.provide(provider, value);
5
+ }
6
+ export function inject(provider) {
7
+ return ROOT_PROVIDER.inject(provider);
8
+ }
9
+ //# sourceMappingURL=inject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/core/di/inject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAA4B,MAAM,eAAe,CAAC;AAG5E,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAK9C,MAAM,UAAU,OAAO,CAAI,QAAqB,EAAE,KAAS;IAC1D,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC;AAID,MAAM,UAAU,MAAM,CAAI,QAAqB;IAC9C,OAAO,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { TypeOf } from '../utils/typeof.js';\nimport { InjectionProvider, InjectionToken, Provider } from './provider.js';\n\n\nconst ROOT_PROVIDER = new InjectionProvider();\n\n\nexport function provide<T>(type: TypeOf<T>): void;\nexport function provide<T>(token: InjectionToken<T>, value: T): void;\nexport function provide<T>(provider: Provider<T>, value?: T) {\n\tROOT_PROVIDER.provide(provider, value);\n}\n\nexport function inject<T>(type: TypeOf<T>): T;\nexport function inject<T>(token: InjectionToken<T>): T | undefined;\nexport function inject<T>(provider: Provider<T>): T | undefined {\n\treturn ROOT_PROVIDER.inject(provider);\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { TypeOf } from '../utils/typeof.js';
2
+ export declare class InjectionToken<T> {
3
+ token: string;
4
+ constructor(token: string);
5
+ }
6
+ export type Provider<T> = TypeOf<T> | InjectionToken<T>;
7
+ export declare class InjectionProvider {
8
+ private parent?;
9
+ private readonly types;
10
+ private readonly tokens;
11
+ constructor(parent?: InjectionProvider | undefined);
12
+ hasToken<T>(token: InjectionToken<T>): InjectionProvider | false;
13
+ hasType<T>(type: TypeOf<T>): InjectionProvider | false;
14
+ getToken<T>(token: InjectionToken<T>): T | undefined;
15
+ getInstance<T>(type: TypeOf<T>): T;
16
+ setType<T>(type: TypeOf<T>, value?: T): void;
17
+ setToken<T>(token: InjectionToken<T>, value: T): void;
18
+ provide<T>(typeOrToken: Provider<T>, value?: T): void;
19
+ inject<T>(typeOrToken: Provider<T>): T | undefined;
20
+ }
21
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/core/di/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,qBAAa,cAAc,CAAC,CAAC;IACT,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAChC;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;AAIxD,qBAAa,iBAAiB;IAKjB,OAAO,CAAC,MAAM,CAAC;IAH3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmC;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;gBAE9C,MAAM,CAAC,EAAE,iBAAiB,YAAA;IAE9C,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,iBAAiB,GAAG,KAAK;IAIhE,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,iBAAiB,GAAG,KAAK;IAItD,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;IAIpD,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;IASlC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI;IAI5C,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIrD,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IAU9C,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;CASlD"}
package/di/provider.js ADDED
@@ -0,0 +1,57 @@
1
+ export class InjectionToken {
2
+ token;
3
+ constructor(token) {
4
+ this.token = token;
5
+ }
6
+ }
7
+ const EMPTY_VALUE = Symbol('EMPTY_VALUE');
8
+ export class InjectionProvider {
9
+ parent;
10
+ types = new WeakMap();
11
+ tokens = new WeakMap();
12
+ constructor(parent) {
13
+ this.parent = parent;
14
+ }
15
+ hasToken(token) {
16
+ return this.tokens.has(token) ? this : false;
17
+ }
18
+ hasType(type) {
19
+ return this.types.has(type) ? this : false;
20
+ }
21
+ getToken(token) {
22
+ return this.tokens.get(token);
23
+ }
24
+ getInstance(type) {
25
+ let instance = this.types.get(type);
26
+ if (instance === EMPTY_VALUE) {
27
+ instance = new type();
28
+ this.types.set(type, instance);
29
+ }
30
+ return instance;
31
+ }
32
+ setType(type, value) {
33
+ this.types.set(type, value ?? EMPTY_VALUE);
34
+ }
35
+ setToken(token, value) {
36
+ this.tokens.set(token, value);
37
+ }
38
+ provide(typeOrToken, value) {
39
+ if (typeOrToken instanceof InjectionToken) {
40
+ const provider = this.parent?.hasToken(typeOrToken) || this;
41
+ provider.setToken(typeOrToken, value);
42
+ }
43
+ else {
44
+ const provider = this.parent?.hasType(typeOrToken) || this;
45
+ provider.setType(typeOrToken, value ?? EMPTY_VALUE);
46
+ }
47
+ }
48
+ inject(typeOrToken) {
49
+ if (typeOrToken instanceof InjectionToken) {
50
+ const provider = this.parent?.hasToken(typeOrToken) || this;
51
+ return provider.getToken(typeOrToken);
52
+ }
53
+ const provider = this.parent?.hasType(typeOrToken) || this;
54
+ return provider.getInstance(typeO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pC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,IAAI,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ,CAAI,KAAwB,EAAE,KAAQ;QAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,CAAI,WAAwB,EAAE,KAAS;QAC7C,IAAI,WAAW,YAAY,cAAc,EAAE,CAAC;YAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;YAC5D,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACP,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;YAC3D,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,IAAI,WAA2B,CAAC,CAAC;QACrE,CAAC;IACF,CAAC;IAED,MAAM,CAAI,WAAwB;QACjC,IAAI,WAAW,YAAY,cAAc,EAAE,CAAC;YAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;YAC5D,OAAO,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;QAC3D,OAAO,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;CAED","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\n\n\nexport class InjectionToken<T> {\n\tconstructor(public token: string) { }\n}\n\nexport type Provider<T> = TypeOf<T> | InjectionToken<T>;\n\nconst EMPTY_VALUE = Symbol('EMPTY_VALUE');\n\nexport class InjectionProvider {\n\n\tprivate readonly types = new WeakMap<TypeOf<any>, any>();\n\tprivate readonly tokens = new WeakMap<InjectionToken<any>, any>();\n\n\tconstructor(private parent?: InjectionProvider) { }\n\n\thasToken<T>(token: InjectionToken<T>): InjectionProvider | false {\n\t\treturn this.tokens.has(token) ? this : false;\n\t}\n\n\thasType<T>(type: TypeOf<T>): InjectionProvider | false {\n\t\treturn this.types.has(type) ? this : false;\n\t}\n\n\tgetToken<T>(token: InjectionToken<T>): T | undefined {\n\t\treturn this.tokens.get(token);\n\t}\n\n\tgetInstance<T>(type: TypeOf<T>): T {\n\t\tlet instance = this.types.get(type);\n\t\tif (instance === EMPTY_VALUE) {\n\t\t\tinstance = new type();\n\t\t\tthis.types.set(type, instance);\n\t\t}\n\t\treturn instance;\n\t}\n\n\tsetType<T>(type: TypeOf<T>, value?: T): void {\n\t\tthis.types.set(type, value ?? EMPTY_VALUE);\n\t}\n\n\tsetToken<T>(token: InjectionToken<T>, value: T): void {\n\t\tthis.tokens.set(token, value);\n\t}\n\n\tprovide<T>(typeOrToken: Provider<T>, value?: T) {\n\t\tif (typeOrToken instanceof InjectionToken) {\n\t\t\tconst provider = this.parent?.hasToken(typeOrToken) || this;\n\t\t\tprovider.setToken(typeOrToken, value);\n\t\t} else {\n\t\t\tconst provider = this.parent?.hasType(typeOrToken) || this;\n\t\t\tprovider.setType(typeOrToken, value ?? EMPTY_VALUE as unknown as T);\n\t\t}\n\t}\n\n\tinject<T>(typeOrToken: Provider<T>): T | undefined {\n\t\tif (typeOrToken instanceof InjectionToken) {\n\t\t\tconst provider = this.parent?.hasToken(typeOrToken) || this;\n\t\t\treturn provider.getToken(typeOrToken);\n\t\t}\n\t\tconst provider = this.parent?.hasType(typeOrToken) || this;\n\t\treturn provider.getInstance(typeOrToken);\n\t}\n\n}\n"]}
package/di/token.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export declare class InjectionToken<T> {
2
+ private token;
3
+ constructor(token: string);
4
+ toString(): string;
5
+ }
6
+ export declare const LOCALE_ID: InjectionToken<string>;
7
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/core/di/token.ts"],"names":[],"mappings":"AACA,qBAAa,cAAc,CAAC,CAAC;IAChB,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IACjC,QAAQ,IAAI,MAAM;CAGlB;AAED,eAAO,MAAM,SAAS,wBAA0C,CAAC"}
package/di/token.js ADDED
@@ -0,0 +1,11 @@
1
+ export class InjectionToken {
2
+ token;
3
+ constructor(token) {
4
+ this.token = token;
5
+ }
6
+ toString() {
7
+ return this.token;
8
+ }
9
+ }
10
+ export const LOCALE_ID = new InjectionToken('LOCALE_ID');
11
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../../../src/core/di/token.ts"],"names":[],"mappings":"AACA,MAAM,OAAO,cAAc;IACN;IAApB,YAAoB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAI,CAAC;IACtC,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,cAAc,CAAS,WAAW,CAAC,CAAC","sourcesContent":["\nexport class InjectionToken<T> {\n\tconstructor(private token: string) { }\n\ttoString(): string {\n\t\treturn this.token;\n\t}\n}\n\nexport const LOCALE_ID = new InjectionToken<string>('LOCALE_ID');\n"]}
package/di/tokens.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { InjectionToken } from './provider.js';
2
+ export declare const LOCALE_ID: InjectionToken<string>;
3
+ export interface DatePipeConfig {
4
+ dateFormat?: string;
5
+ timezone?: string;
6
+ }
7
+ export declare const DATE_PIPE_DEFAULT_OPTIONS: InjectionToken<DatePipeConfig>;
8
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/core/di/tokens.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,SAAS,wBAA0C,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,eAAO,MAAM,yBAAyB,gCAAkE,CAAC"}
package/di/tokens.js ADDED
@@ -0,0 +1,8 @@
1
+ import { provide } from './inject.js';
2
+ import { InjectionToken } from './provider.js';
3
+ export const LOCALE_ID = new InjectionToken('LOCALE_ID');
4
+ export const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken('DATE_PIPE_DEFAULT_OPTIONS');
5
+ const PLATFORM_OPTIONS = Intl.DateTimeFormat().resolvedOptions();
6
+ provide(LOCALE_ID, PLATFORM_OPTIONS.locale);
7
+ provide(DATE_PIPE_DEFAULT_OPTIONS, { dateFormat: PLATFORM_OPTIONS.dateStyle, timezone: PLATFORM_OPTIONS.timeZone });
8
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/core/di/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,cAAc,CAAS,WAAW,CAAC,CAAC;AAMjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,cAAc,CAAiB,2BAA2B,CAAC,CAAC;AAEzG,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC;AAEjE,OAAO,CAAC,SAAS,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE5C,OAAO,CAAC,yBAAyB,EAAE,EAAE,UAAU,EAAE,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC","sourcesContent":["import { provide } from './inject.js';\nimport { InjectionToken } from './provider.js';\n\nexport const LOCALE_ID = new InjectionToken<string>('LOCALE_ID');\n\nexport interface DatePipeConfig {\n\tdateFormat?: string;\n\ttimezone?: string;\n}\nexport const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken<DatePipeConfig>('DATE_PIPE_DEFAULT_OPTIONS');\n\nconst PLATFORM_OPTIONS = Intl.DateTimeFormat().resolvedOptions();\n\nprovide(LOCALE_ID, PLATFORM_OPTIONS.locale);\n\nprovide(DATE_PIPE_DEFAULT_OPTIONS, { dateFormat: PLATFORM_OPTIONS.dateStyle, timezone: PLATFORM_OPTIONS.timeZone });\n"]}
package/di/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/di/types.ts"],"names":[],"mappings":""}