mobx-keystone 2.1.0 → 2.2.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 +11 -0
- package/README.md +1 -1
- package/dist/mobx-keystone.esm.js +275 -489
- package/dist/mobx-keystone.esm.mjs +275 -489
- package/dist/mobx-keystone.umd.js +274 -492
- package/dist/types/actionMiddlewares/undoMiddleware.d.ts +2 -10
- package/dist/types/modelShared/modelDecorator.d.ts +5 -2
- package/dist/types/modelShared/prop.d.ts +42 -29
- package/dist/types/ref/Ref.d.ts +1 -4
- package/dist/types/snapshot/SnapshotOf.d.ts +4 -4
- package/dist/types/snapshot/applySnapshot.d.ts +1 -1
- package/dist/types/snapshot/fromSnapshot.d.ts +2 -2
- package/dist/types/snapshot/getSnapshot.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/schemas.d.ts +41 -37
- package/dist/types/types/tProp.d.ts +12 -6
- package/dist/types/types/types.d.ts +6 -6
- package/dist/types/types/utility/typeToStoredData.d.ts +14 -10
- package/dist/types/types/utility/typesCodecCore.d.ts +3 -0
- package/dist/types/utils/ModelPool.d.ts +0 -1
- package/dist/types/utils/types.d.ts +6 -0
- package/dist/types/wrappers/ArraySet.d.ts +1 -0
- package/package.json +4 -2
- package/src/action/modelFlow.ts +35 -66
- package/src/actionMiddlewares/actionTrackingMiddleware.ts +41 -71
- package/src/actionMiddlewares/transactionMiddleware.ts +1 -1
- package/src/actionMiddlewares/undoMiddleware.ts +16 -22
- package/src/context/context.ts +15 -36
- package/src/dataModel/utils.ts +5 -28
- package/src/deepChange/onDeepChange.ts +44 -126
- package/src/model/BaseModel.ts +1 -1
- package/src/model/utils.ts +5 -10
- package/src/modelShared/modelDecorator.ts +11 -5
- package/src/modelShared/prop.ts +115 -111
- package/src/modelShared/sharedInternalModel.ts +2 -2
- package/src/parent/arrayPaths.ts +1 -4
- package/src/parent/path.ts +0 -10
- package/src/patch/patchRecorder.ts +13 -28
- package/src/ref/core.ts +6 -19
- package/src/rootStore/rootStore.ts +1 -3
- package/src/snapshot/SnapshotOf.ts +24 -48
- package/src/snapshot/applySnapshot.ts +1 -1
- package/src/snapshot/fromSnapshot.ts +10 -3
- package/src/snapshot/getSnapshot.ts +1 -1
- package/src/snapshot/internal.ts +0 -2
- package/src/snapshot/reconcileModelSnapshot.ts +5 -3
- package/src/snapshot/reconcilePlainObjectSnapshot.ts +3 -1
- package/src/treeUtils/draft.ts +6 -1
- package/src/treeUtils/sandbox.ts +10 -7
- package/src/tweaker/tweakArray.ts +20 -50
- package/src/tweaker/tweakPlainObject.ts +9 -15
- package/src/types/arrayBased/typesArray.ts +13 -19
- package/src/types/arrayBased/typesTuple.ts +16 -25
- package/src/types/createCachedTypeCheck.ts +17 -30
- package/src/types/index.ts +1 -0
- package/src/types/objectBased/typesDataModelData.ts +7 -8
- package/src/types/objectBased/typesObject.ts +11 -15
- package/src/types/objectBased/typesRecord.ts +11 -15
- package/src/types/schemas.ts +59 -71
- package/src/types/tProp.ts +29 -29
- package/src/types/utility/typeToStoredData.ts +22 -21
- package/src/types/utility/typesCodecCore.ts +5 -0
- package/src/types/utility/typesCodecSupport.ts +3 -3
- package/src/types/utility/typesMap.ts +43 -51
- package/src/types/utility/typesRefinement.ts +7 -8
- package/src/types/utility/typesSkipCheck.ts +7 -8
- package/src/types/utility/typesTag.ts +7 -8
- package/src/utils/ModelPool.ts +1 -18
- package/src/utils/decorators.ts +5 -5
- package/src/utils/index.ts +1 -20
- package/src/utils/types.ts +5 -0
- package/src/wrappers/ArraySet.ts +27 -14
- package/src/wrappers/ObjectMap.ts +1 -6
- package/src/wrappers/asMap.ts +1 -21
- package/src/wrappers/asSet.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
- Now requires TypeScript 5.4 or newer (the types use the built-in `NoInfer`).
|
|
6
|
+
- Faster TypeScript type-checking of models and runtime types: the snapshot, model data and `types.object` type mappings now create far fewer type instantiations (about 35% fewer in a typical model-heavy project), with no change to the resulting types. `tProp` defaults, `fromSnapshot(type, snapshot)`, `getSnapshot(type, value)` and `applySnapshot` no longer infer their type parameter from the data / snapshot argument, which makes those calls much cheaper to type-check (e.g. about 40% fewer instantiations for a typed `fromSnapshot` call). The `@model` decorator also no longer computes the creation data type of the decorated class. A typed `fromSnapshot(type, snapshot)` call now also accepts the output snapshot type of `type` (which must always round-trip, as with `applySnapshot` and the untyped `fromSnapshot(snapshot)`), so round trips such as `fromSnapshot(M, getSnapshot(m))` no longer compare the output and input snapshot types (about 65% cheaper to type-check).
|
|
7
|
+
- Smaller and faster declaration (`.d.ts`) emit for exported model classes: the types of `idProp` and `tProp` properties (`TypedModelIdProp`, `TypedMaybeOptionalModelProp`, `TypedOptionalModelProp`) and `CodecFromEncoded` are now exported, so emitted declarations reference them by name instead of expanding them inline.
|
|
8
|
+
- Fixed the types of `tProp` codec props (e.g. `tProp(types.dateAsTimestamp)`) after `.withSetter()`, `.withSnapshotProcessor()` or `.withTransform()`: `$` and snapshots now use the encoded type (e.g. `number`) instead of the runtime type (e.g. `Date`). The new `ModelPropWithSetter`, `ModelPropWithSnapshotProcessor` and `ModelPropWithTransform` types describe the props these modifiers return.
|
|
9
|
+
- Fixed `applySnapshot` throwing when the snapshot adds an object under a key named like an `Object.prototype` member (e.g. `toString` or `constructor`).
|
|
10
|
+
- Fixed `Draft`'s `isDirty` not being cached and `commit` / `reset` not running as MobX actions with MobX 6.
|
|
11
|
+
- `fromSnapshot` (and `cloneTreeValue` for plain objects / arrays) now reports a clear error when the snapshot contains tree nodes, instead of a generic "unsupported snapshot".
|
|
12
|
+
- Fixed `ArraySet` set operations (`union`, `intersection`, `isSubsetOf`, etc.) throwing on runtimes without the native ES2025 `Set` methods.
|
|
13
|
+
|
|
3
14
|
## 2.1.0
|
|
4
15
|
|
|
5
16
|
- [BREAKING CHANGE] `UndoStore` keeps undo/redo events as frozen data, making recording ~4x faster and undo/redo ~3x faster:
|
package/README.md
CHANGED
|
@@ -136,7 +136,7 @@ This library requires a modern JavaScript environment with support for:
|
|
|
136
136
|
|
|
137
137
|
In practice, this covers current browsers and Node.js releases, but not Internet Explorer.
|
|
138
138
|
|
|
139
|
-
TypeScript 5.
|
|
139
|
+
When using TypeScript, version 5.4 or newer is required. Legacy decorators remain supported by `mobx-keystone`; see the [installation guide](https://mobx-keystone.js.org/installation) for the required compiler configuration and the MobX 7 compatibility note.
|
|
140
140
|
|
|
141
141
|
## Installation
|
|
142
142
|
|