@jbrowse/mobx-state-tree 6.1.0 → 6.3.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 +91 -14
- package/dist/mobx-state-tree.cjs +508 -220
- package/dist/mobx-state-tree.cjs.map +1 -1
- package/dist/mobx-state-tree.mjs +508 -220
- package/dist/mobx-state-tree.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -604,7 +604,7 @@ declare class ObjectNode<C, S, T> extends BaseNode<C, S, T> {
|
|
|
604
604
|
applySnapshot(snapshot: C): void;
|
|
605
605
|
private _autoUnbox;
|
|
606
606
|
_isRunningAction: boolean;
|
|
607
|
-
private
|
|
607
|
+
private _snapshotReactionDisposer?;
|
|
608
608
|
private _observableInstanceState;
|
|
609
609
|
private _childNodes;
|
|
610
610
|
private _initialSnapshot;
|
|
@@ -663,6 +663,7 @@ declare class ObjectNode<C, S, T> extends BaseNode<C, S, T> {
|
|
|
663
663
|
addMiddleWare(handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer;
|
|
664
664
|
applyPatchLocally(subpath: string, patch: IJsonPatch): void;
|
|
665
665
|
private _addSnapshotReaction;
|
|
666
|
+
private _removeSnapshotReaction;
|
|
666
667
|
private _internalEvents?;
|
|
667
668
|
private _internalEventsHasSubscribers;
|
|
668
669
|
private _internalEventsRegister;
|
|
@@ -913,14 +914,36 @@ type SnapshotOrInstance<T> = SnapshotIn<T> | Instance<T>;
|
|
|
913
914
|
* @hidden
|
|
914
915
|
*/
|
|
915
916
|
declare abstract class BaseType<C, S, T, N extends BaseNode<any, any, any> = BaseNode<C, S, T>> implements IType<C, S, T> {
|
|
916
|
-
[$type]: undefined;
|
|
917
|
+
readonly [$type]: undefined;
|
|
917
918
|
readonly C: C;
|
|
918
919
|
readonly S: S;
|
|
919
920
|
readonly T: T;
|
|
920
921
|
readonly N: N;
|
|
921
|
-
readonly isType
|
|
922
|
-
|
|
923
|
-
|
|
922
|
+
readonly isType: true;
|
|
923
|
+
private _name?;
|
|
924
|
+
/**
|
|
925
|
+
* Builds the name of a type that does not get one handed to it. Composite
|
|
926
|
+
* types (`union`, `array`, `map`, `reference`, ...) override this to fold
|
|
927
|
+
* their members' names; see {@link name}. It runs after construction, so
|
|
928
|
+
* unlike a `super(...)` argument it can read the subclass's own fields.
|
|
929
|
+
*/
|
|
930
|
+
protected computeName(): string;
|
|
931
|
+
/**
|
|
932
|
+
* Friendly type name.
|
|
933
|
+
*
|
|
934
|
+
* A composite type folds its members' names, which for a union is a map +
|
|
935
|
+
* join over every member — and the result is read only by error messages and
|
|
936
|
+
* `describe()`. So those types leave it unset and it is built on first read
|
|
937
|
+
* and cached: a union that never fails a typecheck never builds one, and
|
|
938
|
+
* jbrowse builds a union per config slot, tens of thousands per session load.
|
|
939
|
+
*
|
|
940
|
+
* Deliberately not a lambda passed to the constructor: that allocated a
|
|
941
|
+
* closure per type (the very cost being avoided) and made two separately
|
|
942
|
+
* built but equivalent types compare unequal, since the closures differ.
|
|
943
|
+
*/
|
|
944
|
+
get name(): string;
|
|
945
|
+
set name(value: string);
|
|
946
|
+
constructor(name?: string);
|
|
924
947
|
create(snapshot?: C, environment?: any): any;
|
|
925
948
|
getSnapshot(_node: N, _applyPostProcess?: boolean): S;
|
|
926
949
|
abstract reconcile(current: N, newValue: C | T, parent: AnyObjectNode, subpath: string): N;
|
|
@@ -1777,10 +1800,16 @@ declare const DatePrimitive: IType<number | Date, number, Date>;
|
|
|
1777
1800
|
/**
|
|
1778
1801
|
* Returns if a given value represents a primitive type.
|
|
1779
1802
|
*
|
|
1803
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
1804
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
1805
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
1806
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1807
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
1808
|
+
*
|
|
1780
1809
|
* @param type
|
|
1781
1810
|
* @returns
|
|
1782
1811
|
*/
|
|
1783
|
-
declare function isPrimitiveType<IT extends ISimpleType<string> | ISimpleType<number> | ISimpleType<boolean> | typeof DatePrimitive>(type: IT):
|
|
1812
|
+
declare function isPrimitiveType<IT extends ISimpleType<string> | ISimpleType<number> | ISimpleType<boolean> | typeof DatePrimitive>(type: IT): boolean;
|
|
1784
1813
|
|
|
1785
1814
|
/**
|
|
1786
1815
|
* `types.literal` - The literal type will return a type that will match only the exact given type.
|
|
@@ -1802,20 +1831,32 @@ declare function literal<S extends Primitives>(value: S): ISimpleType<S>;
|
|
|
1802
1831
|
/**
|
|
1803
1832
|
* Returns if a given value represents a literal type.
|
|
1804
1833
|
*
|
|
1834
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
1835
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
1836
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
1837
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1838
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
1839
|
+
*
|
|
1805
1840
|
* @param type
|
|
1806
1841
|
* @returns
|
|
1807
1842
|
*/
|
|
1808
|
-
declare function isLiteralType<IT extends ISimpleType<any>>(type: IT):
|
|
1843
|
+
declare function isLiteralType<IT extends ISimpleType<any>>(type: IT): boolean;
|
|
1809
1844
|
|
|
1810
1845
|
declare function refinement<IT extends IAnyType>(name: string, type: IT, predicate: (snapshot: IT["CreationType"]) => boolean, message?: string | ((v: IT["CreationType"]) => string)): IT;
|
|
1811
1846
|
declare function refinement<IT extends IAnyType>(type: IT, predicate: (snapshot: IT["CreationType"]) => boolean, message?: string | ((v: IT["CreationType"]) => string)): IT;
|
|
1812
1847
|
/**
|
|
1813
1848
|
* Returns if a given value is a refinement type.
|
|
1814
1849
|
*
|
|
1850
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
1851
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
1852
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
1853
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1854
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
1855
|
+
*
|
|
1815
1856
|
* @param type
|
|
1816
1857
|
* @returns
|
|
1817
1858
|
*/
|
|
1818
|
-
declare function isRefinementType<IT extends IAnyType>(type: IT):
|
|
1859
|
+
declare function isRefinementType<IT extends IAnyType>(type: IT): boolean;
|
|
1819
1860
|
|
|
1820
1861
|
/** @hidden */
|
|
1821
1862
|
type UnionStringArray<T extends readonly string[]> = T[number];
|
|
@@ -1872,10 +1913,16 @@ declare function union(dispatchOrType: UnionOptions | IAnyType, ...otherTypes: I
|
|
|
1872
1913
|
/**
|
|
1873
1914
|
* Returns if a given value represents a union type.
|
|
1874
1915
|
*
|
|
1916
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
1917
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
1918
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
1919
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1920
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
1921
|
+
*
|
|
1875
1922
|
* @param type
|
|
1876
1923
|
* @returns
|
|
1877
1924
|
*/
|
|
1878
|
-
declare function isUnionType<IT extends IAnyType>(type: IT):
|
|
1925
|
+
declare function isUnionType<IT extends IAnyType>(type: IT): boolean;
|
|
1879
1926
|
/**
|
|
1880
1927
|
* Returns the member types of a union.
|
|
1881
1928
|
*
|
|
@@ -1905,11 +1952,17 @@ declare function optional<IT extends IAnyType, OptionalVals extends ValidOptiona
|
|
|
1905
1952
|
/**
|
|
1906
1953
|
* Returns if a value represents an optional type.
|
|
1907
1954
|
*
|
|
1955
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
1956
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
1957
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
1958
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
1959
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
1960
|
+
*
|
|
1908
1961
|
* @template IT
|
|
1909
1962
|
* @param type
|
|
1910
1963
|
* @returns
|
|
1911
1964
|
*/
|
|
1912
|
-
declare function isOptionalType<IT extends IAnyType>(type: IT):
|
|
1965
|
+
declare function isOptionalType<IT extends IAnyType>(type: IT): boolean;
|
|
1913
1966
|
/**
|
|
1914
1967
|
* `types.stripDefault` - Like `types.optional`, but the property is omitted from
|
|
1915
1968
|
* a parent model's snapshot entirely when its value equals the default (instead
|
|
@@ -1953,10 +2006,16 @@ declare function late<T extends IAnyType>(name: string, type: () => T): T;
|
|
|
1953
2006
|
/**
|
|
1954
2007
|
* Returns if a given value represents a late type.
|
|
1955
2008
|
*
|
|
2009
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
2010
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
2011
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
2012
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
2013
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
2014
|
+
*
|
|
1956
2015
|
* @param type
|
|
1957
2016
|
* @returns
|
|
1958
2017
|
*/
|
|
1959
|
-
declare function isLateType<IT extends IAnyType>(type: IT):
|
|
2018
|
+
declare function isLateType<IT extends IAnyType>(type: IT): boolean;
|
|
1960
2019
|
|
|
1961
2020
|
interface LazyOptions<T extends IType<any, any, any>, U> {
|
|
1962
2021
|
loadType: () => Promise<T>;
|
|
@@ -1970,10 +2029,16 @@ declare function frozen<T = any>(): IType<T, T, T>;
|
|
|
1970
2029
|
/**
|
|
1971
2030
|
* Returns if a given value represents a frozen type.
|
|
1972
2031
|
*
|
|
2032
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
2033
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
2034
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
2035
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
2036
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
2037
|
+
*
|
|
1973
2038
|
* @param type
|
|
1974
2039
|
* @returns
|
|
1975
2040
|
*/
|
|
1976
|
-
declare function isFrozenType<IT extends IType<T | any, T, T>, T = any>(type: IT):
|
|
2041
|
+
declare function isFrozenType<IT extends IType<T | any, T, T>, T = any>(type: IT): boolean;
|
|
1977
2042
|
|
|
1978
2043
|
type OnReferenceInvalidatedEvent<STN extends IAnyStateTreeNode> = {
|
|
1979
2044
|
parent: IAnyStateTreeNode;
|
|
@@ -2005,10 +2070,16 @@ declare function reference<IT extends IAnyComplexType>(subType: IT, options?: Re
|
|
|
2005
2070
|
/**
|
|
2006
2071
|
* Returns if a given value represents a reference type.
|
|
2007
2072
|
*
|
|
2073
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
2074
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
2075
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
2076
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
2077
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
2078
|
+
*
|
|
2008
2079
|
* @param type
|
|
2009
2080
|
* @returns
|
|
2010
2081
|
*/
|
|
2011
|
-
declare function isReferenceType<IT extends IReferenceType<any>>(type: IT):
|
|
2082
|
+
declare function isReferenceType<IT extends IReferenceType<any>>(type: IT): boolean;
|
|
2012
2083
|
declare function safeReference<IT extends IAnyComplexType>(subType: IT, options: (ReferenceOptionsGetSet<IT> | object) & {
|
|
2013
2084
|
acceptsUndefined: false;
|
|
2014
2085
|
onInvalidated?: OnReferenceInvalidated<ReferenceT<IT>>;
|
|
@@ -2053,10 +2124,16 @@ declare const identifierNumber: ISimpleType<number>;
|
|
|
2053
2124
|
/**
|
|
2054
2125
|
* Returns if a given value represents an identifier type.
|
|
2055
2126
|
*
|
|
2127
|
+
* Returns a plain `boolean`, not a `type is IT` predicate: with the parameter
|
|
2128
|
+
* typed as `IT`, narrowing to `IT` was a no-op in the positive branch while
|
|
2129
|
+
* collapsing the negative one to `never`, so `if (!isX(t)) { t.name }` failed
|
|
2130
|
+
* to compile. Guards with a distinct narrowing target (`isArrayType`,
|
|
2131
|
+
* `isMapType`, `isModelType`) keep their predicate.
|
|
2132
|
+
*
|
|
2056
2133
|
* @param type
|
|
2057
2134
|
* @returns
|
|
2058
2135
|
*/
|
|
2059
|
-
declare function isIdentifierType<IT extends typeof identifier | typeof identifierNumber>(type: IT):
|
|
2136
|
+
declare function isIdentifierType<IT extends typeof identifier | typeof identifierNumber>(type: IT): boolean;
|
|
2060
2137
|
/**
|
|
2061
2138
|
* Valid types for identifiers.
|
|
2062
2139
|
*/
|