@ibyar/core 2.0.2 → 2.1.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.
@@ -11,9 +11,21 @@ export declare function ViewChildren<This, Value>(selector: string | typeof HTML
11
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
12
  type ValueGetter<T> = T | (() => T) | undefined;
13
13
  export declare function HostBinding<This, Value>(hostPropertyName: string): (value: ValueGetter<Value>, context: ClassFieldDecoratorContext<This, Value> | ClassMethodDecoratorContext<This, any> | ClassGetterDecoratorContext<This, Value>) => void;
14
+ /**
15
+ * register a new pipe
16
+ */
14
17
  export declare const Pipe: (param: PipeOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
18
+ /**
19
+ * register a new structure or attribute directive
20
+ */
15
21
  export declare const Directive: (param: DirectiveOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
22
+ /**
23
+ * register a new service
24
+ */
16
25
  export declare const Injectable: (param: InjectableOptions) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
26
+ /**
27
+ * define a new custom element model class
28
+ */
17
29
  export declare const Component: (param: ComponentOptions<Class> | ComponentOptions<Class>[]) => (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => any;
18
30
  export declare const customElement: (param: {
19
31
  selector: string;
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAQhD,OAAO,EACN,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAChD,eAAe,EAAE,aAAa,EAAE,WAAW,EAC3C,iBAAiB,EACjB,MAAM,cAAc,CAAC;AAItB,KAAK,aAAa,CAAC,CAAC,IAA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yB5J,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,wIAY/B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,WAAW,GAAG,wBAAwB,EAAE,YAAY,CAAC,EAAE,YAAY,sIAYnI;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,WAAW,GAAG,wBAAwB,sIAYzG;AAGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,+GAe9H;AAGD,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;AAEhD,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,6KAYhE;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,iFAhIO,GACvB,0BAmIA,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,SAAS,sFA1IE,GACvB,0BA6IA,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,uFAnJC,GACvB,0BAsJA,CAAC;AAmBF;;GAEG;AACH,eAAO,MAAM,SAAS,yHA7KE,GACvB,0BAsLA,CAAC;AAEF,eAAO,MAAM,aAAa;cAAkC,MAAM;wFAzL1C,GACvB,0BA4LA,CAAC"}
@@ -93,12 +93,21 @@ export function HostBinding(hostPropertyName) {
93
93
  ReflectComponents.addHostBinding(metadata, context.name, hostPropertyName);
94
94
  });
95
95
  }
96
+ /**
97
+ * register a new pipe
98
+ */
96
99
  export const Pipe = makeClassDecorator((opt, constructor, context, metadata) => {
97
100
  Components.definePipe(constructor, opt, metadata);
98
101
  });
102
+ /**
103
+ * register a new structure or attribute directive
104
+ */
99
105
  export const Directive = makeClassDecorator((opt, constructor, context, metadata) => {
100
106
  Components.defineDirective(constructor, opt, metadata);
101
107
  });
108
+ /**
109
+ * register a new service
110
+ */
102
111
  export const Injectable = makeClassDecorator((opt, constructor, context) => {
103
112
  Components.defineInjectable(constructor, opt, context.metadata);
104
113
  });
@@ -119,6 +128,9 @@ function generateComponent(target, opt, metadata) {
119
128
  Components.defineComponent(target, opt, metadata);
120
129
  }
121
130
  }
131
+ /**
132
+ * define a new custom element model class
133
+ */
122
134
  export const Component = makeClassDecorator((opt, constructor, context, metadata) => {
123
135
  if (Array.isArray(opt)) {
124
136
  for (const comp of opt) {
@@ -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,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,IAAI,WAAW,CAAC,oBAAoB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;QACzF,CAAC;QACD,iBAAiB,CAA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F,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\nexport const Pipe = makeClassDecorator<PipeOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.definePipe(constructor as any, opt, metadata);\n\t}\n);\n\n\nexport const Directive = makeClassDecorator<DirectiveOptions>(\n\t(opt, constructor, context, metadata) => {\n\t\tComponents.defineDirective(constructor as any, opt, metadata);\n\t}\n);\n\nexport const Injectable = makeClassDecorator<InjectableOptions>(\n\t(opt, constructor, context) => {\n\t\tComponents.defineInjectable(constructor as any, opt, context.metadata);\n\t}\n);\n\nfunction generateComponent<T extends Class>(target: MetadataClass<T>, opt: ComponentOptions<T>, metadata: MetadataContext) {\n\tif (opt.templateUrl) {\n\t\tfetchHtml(opt.templateUrl)\n\t\t\t.then(htmlTemplate => {\n\t\t\t\tif (htmlTemplate) {\n\t\t\t\t\topt.template = htmlTemplate;\n\t\t\t\t\tComponents.defineComponent(target, opt, metadata);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(reason => {\n\t\t\t\tconsole.error(`Error @URL: ${opt.templateUrl}, for model Class: ${target.name},\\n Reason: ${reason}.`);\n\t\t\t});\n\t} else {\n\t\tComponents.defineComponent(target, opt, metadata);\n\t}\n}\n\nexport const Component = makeClassDecorator<ComponentOptions | ComponentOptions[]>(\n\t(opt, constructor, context, metadata) => {\n\t\tif (Array.isArray(opt)) {\n\t\t\tfor (const comp of opt) {\n\t\t\t\tgenerateComponent(constructor as any, comp, metadata);\n\t\t\t}\n\t\t} else if (typeof opt === 'object') {\n\t\t\tgenerateComponent(constructor as any, opt, metadata);\n\t\t}\n\t}\n);\n\nexport const customElement = makeClassDecorator<{ selector: string } & ElementDefinitionOptions, Class<HTMLElement>>(\n\t(opt, constructor, context) => {\n\t\tComponents.defineView(constructor as any, opt);\n\t}\n);\n"]}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/core/annotation/decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,kBAAkB,EAAE,wBAAwB,EAC5C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAY7C,MAAM,UAAU,KAAK,CAAc,IAAa;IAC/C,OAAO,wBAAwB,CAC9B,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC5B,IAAI,CAAC,IAAI,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC/C,MAAM,IAAI,SAAS,CAAC,QAAQ,OAAO,OAAO,CAAC,IAAI,QAAQ,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACrG,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,IAAI,WAAW,CAAC,oBAAoB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;QACzF,CAAC;QACD,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAc,EAAE,IAAI,IAAI,OAAO,CAAC,IAAc,CAAC,CAAC;IAC9F,CAAC,CACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,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AAE,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,8 +1,8 @@
1
1
  import type { Class, 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';
2
+ import type { DomNode } from '@ibyar/elements';
3
+ import type { TemplateUrl } from '../utils/path.js';
4
+ import type { ZoneType } from '../zone/bootstrap.js';
5
+ import type { ValueControl } from '../component/custom-element.js';
6
6
  export interface DirectiveOptions {
7
7
  /**
8
8
  * the name of the directive which is used in the template
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG9D,MAAM,WAAW,gBAAgB;IAEhC;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IAEH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAGhB;;OAEG;IACH,SAAS,CAAC,EAA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OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,GAAG,OAAO,WAAW,GAAG,wBAAwB,CAAC;IACjE,YAAY,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/core/annotation/options.ts"],"names":[],"mappings":"","sourcesContent":["import type { Class, TypeOf } from '../utils/typeof.js';\nimport { DomNode } from '@ibyar/elements';\nimport { TemplateUrl } from '../utils/path.js';\nimport { ZoneType } from '../zone/bootstrap.js';\nimport { ValueControl } from '../component/custom-element.js';\n\n\nexport interface DirectiveOptions {\n\n\t/**\n\t * the name of the directive which is used in the template\n\t * \n\t * a structural directive name should start with `*`,\n\t * and an attributes directive should not.\n\t */\n\tselector: string;\n\n\t/**\n\t * export this directive to the HTML template scope,\n\t * \n\t * it can be accessed by the template reference name \n\t * ex:\n\t * ```ts\n\t * \n\t * \n\t * \n\t * Directive({\n\t * \tselector: '*tooltip',\n\t * \texportAs: 'tooltip'\n\t * })\n\t * ```\n\t * \n\t * in your component\n\t * \n\t * ```html\n\t * <a tooltip=\"I'm a tooltip!!\" #tooltip=\"tooltip\">I'm a link</a>\n\t * <button (click)=\"tooltip.toggleTooltip()\">Toggle tooltip</button>\n\t * ```\n\t * \n\t */\n\n\texportAs?: string;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * if no value specified, the value will be initialized by the custom element `web component` zone,\n\t * - if the web component zone is `manual`, the directive zone also will be `manual`, expect weird behavior.\n\t * - if the web component zone is `proxy`, the directive zone also will be `proxy`.\n\t * - if the web component zone is `aurora`, the directive zone also will be `aurora` and will get the benefit of `zone.js`.\n\t */\n\tzone?: ZoneType;\n\n\n\t/**\n\t * name of possible structure directive successor\n\t */\n\tsuccessor?: string;\n}\n\nexport interface InjectableOptions {\n\tprovideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Class> {\n\n\t/**\n\t * a tag name for the component,\n\t * if the tag name is valid custom element name, the view class will be a custom element,\n\t * otherwise an HTMLUnknownElement will be created\n\t */\n\tselector: string;\n\n\t/**\n\t * add html file url path to fetch,\n\t * templateUrl had propriety than template, and will override it.\n\t *\n\t * Can provide file name as \"person-view.html\" will resolved \n\t * as 'http://site-address.org/persin-view.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }\n\t * let (import.meta = '/person/person.js') will resolved \n\t * as 'http://site-address.org/person/person-edit.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta }\n\t * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.\n\t * \n\t * if url not found, component will not be defined,\n\t * \n\t * if you didn't use webpack or rollup.js or any bundler, \n\t * you should copy the html files to its folder by yourself. \n\t */\n\ttemplateUrl?: TemplateUrl | string;\n\n\t/**\n\t * template: html string\n\t * \tif template === null || undefined ==> it had nothing to render, \n\t * and may be inherit from an html element\n\t * \n\t * write a template, as inline string, represent a a valid html.\n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DomNode;\n\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\n\t/**\n\t * what basic element should the new component inherit from,\n\t * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...\n\t * also, support extends a custom element tag name.\n\t */\n\textend?: keyof HTMLElementTagNameMap | `${string}-${string}`;\n\n\t/**\n\t * An encapsulation policy for the template and CSS styles. One of:\n\t * 'custom': Use global CSS without any encapsulation.\n\t * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.\n\t * \n\t * 'template': like 'custom', with load the template from the document ('index.html' file)\n\t * \t \t\t\tthat had the same id as the component \"selector\".\n\t * 'shadow-dom-template': like 'shadowDom', and load template by selector id.\n\t * \n\t * Both 'template' & 'shadow-dom-template' encapsulation type:\n\t * should had attributes name like lowercase,\n\t * \tthe browser itself, will convert all attributes to lowercase\n\t * \n\t * ```typescript\n\t *\t\t@Input('personage') personAge: number;\n\t *\t\t@Input('propname') propName: string;\n\t *\t\t@Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();\n\t *\t\t@View('personform') personForm: HTMLFormElement;\n\t * ```\n\t * \n\t * any app root element as \n\t * \n\t * ```html\n\t * <app-root></app-root>\n\t * ```\n\t * \n\t * the supported bind options is 'One way binding *(as passing data only)'\n\t * and 'template parsing' and 'event binding' syntax, HTML (angular) like.\n\t * it load its attributes from 'window object'\n\t * \n\t * so to pass date to A root element, \n\t * \n\t * ```html\n\t * <script>\n\t * \tconst appVersion = '0.1.504';\n\t * \tfunction onRootAppClick() {\n\t *\t\tconsole.log('root app clicked');\n\t * \t}\n\t * \tfunction onSave(data){\n\t *\t\tconsole.log('root app save', data);\n\t * \t}\n\t * </script>\n\t * <app-root [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" >\n\t * </app-root>\n\t * ```\n\t * \n\t * default is 'custom'\n\t * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}\n\t */\n\tencapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\n\t/**\n\t * default: 'open' when encapsulation used,\n\t * otherwise it is undefined and will not attach shadow root element.\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n\n\t/**\n\t * shadow root initialization options,\n\t * default mode: `open`, delegatesFocus: `false` and slotAssignment: `manual`\n\t */\n\tshadowRootInit?: Partial<ShadowRootInit>;\n\n\t/**\n\t * Create a custom form-associated element with HTMLElement.attachInternals\n\t * default: false\n\t * \n\t * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface\n\t * \n\t * otherwise you can register another class that implement `ValueControl<T>`,\n\t * in case if you want split the model and the value controller.\n\t * \n\t * #### Usage Notes:\n\t * \n\t * ```ts\n\t * \n\t * @Component({\n\t * \tselector: 'custom-message',\n\t * \ttemplate: `\n\t * \t\t<label for=\"message\">Message</label>\n\t * \t\t<textarea id=\"message\" [(value)]=\"message\" [disabled]=\"disabled\" (change)=\"onMessageChange($event.target.value)\"></textarea>\n\t * \t`,\n\t * \tformAssociated: true,\n\t * \t// formAssociated: CustomMessage,\n\t * })\n\t * export class CustomMessage implements ValueControl<string> {\n\t * \n\t * \tprivate message: string | null = '';\n\t * \tprivate disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<string>) {\n\t * \t\tthis.message = mode !== 'reset' ? value : '';\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis.disabled = isDisabled;\n\t * \t}\n\t * \n\t * \tonMessageChange(message: string) {\n\t * \t\tthis._onChange(message);\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * \n\t * export class CustomInputValueControl implements ValueControl<number> {\n\t * \n\t * \tprivate _value: number | null = null;\n\t * \tprivate _disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<number>) {\n\t * \t\tthis._value = mode !== 'reset' ? value : null;\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis._disabled = isDisabled;\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * @Component({\n\t * \tselector: 'custom-input',\n\t * \textend: 'input',\n\t * \tformAssociated: CustomInputValueControl,\n\t * })\n\t * export class CustomInputElement {\n\t * \t\n\t * @View()\n\t * \tview: HTMLInputElement;\n\t * \n\t * \tonInit() {\n\t * \t\tthis.view.type = 'number';\n\t * \t}\n\t * }\n\t * \n\t * ```\n\t */\n\tformAssociated?: boolean | TypeOf<ValueControl<any>>;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * the default value is the platform zone type which can be changed by:\n\t * \n\t * ```js\n\t * bootstrapZone('manual')\n\t * bootstrapZone('proxy')\n\t * bootstrapZone('aurora')\n\t * ```\n\t * \n\t * if `bootstrapZone` never been called, then the default zone is a `manual`.\n\t */\n\tzone?: ZoneType;\n\n\t/**\n\t * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.\n\t */\n\timports?: (TypeOf<any> | ReadonlyArray<any>)[];\n}\n\nexport interface ChildOptions {\n\t[key: string]: any;\n}\n\nexport interface ViewChildOpt {\n\tselector: string | typeof HTMLElement | CustomElementConstructor;\n\tchildOptions?: ChildOptions;\n}\n\nexport type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n"]}
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\n\t/**\n\t * name of possible structure directive successor\n\t */\n\tsuccessor?: string;\n}\n\nexport interface InjectableOptions {\n\tprovideIn?: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n}\n\nexport interface PipeOptions {\n\tname: string;\n\tasynchronous?: boolean;\n}\n\nexport interface ComponentOptions<T = Class> {\n\n\t/**\n\t * a tag name for the component,\n\t * if the tag name is valid custom element name, the view class will be a custom element,\n\t * otherwise an HTMLUnknownElement will be created\n\t */\n\tselector: string;\n\n\t/**\n\t * add html file url path to fetch,\n\t * templateUrl had propriety than template, and will override it.\n\t *\n\t * Can provide file name as \"person-view.html\" will resolved \n\t * as 'http://site-address.org/persin-view.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta, filename: 'person-edit.html' }\n\t * let (import.meta = '/person/person.js') will resolved \n\t * as 'http://site-address.org/person/person-edit.html',\n\t * \n\t * OR as an object { moduleMeta: import.meta }\n\t * let (import.meta = '/person/person.js') will resolved as 'http://site-address.org/person/person.html'.\n\t * \n\t * if url not found, component will not be defined,\n\t * \n\t * if you didn't use webpack or rollup.js or any bundler, \n\t * you should copy the html files to its folder by yourself. \n\t */\n\ttemplateUrl?: TemplateUrl | string;\n\n\t/**\n\t * template: html string\n\t * \tif template === null || undefined ==> it had nothing to render, \n\t * and may be inherit from an html element\n\t * \n\t * write a template, as inline string, represent a a valid html.\n\t * \t\t\t\t\n\t */\n\ttemplate?: string | DomNode;\n\n\t/**\n\t * style for this element\n\t */\n\tstyles?: string | { [key: string]: string }[];\n\n\t/**\n\t * what basic element should the new component inherit from,\n\t * the tag name to inherit from as 'a', 'div', 'table', 'td', 'th', 'tr', etc ...\n\t * also, support extends a custom element tag name.\n\t */\n\textend?: keyof HTMLElementTagNameMap | `${string}-${string}`;\n\n\t/**\n\t * An encapsulation policy for the template and CSS styles. One of:\n\t * 'custom': Use global CSS without any encapsulation.\n\t * 'shadow-dom': Use Shadow DOM v1 to encapsulate styles.\n\t * \n\t * 'template': like 'custom', with load the template from the document ('index.html' file)\n\t * \t \t\t\tthat had the same id as the component \"selector\".\n\t * 'shadow-dom-template': like 'shadowDom', and load template by selector id.\n\t * \n\t * Both 'template' & 'shadow-dom-template' encapsulation type:\n\t * should had attributes name like lowercase,\n\t * \tthe browser itself, will convert all attributes to lowercase\n\t * \n\t * ```typescript\n\t *\t\t@Input('personage') personAge: number;\n\t *\t\t@Input('propname') propName: string;\n\t *\t\t@Output('savebuttonclick') saveButtonClick = new EventEmitter<Persons>();\n\t *\t\t@View('personform') personForm: HTMLFormElement;\n\t * ```\n\t * \n\t * any app root element as \n\t * \n\t * ```html\n\t * <app-root></app-root>\n\t * ```\n\t * \n\t * the supported bind options is 'One way binding *(as passing data only)'\n\t * and 'template parsing' and 'event binding' syntax, HTML (angular) like.\n\t * it load its attributes from 'window object'\n\t * \n\t * so to pass date to A root element, \n\t * \n\t * ```html\n\t * <script>\n\t * \tconst appVersion = '0.1.504';\n\t * \tfunction onRootAppClick() {\n\t *\t\tconsole.log('root app clicked');\n\t * \t}\n\t * \tfunction onSave(data){\n\t *\t\tconsole.log('root app save', data);\n\t * \t}\n\t * </script>\n\t * <app-root [version]=\"appVersion\" \n\t * \t\tonclick=\"onRootAppClick()\"\n\t * \t\t(save)=\"onSave()\" >\n\t * </app-root>\n\t * ```\n\t * \n\t * default is 'custom'\n\t * @type {'custom' | 'shadowDom' | 'template' | 'shadowDom-template'}\n\t */\n\tencapsulation?: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template';\n\n\t/**\n\t * default: 'open' when encapsulation used,\n\t * otherwise it is undefined and will not attach shadow root element.\n\t */\n\tshadowDomMode?: ShadowRootMode;\n\n\t/**\n\t * default: false\n\t */\n\tshadowDomDelegatesFocus?: boolean;\n\n\t/**\n\t * shadow root initialization options,\n\t * default mode: `open`, delegatesFocus: `false` and slotAssignment: `manual`\n\t */\n\tshadowRootInit?: Partial<ShadowRootInit>;\n\n\t/**\n\t * Create a custom form-associated element with HTMLElement.attachInternals\n\t * default: false\n\t * \n\t * if the value is `true` it is expected from the model class to implement `ValueControl<T>` interface\n\t * \n\t * otherwise you can register another class that implement `ValueControl<T>`,\n\t * in case if you want split the model and the value controller.\n\t * \n\t * #### Usage Notes:\n\t * \n\t * ```ts\n\t * \n\t * @Component({\n\t * \tselector: 'custom-message',\n\t * \ttemplate: `\n\t * \t\t<label for=\"message\">Message</label>\n\t * \t\t<textarea id=\"message\" [(value)]=\"message\" [disabled]=\"disabled\" (change)=\"onMessageChange($event.target.value)\"></textarea>\n\t * \t`,\n\t * \tformAssociated: true,\n\t * \t// formAssociated: CustomMessage,\n\t * })\n\t * export class CustomMessage implements ValueControl<string> {\n\t * \n\t * \tprivate message: string | null = '';\n\t * \tprivate disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<string>) {\n\t * \t\tthis.message = mode !== 'reset' ? value : '';\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis.disabled = isDisabled;\n\t * \t}\n\t * \n\t * \tonMessageChange(message: string) {\n\t * \t\tthis._onChange(message);\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * \n\t * export class CustomInputValueControl implements ValueControl<number> {\n\t * \n\t * \tprivate _value: number | null = null;\n\t * \tprivate _disabled: boolean = false;\n\t * \tprivate _onChange: (_: any) => void = () => {};\n\t * \n\t * \twriteValue({ value, mode }: WriteValueOptions<number>) {\n\t * \t\tthis._value = mode !== 'reset' ? value : null;\n\t * \t}\n\t * \n\t * \tregisterOnChange(fn: (_: any) => void): void {\n\t * \t\tthis._onChange = fn;\n\t * \t}\n\t * \n\t * \tsetDisabledState(isDisabled: boolean) {\n\t * \t\tthis._disabled = isDisabled;\n\t * \t}\n\t * \t\n\t * }\n\t * \n\t * @Component({\n\t * \tselector: 'custom-input',\n\t * \textend: 'input',\n\t * \tformAssociated: CustomInputValueControl,\n\t * })\n\t * export class CustomInputElement {\n\t * \t\n\t * @View()\n\t * \tview: HTMLInputElement;\n\t * \n\t * \tonInit() {\n\t * \t\tthis.view.type = 'number';\n\t * \t}\n\t * }\n\t * \n\t * ```\n\t */\n\tformAssociated?: boolean | TypeOf<ValueControl<any>>;\n\n\t/**\n\t * - use `manual` for no zone.js patch effect applied,\n\t * and used for manual change detection for heavily process components.\n\t * \n\t * - use `proxy` zone for automatic detect changes without use of `zone.js`\n\t * \n\t * - use `aurora` for detection events like `rxjs` observables, `setTimeout`,\n\t * `setInterval` and `fetch` and `XMLHttpRequest`, etc...\n\t * make sure that `zone.js` is imported in the polyfills module. \n\t * \n\t * the default value is the platform zone type which can be changed by:\n\t * \n\t * ```js\n\t * bootstrapZone('manual')\n\t * bootstrapZone('proxy')\n\t * bootstrapZone('aurora')\n\t * ```\n\t * \n\t * if `bootstrapZone` never been called, then the default zone is a `manual`.\n\t */\n\tzone?: ZoneType;\n\n\t/**\n\t * The imports property specifies the component's template dependencies — those directives, components, and pipes that can be used within its template.\n\t */\n\timports?: (TypeOf<any> | ReadonlyArray<any>)[];\n}\n\nexport interface ChildOptions {\n\t[key: string]: any;\n}\n\nexport interface ViewChildOpt {\n\tselector: string | typeof HTMLElement | CustomElementConstructor;\n\tchildOptions?: ChildOptions;\n}\n\nexport type OutputEventInit = Omit<EventInit, 'cancelable'>;\nexport type OutputOptions = { name?: string } & OutputEventInit;\n"]}
@@ -58,8 +58,6 @@ export declare class Components {
58
58
  private static EMPTY_LIST;
59
59
  private static emptyList;
60
60
  private static patchTemplate;
61
- private static createOutputs;
62
- private static parseHostNode;
63
61
  static defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext): void;
64
62
  static definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext): void;
65
63
  static defineInjectable<T extends Class>(modelClass: MetadataClass<T>, opts: InjectableOptions, metadata: MetadataContext): void;
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["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Aa;IAa5B,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe;IAmBnG,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe;IAM7G,MAAM,CAAC,gBAAgB,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe;IAQzH,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe;IAoG1H,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,wBAAwB;CAU1H"}
@@ -1,9 +1,9 @@
1
- import { findByTagName, htmlParser, templateParser, canAttachShadow, directiveRegistry, DomElementNode, DomFragmentNode, DomParentNode, isValidCustomElementName } from '@ibyar/elements';
2
- import { ClassRegistryProvider } from '../providers/provider.js';
1
+ import { findByTagName, htmlParser, templateParser, canAttachShadow, directiveRegistry, DomElementNode, DomParentNode, isValidCustomElementName } from '@ibyar/elements';
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 { ListenerRef } from './reflect.js';
6
5
  import { deserializeExpressionNodes } from '../html/deserialize.js';
6
+ import { parseHostNode } from '../html/host.js';
7
7
  import { provide } from '../di/inject.js';
8
8
  const DEFAULT_SHADOW_ROOT_INIT = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };
9
9
  export class Components {
@@ -22,64 +22,10 @@ export class Components {
22
22
  child.children?.forEach(node => Components.patchTemplate(node, templates));
23
23
  }
24
24
  }
25
- static createOutputs(Listeners) {
26
- return Listeners?.map(listener => `(${listener.eventName})="${listener.modelCallbackName}(${listener.args.join(', ')})"`).join(' ') ?? '';
27
- }
28
- static parseHostNode(option) {
29
- const inputs = option.hostBindings?.map(binding => {
30
- const descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);
31
- if (typeof descriptor?.value === 'function') {
32
- return `[${binding.hostPropertyName}]="${binding.modelPropertyName}()"`;
33
- }
34
- return `[${binding.hostPropertyName}]="${binding.modelPropertyName}"`;
35
- }).join(' ') ?? '';
36
- const hostListeners = [];
37
- const windowListeners = [];
38
- const templateListeners = {};
39
- option.hostListeners?.forEach(listener => {
40
- const [host, event] = listener.eventName.split(':', 2);
41
- if (event === undefined) {
42
- hostListeners.push(listener);
43
- }
44
- else if ('window' === host.toLowerCase()) {
45
- windowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));
46
- }
47
- else {
48
- (templateListeners[host] ??= []).push(new ListenerRef(event, listener.args, listener.modelCallbackName));
49
- }
50
- });
51
- const result = {};
52
- if (hostListeners.length) {
53
- const hostOutputs = Components.createOutputs(hostListeners);
54
- const selector = option.selector ?? 'div';
55
- const hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;
56
- result.host = htmlParser.toDomRootNode(hostTemplate);
57
- buildExpressionNodes(result.host);
58
- }
59
- if (windowListeners.length) {
60
- const windowOutputs = Components.createOutputs(windowListeners);
61
- const windowTemplate = `<window ${windowOutputs}></window>`;
62
- result.window = htmlParser.toDomRootNode(windowTemplate);
63
- buildExpressionNodes(result.window);
64
- }
65
- const templateHosts = Object.keys(templateListeners);
66
- if (templateHosts.length) {
67
- const template = templateHosts.map(host => {
68
- const hostOutputs = Components.createOutputs(templateListeners[host]);
69
- return `<template #${host} ${hostOutputs}></template>`;
70
- }).join('');
71
- const templateNodes = htmlParser.toDomRootNode(template);
72
- buildExpressionNodes(templateNodes);
73
- result.template = templateNodes instanceof DomFragmentNode
74
- ? templateNodes.children?.filter(child => child instanceof DomElementNode) ?? []
75
- : [templateNodes];
76
- }
77
- return result;
78
- }
79
25
  static defineDirective(modelClass, opts, metadata) {
80
26
  Object.assign(metadata, opts);
81
27
  if (metadata.hostListeners?.length || metadata.hostBindings?.length) {
82
- const hostNode = Components.parseHostNode({
28
+ const hostNode = parseHostNode({
83
29
  prototype: modelClass.prototype,
84
30
  hostBindings: metadata.hostBindings,
85
31
  hostListeners: metadata.hostListeners,
@@ -87,7 +33,7 @@ export class Components {
87
33
  metadata.viewBindings = hostNode.host;
88
34
  }
89
35
  metadata.modelClass = modelClass;
90
- ClassRegistryProvider.registerDirective(modelClass);
36
+ classRegistryProvider.registerDirective(modelClass);
91
37
  directiveRegistry.register(opts.selector, {
92
38
  inputs: metadata.inputs?.map(input => input.viewAttribute),
93
39
  outputs: metadata.outputs?.map(output => output.viewAttribute),
@@ -97,13 +43,13 @@ export class Components {
97
43
  static definePipe(modelClass, opts, metadata) {
98
44
  Object.assign(metadata, opts);
99
45
  metadata.modelClass = modelClass;
100
- ClassRegistryProvider.registerPipe(modelClass);
46
+ classRegistryProvider.registerPipe(modelClass);
101
47
  }
102
48
  static defineInjectable(modelClass, opts, metadata) {
103
49
  Object.assign(metadata, opts);
104
50
  metadata.modelClass = modelClass;
105
51
  metadata.name = modelClass.name;
106
- ClassRegistryProvider.registerInjectable(modelClass);
52
+ classRegistryProvider.registerInjectable(modelClass);
107
53
  provide(modelClass);
108
54
  }
109
55
  static defineComponent(modelClass, opts, metadata) {
@@ -151,7 +97,7 @@ export class Components {
151
97
  componentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));
152
98
  }
153
99
  if (componentRef.hostListeners.length || componentRef.hostBindings.length) {
154
- const hostNode = Components.parseHostNode({
100
+ const hostNode = parseHostNode({
155
101
  prototype: modelClass.prototype,
156
102
  selector: componentRef.selector,
157
103
  hostBindings: componentRef.hostBindings,
@@ -181,8 +127,8 @@ export class Components {
181
127
  }
182
128
  componentRef.modelClass = modelClass;
183
129
  componentRef.viewClass = initCustomElementView(modelClass, componentRef);
184
- ClassRegistryProvider.registerComponent(modelClass);
185
- ClassRegistryProvider.registerView(componentRef.viewClass);
130
+ classRegistryProvider.registerComponent(modelClass);
131
+ classRegistryProvider.registerView(componentRef.viewClass);
186
132
  const options = {};
187
133
  const parentTagName = componentRef.extend?.name;
188
134
  if (parentTagName) {
@@ -193,7 +139,7 @@ export class Components {
193
139
  customElements.define(componentRef.selector, componentRef.viewClass, options);
194
140
  }
195
141
  static defineView(viewClass, opt) {
196
- ClassRegistryProvider.registerView(viewClass);
142
+ classRegistryProvider.registerView(viewClass);
197
143
  const { selector, ...definition } = opt;
198
144
  customElements.define(selector, viewClass, definition);
199
145
  }
@@ -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,eAAe,EAAE,aAAa,EAC9B,wBAAwB,EACxB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAK7D,OAAO,EAEN,WAAW,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAwE1C,MAAM,wBAAwB,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAA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GAAG,GAAG,CAAC;QACxC,cAAc,CAAC,MAAM,CACpB,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CAAC;IACH,CAAC","sourcesContent":["import type { MetadataClass, MetadataContext } from '@ibyar/decorators';\nimport type { Class, TypeOf } from '../utils/typeof.js';\nimport type { ZoneType } from '../zone/bootstrap.js';\nimport {\n\tfindByTagName, Tag, htmlParser, templateParser,\n\tDomNode, DomRenderNode, canAttachShadow,\n\tdirectiveRegistry, DomElementNode,\n\tDomFragmentNode, DomParentNode,\n\tisValidCustomElementName\n} from '@ibyar/elements';\n\nimport { HTMLComponent, ValueControl } from './custom-element.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective, StructuralDirective } from '../directive/directive.js';\nimport { initCustomElementView } from '../view/view.js';\nimport { buildExpressionNodes } from '../html/expression.js';\nimport {\n\tComponentOptions, PipeOptions,\n\tInjectableOptions, DirectiveOptions\n} from '../annotation/options.js';\nimport {\n\tChildRef, HostBindingRef, InputPropertyRef,\n\tListenerRef, OutputPropertyRef, PropertyRef\n} from './reflect.js';\nimport { deserializeExpressionNodes } from '../html/deserialize.js';\nimport { provide } from '../di/inject.js';\n\n\nexport interface ServiceRef<T> {\n\tprovideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: TypeOf<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: TypeOf<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\texportAs?: string;\n\tzone?: ZoneType;\n\n\tmodelClass: TypeOf<StructuralDirective> | TypeOf<AttributeDirective>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostListeners: ListenerRef[];\n\thostBindings: HostBindingRef[];\n\tviewBindings?: DomElementNode;\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\tcompiledTemplate?: DomNode;\n\tstyles: string;\n\textend: Tag;\n\textendCustomElement: boolean;\n\n\tviewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: InputPropertyRef[];\n\toutputs: OutputPropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\tviewBindings?: DomElementNode;\n\twindowBindings?: DomElementNode;\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template' | 'shadow-slot';\n\tisShadowDom: boolean;\n\tshadowRootInit: ShadowRootInit;\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\n}\n\ntype ViewBindingOption = {\n\tprototype: Record<PropertyKey, any>;\n\thostBindings?: HostBindingRef[];\n\thostListeners?: ListenerRef[];\n\tselector?: string;\n};\n\ntype HostNode = {\n\thost?: DomElementNode;\n\twindow?: DomElementNode;\n\ttemplate?: DomElementNode[];\n};\n\nconst DEFAULT_SHADOW_ROOT_INIT: ShadowRootInit = { mode: 'open', delegatesFocus: false, slotAssignment: 'named' };\n\nexport class Components {\n\n\tprivate static EMPTY_LIST = Object.freeze<any>([]);\n\tprivate static emptyList<T>(): T[] {\n\t\treturn Components.EMPTY_LIST as T[];\n\t}\n\n\tprivate static patchTemplate(child: DomNode, templates: DomElementNode[]): void {\n\t\tif (child instanceof DomElementNode && child.templateRefName?.name) {\n\t\t\tconst ref = templates.find(node => child.templateRefName?.name === node.templateRefName?.name);\n\t\t\tif (ref?.outputs) {\n\t\t\t\t(child.outputs ??= []).push(...ref.outputs);\n\t\t\t}\n\t\t}\n\t\tif (child instanceof DomParentNode) {\n\t\t\tchild.children?.forEach(node => Components.patchTemplate(node, templates));\n\t\t}\n\t}\n\n\tprivate static createOutputs(Listeners?: ListenerRef[]) {\n\t\treturn Listeners?.map(\n\t\t\tlistener => `(${listener.eventName})=\"${listener.modelCallbackName}(${listener.args.join(', ')})\"`\n\t\t).join(' ') ?? ''\n\t}\n\n\tprivate static parseHostNode(option: ViewBindingOption): HostNode {\n\t\tconst inputs = option.hostBindings?.map(binding => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(option.prototype, binding.modelPropertyName);\n\t\t\tif (typeof descriptor?.value === 'function') {\n\t\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}()\"`\n\t\t\t}\n\t\t\treturn `[${binding.hostPropertyName}]=\"${binding.modelPropertyName}\"`;\n\t\t}).join(' ') ?? '';\n\n\t\tconst hostListeners: ListenerRef[] = [];\n\t\tconst windowListeners: ListenerRef[] = [];\n\t\tconst templateListeners: Record<string, ListenerRef[]> = {};\n\n\t\toption.hostListeners?.forEach(listener => {\n\t\t\tconst [host, event] = listener.eventName.split(':', 2);\n\t\t\tif (event === undefined) {\n\t\t\t\thostListeners.push(listener);\n\t\t\t} else if ('window' === host.toLowerCase()) {\n\t\t\t\twindowListeners.push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t} else {\n\t\t\t\t(templateListeners[host] ??= []).push(new ListenerRef(event, listener.args, listener.modelCallbackName));\n\t\t\t}\n\t\t});\n\n\t\tconst result: HostNode = {};\n\n\t\tif (hostListeners.length) {\n\t\t\tconst hostOutputs = Components.createOutputs(hostListeners);\n\t\t\tconst selector = option.selector ?? 'div';\n\t\t\tconst hostTemplate = `<${selector} ${inputs} ${hostOutputs}></${selector}>`;\n\t\t\tresult.host = htmlParser.toDomRootNode(hostTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.host);\n\t\t}\n\n\t\tif (windowListeners.length) {\n\t\t\tconst windowOutputs = Components.createOutputs(windowListeners);\n\t\t\tconst windowTemplate = `<window ${windowOutputs}></window>`;\n\t\t\tresult.window = htmlParser.toDomRootNode(windowTemplate) as DomElementNode;\n\t\t\tbuildExpressionNodes(result.window);\n\t\t}\n\n\t\tconst templateHosts = Object.keys(templateListeners);\n\t\tif (templateHosts.length) {\n\t\t\tconst template = templateHosts.map(host => {\n\t\t\t\tconst hostOutputs = Components.createOutputs(templateListeners[host]);\n\t\t\t\treturn `<template #${host} ${hostOutputs}></template>`;\n\t\t\t}).join('');\n\t\t\tconst templateNodes = htmlParser.toDomRootNode(template) as DomElementNode | DomFragmentNode;\n\t\t\tbuildExpressionNodes(templateNodes);\n\t\t\tresult.template = templateNodes instanceof DomFragmentNode\n\t\t\t\t? templateNodes.children?.filter(child => child instanceof DomElementNode) as DomElementNode[] ?? []\n\t\t\t\t: [templateNodes];\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic defineDirective(modelClass: MetadataClass, opts: DirectiveOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tif (metadata.hostListeners?.length || metadata.hostBindings?.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\thostBindings: metadata.hostBindings,\n\t\t\t\thostListeners: metadata.hostListeners,\n\t\t\t});\n\t\t\tmetadata.viewBindings = hostNode.host;\n\t\t}\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerDirective(modelClass);\n\t\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (metadata.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (metadata.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t\tsuccessor: (metadata.successor as string | undefined),\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tClassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineInjectable<T extends Class>(modelClass: MetadataClass<T>, opts: InjectableOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tmetadata.name = modelClass.name;\n\t\tClassRegistryProvider.registerInjectable(modelClass);\n\t\tprovide(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tconst componentRef = Object.assign(metadata, opts) as any as ComponentRef<T>;\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\t\tcomponentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(opts.extend);\n\n\t\tif (typeof componentRef.template === 'string') {\n\t\t\tif (componentRef.styles) {\n\t\t\t\tconst template = `<style>${componentRef.styles}</style>${componentRef.template}`;\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(template);\n\t\t\t} else {\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(componentRef.template);\n\t\t\t}\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.template === 'object') {\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.compiledTemplate === 'object') {\n\t\t\thtmlParser.deserializeNode(componentRef.compiledTemplate);\n\t\t\tdeserializeExpressionNodes(componentRef.compiledTemplate);\n\t\t\tcomponentRef.template = componentRef.compiledTemplate;\n\t\t\tcomponentRef.compiledTemplate = undefined;\n\t\t}\n\n\t\tif (!componentRef.template && /template/g.test(componentRef.encapsulation)) {\n\t\t\tconst template = document.querySelector('#' + componentRef.selector);\n\t\t\tif (template && template instanceof HTMLTemplateElement) {\n\t\t\t\tcomponentRef.template = templateParser.parse(template);\n\t\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t\t} else {\n\t\t\t\t// didn't find this template in 'index.html' document\n\t\t\t}\n\t\t}\n\n\t\tcomponentRef.inputs ||= Components.emptyList();\n\t\tcomponentRef.outputs ||= Components.emptyList();\n\t\tcomponentRef.viewChild ||= Components.emptyList();\n\t\tcomponentRef.ViewChildren ||= Components.emptyList();\n\t\tcomponentRef.hostBindings ||= Components.emptyList();\n\t\tcomponentRef.hostListeners ||= Components.emptyList();\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow/g.test(componentRef.encapsulation);\n\t\tif (componentRef.isShadowDom) {\n\t\t\tcomponentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));\n\t\t}\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tconst hostNode = Components.parseHostNode({\n\t\t\t\tprototype: modelClass.prototype,\n\t\t\t\tselector: componentRef.selector,\n\t\t\t\thostBindings: componentRef.hostBindings,\n\t\t\t\thostListeners: componentRef.hostListeners,\n\t\t\t});\n\t\t\tcomponentRef.viewBindings = hostNode.host;\n\t\t\tcomponentRef.windowBindings = hostNode.window;\n\n\t\t\tif (typeof componentRef.template === 'function') {\n\t\t\t\tconst creator = componentRef.template;\n\t\t\t\tcomponentRef.template = (model: T) => {\n\t\t\t\t\tconst template = creator(model);\n\t\t\t\t\tif (hostNode.template) {\n\t\t\t\t\t\tComponents.patchTemplate(template, hostNode.template);\n\t\t\t\t\t}\n\t\t\t\t\treturn template;\n\t\t\t\t};\n\t\t\t} else if (hostNode.template) {\n\t\t\t\tComponents.patchTemplate(componentRef.template, hostNode.template);\n\t\t\t}\n\n\t\t}\n\n\t\tif (!(componentRef.formAssociated === true || typeof componentRef.formAssociated === 'function')) {\n\t\t\tcomponentRef.formAssociated = false;\n\t\t}\n\n\t\tif (componentRef.isShadowDom && componentRef.extend.name) {\n\t\t\tcomponentRef.isShadowDom = canAttachShadow(componentRef.extend.name);\n\t\t}\n\n\t\tcomponentRef.modelClass = modelClass;\n\t\tcomponentRef.viewClass = initCustomElementView(modelClass, componentRef);\n\n\t\tClassRegistryProvider.registerComponent(modelClass);\n\t\tClassRegistryProvider.registerView(componentRef.viewClass);\n\n\t\tconst options: ElementDefinitionOptions = {};\n\t\tconst parentTagName = componentRef.extend?.name;\n\t\tif (parentTagName) {\n\t\t\tif (parentTagName !== '!' && parentTagName.indexOf('-') === -1) {\n\t\t\t\toptions.extends = parentTagName;\n\t\t\t}\n\t\t}\n\n\n\t\tcustomElements.define(\n\t\t\tcomponentRef.selector as string,\n\t\t\tcomponentRef.viewClass as CustomElementConstructor,\n\t\t\toptions\n\t\t);\n\n\t}\n\n\tstatic defineView<T extends HTMLElement>(viewClass: MetadataClass<T>, opt: { selector: string } & ElementDefinitionOptions) {\n\t\tClassRegistryProvider.registerView(viewClass);\n\t\tconst { selector, ...definition } = opt;\n\t\tcustomElements.define(\n\t\t\tselector,\n\t\t\tviewClass,\n\t\t\tdefinition,\n\t\t);\n\t}\n\n}\n"]}
1
+ {"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;AA2D1C,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,SAAS;QACvB,OAAO,UAAU,CAAC,UAAiB,CAAC;IACrC,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,KAAc,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G,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 ServiceRef<T> {\n\tprovideIn: TypeOf<CustomElementConstructor> | 'root' | 'platform' | 'any';\n\tmodelClass: TypeOf<T>;\n\tname: string;\n}\n\nexport interface PipeRef<T> {\n\tname: string;\n\tasynchronous?: boolean;\n\tmodelClass: TypeOf<T>;\n}\nexport interface DirectiveRef<T> {\n\tselector: string;\n\texportAs?: string;\n\tzone?: ZoneType;\n\n\tmodelClass: TypeOf<StructuralDirective> | TypeOf<AttributeDirective>;\n\n\tinputs: PropertyRef[];\n\toutputs: PropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostListeners: ListenerRef[];\n\thostBindings: HostBindingRef[];\n\tviewBindings?: DomElementNode;\n}\n\nexport interface ComponentRef<T> {\n\tselector: string;\n\ttemplate: DomNode | DomRenderNode<T>;\n\tcompiledTemplate?: DomNode;\n\tstyles: string;\n\textend: Tag;\n\textendCustomElement: boolean;\n\n\tviewClass: MetadataClass<HTMLComponent<T>> & CustomElementConstructor;\n\tmodelClass: TypeOf<T>;\n\n\tinputs: InputPropertyRef[];\n\toutputs: OutputPropertyRef[];\n\tview: string;\n\tviewChild: ChildRef[];\n\tViewChildren: ChildRef[];\n\thostBindings: HostBindingRef[];\n\thostListeners: ListenerRef[];\n\tviewBindings?: DomElementNode;\n\twindowBindings?: DomElementNode;\n\n\tencapsulation: 'custom' | 'shadow-dom' | 'template' | 'shadow-dom-template' | 'shadow-slot';\n\tisShadowDom: boolean;\n\tshadowRootInit: ShadowRootInit;\n\tformAssociated: boolean | TypeOf<ValueControl<any>>;\n\tzone?: ZoneType;\n}\n\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\tdirectiveRegistry.register(opts.selector, {\n\t\t\tinputs: (metadata.inputs as PropertyRef[])?.map(input => input.viewAttribute),\n\t\t\toutputs: (metadata.outputs as PropertyRef[])?.map(output => output.viewAttribute),\n\t\t\tsuccessor: (metadata.successor as string | undefined),\n\t\t});\n\t}\n\n\tstatic definePipe<T extends Class>(modelClass: MetadataClass<T>, opts: PipeOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tclassRegistryProvider.registerPipe(modelClass);\n\t}\n\n\tstatic defineInjectable<T extends Class>(modelClass: MetadataClass<T>, opts: InjectableOptions, metadata: MetadataContext) {\n\t\tObject.assign(metadata, opts);\n\t\tmetadata.modelClass = modelClass;\n\t\tmetadata.name = modelClass.name;\n\t\tclassRegistryProvider.registerInjectable(modelClass);\n\t\tprovide(modelClass);\n\t}\n\n\tstatic defineComponent<T extends Class>(modelClass: MetadataClass<T>, opts: ComponentOptions<T>, metadata: MetadataContext) {\n\t\tconst componentRef = Object.assign(metadata, opts) as any as ComponentRef<T>;\n\t\tcomponentRef.extend = findByTagName(opts.extend);\n\t\tcomponentRef.extendCustomElement = !!opts.extend && isValidCustomElementName(opts.extend);\n\n\t\tif (typeof componentRef.template === 'string') {\n\t\t\tif (componentRef.styles) {\n\t\t\t\tconst template = `<style>${componentRef.styles}</style>${componentRef.template}`;\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(template);\n\t\t\t} else {\n\t\t\t\tcomponentRef.template = htmlParser.toDomRootNode(componentRef.template);\n\t\t\t}\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.template === 'object') {\n\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t} else if (typeof componentRef.compiledTemplate === 'object') {\n\t\t\thtmlParser.deserializeNode(componentRef.compiledTemplate);\n\t\t\tdeserializeExpressionNodes(componentRef.compiledTemplate);\n\t\t\tcomponentRef.template = componentRef.compiledTemplate;\n\t\t\tcomponentRef.compiledTemplate = undefined;\n\t\t}\n\n\t\tif (!componentRef.template && /template/g.test(componentRef.encapsulation)) {\n\t\t\tconst template = document.querySelector('#' + componentRef.selector);\n\t\t\tif (template && template instanceof HTMLTemplateElement) {\n\t\t\t\tcomponentRef.template = templateParser.parse(template);\n\t\t\t\tbuildExpressionNodes(componentRef.template);\n\t\t\t} else {\n\t\t\t\t// didn't find this template in 'index.html' document\n\t\t\t}\n\t\t}\n\n\t\tcomponentRef.inputs ||= Components.emptyList();\n\t\tcomponentRef.outputs ||= Components.emptyList();\n\t\tcomponentRef.viewChild ||= Components.emptyList();\n\t\tcomponentRef.ViewChildren ||= Components.emptyList();\n\t\tcomponentRef.hostBindings ||= Components.emptyList();\n\t\tcomponentRef.hostListeners ||= Components.emptyList();\n\t\tcomponentRef.encapsulation ||= 'custom';\n\t\tcomponentRef.isShadowDom = /shadow/g.test(componentRef.encapsulation);\n\t\tif (componentRef.isShadowDom) {\n\t\t\tcomponentRef.shadowRootInit = Object.assign({}, DEFAULT_SHADOW_ROOT_INIT, (componentRef.shadowRootInit ?? {}));\n\t\t}\n\n\t\tif (componentRef.hostListeners.length || componentRef.hostBindings.length) {\n\t\t\tconst hostNode = 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,6 +1,6 @@
1
1
  import { ReactiveScope } from '@ibyar/expressions';
2
2
  import { isOnInit } from '../component/lifecycle.js';
3
- import { ClassRegistryProvider } from '../providers/provider.js';
3
+ import { classRegistryProvider } from '../providers/provider.js';
4
4
  import { AttributeDirective } from './directive.js';
5
5
  export class ElementReactiveScope extends ReactiveScope {
6
6
  el;
@@ -29,7 +29,7 @@ export class ElementReactiveScope extends ReactiveScope {
29
29
  return Reflect.get(directive, propertyKey);
30
30
  }
31
31
  }
32
- const directiveRef = ClassRegistryProvider.getDirectiveRef(propertyKey);
32
+ const directiveRef = classRegistryProvider.getDirectiveRef(propertyKey);
33
33
  if (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {
34
34
  const directive = new directiveRef.modelClass(this.el);
35
35
  this.directiveMap.set(propertyKey, directive);
@@ -54,7 +54,7 @@ export class ElementReactiveScope extends ReactiveScope {
54
54
  return Reflect.set(directive, propertyKey, value);
55
55
  }
56
56
  }
57
- const directiveRef = ClassRegistryProvider.getDirectiveRef(propertyKey);
57
+ const directiveRef = classRegistryProvider.getDirectiveRef(propertyKey);
58
58
  if (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {
59
59
  const directive = new directiveRef.modelClass(this.el);
60
60
  this.directiveMap.set(propertyKey, directive);
@@ -78,10 +78,10 @@ export class ElementReactiveScope extends ReactiveScope {
78
78
  return true;
79
79
  }
80
80
  }
81
- if (ClassRegistryProvider.hasDirective(propertyKey)) {
81
+ if (classRegistryProvider.hasDirective(propertyKey)) {
82
82
  return true;
83
83
  }
84
- if (ClassRegistryProvider.directiveHasInput(propertyKey)) {
84
+ if (classRegistryProvider.directiveHasInput(propertyKey)) {
85
85
  return true;
86
86
  }
87
87
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../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,CAAC,UAAU,CAAC,SAAS,YAAY,kBAAkB,EAAE,CAAC;YACrF,MAAM,SAAS,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAuB,CAAC;YAC7E,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAqB,EAAE,SAAS,CAAC,CAAC;YACxD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;YAC1D,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBACzB,SAAS,CAAC,MAAM,EAAE,CAAC;YACpB,CAAC;YACD,OAAO,MAAM,CAAC;QACf,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,GAAG,CAAC,WAAmB;QACtB,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;YACpD,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;gBAC9B,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;QACD,IAAI,qBAAqB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,QAAQ;QACP,OAAO,oBAAoB,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { ReactiveScope } from '@ibyar/expressions';\nimport { TypeOf } from '@ibyar/expressions/api/utils';\nimport { isOnInit } from '../component/lifecycle.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective } from './directive.js';\n\nexport type ElementContext = { this: HTMLElement } & { [key: string]: AttributeDirective | undefined; };\nexport class ElementReactiveScope extends ReactiveScope<ElementContext> {\n\tprivate directiveMap: Map<string, AttributeDirective> = new Map();\n\tconstructor(private el: HTMLElement) {\n\t\tsuper({} as ElementContext);\n\t\tthis._ctx.this = el;\n\t}\n\tgetElement() {\n\t\treturn this.el;\n\t}\n\tgetDirectives() {\n\t\treturn this.directiveMap;\n\t}\n\tget(propertyKey: PropertyKey): any {\n\t\tif (propertyKey === 'this') {\n\t\t\treturn this.el;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn directive;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.get(directive, propertyKey);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tthis._ctx[propertyKey as string] = directive;\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn Reflect.get(directive, propertyKey as string);\n\t\t}\n\t\treturn void 0;\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\tif (propertyKey in this.el) {\n\t\t\treturn Reflect.set(this.el, propertyKey, value);\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tconst result = Reflect.set(directive, propertyKey, value);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn false;\n\t}\n\thas(propertyKey: string): boolean {\n\t\tif (propertyKey in this._ctx) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (ClassRegistryProvider.hasDirective(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (ClassRegistryProvider.directiveHasInput(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ElementReactiveScope> {\n\t\treturn ElementReactiveScope;\n\t}\n}\n"]}
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/core/directive/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,oBAAqB,SAAQ,aAA6B;IAElD;IADZ,YAAY,GAAoC,IAAI,GAAG,EAAE,CAAC;IAClE,YAAoB,EAAe;QAClC,KAAK,CAAC,EAAoB,CAAC,CAAC;QADT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B,CAAC;YACD,OAAO,MAAM,CAAC;QACf,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,GAAG,CAAC,WAAmB;QACtB,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;YACpD,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;gBAC9B,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;QACD,IAAI,qBAAqB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,QAAQ;QACP,OAAO,oBAAoB,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { ReactiveScope } from '@ibyar/expressions';\nimport { TypeOf } from '@ibyar/expressions/api/utils';\nimport { isOnInit } from '../component/lifecycle.js';\nimport { classRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective } from './directive.js';\n\nexport type ElementContext = { this: HTMLElement } & { [key: string]: AttributeDirective | undefined; };\nexport class ElementReactiveScope extends ReactiveScope<ElementContext> {\n\tprivate directiveMap: Map<string, AttributeDirective> = new Map();\n\tconstructor(private el: HTMLElement) {\n\t\tsuper({} as ElementContext);\n\t\tthis._ctx.this = el;\n\t}\n\tgetElement() {\n\t\treturn this.el;\n\t}\n\tgetDirectives() {\n\t\treturn this.directiveMap;\n\t}\n\tget(propertyKey: PropertyKey): any {\n\t\tif (propertyKey === 'this') {\n\t\t\treturn this.el;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn directive;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.get(directive, propertyKey);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = classRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tthis._ctx[propertyKey as string] = directive;\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn Reflect.get(directive, propertyKey as string);\n\t\t}\n\t\treturn void 0;\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\tif (propertyKey in this.el) {\n\t\t\treturn Reflect.set(this.el, propertyKey, value);\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = classRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tconst result = Reflect.set(directive, propertyKey, value);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn false;\n\t}\n\thas(propertyKey: string): boolean {\n\t\tif (propertyKey in this._ctx) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (classRegistryProvider.hasDirective(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (classRegistryProvider.directiveHasInput(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ElementReactiveScope> {\n\t\treturn ElementReactiveScope;\n\t}\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { DomElementNode } from '@ibyar/elements/node';
2
+ import { HostBindingRef, ListenerRef } from '../component/reflect.js';
3
+ export type ViewBindingOption = {
4
+ prototype: Record<PropertyKey, any>;
5
+ hostBindings?: HostBindingRef[];
6
+ hostListeners?: ListenerRef[];
7
+ selector?: string;
8
+ };
9
+ export type HostNode = {
10
+ host?: DomElementNode;
11
+ window?: DomElementNode;
12
+ template?: DomElementNode[];
13
+ };
14
+ export declare function createOutputs(Listeners?: ListenerRef[]): string;
15
+ export declare function parseHostNode(option: ViewBindingOption): HostNode;
16
+ //# sourceMappingURL=binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../../src/core/html/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA+B,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IACpC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACtB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B,CAAC;AAEF,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,UAItD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,QAAQ,CAsDjE"}