mobx 6.13.7 → 6.15.1
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 +24 -0
- package/README.md +2 -1
- package/dist/api/flow.d.ts +4 -4
- package/dist/api/observable.d.ts +10 -2
- package/dist/mobx.cjs.development.js +75 -10
- 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.d.ts +1 -1
- package/dist/mobx.esm.js +75 -10
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.umd.development.js +75 -10
- 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/dist/types/observablemap.d.ts +1 -1
- package/package.json +5 -5
- package/src/api/flow.ts +10 -3
- package/src/api/observable.ts +22 -4
- package/src/core/reaction.ts +4 -0
- package/src/mobx.ts +1 -0
- package/src/types/autoannotation.ts +5 -2
- package/src/types/observablemap.ts +1 -1
- package/src/types/observablevalue.ts +1 -1
- package/dist/mobx.esm.development.js +0 -5935
- package/dist/mobx.esm.development.js.map +0 -1
- package/dist/mobx.esm.production.min.js +0 -2
- package/dist/mobx.esm.production.min.js.map +0 -1
|
@@ -5,7 +5,7 @@ export interface IKeyValueMap<V = any> {
|
|
|
5
5
|
export type IMapEntry<K = any, V = any> = [K, V];
|
|
6
6
|
export type IReadonlyMapEntry<K = any, V = any> = readonly [K, V];
|
|
7
7
|
export type IMapEntries<K = any, V = any> = IMapEntry<K, V>[];
|
|
8
|
-
export type IReadonlyMapEntries<K = any, V = any> = IReadonlyMapEntry<K, V>[];
|
|
8
|
+
export type IReadonlyMapEntries<K = any, V = any> = readonly IReadonlyMapEntry<K, V>[];
|
|
9
9
|
export type IMapDidChange<K = any, V = any> = {
|
|
10
10
|
observableKind: "map";
|
|
11
11
|
debugObjectName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.15.1",
|
|
4
4
|
"description": "Simple, scalable state management.",
|
|
5
5
|
"source": "src/mobx.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "https://github.com/mobxjs/mobx.git"
|
|
25
|
+
"url": "git+https://github.com/mobxjs/mobx.git"
|
|
26
26
|
},
|
|
27
27
|
"author": "Michel Weststrate",
|
|
28
28
|
"license": "MIT",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"data flow"
|
|
62
62
|
],
|
|
63
63
|
"scripts": {
|
|
64
|
-
"test": "jest",
|
|
64
|
+
"test": "jest --config jest.projects.js",
|
|
65
65
|
"lint": "eslint src/**/*",
|
|
66
66
|
"build": "node ../../scripts/build.js mobx",
|
|
67
|
-
"build:test": "
|
|
67
|
+
"build:test": "npm run build --target test",
|
|
68
68
|
"perf": "scripts/perf.sh",
|
|
69
69
|
"perf-legacy": "node --expose-gc ./__tests__/perf/index.js legacy",
|
|
70
70
|
"perf-proxy": "node --expose-gc ./__tests__/perf/index.js proxy",
|
|
@@ -75,6 +75,6 @@
|
|
|
75
75
|
"test:coverage": "yarn test -i --coverage",
|
|
76
76
|
"test:size": "yarn import-size --report . observable computed autorun action",
|
|
77
77
|
"test:check": "yarn test:types",
|
|
78
|
-
"prepublishOnly": "node ./scripts/prepublish.js &&
|
|
78
|
+
"prepublishOnly": "node ./scripts/prepublish.js && npm run build --target publish"
|
|
79
79
|
}
|
|
80
80
|
}
|
package/src/api/flow.ts
CHANGED
|
@@ -17,10 +17,17 @@ export const FLOW = "flow"
|
|
|
17
17
|
|
|
18
18
|
let generatorId = 0
|
|
19
19
|
|
|
20
|
-
export
|
|
21
|
-
|
|
20
|
+
export class FlowCancellationError extends Error {
|
|
21
|
+
constructor() {
|
|
22
|
+
super("FLOW_CANCELLED")
|
|
23
|
+
Object.setPrototypeOf(this, new.target.prototype)
|
|
24
|
+
this.name = "FlowCancellationError"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
toString() {
|
|
28
|
+
return `Error: ${this.message}`
|
|
29
|
+
}
|
|
22
30
|
}
|
|
23
|
-
FlowCancellationError.prototype = Object.create(Error.prototype)
|
|
24
31
|
|
|
25
32
|
export function isFlowCancellationError(error: Error) {
|
|
26
33
|
return error instanceof FlowCancellationError
|
package/src/api/observable.ts
CHANGED
|
@@ -3,6 +3,9 @@ import {
|
|
|
3
3
|
IEqualsComparer,
|
|
4
4
|
IObservableArray,
|
|
5
5
|
IObservableMapInitialValues,
|
|
6
|
+
IMapEntries,
|
|
7
|
+
IReadonlyMapEntries,
|
|
8
|
+
IKeyValueMap,
|
|
6
9
|
IObservableSetInitialValues,
|
|
7
10
|
IObservableValue,
|
|
8
11
|
ObservableMap,
|
|
@@ -151,6 +154,24 @@ export interface IObservableValueFactory {
|
|
|
151
154
|
<T>(value?: T, options?: CreateObservableOptions): IObservableValue<T | undefined>
|
|
152
155
|
}
|
|
153
156
|
|
|
157
|
+
export interface IObservableMapFactory {
|
|
158
|
+
<K = any, V = any>(): ObservableMap<K, V>
|
|
159
|
+
<K, V>(initialValues?: IMapEntries<K, V>, options?: CreateObservableOptions): ObservableMap<
|
|
160
|
+
K,
|
|
161
|
+
V
|
|
162
|
+
>
|
|
163
|
+
<K, V>(
|
|
164
|
+
initialValues?: IReadonlyMapEntries<K, V>,
|
|
165
|
+
options?: CreateObservableOptions
|
|
166
|
+
): ObservableMap<K, V>
|
|
167
|
+
<K, V>(initialValues?: IKeyValueMap<V>, options?: CreateObservableOptions): ObservableMap<K, V>
|
|
168
|
+
<K, V>(initialValues?: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>
|
|
169
|
+
<K = any, V = any>(initialValues: undefined, options?: CreateObservableOptions): ObservableMap<
|
|
170
|
+
K,
|
|
171
|
+
V
|
|
172
|
+
>
|
|
173
|
+
}
|
|
174
|
+
|
|
154
175
|
export interface IObservableFactory
|
|
155
176
|
extends Annotation,
|
|
156
177
|
PropertyDecorator,
|
|
@@ -172,10 +193,7 @@ export interface IObservableFactory
|
|
|
172
193
|
initialValues?: IObservableSetInitialValues<T>,
|
|
173
194
|
options?: CreateObservableOptions
|
|
174
195
|
) => ObservableSet<T>
|
|
175
|
-
map:
|
|
176
|
-
initialValues?: IObservableMapInitialValues<K, V>,
|
|
177
|
-
options?: CreateObservableOptions
|
|
178
|
-
) => ObservableMap<K, V>
|
|
196
|
+
map: IObservableMapFactory
|
|
179
197
|
object: <T = any>(
|
|
180
198
|
props: T,
|
|
181
199
|
decorators?: AnnotationsMap<T, never>,
|
package/src/core/reaction.ts
CHANGED
|
@@ -240,6 +240,10 @@ export class Reaction implements IDerivation, IReactionPublic {
|
|
|
240
240
|
abortSignal?.addEventListener?.("abort", dispose)
|
|
241
241
|
dispose[$mobx] = this
|
|
242
242
|
|
|
243
|
+
if ("dispose" in Symbol && typeof Symbol.dispose === "symbol") {
|
|
244
|
+
dispose[Symbol.dispose] = dispose
|
|
245
|
+
}
|
|
246
|
+
|
|
243
247
|
return dispose
|
|
244
248
|
}
|
|
245
249
|
|
package/src/mobx.ts
CHANGED
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
autoAction,
|
|
11
11
|
isGenerator,
|
|
12
12
|
MakeResult,
|
|
13
|
-
die
|
|
13
|
+
die,
|
|
14
|
+
isAction
|
|
14
15
|
} from "../internal"
|
|
15
16
|
|
|
16
17
|
const AUTO = "true"
|
|
@@ -40,7 +41,9 @@ function make_(
|
|
|
40
41
|
// lone setter -> action setter
|
|
41
42
|
if (descriptor.set) {
|
|
42
43
|
// TODO make action applicable to setter and delegate to action.make_
|
|
43
|
-
const set =
|
|
44
|
+
const set = isAction(descriptor.set)
|
|
45
|
+
? descriptor.set // See #4553
|
|
46
|
+
: (createAction(key.toString(), descriptor.set) as (v: any) => void)
|
|
44
47
|
// own
|
|
45
48
|
if (source === adm.target_) {
|
|
46
49
|
return adm.defineProperty_(key, {
|
|
@@ -46,7 +46,7 @@ export interface IKeyValueMap<V = any> {
|
|
|
46
46
|
export type IMapEntry<K = any, V = any> = [K, V]
|
|
47
47
|
export type IReadonlyMapEntry<K = any, V = any> = readonly [K, V]
|
|
48
48
|
export type IMapEntries<K = any, V = any> = IMapEntry<K, V>[]
|
|
49
|
-
export type IReadonlyMapEntries<K = any, V = any> = IReadonlyMapEntry<K, V>[]
|
|
49
|
+
export type IReadonlyMapEntries<K = any, V = any> = readonly IReadonlyMapEntry<K, V>[]
|
|
50
50
|
|
|
51
51
|
export type IMapDidChange<K = any, V = any> = { observableKind: "map"; debugObjectName: string } & (
|
|
52
52
|
| {
|