@produck/charon-options
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,1 +0,1 @@ | ||
export { define } from './types/Options'; | ||
export { define, OptionsConstructorProvider } from './types/Options'; |
{ | ||
"name": "@produck/charon-options", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Reactive options accessor provider.", | ||
@@ -38,3 +38,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "f0d1dcb07889386e99dde086c09b691d734807ee" | ||
"gitHead": "93b24e7a364849657dd0e72f24147572f1017907" | ||
} |
@@ -1,48 +0,51 @@ | ||
interface BaseAccessor {} | ||
interface Accessor {} | ||
export interface AccessorConstructor< | ||
Descriptor extends BaseDescriptor = {}, | ||
ChildrenAccessorConstructorMap extends AccessorConstructorMap = {}, | ||
> { | ||
new < | ||
Context = any | ||
>( | ||
context: Context | ||
): MixinedAccessor<Descriptor, ChildrenAccessorConstructorMap>; | ||
interface PropertyDescriptorObject<Value = any> { | ||
value: Value; | ||
set?(newValue?: any, oldValue?: any): any; | ||
validate?: (value: Value) => any; | ||
[key: string]: any; | ||
} | ||
appendChild(name: string, ChildAccessor: AccessorConstructor): void; | ||
type ThisTypedPropertyDescriptorObject<Context = any> = PropertyDescriptorObject & ThisType<Context>; | ||
type SimplePropertyDescriptor = number | boolean | string | symbol | null | Function; | ||
type SimpleType<T> = T extends boolean ? boolean : T; | ||
merge( | ||
accessor: MixinedAccessor<Descriptor, ChildrenAccessorConstructorMap>, | ||
options: object | ||
): void; | ||
interface PropertyDescriptorMap<Context = any> { | ||
[propertyName: string]: ThisTypedPropertyDescriptorObject<Context> | SimplePropertyDescriptor; | ||
} | ||
interface PropertyDescriptorObject< | ||
Value = any | ||
type ThisTypedPropertyDescriptorMap< | ||
Context = any, | ||
CustomPropertyDescriptorMap extends PropertyDescriptorMap<Context> = {}, | ||
> = CustomPropertyDescriptorMap & ThisType<Context>; | ||
interface AccessorConstructor< | ||
Context = any, | ||
CustomPropertyDescriptorMap extends PropertyDescriptorMap<Context> = {}, | ||
ChildrenAccessorConstructorMap extends AccessorConstructorMap = {}, | ||
> { | ||
value: Value; | ||
set?(newValue?: any, oldValue?: any): any; | ||
validate?(value?: any): any; | ||
[key: string]: any; | ||
} | ||
new (context: Context): MixinedAccessor<CustomPropertyDescriptorMap, ChildrenAccessorConstructorMap>; | ||
type SimpleProperty = number | boolean | string | symbol; | ||
type PropertyDescriptor = PropertyDescriptorObject | SimpleProperty; | ||
appendChild(name: string, ChildAccessor: AccessorConstructor): void; | ||
interface BaseDescriptor { | ||
[key: string]: PropertyDescriptor; | ||
merge< | ||
CustomAccessor = MixinedAccessor<CustomPropertyDescriptorMap, ChildrenAccessorConstructorMap> | ||
>( | ||
accessor: CustomAccessor, | ||
options: CustomAccessor | ||
): void; | ||
} | ||
interface AccessorConstructorMap { | ||
[key: string]: AccessorConstructor; | ||
[propertyName: string]: AccessorConstructor | ||
} | ||
type MixinedAccessor< | ||
Descriptor extends BaseDescriptor = {}, | ||
CustomPropertyDescriptorMap extends PropertyDescriptorMap = {}, | ||
ChildrenAccessorConstructorMap extends AccessorConstructorMap = {} | ||
> = BaseAccessor & { | ||
[SelfProperty in keyof Descriptor]: | ||
Descriptor[SelfProperty] extends PropertyDescriptorObject<infer R> | ||
? R : Descriptor[SelfProperty] | ||
> = Accessor & { | ||
[SelfProperty in keyof CustomPropertyDescriptorMap]: | ||
CustomPropertyDescriptorMap[SelfProperty] extends PropertyDescriptorObject<infer R> | ||
? R : SimpleType<CustomPropertyDescriptorMap[SelfProperty]>; | ||
} & { | ||
@@ -57,10 +60,11 @@ [ChildProperty in keyof ChildrenAccessorConstructorMap]: | ||
< | ||
CustomDescriptor extends BaseDescriptor = {}, | ||
CustomPropertyDescriptorMap extends PropertyDescriptorMap<Context> = {}, | ||
ChildrenAccessorConstructorMap extends AccessorConstructorMap = {} | ||
> ( | ||
descriptor?: CustomDescriptor, | ||
children?: ChildrenAccessorConstructorMap | ||
): AccessorConstructor<CustomDescriptor, ChildrenAccessorConstructorMap>; | ||
>( | ||
descriptor?: ThisTypedPropertyDescriptorMap<Context, CustomPropertyDescriptorMap>, | ||
children?: ChildrenAccessorConstructorMap, | ||
eachSet?: (this: Context) => void | ||
): AccessorConstructor<Context, CustomPropertyDescriptorMap, ChildrenAccessorConstructorMap>; | ||
} | ||
export const define: OptionsConstructorProvider; | ||
export const define: OptionsConstructorProvider<any> |
8163
161