mobx-keystone 1.24.0 → 1.25.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 +18 -0
- package/LICENSE +21 -21
- package/README.md +16 -11
- package/dist/mobx-keystone.esm.js +204 -202
- package/dist/mobx-keystone.esm.mjs +204 -202
- package/dist/mobx-keystone.umd.js +204 -202
- package/dist/types/modelShared/BaseModelShared.d.ts +7 -1
- package/dist/types/modelShared/prop.d.ts +5 -0
- package/dist/types/types/TypeChecker.d.ts +79 -0
- package/dist/types/types/schemas.d.ts +15 -0
- package/package.json +10 -9
- package/src/actionMiddlewares/undoMiddleware.ts +11 -14
- package/src/model/BaseModel.ts +11 -5
- package/src/model/newModel.ts +11 -4
- package/src/modelShared/BaseModelShared.ts +1 -1
- package/src/modelShared/prop.ts +1 -1
- package/src/parent/findParent.ts +14 -9
- package/src/parent/onChildAttachedTo.ts +1 -12
- package/src/parent/path.ts +6 -4
- package/src/parent/setParent.ts +26 -14
- package/src/patch/applyPatches.ts +10 -30
- package/src/snapshot/applySnapshot.ts +9 -0
- package/src/snapshot/fromSnapshot.ts +3 -1
- package/src/snapshot/modelInitialData.ts +14 -19
- package/src/snapshot/reconcileModelSnapshot.ts +11 -3
- package/src/snapshot/reconcileSnapshot.ts +13 -4
- package/src/tweaker/tweak.ts +6 -7
- package/src/tweaker/tweakArray.ts +3 -17
- package/src/tweaker/tweakFrozen.ts +0 -1
- package/src/tweaker/tweakModel.ts +0 -1
- package/src/tweaker/tweakPlainObject.ts +2 -6
- package/src/tweaker/typeChecking.ts +9 -19
- package/src/types/TypeChecker.ts +6 -6
- package/src/types/schemas.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 1.25.0
|
|
4
|
+
|
|
5
|
+
- Performance: reduced scalar mutation overhead by returning primitive values before entering internal MobX actions used for tree bookkeeping.
|
|
6
|
+
- Performance: applying the current snapshot by reference skips model-pool construction, avoiding a tree traversal on first use. Pending child changes are still flushed before treating the snapshot as unchanged.
|
|
7
|
+
- Performance: reduced automatic type-checking overhead for nested model mutations by traversing logical parents directly.
|
|
8
|
+
- Performance: reduce reconciliation work for non-null primitive model fields during snapshot updates, skipping unchanged fields and directly assigning changed scalar values.
|
|
9
|
+
- Performance: reduced construction work for models created from empty data with primitive defaults, reusing their initialization snapshot instead of rereading observable fields. Structured defaults retain the general initialization path.
|
|
10
|
+
- Performance: `findParent` no longer constructs a discarded path array while searching ancestors. `findParentPath` shares the same traversal and retains its existing path output.
|
|
11
|
+
- Performance: reduced child-set copying overhead in `onChildAttachedTo`, improving attachment tracking for large collections.
|
|
12
|
+
- Performance: path construction now scales linearly with tree depth, avoiding repeated array front insertions in `getRootPath`, `getParentToChildPath`, and `findParentPath`.
|
|
13
|
+
- Performance: reduced `applySnapshot` traversal overhead by using internal snapshots for reconciliation comparisons, avoiding unnecessary snapshot freezing and observation metadata. Fresh 10,000-item editor snapshot refreshes take about 9–17% less time in local benchmarks.
|
|
14
|
+
- Performance: reduced snapshot hydration work for models with primitive defaults or regenerated IDs by updating the existing initialization snapshot instead of rebuilding it from observable data. Initialization bookkeeping also allocates fewer temporary objects.
|
|
15
|
+
- Performance: reduced large-array insertion and removal overhead by batching parent-path reindexing for unchanged children. Moving the first model to the end of a 10k–50k-item editor list is about 30% faster with undo and snapshot observation enabled.
|
|
16
|
+
|
|
17
|
+
## 1.24.1
|
|
18
|
+
|
|
19
|
+
- Fixed a serious type-safety regression in the declarations published with versions 1.20.0 through 1.24.0, where `types.object(...)` data, snapshot, and stored-data types could collapse to `{ [x: string]: any }`. This allowed incorrect property values, unknown properties, and arbitrary property access to pass TypeScript checks. The missing declaration dependencies are now retained, restoring the exact object shape and optional-property inference, and package builds now fully type-check every generated declaration to prevent this from recurring.
|
|
20
|
+
|
|
3
21
|
## 1.24.0
|
|
4
22
|
|
|
5
23
|
- Added MobX 7 compatibility with standard-decorator coverage across TypeScript, Babel, and SWC.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Javier González Garcés
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Javier González Garcés
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="./apps/site/static/img/logo-dark.png" />
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="./apps/site/static/img/logo-light.png" />
|
|
5
|
+
<img src="./apps/site/static/img/logo-light.png" alt="mobx-keystone" height="128" />
|
|
6
|
+
</picture>
|
|
3
7
|
<h1 align="center">mobx-keystone</h1>
|
|
4
8
|
</p>
|
|
5
9
|
<p align="center">
|
|
6
|
-
<i>A MobX
|
|
10
|
+
<i>A MobX-powered state management solution based on data trees, with first-class support for TypeScript, snapshots, patches, and much more</i>
|
|
7
11
|
</p>
|
|
8
12
|
|
|
9
13
|
<p align="center">
|
|
@@ -32,9 +36,7 @@
|
|
|
32
36
|
>
|
|
33
37
|
> ## [mobx-keystone.js.org](https://mobx-keystone.js.org)
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
#### New! Loro CRDT bindings for `mobx-keystone` are now available in the `mobx-keystone-loro` package with native move operation support for arrays, as well as a working example in the examples section of the online docs.
|
|
39
|
+
Collaborative editing is available through the [`mobx-keystone-yjs`](https://mobx-keystone.js.org/integrations/yjs-binding) and [`mobx-keystone-loro`](https://mobx-keystone.js.org/integrations/loro-binding) CRDT bindings, with complete examples in the online docs.
|
|
38
40
|
|
|
39
41
|
## Introduction
|
|
40
42
|
|
|
@@ -46,6 +48,7 @@ You can think of it as a TypeScript-first model layer on top of MobX that scales
|
|
|
46
48
|
### Quick links
|
|
47
49
|
|
|
48
50
|
- [Installation](https://mobx-keystone.js.org/installation)
|
|
51
|
+
- [Getting Started](https://mobx-keystone.js.org/getting-started)
|
|
49
52
|
- [Class Models](https://mobx-keystone.js.org/class-models)
|
|
50
53
|
- [Todo List Example](https://mobx-keystone.js.org/examples/todo-list)
|
|
51
54
|
- [MST Migration Guide](https://mobx-keystone.js.org/mst-migration-guide)
|
|
@@ -124,21 +127,23 @@ Model instances are created from props, protect their own updates, and reconcile
|
|
|
124
127
|
|
|
125
128
|
## Requirements
|
|
126
129
|
|
|
127
|
-
This library requires a
|
|
130
|
+
This library requires a modern JavaScript environment with support for:
|
|
128
131
|
|
|
129
132
|
- MobX 7, 6, 5 (or 4 with its gotchas)
|
|
130
133
|
- Proxies
|
|
131
134
|
- Symbols
|
|
132
135
|
- WeakMap/WeakSet
|
|
133
136
|
|
|
134
|
-
In
|
|
137
|
+
In practice, this covers current browsers and Node.js releases, but not Internet Explorer.
|
|
135
138
|
|
|
136
|
-
|
|
139
|
+
TypeScript 5.0 or newer is recommended so you can use standard decorators. 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.
|
|
137
140
|
|
|
138
141
|
## Installation
|
|
139
142
|
|
|
140
|
-
> `npm install mobx-keystone`
|
|
143
|
+
> `npm install mobx mobx-keystone`
|
|
144
|
+
|
|
145
|
+
> `yarn add mobx mobx-keystone`
|
|
141
146
|
|
|
142
|
-
> `
|
|
147
|
+
> `pnpm add mobx mobx-keystone`
|
|
143
148
|
|
|
144
|
-
|
|
149
|
+
`mobx` is a peer dependency and must be installed alongside `mobx-keystone`.
|