mobx-keystone 2.0.0 → 2.1.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 +22 -0
- package/dist/mobx-keystone.esm.js +2341 -780
- package/dist/mobx-keystone.esm.mjs +2341 -780
- package/dist/mobx-keystone.umd.js +2346 -782
- package/dist/types/actionMiddlewares/transactionMiddleware.d.ts +1 -1
- package/dist/types/actionMiddlewares/undoMiddleware.d.ts +17 -10
- package/dist/types/parent/arrayPaths.d.ts +1 -0
- package/dist/types/parent/treeOrder.d.ts +1 -0
- package/dist/types/patch/applyPatches.d.ts +2 -1
- package/dist/types/ref/modelRefIdIndex.d.ts +1 -0
- package/dist/types/ref/nodesById.d.ts +1 -0
- package/dist/types/ref/refIdIndex.d.ts +1 -0
- package/dist/types/snapshot/applySnapshot.d.ts +1 -0
- package/dist/types/snapshot/fromSnapshot.d.ts +0 -3
- package/dist/types/tweaker/changeRollback.d.ts +1 -0
- package/dist/types/tweaker/tweakedChangeListeners.d.ts +1 -0
- package/dist/types/utils/ModelPool.d.ts +7 -1
- package/dist/types/utils/chunks.d.ts +1 -0
- package/package.json +2 -2
- package/src/actionMiddlewares/transactionMiddleware.ts +40 -41
- package/src/actionMiddlewares/undoMiddleware.ts +47 -13
- package/src/model/BaseModel.ts +6 -4
- package/src/modelShared/modelDecorator.ts +5 -25
- package/src/parent/arrayPaths.ts +242 -0
- package/src/parent/coreObjectChildren.ts +300 -48
- package/src/parent/onChildAttachedTo.ts +130 -44
- package/src/parent/path.ts +10 -2
- package/src/parent/setParent.ts +27 -15
- package/src/parent/treeOrder.ts +53 -0
- package/src/parent/walkTree.ts +0 -73
- package/src/patch/applyPatches.ts +31 -26
- package/src/ref/core.ts +63 -27
- package/src/ref/modelRefIdIndex.ts +131 -0
- package/src/ref/nodesById.ts +60 -0
- package/src/ref/refIdIndex.ts +209 -0
- package/src/snapshot/applySnapshot.ts +26 -18
- package/src/snapshot/fromPlainObjectSnapshot.ts +3 -8
- package/src/snapshot/fromSnapshot.ts +2 -6
- package/src/snapshot/internal.ts +67 -10
- package/src/tweaker/changeRollback.ts +218 -0
- package/src/tweaker/core.ts +33 -20
- package/src/tweaker/treeNodeMetadata.ts +12 -2
- package/src/tweaker/tweak.ts +181 -18
- package/src/tweaker/tweakArray.ts +107 -27
- package/src/tweaker/tweakPlainObject.ts +56 -31
- package/src/tweaker/tweakedChangeListeners.ts +61 -0
- package/src/tweaker/typeChecking.ts +5 -104
- package/src/types/arrayBased/typesArray.ts +10 -11
- package/src/types/createCachedTypeCheck.ts +522 -94
- package/src/types/objectBased/typesRecord.ts +2 -5
- package/src/utils/ModelPool.ts +75 -19
- package/src/utils/chunks.ts +271 -0
- package/src/utils/index.ts +37 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
- [BREAKING CHANGE] `UndoStore` keeps undo/redo events as frozen data, making recording ~4x faster and undo/redo ~3x faster:
|
|
6
|
+
- Snapshots and patches store events as `{ $frozen: true, data: event }`. Older snapshots still load, but earlier versions cannot load newer ones.
|
|
7
|
+
- Events passed when creating an `UndoStore` must be wrapped with `frozen(event)`.
|
|
8
|
+
- `undoQueue` / `redoQueue` events are plain objects, and attached states are no longer copied.
|
|
9
|
+
- Performance on large trees: operations that used to rescan or rebuild state for the whole tree now only update what changed (e.g. at 16,000 items, from milliseconds to microseconds):
|
|
10
|
+
- array splices (`shift`, `unshift`, `splice`, `detach`);
|
|
11
|
+
- `rootRef` / `resolveId` and `getRefsResolvingTo`;
|
|
12
|
+
- structural `applyPatches` / `applySnapshot`, which also makes undo/redo no longer quadratic when the `UndoStore` is inside the tracked tree;
|
|
13
|
+
- `getSnapshot` / `onSnapshot` after splices and key changes;
|
|
14
|
+
- `onChildAttachedTo`;
|
|
15
|
+
- runtime type checking of large arrays, records and `ObjectMap`s, and of key changes in deep trees;
|
|
16
|
+
- transactions, which no longer build patches to roll back.
|
|
17
|
+
- Tree nodes use ~30% less memory and are ~15% faster to create. Models without MobX decorators no longer get a MobX observable administration, so `isObservableObject(model)` is now `false` for them.
|
|
18
|
+
- Rejected tree changes (e.g. assigning a `Map`, a node that already has a parent, or the same node twice) now leave the tree unchanged instead of half-changed.
|
|
19
|
+
- Inserting an array item at its own index (e.g. `arr.unshift(arr[0])`) now throws instead of putting the same node in the array twice.
|
|
20
|
+
- `applySnapshot` / `applyPatches` now undo their changes when they throw partway.
|
|
21
|
+
- Fixed `transactionMiddleware` / `@transaction` not fully restoring the state when the failed action detached, changed and reattached a model.
|
|
22
|
+
- Fixed `applySnapshot` / `applyPatches` not reusing a model whose id had changed.
|
|
23
|
+
- Fixed `onAttachedToRootStore` not being called for models inside a plain tree node attached to a root store.
|
|
24
|
+
|
|
3
25
|
## 2.0.0
|
|
4
26
|
|
|
5
27
|
- [BREAKING CHANGE] Preserve repeated property names and array indexes in type-check error paths when validating an attached subtree. Paths supplied to `TypeCheckError` and `TypeCheckErrorFailure` are now consistently treated as relative to the checked value; manually supplied rooted paths are no longer detected automatically.
|