@jbrowse/mobx-state-tree 5.10.1 → 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 +15 -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
|
@@ -1862,6 +1862,19 @@ declare function union(dispatchOrType: UnionOptions | IAnyType, ...otherTypes: I
|
|
|
1862
1862
|
* @returns
|
|
1863
1863
|
*/
|
|
1864
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[];
|
|
1865
1878
|
|
|
1866
1879
|
/** @hidden */
|
|
1867
1880
|
type ValidOptionalValue = string | boolean | number | null | undefined;
|
|
@@ -1871,6 +1884,7 @@ type ValidOptionalValues = [ValidOptionalValue, ...ValidOptionalValue[]];
|
|
|
1871
1884
|
type OptionalDefaultValueOrFunction<IT extends IAnyType> = IT["CreationType"] | IT["SnapshotType"] | (() => ExtractCSTWithSTN<IT>);
|
|
1872
1885
|
/** @hidden */
|
|
1873
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"];
|
|
1874
1888
|
}
|
|
1875
1889
|
declare function optional<IT extends IAnyType>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>): IOptionalIType<IT, [undefined]>;
|
|
1876
1890
|
declare function optional<IT extends IAnyType, OptionalVals extends ValidOptionalValues>(type: IT, defaultValueOrFunction: OptionalDefaultValueOrFunction<IT>, optionalValues: OptionalVals): IOptionalIType<IT, OptionalVals>;
|
|
@@ -2134,5 +2148,5 @@ declare const types: {
|
|
|
2134
2148
|
resilient: typeof resilient;
|
|
2135
2149
|
};
|
|
2136
2150
|
|
|
2137
|
-
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 };
|
|
2138
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;
|