mobx-state-tree 5.3.1-alpha.1 → 5.4.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.
@@ -1,4 +1,4 @@
1
- import { IType, IAnyType } from "../../internal";
1
+ import { IType, IAnyType, Instance } from "../../internal";
2
2
  /** @hidden */
3
3
  declare const $mstNotCustomized: unique symbol;
4
4
  /** @hidden */
@@ -15,16 +15,16 @@ export interface ISnapshotProcessor<IT extends IAnyType, CustomC, CustomS> exten
15
15
  /**
16
16
  * Snapshot processors.
17
17
  */
18
- export interface ISnapshotProcessors<C, CustomC, S, CustomS> {
18
+ export interface ISnapshotProcessors<IT extends IAnyType, CustomC, CustomS> {
19
19
  /**
20
20
  * Function that transforms an input snapshot.
21
21
  */
22
- preProcessor?(snapshot: CustomC): C;
22
+ preProcessor?(snapshot: CustomC): IT["CreationType"];
23
23
  /**
24
24
  * Function that transforms an output snapshot.
25
25
  * @param snapshot
26
26
  */
27
- postProcessor?(snapshot: S): CustomS;
27
+ postProcessor?(snapshot: IT["SnapshotType"], node: Instance<IT>): CustomS;
28
28
  }
29
29
  /**
30
30
  * `types.snapshotProcessor` - Runs a pre/post snapshot processor before/after serializing a given type.
@@ -36,15 +36,17 @@ export interface ISnapshotProcessors<C, CustomC, S, CustomS> {
36
36
  * interface BackendTodo {
37
37
  * text: string | null
38
38
  * }
39
+ *
39
40
  * const Todo2 = types.snapshotProcessor(Todo1, {
40
41
  * // from snapshot to instance
41
- * preProcessor(sn: BackendTodo) {
42
+ * preProcessor(snapshot: BackendTodo) {
42
43
  * return {
43
44
  * text: sn.text || "";
44
45
  * }
45
46
  * },
47
+ *
46
48
  * // from instance to snapshot
47
- * postProcessor(sn): BackendTodo {
49
+ * postProcessor(snapshot, node): BackendTodo {
48
50
  * return {
49
51
  * text: !sn.text ? null : sn.text
50
52
  * }
@@ -57,5 +59,5 @@ export interface ISnapshotProcessors<C, CustomC, S, CustomS> {
57
59
  * @param name Type name, or undefined to inherit the inner type one.
58
60
  * @returns
59
61
  */
60
- export declare function snapshotProcessor<IT extends IAnyType, CustomC = _NotCustomized, CustomS = _NotCustomized>(type: IT, processors: ISnapshotProcessors<IT["CreationType"], CustomC, IT["SnapshotType"], CustomS>, name?: string): ISnapshotProcessor<IT, CustomC, CustomS>;
62
+ export declare function snapshotProcessor<IT extends IAnyType, CustomC = _NotCustomized, CustomS = _NotCustomized>(type: IT, processors: ISnapshotProcessors<IT, CustomC, CustomS>, name?: string): ISnapshotProcessor<IT, CustomC, CustomS>;
61
63
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-state-tree",
3
- "version": "5.3.1-alpha.1",
3
+ "version": "5.4.0",
4
4
  "description": "Opinionated, transactional, MobX powered state container",
5
5
  "main": "dist/mobx-state-tree.js",
6
6
  "umd:main": "dist/mobx-state-tree.umd.js",
@@ -17,7 +17,6 @@
17
17
  "scripts": {
18
18
  "clean": "shx rm -rf dist && shx rm -rf lib",
19
19
  "build": "yarn clean && tsc && cpr lib dist --filter=\\.js$ && rollup -c",
20
- "jest": "jest --testPathPattern=/__tests__/core/",
21
20
  "jest:perf": "jest --testPathPattern=/__tests__/perf/",
22
21
  "test:perf": "yarn build && yarn jest:perf && TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' /usr/bin/time node --expose-gc --require ts-node/register __tests__/perf/report.ts",
23
22
  "test": "yarn test:dev && yarn test:prod",