@vue-modeler/model 2.2.0-beta.3 → 2.2.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.ts +14 -20
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -12,11 +12,11 @@ import { WatchStopHandle } from 'vue';
12
12
  * For example, `setActionState` method.
13
13
  * @see `ProtoModel.setActionState`
14
14
  */
15
- export declare class Action<T extends object, Args extends any[] = unknown[], Owner extends object = Model<T>> implements ActionLike<Owner, Args> {
15
+ export declare class Action<T extends object, Args extends any[] = unknown[]> implements ActionLike<T, Args> {
16
16
  protected _model: T;
17
17
  protected actionFunction: OriginalMethodWrapper<Args>;
18
- protected ownerGetter: () => Owner;
19
- protected setStateCb?: ((action: SrActionLike<Owner, Args>, oldState: ActionStateName, newState: ActionStateName) => void) | undefined;
18
+ protected ownerGetter: () => Model<T>;
19
+ protected setStateCb?: ((action: ActionLike<T, Args>, oldState: ActionStateName, newState: ActionStateName) => void) | undefined;
20
20
  static readonly actionFlag: unique symbol;
21
21
  static readonly possibleState: {
22
22
  readonly pending: "pending";
@@ -30,10 +30,10 @@ export declare class Action<T extends object, Args extends any[] = unknown[], Ow
30
30
  protected _state: ActionStateName;
31
31
  protected _value: ActionValue;
32
32
  protected _args: Args | null;
33
- constructor(_model: T, actionFunction: OriginalMethodWrapper<Args>, ownerGetter: () => Owner, setStateCb?: ((action: SrActionLike<Owner, Args>, oldState: ActionStateName, newState: ActionStateName) => void) | undefined);
34
- static create<T extends ProtoModel, Args extends unknown[] = unknown[], Owner extends object = Model<T>>(model: T, actionFunction: OriginalMethodWrapper<Args>, ownerGetter: () => Owner, setStateCb?: (action: SrActionLike<Owner, Args>, oldState: ActionStateName, newState: ActionStateName) => void): SrActionLike<Owner, Args>;
33
+ constructor(_model: T, actionFunction: OriginalMethodWrapper<Args>, ownerGetter: () => Model<T>, setStateCb?: ((action: ActionLike<T, Args>, oldState: ActionStateName, newState: ActionStateName) => void) | undefined);
34
+ static create<T extends ProtoModel, Args extends unknown[] = unknown[]>(model: T, actionFunction: OriginalMethodWrapper<Args>, ownerGetter: () => Model<T>, setStateCb?: (action: ActionLike<T, Args>, oldState: ActionStateName, newState: ActionStateName) => void): ActionLike<T, Args>;
35
35
  toString(): string;
36
- get owner(): Owner;
36
+ get owner(): Model<T>;
37
37
  get possibleStates(): ActionStateName[];
38
38
  get state(): ActionStateName;
39
39
  protected set state(newState: ActionStateName);
@@ -106,9 +106,9 @@ export declare class ActionInternalError extends Error {
106
106
  * Public API interface for Action instances.
107
107
  * Describes only the public contract without implementation details.
108
108
  */
109
- export declare interface ActionLike<Owner extends object, Args extends any[] = unknown[]> {
109
+ export declare interface ActionLike<T extends object, Args extends any[] = unknown[]> {
110
110
  readonly name: string;
111
- readonly owner: Owner;
111
+ readonly owner: Model<T>;
112
112
  readonly possibleStates: ActionStateName[];
113
113
  readonly state: ActionStateName;
114
114
  readonly abortController: null | AbortController;
@@ -181,7 +181,7 @@ declare type ActionValue = ActionPendingValue | ActionError | null;
181
181
  declare function createModel<Target extends ProtoModel>(protoModel: Target): Model<Target>;
182
182
 
183
183
  export declare type Model<T extends object = object> = ShallowReactive<{
184
- [K in keyof T]: T[K] extends ((...args: infer Args) => Promise<void>) ? SrActionLike<T, Args> : K extends ProtectedMethodInModel ? never : T[K];
184
+ [K in keyof T]: T[K] extends ((...args: infer Args) => Promise<void>) ? ActionLike<T, Args> : K extends ProtectedMethodInModel ? never : T[K];
185
185
  }>;
186
186
 
187
187
  export declare type ModelAdapterProxyConstructor = new <Target extends ProtoModel>(target: Target, handler: ProxyHandler<Target>) => Model<Target>;
@@ -204,8 +204,8 @@ export declare type ProtectedMethodInModel = 'action' | 'setActionState';
204
204
  export declare abstract class ProtoModel {
205
205
  protected [scopeKey]: EffectScope;
206
206
  protected [modelKey]: Model<this> | null;
207
- protected [actionsKey]: WeakMap<OriginalMethodWrapper<unknown[]>, SrActionLike<Model<this>>>;
208
- protected [actionIdsKey]: WeakMap<SrActionLike<Model<this>>, number>;
207
+ protected [actionsKey]: WeakMap<OriginalMethodWrapper<unknown[]>, ActionLike<this, unknown[]>>;
208
+ protected [actionIdsKey]: WeakMap<ActionLike<this, unknown[]>, number>;
209
209
  protected [actionStatesKey]: Map<"pending" | "error" | "lock" | "ready" | "abort", Ref<number>>;
210
210
  protected [actionsSizeKey]: number;
211
211
  protected [watchStopHandlersKey]: Set<WatchStopHandle>;
@@ -279,7 +279,7 @@ export declare abstract class ProtoModel {
279
279
  protected watch(...args: unknown[]): WatchStopHandle;
280
280
  protected computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
281
281
  protected updateBit(number: number, bitPosition: number, bitValue: boolean): number;
282
- protected createAction(actionFunction: OriginalMethodWrapper): SrActionLike<Model<this>>;
282
+ protected createAction(actionFunction: OriginalMethodWrapper): ActionLike<this>;
283
283
  protected getActionStatesRef(stateName: ActionStateName): Ref<number>;
284
284
  /**
285
285
  * Gets Action instance by wrapped original method or create Action instance.
@@ -324,26 +324,20 @@ export declare abstract class ProtoModel {
324
324
  * @param originalMethod - defined as OriginalMethod or OriginalMethodWrapper.
325
325
  * @returns action
326
326
  */
327
- protected action(originalMethod: OriginalMethod | OriginalMethodWrapper): SrActionLike<Model<this>>;
327
+ protected action(originalMethod: OriginalMethod | OriginalMethodWrapper): ActionLike<this>;
328
328
  /**
329
329
  * It is public method in context ProtoModel,
330
330
  * but in Model<ProtoModel> context it is protected method
331
331
  *
332
332
  * @see type Model<T>
333
333
  */
334
- setActionState(action: SrActionLike<Model<this>>): void;
334
+ setActionState(action: ActionLike<this>): void;
335
335
  isModelOf<T extends ProtoModel>(typeModel: ModelConstructor_2<T>): boolean;
336
336
  destructor(): void;
337
337
  }
338
338
 
339
339
  declare const scopeKey: unique symbol;
340
340
 
341
- /**
342
- * Reactive ActionLike type - ActionLike wrapped in ShallowReactive.
343
- * This is the type used throughout the codebase for action instances.
344
- */
345
- export declare type SrActionLike<Owner extends object, Args extends any[] = unknown[]> = ShallowReactive<ActionLike<Owner, Args>>;
346
-
347
341
  declare const watchStopHandlersKey: unique symbol;
348
342
 
349
343
  export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@vue-modeler/model",
4
- "version": "2.2.0-beta.3",
4
+ "version": "2.2.0-beta.4",
5
5
  "description": "A state management library based on models for Vue.js",
6
6
  "author": "abratko",
7
7
  "license": "MIT",