doura-plugin-log
Advanced tools
Comparing version 0.0.0-rc.7 to 0.0.0-rc.8
@@ -1,247 +0,6 @@ | ||
declare interface ActionListener { | ||
(action: ModelAction): any | ||
} | ||
import { Plugin as Plugin_2 } from 'doura'; | ||
declare type ActionOptions = Record<string, Function> | ||
declare type Actions<A> = A extends ActionOptions | ||
? { | ||
[K in keyof A]: A[K] | ||
} | ||
: {} | ||
declare enum ActionType { | ||
REPLACE = 'replace', | ||
MODIFY = 'modify', | ||
PATCH = 'patch', | ||
} | ||
declare type AnyFunctionModel = FunctionModel<any, any, any> | ||
declare type AnyModel = AnyObjectModel | AnyFunctionModel | ||
declare type AnyObject = { [key: string]: any } | ||
declare type AnyObjectModel = ObjectModel<any, any, any> | ||
declare const douraLog: Plugin_2; | ||
export default douraLog; | ||
declare interface DouraSubscriptionCallback { | ||
(): any | ||
} | ||
declare type EmptyObject = { [X: string | number | symbol]: never } | ||
declare interface FunctionModel< | ||
S extends State, | ||
A extends ActionOptions, | ||
V extends ViewOptions | ||
> { | ||
(context: ModelOptionContext): ObjectModel<S, A, V> | ||
} | ||
declare interface ModelAction { | ||
name: string | ||
args: any[] | ||
} | ||
declare type ModelActions<Model> = Model extends ModelOptions< | ||
any, | ||
infer A, | ||
any, | ||
any | ||
> | ||
? Actions<A> & EmptyObject | ||
: never | ||
declare type ModelAPI<IModel extends AnyModel> = ModelData<IModel> & | ||
ModelActions<IModel> | ||
declare type ModelChangeEvent = | ||
| ModelModifyEvent | ||
| ModelPatchEvent | ||
| ModelReplaceEvent | ||
declare interface ModelChangeEventBase { | ||
type: ActionType | ||
// the model to which the event is attached. | ||
model: ModelPublicInstance<AnyModel> | ||
// the model that triggered the event. | ||
target: ModelPublicInstance<AnyModel> | ||
} | ||
declare type ModelData<Model extends AnyModel> = { | ||
$state: ModelState<Model> | ||
} & ModelState<Model> & | ||
ModelViews<Model> | ||
declare interface ModelManager { | ||
getState(): Record<string, State> | ||
getModel<IModel extends AnyModel>( | ||
name: string, | ||
model: IModel | ||
): ModelPublicInstance<IModel> | ||
getDetachedModel<IModel extends AnyModel>( | ||
model: IModel | ||
): ModelPublicInstance<IModel> | ||
subscribe(fn: DouraSubscriptionCallback): UnSubscribe | ||
destroy(): void | ||
} | ||
declare interface ModelModifyEvent extends ModelChangeEventBase { | ||
type: ActionType.MODIFY | ||
} | ||
declare interface ModelOptionContext { | ||
use<IModel extends AnyModel>(model: IModel): ModelPublicInstance<IModel> | ||
use<IModel extends AnyModel>( | ||
name: string, | ||
model: IModel | ||
): ModelPublicInstance<IModel> | ||
} | ||
declare type ModelOptions< | ||
S extends State, | ||
A extends ActionOptions, | ||
V extends ViewOptions, | ||
P extends Params | ||
> = ObjectModel<S, A, V> | FunctionModel<S, A, V> | ||
declare interface ModelPatchEvent extends ModelChangeEventBase, PatchArgs { | ||
type: ActionType.PATCH | ||
} | ||
declare type ModelPublicInstance<IModel extends AnyModel> = { | ||
$name: string | ||
$rawState: ModelState<IModel> | ||
$state: ModelState<IModel> | ||
$actions: ModelActions<IModel> | ||
$views: ModelViews<IModel> | ||
$patch(newState: State): void | ||
$onAction: (listener: ActionListener) => UnSubscribe | ||
$subscribe: (listener: SubscriptionCallback) => UnSubscribe | ||
$isolate: <T>(fn: (s: ModelState<IModel>) => T) => T | ||
$getApi(): ModelAPI<IModel> | ||
$createView: <R>( | ||
selector: Selector<IModel, R> | ||
) => ModelView<Selector<IModel, R>> | ||
} & ModelState<IModel> & | ||
ModelViews<IModel> & | ||
ModelActions<IModel> | ||
declare interface ModelReplaceEvent extends ModelChangeEventBase { | ||
type: ActionType.REPLACE | ||
} | ||
declare type ModelState<Model> = Model extends ModelOptions< | ||
infer S, | ||
any, | ||
any, | ||
any | ||
> | ||
? { [K in keyof S]: S[K] } | ||
: never | ||
declare type ModelThis< | ||
S extends State = {}, | ||
A extends ActionOptions = {}, | ||
V extends ViewOptions = {} | ||
> = { | ||
$state: S | ||
$patch: (s: AnyObject) => void | ||
} & S & | ||
Views<V> & | ||
Actions<A> | ||
declare interface ModelView<T extends (...args: any[]) => any = any> { | ||
(): ReturnType<T> | ||
destory(): void | ||
} | ||
declare type ModelViews<Model> = Model extends ModelOptions< | ||
any, | ||
any, | ||
infer V, | ||
any | ||
> | ||
? Views<V> & EmptyObject | ||
: never | ||
declare type ObjectModel< | ||
S extends State, | ||
A extends ActionOptions, | ||
V extends ViewOptions | ||
> = { | ||
state: S | ||
actions?: A | ||
views?: V & ThisType<ViewThis<S, V>> | ||
} & ThisType<ModelThis<S, A, V>> | ||
declare type Params = any | ||
declare type PatchArgs = { | ||
patch: any | ||
} | ||
declare type Plugin_2<Option = any> = (option: Option) => PluginHook | ||
declare interface PluginContext { | ||
doura: ModelManager | ||
} | ||
declare type PluginHook = { | ||
onInit?( | ||
options: { initialState: Record<string, State> }, | ||
context: PluginContext | ||
): void | ||
onModel?(name: string, model: AnyObjectModel, context: PluginContext): void | ||
onModelInstance?( | ||
instance: ModelPublicInstance<AnyObjectModel>, | ||
context: PluginContext | ||
): void | ||
onDestroy?(): void | ||
} | ||
declare type Selector<Model extends AnyModel, TReturn = any> = ( | ||
api: ModelAPI<Model>, | ||
actions: ModelActions<Model> | ||
) => TReturn | ||
declare type State = StateObject | StatePrimitive | ||
declare type StateObject = { | ||
[x: string]: any | ||
} | ||
declare type StatePrimitive = | ||
| String | ||
| Number | ||
| Boolean | ||
| any[] | ||
| undefined | ||
| null | ||
declare interface SubscriptionCallback { | ||
(event: ModelChangeEvent): any | ||
} | ||
declare type UnSubscribe = () => void | ||
declare type ViewOptions<State = any> = Record< | ||
string, | ||
((s: State) => any) | (() => any) | ||
> | ||
declare type Views<ViewOptions> = { | ||
[K in keyof ViewOptions]: ViewOptions[K] extends (...args: any) => any | ||
? ReturnType<ViewOptions[K]> | ||
: never | ||
} | ||
declare type ViewThis<S extends State = {}, V extends ViewOptions = {}> = S & { | ||
$state: S | ||
$isolate: <T>(fn: (s: S) => T) => T | ||
} & Views<V> | ||
export { } |
{ | ||
"name": "doura-plugin-log", | ||
"version": "0.0.0-rc.7", | ||
"version": "0.0.0-rc.8", | ||
"main": "index.js", | ||
@@ -42,4 +42,4 @@ "module": "dist/doura-plugin-log.esm-bundler.js", | ||
"peerDependencies": { | ||
"doura": "0.0.0-rc.7" | ||
"doura": "0.0.0-rc.8" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2285
47