@jbrowse/mobx-state-tree 5.5.0 → 5.6.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.
@@ -35,4 +35,5 @@ export * from "./types/utility-types/frozen.ts";
35
35
  export * from "./types/utility-types/reference.ts";
36
36
  export * from "./types/utility-types/identifier.ts";
37
37
  export * from "./types/utility-types/custom.ts";
38
+ export * from "./types/utility-types/resilient.ts";
38
39
  export * from "./types/index.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,oDAAoD,CAAA;AAClE,cAAc,kDAAkD,CAAA;AAChE,cAAc,4BAA4B,CAAA;AAC1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,2BAA2B,CAAA;AACzC,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,4CAA4C,CAAA;AAC1D,cAAc,8BAA8B,CAAA;AAC5C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,uBAAuB,CAAA;AACrC,cAAc,kCAAkC,CAAA;AAChD,cAAc,qCAAqC,CAAA;AACnD,cAAc,sCAAsC,CAAA;AACpD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,mCAAmC,CAAA;AACjD,cAAc,gCAAgC,CAAA;AAC9C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AAA;AACnD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,oCAAoC,CAAA;AAClD,cAAc,kBAAkB,CAAA"}
@@ -6638,6 +6638,122 @@ class CustomType extends SimpleType {
6638
6638
  }
6639
6639
  }
6640
6640
 
6641
+ class Resilient extends BaseType {
6642
+ _subtype;
6643
+ _fallbackType;
6644
+ _createFallbackSnapshot;
6645
+ get flags() {
6646
+ return this._subtype.flags;
6647
+ }
6648
+ constructor(_subtype, _fallbackType, _createFallbackSnapshot) {
6649
+ super(`resilient(${_subtype.name})`);
6650
+ this._subtype = _subtype;
6651
+ this._fallbackType = _fallbackType;
6652
+ this._createFallbackSnapshot = _createFallbackSnapshot;
6653
+ }
6654
+ describe() {
6655
+ return `resilient(${this._subtype.describe()})`;
6656
+ }
6657
+ _instantiateFallback(parent, subpath, environment, originalSnapshot, originalError) {
6658
+ let fallbackSnapshot;
6659
+ try {
6660
+ fallbackSnapshot = this._createFallbackSnapshot(originalError, originalSnapshot);
6661
+ }
6662
+ catch (e) {
6663
+ throw fail(`resilient: createFallbackSnapshot threw while handling error for '${this._subtype.name}': ${originalError}. createFallbackSnapshot error: ${e}`);
6664
+ }
6665
+ try {
6666
+ return this._fallbackType.instantiate(parent, subpath, environment, fallbackSnapshot);
6667
+ }
6668
+ catch (e) {
6669
+ throw fail(`resilient: fallback type '${this._fallbackType.name}' failed to instantiate while handling error for '${this._subtype.name}': ${originalError}. Fallback error: ${e}`);
6670
+ }
6671
+ }
6672
+ instantiate(parent, subpath, environment, initialValue) {
6673
+ if (isStateTreeNode(initialValue)) {
6674
+ return this._subtype.instantiate(parent, subpath, environment, initialValue);
6675
+ }
6676
+ try {
6677
+ return this._subtype.instantiate(parent, subpath, environment, initialValue);
6678
+ }
6679
+ catch (e) {
6680
+ return this._instantiateFallback(parent, subpath, environment, initialValue, e);
6681
+ }
6682
+ }
6683
+ reconcile(current, newValue, parent, subpath) {
6684
+ if (isStateTreeNode(newValue)) {
6685
+ return this._subtype.reconcile(current, newValue, parent, subpath);
6686
+ }
6687
+ if (this._fallbackType.isAssignableFrom(current.type)) {
6688
+ try {
6689
+ return this._subtype.instantiate(parent, subpath, undefined, newValue);
6690
+ }
6691
+ catch (e) {
6692
+ return this._fallbackType.reconcile(current, this._createFallbackSnapshot(e, newValue), parent, subpath);
6693
+ }
6694
+ }
6695
+ try {
6696
+ return this._subtype.reconcile(current, newValue, parent, subpath);
6697
+ }
6698
+ catch (e) {
6699
+ current.die();
6700
+ return this._instantiateFallback(parent, subpath, undefined, newValue, e);
6701
+ }
6702
+ }
6703
+ isValidSnapshot(_value, _context) {
6704
+ return typeCheckSuccess();
6705
+ }
6706
+ is(thing) {
6707
+ if (isType(thing)) {
6708
+ return (this._subtype.isAssignableFrom(thing) ||
6709
+ this._fallbackType.isAssignableFrom(thing));
6710
+ }
6711
+ try {
6712
+ if (this._subtype.is(thing)) {
6713
+ return true;
6714
+ }
6715
+ }
6716
+ catch (_e) {
6717
+ // subtype.is() may throw (e.g. union dispatcher)
6718
+ }
6719
+ try {
6720
+ return this._fallbackType.is(thing);
6721
+ }
6722
+ catch (_e) {
6723
+ return false;
6724
+ }
6725
+ }
6726
+ isAssignableFrom(type) {
6727
+ return (this._subtype.isAssignableFrom(type) ||
6728
+ this._fallbackType.isAssignableFrom(type));
6729
+ }
6730
+ getSubTypes() {
6731
+ return [this._subtype, this._fallbackType];
6732
+ }
6733
+ getSnapshot(node) {
6734
+ return node.snapshot;
6735
+ }
6736
+ }
6737
+ /**
6738
+ * `types.resilient` - Wraps a type so that instantiation errors are caught
6739
+ * and a fallback type is used instead. This is useful for loading data that
6740
+ * may contain unknown or invalid subtrees (e.g., plugin types that are not
6741
+ * installed) without crashing the entire state tree.
6742
+ *
6743
+ * The `createFallbackSnapshot` callback receives the caught error and the
6744
+ * original snapshot, and must return a valid snapshot for the fallback type.
6745
+ *
6746
+ * @param type The type to wrap.
6747
+ * @param fallbackType The fallback type to use when instantiation fails.
6748
+ * @param createFallbackSnapshot Callback that produces a fallback snapshot from the error and original snapshot.
6749
+ * @returns A resilient type.
6750
+ */
6751
+ function resilient(type, fallbackType, createFallbackSnapshot) {
6752
+ assertIsType(type, 1);
6753
+ assertIsType(fallbackType, 2);
6754
+ return new Resilient(type, fallbackType, createFallbackSnapshot);
6755
+ }
6756
+
6641
6757
  // we import the types to re-export them inside types.
6642
6758
  const types = {
6643
6759
  enumeration,
@@ -6668,7 +6784,8 @@ const types = {
6668
6784
  lazy,
6669
6785
  undefined: undefinedType,
6670
6786
  null: nullType,
6671
- snapshotProcessor
6787
+ snapshotProcessor,
6788
+ resilient
6672
6789
  };
6673
6790
 
6674
6791
  exports.addDisposer = addDisposer;
@@ -6636,6 +6636,122 @@ class CustomType extends SimpleType {
6636
6636
  }
6637
6637
  }
6638
6638
 
6639
+ class Resilient extends BaseType {
6640
+ _subtype;
6641
+ _fallbackType;
6642
+ _createFallbackSnapshot;
6643
+ get flags() {
6644
+ return this._subtype.flags;
6645
+ }
6646
+ constructor(_subtype, _fallbackType, _createFallbackSnapshot) {
6647
+ super(`resilient(${_subtype.name})`);
6648
+ this._subtype = _subtype;
6649
+ this._fallbackType = _fallbackType;
6650
+ this._createFallbackSnapshot = _createFallbackSnapshot;
6651
+ }
6652
+ describe() {
6653
+ return `resilient(${this._subtype.describe()})`;
6654
+ }
6655
+ _instantiateFallback(parent, subpath, environment, originalSnapshot, originalError) {
6656
+ let fallbackSnapshot;
6657
+ try {
6658
+ fallbackSnapshot = this._createFallbackSnapshot(originalError, originalSnapshot);
6659
+ }
6660
+ catch (e) {
6661
+ throw fail(`resilient: createFallbackSnapshot threw while handling error for '${this._subtype.name}': ${originalError}. createFallbackSnapshot error: ${e}`);
6662
+ }
6663
+ try {
6664
+ return this._fallbackType.instantiate(parent, subpath, environment, fallbackSnapshot);
6665
+ }
6666
+ catch (e) {
6667
+ throw fail(`resilient: fallback type '${this._fallbackType.name}' failed to instantiate while handling error for '${this._subtype.name}': ${originalError}. Fallback error: ${e}`);
6668
+ }
6669
+ }
6670
+ instantiate(parent, subpath, environment, initialValue) {
6671
+ if (isStateTreeNode(initialValue)) {
6672
+ return this._subtype.instantiate(parent, subpath, environment, initialValue);
6673
+ }
6674
+ try {
6675
+ return this._subtype.instantiate(parent, subpath, environment, initialValue);
6676
+ }
6677
+ catch (e) {
6678
+ return this._instantiateFallback(parent, subpath, environment, initialValue, e);
6679
+ }
6680
+ }
6681
+ reconcile(current, newValue, parent, subpath) {
6682
+ if (isStateTreeNode(newValue)) {
6683
+ return this._subtype.reconcile(current, newValue, parent, subpath);
6684
+ }
6685
+ if (this._fallbackType.isAssignableFrom(current.type)) {
6686
+ try {
6687
+ return this._subtype.instantiate(parent, subpath, undefined, newValue);
6688
+ }
6689
+ catch (e) {
6690
+ return this._fallbackType.reconcile(current, this._createFallbackSnapshot(e, newValue), parent, subpath);
6691
+ }
6692
+ }
6693
+ try {
6694
+ return this._subtype.reconcile(current, newValue, parent, subpath);
6695
+ }
6696
+ catch (e) {
6697
+ current.die();
6698
+ return this._instantiateFallback(parent, subpath, undefined, newValue, e);
6699
+ }
6700
+ }
6701
+ isValidSnapshot(_value, _context) {
6702
+ return typeCheckSuccess();
6703
+ }
6704
+ is(thing) {
6705
+ if (isType(thing)) {
6706
+ return (this._subtype.isAssignableFrom(thing) ||
6707
+ this._fallbackType.isAssignableFrom(thing));
6708
+ }
6709
+ try {
6710
+ if (this._subtype.is(thing)) {
6711
+ return true;
6712
+ }
6713
+ }
6714
+ catch (_e) {
6715
+ // subtype.is() may throw (e.g. union dispatcher)
6716
+ }
6717
+ try {
6718
+ return this._fallbackType.is(thing);
6719
+ }
6720
+ catch (_e) {
6721
+ return false;
6722
+ }
6723
+ }
6724
+ isAssignableFrom(type) {
6725
+ return (this._subtype.isAssignableFrom(type) ||
6726
+ this._fallbackType.isAssignableFrom(type));
6727
+ }
6728
+ getSubTypes() {
6729
+ return [this._subtype, this._fallbackType];
6730
+ }
6731
+ getSnapshot(node) {
6732
+ return node.snapshot;
6733
+ }
6734
+ }
6735
+ /**
6736
+ * `types.resilient` - Wraps a type so that instantiation errors are caught
6737
+ * and a fallback type is used instead. This is useful for loading data that
6738
+ * may contain unknown or invalid subtrees (e.g., plugin types that are not
6739
+ * installed) without crashing the entire state tree.
6740
+ *
6741
+ * The `createFallbackSnapshot` callback receives the caught error and the
6742
+ * original snapshot, and must return a valid snapshot for the fallback type.
6743
+ *
6744
+ * @param type The type to wrap.
6745
+ * @param fallbackType The fallback type to use when instantiation fails.
6746
+ * @param createFallbackSnapshot Callback that produces a fallback snapshot from the error and original snapshot.
6747
+ * @returns A resilient type.
6748
+ */
6749
+ function resilient(type, fallbackType, createFallbackSnapshot) {
6750
+ assertIsType(type, 1);
6751
+ assertIsType(fallbackType, 2);
6752
+ return new Resilient(type, fallbackType, createFallbackSnapshot);
6753
+ }
6754
+
6639
6755
  // we import the types to re-export them inside types.
6640
6756
  const types = {
6641
6757
  enumeration,
@@ -6666,7 +6782,8 @@ const types = {
6666
6782
  lazy,
6667
6783
  undefined: undefinedType,
6668
6784
  null: nullType,
6669
- snapshotProcessor
6785
+ snapshotProcessor,
6786
+ resilient
6670
6787
  };
6671
6788
 
6672
6789
  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$1 as process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setDevMode, setLivelinessChecking, setLivelynessChecking, splitJsonPath, types as t, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, unescapeJsonPath, unprotect, walk };
@@ -6640,6 +6640,122 @@
6640
6640
  }
6641
6641
  }
6642
6642
 
6643
+ class Resilient extends BaseType {
6644
+ _subtype;
6645
+ _fallbackType;
6646
+ _createFallbackSnapshot;
6647
+ get flags() {
6648
+ return this._subtype.flags;
6649
+ }
6650
+ constructor(_subtype, _fallbackType, _createFallbackSnapshot) {
6651
+ super(`resilient(${_subtype.name})`);
6652
+ this._subtype = _subtype;
6653
+ this._fallbackType = _fallbackType;
6654
+ this._createFallbackSnapshot = _createFallbackSnapshot;
6655
+ }
6656
+ describe() {
6657
+ return `resilient(${this._subtype.describe()})`;
6658
+ }
6659
+ _instantiateFallback(parent, subpath, environment, originalSnapshot, originalError) {
6660
+ let fallbackSnapshot;
6661
+ try {
6662
+ fallbackSnapshot = this._createFallbackSnapshot(originalError, originalSnapshot);
6663
+ }
6664
+ catch (e) {
6665
+ throw fail(`resilient: createFallbackSnapshot threw while handling error for '${this._subtype.name}': ${originalError}. createFallbackSnapshot error: ${e}`);
6666
+ }
6667
+ try {
6668
+ return this._fallbackType.instantiate(parent, subpath, environment, fallbackSnapshot);
6669
+ }
6670
+ catch (e) {
6671
+ throw fail(`resilient: fallback type '${this._fallbackType.name}' failed to instantiate while handling error for '${this._subtype.name}': ${originalError}. Fallback error: ${e}`);
6672
+ }
6673
+ }
6674
+ instantiate(parent, subpath, environment, initialValue) {
6675
+ if (isStateTreeNode(initialValue)) {
6676
+ return this._subtype.instantiate(parent, subpath, environment, initialValue);
6677
+ }
6678
+ try {
6679
+ return this._subtype.instantiate(parent, subpath, environment, initialValue);
6680
+ }
6681
+ catch (e) {
6682
+ return this._instantiateFallback(parent, subpath, environment, initialValue, e);
6683
+ }
6684
+ }
6685
+ reconcile(current, newValue, parent, subpath) {
6686
+ if (isStateTreeNode(newValue)) {
6687
+ return this._subtype.reconcile(current, newValue, parent, subpath);
6688
+ }
6689
+ if (this._fallbackType.isAssignableFrom(current.type)) {
6690
+ try {
6691
+ return this._subtype.instantiate(parent, subpath, undefined, newValue);
6692
+ }
6693
+ catch (e) {
6694
+ return this._fallbackType.reconcile(current, this._createFallbackSnapshot(e, newValue), parent, subpath);
6695
+ }
6696
+ }
6697
+ try {
6698
+ return this._subtype.reconcile(current, newValue, parent, subpath);
6699
+ }
6700
+ catch (e) {
6701
+ current.die();
6702
+ return this._instantiateFallback(parent, subpath, undefined, newValue, e);
6703
+ }
6704
+ }
6705
+ isValidSnapshot(_value, _context) {
6706
+ return typeCheckSuccess();
6707
+ }
6708
+ is(thing) {
6709
+ if (isType(thing)) {
6710
+ return (this._subtype.isAssignableFrom(thing) ||
6711
+ this._fallbackType.isAssignableFrom(thing));
6712
+ }
6713
+ try {
6714
+ if (this._subtype.is(thing)) {
6715
+ return true;
6716
+ }
6717
+ }
6718
+ catch (_e) {
6719
+ // subtype.is() may throw (e.g. union dispatcher)
6720
+ }
6721
+ try {
6722
+ return this._fallbackType.is(thing);
6723
+ }
6724
+ catch (_e) {
6725
+ return false;
6726
+ }
6727
+ }
6728
+ isAssignableFrom(type) {
6729
+ return (this._subtype.isAssignableFrom(type) ||
6730
+ this._fallbackType.isAssignableFrom(type));
6731
+ }
6732
+ getSubTypes() {
6733
+ return [this._subtype, this._fallbackType];
6734
+ }
6735
+ getSnapshot(node) {
6736
+ return node.snapshot;
6737
+ }
6738
+ }
6739
+ /**
6740
+ * `types.resilient` - Wraps a type so that instantiation errors are caught
6741
+ * and a fallback type is used instead. This is useful for loading data that
6742
+ * may contain unknown or invalid subtrees (e.g., plugin types that are not
6743
+ * installed) without crashing the entire state tree.
6744
+ *
6745
+ * The `createFallbackSnapshot` callback receives the caught error and the
6746
+ * original snapshot, and must return a valid snapshot for the fallback type.
6747
+ *
6748
+ * @param type The type to wrap.
6749
+ * @param fallbackType The fallback type to use when instantiation fails.
6750
+ * @param createFallbackSnapshot Callback that produces a fallback snapshot from the error and original snapshot.
6751
+ * @returns A resilient type.
6752
+ */
6753
+ function resilient(type, fallbackType, createFallbackSnapshot) {
6754
+ assertIsType(type, 1);
6755
+ assertIsType(fallbackType, 2);
6756
+ return new Resilient(type, fallbackType, createFallbackSnapshot);
6757
+ }
6758
+
6643
6759
  // we import the types to re-export them inside types.
6644
6760
  const types = {
6645
6761
  enumeration,
@@ -6670,7 +6786,8 @@
6670
6786
  lazy,
6671
6787
  undefined: undefinedType,
6672
6788
  null: nullType,
6673
- snapshotProcessor
6789
+ snapshotProcessor,
6790
+ resilient
6674
6791
  };
6675
6792
 
6676
6793
  exports.addDisposer = addDisposer;
@@ -1,4 +1,4 @@
1
- import { array, compose, custom, enumeration, frozen, late, lazy, literal, map, maybe, maybeNull, model, optional, reference, refinement, safeReference, snapshotProcessor, union } from "../internal.ts";
1
+ import { array, compose, custom, enumeration, frozen, late, lazy, literal, map, maybe, maybeNull, model, optional, reference, refinement, safeReference, resilient, snapshotProcessor, union } from "../internal.ts";
2
2
  export declare const types: {
3
3
  enumeration: typeof enumeration;
4
4
  model: typeof model;
@@ -29,4 +29,5 @@ export declare const types: {
29
29
  undefined: import("../internal.ts").ISimpleType<undefined>;
30
30
  null: import("../internal.ts").ISimpleType<null>;
31
31
  snapshotProcessor: typeof snapshotProcessor;
32
+ resilient: typeof resilient;
32
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EACL,aAAa,EACb,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,GAAG,EACH,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,aAAa,EACb,KAAK,EACN,MAAM,gBAAgB,CAAA;AAEvB,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,WAAW;IACX,KAAK;IACL,OAAO;IACP,MAAM;IACN,SAAS;IACT,aAAa;IACb,KAAK;IACL,QAAQ;IACR,OAAO;IACP,KAAK;IACL,SAAS;IACT,UAAU;IACV,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,IAAI,EAAE,aAAa;IACnB,GAAG;IACH,KAAK;IACL,MAAM;IACN,UAAU;IACV,gBAAgB;IAChB,IAAI;IACJ,IAAI;IACJ,SAAS,EAAE,aAAa;IACxB,IAAI,EAAE,QAAQ;IACd,iBAAiB;CAClB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EACL,aAAa,EACb,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,GAAG,EACH,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,MAAM,EACN,aAAa,EACb,KAAK,EACN,MAAM,gBAAgB,CAAA;AAEvB,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,WAAW;IACX,KAAK;IACL,OAAO;IACP,MAAM;IACN,SAAS;IACT,aAAa;IACb,KAAK;IACL,QAAQ;IACR,OAAO;IACP,KAAK;IACL,SAAS;IACT,UAAU;IACV,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,IAAI,EAAE,aAAa;IACnB,GAAG;IACH,KAAK;IACL,MAAM;IACN,UAAU;IACV,gBAAgB;IAChB,IAAI;IACJ,IAAI;IACJ,SAAS,EAAE,aAAa;IACxB,IAAI,EAAE,QAAQ;IACd,iBAAiB;IACjB,SAAS;CACV,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { type IAnyType, type IType } from "../../internal.ts";
2
+ export interface IResilientType<IT extends IAnyType, FT extends IAnyType> extends IType<IT["CreationType"] | FT["CreationType"], IT["SnapshotType"] | FT["SnapshotType"], IT["TypeWithoutSTN"] | FT["TypeWithoutSTN"]> {
3
+ }
4
+ /**
5
+ * `types.resilient` - Wraps a type so that instantiation errors are caught
6
+ * and a fallback type is used instead. This is useful for loading data that
7
+ * may contain unknown or invalid subtrees (e.g., plugin types that are not
8
+ * installed) without crashing the entire state tree.
9
+ *
10
+ * The `createFallbackSnapshot` callback receives the caught error and the
11
+ * original snapshot, and must return a valid snapshot for the fallback type.
12
+ *
13
+ * @param type The type to wrap.
14
+ * @param fallbackType The fallback type to use when instantiation fails.
15
+ * @param createFallbackSnapshot Callback that produces a fallback snapshot from the error and original snapshot.
16
+ * @returns A resilient type.
17
+ */
18
+ export declare function resilient<IT extends IAnyType, FT extends IAnyType>(type: IT, fallbackType: FT, createFallbackSnapshot: (error: unknown, snapshot: any) => FT["CreationType"]): IResilientType<IT, FT>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resilient.js","sourceRoot":"","sources":["../../../src/types/utility-types/resilient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAMR,YAAY,EACZ,IAAI,EACJ,eAAe,EACf,MAAM,EACN,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,SAAoD,SAAQ,QAKjE;IAMoB;IACA;IACA;IAPnB,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAA;IAC5B,CAAC;IAED,YACmB,QAAY,EACZ,aAAiB,EACjB,uBAGM;QAEvB,KAAK,CAAC,aAAa,QAAQ,CAAC,IAAI,GAAG,CA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1
  {
2
2
  "name": "@jbrowse/mobx-state-tree",
3
- "version": "5.5.0",
3
+ "version": "5.6.0",
4
4
  "description": "Fork of mobx-state-tree starting from v5.4.2 for use in jbrowse 2",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/mobx-state-tree.js",
@@ -31,21 +31,22 @@
31
31
  "dist/"
32
32
  ],
33
33
  "devDependencies": {
34
- "@types/node": "^24.10.1",
34
+ "@eslint/js": "^10.0.1",
35
+ "@types/node": "^25.3.0",
35
36
  "concat": "^1.0.3",
36
37
  "cpr": "^3.0.1",
37
38
  "cross-env": "^10.1.0",
38
- "eslint": "^9.39.1",
39
+ "eslint": "^10.0.1",
39
40
  "eslint-plugin-import": "^2.32.0",
40
41
  "mobx": "^6.15.0",
41
- "prettier": "^3.7.3",
42
- "rimraf": "^6.1.2",
43
- "rollup": "^4.53.3",
42
+ "prettier": "^3.8.1",
43
+ "rimraf": "^6.1.3",
44
+ "rollup": "^4.59.0",
44
45
  "rollup-plugin-replace": "^2.2.0",
45
46
  "spec.ts": "^1.1.3",
46
47
  "typescript": "^5.9.3",
47
- "typescript-eslint": "^8.48.0",
48
- "vitest": "^4.0.14"
48
+ "typescript-eslint": "^8.56.0",
49
+ "vitest": "^4.0.18"
49
50
  },
50
51
  "peerDependencies": {
51
52
  "mobx": "^6.3.0"