@ibyar/core 0.8.5 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/annotation/context.d.ts +41 -0
  2. package/annotation/context.d.ts.map +1 -0
  3. package/annotation/context.js +79 -0
  4. package/annotation/context.js.map +1 -0
  5. package/annotation/decorators.d.ts +20 -285
  6. package/annotation/decorators.d.ts.map +1 -0
  7. package/annotation/decorators.js +92 -84
  8. package/annotation/decorators.js.map +1 -1
  9. package/annotation/options.d.ts +275 -0
  10. package/annotation/options.d.ts.map +1 -0
  11. package/annotation/options.js +2 -0
  12. package/annotation/options.js.map +1 -0
  13. package/binding/binding.expressions.d.ts +1 -0
  14. package/binding/binding.expressions.d.ts.map +1 -0
  15. package/binding/binding.expressions.js +138 -125
  16. package/binding/binding.expressions.js.map +1 -1
  17. package/component/component.d.ts +16 -12
  18. package/component/component.d.ts.map +1 -0
  19. package/component/component.js +111 -52
  20. package/component/component.js.map +1 -1
  21. package/component/custom-element.d.ts +1 -0
  22. package/component/custom-element.d.ts.map +1 -0
  23. package/component/events.d.ts +1 -0
  24. package/component/events.d.ts.map +1 -0
  25. package/component/events.js +4 -3
  26. package/component/events.js.map +1 -1
  27. package/component/lifecycle.d.ts +1 -0
  28. package/component/lifecycle.d.ts.map +1 -0
  29. package/component/reflect.d.ts +12 -15
  30. package/component/reflect.d.ts.map +1 -0
  31. package/component/reflect.js +27 -47
  32. package/component/reflect.js.map +1 -1
  33. package/context/stack.d.ts +1 -0
  34. package/context/stack.d.ts.map +1 -0
  35. package/context/subscription.d.ts +1 -0
  36. package/context/subscription.d.ts.map +1 -0
  37. package/directive/directive.d.ts +1 -0
  38. package/directive/directive.d.ts.map +1 -0
  39. package/directive/directive.js +8 -0
  40. package/directive/directive.js.map +1 -1
  41. package/directive/parser.d.ts +1 -0
  42. package/directive/parser.d.ts.map +1 -0
  43. package/directive/parser.js +9 -7
  44. package/directive/parser.js.map +1 -1
  45. package/directive/providers.d.ts +1 -0
  46. package/directive/providers.d.ts.map +1 -0
  47. package/directive/providers.js +2 -1
  48. package/directive/providers.js.map +1 -1
  49. package/html/deserialize.d.ts +1 -0
  50. package/html/deserialize.d.ts.map +1 -0
  51. package/html/expression.d.ts +1 -0
  52. package/html/expression.d.ts.map +1 -0
  53. package/html/expression.js +2 -2
  54. package/html/expression.js.map +1 -1
  55. package/html/types.d.ts +1 -0
  56. package/html/types.d.ts.map +1 -0
  57. package/index.d.ts +2 -2
  58. package/index.d.ts.map +1 -0
  59. package/index.js +1 -2
  60. package/index.js.map +1 -1
  61. package/linker/change-detector-ref.d.ts +1 -0
  62. package/linker/change-detector-ref.d.ts.map +1 -0
  63. package/linker/template-ref.d.ts +1 -0
  64. package/linker/template-ref.d.ts.map +1 -0
  65. package/linker/template-ref.js +5 -0
  66. package/linker/template-ref.js.map +1 -1
  67. package/linker/view-container-ref.d.ts +4 -2
  68. package/linker/view-container-ref.d.ts.map +1 -0
  69. package/linker/view-container-ref.js +8 -7
  70. package/linker/view-container-ref.js.map +1 -1
  71. package/linker/view-ref.d.ts +1 -0
  72. package/linker/view-ref.d.ts.map +1 -0
  73. package/linker/view-ref.js +5 -2
  74. package/linker/view-ref.js.map +1 -1
  75. package/node.d.ts +1 -0
  76. package/node.d.ts.map +1 -0
  77. package/package.json +7 -8
  78. package/pipe/pipe.d.ts +1 -0
  79. package/pipe/pipe.d.ts.map +1 -0
  80. package/pipe/pipe.js +2 -1
  81. package/pipe/pipe.js.map +1 -1
  82. package/providers/provider.d.ts +15 -13
  83. package/providers/provider.d.ts.map +1 -0
  84. package/providers/provider.js +13 -16
  85. package/providers/provider.js.map +1 -1
  86. package/utils/elements-util.d.ts +1 -0
  87. package/utils/elements-util.d.ts.map +1 -0
  88. package/utils/path.d.ts +1 -0
  89. package/utils/path.d.ts.map +1 -0
  90. package/utils/typeof.d.ts +3 -0
  91. package/utils/typeof.d.ts.map +1 -0
  92. package/utils/typeof.js.map +1 -1
  93. package/utils/utils.d.ts +1 -0
  94. package/utils/utils.d.ts.map +1 -0
  95. package/view/base-view.d.ts +1 -0
  96. package/view/base-view.d.ts.map +1 -0
  97. package/view/base-view.js +34 -16
  98. package/view/base-view.js.map +1 -1
  99. package/view/form-view.d.ts +1 -0
  100. package/view/form-view.d.ts.map +1 -0
  101. package/view/form-view.js +70 -67
  102. package/view/form-view.js.map +1 -1
  103. package/view/mutation.d.ts +1 -0
  104. package/view/mutation.d.ts.map +1 -0
  105. package/view/mutation.js +37 -36
  106. package/view/mutation.js.map +1 -1
  107. package/view/render.d.ts +2 -2
  108. package/view/render.d.ts.map +1 -0
  109. package/view/render.js +21 -21
  110. package/view/render.js.map +1 -1
  111. package/view/utils.d.ts +4 -3
  112. package/view/utils.d.ts.map +1 -0
  113. package/view/utils.js.map +1 -1
  114. package/view/view.d.ts +5 -4
  115. package/view/view.d.ts.map +1 -0
  116. package/view/view.js +19 -3
  117. package/view/view.js.map +1 -1
  118. package/zone/bootstrap.d.ts +1 -0
  119. package/zone/bootstrap.d.ts.map +1 -0
  120. package/zone/proxy.d.ts +1 -0
  121. package/zone/proxy.d.ts.map +1 -0
  122. package/zone/proxy.js +1 -0
  123. package/zone/proxy.js.map +1 -1
  124. package/zone/task.d.ts +1 -0
  125. package/zone/task.d.ts.map +1 -0
  126. package/zone/task.js +11 -3
  127. package/zone/task.js.map +1 -1
  128. package/zone/zone.d.ts +1 -0
  129. package/zone/zone.d.ts.map +1 -0
  130. package/zone/zone.js +8 -6
  131. package/zone/zone.js.map +1 -1
  132. package/providers/injector.d.ts +0 -10
  133. package/providers/injector.js +0 -27
  134. package/providers/injector.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ import type { Class } from '../utils/typeof.js';
2
+ export interface MetadataContext extends Record<PropertyKey, any> {
3
+ }
4
+ declare global {
5
+ interface SymbolConstructor {
6
+ /**
7
+ * metadata symbol
8
+ */
9
+ readonly metadata: unique symbol;
10
+ }
11
+ interface ClassDecoratorContext<Class extends abstract new (...args: any) => any = abstract new (...args: any) => any> {
12
+ metadata: MetadataContext;
13
+ }
14
+ interface ClassMethodDecoratorContext {
15
+ metadata: MetadataContext;
16
+ }
17
+ interface ClassGetterDecoratorContext {
18
+ metadata: MetadataContext;
19
+ }
20
+ interface ClassFieldDecoratorContext {
21
+ metadata: MetadataContext;
22
+ }
23
+ interface ClassSetterDecoratorContext {
24
+ metadata: MetadataContext;
25
+ }
26
+ interface ClassAccessorDecoratorContext {
27
+ metadata: MetadataContext;
28
+ }
29
+ }
30
+ export declare class MetadataContext {
31
+ static create(): MetadataContext;
32
+ static inherits(context: MetadataContext): MetadataContext;
33
+ static assign(previous: MetadataContext, next: MetadataContext): MetadataContext;
34
+ static merge(previous: MetadataContext, next: MetadataContext): MetadataContext;
35
+ }
36
+ export declare function getCurrentMetadata(): MetadataContext;
37
+ export declare function updateCurrentMetadata(context?: MetadataContext): void;
38
+ export declare function makeClassDecoratorContext<V, T extends Class = Class>(decorator?: (opt: V, constructor: T, context: ClassDecoratorContext<T>) => (T | void)): (props: V) => (constructor: T, context: ClassDecoratorContext<T>) => T;
39
+ export declare const Metadata: (props: void) => (constructor: Class, context: ClassDecoratorContext<Class>) => Class;
40
+ export declare function makeClassMemberDecoratorContext<This, Value, Context extends ClassMemberDecoratorContext = ClassMemberDecoratorContext>(decorator?: (value: Value | undefined, context: Context) => void): (value: Value, context: Context) => void;
41
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAiB,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,eAAgB,SAAQ,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC;CAEhE;AAED,OAAO,CAAC,MAAM,CAAC;IAEd,UAAU,iBAAiB;QAC1B;;WAEG;QACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,MAAM,CAA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+BAA+B,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,SAAS,2BAA2B,GAAG,2BAA2B,EAAE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,WACxL,KAAK,WAAW,OAAO,UAItC"}
@@ -0,0 +1,79 @@
1
+ if (!Symbol.metadata) {
2
+ Reflect.set(Symbol, 'metadata', Symbol('metadata'));
3
+ }
4
+ export class MetadataContext {
5
+ static create() {
6
+ return new MetadataContext();
7
+ }
8
+ static inherits(context) {
9
+ return Object.assign(MetadataContext.create(), context);
10
+ }
11
+ static assign(previous, next) {
12
+ return Object.assign(previous, next);
13
+ }
14
+ static merge(previous, next) {
15
+ for (const key in next) {
16
+ const previousValue = previous[key];
17
+ const nextValue = next[key];
18
+ if (typeof previousValue === 'object' && typeof nextValue === 'object') {
19
+ if (Array.isArray(previousValue) && Array.isArray(nextValue)) {
20
+ previous[key] = previousValue.concat(nextValue)
21
+ .filter((value, index, array) => index === array.indexOf(value));
22
+ }
23
+ else {
24
+ previous[key] = Object.assign(previousValue, nextValue);
25
+ }
26
+ }
27
+ else {
28
+ previous[key] = nextValue;
29
+ }
30
+ }
31
+ return previous;
32
+ }
33
+ }
34
+ let currentContext = MetadataContext.create();
35
+ export function getCurrentMetadata() {
36
+ return currentContext;
37
+ }
38
+ export function updateCurrentMetadata(context) {
39
+ currentContext = context ?? MetadataContext.create();
40
+ }
41
+ function updateConstructorMetadata(constructor) {
42
+ const pConstr = constructor.prototype?.constructor?.[Symbol.metadata];
43
+ if (pConstr) {
44
+ if (!constructor.hasOwnProperty(Symbol.metadata)) {
45
+ constructor[Symbol.metadata] = MetadataContext.inherits(pConstr);
46
+ }
47
+ MetadataContext.merge(constructor[Symbol.metadata], getCurrentMetadata());
48
+ }
49
+ else {
50
+ if (constructor[Symbol.metadata]) {
51
+ MetadataContext.merge(constructor[Symbol.metadata], getCurrentMetadata());
52
+ }
53
+ else {
54
+ constructor[Symbol.metadata] = getCurrentMetadata();
55
+ }
56
+ }
57
+ return constructor[Symbol.metadata];
58
+ }
59
+ export function makeClassDecoratorContext(decorator) {
60
+ return (props) => {
61
+ updateCurrentMetadata();
62
+ return (constructor, context) => {
63
+ context.metadata = updateConstructorMetadata(constructor);
64
+ context.addInitializer(() => {
65
+ updateCurrentMetadata();
66
+ console.log(context.metadata, props);
67
+ });
68
+ return decorator?.(props, constructor, context) ?? constructor;
69
+ };
70
+ };
71
+ }
72
+ export const Metadata = makeClassDecoratorContext();
73
+ export function makeClassMemberDecoratorContext(decorator) {
74
+ return (value, context) => {
75
+ context.metadata = getCurrentMetadata();
76
+ decorator?.(value, context);
77
+ };
78
+ }
79
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/core/annotation/context.ts"],"names":[],"mappings":"AAwCA,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;IACrB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;CACpD;AAED,MAAM,OAAO,eAAe;IAE3B,MAAM,CAAC,MAAM;QACZ,OAAO,IAAI,eAAe,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAwB;QACvC,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,QAAyB,EAAE,IAAqB;QAC7D,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,QAAyB,EAAE,IAAqB;QAC5D,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACvB,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,SAAS,GAAG,IA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\nexport interface MetadataContext extends Record<PropertyKey, any> {\n\n}\n\ndeclare global {\n\n\tinterface SymbolConstructor {\n\t\t/**\n\t\t * metadata symbol\n\t\t */\n\t\treadonly metadata: unique symbol;\n\t}\n\n\tinterface ClassDecoratorContext<Class extends abstract new (...args: any) => any = abstract new (...args: any) => any,> {\n\t\tmetadata: MetadataContext;\n\t}\n\n\tinterface ClassMethodDecoratorContext {\n\t\tmetadata: MetadataContext;\n\t}\n\n\tinterface ClassGetterDecoratorContext {\n\t\tmetadata: MetadataContext;\n\t}\n\n\tinterface ClassFieldDecoratorContext {\n\t\tmetadata: MetadataContext;\n\t}\n\n\tinterface ClassSetterDecoratorContext {\n\t\tmetadata: MetadataContext;\n\t}\n\n\tinterface ClassAccessorDecoratorContext {\n\t\tmetadata: MetadataContext;\n\t}\n}\n\nif (!Symbol.metadata) {\n\tReflect.set(Symbol, 'metadata', Symbol('metadata'));\n}\n\nexport class MetadataContext {\n\n\tstatic create(): MetadataContext {\n\t\treturn new MetadataContext();\n\t}\n\n\tstatic inherits(context: MetadataContext): MetadataContext {\n\t\treturn Object.assign(MetadataContext.create(), context);\n\t}\n\n\tstatic assign(previous: MetadataContext, next: MetadataContext): MetadataContext {\n\t\treturn Object.assign(previous, next);\n\t}\n\n\tstatic merge(previous: MetadataContext, next: MetadataContext): MetadataContext {\n\t\tfor (const key in next) {\n\t\t\tconst previousValue = previous[key];\n\t\t\tconst nextValue = next[key];\n\t\t\tif (typeof previousValue === 'object' && typeof nextValue === 'object') {\n\t\t\t\tif (Array.isArray(previousValue) && Array.isArray(nextValue)) {\n\t\t\t\t\tprevious[key] = previousValue.concat(nextValue)\n\t\t\t\t\t\t.filter((value, index, array) => index === array.indexOf(value));\n\t\t\t\t} else {\n\t\t\t\t\tprevious[key] = Object.assign(previousValue, nextValue);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprevious[key] = nextValue;\n\t\t\t}\n\t\t}\n\t\treturn previous;\n\t}\n\n}\n\nlet currentContext: MetadataContext = MetadataContext.create();\n\nexport function getCurrentMetadata(): MetadataContext {\n\treturn currentContext;\n}\n\nexport function updateCurrentMetadata(context?: MetadataContext): void {\n\tcurrentContext = context ?? MetadataContext.create();\n}\n\nfunction updateConstructorMetadata(constructor: MetadataClass): MetadataContext {\n\tconst pConstr = constructor.prototype?.constructor?.[Symbol.metadata];\n\tif (pConstr) {\n\t\tif (!constructor.hasOwnProperty(Symbol.metadata)) {\n\t\t\tconstructor[Symbol.metadata] = MetadataContext.inherits(pConstr);\n\t\t}\n\t\tMetadataContext.merge(constructor[Symbol.metadata], getCurrentMetadata());\n\t} else {\n\t\tif (constructor[Symbol.metadata]) {\n\t\t\tMetadataContext.merge(constructor[Symbol.metadata], getCurrentMetadata());\n\t\t} else {\n\t\t\tconstructor[Symbol.metadata] = getCurrentMetadata();\n\t\t}\n\t}\n\treturn constructor[Symbol.metadata];\n}\n\nexport function makeClassDecoratorContext<V, T extends Class = Class>(\n\tdecorator?: (opt: V, constructor: T, context: ClassDecoratorContext<T>) => (T | void)) {\n\treturn (props: V) => {\n\t\tupdateCurrentMetadata();\n\t\treturn (constructor: T, context: ClassDecoratorContext<T>) => {\n\t\t\tcontext.metadata = updateConstructorMetadata(constructor as any as MetadataClass);\n\t\t\tcontext.addInitializer(() => {\n\t\t\t\tupdateCurrentMetadata();\n\t\t\t\tconsole.log(context.metadata, props);\n\t\t\t});\n\t\t\treturn decorator?.(props, constructor, context) ?? constructor;\n\t\t};\n\t};\n}\n\nexport const Metadata = makeClassDecoratorContext<void>();\n\nexport function makeClassMemberDecoratorContext<This, Value, Context extends ClassMemberDecoratorContext = ClassMemberDecoratorContext>(decorator?: (value: Value | undefined, context: Context) => void) {\n\treturn (value: Value, context: Context) => {\n\t\tcontext.metadata = getCurrentMetadata();\n\t\tdecorator?.(value, context);\n\t};\n}\n"]}
@@ -1,286 +1,21 @@
1
- import type { TypeOf } from '../utils/typeof.js';
2
- import { DomNode } from '@ibyar/elements';
3
- import { TemplateUrl } from '../utils/path.js';
4
- import { ZoneType } from '../zone/bootstrap.js';
5
- import { ValueControl } from '../component/custom-element.js';
6
- export interface DirectiveOptions {
7
- /**
8
- * the name of the directive which is used in the template
9
- *
10
- * a structural directive name should start with `*`,
11
- * and an attributes directive should not.
12
- */
1
+ import type { Class } from '../utils/typeof.js';
2
+ import { ChildOptions, ComponentOptions, DirectiveOptions, OutputEventInit, OutputOptions, PipeOptions } from './options.js';
3
+ type PropertyValue<T> = T | ((value: T) => void) | undefined;
4
+ export declare function Input<This, Value>(name?: string): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
5
+ export declare function FormValue<This, Value>(): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
6
+ export declare function Output<This, Value>(options?: OutputOptions): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;
7
+ export declare function Output<This, Value>(name?: string, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;
8
+ export declare function View<This, Value>(): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
9
+ export declare function ViewChild<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
10
+ export declare function ViewChildren<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
11
+ export declare function HostListener<This, Value extends (this: This, ...args: any) => any>(eventName: string, args?: string | string[]): (value: Value, context: ClassMethodDecoratorContext<unknown, (this: unknown, ...args: any) => any>) => void;
12
+ type ValueGetter<T> = T | (() => T) | undefined;
13
+ export declare function HostBinding<This, Value>(hostPropertyName: string): (value: ValueGetter<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassMethodDecoratorContext<This, any> | ClassGetterDecoratorContext<This, Value>) => void;
14
+ export declare const Pipe: (param: PipeOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
15
+ export declare const Directive: (param: DirectiveOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
16
+ export declare const Component: (param: ComponentOptions<Class> | ComponentOptions<Class>[]) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
17
+ export declare const customElement: (param: {
13
18
  selector: string;
14
- /**
15
- * - use `manual` for no zone.js patch effect applied,
16
- * and used for manual change detection for heavily process components.
17
- *
18
- * - use `proxy` zone for automatic detect changes without use of `zone.js`
19
- *
20
- * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,
21
- * `setInterval` and `fetch` and `XMLHttpRequest`, etc...
22
- * make sure that `zone.js` is imported in the polyfills module.
23
- *
24
- * if no value specified, the value will be initialized by the custom element `web component` zone,
25
- * - if the web component zone is `manual`, the directive zone also will be `manual`, expect weird behavior.
26
- * - if the web component zone is `proxy`, the directive zone also will be `proxy`.
27
- * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.
28
- */
29
- zone?: ZoneType;
30
- }
31
- export interface ServiceOptions {
32
- provideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';
33
- }
34
- export interface PipeOptions {
35
- name: string;
36
- asynchronous?: boolean;
37
- }
38
- export interface ComponentOptions<T = Function> {
39
- /**
40
- * a tag name for the component,
41
- * if the tag name is valid custom element name, the view class will be a custom element,
42
- * otherwise an HTMLUnknownElement will be created
43
- */
44
- selector: string;
45
- /**
46
- * add html file url path to fetch,
47
- * templateUrl had propriety than template, and will override it.
48
- *
49
- * Can provide file name as "person-view.html" will resolved
50
- * as 'http://site-address.org/persin-view.html',
51
- *
52
- * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }
53
- * let (import.meta = '/person/person.js') will resolved
54
- * as 'http://site-address.org/person/person-edit.html',
55
- *
56
- * OR as an object { moduleMeta: import.meta }
57
- * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.
58
- *
59
- * if url not found, component will not be defined,
60
- *
61
- * if you didn't use webpack or rollup.js or any bundler,
62
- * you should copy the html files to its folder by yourself.
63
- */
64
- templateUrl?: TemplateUrl | string;
65
- /**
66
- * template: typeof 'string' ==> html string,
67
- * TypeOf 'DomRootRenderNode<T>' ==> JSX, create factory
68
- * if template === null || undefined ==> it had nothing to render,
69
- * and may be inherit from an html element
70
- *
71
- * 2 possible way to write a template, as inline string, represent a a valid html,
72
- * or us aurora jsx factory
73
- *
74
- */
75
- template?: string | DomNode;
76
- /**
77
- * style for this element
78
- */
79
- styles?: string | {
80
- [key: string]: string;
81
- }[];
82
- /**
83
- * what basic element should the new component inherit from,
84
- * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...
85
- */
86
- extend?: keyof HTMLElementTagNameMap;
87
- /**
88
- * An encapsulation policy for the template and CSS styles. One of:
89
- * 'custom': Use global CSS without any encapsulation.
90
- * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.
91
- *
92
- * 'template': like 'custom', with load the template from the document ('index.html' file)
93
- * that had the same id as the component "selector".
94
- * 'shadow-dom-template': like 'shadowDom', and load template by selector id.
95
- *
96
- * Both 'template' & 'shadow-dom-template' encapsulation type:
97
- * should had attributes name like lowercase,
98
- * the browser itself, will convert all attributes to lowercase
99
- *
100
- * ```typescript
101
- * @Input('personage') personAge: number;
102
- * @Input('propname') propName: string;
103
- * @Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();
104
- * @View('personform') personForm: HTMLFormElement;
105
- * ```
106
- *
107
- * any root element as
108
- *
109
- * ```html
110
- * <root-app></root-app>
111
- * ```
112
- *
113
- * the supported bind options is 'One way binding *(as passing data only)'
114
- * and 'template parsing' and 'event binding' syntax, HTML (angular) like.
115
- * it load its attributes from 'window object'
116
- *
117
- * so to pass date to A root element,
118
- *
119
- * ```html
120
- * <script>
121
- * let appVersion = '0.1.504';
122
- * function onRootAppClick() {
123
- * console.log('root app clicked');
124
- * }
125
- * function onSave(data){
126
- * console.log('root app save', data);
127
- * }
128
- * </script>
129
- * <root-app [version]="appVersion"
130
- * onclick="onRootAppClick()"
131
- * (save)="onSave()" ></root-app>
132
- * ```
133
- *
134
- * default is 'custom'
135
- * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}
136
- */
137
- encapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';
138
- /**
139
- * default: 'open'
140
- */
141
- shadowDomMode?: ShadowRootMode;
142
- /**
143
- * default: false
144
- */
145
- shadowDomDelegatesFocus?: boolean;
146
- /**
147
- * Create a custom form-associated element with HTMLElement.attachInternals
148
- * default: false
149
- *
150
- * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface
151
- *
152
- * otherwise you can register another class that implement `ValueControl<T>`,
153
- * in case if you want split the model and the value controller.
154
- *
155
- * #### Usage Notes:
156
- *
157
- * ```ts
158
- *
159
- * @Component({
160
- * selector: 'custom-message',
161
- * template: `
162
- * <label for="message">Message</label>
163
- * <textarea id="message" [(value)]="message" [disabled]="disabled" (change)="onMessageChange($event.target.value)"></textarea>
164
- * `,
165
- * formAssociated: true,
166
- * // formAssociated: CustomMessage,
167
- * })
168
- * export class CustomMessage implements ValueControl<string> {
169
- *
170
- * private message: string | null = '';
171
- * private disabled: boolean = false;
172
- * private _onChange: (_: any) => void = () => {};
173
- *
174
- * writeValue({ value, mode }: WriteValueOptions<string>) {
175
- * this.message = mode !== 'reset' ? value : '';
176
- * }
177
- *
178
- * registerOnChange(fn: (_: any) => void): void {
179
- * this._onChange = fn;
180
- * }
181
- *
182
- * setDisabledState(isDisabled: boolean) {
183
- * this.disabled = isDisabled;
184
- * }
185
- *
186
- * onMessageChange(message: string) {
187
- * this._onChange(message);
188
- * }
189
- *
190
- * }
191
- *
192
- *
193
- * export class CustomInputValueControl implements ValueControl<number> {
194
- *
195
- * private _value: number | null = null;
196
- * private _disabled: boolean = false;
197
- * private _onChange: (_: any) => void = () => {};
198
- *
199
- * writeValue({ value, mode }: WriteValueOptions<number>) {
200
- * this._value = mode !== 'reset' ? value : null;
201
- * }
202
- *
203
- * registerOnChange(fn: (_: any) => void): void {
204
- * this._onChange = fn;
205
- * }
206
- *
207
- * setDisabledState(isDisabled: boolean) {
208
- * this._disabled = isDisabled;
209
- * }
210
- *
211
- * }
212
- *
213
- * @Component({
214
- * selector: 'custom-input',
215
- * extend: 'input',
216
- * formAssociated: CustomInputValueControl,
217
- * })
218
- * export class CustomInputElement {
219
- * @View()
220
- * view: HTMLInputElement;
221
- *
222
- * onInit() {
223
- * this.view.type = 'number';
224
- * }
225
- * }
226
- *
227
- * ```
228
- */
229
- formAssociated?: boolean | TypeOf<ValueControl<any>>;
230
- /**
231
- * - use `manual` for no zone.js patch effect applied,
232
- * and used for manual change detection for heavily process components.
233
- *
234
- * - use `proxy` zone for automatic detect changes without use of `zone.js`
235
- *
236
- * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,
237
- * `setInterval` and `fetch` and `XMLHttpRequest`, etc...
238
- * make sure that `zone.js` is imported in the polyfills module.
239
- *
240
- * the default value is the platform zone type which can be changed by:
241
- *
242
- * ```js
243
- * bootstrapZone('manual')
244
- * bootstrapZone('proxy')
245
- * bootstrapZone('aurora')
246
- * ```
247
- *
248
- * if `bootstrapZone` never been called, then the default zone is a `manual`.
249
- */
250
- zone?: ZoneType;
251
- /**
252
- * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.
253
- */
254
- imports?: (TypeOf<any> | ReadonlyArray<any>)[];
255
- }
256
- export interface ChildOptions {
257
- [key: string]: any;
258
- }
259
- export interface ViewChildOpt {
260
- selector: string | typeof HTMLElement | CustomElementConstructor;
261
- childOptions?: ChildOptions;
262
- }
263
- export declare function Input(name?: string): Function;
264
- export declare function FormValue(): Function;
265
- export type OutputEventInit = Omit<EventInit, 'cancelable'>;
266
- export type OutputOptions = {
267
- name?: string;
268
- } & OutputEventInit;
269
- export declare function Output(options?: OutputOptions): Function;
270
- export declare function Output(name?: string, options?: OutputEventInit): Function;
271
- export declare function View(): Function;
272
- export declare function ViewChild(selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions): Function;
273
- export declare function ViewChildren(selector: string | typeof HTMLElement | CustomElementConstructor): Function;
274
- export declare function HostListener(eventName: string, args?: string | string[]): Function;
275
- export declare function HostBinding(hostPropertyName: string): Function;
276
- export declare function Pipe(opt: PipeOptions): Function;
277
- export declare function Service(opt: ServiceOptions): Function;
278
- export declare function Directive(opt: DirectiveOptions): Function;
279
- export declare function Component<T extends {
280
- new (...args: any[]): {};
281
- }>(opt: ComponentOptions<T> | ComponentOptions<T>[]): Function;
282
- export declare function SelfSkip(name?: string): Function;
283
- export declare function Optional(): Function;
284
- export declare function customElement<T extends HTMLElement>(opt: {
285
- selector: string;
286
- } & ElementDefinitionOptions): Function;
19
+ } & ElementDefinitionOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
20
+ export {};
21
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +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,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