mobx-keystone 1.24.1 → 2.0.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 +137 -0
- package/README.md +5 -1
- package/dist/mobx-keystone.esm.js +1608 -1072
- package/dist/mobx-keystone.esm.mjs +1608 -1072
- package/dist/mobx-keystone.umd.js +1613 -1072
- package/dist/types/actionMiddlewares/actionSerialization/dateSerializer.d.ts +1 -1
- package/dist/types/dataModel/dataModelInstanceCache.d.ts +1 -0
- package/dist/types/deepChange/onDeepChange.d.ts +9 -0
- package/dist/types/parent/detach.d.ts +1 -1
- package/dist/types/parent/findChildren.d.ts +1 -1
- package/dist/types/patch/applyPatches.d.ts +2 -0
- package/dist/types/redux/connectReduxDevTools.d.ts +2 -1
- package/dist/types/snapshot/SnapshotOf.d.ts +2 -2
- package/dist/types/standardActions/arrayActions.d.ts +1 -1
- package/dist/types/treeUtils/sandbox.d.ts +0 -4
- package/dist/types/types/TypeCheckError.d.ts +1 -0
- package/dist/types/types/utility/typesRefinement.d.ts +2 -2
- package/dist/types/utils/forEachWithDelayedThrow.d.ts +1 -0
- package/dist/types/utils/index.d.ts +13 -0
- package/dist/types/utils/mapUtils.d.ts +2 -2
- package/dist/types/utils/setLike.d.ts +1 -0
- package/package.json +7 -7
- package/src/action/applyAction.ts +1 -1
- package/src/action/middleware.ts +17 -36
- package/src/action/modelFlow.ts +4 -5
- package/src/action/mutationBatch.ts +10 -10
- package/src/action/pendingActions.ts +3 -4
- package/src/actionMiddlewares/actionSerialization/actionSerialization.ts +19 -14
- package/src/actionMiddlewares/actionSerialization/applySerializedAction.ts +29 -20
- package/src/actionMiddlewares/actionSerialization/arraySerializer.ts +1 -1
- package/src/actionMiddlewares/actionSerialization/dateSerializer.ts +4 -3
- package/src/actionMiddlewares/actionSerialization/mapSerializer.ts +4 -12
- package/src/actionMiddlewares/actionSerialization/setSerializer.ts +4 -13
- package/src/actionMiddlewares/actionTrackingMiddleware.ts +11 -13
- package/src/actionMiddlewares/transactionMiddleware.ts +42 -11
- package/src/actionMiddlewares/undoMiddleware.ts +76 -60
- package/src/actionMiddlewares/utils.ts +2 -1
- package/src/computedTree/computedTree.ts +14 -3
- package/src/context/context.ts +17 -45
- package/src/dataModel/BaseDataModel.ts +20 -16
- package/src/dataModel/dataModelInstanceCache.ts +8 -0
- package/src/deepChange/onDeepChange.ts +179 -24
- package/src/frozen/Frozen.ts +50 -33
- package/src/model/BaseModel.ts +15 -14
- package/src/model/newModel.ts +32 -28
- package/src/model/utils.ts +2 -2
- package/src/modelShared/modelClassInitializer.ts +3 -2
- package/src/modelShared/modelDecorator.ts +34 -14
- package/src/modelShared/modelInfo.ts +1 -1
- package/src/modelShared/prop.ts +6 -9
- package/src/modelShared/sharedInternalModel.ts +16 -3
- package/src/parent/detach.ts +1 -1
- package/src/parent/findChildren.ts +4 -7
- package/src/parent/findParent.ts +14 -9
- package/src/parent/onChildAttachedTo.ts +45 -40
- package/src/parent/path.ts +11 -7
- package/src/parent/setParent.ts +33 -14
- package/src/parent/walkTree.ts +21 -37
- package/src/patch/applyPatches.ts +75 -60
- package/src/patch/emitPatch.ts +142 -26
- package/src/patch/jsonPatch.ts +5 -0
- package/src/patch/patchRecorder.ts +18 -14
- package/src/redux/connectReduxDevTools.ts +24 -18
- package/src/redux/redux.ts +5 -21
- package/src/ref/core.ts +18 -2
- package/src/rootStore/attachDetach.ts +27 -16
- package/src/rootStore/rootStore.ts +10 -6
- package/src/snapshot/SnapshotOf.ts +2 -2
- package/src/snapshot/applySnapshot.ts +10 -1
- package/src/snapshot/clone.ts +1 -2
- package/src/snapshot/cloneTreeValue.ts +1 -2
- package/src/snapshot/fromModelSnapshot.ts +6 -2
- package/src/snapshot/fromSnapshot.ts +3 -1
- package/src/snapshot/internal.ts +22 -9
- package/src/snapshot/modelInitialData.ts +14 -19
- package/src/snapshot/onSnapshot.ts +12 -1
- package/src/snapshot/reconcileModelSnapshot.ts +16 -8
- package/src/snapshot/reconcilePlainObjectSnapshot.ts +5 -4
- package/src/snapshot/reconcileSnapshot.ts +13 -4
- package/src/standardActions/arrayActions.ts +12 -2
- package/src/standardActions/objectActions.ts +3 -2
- package/src/transforms/ImmutableDate.ts +4 -0
- package/src/transforms/asMap.ts +3 -1
- package/src/treeUtils/deepEquals.ts +15 -13
- package/src/treeUtils/draft.ts +8 -0
- package/src/treeUtils/sandbox.ts +31 -27
- package/src/tweaker/core.ts +2 -4
- package/src/tweaker/tweak.ts +8 -8
- package/src/tweaker/tweakArray.ts +86 -37
- package/src/tweaker/tweakFrozen.ts +0 -1
- package/src/tweaker/tweakModel.ts +0 -1
- package/src/tweaker/tweakPlainObject.ts +78 -29
- package/src/tweaker/typeChecking.ts +132 -33
- package/src/types/TypeCheckError.ts +17 -19
- package/src/types/createCachedTypeCheck.ts +27 -2
- package/src/types/objectBased/typesDataModelData.ts +4 -2
- package/src/types/objectBased/typesModel.ts +4 -2
- package/src/types/objectBased/typesObject.ts +20 -16
- package/src/types/objectBased/typesRecord.ts +6 -13
- package/src/types/objectBased/typesRef.ts +2 -2
- package/src/types/primitiveBased/typesEnum.ts +4 -2
- package/src/types/primitiveBased/typesPrimitive.ts +9 -4
- package/src/types/typeCheckErrorUtils.ts +1 -0
- package/src/types/utility/typesCodecSupport.ts +97 -56
- package/src/types/utility/typesMap.ts +24 -41
- package/src/types/utility/typesRefinement.ts +3 -2
- package/src/types/utility/typesSet.ts +24 -0
- package/src/utils/ModelPool.ts +3 -3
- package/src/utils/chainFns.ts +4 -0
- package/src/utils/decorators.ts +1 -1
- package/src/utils/errorDiagnostics.ts +6 -2
- package/src/utils/forEachWithDelayedThrow.ts +83 -0
- package/src/utils/index.ts +34 -2
- package/src/utils/mapUtils.ts +3 -7
- package/src/utils/setIfDifferent.ts +3 -2
- package/src/utils/setLike.ts +134 -0
- package/src/wrappers/ArraySet.ts +5 -9
- package/src/wrappers/ObjectMap.ts +15 -11
- package/src/wrappers/asMap.ts +30 -18
- package/src/wrappers/asSet.ts +36 -12
- package/dist/types/action/modelFlowPromiseGenerator.d.ts +0 -1
- package/src/action/modelFlowPromiseGenerator.ts +0 -127
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// biome-ignore-all lint: transpiled TypeScript ES5 helper kept verbatim; its generated shape intentionally violates style and complexity rules.
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
function* promiseGenerator<T>(
|
|
5
|
-
this: Promise<T>
|
|
6
|
-
) {
|
|
7
|
-
const ret: T = yield this
|
|
8
|
-
return ret
|
|
9
|
-
}
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// above code but compiled by TS for ES5
|
|
13
|
-
// so we don't include a dependency to regenerator runtime
|
|
14
|
-
|
|
15
|
-
const __generator = function (thisArg: any, body: any) {
|
|
16
|
-
let _: any = {
|
|
17
|
-
label: 0,
|
|
18
|
-
sent: function () {
|
|
19
|
-
if (t[0] & 1) throw t[1]
|
|
20
|
-
return t[1]
|
|
21
|
-
},
|
|
22
|
-
trys: [],
|
|
23
|
-
ops: [],
|
|
24
|
-
},
|
|
25
|
-
f: any,
|
|
26
|
-
y: any,
|
|
27
|
-
t: any,
|
|
28
|
-
g: any
|
|
29
|
-
return (
|
|
30
|
-
(g = { next: verb(0), throw: verb(1), return: verb(2) }),
|
|
31
|
-
typeof Symbol === "function" &&
|
|
32
|
-
(g[Symbol.iterator] = function () {
|
|
33
|
-
return this
|
|
34
|
-
}),
|
|
35
|
-
g
|
|
36
|
-
)
|
|
37
|
-
function verb(n: any) {
|
|
38
|
-
return function (v: any) {
|
|
39
|
-
return step([n, v])
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function step(op: any) {
|
|
43
|
-
if (f) throw new TypeError("Generator is already executing.")
|
|
44
|
-
while (_)
|
|
45
|
-
try {
|
|
46
|
-
if (
|
|
47
|
-
((f = 1),
|
|
48
|
-
y &&
|
|
49
|
-
(t =
|
|
50
|
-
op[0] & 2
|
|
51
|
-
? y["return"]
|
|
52
|
-
: op[0]
|
|
53
|
-
? y["throw"] || ((t = y["return"]) && t.call(y), 0)
|
|
54
|
-
: y.next) &&
|
|
55
|
-
!(t = t.call(y, op[1])).done)
|
|
56
|
-
)
|
|
57
|
-
return t
|
|
58
|
-
if (((y = 0), t)) op = [op[0] & 2, t.value]
|
|
59
|
-
switch (op[0]) {
|
|
60
|
-
case 0:
|
|
61
|
-
case 1:
|
|
62
|
-
t = op
|
|
63
|
-
break
|
|
64
|
-
case 4:
|
|
65
|
-
_.label++
|
|
66
|
-
return { value: op[1], done: false }
|
|
67
|
-
case 5:
|
|
68
|
-
_.label++
|
|
69
|
-
y = op[1]
|
|
70
|
-
op = [0]
|
|
71
|
-
continue
|
|
72
|
-
case 7:
|
|
73
|
-
op = _.ops.pop()
|
|
74
|
-
_.trys.pop()
|
|
75
|
-
continue
|
|
76
|
-
default:
|
|
77
|
-
if (
|
|
78
|
-
!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) &&
|
|
79
|
-
(op[0] === 6 || op[0] === 2)
|
|
80
|
-
) {
|
|
81
|
-
_ = 0
|
|
82
|
-
continue
|
|
83
|
-
}
|
|
84
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
85
|
-
_.label = op[1]
|
|
86
|
-
break
|
|
87
|
-
}
|
|
88
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
89
|
-
_.label = t[1]
|
|
90
|
-
t = op
|
|
91
|
-
break
|
|
92
|
-
}
|
|
93
|
-
if (t && _.label < t[2]) {
|
|
94
|
-
_.label = t[2]
|
|
95
|
-
_.ops.push(op)
|
|
96
|
-
break
|
|
97
|
-
}
|
|
98
|
-
if (t[2]) _.ops.pop()
|
|
99
|
-
_.trys.pop()
|
|
100
|
-
continue
|
|
101
|
-
}
|
|
102
|
-
op = body.call(thisArg, _)
|
|
103
|
-
} catch (e) {
|
|
104
|
-
op = [6, e]
|
|
105
|
-
y = 0
|
|
106
|
-
} finally {
|
|
107
|
-
f = t = 0
|
|
108
|
-
}
|
|
109
|
-
if (op[0] & 5) throw op[1]
|
|
110
|
-
return { value: op[0] ? op[1] : void 0, done: true }
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function promiseGenerator(this: Promise<any>) {
|
|
115
|
-
let ret
|
|
116
|
-
return __generator(this, function (this: any, _a: any) {
|
|
117
|
-
switch (_a.label) {
|
|
118
|
-
case 0:
|
|
119
|
-
return [4 /*yield*/, this]
|
|
120
|
-
case 1:
|
|
121
|
-
ret = _a.sent()
|
|
122
|
-
return [2 /*return*/, ret]
|
|
123
|
-
default:
|
|
124
|
-
return
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
}
|