@jbrowse/mobx-state-tree 6.5.2 → 6.6.1
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/CHANGELOG.md +33 -0
- package/dist/index.d.ts +151 -116
- package/dist/mobx-state-tree.cjs +416 -386
- package/dist/mobx-state-tree.cjs.map +1 -1
- package/dist/mobx-state-tree.mjs +413 -388
- package/dist/mobx-state-tree.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## [6.6.1](https://github.com/GMOD/mobx-state-tree/compare/v6.6.0...v6.6.1) (2026-09-25)
|
|
2
|
+
|
|
3
|
+
### Performance Improvements
|
|
4
|
+
|
|
5
|
+
- Reconcile children in linear time ([530e27f](https://github.com/GMOD/mobx-state-tree/commit/530e27f20046ba449d45c2724106fcb5b4133e06))
|
|
6
|
+
|
|
7
|
+
### Tests
|
|
8
|
+
|
|
9
|
+
- Typecheck the reconcile tests; add pnpm typecheck to the verification norm ([a23e4f3](https://github.com/GMOD/mobx-state-tree/commit/a23e4f34f718dfd398b696ca5e36be88bbe52454))
|
|
10
|
+
|
|
11
|
+
## [6.6.0](https://github.com/GMOD/mobx-state-tree/compare/v6.5.2...v6.6.0) (2026-09-24)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- Stop overwriting the wrapped type's create ([f8a73dc](https://github.com/GMOD/mobx-state-tree/commit/f8a73dc2f1963828ac51d8bf7ef3ee18d2bb416a))
|
|
16
|
+
- Invalidate references whose target leaves with an ancestor ([fb1a8ee](https://github.com/GMOD/mobx-state-tree/commit/fb1a8ee3d2b73e4793737b8061ad2fa1ddf088aa))
|
|
17
|
+
|
|
18
|
+
### Documentation
|
|
19
|
+
|
|
20
|
+
- ADRs for the guard and processor-typing decisions; refresh CLAUDE.md ([a6a1776](https://github.com/GMOD/mobx-state-tree/commit/a6a17769cf715b8a2a8807e110ceedcda34680af))
|
|
21
|
+
|
|
22
|
+
### Refactoring
|
|
23
|
+
|
|
24
|
+
- Chain snapshot processors only where there are two ([133a750](https://github.com/GMOD/mobx-state-tree/commit/133a75096a5a266ac31cfd75730e9cd35fdae135))
|
|
25
|
+
- Dedupe the node lifecycle and drop dead weight ([0f3f682](https://github.com/GMOD/mobx-state-tree/commit/0f3f68216b84d2080793f8b141ea4033d2c6f528))
|
|
26
|
+
|
|
27
|
+
### Types
|
|
28
|
+
|
|
29
|
+
- Infer enumeration members, export what public signatures name ([ba784a6](https://github.com/GMOD/mobx-state-tree/commit/ba784a6bbc750bc3e361273330d0be054264202e))
|
|
30
|
+
- Variadic signatures in place of the generated overloads ([c8d062d](https://github.com/GMOD/mobx-state-tree/commit/c8d062d14fadc99c93dfd2c05fb2dd444f813227))
|
|
31
|
+
- Snapshot processors pass through keys they do not own ([bc6c747](https://github.com/GMOD/mobx-state-tree/commit/bc6c7479f5b362c94db5d81de00afaad88c87d56))
|
|
32
|
+
- IsArrayType/isMapType/isModelType stop narrowing unsoundly ([540e9f7](https://github.com/GMOD/mobx-state-tree/commit/540e9f74a5878d8c817dbc3521c42ef6a984ab0b))
|
|
33
|
+
|
|
1
34
|
## [6.5.2](https://github.com/GMOD/mobx-state-tree/compare/v6.3.1...v6.5.2) (2026-09-19)
|
|
2
35
|
|
|
3
36
|
### Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -339,7 +339,9 @@ declare function tryResolve<T = any>(target: IAnyStateTreeNode, path: string): T
|
|
|
339
339
|
declare function getRelativePath(base: IAnyStateTreeNode, target: IAnyStateTreeNode): string;
|
|
340
340
|
/**
|
|
341
341
|
* Returns a deep copy of the given state tree node as new tree.
|
|
342
|
-
*
|
|
342
|
+
* Like `getType(x).create(getSnapshot(x))`, except that a node wrapped in a
|
|
343
|
+
* `types.snapshotProcessor` is recreated through the processor, which
|
|
344
|
+
* `getType(x)` (the wrapped type) would skip.
|
|
343
345
|
*
|
|
344
346
|
* _Tip: clone will create a literal copy, including the same identifiers. To modify identifiers etc. during cloning, don't use clone but take a snapshot of the tree, modify it, and create new instance_
|
|
345
347
|
*
|
|
@@ -515,13 +517,7 @@ declare function castToReferenceSnapshot<I>(instance: I): Extract<I, IAnyStateTr
|
|
|
515
517
|
*/
|
|
516
518
|
declare function getNodeId(target: IAnyStateTreeNode): number;
|
|
517
519
|
|
|
518
|
-
type
|
|
519
|
-
[Hook.afterAttach]: (node: AnyNode, hook: Hook) => void;
|
|
520
|
-
[Hook.afterCreate]: (node: AnyNode, hook: Hook) => void;
|
|
521
|
-
[Hook.afterCreationFinalization]: (node: AnyNode, hook: Hook) => void;
|
|
522
|
-
[Hook.beforeDestroy]: (node: AnyNode, hook: Hook) => void;
|
|
523
|
-
[Hook.beforeDetach]: (node: AnyNode, hook: Hook) => void;
|
|
524
|
-
};
|
|
520
|
+
type HookSubscriber = (subject: AnyNode, hook: Hook) => void;
|
|
525
521
|
/**
|
|
526
522
|
* @internal
|
|
527
523
|
* @hidden
|
|
@@ -544,8 +540,16 @@ declare abstract class BaseNode<C, S, T> {
|
|
|
544
540
|
set state(val: NodeLifeCycle);
|
|
545
541
|
private _hookSubscribers?;
|
|
546
542
|
protected abstract fireHook(name: Hook): void;
|
|
547
|
-
protected fireInternalHook(name: Hook): void;
|
|
548
|
-
|
|
543
|
+
protected fireInternalHook(name: Hook, subject?: AnyNode): void;
|
|
544
|
+
/**
|
|
545
|
+
* Detaching a node takes its whole subtree out of the tree, but only the
|
|
546
|
+
* detached node's parent changes, so only it fires `beforeDetach` for real.
|
|
547
|
+
* Internal subscribers below it (reference watchers on a target) still need
|
|
548
|
+
* to know their node is leaving.
|
|
549
|
+
*/
|
|
550
|
+
notifyDetachOf(subject: AnyObjectNode): void;
|
|
551
|
+
isWithin(ancestor: AnyNode): boolean;
|
|
552
|
+
registerHook(hook: Hook, hookHandler: HookSubscriber): IDisposer;
|
|
549
553
|
private _parent;
|
|
550
554
|
get parent(): AnyObjectNode | null;
|
|
551
555
|
constructor(type: IAnyType, parent: AnyObjectNode | null, subpath: string, environment: any);
|
|
@@ -562,7 +566,7 @@ declare abstract class BaseNode<C, S, T> {
|
|
|
562
566
|
get isAlive(): boolean;
|
|
563
567
|
get isDetaching(): boolean;
|
|
564
568
|
get observableIsAlive(): boolean;
|
|
565
|
-
|
|
569
|
+
die(): void;
|
|
566
570
|
abstract finalizeCreation(): void;
|
|
567
571
|
protected baseFinalizeCreation(whenFinalized?: () => void): void;
|
|
568
572
|
abstract finalizeDeath(): void;
|
|
@@ -598,6 +602,7 @@ declare class ObjectNode<C, S, T> extends BaseNode<C, S, T> {
|
|
|
598
602
|
isProtectionEnabled: boolean;
|
|
599
603
|
middlewares?: IMiddleware[];
|
|
600
604
|
hasSnapshotPostProcessor: boolean;
|
|
605
|
+
snapshotProcessorType?: IAnyType;
|
|
601
606
|
private _applyPatches?;
|
|
602
607
|
applyPatches(patches: ReadonlyArray<IJsonPatch>): void;
|
|
603
608
|
private _applySnapshot?;
|
|
@@ -617,6 +622,8 @@ declare class ObjectNode<C, S, T> extends BaseNode<C, S, T> {
|
|
|
617
622
|
createObservableInstance(fireHooks?: boolean): void;
|
|
618
623
|
get root(): AnyObjectNode;
|
|
619
624
|
clearParent(): void;
|
|
625
|
+
notifyDetachOf(subject: AnyObjectNode): void;
|
|
626
|
+
private notifyChildrenOfDetach;
|
|
620
627
|
setParent(newParent: AnyObjectNode, subpath: string): void;
|
|
621
628
|
protected fireHook(name: Hook): void;
|
|
622
629
|
private _snapshotUponDeath?;
|
|
@@ -649,7 +656,6 @@ declare class ObjectNode<C, S, T> extends BaseNode<C, S, T> {
|
|
|
649
656
|
finalizeCreation(): void;
|
|
650
657
|
detach(): void;
|
|
651
658
|
private preboot;
|
|
652
|
-
die(): void;
|
|
653
659
|
aboutToDie(): void;
|
|
654
660
|
finalizeDeath(): void;
|
|
655
661
|
onSnapshot(onChange: (snapshot: S) => void): IDisposer;
|
|
@@ -665,13 +671,7 @@ declare class ObjectNode<C, S, T> extends BaseNode<C, S, T> {
|
|
|
665
671
|
private _addSnapshotReaction;
|
|
666
672
|
private _removeSnapshotReaction;
|
|
667
673
|
private _internalEvents?;
|
|
668
|
-
private
|
|
669
|
-
private _internalEventsRegister;
|
|
670
|
-
private _internalEventsHas;
|
|
671
|
-
private _internalEventsUnregister;
|
|
672
|
-
private _internalEventsEmit;
|
|
673
|
-
private _internalEventsClear;
|
|
674
|
-
private _internalEventsClearAll;
|
|
674
|
+
private internalEvents;
|
|
675
675
|
}
|
|
676
676
|
/**
|
|
677
677
|
* @internal
|
|
@@ -735,9 +735,12 @@ interface IType<C, S, T> {
|
|
|
735
735
|
/** @hidden */
|
|
736
736
|
readonly [$type]: undefined;
|
|
737
737
|
/**
|
|
738
|
-
* Friendly type name.
|
|
738
|
+
* Friendly type name. Read-only: types are shared (unions built from the
|
|
739
|
+
* same members are the same object), so renaming one renames it everywhere.
|
|
740
|
+
* Name a type where it is built instead — `types.model(name, ...)`,
|
|
741
|
+
* `.named()`, or the `name` option of `union`/`snapshotProcessor`.
|
|
739
742
|
*/
|
|
740
|
-
name: string;
|
|
743
|
+
readonly name: string;
|
|
741
744
|
/**
|
|
742
745
|
* Name of the identifier attribute or null if none.
|
|
743
746
|
*/
|
|
@@ -997,6 +1000,24 @@ declare abstract class ComplexType<C, S, T> extends BaseType<C, S, T, ObjectNode
|
|
|
997
1000
|
* @returns `true` if the value is a type.
|
|
998
1001
|
*/
|
|
999
1002
|
declare function isType(value: unknown): value is IAnyType;
|
|
1003
|
+
/**
|
|
1004
|
+
* The one type a wrapper hands everything to: what an `optional`,
|
|
1005
|
+
* `stripDefault`, `refinement`, `snapshotProcessor` or (resolved) `late`
|
|
1006
|
+
* wraps. `undefined` for any other type, including a union or a `resilient`,
|
|
1007
|
+
* which pick a type per value.
|
|
1008
|
+
*
|
|
1009
|
+
* Resolves a `late` type's definition if it has not been read yet.
|
|
1010
|
+
*/
|
|
1011
|
+
declare function getWrappedType(type: IAnyType): IAnyType | undefined;
|
|
1012
|
+
/**
|
|
1013
|
+
* Strips every wrapper {@link getWrappedType} sees through, down to the type
|
|
1014
|
+
* that actually builds the value: for a complex type `T`,
|
|
1015
|
+
* `getType(T.create(snapshot)) === unwrapType(T)`.
|
|
1016
|
+
*
|
|
1017
|
+
* `types.model({ xs: types.array(X) }).properties.xs`, for instance, is an
|
|
1018
|
+
* `optional` whose unwrapped type is the array type.
|
|
1019
|
+
*/
|
|
1020
|
+
declare function unwrapType(type: IAnyType): IAnyType;
|
|
1000
1021
|
|
|
1001
1022
|
interface IActionTrackingMiddlewareHooks<T> {
|
|
1002
1023
|
filter?: (call: IMiddlewareEvent) => boolean;
|
|
@@ -1574,12 +1595,15 @@ interface IMSTMap<IT extends IAnyType> {
|
|
|
1574
1595
|
*/
|
|
1575
1596
|
declare function map<IT extends IAnyType>(subtype: IT): IMapType<IT>;
|
|
1576
1597
|
/**
|
|
1577
|
-
* Returns if a
|
|
1578
|
-
*
|
|
1579
|
-
* @param type
|
|
1580
|
-
* @returns `true` if it is a map type.
|
|
1598
|
+
* Returns if a type is a map type, or wraps or unions one. For the map type
|
|
1599
|
+
* itself, use {@link asMapType}.
|
|
1581
1600
|
*/
|
|
1582
|
-
declare function isMapType
|
|
1601
|
+
declare function isMapType(type: IAnyType): boolean;
|
|
1602
|
+
/**
|
|
1603
|
+
* The map type `type` builds its values with, seeing through the wrappers
|
|
1604
|
+
* {@link unwrapType} does, or `undefined` if that is not a map type.
|
|
1605
|
+
*/
|
|
1606
|
+
declare function asMapType(type: IAnyType): IMapType<IAnyType> | undefined;
|
|
1583
1607
|
|
|
1584
1608
|
/** @hidden */
|
|
1585
1609
|
interface IMSTArray<IT extends IAnyType> extends IObservableArray<IT["Type"]> {
|
|
@@ -1597,7 +1621,7 @@ interface IMSTArray<IT extends IAnyType> extends IObservableArray<IT["Type"]> {
|
|
|
1597
1621
|
}
|
|
1598
1622
|
/** @hidden */
|
|
1599
1623
|
interface IArrayType<IT extends IAnyType> extends IType<readonly IT["CreationType"][] | undefined, IT["SnapshotType"][], IMSTArray<IT>> {
|
|
1600
|
-
hooks(hooks: IHooksGetter<IMSTArray<
|
|
1624
|
+
hooks(hooks: IHooksGetter<IMSTArray<IT>>): IArrayType<IT>;
|
|
1601
1625
|
/** the element type of the array */
|
|
1602
1626
|
getChildType(): IAnyType;
|
|
1603
1627
|
}
|
|
@@ -1627,12 +1651,15 @@ interface IArrayType<IT extends IAnyType> extends IType<readonly IT["CreationTyp
|
|
|
1627
1651
|
*/
|
|
1628
1652
|
declare function array<IT extends IAnyType>(subtype: IT): IArrayType<IT>;
|
|
1629
1653
|
/**
|
|
1630
|
-
* Returns if a
|
|
1631
|
-
*
|
|
1632
|
-
|
|
1633
|
-
|
|
1654
|
+
* Returns if a type is an array type, or wraps or unions one. For the array
|
|
1655
|
+
* type itself, use {@link asArrayType}.
|
|
1656
|
+
*/
|
|
1657
|
+
declare function isArrayType(type: IAnyType): boolean;
|
|
1658
|
+
/**
|
|
1659
|
+
* The array type `type` builds its values with, seeing through the wrappers
|
|
1660
|
+
* {@link unwrapType} does, or `undefined` if that is not an array type.
|
|
1634
1661
|
*/
|
|
1635
|
-
declare function
|
|
1662
|
+
declare function asArrayType(type: IAnyType): IArrayType<IAnyType> | undefined;
|
|
1636
1663
|
|
|
1637
1664
|
/** @hidden */
|
|
1638
1665
|
interface ModelProperties {
|
|
@@ -1693,6 +1720,16 @@ type ExtractCFromProps<P extends ModelProperties> = {
|
|
|
1693
1720
|
*/
|
|
1694
1721
|
type _OverrideProps<PA extends ModelProperties, PB extends ModelProperties> = Omit<PA, keyof PB> & PB;
|
|
1695
1722
|
/** @hidden */
|
|
1723
|
+
type _IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1724
|
+
/**
|
|
1725
|
+
* Snapshot processors own only the keys they were written for and pass the
|
|
1726
|
+
* rest through, so a processor earlier in a model's chain also carries props
|
|
1727
|
+
* added after it. Added props therefore replace their keys in a customized
|
|
1728
|
+
* creation or snapshot type; an uncustomized one stays uncustomized.
|
|
1729
|
+
* @hidden
|
|
1730
|
+
*/
|
|
1731
|
+
type _WithAddedKeys<Custom, Added> = _IsAny<Custom> extends true ? Custom : [Custom] extends [_NotCustomized] ? _NotCustomized : Omit<Custom, keyof Added> & Added;
|
|
1732
|
+
/** @hidden */
|
|
1696
1733
|
type ModelCreationType<PC> = MaybeEmpty<{
|
|
1697
1734
|
[P in DefinablePropsNames<PC>]: PC[P];
|
|
1698
1735
|
}> & Partial<PC>;
|
|
@@ -1723,7 +1760,7 @@ interface ModelActions {
|
|
|
1723
1760
|
interface IModelType<PROPS extends ModelProperties, OTHERS, CustomC = _NotCustomized, CustomS = _NotCustomized> extends IType<ModelCreationType2<PROPS, CustomC>, ModelSnapshotType2<PROPS, CustomS>, ModelInstanceType<PROPS, OTHERS>> {
|
|
1724
1761
|
readonly properties: PROPS;
|
|
1725
1762
|
named(newName: string): IModelType<PROPS, OTHERS, CustomC, CustomS>;
|
|
1726
|
-
props<PROPS2 extends ModelPropertiesDeclaration>(props: PROPS2): IModelType<_OverrideProps<PROPS, ModelPropertiesDeclarationToProperties<PROPS2>>, OTHERS, CustomC, CustomS
|
|
1763
|
+
props<PROPS2 extends ModelPropertiesDeclaration>(props: PROPS2): IModelType<_OverrideProps<PROPS, ModelPropertiesDeclarationToProperties<PROPS2>>, OTHERS, _WithAddedKeys<CustomC, ModelCreationType<ExtractCFromProps<ModelPropertiesDeclarationToProperties<PROPS2>>>>, _WithAddedKeys<CustomS, ModelSnapshotType<ModelPropertiesDeclarationToProperties<PROPS2>>>>;
|
|
1727
1764
|
views<V extends object>(fn: (self: Instance<this>) => V): IModelType<PROPS, OTHERS & V, CustomC, CustomS>;
|
|
1728
1765
|
actions<A extends ModelActions>(fn: (self: Instance<this>) => A): IModelType<PROPS, OTHERS & A, CustomC, CustomS>;
|
|
1729
1766
|
volatile<TP extends object>(fn: (self: Instance<this>) => TP): IModelType<PROPS, OTHERS & TP, CustomC, CustomS>;
|
|
@@ -1743,34 +1780,54 @@ interface IAnyModelType extends IModelType<any, any, any, any> {
|
|
|
1743
1780
|
declare function model<P extends ModelPropertiesDeclaration = {}>(name: string, properties?: P): IModelType<ModelPropertiesDeclarationToProperties<P>, {}>;
|
|
1744
1781
|
declare function model<P extends ModelPropertiesDeclaration = {}>(properties?: P): IModelType<ModelPropertiesDeclarationToProperties<P>, {}>;
|
|
1745
1782
|
/** @hidden */
|
|
1746
|
-
type
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1783
|
+
type _ComposableParts = readonly [
|
|
1784
|
+
IAnyModelType,
|
|
1785
|
+
IAnyModelType,
|
|
1786
|
+
...IAnyModelType[]
|
|
1787
|
+
];
|
|
1788
|
+
/**
|
|
1789
|
+
* Props override left to right, as `compose` merges them at runtime.
|
|
1790
|
+
* @hidden
|
|
1791
|
+
*/
|
|
1792
|
+
type _ComposedProps<Acc extends ModelProperties, Rest> = Rest extends readonly [IModelType<infer P, any, any, any>, ...infer Tail] ? _ComposedProps<_OverrideProps<Acc, P>, Tail> : Acc;
|
|
1793
|
+
/** @hidden */
|
|
1794
|
+
type _ComposedOthers<Parts> = Parts extends readonly [
|
|
1795
|
+
IModelType<any, infer O, any, any>,
|
|
1796
|
+
...infer Tail
|
|
1797
|
+
] ? O & _ComposedOthers<Tail> : unknown;
|
|
1798
|
+
/**
|
|
1799
|
+
* A composed part's snapshot processors are handed the whole snapshot but own
|
|
1800
|
+
* only their part's keys, passing the other parts' through — the only way a
|
|
1801
|
+
* part can process without knowing what it is composed with. So a part with a
|
|
1802
|
+
* custom creation (`"C"`) or snapshot (`"S"`) type replaces its own props' keys
|
|
1803
|
+
* in the merged type. `_NotCustomized` when no part customizes.
|
|
1804
|
+
* @hidden
|
|
1805
|
+
*/
|
|
1806
|
+
type _ComposedCustom<Parts, Which extends "C" | "S", Acc, Customized extends boolean = false> = Parts extends readonly [
|
|
1807
|
+
IModelType<infer P, any, infer C, infer S>,
|
|
1808
|
+
...infer Tail
|
|
1809
|
+
] ? (Which extends "C" ? C : S) extends _NotCustomized ? _ComposedCustom<Tail, Which, Acc, Customized> : _ComposedCustom<Tail, Which, Omit<Acc, keyof P> & (Which extends "C" ? C : S), true> : Customized extends true ? Acc : _NotCustomized;
|
|
1810
|
+
/** @hidden */
|
|
1811
|
+
type _ComposedModel<Props extends ModelProperties, Parts> = IModelType<Props, _ComposedOthers<Parts>, _ComposedCustom<Parts, "C", ModelCreationType<ExtractCFromProps<Props>>>, _ComposedCustom<Parts, "S", ModelSnapshotType<Props>>>;
|
|
1812
|
+
/** @hidden */
|
|
1813
|
+
/**
|
|
1814
|
+
* A part typed `any` makes the composition `any`-shaped: inferring from `any`
|
|
1815
|
+
* would yield the parameters' constraints instead, an empty model.
|
|
1816
|
+
* @hidden
|
|
1772
1817
|
*/
|
|
1773
|
-
|
|
1818
|
+
type _Composed<Parts extends _ComposableParts> = true extends _IsAny<Parts[number]> ? IAnyModelType : Parts extends readonly [IModelType<infer P, any, any, any>, ...infer Tail] ? _ComposedModel<_ComposedProps<P, Tail>, Parts> : never;
|
|
1819
|
+
declare function compose<Parts extends _ComposableParts>(name: string, ...parts: Parts): _Composed<Parts>;
|
|
1820
|
+
declare function compose<Parts extends _ComposableParts>(...parts: Parts): _Composed<Parts>;
|
|
1821
|
+
/**
|
|
1822
|
+
* Returns if a type is a model type, or wraps or unions one. For the model
|
|
1823
|
+
* type itself, use {@link asModelType}.
|
|
1824
|
+
*/
|
|
1825
|
+
declare function isModelType(type: IAnyType): boolean;
|
|
1826
|
+
/**
|
|
1827
|
+
* The model type `type` builds its values with, seeing through the wrappers
|
|
1828
|
+
* {@link unwrapType} does, or `undefined` if that is not a model type.
|
|
1829
|
+
*/
|
|
1830
|
+
declare function asModelType(type: IAnyType): IAnyModelType | undefined;
|
|
1774
1831
|
/**
|
|
1775
1832
|
* `extendInstance` - attaches additional actions, views and volatile state to an
|
|
1776
1833
|
* already-created model instance, using the same instantiation machinery as
|
|
@@ -1800,11 +1857,9 @@ declare function extendInstance<T extends IAnyStateTreeNode>(instance: T, fn: (s
|
|
|
1800
1857
|
/**
|
|
1801
1858
|
* Returns if a given value represents a primitive type.
|
|
1802
1859
|
*
|
|
1803
|
-
*
|
|
1804
|
-
*
|
|
1805
|
-
*
|
|
1806
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1807
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
1860
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
1861
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
1862
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
1808
1863
|
*
|
|
1809
1864
|
* @param type
|
|
1810
1865
|
* @returns
|
|
@@ -1839,11 +1894,9 @@ declare function literal<S extends Primitives>(value: S): ILiteralType<S>;
|
|
|
1839
1894
|
/**
|
|
1840
1895
|
* Returns if a given value represents a literal type.
|
|
1841
1896
|
*
|
|
1842
|
-
*
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
1845
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1846
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
1897
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
1898
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
1899
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
1847
1900
|
*
|
|
1848
1901
|
* @param type
|
|
1849
1902
|
* @returns
|
|
@@ -1855,11 +1908,9 @@ declare function refinement<IT extends IAnyType>(type: IT, predicate: (snapshot:
|
|
|
1855
1908
|
/**
|
|
1856
1909
|
* Returns if a given value is a refinement type.
|
|
1857
1910
|
*
|
|
1858
|
-
*
|
|
1859
|
-
*
|
|
1860
|
-
*
|
|
1861
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1862
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
1911
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
1912
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
1913
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
1863
1914
|
*
|
|
1864
1915
|
* @param type
|
|
1865
1916
|
* @returns
|
|
@@ -1868,8 +1919,8 @@ declare function isRefinementType(type: IAnyType): boolean;
|
|
|
1868
1919
|
|
|
1869
1920
|
/** @hidden */
|
|
1870
1921
|
type UnionStringArray<T extends readonly string[]> = T[number];
|
|
1871
|
-
declare function enumeration<T extends
|
|
1872
|
-
declare function enumeration<T extends string>(name: string, options: T[]): ISimpleType<
|
|
1922
|
+
declare function enumeration<T extends string>(options: readonly T[]): ISimpleType<T>;
|
|
1923
|
+
declare function enumeration<T extends string>(name: string, options: readonly T[]): ISimpleType<T>;
|
|
1873
1924
|
|
|
1874
1925
|
type ITypeDispatcher = (snapshot: any) => IAnyType;
|
|
1875
1926
|
interface UnionOptions {
|
|
@@ -1909,24 +1960,18 @@ declare function union(dispatchOrType: UnionOptions | IAnyType, ...otherTypes: I
|
|
|
1909
1960
|
/**
|
|
1910
1961
|
* Returns if a given value represents a union type.
|
|
1911
1962
|
*
|
|
1912
|
-
*
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
1915
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1916
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
1963
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
1964
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
1965
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
1917
1966
|
*
|
|
1918
1967
|
* @param type
|
|
1919
1968
|
* @returns
|
|
1920
1969
|
*/
|
|
1921
1970
|
declare function isUnionType(type: IAnyType): boolean;
|
|
1922
1971
|
/**
|
|
1923
|
-
* Returns the member types of a union
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
1926
|
-
* the type they wrap, so `isUnionType` is true for e.g. an optional-of-union,
|
|
1927
|
-
* but their `getSubTypes()` reports the single wrapped type rather than the
|
|
1928
|
-
* union's members. This drills through those wrappers until the union's member
|
|
1929
|
-
* array surfaces.
|
|
1972
|
+
* Returns the member types of a union, seeing through the wrappers
|
|
1973
|
+
* {@link unwrapType} does: `isUnionType` is also true for e.g. an
|
|
1974
|
+
* optional-of-union.
|
|
1930
1975
|
*
|
|
1931
1976
|
* @param type a type for which `isUnionType` is true
|
|
1932
1977
|
* @returns the array of member types of the underlying union
|
|
@@ -1948,11 +1993,9 @@ declare function optional<IT extends IAnyType, OptionalVals extends ValidOptiona
|
|
|
1948
1993
|
/**
|
|
1949
1994
|
* Returns if a value represents an optional type.
|
|
1950
1995
|
*
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
1953
|
-
*
|
|
1954
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1955
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
1996
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
1997
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
1998
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
1956
1999
|
*
|
|
1957
2000
|
* @param type
|
|
1958
2001
|
* @returns
|
|
@@ -2001,11 +2044,9 @@ declare function late<T extends IAnyType>(name: string, type: () => T): T;
|
|
|
2001
2044
|
/**
|
|
2002
2045
|
* Returns if a given value represents a late type.
|
|
2003
2046
|
*
|
|
2004
|
-
*
|
|
2005
|
-
*
|
|
2006
|
-
*
|
|
2007
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
2008
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
2047
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
2048
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
2049
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
2009
2050
|
*
|
|
2010
2051
|
* @param type
|
|
2011
2052
|
* @returns
|
|
@@ -2024,11 +2065,9 @@ declare function frozen<T = any>(): IType<T, T, T>;
|
|
|
2024
2065
|
/**
|
|
2025
2066
|
* Returns if a given value represents a frozen type.
|
|
2026
2067
|
*
|
|
2027
|
-
*
|
|
2028
|
-
*
|
|
2029
|
-
*
|
|
2030
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
2031
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
2068
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
2069
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
2070
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
2032
2071
|
*
|
|
2033
2072
|
* @param type
|
|
2034
2073
|
* @returns
|
|
@@ -2065,11 +2104,9 @@ declare function reference<IT extends IAnyComplexType>(subType: IT, options?: Re
|
|
|
2065
2104
|
/**
|
|
2066
2105
|
* Returns if a given value represents a reference type.
|
|
2067
2106
|
*
|
|
2068
|
-
*
|
|
2069
|
-
*
|
|
2070
|
-
*
|
|
2071
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
2072
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
2107
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
2108
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
2109
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
2073
2110
|
*
|
|
2074
2111
|
* @param type
|
|
2075
2112
|
* @returns
|
|
@@ -2087,11 +2124,9 @@ declare function safeReference<IT extends IAnyComplexType>(subType: IT, options?
|
|
|
2087
2124
|
/**
|
|
2088
2125
|
* Returns if a given value represents an identifier type.
|
|
2089
2126
|
*
|
|
2090
|
-
*
|
|
2091
|
-
*
|
|
2092
|
-
*
|
|
2093
|
-
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
2094
|
-
* `isMapType`, `isModelType`) keep their predicate.
|
|
2127
|
+
* Like every `isXType` guard it reads the type's flags, which wrappers and
|
|
2128
|
+
* unions inherit from what they hold, so it is also true for a type that wraps
|
|
2129
|
+
* or unions one. Use {@link unwrapType} to get at the type itself.
|
|
2095
2130
|
*
|
|
2096
2131
|
* @param type
|
|
2097
2132
|
* @returns
|
|
@@ -2214,5 +2249,5 @@ declare const types: {
|
|
|
2214
2249
|
resilient: typeof resilient;
|
|
2215
2250
|
};
|
|
2216
2251
|
|
|
2217
|
-
export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cannotDetermineSubtype, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware, createActionTrackingMiddleware2, decorate, destroy, detach, escapeJsonPath, extendInstance, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, getUnionSubtypes, hasParent, hasParentOfType, isActionContextChildOf, isActionContextThisOrChildOf, isAlive, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isProtected, isReferenceType, isRefinementType, isRoot, isStateTreeNode, isType, isUnionType, isValidReference, joinJsonPath, onAction, onPatch, onSnapshot, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setDevMode, setLivelinessChecking, setLivelynessChecking, setTypeChecking, splitJsonPath, types as t, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, unescapeJsonPath, unprotect, walk };
|
|
2218
|
-
export type { $EmptyObjectBrand, CustomTypeOptions, IActionContext, IActionRecorder, IActionTrackingMiddleware2Call, IActionTrackingMiddleware2Hooks, IActionTrackingMiddlewareHooks, IAnyComplexType, IAnyModelType, IAnyStateTreeNode, IAnyType, IArrayType, IComplexType, IDisposer, IJsonPatch, ILiteralType, IMSTArray, IMSTMap, IMapType, IMaybe, IMaybeIType, IMaybeNull, IMiddlewareEvent, IMiddlewareEventType, IMiddlewareHandler, IModelReflectionData, IModelReflectionPropertiesData, IModelType, IOptionalIType, IPatchRecorder, IReferenceType, IReversibleJsonPatch, ISerializedActionCall, ISimpleType, ISnapshotProcessor, ISnapshotProcessors, IStateTreeNode, IType, ITypeUnion, Instance, LivelinessMode, LivelynessMode, ModelActions, ModelCreationType, ModelCreationType2, ModelInstanceType, ModelInstanceTypeProps, ModelPrimitive, ModelProperties, ModelPropertiesDeclaration, ModelPropertiesDeclarationToProperties, ModelSnapshotType, ModelSnapshotType2, OnReferenceInvalidated, OnReferenceInvalidatedEvent, OptionalDefaultValueOrFunction, ReferenceIdentifier, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, SnapshotIn, SnapshotOrInstance, SnapshotOut, TypeOfValue, TypeOrStateTreeNodeToStateTreeNode, UnionOptions, UnionStringArray, ValidOptionalValue, ValidOptionalValues, _CustomCSProcessor,
|
|
2252
|
+
export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, asArrayType, asMapType, asModelType, cannotDetermineSubtype, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware, createActionTrackingMiddleware2, decorate, destroy, detach, escapeJsonPath, extendInstance, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, getUnionSubtypes, getWrappedType, hasParent, hasParentOfType, isActionContextChildOf, isActionContextThisOrChildOf, isAlive, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isProtected, isReferenceType, isRefinementType, isRoot, isStateTreeNode, isType, isUnionType, isValidReference, joinJsonPath, onAction, onPatch, onSnapshot, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setDevMode, setLivelinessChecking, setLivelynessChecking, setTypeChecking, splitJsonPath, types as t, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, unescapeJsonPath, unprotect, unwrapType, walk };
|
|
2253
|
+
export type { $EmptyObjectBrand, CustomTypeOptions, IActionContext, IActionRecorder, IActionTrackingMiddleware2Call, IActionTrackingMiddleware2Hooks, IActionTrackingMiddlewareHooks, IAnyComplexType, IAnyModelType, IAnyStateTreeNode, IAnyType, IArrayType, IComplexType, IDisposer, IHooks, IHooksGetter, IJsonPatch, ILiteralType, IMSTArray, IMSTMap, IMapType, IMaybe, IMaybeIType, IMaybeNull, IMiddlewareEvent, IMiddlewareEventType, IMiddlewareHandler, IModelReflectionData, IModelReflectionPropertiesData, IModelType, IOptionalIType, IPatchRecorder, IReferenceType, IResilientType, IReversibleJsonPatch, ISerializedActionCall, ISimpleType, ISnapshotProcessor, ISnapshotProcessors, IStateTreeNode, IType, ITypeUnion, IValidationContext, IValidationContextEntry, IValidationError, IValidationResult, Instance, LivelinessMode, LivelynessMode, ModelActions, ModelCreationType, ModelCreationType2, ModelInstanceType, ModelInstanceTypeProps, ModelPrimitive, ModelProperties, ModelPropertiesDeclaration, ModelPropertiesDeclarationToProperties, ModelSnapshotType, ModelSnapshotType2, OnReferenceInvalidated, OnReferenceInvalidatedEvent, OptionalDefaultValueOrFunction, ReferenceIdentifier, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, SnapshotIn, SnapshotOrInstance, SnapshotOut, TypeOfValue, TypeOrStateTreeNodeToStateTreeNode, UnionOptions, UnionStringArray, ValidOptionalValue, ValidOptionalValues, _CustomCSProcessor, _CustomOrOther, _NotCustomized };
|