mobx-keystone 2.3.0 → 2.3.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 +4 -0
- package/dist/mobx-keystone.esm.js +151 -312
- package/dist/mobx-keystone.esm.mjs +151 -312
- package/dist/mobx-keystone.umd.js +151 -312
- package/dist/types/action/applyAction.d.ts +1 -1
- package/dist/types/action/applyMethodCall.d.ts +1 -1
- package/dist/types/action/index.d.ts +12 -12
- package/dist/types/action/isModelAction.d.ts +1 -1
- package/dist/types/action/middleware.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/actionSerialization.d.ts +3 -3
- package/dist/types/actionMiddlewares/actionSerialization/applySerializedAction.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/arraySerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/dateSerializer.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/index.d.ts +3 -3
- package/dist/types/actionMiddlewares/actionSerialization/mapSerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/objectPathSerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/objectSnapshotSerializer.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/plainObjectSerializer.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/primitiveSerializer.d.ts +1 -1
- package/dist/types/actionMiddlewares/actionSerialization/setSerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionTrackingMiddleware.d.ts +3 -3
- package/dist/types/actionMiddlewares/index.d.ts +6 -6
- package/dist/types/actionMiddlewares/onActionMiddleware.d.ts +3 -3
- package/dist/types/actionMiddlewares/readonlyMiddleware.d.ts +1 -1
- package/dist/types/actionMiddlewares/transactionMiddleware.d.ts +2 -2
- package/dist/types/actionMiddlewares/undoMiddleware.d.ts +8 -8
- package/dist/types/computedTree/index.d.ts +1 -1
- package/dist/types/context/index.d.ts +1 -1
- package/dist/types/dataModel/BaseDataModel.d.ts +3 -3
- package/dist/types/dataModel/DataModel.d.ts +3 -3
- package/dist/types/dataModel/getDataModelMetadata.d.ts +3 -3
- package/dist/types/dataModel/index.d.ts +4 -4
- package/dist/types/dataModel/utils.d.ts +1 -1
- package/dist/types/deepChange/index.d.ts +1 -1
- package/dist/types/deepChange/onDeepChange.d.ts +1 -1
- package/dist/types/frozen/Frozen.d.ts +1 -1
- package/dist/types/frozen/index.d.ts +1 -1
- package/dist/types/globalConfig/index.d.ts +1 -1
- package/dist/types/index.d.ts +24 -24
- package/dist/types/model/BaseModel.d.ts +5 -5
- package/dist/types/model/Model.d.ts +3 -3
- package/dist/types/model/getModelMetadata.d.ts +3 -3
- package/dist/types/model/index.d.ts +6 -6
- package/dist/types/model/mixins.d.ts +4 -4
- package/dist/types/model/utils.d.ts +4 -4
- package/dist/types/modelShared/BaseModelShared.d.ts +5 -5
- package/dist/types/modelShared/index.d.ts +4 -4
- package/dist/types/modelShared/modelDecorator.d.ts +3 -3
- package/dist/types/modelShared/modelInfo.d.ts +3 -3
- package/dist/types/modelShared/newModel.d.ts +3 -3
- package/dist/types/modelShared/prop.d.ts +3 -3
- package/dist/types/modelShared/sharedInternalModel.d.ts +4 -4
- package/dist/types/parent/findParent.d.ts +1 -1
- package/dist/types/parent/index.d.ts +9 -9
- package/dist/types/parent/path.d.ts +1 -1
- package/dist/types/patch/Patch.d.ts +1 -1
- package/dist/types/patch/applyPatches.d.ts +1 -1
- package/dist/types/patch/emitPatch.d.ts +1 -1
- package/dist/types/patch/index.d.ts +5 -5
- package/dist/types/patch/jsonPatch.d.ts +2 -2
- package/dist/types/patch/patchRecorder.d.ts +2 -2
- package/dist/types/redux/index.d.ts +2 -2
- package/dist/types/redux/redux.d.ts +3 -3
- package/dist/types/ref/Ref.d.ts +3 -3
- package/dist/types/ref/core.d.ts +2 -2
- package/dist/types/ref/customRef.d.ts +2 -2
- package/dist/types/ref/index.d.ts +4 -4
- package/dist/types/ref/rootRef.d.ts +2 -2
- package/dist/types/rootStore/index.d.ts +1 -1
- package/dist/types/snapshot/SnapshotOf.d.ts +5 -5
- package/dist/types/snapshot/SnapshotProcessingError.d.ts +2 -2
- package/dist/types/snapshot/applySnapshot.d.ts +1 -1
- package/dist/types/snapshot/cloneTreeValue.d.ts +1 -1
- package/dist/types/snapshot/fromSnapshot.d.ts +2 -2
- package/dist/types/snapshot/getSnapshot.d.ts +2 -2
- package/dist/types/snapshot/index.d.ts +8 -8
- package/dist/types/snapshot/onSnapshot.d.ts +1 -1
- package/dist/types/standardActions/index.d.ts +3 -3
- package/dist/types/standardActions/objectActions.d.ts +1 -1
- package/dist/types/transforms/asMap.d.ts +1 -1
- package/dist/types/transforms/asSet.d.ts +2 -2
- package/dist/types/transforms/bigint.d.ts +1 -1
- package/dist/types/transforms/date.d.ts +1 -1
- package/dist/types/transforms/index.d.ts +4 -4
- package/dist/types/treeUtils/draft.d.ts +1 -1
- package/dist/types/treeUtils/index.d.ts +3 -3
- package/dist/types/tweaker/index.d.ts +2 -2
- package/dist/types/tweaker/tweak.d.ts +1 -1
- package/dist/types/types/SnapshotTypeMismatchError.d.ts +2 -2
- package/dist/types/types/TypeCheckError.d.ts +2 -2
- package/dist/types/types/TypeChecker.d.ts +3 -3
- package/dist/types/types/arrayBased/typesArray.d.ts +2 -2
- package/dist/types/types/arrayBased/typesTuple.d.ts +2 -2
- package/dist/types/types/getTypeInfo.d.ts +2 -2
- package/dist/types/types/index.d.ts +7 -7
- package/dist/types/types/objectBased/typesArraySet.d.ts +3 -3
- package/dist/types/types/objectBased/typesDataModelData.d.ts +4 -4
- package/dist/types/types/objectBased/typesModel.d.ts +4 -4
- package/dist/types/types/objectBased/typesObject.d.ts +3 -3
- package/dist/types/types/objectBased/typesObjectMap.d.ts +3 -3
- package/dist/types/types/objectBased/typesRecord.d.ts +2 -2
- package/dist/types/types/objectBased/typesRef.d.ts +3 -3
- package/dist/types/types/primitiveBased/typesEnum.d.ts +1 -1
- package/dist/types/types/primitiveBased/typesPrimitive.d.ts +3 -3
- package/dist/types/types/primitiveBased/typesRefinedPrimitive.d.ts +2 -2
- package/dist/types/types/schemas.d.ts +5 -5
- package/dist/types/types/tProp.d.ts +4 -4
- package/dist/types/types/typeCheck.d.ts +2 -2
- package/dist/types/types/types.d.ts +39 -39
- package/dist/types/types/utility/typeToStoredData.d.ts +2 -2
- package/dist/types/types/utility/typesBigInt.d.ts +1 -1
- package/dist/types/types/utility/typesCodec.d.ts +6 -6
- package/dist/types/types/utility/typesCodecCore.d.ts +4 -4
- package/dist/types/types/utility/typesCodecSupport.d.ts +4 -4
- package/dist/types/types/utility/typesDate.d.ts +2 -2
- package/dist/types/types/utility/typesMap.d.ts +2 -2
- package/dist/types/types/utility/typesMaybe.d.ts +1 -1
- package/dist/types/types/utility/typesOr.d.ts +2 -2
- package/dist/types/types/utility/typesRefinement.d.ts +3 -3
- package/dist/types/types/utility/typesSet.d.ts +3 -3
- package/dist/types/types/utility/typesSkipCheck.d.ts +2 -2
- package/dist/types/types/utility/typesTag.d.ts +2 -2
- package/dist/types/types/utility/typesUnchecked.d.ts +2 -2
- package/dist/types/utils/ModelPool.d.ts +1 -1
- package/dist/types/wrappers/ArraySet.d.ts +1 -1
- package/dist/types/wrappers/ObjectMap.d.ts +1 -1
- package/dist/types/wrappers/asMap.d.ts +1 -1
- package/dist/types/wrappers/asSet.d.ts +1 -1
- package/dist/types/wrappers/index.d.ts +4 -4
- package/package.json +5 -18
- package/src/action/modelAction.ts +1 -1
- package/src/action/modelFlow.ts +1 -1
- package/src/dataModel/BaseDataModel.ts +5 -5
- package/src/model/BaseModel.ts +7 -6
- package/src/model/mixins.ts +1 -1
- package/src/model/newModel.ts +1 -1
- package/src/modelShared/modelDecorator.ts +4 -6
- package/src/modelShared/modelInfo.ts +2 -1
- package/src/modelShared/sharedInternalModel.ts +1 -1
- package/src/ref/Ref.ts +1 -1
- package/src/snapshot/SnapshotterAndReconcilerPriority.ts +2 -1
- package/src/snapshot/fromModelSnapshot.ts +1 -1
- package/src/snapshot/fromSnapshot.ts +1 -1
- package/src/transforms/ImmutableDate.ts +19 -19
- package/src/tweaker/tweakArray.ts +1 -1
- package/src/tweaker/tweakFrozen.ts +1 -1
- package/src/tweaker/tweakModel.ts +1 -1
- package/src/tweaker/tweakPlainObject.ts +1 -1
- package/src/types/arrayBased/typesArray.ts +1 -1
- package/src/types/arrayBased/typesTuple.ts +1 -1
- package/src/types/objectBased/typesArraySet.ts +1 -1
- package/src/types/objectBased/typesModel.ts +2 -2
- package/src/types/objectBased/typesObject.ts +1 -1
- package/src/types/objectBased/typesObjectMap.ts +1 -1
- package/src/types/objectBased/typesRecord.ts +1 -1
- package/src/types/objectBased/typesRef.ts +2 -2
- package/src/types/primitiveBased/typesPrimitive.ts +1 -1
- package/src/types/schemas.ts +1 -1
- package/src/types/utility/typesCodecCore.ts +1 -1
- package/src/types/utility/typesCodecSupport.ts +2 -0
- package/src/types/utility/typesOr.ts +2 -2
- package/src/types/utility/typesRefinement.ts +1 -1
- package/src/utils/index.ts +20 -13
- package/src/wrappers/ArraySet.ts +3 -5
- package/src/wrappers/ObjectMap.ts +3 -5
|
@@ -3,25 +3,25 @@ import { failure } from "../utils"
|
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
// oxlint-disable-next-line typescript/no-unsafe-declaration-merging -- the class implements this narrowed Date API.
|
|
7
|
+
export interface ImmutableDate extends Omit<
|
|
8
|
+
Date,
|
|
9
|
+
| "setTime"
|
|
10
|
+
| "setMilliseconds"
|
|
11
|
+
| "setUTCMilliseconds"
|
|
12
|
+
| "setSeconds"
|
|
13
|
+
| "setUTCSeconds"
|
|
14
|
+
| "setMinutes"
|
|
15
|
+
| "setUTCMinutes"
|
|
16
|
+
| "setHours"
|
|
17
|
+
| "setUTCHours"
|
|
18
|
+
| "setDate"
|
|
19
|
+
| "setUTCDate"
|
|
20
|
+
| "setMonth"
|
|
21
|
+
| "setUTCMonth"
|
|
22
|
+
| "setFullYear"
|
|
23
|
+
| "setUTCFullYear"
|
|
24
|
+
> {}
|
|
25
25
|
|
|
26
26
|
const errMessage = "this Date object is immutable"
|
|
27
27
|
|
|
@@ -36,7 +36,6 @@ import { failure, inDevMode, isArray, isPrimitive } from "../utils"
|
|
|
36
36
|
import { addDelayedError, type DelayedError } from "../utils/forEachWithDelayedThrow"
|
|
37
37
|
import { recordChangeForRollback, throwDelayedListenerError } from "./changeRollback"
|
|
38
38
|
import { activateHandlers, areHandlersActive, runningWithoutSnapshotOrPatches } from "./core"
|
|
39
|
-
import { TweakerPriority } from "./TweakerPriority"
|
|
40
39
|
import { markAsTweakedObject } from "./treeNodeMetadata"
|
|
41
40
|
import {
|
|
42
41
|
assertCanAttach,
|
|
@@ -46,6 +45,7 @@ import {
|
|
|
46
45
|
tweak,
|
|
47
46
|
} from "./tweak"
|
|
48
47
|
import { notifyTweakedChangeListeners } from "./tweakedChangeListeners"
|
|
48
|
+
import { TweakerPriority } from "./TweakerPriority"
|
|
49
49
|
import { isTypeCheckingAfterChangeEnabled, runTypeCheckingAfterChange } from "./typeChecking"
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -2,9 +2,9 @@ import { Frozen, frozenKey } from "../frozen/Frozen"
|
|
|
2
2
|
import type { ParentPath } from "../parent/path"
|
|
3
3
|
import { setParent } from "../parent/setParent"
|
|
4
4
|
import { setNewInternalSnapshot } from "../snapshot/internal"
|
|
5
|
-
import { TweakerPriority } from "./TweakerPriority"
|
|
6
5
|
import { markAsTweakedObject } from "./treeNodeMetadata"
|
|
7
6
|
import { registerTweaker } from "./tweak"
|
|
7
|
+
import { TweakerPriority } from "./TweakerPriority"
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @internal
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isModel } from "../model/utils"
|
|
2
2
|
import type { ParentPath } from "../parent/path"
|
|
3
3
|
import { setParent } from "../parent/setParent"
|
|
4
|
-
import { TweakerPriority } from "./TweakerPriority"
|
|
5
4
|
import { markAsTweakedObject } from "./treeNodeMetadata"
|
|
6
5
|
import { registerTweaker } from "./tweak"
|
|
6
|
+
import { TweakerPriority } from "./TweakerPriority"
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
@@ -43,10 +43,10 @@ import { addDelayedError, type DelayedError } from "../utils/forEachWithDelayedT
|
|
|
43
43
|
import { setIfDifferent } from "../utils/setIfDifferent"
|
|
44
44
|
import { recordChangeForRollback, throwDelayedListenerError } from "./changeRollback"
|
|
45
45
|
import { activateHandlers, runningWithoutSnapshotOrPatches } from "./core"
|
|
46
|
-
import { TweakerPriority } from "./TweakerPriority"
|
|
47
46
|
import { markAsTweakedObject, treeNodeMetadata } from "./treeNodeMetadata"
|
|
48
47
|
import { assertCanAttachValue, registerTweaker, tweak } from "./tweak"
|
|
49
48
|
import { notifyTweakedChangeListeners } from "./tweakedChangeListeners"
|
|
49
|
+
import { TweakerPriority } from "./TweakerPriority"
|
|
50
50
|
import { isTypeCheckingAfterChangeEnabled, runTypeCheckingAfterChange } from "./typeChecking"
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -5,7 +5,6 @@ import { createChunkedArrayCachedCheck } from "../createCachedTypeCheck"
|
|
|
5
5
|
import { getTypeInfo } from "../getTypeInfo"
|
|
6
6
|
import { resolveStandardType, resolveTypeChecker } from "../resolveTypeChecker"
|
|
7
7
|
import type { AnyStandardType, AnyType, ArrayType } from "../schemas"
|
|
8
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
9
8
|
import {
|
|
10
9
|
lateTypeChecker,
|
|
11
10
|
snapshotProcessorPlan,
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
TypeInfo,
|
|
15
14
|
type TypeInfoGen,
|
|
16
15
|
} from "../TypeChecker"
|
|
16
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
17
17
|
import { prependPathElementToTypeCheckError } from "../typeCheckErrorUtils"
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -5,7 +5,6 @@ import { createWholeContainerCachedCheck } from "../createCachedTypeCheck"
|
|
|
5
5
|
import { getTypeInfo } from "../getTypeInfo"
|
|
6
6
|
import { resolveStandardType, resolveTypeChecker } from "../resolveTypeChecker"
|
|
7
7
|
import type { AnyStandardType, AnyType, ArrayType } from "../schemas"
|
|
8
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
9
8
|
import {
|
|
10
9
|
lateTypeChecker,
|
|
11
10
|
snapshotProcessorPlan,
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
TypeInfo,
|
|
15
14
|
type TypeInfoGen,
|
|
16
15
|
} from "../TypeChecker"
|
|
16
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
17
17
|
import { prependPathElementToTypeCheckError } from "../typeCheckErrorUtils"
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -7,7 +7,6 @@ import { typesArray } from "../arrayBased/typesArray"
|
|
|
7
7
|
import { getTypeInfo } from "../getTypeInfo"
|
|
8
8
|
import { resolveStandardType, resolveTypeChecker } from "../resolveTypeChecker"
|
|
9
9
|
import type { AnyStandardType, AnyType, ModelType, TypeToData } from "../schemas"
|
|
10
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
11
10
|
import {
|
|
12
11
|
lateTypeChecker,
|
|
13
12
|
snapshotProcessorPlan,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
TypeInfo,
|
|
17
16
|
type TypeInfoGen,
|
|
18
17
|
} from "../TypeChecker"
|
|
18
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
19
19
|
import { resolveCodecSupport } from "../utility/typesCodec"
|
|
20
20
|
import { typesObject } from "./typesObject"
|
|
21
21
|
|
|
@@ -15,9 +15,8 @@ import {
|
|
|
15
15
|
snapshotModelTypeMatches,
|
|
16
16
|
} from "../modelTypeMatching"
|
|
17
17
|
import { registerStandardTypeResolver, resolveTypeChecker } from "../resolveTypeChecker"
|
|
18
|
-
import { SnapshotTypeMismatchError } from "../SnapshotTypeMismatchError"
|
|
19
18
|
import type { AnyStandardType, ModelType } from "../schemas"
|
|
20
|
-
import {
|
|
19
|
+
import { SnapshotTypeMismatchError } from "../SnapshotTypeMismatchError"
|
|
21
20
|
import {
|
|
22
21
|
lateTypeChecker,
|
|
23
22
|
TypeChecker,
|
|
@@ -25,6 +24,7 @@ import {
|
|
|
25
24
|
TypeInfo,
|
|
26
25
|
type TypeInfoGen,
|
|
27
26
|
} from "../TypeChecker"
|
|
27
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
28
28
|
|
|
29
29
|
const cachedModelTypeChecker = new WeakMap<ModelClass<AnyModel>, TypeChecker>()
|
|
30
30
|
const modelStandardTypes = new WeakSet<object>()
|
|
@@ -23,7 +23,6 @@ import type {
|
|
|
23
23
|
ObjectTypeFunction,
|
|
24
24
|
TypeToData,
|
|
25
25
|
} from "../schemas"
|
|
26
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
27
26
|
import {
|
|
28
27
|
type LateTypeChecker,
|
|
29
28
|
lateTypeChecker,
|
|
@@ -34,6 +33,7 @@ import {
|
|
|
34
33
|
TypeInfo,
|
|
35
34
|
type TypeInfoGen,
|
|
36
35
|
} from "../TypeChecker"
|
|
36
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
37
37
|
import { prependPathElementToTypeCheckError } from "../typeCheckErrorUtils"
|
|
38
38
|
|
|
39
39
|
const needsObservableObjectKeyTracking = getMobxVersion() < 5
|
|
@@ -6,7 +6,6 @@ import { ObjectMap } from "../../wrappers/ObjectMap"
|
|
|
6
6
|
import { getTypeInfo } from "../getTypeInfo"
|
|
7
7
|
import { resolveStandardType, resolveTypeChecker } from "../resolveTypeChecker"
|
|
8
8
|
import type { AnyStandardType, AnyType, ModelType, TypeToData } from "../schemas"
|
|
9
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
10
9
|
import {
|
|
11
10
|
lateTypeChecker,
|
|
12
11
|
snapshotProcessorPlan,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
TypeInfo,
|
|
16
15
|
type TypeInfoGen,
|
|
17
16
|
} from "../TypeChecker"
|
|
17
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
18
18
|
import { resolveCodecSupport } from "../utility/typesCodec"
|
|
19
19
|
import { typesObject } from "./typesObject"
|
|
20
20
|
import { typesRecord } from "./typesRecord"
|
|
@@ -6,7 +6,6 @@ import { createChunkedRecordCachedCheck } from "../createCachedTypeCheck"
|
|
|
6
6
|
import { getTypeInfo } from "../getTypeInfo"
|
|
7
7
|
import { resolveStandardType, resolveTypeChecker } from "../resolveTypeChecker"
|
|
8
8
|
import type { AnyStandardType, AnyType, RecordType } from "../schemas"
|
|
9
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
10
9
|
import {
|
|
11
10
|
lateTypeChecker,
|
|
12
11
|
snapshotProcessorPlan,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
TypeInfo,
|
|
16
15
|
type TypeInfoGen,
|
|
17
16
|
} from "../TypeChecker"
|
|
17
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
18
18
|
import { prependPathElementToTypeCheckError } from "../typeCheckErrorUtils"
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
} from "../modelTypeMatching"
|
|
11
11
|
import { typesString } from "../primitiveBased/typesPrimitive"
|
|
12
12
|
import { resolveTypeChecker } from "../resolveTypeChecker"
|
|
13
|
-
import { SnapshotTypeMismatchError } from "../SnapshotTypeMismatchError"
|
|
14
13
|
import type { ModelType } from "../schemas"
|
|
15
|
-
import {
|
|
14
|
+
import { SnapshotTypeMismatchError } from "../SnapshotTypeMismatchError"
|
|
16
15
|
import { TypeChecker, TypeCheckerBaseType, TypeInfo } from "../TypeChecker"
|
|
16
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
17
17
|
import { typesObject } from "./typesObject"
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -2,8 +2,8 @@ import { assertIsPrimitive, isEqualOrBothNaN } from "../../utils"
|
|
|
2
2
|
import type { PrimitiveValue } from "../../utils/types"
|
|
3
3
|
import { registerStandardTypeResolver, type StandardTypeResolverFn } from "../resolveTypeChecker"
|
|
4
4
|
import type { AnyStandardType, IdentityType } from "../schemas"
|
|
5
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
6
5
|
import { TypeChecker, TypeCheckerBaseType, TypeInfo, type TypeInfoGen } from "../TypeChecker"
|
|
6
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
7
7
|
|
|
8
8
|
const standardTypeResolvers: StandardTypeResolverFn[] = []
|
|
9
9
|
|
package/src/types/schemas.ts
CHANGED
|
@@ -96,7 +96,7 @@ type ObjectSnapshotOutData<S, OK = ObjectOptionalKeys<S>> = SimplifyObject<
|
|
|
96
96
|
export interface ObjectType<S> extends Type<"object", ObjectData<S>> {}
|
|
97
97
|
|
|
98
98
|
export interface ObjectTypeFunction {
|
|
99
|
-
//
|
|
99
|
+
// oxlint-disable-next-line typescript/prefer-function-type -- make the type recursive
|
|
100
100
|
(): ObjectOfTypes
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -11,7 +11,6 @@ import type {
|
|
|
11
11
|
TypeToSnapshotIn,
|
|
12
12
|
TypeToSnapshotOut,
|
|
13
13
|
} from "../schemas"
|
|
14
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
15
14
|
import {
|
|
16
15
|
lateTypeChecker,
|
|
17
16
|
TypeChecker,
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
TypeInfo,
|
|
20
19
|
type TypeInfoGen,
|
|
21
20
|
} from "../TypeChecker"
|
|
21
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
22
22
|
import type { TypeToStoredData } from "./typeToStoredData"
|
|
23
23
|
|
|
24
24
|
export interface RuntimeAdapter<Stored, Runtime> {
|
|
@@ -275,6 +275,7 @@ function createArrayLikeRuntimeAdapter(
|
|
|
275
275
|
target.length = storedValues.length
|
|
276
276
|
for (let i = 0; i < storedValues.length; i++) {
|
|
277
277
|
if (i in storedValues) target[i] = storedValues[i]
|
|
278
|
+
// oxlint-disable-next-line typescript/no-array-delete -- keep the holes of sparse arrays
|
|
278
279
|
else delete target[i]
|
|
279
280
|
}
|
|
280
281
|
}
|
|
@@ -513,6 +514,7 @@ function createCodecLeafRuntimeAdapter(
|
|
|
513
514
|
|
|
514
515
|
// Declared up front (rather than initialized from the call) so that a setter invoked
|
|
515
516
|
// while decoding can read it without hitting the temporal dead zone.
|
|
517
|
+
// oxlint-disable-next-line eslint/prefer-const -- see above
|
|
516
518
|
let runtime: unknown
|
|
517
519
|
let storedChanged = false
|
|
518
520
|
runtime = transform.transform({
|
|
@@ -14,9 +14,8 @@ import {
|
|
|
14
14
|
resolveStandardTypeNoThrow,
|
|
15
15
|
resolveTypeChecker,
|
|
16
16
|
} from "../resolveTypeChecker"
|
|
17
|
-
import { SnapshotTypeMismatchError } from "../SnapshotTypeMismatchError"
|
|
18
17
|
import type { AnyStandardType, AnyType } from "../schemas"
|
|
19
|
-
import {
|
|
18
|
+
import { SnapshotTypeMismatchError } from "../SnapshotTypeMismatchError"
|
|
20
19
|
import {
|
|
21
20
|
getTypeCheckerBaseTypeFromValue,
|
|
22
21
|
lateTypeChecker,
|
|
@@ -26,6 +25,7 @@ import {
|
|
|
26
25
|
TypeInfo,
|
|
27
26
|
type TypeInfoGen,
|
|
28
27
|
} from "../TypeChecker"
|
|
28
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
29
29
|
import { typesUnchecked } from "./typesUnchecked"
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getTypeInfo } from "../getTypeInfo"
|
|
2
2
|
import { resolveStandardType, resolveTypeChecker } from "../resolveTypeChecker"
|
|
3
3
|
import type { AnyStandardType, AnyType, TypeToData } from "../schemas"
|
|
4
|
-
import { TypeCheckError } from "../TypeCheckError"
|
|
5
4
|
import {
|
|
6
5
|
lateTypeChecker,
|
|
7
6
|
snapshotProcessorPlan,
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
TypeInfo,
|
|
10
9
|
type TypeInfoGen,
|
|
11
10
|
} from "../TypeChecker"
|
|
11
|
+
import { TypeCheckError } from "../TypeCheckError"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A refinement over a given type. This allows you to do extra checks
|
package/src/utils/index.ts
CHANGED
|
@@ -117,7 +117,7 @@ export let hasOwnProp: (object: object, propName: PropertyKey) => boolean = (
|
|
|
117
117
|
typeof Object.hasOwn === "function"
|
|
118
118
|
? Object.hasOwn
|
|
119
119
|
: (object, propName) => {
|
|
120
|
-
//
|
|
120
|
+
// oxlint-disable-next-line eslint/no-prototype-builtins -- legacy fallback for runtimes without Object.hasOwn.
|
|
121
121
|
return Object.prototype.hasOwnProperty.call(object, propName)
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -133,7 +133,7 @@ export let hasOwnProp: (object: object, propName: PropertyKey) => boolean = (
|
|
|
133
133
|
* @internal
|
|
134
134
|
*/
|
|
135
135
|
export function isEqualOrBothNaN(a: unknown, b: unknown): boolean {
|
|
136
|
-
//
|
|
136
|
+
// oxlint-disable-next-line eslint/no-self-compare -- NaN check
|
|
137
137
|
return a === b || (a !== a && b !== b)
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -244,19 +244,26 @@ export function isArray(val: unknown): val is any[] | IObservableArray {
|
|
|
244
244
|
return Array.isArray(val) || isObservableArray(val)
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
declare const process:
|
|
248
|
-
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
declare const process: {
|
|
248
|
+
env: Record<string, string | undefined>
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function readInDevMode(): boolean {
|
|
252
|
+
// Bundlers replace the literal expression `process.env.NODE_ENV` with a string, so it must stay
|
|
253
|
+
// spelled out in full (no optional chaining, destructuring or `typeof process` guard) for dev
|
|
254
|
+
// mode to work in browser bundles. The try/catch keeps the library loadable where there is
|
|
255
|
+
// neither a bundler replacement nor a global `process`.
|
|
256
|
+
try {
|
|
257
|
+
return process.env.NODE_ENV !== undefined && process.env.NODE_ENV !== "production"
|
|
258
|
+
} catch {
|
|
259
|
+
return false
|
|
260
|
+
}
|
|
261
|
+
}
|
|
252
262
|
|
|
253
263
|
/**
|
|
254
264
|
* @internal
|
|
255
265
|
*/
|
|
256
|
-
export const inDevMode =
|
|
257
|
-
typeof process !== "undefined" &&
|
|
258
|
-
process?.env?.NODE_ENV !== undefined &&
|
|
259
|
-
process.env.NODE_ENV !== "production"
|
|
266
|
+
export const inDevMode = readInDevMode()
|
|
260
267
|
|
|
261
268
|
/**
|
|
262
269
|
* @internal
|
|
@@ -390,11 +397,11 @@ export function logWarning(type: "warn" | "error", msg: string, uniqueKey?: stri
|
|
|
390
397
|
msg = "[mobx-keystone] " + msg
|
|
391
398
|
switch (type) {
|
|
392
399
|
case "warn":
|
|
393
|
-
//
|
|
400
|
+
// oxlint-disable-next-line eslint/no-console -- this internal helper intentionally emits user-facing warnings.
|
|
394
401
|
console.warn(msg)
|
|
395
402
|
break
|
|
396
403
|
case "error":
|
|
397
|
-
//
|
|
404
|
+
// oxlint-disable-next-line eslint/no-console -- this internal helper intentionally emits user-facing errors.
|
|
398
405
|
console.error(msg)
|
|
399
406
|
break
|
|
400
407
|
default:
|
package/src/wrappers/ArraySet.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { modelAction } from "../action/modelAction"
|
|
2
2
|
import type { AnyModel } from "../model/BaseModel"
|
|
3
|
-
import { Model } from "../model/Model"
|
|
4
3
|
import { modelIdKey } from "../model/metadata"
|
|
4
|
+
import { Model } from "../model/Model"
|
|
5
5
|
import { model } from "../modelShared/modelDecorator"
|
|
6
6
|
import { idProp } from "../modelShared/prop"
|
|
7
7
|
import { typesArray } from "../types/arrayBased/typesArray"
|
|
@@ -21,9 +21,7 @@ import {
|
|
|
21
21
|
const arraySetBase = Model({
|
|
22
22
|
[modelIdKey]: idProp,
|
|
23
23
|
items: tProp(typesArray(typesUnchecked<any>()), () => []), // will be properly checked by types.arraySet(subType)
|
|
24
|
-
}) as abstract new (
|
|
25
|
-
data: any
|
|
26
|
-
) => AnyModel & {
|
|
24
|
+
}) as abstract new (data: any) => AnyModel & {
|
|
27
25
|
readonly $: {
|
|
28
26
|
items: any[]
|
|
29
27
|
}
|
|
@@ -35,7 +33,7 @@ const arraySetBase = Model({
|
|
|
35
33
|
* Use `arraySet` to create it.
|
|
36
34
|
*/
|
|
37
35
|
@model(`${namespace}/ArraySet`)
|
|
38
|
-
//
|
|
36
|
+
// oxlint-disable-next-line typescript/no-unsafe-declaration-merging -- model base defines these properties at runtime.
|
|
39
37
|
export class ArraySet<V> extends arraySetBase implements Set<V> {
|
|
40
38
|
@modelAction
|
|
41
39
|
add(value: V): this {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { entries, get, has, keys, remove, values } from "mobx"
|
|
2
2
|
import { modelAction } from "../action/modelAction"
|
|
3
3
|
import type { AnyModel } from "../model/BaseModel"
|
|
4
|
-
import { Model } from "../model/Model"
|
|
5
4
|
import { modelIdKey } from "../model/metadata"
|
|
5
|
+
import { Model } from "../model/Model"
|
|
6
6
|
import { model } from "../modelShared/modelDecorator"
|
|
7
7
|
import { idProp } from "../modelShared/prop"
|
|
8
8
|
import { typesRecord } from "../types/objectBased/typesRecord"
|
|
@@ -14,9 +14,7 @@ import { setIfDifferent } from "../utils/setIfDifferent"
|
|
|
14
14
|
const objectMapBase = Model({
|
|
15
15
|
[modelIdKey]: idProp,
|
|
16
16
|
items: tProp(typesRecord(typesUnchecked<any>()), () => ({})), // will be properly checked by types.objectMap(subType)
|
|
17
|
-
}) as abstract new (
|
|
18
|
-
data: any
|
|
19
|
-
) => AnyModel & {
|
|
17
|
+
}) as abstract new (data: any) => AnyModel & {
|
|
20
18
|
readonly $: {
|
|
21
19
|
items: Record<string, any>
|
|
22
20
|
}
|
|
@@ -28,7 +26,7 @@ const objectMapBase = Model({
|
|
|
28
26
|
* Use `objectMap` to create it.
|
|
29
27
|
*/
|
|
30
28
|
@model(`${namespace}/ObjectMap`)
|
|
31
|
-
//
|
|
29
|
+
// oxlint-disable-next-line typescript/no-unsafe-declaration-merging -- model base defines these properties at runtime.
|
|
32
30
|
export class ObjectMap<V> extends objectMapBase implements Map<string, V> {
|
|
33
31
|
@modelAction
|
|
34
32
|
clear(): void {
|