@expressive/mvc 0.49.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -61,21 +61,19 @@ declare namespace Model {
61
61
  * @param update - `true` if update is pending, `false` effect has been cancelled, `null` if controller is destroyed.
62
62
  */
63
63
  type EffectCallback = ((update: boolean | null) => void);
64
- namespace Instruction {
65
- type Getter<T> = (source: Model) => T;
66
- type Setter<T> = (value: T, previous: T) => boolean | void | (() => T);
67
- type Descriptor<T = any> = {
68
- get?: Getter<T> | boolean;
69
- set?: Setter<T> | false;
70
- enumerable?: boolean;
71
- value?: T;
72
- };
73
- }
74
64
  /**
75
65
  * Property initializer, will run upon instance creation.
76
66
  * Optional returned callback will run when once upon first access.
77
67
  */
78
- type Instruction<T = any, M extends Model = any> = (this: M, key: Field<M> & string, thisArg: M, state: State<M>) => Instruction.Descriptor<T> | Instruction.Getter<T> | void;
68
+ type Instruction<T = any, M extends Model = any> = (this: M, key: Field<M> & string, thisArg: M, state: State<M>) => Descriptor<T> | Getter<T> | void;
69
+ type Getter<T> = (source: Model) => T;
70
+ type Setter<T> = (value: T, previous: T) => boolean | void | (() => T);
71
+ type Descriptor<T = any> = {
72
+ get?: Getter<T> | boolean;
73
+ set?: Setter<T> | false;
74
+ enumerable?: boolean;
75
+ value?: T;
76
+ };
79
77
  }
80
78
  interface Model {
81
79
  /**
@@ -309,7 +307,7 @@ declare function ref<T = HTMLElement>(callback: ref.Callback<T | null>, ignoreNu
309
307
 
310
308
  declare namespace set {
311
309
  type Callback<T, S = any> = (this: S, next: T, previous: T) => ((next: T) => void) | Promise<any> | void | boolean;
312
- type Factory<T, S = any> = (this: S, key: string, thisArg: S) => Promise<T> | T;
310
+ type Factory<T, S = any> = (this: S, key: string) => Promise<T> | T;
313
311
  }
314
312
  /**
315
313
  * Set property with a placeholder.
@@ -348,11 +346,10 @@ declare function use<T extends Model>(Type: Model.Type<T>, required: false): T |
348
346
  declare function use<T extends Model>(Type: Model.Type<T>, ready?: (i: T) => void): T;
349
347
 
350
348
  declare namespace has {
351
- type Callback<T = any> = (model: T) => void | boolean | (() => void);
349
+ type Callback<T = any> = (model: T, recipient: Model) => void | boolean | (() => void);
352
350
  }
353
- declare function has<T extends Model>(type: Model.Type<T>, one: true): T;
354
- declare function has<T extends Model>(type: Model.Type<T>, required: boolean): T | undefined;
355
- declare function has<T extends Model>(type: Model.Type<T>, arg?: has.Callback<T>): Set<T>;
351
+ declare function has<T extends Model>(type: Model.Type<T>, callback?: has.Callback<T>): readonly T[];
352
+ declare function has(callback?: has.Callback): readonly Model[];
356
353
 
357
354
  type Effect<T extends {}> = (this: T, argument: T) => ((update: boolean | null) => void) | Promise<void> | null | void;
358
355
  /**
@@ -368,23 +365,23 @@ declare function effect<T extends {}>(target: T, callback: Effect<T>, requireVal
368
365
 
369
366
  declare namespace Context {
370
367
  type Input = Record<string | number, Model | Model.Type<Model>>;
368
+ type Expect = (model: Model) => (() => void) | void;
371
369
  }
372
370
  declare class Context {
373
371
  static get<T extends Model>(on: Model, callback: ((got: Context) => void)): void;
374
372
  static get<T extends Model>(on: Model): Context | undefined;
375
373
  id: string;
376
- protected downstream: WeakMap<Model.Type<Model>, symbol>;
377
- protected upstream: WeakMap<Model.Type<Model>, symbol>;
378
374
  protected layer: Map<string | number, Model | Model.Type<Model>>;
375
+ protected cleanup: Set<() => void>;
379
376
  constructor(inputs?: Context.Input);
380
- key(T: Model.Type, upstream?: boolean): keyof this;
381
- has(model: Model): (() => void) | undefined;
382
377
  get<T extends Model>(Type: Model.Type<T>): T | undefined;
383
- include(inputs: Context.Input, forEach?: (added: Model, explicit: boolean) => void): void;
384
- put<T extends Model>(T: Model.Type<T>, I: T | ((model: T) => void), implicit?: boolean, writable?: boolean): void;
385
- add<T extends Model>(input: T | Model.Type<T>, implicit?: boolean): T;
378
+ get<T extends Model>(Type: Model.Type<T>, callback: (model: T) => void): void;
386
379
  push(inputs?: Context.Input): this;
387
380
  pop(): void;
381
+ include(inputs: Context.Input, forEach?: (added: Model, explicit: boolean) => void): void;
382
+ protected add<T extends Model>(input: T | Model.Type<T>, implicit?: boolean): T;
383
+ protected has<T extends Model>(type: Model.Type<T>, model: T): void;
384
+ protected put<T extends Model>(T: Model.Type<T>, I: T | ((model: T) => void), implicit?: boolean): void;
388
385
  }
389
386
 
390
387
  declare global {