mobx 7.0.1 → 7.0.3
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 +16 -0
- package/dist/mobx.cjs.development.js +34 -11
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.esm.development.js +34 -11
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +184 -159
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.mjs +184 -159
- package/dist/mobx.mjs.map +1 -1
- package/dist/mobx.umd.development.js +34 -11
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/package.json +5 -1
- package/src/types/observableset.ts +36 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 7.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6f002b8e543ca39d3ee23681e28848d7f1724fae`](https://github.com/mobxjs/mobx/commit/6f002b8e543ca39d3ee23681e28848d7f1724fae) [#4696](https://github.com/mobxjs/mobx/pull/4696) Thanks [@gesposito](https://github.com/gesposito)! - perf: add a `node` export condition that routes Node and Bun to the existing `dist/index.js` entry, which picks the prebaked development or production CJS build once at require time. `import`ing mobx in Node no longer executes the env-agnostic `dist/mobx.mjs` with per-call `NODE_ENV` checks, and mixing `import` and `require` in one Node app now yields a single mobx instance.
|
|
8
|
+
|
|
9
|
+
## 7.0.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`ec1b708026c1578e1c1f6c7bd90be18b26f7ce85`](https://github.com/mobxjs/mobx/commit/ec1b708026c1578e1c1f6c7bd90be18b26f7ce85) [#4695](https://github.com/mobxjs/mobx/pull/4695) Thanks [@gesposito](https://github.com/gesposito)! - perf: evaluate `NODE_ENV` once at module scope in the env-agnostic esm bundles (`dist/<pkg>.esm.js` and `dist/<pkg>.mjs`) instead of at every `__DEV__` call site. `process.env` is an exotic object in Node, so each check performed a real environment lookup on hot paths; consumers that execute these files as-is (Node ESM, vitest, SSR) see roughly 10x faster observable writes in dev mode. All env-set artifacts and bundler output are unchanged.
|
|
14
|
+
|
|
15
|
+
- [`6d8b5fa6c7596d7e5b16e55e3121d81c0c5bb21a`](https://github.com/mobxjs/mobx/commit/6d8b5fa6c7596d7e5b16e55e3121d81c0c5bb21a) [#4672](https://github.com/mobxjs/mobx/pull/4672) Thanks [@chatman-media](https://github.com/chatman-media)! - Fix `ObservableSet.replace` emitting spurious `delete`/`add` events (and triggering reactions) for values that are unchanged. It now only fires `delete` for removed values and `add` for newly added ones, mirroring `ObservableMap.replace`.
|
|
16
|
+
|
|
17
|
+
Note: because `replace` no longer clears and re-adds every value, the iteration order after `replace` changes in a (subtle but observable) way. Surviving values now keep their original relative position and newly added values are appended, instead of the whole set being reordered to match the argument. For example, `set(["a", "b", "c"]).replace(["d", "b", "a"])` previously iterated as `d, b, a`, and now iterates as `a, b, d`. This is arguably the more correct behavior (unchanged values are genuinely unchanged), but if you relied on `replace` reordering the set to match its argument, you may need to adjust.
|
|
18
|
+
|
|
3
19
|
## 7.0.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -4399,17 +4399,40 @@ class ObservableSet {
|
|
|
4399
4399
|
if (isObservableSet(other)) {
|
|
4400
4400
|
other = new Set(other);
|
|
4401
4401
|
}
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4402
|
+
if (Array.isArray(other) || isES6Set(other)) {
|
|
4403
|
+
// Only emit `delete`/`add` events (and `reportChanged`) for values that
|
|
4404
|
+
// actually change, instead of clearing and re-adding everything. `add` and
|
|
4405
|
+
// `delete` are already no-ops for values that are respectively already
|
|
4406
|
+
// present or already absent, so we just need to avoid deleting values that
|
|
4407
|
+
// are part of the replacement. See #3761.
|
|
4408
|
+
transaction(() => {
|
|
4409
|
+
// Collect the desired values for quick lookup. `other` is already a Set
|
|
4410
|
+
// here when it was passed (or snapshotted from an observable set) as one,
|
|
4411
|
+
// so reuse it rather than allocating another; arrays are wrapped (which
|
|
4412
|
+
// also dedupes them).
|
|
4413
|
+
const replacementValues = isES6Set(other) ? other : new Set(other);
|
|
4414
|
+
// Short-circuit the trivial cases: an empty replacement is just a clear,
|
|
4415
|
+
// and replacing into an empty set only needs the adds.
|
|
4416
|
+
if (replacementValues.size === 0) {
|
|
4417
|
+
this.clear();
|
|
4418
|
+
return;
|
|
4419
|
+
}
|
|
4420
|
+
if (this.data_.size === 0) {
|
|
4421
|
+
replacementValues.forEach(value => this.add(value));
|
|
4422
|
+
return;
|
|
4423
|
+
}
|
|
4424
|
+
// Delete values that are not part of the replacement.
|
|
4425
|
+
for (const value of this.data_.values()) {
|
|
4426
|
+
if (!replacementValues.has(this.dehanceValue_(value))) {
|
|
4427
|
+
this.delete(value);
|
|
4428
|
+
}
|
|
4429
|
+
}
|
|
4430
|
+
// Add new values; values that are already present are a no-op.
|
|
4431
|
+
replacementValues.forEach(value => this.add(value));
|
|
4432
|
+
});
|
|
4433
|
+
} else if (other !== null && other !== undefined) {
|
|
4434
|
+
die(41, other);
|
|
4435
|
+
}
|
|
4413
4436
|
return this;
|
|
4414
4437
|
}
|
|
4415
4438
|
toJSON() {
|