mobx-keystone 2.3.0 → 2.4.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/CHANGELOG.md +20 -0
- package/dist/mobx-keystone.esm.js +3737 -2722
- package/dist/mobx-keystone.esm.mjs +3737 -2722
- package/dist/mobx-keystone.umd.js +3750 -2721
- package/dist/types/action/CallKind.d.ts +29 -0
- package/dist/types/action/applyAction.d.ts +8 -2
- package/dist/types/action/applyMethodCall.d.ts +1 -1
- package/dist/types/action/index.d.ts +13 -12
- package/dist/types/action/isModelAction.d.ts +1 -1
- package/dist/types/action/middleware.d.ts +1 -1
- package/dist/types/action/resolveCallName.d.ts +1 -0
- package/dist/types/actionMiddlewares/actionSerialization/actionSerialization.d.ts +17 -3
- package/dist/types/actionMiddlewares/actionSerialization/applySerializedAction.d.ts +8 -2
- package/dist/types/actionMiddlewares/actionSerialization/arraySerializer.d.ts +2 -2
- package/dist/types/actionMiddlewares/actionSerialization/core.d.ts +7 -0
- 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 +25 -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 +7 -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/serialization/Call.d.ts +55 -0
- package/dist/types/serialization/CallError.d.ts +96 -0
- package/dist/types/serialization/JsonValue.d.ts +6 -0
- package/dist/types/serialization/Serializer.d.ts +84 -0
- package/dist/types/serialization/ValueSerializer.d.ts +88 -0
- package/dist/types/serialization/applyCall.d.ts +54 -0
- package/dist/types/serialization/builtinSerializers.d.ts +49 -0
- package/dist/types/serialization/codec.d.ts +1 -0
- package/dist/types/serialization/index.d.ts +8 -0
- package/dist/types/serialization/references.d.ts +74 -0
- package/dist/types/serialization/resolvedCall.d.ts +1 -0
- 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/CallKind.ts +29 -0
- package/src/action/applyAction.ts +22 -49
- package/src/action/applySet.ts +21 -1
- package/src/action/index.ts +1 -0
- package/src/action/modelAction.ts +1 -1
- package/src/action/modelFlow.ts +1 -1
- package/src/action/resolveCallName.ts +207 -0
- package/src/actionMiddlewares/actionSerialization/actionSerialization.ts +14 -0
- package/src/actionMiddlewares/actionSerialization/applySerializedAction.ts +6 -0
- package/src/actionMiddlewares/actionSerialization/core.ts +7 -0
- package/src/actionMiddlewares/actionSerialization/index.ts +2 -0
- package/src/actionMiddlewares/actionSerialization/objectPathSerializer.ts +3 -2
- package/src/dataModel/BaseDataModel.ts +5 -5
- package/src/index.ts +1 -0
- 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/parent/path.ts +45 -12
- package/src/patch/emitPatch.ts +6 -0
- package/src/ref/Ref.ts +1 -1
- package/src/serialization/Call.ts +58 -0
- package/src/serialization/CallError.ts +153 -0
- package/src/serialization/JsonValue.ts +12 -0
- package/src/serialization/Serializer.ts +321 -0
- package/src/serialization/ValueSerializer.ts +98 -0
- package/src/serialization/applyCall.ts +190 -0
- package/src/serialization/builtinSerializers.ts +261 -0
- package/src/serialization/codec.ts +338 -0
- package/src/serialization/index.ts +15 -0
- package/src/serialization/references.ts +225 -0
- package/src/serialization/resolvedCall.ts +169 -0
- package/src/snapshot/SnapshotterAndReconcilerPriority.ts +2 -1
- package/src/snapshot/fromModelSnapshot.ts +1 -1
- package/src/snapshot/fromSnapshot.ts +1 -1
- package/src/standardActions/actions.ts +11 -3
- 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/errorDiagnostics.ts +9 -4
- package/src/utils/index.ts +20 -13
- package/src/wrappers/ArraySet.ts +3 -5
- package/src/wrappers/ObjectMap.ts +3 -5
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { type CallResolution, resolveCallName } from "../action/resolveCallName"
|
|
2
|
+
import { fastGetRootPath, isRoot } from "../parent/path"
|
|
3
|
+
import { isTreeNode } from "../tweaker/core"
|
|
4
|
+
import { failure, isArray } from "../utils"
|
|
5
|
+
import type { Call, ResolvedCall } from "./Call"
|
|
6
|
+
import { CallError, CallErrorCode } from "./CallError"
|
|
7
|
+
import type { JsonValue } from "./JsonValue"
|
|
8
|
+
import { isNodeOfTree } from "./references"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface ResolvedCallData {
|
|
14
|
+
readonly resolution: CallResolution
|
|
15
|
+
/**
|
|
16
|
+
* Whether the call has `args`, known without decoding them.
|
|
17
|
+
*/
|
|
18
|
+
readonly hasArgs: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const resolvedCallData = new WeakMap<object, ResolvedCallData>()
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export function getResolvedCallData(call: object): ResolvedCallData | undefined {
|
|
27
|
+
return resolvedCallData.get(call)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export function assertIsTreeRoot(root: object): void {
|
|
34
|
+
if (!isTreeNode(root) || !isRoot(root)) {
|
|
35
|
+
throw failure("root must be a tree root")
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function describeTargetLocation(target: unknown): string {
|
|
40
|
+
if (!isTreeNode(target)) {
|
|
41
|
+
return "it is not a tree node"
|
|
42
|
+
}
|
|
43
|
+
const { path } = fastGetRootPath(target, false)
|
|
44
|
+
return path.length === 0
|
|
45
|
+
? "it is the root of another tree (or detached)"
|
|
46
|
+
: `it is at path ${JSON.stringify(path)} of another tree`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*
|
|
52
|
+
* Throws `NotFound` unless the call target is a node of the root's tree.
|
|
53
|
+
*/
|
|
54
|
+
export function assertIsTargetInTree(target: unknown, root: object): asserts target is object {
|
|
55
|
+
if (!isNodeOfTree(target, root)) {
|
|
56
|
+
throw new CallError({
|
|
57
|
+
code: CallErrorCode.NotFound,
|
|
58
|
+
message: `the call target is not a node of the root's tree: ${describeTargetLocation(target)}`,
|
|
59
|
+
path: ["target"],
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*
|
|
67
|
+
* Resolves a call's name on its target, throwing `UnknownName` when nothing can be called.
|
|
68
|
+
*/
|
|
69
|
+
export function resolveCallNameOrThrow(target: object, name: string): CallResolution {
|
|
70
|
+
let resolution: ReturnType<typeof resolveCallName>
|
|
71
|
+
try {
|
|
72
|
+
resolution = resolveCallName(target, name)
|
|
73
|
+
} catch (e) {
|
|
74
|
+
// a data model member on a target that isn't valid data for the data model
|
|
75
|
+
throw new CallError({
|
|
76
|
+
code: CallErrorCode.WrongKind,
|
|
77
|
+
message: `'${name}' cannot be called on the target: its data model can't be created over it`,
|
|
78
|
+
path: ["target"],
|
|
79
|
+
cause: e,
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
if (resolution === "hook") {
|
|
83
|
+
throw new CallError({
|
|
84
|
+
code: CallErrorCode.UnknownName,
|
|
85
|
+
message: `calls to hooks (${name}) cannot be applied`,
|
|
86
|
+
path: ["name"],
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
if (resolution === "unknown") {
|
|
90
|
+
throw new CallError({
|
|
91
|
+
code: CallErrorCode.UnknownName,
|
|
92
|
+
message: `'${name}' cannot be called on the target: it is not an action or a view`,
|
|
93
|
+
path: ["name"],
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
return resolution
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @internal
|
|
101
|
+
*
|
|
102
|
+
* Arguments still to decode: `decode` runs once, when `args` is first read.
|
|
103
|
+
*/
|
|
104
|
+
export interface EncodedArgs {
|
|
105
|
+
readonly rawArgs: JsonValue[]
|
|
106
|
+
decode(): unknown[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @internal
|
|
111
|
+
*
|
|
112
|
+
* Creates a resolved call, with its arguments, or with arguments still to decode.
|
|
113
|
+
*/
|
|
114
|
+
export function createResolvedCall(
|
|
115
|
+
target: object,
|
|
116
|
+
name: string,
|
|
117
|
+
resolution: CallResolution,
|
|
118
|
+
args: unknown[] | EncodedArgs | undefined
|
|
119
|
+
): ResolvedCall {
|
|
120
|
+
const call: { -readonly [K in keyof ResolvedCall]: ResolvedCall[K] } = {
|
|
121
|
+
target,
|
|
122
|
+
name,
|
|
123
|
+
kind: resolution.kind,
|
|
124
|
+
isFlow: resolution.isFlow,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (args === undefined || isArray(args)) {
|
|
128
|
+
call.args = args
|
|
129
|
+
} else {
|
|
130
|
+
call.rawArgs = args.rawArgs
|
|
131
|
+
let decodedArgs: unknown[] | undefined
|
|
132
|
+
Object.defineProperty(call, "args", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: () => (decodedArgs ??= args.decode()),
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
Object.freeze(call)
|
|
139
|
+
resolvedCallData.set(call, { resolution, hasArgs: args !== undefined })
|
|
140
|
+
return call
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @internal
|
|
145
|
+
*
|
|
146
|
+
* Checks the name and args of a call built in process.
|
|
147
|
+
*/
|
|
148
|
+
export function assertIsCallShape(call: Call): void {
|
|
149
|
+
if (typeof call.name !== "string") {
|
|
150
|
+
throw failure("call name must be a string")
|
|
151
|
+
}
|
|
152
|
+
if (call.args !== undefined && !isArray(call.args)) {
|
|
153
|
+
throw failure("call args must be an array or undefined")
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @internal
|
|
159
|
+
*
|
|
160
|
+
* Resolves a call built in process (its target must be a node of the tree).
|
|
161
|
+
*/
|
|
162
|
+
export function toResolvedCall(call: Call): ResolvedCall {
|
|
163
|
+
return createResolvedCall(
|
|
164
|
+
call.target,
|
|
165
|
+
call.name,
|
|
166
|
+
resolveCallNameOrThrow(call.target, call.name),
|
|
167
|
+
call.args
|
|
168
|
+
)
|
|
169
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @internal
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
/* oxlint-disable typescript/prefer-enum-initializers -- that's ok, it is not serialized */
|
|
5
5
|
export enum SnapshotterAndReconcilerPriority {
|
|
6
6
|
Array,
|
|
7
7
|
Frozen,
|
|
8
8
|
Model,
|
|
9
9
|
PlainObject,
|
|
10
10
|
}
|
|
11
|
+
/* oxlint-enable typescript/prefer-enum-initializers */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyModel } from "../model/BaseModel"
|
|
2
2
|
import { getModelIdPropertyName } from "../model/getModelMetadata"
|
|
3
|
-
import type { ModelConstructorOptions } from "../model/ModelConstructorOptions"
|
|
4
3
|
import { modelTypeKey } from "../model/metadata"
|
|
4
|
+
import type { ModelConstructorOptions } from "../model/ModelConstructorOptions"
|
|
5
5
|
import { getModelOrSnapshotTypeAndId, getSnapshotModelType } from "../model/utils"
|
|
6
6
|
import type { ModelClass } from "../modelShared/BaseModelShared"
|
|
7
7
|
import { getModelInfoForName, getModelNotRegisteredErrorMessage } from "../modelShared/modelInfo"
|
|
@@ -83,7 +83,7 @@ export function fromSnapshot<T>(arg1: any, arg2: any, arg3?: any): T {
|
|
|
83
83
|
let snapshot: any
|
|
84
84
|
let unprocessedSnapshot: unknown
|
|
85
85
|
let options: Partial<FromSnapshotOptions> | undefined
|
|
86
|
-
//
|
|
86
|
+
// oxlint-disable-next-line eslint/prefer-rest-params -- overload resolution needs the real call arity to distinguish omitted snapshots from omitted type args.
|
|
87
87
|
const standardType = arguments.length >= 2 ? resolveStandardTypeNoThrow(arg1) : undefined
|
|
88
88
|
|
|
89
89
|
if (isLateTypeChecker(arg1) || arg1 instanceof TypeChecker || standardType) {
|
|
@@ -12,12 +12,20 @@ import { copyFunctionMetadata } from "../utils/decorators"
|
|
|
12
12
|
*/
|
|
13
13
|
type TargetedAction = AnyFunction
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export interface StandaloneActionEntry {
|
|
19
|
+
readonly fn: TargetedAction
|
|
20
|
+
readonly isFlow: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const standaloneActionRegistry = new Map<string, StandaloneActionEntry>()
|
|
16
24
|
|
|
17
25
|
/**
|
|
18
26
|
* @internal
|
|
19
27
|
*/
|
|
20
|
-
export function getStandaloneAction(actionName: string) {
|
|
28
|
+
export function getStandaloneAction(actionName: string): StandaloneActionEntry | undefined {
|
|
21
29
|
return standaloneActionRegistry.get(actionName)
|
|
22
30
|
}
|
|
23
31
|
|
|
@@ -59,6 +67,6 @@ export function addStandaloneAction(fullActionName: string, fn: TargetedAction,
|
|
|
59
67
|
// preserve user-provided metadata without leaking internal action/flow markers.
|
|
60
68
|
copyFunctionMetadata(fn, finalAction)
|
|
61
69
|
|
|
62
|
-
standaloneActionRegistry.set(fullActionName, finalAction)
|
|
70
|
+
standaloneActionRegistry.set(fullActionName, { fn: finalAction, isFlow })
|
|
63
71
|
return finalAction
|
|
64
72
|
}
|
|
@@ -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
|
|
@@ -63,11 +63,16 @@ export function getCurrentErrorDiagnosticsContext(): ErrorDiagnosticsContext | u
|
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
65
65
|
export function runWithErrorDiagnosticsContext<T>(fn: () => T): T {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return fn()
|
|
69
|
-
}
|
|
66
|
+
return getCurrentErrorDiagnosticsContext() ? fn() : runWithNewErrorDiagnosticsContext(fn)
|
|
67
|
+
}
|
|
70
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
*
|
|
72
|
+
* Like `runWithErrorDiagnosticsContext`, but always with a new context, so paths start empty
|
|
73
|
+
* even when called while another context is active.
|
|
74
|
+
*/
|
|
75
|
+
export function runWithNewErrorDiagnosticsContext<T>(fn: () => T): T {
|
|
71
76
|
const ctx = new ErrorDiagnosticsContext()
|
|
72
77
|
errorDiagnosticsContextStack.push(ctx)
|
|
73
78
|
try {
|
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:
|