@ibyar/core 2.4.0 → 2.5.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.
- package/annotation/decorators.d.ts +23 -2
- package/annotation/decorators.d.ts.map +1 -1
- package/annotation/decorators.js +18 -0
- package/annotation/decorators.js.map +1 -1
- package/annotation/options.d.ts +5 -5
- package/annotation/options.d.ts.map +1 -1
- package/annotation/options.js.map +1 -1
- package/component/component.d.ts +14 -10
- package/component/component.d.ts.map +1 -1
- package/component/component.js +37 -0
- package/component/component.js.map +1 -1
- package/component/custom-element.d.ts +6 -2
- package/component/custom-element.d.ts.map +1 -1
- package/component/custom-element.js.map +1 -1
- package/component/events.js.map +1 -1
- package/component/initializer.d.ts +67 -0
- package/component/initializer.d.ts.map +1 -0
- package/component/initializer.js +59 -0
- package/component/initializer.js.map +1 -0
- package/di/inject.d.ts +11 -4
- package/di/inject.d.ts.map +1 -1
- package/di/inject.js +18 -2
- package/di/inject.js.map +1 -1
- package/di/provider.d.ts +7 -5
- package/di/provider.d.ts.map +1 -1
- package/di/provider.js +29 -13
- package/di/provider.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/initializer/input.d.ts +1 -0
- package/initializer/input.d.ts.map +1 -0
- package/initializer/input.js +2 -0
- package/initializer/input.js.map +1 -0
- package/linker/change-detector-ref.d.ts.map +1 -1
- package/linker/change-detector-ref.js +26 -4
- package/linker/change-detector-ref.js.map +1 -1
- package/linker/view-container-ref.d.ts +4 -4
- package/linker/view-container-ref.d.ts.map +1 -1
- package/linker/view-container-ref.js.map +1 -1
- package/package.json +6 -6
- package/pipe/pipe.d.ts +6 -6
- package/pipe/pipe.d.ts.map +1 -1
- package/pipe/pipe.js.map +1 -1
- package/signals/factory.d.ts +23 -0
- package/signals/factory.d.ts.map +1 -0
- package/signals/factory.js +65 -0
- package/signals/factory.js.map +1 -0
- package/signals/initializer.d.ts +26 -0
- package/signals/initializer.d.ts.map +1 -0
- package/signals/initializer.js +19 -0
- package/signals/initializer.js.map +1 -0
- package/signals/input.d.ts +1 -0
- package/signals/input.d.ts.map +1 -0
- package/signals/input.js +2 -0
- package/signals/input.js.map +1 -0
- package/signals/runtime.d.ts +37 -0
- package/signals/runtime.d.ts.map +1 -0
- package/signals/runtime.js +165 -0
- package/signals/runtime.js.map +1 -0
- package/signals/signals.d.ts +11 -9
- package/signals/signals.d.ts.map +1 -1
- package/signals/signals.js +23 -41
- package/signals/signals.js.map +1 -1
- package/utils/typeof.d.ts +4 -2
- package/utils/typeof.d.ts.map +1 -1
- package/utils/typeof.js.map +1 -1
- package/view/base-view.d.ts +2 -2
- package/view/base-view.d.ts.map +1 -1
- package/view/base-view.js +41 -23
- package/view/base-view.js.map +1 -1
- package/view/form-view.d.ts +2 -2
- package/view/form-view.d.ts.map +1 -1
- package/view/form-view.js.map +1 -1
- package/view/render.d.ts +2 -0
- package/view/render.d.ts.map +1 -1
- package/view/render.js +16 -0
- package/view/render.js.map +1 -1
- package/view/utils.d.ts +2 -2
- package/view/utils.d.ts.map +1 -1
- package/view/utils.js.map +1 -1
- package/view/view.d.ts +3 -3
- package/view/view.d.ts.map +1 -1
- package/view/view.js +15 -2
- package/view/view.js.map +1 -1
|
@@ -1,12 +1,33 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Type } from '../utils/typeof.js';
|
|
2
2
|
import { ChildOptions, ComponentOptions, DirectiveOptions, OutputEventInit, OutputOptions, PipeOptions, InjectableOptions } from './options.js';
|
|
3
3
|
type PropertyValue<T> = T | ((value: T) => void) | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated since v2.4.0, use `input` function instead.
|
|
6
|
+
*/
|
|
4
7
|
export declare function Input<This, Value>(name?: string): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated since v2.4.0, use `formValue` function instead.
|
|
10
|
+
*/
|
|
5
11
|
export declare function FormValue<This, Value>(): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated since v2.4.0, use `output` function instead.
|
|
14
|
+
*/
|
|
6
15
|
export declare function Output<This, Value>(options?: OutputOptions): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated since v2.4.0, use `output` function instead.
|
|
18
|
+
*/
|
|
7
19
|
export declare function Output<This, Value>(name?: string, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated since v2.4.0, use `view` function instead.
|
|
22
|
+
*/
|
|
8
23
|
export declare function View<This, Value>(): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated since v2.4.0, use `viewChild` function instead.
|
|
26
|
+
*/
|
|
9
27
|
export declare function ViewChild<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor, childOptions?: ChildOptions): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated since v2.4.0, use `viewChildren` function instead.
|
|
30
|
+
*/
|
|
10
31
|
export declare function ViewChildren<This, Value>(selector: string | typeof HTMLElement | CustomElementConstructor): (value: PropertyValue<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassSetterDecoratorContext<This, Value>) => void;
|
|
11
32
|
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
33
|
type ValueGetter<T> = T | (() => T) | undefined;
|
|
@@ -26,7 +47,7 @@ export declare const Injectable: (param: InjectableOptions) => (constructor: any
|
|
|
26
47
|
/**
|
|
27
48
|
* define a new custom element model class
|
|
28
49
|
*/
|
|
29
|
-
export declare const Component: (param: ComponentOptions<
|
|
50
|
+
export declare const Component: (param: ComponentOptions<Type<any>> | ComponentOptions<Type<any>>[]) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
|
|
30
51
|
export declare const customElement: (param: {
|
|
31
52
|
selector: string;
|
|
32
53
|
} & ElementDefinitionOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAQ/C,OAAO,EACN,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAChD,eAAe,EAAE,aAAa,EAAE,WAAW,EAC3C,iBAAiB,EACjB,MAAM,cAAc,CAAC;AAItB,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;AAE7D;;GAEG;AAEH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,sIAY/C;AAGD;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,wIAYpC;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;AAE3I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FAlNE,GAAG,0BAsNtE,CAAC"}
|
package/annotation/decorators.js
CHANGED
|
@@ -2,6 +2,9 @@ import { makeClassDecorator, makeClassMemberDecorator } from '@ibyar/decorators'
|
|
|
2
2
|
import { Components } from '../component/component.js';
|
|
3
3
|
import { ReflectComponents } from '../component/reflect.js';
|
|
4
4
|
import { fetchHtml } from '../utils/path.js';
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated since v2.4.0, use `input` function instead.
|
|
7
|
+
*/
|
|
5
8
|
export function Input(name) {
|
|
6
9
|
return makeClassMemberDecorator((value, context, metadata) => {
|
|
7
10
|
if (!name && typeof context.name !== 'string') {
|
|
@@ -13,6 +16,9 @@ export function Input(name) {
|
|
|
13
16
|
ReflectComponents.addInput(metadata, context.name, name || context.name);
|
|
14
17
|
});
|
|
15
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated since v2.4.0, use `formValue` function instead.
|
|
21
|
+
*/
|
|
16
22
|
export function FormValue() {
|
|
17
23
|
return makeClassMemberDecorator((value, context, metadata) => {
|
|
18
24
|
if (typeof context.name !== 'string') {
|
|
@@ -24,6 +30,9 @@ export function FormValue() {
|
|
|
24
30
|
ReflectComponents.addInput(metadata, context.name, 'value');
|
|
25
31
|
});
|
|
26
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated since v2.4.0, use `output` function instead.
|
|
35
|
+
*/
|
|
27
36
|
export function Output(name, options) {
|
|
28
37
|
const eventType = typeof name === 'object' ? name.name : name;
|
|
29
38
|
const eventOpts = typeof name === 'object' ? name : options;
|
|
@@ -40,6 +49,9 @@ export function Output(name, options) {
|
|
|
40
49
|
});
|
|
41
50
|
});
|
|
42
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated since v2.4.0, use `view` function instead.
|
|
54
|
+
*/
|
|
43
55
|
export function View() {
|
|
44
56
|
return makeClassMemberDecorator((value, context, metadata) => {
|
|
45
57
|
if (typeof context.name !== 'string') {
|
|
@@ -51,6 +63,9 @@ export function View() {
|
|
|
51
63
|
ReflectComponents.setComponentView(metadata, context.name);
|
|
52
64
|
});
|
|
53
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated since v2.4.0, use `viewChild` function instead.
|
|
68
|
+
*/
|
|
54
69
|
export function ViewChild(selector, childOptions) {
|
|
55
70
|
return makeClassMemberDecorator((value, context, metadata) => {
|
|
56
71
|
if (typeof context.name !== 'string') {
|
|
@@ -62,6 +77,9 @@ export function ViewChild(selector, childOptions) {
|
|
|
62
77
|
ReflectComponents.addViewChild(metadata, context.name, selector, childOptions);
|
|
63
78
|
});
|
|
64
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated since v2.4.0, use `viewChildren` function instead.
|
|
82
|
+
*/
|
|
65
83
|
export function ViewChildren(selector) {
|
|
66
84
|
return makeClassMemberDecorator((value, context, metadata) => {
|
|
67
85
|
if (typeof context.name !== 'string') {
|
|
@@ -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;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,IAA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AAQ,EAAE,EAAE;IACvC,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,\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\n/**\n * register a new pipe\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\n/**\n * register a new structure or attribute directive \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/**\n * register a new service\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\n/**\n * define a new custom element model class\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;AAW7C;;GAEG;AAEH,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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S,GAAG,kBAAkB,CAC1C,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IACvC,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 { Type } 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/**\n * @deprecated since v2.4.0, use `input` function instead.\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\n\n/**\n * @deprecated since v2.4.0, use `formValue` function instead.\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\n/**\n * @deprecated since v2.4.0, use `output` function instead.\n */\nexport function Output<This, Value>(options?: OutputOptions): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\n\n/**\n * @deprecated since v2.4.0, use `output` function instead.\n */\nexport function Output<This, Value>(name?: string, options?: OutputEventInit): (value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;\n\n/**\n * @deprecated since v2.4.0, use `output` function instead.\n */\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\n/**\n * @deprecated since v2.4.0, use `view` function instead.\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\n/**\n * @deprecated since v2.4.0, use `viewChild` function instead.\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\n/**\n * @deprecated since v2.4.0, use `viewChildren` function instead.\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\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\n/**\n * register a new pipe\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\n/**\n * register a new structure or attribute directive \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/**\n * register a new service\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 Type<any>>(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\n/**\n * define a new custom element model class\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, Type<HTMLElement>>(\n\t(opt, constructor, context) => {\n\t\tComponents.defineView(constructor as any, opt);\n\t}\n);\n"]}
|
package/annotation/options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Type } from '../utils/typeof.js';
|
|
2
2
|
import type { DomNode } from '@ibyar/elements';
|
|
3
3
|
import type { TemplateUrl } from '../utils/path.js';
|
|
4
4
|
import type { ZoneType } from '../zone/bootstrap.js';
|
|
@@ -57,13 +57,13 @@ export interface DirectiveOptions {
|
|
|
57
57
|
successors?: string[];
|
|
58
58
|
}
|
|
59
59
|
export interface InjectableOptions {
|
|
60
|
-
provideIn?:
|
|
60
|
+
provideIn?: Type<CustomElementConstructor> | 'root' | 'platform' | 'any';
|
|
61
61
|
}
|
|
62
62
|
export interface PipeOptions {
|
|
63
63
|
name: string;
|
|
64
64
|
asynchronous?: boolean;
|
|
65
65
|
}
|
|
66
|
-
export interface ComponentOptions<T =
|
|
66
|
+
export interface ComponentOptions<T = Type<any>> {
|
|
67
67
|
/**
|
|
68
68
|
* a tag name for the component,
|
|
69
69
|
* if the tag name is valid custom element name, the view class will be a custom element,
|
|
@@ -265,7 +265,7 @@ export interface ComponentOptions<T = Class> {
|
|
|
265
265
|
*
|
|
266
266
|
* ```
|
|
267
267
|
*/
|
|
268
|
-
formAssociated?: boolean |
|
|
268
|
+
formAssociated?: boolean | Type<ValueControl<any>>;
|
|
269
269
|
/**
|
|
270
270
|
* - use `manual` for no zone.js patch effect applied,
|
|
271
271
|
* and used for manual change detection for heavily process components.
|
|
@@ -290,7 +290,7 @@ export interface ComponentOptions<T = Class> {
|
|
|
290
290
|
/**
|
|
291
291
|
* The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.
|
|
292
292
|
*/
|
|
293
|
-
imports?: (
|
|
293
|
+
imports?: (Type<any> | ReadonlyArray<any>)[];
|
|
294
294
|
}
|
|
295
295
|
export interface ChildOptions {
|
|
296
296
|
[key: string]: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAA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,GAAG,UAAU,GAAG,qBAAqB,CAAC;IAE7E;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC;IAE/B;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAEzC;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,WAAW,GAAG,QAAQ,CAAC,EAAE,CAAC;IAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmFG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAEnD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;CAC7C;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 type { DomNode } from '@ibyar/elements';\nimport type { TemplateUrl } from '../utils/path.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport type { 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\t/**\n\t * name of possible structure directives successor\n\t */\n\tsuccessors?: string[];\n\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 * \n\t */\n\tdisabledFeatures?: ('internals' | 'shadow')[];\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 { Type } from '../utils/typeof.js';\nimport type { DomNode } from '@ibyar/elements';\nimport type { TemplateUrl } from '../utils/path.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport type { 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\t/**\n\t * name of possible structure directives successor\n\t */\n\tsuccessors?: string[];\n\n}\n\nexport interface InjectableOptions {\n\tprovideIn?: Type<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Type<any>> {\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 * \n\t */\n\tdisabledFeatures?: ('internals' | 'shadow')[];\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 | Type<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?: (Type<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"]}
|
package/component/component.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import type { MetadataClass, MetadataContext } from '@ibyar/decorators';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Type } from '../utils/typeof.js';
|
|
3
3
|
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
7
|
import { ComponentOptions, PipeOptions, InjectableOptions, DirectiveOptions } from '../annotation/options.js';
|
|
8
8
|
import { ChildRef, HostBindingRef, InputPropertyRef, ListenerRef, OutputPropertyRef, PropertyRef } from './reflect.js';
|
|
9
|
+
import { SignalRuntimeMetadata } from '../signals/runtime.js';
|
|
9
10
|
export interface InjectableRef<T> {
|
|
10
|
-
provideIn:
|
|
11
|
-
modelClass:
|
|
11
|
+
provideIn: Type<CustomElementConstructor> | 'root' | 'platform' | 'any';
|
|
12
|
+
modelClass: Type<T>;
|
|
12
13
|
name: string;
|
|
13
14
|
}
|
|
14
15
|
export interface PipeRef<T> {
|
|
15
16
|
name: string;
|
|
16
17
|
asynchronous?: boolean;
|
|
17
|
-
modelClass:
|
|
18
|
+
modelClass: Type<T>;
|
|
18
19
|
}
|
|
19
20
|
export interface DirectiveRef<T> {
|
|
20
21
|
selector: string;
|
|
21
22
|
exportAs?: string;
|
|
22
23
|
zone?: ZoneType;
|
|
23
|
-
modelClass:
|
|
24
|
+
modelClass: Type<StructuralDirective> | Type<AttributeDirective>;
|
|
24
25
|
inputs: PropertyRef[];
|
|
25
26
|
outputs: PropertyRef[];
|
|
26
27
|
view: string;
|
|
@@ -29,6 +30,7 @@ export interface DirectiveRef<T> {
|
|
|
29
30
|
hostListeners: ListenerRef[];
|
|
30
31
|
hostBindings: HostBindingRef[];
|
|
31
32
|
viewBindings?: DomElementNode;
|
|
33
|
+
signals: SignalRuntimeMetadata[];
|
|
32
34
|
}
|
|
33
35
|
export interface ComponentRef<T> {
|
|
34
36
|
selector: string;
|
|
@@ -38,7 +40,7 @@ export interface ComponentRef<T> {
|
|
|
38
40
|
extend: Tag;
|
|
39
41
|
extendCustomElement: boolean;
|
|
40
42
|
viewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;
|
|
41
|
-
modelClass:
|
|
43
|
+
modelClass: Type<T>;
|
|
42
44
|
inputs: InputPropertyRef[];
|
|
43
45
|
outputs: OutputPropertyRef[];
|
|
44
46
|
view: string;
|
|
@@ -52,19 +54,21 @@ export interface ComponentRef<T> {
|
|
|
52
54
|
isShadowDom: boolean;
|
|
53
55
|
shadowRootInit: ShadowRootInit;
|
|
54
56
|
disabledFeatures?: ('internals' | 'shadow')[];
|
|
55
|
-
formAssociated: boolean |
|
|
57
|
+
formAssociated: boolean | Type<ValueControl<any>>;
|
|
56
58
|
zone?: ZoneType;
|
|
59
|
+
signals: SignalRuntimeMetadata[];
|
|
57
60
|
}
|
|
58
61
|
export declare class Components {
|
|
59
62
|
private static EMPTY_LIST;
|
|
60
63
|
private static emptyList;
|
|
61
64
|
private static patchTemplate;
|
|
62
65
|
static defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext): void;
|
|
63
|
-
static definePipe<T extends
|
|
64
|
-
static defineInjectable<T extends
|
|
65
|
-
static defineComponent<T extends
|
|
66
|
+
static definePipe<T extends Type<any>>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext): void;
|
|
67
|
+
static defineInjectable<T extends Type<any>>(modelClass: MetadataClass<T>, opts: InjectableOptions, metadata: MetadataContext): void;
|
|
68
|
+
static defineComponent<T extends Type<any>>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext): void;
|
|
66
69
|
static defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: {
|
|
67
70
|
selector: string;
|
|
68
71
|
} & ElementDefinitionOptions): void;
|
|
72
|
+
private static scanRuntimeSignals;
|
|
69
73
|
}
|
|
70
74
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -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,
|
|
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,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACS,GAAG,EAClB,OAAO,EAAE,aAAa,EACH,cAAc,EAEjC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGpF,OAAO,EACN,gBAAgB,EAAE,WAAW,EAC7B,iBAAiB,EAAE,gBAAgB,EACnC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAC1C,WAAW,EAA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CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe;IAMjH,MAAM,CAAC,gBAAgB,CAAC,CAAC,SAAS,IAAI,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe;IAQ7H,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,IAAI,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe;IAuG9H,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;IAU1H,OAAO,CAAC,MAAM,CAAC,kBAAkB;CA6BjC"}
|
package/component/component.js
CHANGED
|
@@ -2,9 +2,11 @@ import { findByTagName, htmlParser, templateParser, canAttachShadow, directiveRe
|
|
|
2
2
|
import { classRegistryProvider } from '../providers/provider.js';
|
|
3
3
|
import { initCustomElementView } from '../view/view.js';
|
|
4
4
|
import { buildExpressionNodes } from '../html/expression.js';
|
|
5
|
+
import { ReflectComponents } from './reflect.js';
|
|
5
6
|
import { deserializeExpressionNodes } from '../html/deserialize.js';
|
|
6
7
|
import { parseHostNode } from '../html/host.js';
|
|
7
8
|
import { provide } from '../di/inject.js';
|
|
9
|
+
import { RuntimeClassMetadata } from '../signals/runtime.js';
|
|
8
10
|
const DEFAULT_SHADOW_ROOT_INIT = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };
|
|
9
11
|
export class Components {
|
|
10
12
|
static EMPTY_LIST = Object.freeze([]);
|
|
@@ -23,6 +25,10 @@ export class Components {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
static defineDirective(modelClass, opts, metadata) {
|
|
28
|
+
if (!opts.signals) {
|
|
29
|
+
opts.signals = RuntimeClassMetadata.scanMetadata(modelClass);
|
|
30
|
+
}
|
|
31
|
+
this.scanRuntimeSignals(modelClass, opts, metadata);
|
|
26
32
|
Object.assign(metadata, opts);
|
|
27
33
|
if (metadata.hostListeners?.length || metadata.hostBindings?.length) {
|
|
28
34
|
const hostNode = parseHostNode({
|
|
@@ -61,6 +67,10 @@ export class Components {
|
|
|
61
67
|
provide(modelClass);
|
|
62
68
|
}
|
|
63
69
|
static defineComponent(modelClass, opts, metadata) {
|
|
70
|
+
if (!opts.signals) {
|
|
71
|
+
opts.signals = RuntimeClassMetadata.scanMetadata(modelClass);
|
|
72
|
+
}
|
|
73
|
+
this.scanRuntimeSignals(modelClass, opts, metadata);
|
|
64
74
|
const componentRef = Object.assign(metadata, opts);
|
|
65
75
|
componentRef.extend = findByTagName(opts.extend);
|
|
66
76
|
componentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(opts.extend);
|
|
@@ -151,5 +161,32 @@ export class Components {
|
|
|
151
161
|
const { selector, ...definition } = opt;
|
|
152
162
|
customElements.define(selector, viewClass, definition);
|
|
153
163
|
}
|
|
164
|
+
static scanRuntimeSignals(modelClass, opts, metadata) {
|
|
165
|
+
if (!opts.signals) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const signals = opts.signals;
|
|
169
|
+
signals.filter(item => item.signal === 'input')
|
|
170
|
+
.flatMap(item => item.options)
|
|
171
|
+
.forEach(option => ReflectComponents.addInput(metadata, option.name, option.alias));
|
|
172
|
+
signals.filter(item => item.signal === 'formValue')
|
|
173
|
+
.flatMap(item => item.options)
|
|
174
|
+
.forEach(option => ReflectComponents.addInput(metadata, option.name, 'view'));
|
|
175
|
+
signals.filter(item => item.signal === 'output')
|
|
176
|
+
.flatMap(item => item.options)
|
|
177
|
+
.forEach(option => ReflectComponents.addOutput(metadata, option.name, option.alias, {}));
|
|
178
|
+
signals.filter(item => item.signal === 'model')
|
|
179
|
+
.flatMap(item => item.options)
|
|
180
|
+
.forEach(option => {
|
|
181
|
+
ReflectComponents.addInput(metadata, option.name, option.alias);
|
|
182
|
+
ReflectComponents.addOutput(metadata, option.name, option.alias, {});
|
|
183
|
+
});
|
|
184
|
+
signals.filter(item => item.signal === 'view')
|
|
185
|
+
.flatMap(item => item.options)
|
|
186
|
+
.forEach(option => ReflectComponents.setComponentView(metadata, option.name));
|
|
187
|
+
signals.filter(item => item.signal === 'viewChild')
|
|
188
|
+
.flatMap(item => item.options)
|
|
189
|
+
.forEach(option => ReflectComponents.addViewChild(metadata, option.name, 'ɵSignal', {}));
|
|
190
|
+
}
|
|
154
191
|
}
|
|
155
192
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
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,aAAa,EAAE,wBAAwB,EACvC,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;AAS7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AA4D1C,MAAM,wBAAwB,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AAElH,MAAM,OAAO,UAAU;IAEd,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAM,EAAE,CAAC,CAAC;IAC3C,MAAM,CAAC,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YAAY,CAAC,WAAW,GAAG,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtE,CAAC;QAED,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC;QACrC,YAAY,CAAC,SAAS,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAEzE,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpD,qBAAqB,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAE3D,MAAM,OAAO,GAA6B,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,EAAE,IAAI,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\tDomParentNode, isValidCustomElementName\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 { parseHostNode } from '../html/host.js';\nimport { provide } from '../di/inject.js';\n\n\nexport interface InjectableRef<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\tdisabledFeatures?: ('internals' | 'shadow')[];\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\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\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 = 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\tconst successors: string[] = [];\n\t\tif (metadata.successor) {\n\t\t\tsuccessors.push(metadata.successor.trim());\n\t\t}\n\t\tif (Array.isArray(metadata.successors)) {\n\t\t\tsuccessors.push(...metadata.successors.map(s => s.trim()));\n\t\t}\n\t\tmetadata.successors = successors;\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\tsuccessors: successors,\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 = 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,aAAa,EAAE,wBAAwB,EACvC,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,EAGN,iBAAiB,EACjB,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AAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC;aACjD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;aAC7B,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC","sourcesContent":["import type { MetadataClass, MetadataContext } from '@ibyar/decorators';\nimport type { Type } 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\tDomParentNode, isValidCustomElementName\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\tReflectComponents\n} from './reflect.js';\nimport { deserializeExpressionNodes } from '../html/deserialize.js';\nimport { parseHostNode } from '../html/host.js';\nimport { provide } from '../di/inject.js';\nimport { RuntimeClassMetadata, SignalRuntimeMetadata } from '../signals/runtime.js';\n\n\nexport interface InjectableRef<T> {\n\tprovideIn: Type<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: Type<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: Type<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\texportAs?: string;\n\tzone?: ZoneType;\n\n\tmodelClass: Type<StructuralDirective> | Type<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\tsignals: SignalRuntimeMetadata[];\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: Type<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\tdisabledFeatures?: ('internals' | 'shadow')[];\n\tformAssociated: boolean | Type<ValueControl<any>>;\n\tzone?: ZoneType;\n\tsignals: SignalRuntimeMetadata[];\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\n\tstatic defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext) {\n\t\tif (!(opts as any as DirectiveRef<Type<any>>).signals) {\n\t\t\t(opts as any as DirectiveRef<Type<any>>).signals = RuntimeClassMetadata.scanMetadata(modelClass);\n\t\t}\n\t\tthis.scanRuntimeSignals(modelClass, opts as any as DirectiveRef<Type<any>>, metadata);\n\t\tObject.assign(metadata, opts);\n\t\tif (metadata.hostListeners?.length || metadata.hostBindings?.length) {\n\t\t\tconst hostNode = 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\tconst successors: string[] = [];\n\t\tif (metadata.successor) {\n\t\t\tsuccessors.push(metadata.successor.trim());\n\t\t}\n\t\tif (Array.isArray(metadata.successors)) {\n\t\t\tsuccessors.push(...metadata.successors.map(s => s.trim()));\n\t\t}\n\t\tmetadata.successors = successors;\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\tsuccessors: successors,\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Type<any>>(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 Type<any>>(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 Type<any>>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tif (!(opts as any as ComponentRef<T>).signals) {\n\t\t\t(opts as any as ComponentRef<T>).signals = RuntimeClassMetadata.scanMetadata(modelClass);\n\t\t}\n\t\tthis.scanRuntimeSignals(modelClass, opts as any as ComponentRef<T>, metadata);\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\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 = 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\tprivate static scanRuntimeSignals<T extends Type<any>>(modelClass: MetadataClass<T>, opts: { signals: SignalRuntimeMetadata[] }, metadata: MetadataContext) {\n\t\tif (!opts.signals) {\n\t\t\treturn;\n\t\t}\n\t\tconst signals = opts.signals;\n\t\tsignals.filter(item => item.signal === 'input')\n\t\t\t.flatMap(item => item.options)\n\t\t\t.forEach(option => ReflectComponents.addInput(metadata, option.name, option.alias));\n\t\tsignals.filter(item => item.signal === 'formValue')\n\t\t\t.flatMap(item => item.options)\n\t\t\t.forEach(option => ReflectComponents.addInput(metadata, option.name, 'view'));\n\t\tsignals.filter(item => item.signal === 'output')\n\t\t\t.flatMap(item => item.options)\n\t\t\t.forEach(option => ReflectComponents.addOutput(metadata, option.name, option.alias, {}));\n\t\tsignals.filter(item => item.signal === 'model')\n\t\t\t.flatMap(item => item.options)\n\t\t\t.forEach(option => {\n\t\t\t\tReflectComponents.addInput(metadata, option.name, option.alias);\n\t\t\t\tReflectComponents.addOutput(metadata, option.name, option.alias, {});\n\t\t\t});\n\t\tsignals.filter(item => item.signal === 'view')\n\t\t\t.flatMap(item => item.options)\n\t\t\t.forEach(option => ReflectComponents.setComponentView(metadata, option.name));\n\n\t\tsignals.filter(item => item.signal === 'viewChild')\n\t\t\t.flatMap(item => item.options)\n\t\t\t.forEach(option => ReflectComponents.addViewChild(metadata, option.name, 'ɵSignal', {}));\n\t}\n\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ReactiveScope, ReactiveScopeControl, Context, SignalScope } from '@ibyar/expressions';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Type } from '../utils/typeof.js';
|
|
3
3
|
import { EventEmitter } from './events.js';
|
|
4
4
|
import { ComponentRef } from './component.js';
|
|
5
5
|
import { AuroraZone } from '../zone/zone.js';
|
|
6
6
|
import { PropertyRef } from './reflect.js';
|
|
7
|
+
import { InjectionProvider } from '../di/provider.js';
|
|
8
|
+
import { ChangeDetectorRef } from '../linker/change-detector-ref.js';
|
|
7
9
|
export interface CustomElement {
|
|
8
10
|
adoptedCallback(): void;
|
|
9
11
|
attributeChangedCallback(name: string, oldValue: any, newValue: any): void;
|
|
@@ -22,6 +24,8 @@ export interface BaseComponent<T> extends CustomElement {
|
|
|
22
24
|
'this': BaseComponent<T>;
|
|
23
25
|
}>;
|
|
24
26
|
_zone: AuroraZone;
|
|
27
|
+
_provider: InjectionProvider;
|
|
28
|
+
_detector: ChangeDetectorRef;
|
|
25
29
|
getComponentRef(): ComponentRef<T>;
|
|
26
30
|
hasInputStartWith(viewProp: string): boolean;
|
|
27
31
|
getInputStartWith(viewProp: string): PropertyRef | undefined;
|
|
@@ -43,7 +47,7 @@ export interface BaseComponent<T> extends CustomElement {
|
|
|
43
47
|
export interface HTMLComponent<T> extends BaseComponent<T>, HTMLElement {
|
|
44
48
|
}
|
|
45
49
|
export declare function isHTMLComponent(object: any): object is HTMLComponent<any>;
|
|
46
|
-
export declare function isHTMLComponentOfType<T extends object>(object: any, typeClass:
|
|
50
|
+
export declare function isHTMLComponentOfType<T extends object>(object: any, typeClass: Type<T>): object is HTMLComponent<T>;
|
|
47
51
|
export declare function isHTMLElement(element: HTMLElement): element is HTMLElement;
|
|
48
52
|
export declare function isHTMLUnknownElement(element: HTMLElement): element is HTMLElement;
|
|
49
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-element.d.ts","sourceRoot":"","sources":["../../../src/core/component/custom-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"custom-element.d.ts","sourceRoot":"","sources":["../../../src/core/component/custom-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,WAAW,aAAa;IAC7B,eAAe,IAAI,IAAI,CAAC;IACxB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,CAAC;IAC3E,iBAAiB,IAAI,IAAI,CAAC;IAC1B,oBAAoB,IAAI,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;AAEvC,MAAM,MAAM,eAAe,CA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