@expressive/mvc 0.88.0 → 0.89.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/state.d.ts CHANGED
@@ -3,13 +3,13 @@ import { event } from "./observable.js";
3
3
 
4
4
  //#region src/state.d.ts
5
5
  /** Internal state assigned to states. */
6
- declare const STORE: WeakMap<State, Record<string | number | symbol, unknown>>;
7
- /** States under construction - added on `new`, removed when activated or released.
6
+ declare const STORE: WeakMap<Model, Record<string | number | symbol, unknown>>;
7
+ /** Models under construction - added on `new`, removed when activated or released.
8
8
  * Also carries work to run at the deadline, which `def` uses to bound its registry. */
9
- declare const PENDING: Set<State | (() => void)>;
10
- /** External lifecycle listeners for any given State class. */
11
- type Handler = State.On<any>;
12
- declare const SETUP: WeakMap<State.Extends<State>, Set<Handler>>;
9
+ declare const PENDING: Set<Model | (() => void)>;
10
+ /** External lifecycle listeners for any given Model class. */
11
+ type Handler = Model.On<any>;
12
+ declare const SETUP: WeakMap<Model.Extends<Model>, Set<Handler>>;
13
13
  /** Reference bound instance methods, or their getter, to real one. */
14
14
  declare const UNBIND: WeakMap<any, any>;
15
15
  /** List of methods defined by a given type. */
@@ -18,43 +18,44 @@ declare const METHODS: WeakMap<Function, Map<string, (value: any) => void>>;
18
18
  declare const GETTERS: WeakMap<Function, Map<string, () => unknown>>;
19
19
  /** Replacement for a getter captured by live computed properties, for hot patching. */
20
20
  declare const LATEST: WeakMap<Function, Function>;
21
- declare namespace State {
22
- /** Any type of State, using own class constructor as its identifier. */
23
- type Extends<T extends State = State> = (abstract new (...args: any[]) => T) & typeof State;
24
- /** A State constructor which may be instanciated. */
25
- type Type<T extends State = State> = (new (...args: State.Args<T>) => T) & Omit<typeof State, never>;
26
- /** State constructor arguments */
27
- type Args<T extends State = any> = (Args<T> | Init<T> | Assign<T> | void)[];
21
+ type Overlay<T> = Record<string, unknown> & { [K in Model.Property<T>]?: T[K] extends ((...args: infer A) => infer R) ? (this: T, ...args: A) => R : T[K] };
22
+ declare namespace Model {
23
+ /** Any type of Model, using own class constructor as its identifier. */
24
+ type Extends<T extends Model = Model> = (abstract new (...args: any[]) => T) & typeof Model;
25
+ /** A Model constructor which may be instanciated. */
26
+ type Type<T extends Model = Model> = (new (...args: Model.Args<T>) => T) & Omit<typeof Model, never>;
27
+ /** Model constructor arguments */
28
+ type Args<T extends Model = any> = (Args<T> | Init<T> | Overlay<T> | void)[];
28
29
  /**
29
- * Value of `static global`. A boolean opts a State in or out of the
30
+ * Value of `static global`. A boolean opts a Model in or out of the
30
31
  * process-global root; a resolver decides at activation, receiving the
31
32
  * instance and returning whether it registers - use it to make the choice
32
33
  * conditional (e.g. per environment). A bare literal (`= true` / `= false`)
33
34
  * seals the choice for subclasses; widen a subclass's `static global` type to
34
- * `State.Global` to permit a resolver or a later override.
35
+ * `Model.Global` to permit a resolver or a later override.
35
36
  */
36
- type Global<T extends State = any> = boolean | ((self: T) => boolean);
37
+ type Global<T extends Model = any> = boolean | ((self: T) => boolean);
37
38
  /**
38
- * State constructor callback - runs during activation, in argument order,
39
+ * Model constructor callback - runs during activation, in argument order,
39
40
  * before the `new()` lifecycle hook (so it may configure state `new()`
40
41
  * will observe). Returned function will run when state is destroyed.
41
42
  */
42
- type Init<T extends State = State> = (this: T, thisArg: T) => Promise<void> | (() => void) | Args<T> | Assign<T> | void;
43
- /** Lifecycle handlers for `State.on`, keyed by when they run. */
44
- interface On<T extends State = State> {
43
+ type Init<T extends Model = Model> = (this: T, thisArg: T) => Promise<void> | (() => void) | Args<T> | Overlay<T> | void;
44
+ /** Lifecycle handlers for `Model.on`, keyed by when they run. */
45
+ interface On<T extends Model = Model> {
45
46
  /**
46
47
  * Per-class setup, run once when the class is first bootstrapped - before
47
48
  * its members are classified and bound. Receives the class, so a handler
48
49
  * may inspect or reshape the prototype first. A handler registered on a
49
50
  * base class runs for each subclass too.
50
51
  */
51
- type?(type: State.Extends<T>): void;
52
+ type?(type: Model.Extends<T>): void;
52
53
  /**
53
54
  * Per-instance, once constructed - before own values are observed and
54
55
  * before constructor args and `new()`. May return a cleanup, constructor
55
56
  * args, or an assign overlay.
56
57
  */
57
- setup?(this: T, self: T): void | (() => void) | Promise<void> | Args<T> | Assign<T>;
58
+ setup?(this: T, self: T): void | (() => void) | Promise<void> | Args<T> | Overlay<T>;
58
59
  /**
59
60
  * Per-instance, once ready - after own values are observed, constructor
60
61
  * args applied and `new()` has run. May return a cleanup function.
@@ -67,7 +68,7 @@ declare namespace State {
67
68
  */
68
69
  method?(this: T, key: string, fn: Function, self: T): void;
69
70
  /**
70
- * Receives what an effect, refreshing getter or async initializer of this State
71
+ * Receives what an effect, refreshing getter or async initializer of this Model
71
72
  * or a subclass threw, a destroyed write, or an instance never activated - with
72
73
  * its `kind` (`effect`, `getter`, `setup`, `dead`, `unused`) and `key` where
73
74
  * one applies. Most-derived class first, last registered first, each once. Return the error
@@ -78,17 +79,17 @@ declare namespace State {
78
79
  catch?(this: T, error: unknown, kind: 'effect' | 'getter' | 'setup' | 'dead' | 'unused', key?: string): unknown;
79
80
  }
80
81
  /** Object overlay to override values and methods on a state. */
81
- type Assign<T> = Record<string, unknown> & { [K in Property<T>]?: T[K] extends ((...args: infer A) => infer R) ? (this: T, ...args: A) => R : T[K] };
82
- /** Subset of `keyof T` not defined by base State. **/
83
- type Property<T> = Exclude<keyof T, keyof State>;
82
+ type Assign<T> = Record<string, unknown> & { [K in Property<T>]?: T[K] } & ThisType<T>;
83
+ /** Subset of `keyof T` not defined by base Model. **/
84
+ type Property<T> = Exclude<keyof T, keyof Model>;
84
85
  /** Managed subset of Property<T> - excludes unmanaged `_` keys. **/
85
86
  type Field<T> = Exclude<Property<T>, `_${string}`>;
86
87
  /** Any valid key for state, including but not limited to Field<T>. */
87
- type Event<T = State> = Field<T> | number | symbol | (string & {});
88
+ type Event<T = Model> = Field<T> | number | symbol | (string & {});
88
89
  /** Any event signal dispatched to listeners, including lifecycle meta events. */
89
- type Signal<T = State> = Event<T> | true | false | null;
90
- /** Export/Import compatible value for a given property in a State. */
91
- type Export<R> = R extends State ? Values<R> : R extends {
90
+ type Signal<T = Model> = Event<T> | true | false | null;
91
+ /** Export/Import compatible value for a given property in a Model. */
92
+ type Export<R> = R extends Model ? Values<R> : R extends {
92
93
  get(): infer T;
93
94
  } ? T : R;
94
95
  /**
@@ -100,18 +101,18 @@ declare namespace State {
100
101
  /** Object comperable to data found in T. */
101
102
  type Partial<T> = { [P in Field<T>]?: Export<T[P]> };
102
103
  /** Value for a property applied by a state. */
103
- type Value<T extends State, K extends State.Event<T>> = K extends keyof T ? Export<T[K]> : unknown;
104
+ type Value<T extends Model, K extends Model.Event<T>> = K extends keyof T ? Export<T[K]> : unknown;
104
105
  type Setter<T> = (value: T, previous: T) => T | void;
105
106
  /** Descriptor config for a managed property. */
106
107
  type Apply<T = any> = {
107
108
  value?: T;
108
- get?: ((source: State) => T) | boolean;
109
+ get?: ((source: Model) => T) | boolean;
109
110
  set?: Setter<T> | boolean;
110
111
  enumerable?: boolean;
111
112
  };
112
113
  /** Descriptor config for set() overload - enforces type when key is a known field. */
113
114
  type Define<T, K> = K extends Field<T> ? Apply<T[K] | Export<T[K]>> : Apply;
114
- type OnEvent<T extends State> = (this: T, key: Signal<T>, source: T) => void | (() => void) | null;
115
+ type OnEvent<T extends Model> = (this: T, key: Signal<T>, source: T) => void | (() => void) | null;
115
116
  /** Exotic value, where actual value is contained within. */
116
117
  type Ref<T = any> = {
117
118
  (next: T): void;
@@ -127,7 +128,13 @@ declare namespace State {
127
128
  *
128
129
  * @returns A callback function which will be called when this effect is stale.
129
130
  */
130
- type Effect<T> = (this: T, current: T, update: readonly State.Event<T>[] | undefined) => EffectCallback | Promise<void> | null | void;
131
+ type Effect<T, R = EffectCallback | Promise<void> | null | void> = (this: T, current: T, update: readonly Model.Event<T>[] | undefined) => R;
132
+ /**
133
+ * Returned by `get(effect)`. Call to stop the effect. Await to stop it once it
134
+ * has run clean and receive that run's value - a sync run's output, or what its
135
+ * promise resolved to.
136
+ */
137
+ type Release<R = void> = (() => void) & PromiseLike<R>;
131
138
  /**
132
139
  * A callback function returned by effect. Will be called when effect is stale.
133
140
  *
@@ -138,29 +145,29 @@ declare namespace State {
138
145
  * A list of keys updated, or events fired, since last update.
139
146
  * This may be awaited to get full list (same array) when update is settled.
140
147
  */
141
- type Updated<T extends State> = readonly Event<T>[] & PromiseLike<readonly Event<T>[]>;
148
+ type Updated<T extends Model> = readonly Event<T>[] & PromiseLike<readonly Event<T>[]>;
142
149
  }
143
- declare abstract class State {
150
+ declare abstract class Model {
144
151
  /**
145
152
  * Whether an instance activated with no enclosing context registers itself
146
153
  * to the process-global root, where `get()` can resolve it from anywhere.
147
154
  * `false` (the default) keeps a context-less instance fully functional but
148
155
  * private - not injectable, though it can still read declared globals. Opt in
149
- * with `static readonly global = true`; a resolver (see {@link State.Global})
156
+ * with `static readonly global = true`; a resolver (see {@link Model.Global})
150
157
  * makes the choice conditional. It must be declared per class - a subclass
151
158
  * that would inherit a global without its own declaration throws on
152
- * activation, so an accidental global (a forgotten `Provider`, an extended
153
- * global) cannot leak into the shared root.
159
+ * activation, so an accidental global (a forgotten `<Component for>`, an
160
+ * extended global) cannot leak into the shared root.
154
161
  */
155
- static readonly global: State.Global;
162
+ static readonly global: Model.Global;
156
163
  /**
157
164
  * Loopback to instance of this state. This is useful when in a subscribed context,
158
165
  * to keep write access to `this` after a destructure. You can use it to read variables silently as well.
159
166
  **/
160
167
  is: this;
161
- constructor(...args: State.Args);
168
+ constructor(...args: Model.Args);
162
169
  /**
163
- * Optional lifecycle hook called during State initialization.
170
+ * Optional lifecycle hook called during Model initialization.
164
171
  * Can return a cleanup function to run when state is destroyed.
165
172
  *
166
173
  * It is recommended you protect this method.
@@ -171,16 +178,23 @@ declare abstract class State {
171
178
  *
172
179
  * @returns Object with all values from this state.
173
180
  **/
174
- get(): State.Values<this>;
181
+ get(): Model.Values<this>;
175
182
  /**
176
183
  * Run a function to run automatically when accessed values change.
177
184
  *
178
185
  * @param effect Function to run, and whenever accessed values change.
179
186
  * If effect returns a function, it will be called when a change occurs (syncronously),
180
- * effect is cancelled, or parent state is destroyed.
181
- * @returns Function to cancel listener.
187
+ * effect is cancelled, or parent state is destroyed. A returned promise
188
+ * defers re-runs until it settles; its resolved value is treated the same way.
189
+ * @returns Function to cancel listener - awaited, cancels and yields the effect's value.
190
+ */
191
+ get(effect: Model.Effect<this>): Model.Release;
192
+ /**
193
+ * Run a function to run automatically when accessed values change, which
194
+ * produces a value - sync or async. Await the returned function to cancel the
195
+ * effect once a run completes and receive what it returned.
182
196
  */
183
- get(effect: State.Effect<this>): () => void;
197
+ get<R>(effect: Model.Effect<this, Promise<R>>): Model.Release<R>;
184
198
  /**
185
199
  * Get value of a property. Will fetch underlying value from exotic values like ref.Object.
186
200
  *
@@ -190,7 +204,7 @@ declare abstract class State {
190
204
  * @param required - If true, will throw an error if property is not available.
191
205
  * @returns Value of property.
192
206
  */
193
- get<T extends State.Event<this>>(key: T, required?: boolean): State.Value<this, T>;
207
+ get<T extends Model.Event<this>>(key: T, required?: boolean): Model.Value<this, T>;
194
208
  /**
195
209
  * Check if state is destroyed.
196
210
  *
@@ -205,42 +219,42 @@ declare abstract class State {
205
219
  * @returns Function to cancel listener.
206
220
  */
207
221
  get(status: null, callback: () => void): () => void;
208
- /** Fetch State of type from context. Throws if not found. */
209
- get<T extends State>(type: State.Type<T>, required?: true): T;
210
- /** Fetch a State from context. Undefined if not found. */
211
- get<T extends State>(type: State.Type<T>, required: boolean): T | undefined;
222
+ /** Fetch Model of type from context. Throws if not found. */
223
+ get<T extends Model>(type: Model.Type<T>, required?: true): T;
224
+ /** Fetch a Model from context. Undefined if not found. */
225
+ get<T extends Model>(type: Model.Type<T>, required: boolean): T | undefined;
212
226
  /**
213
- * Subscribe to State becoming available in context.
227
+ * Subscribe to Model becoming available in context.
214
228
  *
215
229
  * Will search both up and downstream by default.
216
- * Normally you can ignore this because State you expect is rarely both.
230
+ * Normally you can ignore this because Model you expect is rarely both.
217
231
  *
218
- * Specify downstream if you only want to watch for State in children, which can be useful if you expect multiple of the same State in different branches of the tree.
232
+ * Specify downstream if you only want to watch for Model in children, which can be useful if you expect multiple of the same Model in different branches of the tree.
219
233
  *
220
- * @param type - Type of State to watch for.
221
- * @param callback - Function to call when State is found. Will be called immediately if State is already available.
222
- * @param downstream - If true, will only watch for State in children, if false will only for parents.
234
+ * @param type - Type of Model to watch for.
235
+ * @param callback - Function to call when Model is found. Will be called immediately if Model is already available.
236
+ * @param downstream - If true, will only watch for Model in children, if false will only for parents.
223
237
  * @returns Function to cancel listener.
224
238
  */
225
- get<T extends State>(type: State.Type<T>, callback: Context.Expect<T>, downstream?: boolean): () => void;
226
- /** Owner of this State. Throws if it has none. */
227
- get<T extends typeof State>(type: T & (typeof State extends T ? unknown : never), required?: true): State;
228
- /** Owner of this State. Undefined if it has none. */
229
- get<T extends typeof State>(type: T & (typeof State extends T ? unknown : never), required: boolean): State | undefined;
239
+ get<T extends Model>(type: Model.Type<T>, callback: Context.Expect<T>, downstream?: boolean): () => void;
240
+ /** Owner of this Model. Throws if it has none. */
241
+ get<T extends typeof Model>(type: T & (typeof Model extends T ? unknown : never), required?: true): Model;
242
+ /** Owner of this Model. Undefined if it has none. */
243
+ get<T extends typeof Model>(type: T & (typeof Model extends T ? unknown : never), required: boolean): Model | undefined;
230
244
  /**
231
- * Run a callback for each State this one owns - those owned now, then each
232
- * one as it activates. Callback may return a function, called when that State
245
+ * Run a callback for each Model this one owns - those owned now, then each
246
+ * one as it activates. Callback may return a function, called when that Model
233
247
  * is destroyed.
234
248
  *
235
249
  * @returns Function to stop watching.
236
250
  */
237
- get<T extends typeof State>(type: T & (typeof State extends T ? unknown : never), callback: (child: State) => void | (() => void), downstream: true): () => void;
251
+ get<T extends typeof Model>(type: T & (typeof Model extends T ? unknown : never), callback: (child: Model) => void | (() => void), downstream: true): () => void;
238
252
  /**
239
253
  * Get update in progress.
240
254
  *
241
255
  * @returns Promise which resolves object with updated values, `undefined` if there no update is pending.
242
256
  **/
243
- set(): State.Updated<this>;
257
+ set(): Model.Updated<this>;
244
258
  /**
245
259
  * Merge argument with current state, updating one or more properties at once.
246
260
  * Properties which are not managed by this state will be ignored.
@@ -249,7 +263,7 @@ declare abstract class State {
249
263
  * @param silent - If true, listeners will not be notified. If state is destroyed, stores the update without reporting it.
250
264
  * @returns Array of keys updated, syncronously contains keys updated immediately and may be resolved (to itself) when all updates are settled.
251
265
  */
252
- set(assign?: State.Assign<this>, silent?: boolean): State.Updated<this>;
266
+ set(assign?: Model.Assign<this>, silent?: boolean): Model.Updated<this>;
253
267
  /**
254
268
  * Call a function when update occurs.
255
269
  *
@@ -263,7 +277,7 @@ declare abstract class State {
263
277
  * @param callback - Function to call when update occurs.
264
278
  * @returns Function to remove listener. Will return `true` if removed, `false` if inactive already.
265
279
  */
266
- set(callback: State.OnEvent<this>): () => boolean;
280
+ set(callback: Model.OnEvent<this>): () => boolean;
267
281
  /**
268
282
  * Push an update. This will not change the value of associated property.
269
283
  *
@@ -278,7 +292,7 @@ declare abstract class State {
278
292
  * @param key - Property or event to dispatch.
279
293
  * @returns Promise resolves an array of keys updated.
280
294
  */
281
- set(key: State.Event<this>): State.Updated<this>;
295
+ set(key: Model.Event<this>): Model.Updated<this>;
282
296
  /**
283
297
  * Declare an end to updates. This event is final - later writes are stored but never dispatched.
284
298
  * This event can be watched for as well, to run cleanup logic and internally will remove all listeners.
@@ -295,7 +309,7 @@ declare abstract class State {
295
309
  * @param callback - Function to call when event occurs.
296
310
  * @returns Function to remove listener.
297
311
  */
298
- set<K extends State.Event<this>>(event: K | null, callback: State.OnEvent<this>): () => boolean;
312
+ set<K extends Model.Event<this>>(event: K | null, callback: Model.OnEvent<this>): () => boolean;
299
313
  /**
300
314
  * Define or update a managed property using a descriptor config.
301
315
  * If the property already is managed, config will only accept value.
@@ -305,9 +319,9 @@ declare abstract class State {
305
319
  * @param config - Descriptor config with value, get, set, enumerable, and/or destroy.
306
320
  * @returns Promise resolves an array of keys updated.
307
321
  */
308
- set<K extends State.Event<this>>(key: K, config: State.Define<this, K>): State.Updated<this>;
322
+ set<K extends Model.Event<this>>(key: K, config: Model.Define<this, K>): Model.Updated<this>;
309
323
  /**
310
- * Iterate over managed properties in this instance of State.
324
+ * Iterate over managed properties in this instance of Model.
311
325
  * Yeilds the key and current value for each property.
312
326
  */
313
327
  [Symbol.iterator](): Iterator<[string, unknown]>;
@@ -318,16 +332,16 @@ declare abstract class State {
318
332
  *
319
333
  * @param args - arguments sent to constructor
320
334
  */
321
- static new<T extends State>(this: State.Type<T>, ...args: State.Args<T>): T;
335
+ static new<T extends Model>(this: Model.Type<T>, ...args: Model.Args<T>): T;
322
336
  /**
323
337
  * Static equivalent of `x instanceof this`.
324
338
  * Determines if provided class is a subtype of this one.
325
339
  * If so, language server will make available all static
326
340
  * methods and properties of this class.
327
341
  */
328
- static is<T extends State.Extends>(this: T, maybe: unknown): maybe is T;
342
+ static is<T extends Model.Extends>(this: T, maybe: unknown): maybe is T;
329
343
  /**
330
- * Register a lifecycle handler for this State and its subclasses.
344
+ * Register a lifecycle handler for this Model and its subclasses.
331
345
  *
332
346
  * Hooks by cadence - `type` (per-class, at bootstrap), `setup` (per-instance,
333
347
  * before values are observed), `ready` (per-instance, after `new()`), and
@@ -336,11 +350,11 @@ declare abstract class State {
336
350
  *
337
351
  * @returns Function to remove the handler.
338
352
  */
339
- static on<T extends State>(this: State.Extends<T>, setup: NonNullable<State.On<T>['setup']>): () => boolean;
340
- static on<T extends State>(this: State.Extends<T>, handler: State.On<T>): () => boolean;
353
+ static on<T extends Model>(this: Model.Extends<T>, setup: NonNullable<Model.On<T>['setup']>): () => boolean;
354
+ static on<T extends Model>(this: Model.Extends<T>, handler: Model.On<T>): () => boolean;
341
355
  }
342
356
  /** Bind own configurable methods of a type and collect its reactive getters. */
343
- declare function classify(type: State.Extends, keys: Map<string, (value: any) => void>, getters: Map<string, () => unknown>): void;
357
+ declare function classify(type: Model.Extends, keys: Map<string, (value: any) => void>, getters: Map<string, () => unknown>): void;
344
358
  /**
345
359
  * Install a reactive computed property on a state instance, derived from a prototype
346
360
  * getter or an arity-bearing `set` factory.
@@ -349,34 +363,34 @@ declare function classify(type: State.Extends, keys: Map<string, (value: any) =>
349
363
  * reads of managed properties through it create subscriptions. Result is cached and
350
364
  * emits a keyed event when stale.
351
365
  */
352
- declare function compute(this: State, getter: (self: any) => unknown, key: string): void;
366
+ declare function compute(this: Model, getter: (self: any) => unknown, key: string): void;
353
367
  /**
354
368
  * Define or update a managed property using a descriptor config.
355
369
  * If the property already is managed, config will only accept value.
356
370
  * If the property does not exist, it will be created and made reactive.
357
371
  *
358
- * @param state - State to apply property to.
372
+ * @param state - Model to apply property to.
359
373
  * @param key - Property to define or update.
360
374
  * @param config - Descriptor config with value, get, set, enumerable, and/or destroy.
361
375
  * @param silent - If an update does occur, listeners will not be refreshed automatically.
362
376
  */
363
- declare function apply(state: State, key: string, config: State.Apply, silent?: boolean): void;
377
+ declare function apply(state: Model, key: string, config: Model.Apply, silent?: boolean): void;
364
378
  /**
365
- * Pending States constructed after this one - in a parent, the products of
379
+ * Pending Models constructed after this one - in a parent, the products of
366
380
  * its own initializers, until the last one it kept.
367
381
  */
368
- declare function trailing(state: State): State[];
382
+ declare function trailing(state: Model): Model[];
369
383
  /**
370
- * Report States adopted by a parent - those already held, then each one
384
+ * Report Models adopted by a parent - those already held, then each one
371
385
  * claimed later. Returns a callback to stop watching.
372
386
  */
373
- declare function children(state: State, callback: (child: State) => void): () => boolean;
387
+ declare function children(state: Model, callback: (child: Model) => void): () => boolean;
374
388
  /**
375
- * Report States owned by this one - those active now, then each one as it
376
- * activates. A function returned by `callback` runs when that State is destroyed.
389
+ * Report Models owned by this one - those active now, then each one as it
390
+ * activates. A function returned by `callback` runs when that Model is destroyed.
377
391
  */
378
- declare function owned(state: State, callback: (child: State) => void | (() => void)): () => undefined;
379
- declare function access(state: State, property: string, required?: boolean): any;
392
+ declare function owned(state: Model, callback: (child: Model) => void | (() => void)): () => undefined;
393
+ declare function access(state: Model, property: string, required?: boolean): any;
380
394
  /**
381
395
  * Update a property on a state instance and notify listeners.
382
396
  *
@@ -384,14 +398,14 @@ declare function access(state: State, property: string, required?: boolean): any
384
398
  *
385
399
  * A destroyed state stores the write without dispatch, reports it unless `silent`, and returns `false`.
386
400
  */
387
- declare function update<T>(state: State, key: State.Event<T>, value: T, silent?: boolean, own?: boolean): boolean;
401
+ declare function update<T>(state: Model, key: Model.Event<T>, value: T, silent?: boolean, own?: boolean): boolean;
388
402
  /**
389
403
  * Hand a value stored by an owning writer to that property's adopter,
390
- * creating one the first time a State is stored there. A property which has
391
- * held a State keeps its adopter, so a later non-State value releases the
404
+ * creating one the first time a Model is stored there. A property which has
405
+ * held a Model keeps its adopter, so a later non-Model value releases the
392
406
  * previous child.
393
407
  */
394
- declare function adopt(state: State, key: unknown, value: unknown): void;
408
+ declare function adopt(state: Model, key: unknown, value: unknown): void;
395
409
  /** Random alphanumberic of length 6; always starts with a letter. */
396
410
  declare function uid(): string;
397
411
  declare function unbind<T extends Function>(fn: T): T;
@@ -402,8 +416,8 @@ declare function unbind<T extends Function>(fn?: T): T | undefined;
402
416
  * only if unclaimed and returns whether the assignment applied - `true` means
403
417
  * this call freshly claimed it, `false` means it was already parented.
404
418
  */
405
- declare function parent(child: object): State | null | undefined;
406
- declare function parent(child: object, value: State | null): boolean;
419
+ declare function parent(child: object): Model | null | undefined;
420
+ declare function parent(child: object, value: Model | null): boolean;
407
421
  //#endregion
408
- export { GETTERS, type Handler, LATEST, METHODS, PENDING, SETUP, STORE, State, UNBIND, access, adopt, apply, children, classify, compute, event, owned, parent, trailing, uid, unbind, update };
422
+ export { GETTERS, type Handler, LATEST, METHODS, Model, PENDING, SETUP, STORE, UNBIND, access, adopt, apply, children, classify, compute, event, owned, parent, trailing, uid, unbind, update };
409
423
  //# sourceMappingURL=state.d.ts.map