@jbrowse/mobx-state-tree 5.10.0 → 5.10.2
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/README.md +1 -0
- package/dist/index.d.ts +19 -1
- package/dist/mobx-state-tree.cjs +28 -0
- package/dist/mobx-state-tree.cjs.map +1 -1
- package/dist/mobx-state-tree.mjs +28 -1
- package/dist/mobx-state-tree.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,3 +24,4 @@ Fork of mobx-state-tree v5.4.2 for use in jbrowse
|
|
|
24
24
|
- replaced `unique symbol` phantom properties (`$emptyObject`, `$stateTreeNodeType`) with
|
|
25
25
|
exported string-keyed brand interfaces (`$EmptyObjectBrand`, `$__mstStateTreeNodeType__`),
|
|
26
26
|
fixing tsgo TS4058/TS4023 errors when MST types propagate into exported function return types
|
|
27
|
+
- add reflection api getChildType
|
package/dist/index.d.ts
CHANGED
|
@@ -1501,6 +1501,8 @@ declare function snapshotProcessor<IT extends IAnyType, CustomC = _NotCustomized
|
|
|
1501
1501
|
/** @hidden */
|
|
1502
1502
|
interface IMapType<IT extends IAnyType> extends IType<IKeyValueMap<IT["CreationType"]> | undefined, IKeyValueMap<IT["SnapshotType"]>, IMSTMap<IT>> {
|
|
1503
1503
|
hooks(hooks: IHooksGetter<IMSTMap<IT>>): IMapType<IT>;
|
|
1504
|
+
/** the value type of the map */
|
|
1505
|
+
getChildType(): IAnyType;
|
|
1504
1506
|
}
|
|
1505
1507
|
/** @hidden */
|
|
1506
1508
|
interface IMSTMap<IT extends IAnyType> {
|
|
@@ -1583,6 +1585,8 @@ interface IMSTArray<IT extends IAnyType> extends IObservableArray<IT["Type"]> {
|
|
|
1583
1585
|
/** @hidden */
|
|
1584
1586
|
interface IArrayType<IT extends IAnyType> extends IType<readonly IT["CreationType"][] | undefined, IT["SnapshotType"][], IMSTArray<IT>> {
|
|
1585
1587
|
hooks(hooks: IHooksGetter<IMSTArray<IAnyType>>): IArrayType<IT>;
|
|
1588
|
+
/** the element type of the array */
|
|
1589
|
+
getChildType(): IAnyType;
|
|
1586
1590
|
}
|
|
1587
1591
|
/**
|
|
1588
1592
|
* `types.array` - Creates an index based collection type who's children are all of a uniform declared type.
|
|
@@ -1858,6 +1862,19 @@ declare function union(dispatchOrType: UnionOptions | IAnyType, ...otherTypes: I
|
|
|
1858
1862
|
* @returns
|
|
1859
1863
|
*/
|
|
1860
1864
|
declare function isUnionType<IT extends IAnyType>(type: IT): type is IT;
|
|
1865
|
+
/**
|
|
1866
|
+
* Returns the member types of a union.
|
|
1867
|
+
*
|
|
1868
|
+
* Wrapper types (`optional`, `refinement`, `late`) inherit the union flag from
|
|
1869
|
+
* the type they wrap, so `isUnionType` is true for e.g. an optional-of-union,
|
|
1870
|
+
* but their `getSubTypes()` reports the single wrapped type rather than the
|
|
1871
|
+
* union's members. This drills through those wrappers until the union's member
|
|
1872
|
+
* array surfaces.
|
|
1873
|
+
*
|
|
1874
|
+
* @param type a type for which `isUnionType` is true
|
|
1875
|
+
* @returns the array of member types of the underlying union
|
|
1876
|
+
*/
|
|
1877
|
+
declare function getUnionSubtypes(type: IAnyType): IAnyType[];
|
|
1861
1878
|
|
|
1862
1879
|
/** @hidden */
|
|
1863
1880
|
type ValidOptionalValue = string | boolean | number | null | undefined;
|
|
@@ -1867,6 +1884,7 @@ type ValidOptionalValues = [ValidOptionalValue, ...ValidOptionalValue[]];
|
|
|
1867
1884
|
type OptionalDefaultValueOrFunction<IT extends IAnyType> = IT["CreationType"] | IT["SnapshotType"] | (() => ExtractCSTWithSTN<IT>);
|
|
1868
1885
|
/** @hidden */
|
|
1869
1886
|
interface IOptionalIType<IT extends IAnyType, OptionalVals extends ValidOptionalValues> extends IType<IT["CreationType"] | OptionalVals[number], IT["SnapshotType"], IT["TypeWithoutSTN"]> {
|
|
1887
|
+
getDefaultInstanceOrSnapshot(): IT["CreationType"] | IT["SnapshotType"];
|
|
1870
1888
|
}
|
|
1871
1889
|
declare function optional<IT extends IAnyType>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>): IOptionalIType<IT, [undefined]>;
|
|
1872
1890
|
declare function optional<IT extends IAnyType, OptionalVals extends ValidOptionalValues>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>, optionalValues: OptionalVals): IOptionalIType<IT, OptionalVals>;
|
|
@@ -2130,5 +2148,5 @@ declare const types: {
|
|
|
2130
2148
|
resilient: typeof resilient;
|
|
2131
2149
|
};
|
|
2132
2150
|
|
|
2133
|
-
export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware, createActionTrackingMiddleware2, decorate, destroy, detach, escapeJsonPath, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, 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, process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setDevMode, setLivelinessChecking, setLivelynessChecking, splitJsonPath, types as t, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, unescapeJsonPath, unprotect, walk };
|
|
2151
|
+
export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware, createActionTrackingMiddleware2, decorate, destroy, detach, escapeJsonPath, 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, process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setDevMode, setLivelinessChecking, setLivelynessChecking, splitJsonPath, types as t, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, unescapeJsonPath, unprotect, walk };
|
|
2134
2152
|
export type { $EmptyObjectBrand, CustomTypeOptions, IActionContext, IActionRecorder, IActionTrackingMiddleware2Call, IActionTrackingMiddleware2Hooks, IActionTrackingMiddlewareHooks, IAnyComplexType, IAnyModelType, IAnyStateTreeNode, IAnyType, IArrayType, IComplexType, IDisposer, IJsonPatch, 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, _CustomJoin, _CustomOrOther, _NotCustomized };
|
package/dist/mobx-state-tree.cjs
CHANGED
|
@@ -5747,6 +5747,33 @@ function union(optionsOrType, ...otherTypes) {
|
|
|
5747
5747
|
function isUnionType(type) {
|
|
5748
5748
|
return (type.flags & TypeFlags.Union) > 0;
|
|
5749
5749
|
}
|
|
5750
|
+
/**
|
|
5751
|
+
* Returns the member types of a union.
|
|
5752
|
+
*
|
|
5753
|
+
* Wrapper types (`optional`, `refinement`, `late`) inherit the union flag from
|
|
5754
|
+
* the type they wrap, so `isUnionType` is true for e.g. an optional-of-union,
|
|
5755
|
+
* but their `getSubTypes()` reports the single wrapped type rather than the
|
|
5756
|
+
* union's members. This drills through those wrappers until the union's member
|
|
5757
|
+
* array surfaces.
|
|
5758
|
+
*
|
|
5759
|
+
* @param type a type for which `isUnionType` is true
|
|
5760
|
+
* @returns the array of member types of the underlying union
|
|
5761
|
+
*/
|
|
5762
|
+
function getUnionSubtypes(type) {
|
|
5763
|
+
if (!isUnionType(type)) {
|
|
5764
|
+
throw fail("expected a union type");
|
|
5765
|
+
}
|
|
5766
|
+
let subtypes = type.getSubTypes();
|
|
5767
|
+
while (typeof subtypes === "object" &&
|
|
5768
|
+
subtypes !== null &&
|
|
5769
|
+
!Array.isArray(subtypes)) {
|
|
5770
|
+
subtypes = subtypes.getSubTypes();
|
|
5771
|
+
}
|
|
5772
|
+
if (!Array.isArray(subtypes)) {
|
|
5773
|
+
throw fail("could not extract subtypes from union type");
|
|
5774
|
+
}
|
|
5775
|
+
return subtypes;
|
|
5776
|
+
}
|
|
5750
5777
|
|
|
5751
5778
|
/**
|
|
5752
5779
|
* @hidden
|
|
@@ -6956,6 +6983,7 @@ exports.getRoot = getRoot;
|
|
|
6956
6983
|
exports.getRunningActionContext = getRunningActionContext;
|
|
6957
6984
|
exports.getSnapshot = getSnapshot;
|
|
6958
6985
|
exports.getType = getType;
|
|
6986
|
+
exports.getUnionSubtypes = getUnionSubtypes;
|
|
6959
6987
|
exports.hasParent = hasParent;
|
|
6960
6988
|
exports.hasParentOfType = hasParentOfType;
|
|
6961
6989
|
exports.isActionContextChildOf = isActionContextChildOf;
|