mobx-state-tree 7.0.0-pre.2 → 7.0.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.
@@ -1,8 +1,17 @@
1
1
  import { IType, IAnyType, _NotCustomized } from "../../internal";
2
- export type ITypeDispatcher = (snapshot: any) => IAnyType;
3
- export interface UnionOptions {
2
+ export type ITypeDispatcher<Types extends IAnyType[]> = (snapshot: Types[number]["SnapshotType"]) => Types[number];
3
+ export interface UnionOptions<Types extends IAnyType[]> {
4
+ /**
5
+ * Whether or not to use eager validation.
6
+ *
7
+ * When `true`, the first matching type will be used. Otherwise, all types will be checked and the
8
+ * validation will pass if and only if a single type matches.
9
+ */
4
10
  eager?: boolean;
5
- dispatcher?: ITypeDispatcher;
11
+ /**
12
+ * A function that returns the type to be used given an input snapshot.
13
+ */
14
+ dispatcher?: ITypeDispatcher<Types>;
6
15
  }
7
16
  /**
8
17
  * Transform _NotCustomized | _NotCustomized... to _NotCustomized, _NotCustomized | A | B to A | B
@@ -14,7 +23,7 @@ export interface ITypeUnion<C, S, T> extends IType<_CustomCSProcessor<C>, _Custo
14
23
  }
15
24
  export type IUnionType<Types extends IAnyType[]> = ITypeUnion<Types[number]["CreationType"], Types[number]["SnapshotType"], Types[number]["TypeWithoutSTN"]>;
16
25
  export declare function union<Types extends IAnyType[]>(...types: Types): IUnionType<Types>;
17
- export declare function union<Types extends IAnyType[]>(options: UnionOptions, ...types: Types): IUnionType<Types>;
26
+ export declare function union<Types extends IAnyType[]>(options: UnionOptions<Types>, ...types: Types): IUnionType<Types>;
18
27
  /**
19
28
  * Returns if a given value represents a union type.
20
29
  *
package/package.json CHANGED
@@ -1,112 +1,114 @@
1
1
  {
2
- "name": "mobx-state-tree",
3
- "version": "7.0.0-pre.2",
4
- "description": "Opinionated, transactional, MobX powered state container",
5
- "main": "dist/mobx-state-tree.js",
6
- "umd:main": "dist/mobx-state-tree.umd.js",
7
- "module": "dist/mobx-state-tree.module.js",
8
- "browser": {
9
- "./dist/mobx-state-tree.js": "./dist/mobx-state-tree.js",
10
- "./dist/mobx-state-tree.module.js": "./dist/mobx-state-tree.module.js"
11
- },
12
- "unpkg": "dist/mobx-state-tree.umd.min.js",
13
- "jsnext:main": "dist/mobx-state-tree.module.js",
14
- "react-native": "dist/mobx-state-tree.module.js",
15
- "typings": "dist/index.d.ts",
16
- "sideEffects": false,
17
- "scripts": {
18
- "clean": "shx rm -rf dist lib",
19
- "build": "bun run clean && tsc && cpr lib/src dist --filter=\\.js$ && rollup -c",
20
- "test:dev": "./scripts/bun-test-dev.sh",
21
- "test:prod": "./scripts/bun-test-prod.sh",
22
- "test:all": "bun run test:dev && bun run test:prod && bun run size",
23
- "test:perf": "bun test ./__tests__/perf/",
24
- "test:perf:compiled": "bun run build && bun run jest:perf && TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' /usr/bin/time node --expose-gc --require ts-node/register __tests__/perf/report.ts",
25
- "typecheck": "tsc --noEmit",
26
- "size": "size-limit",
27
- "tag-new-version": "yarn version && git push --tags",
28
- "build-docs": "bun run fix-typedoc && shx rm -rf ./docs/API && typedoc --options ./typedocconfig.js",
29
- "publish-docs": "bun run build-docs && cd ./website && GIT_USER=jamonholmgren USE_SSH=true bun run publish-gh-pages",
30
- "start": "cd website && bun run start",
31
- "prepare": "husky install",
32
- "lint": "tslint -c ./tslint.json 'src/**/*.ts'",
33
- "fix-typedoc": "shx rm -rf ./node_modules/typedoc/node_modules/typescript",
34
- "prettier:list": "prettier --list-different \"src/**/*.ts\" \"__tests__/**/*.ts\"",
35
- "prettier:check": "prettier --check \"src/**/*.ts\" \"__tests__/**/*.ts\"",
36
- "prettier:write": "prettier --write \"src/**/*.ts\" \"__tests__/**/*.ts\""
37
- },
38
- "lint-staged": {
39
- "*.{ts,tsx,js,jsx}": [
40
- "prettier --write"
2
+ "name": "mobx-state-tree",
3
+ "version": "7.0.1",
4
+ "description": "Opinionated, transactional, MobX powered state container",
5
+ "main": "dist/mobx-state-tree.js",
6
+ "umd:main": "dist/mobx-state-tree.umd.js",
7
+ "module": "dist/mobx-state-tree.module.js",
8
+ "browser": {
9
+ "./dist/mobx-state-tree.js": "./dist/mobx-state-tree.js",
10
+ "./dist/mobx-state-tree.module.js": "./dist/mobx-state-tree.module.js"
11
+ },
12
+ "unpkg": "dist/mobx-state-tree.umd.min.js",
13
+ "jsnext:main": "dist/mobx-state-tree.module.js",
14
+ "react-native": "dist/mobx-state-tree.module.js",
15
+ "typings": "dist/index.d.ts",
16
+ "sideEffects": false,
17
+ "scripts": {
18
+ "clean": "shx rm -rf dist lib",
19
+ "build": "bun run clean && tsc && cpr lib/src dist --filter=\\.js$ && rollup -c",
20
+ "test:dev": "NODE_ENV=development bun test",
21
+ "test:prod": "MST_TESTING=1 NODE_ENV=production bun test",
22
+ "test:all": "bun run test:dev && bun run test:prod && bun run size",
23
+ "test:perf": "bun test ./__tests__/perf/",
24
+ "test:perf:compiled": "bun run build && bun run jest:perf && TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' /usr/bin/time node --expose-gc --require ts-node/register __tests__/perf/report.ts",
25
+ "typecheck": "tsc --noEmit",
26
+ "size": "size-limit",
27
+ "tag-new-version": "yarn version && git push --tags",
28
+ "build-docs": "bun run fix-typedoc && shx rm -rf ./docs/API && typedoc --options ./typedocconfig.js",
29
+ "publish-docs": "bun run build-docs && cd ./website && GIT_USER=jamonholmgren USE_SSH=true bun run publish-gh-pages",
30
+ "start": "cd website && bun run start",
31
+ "prepare": "husky install",
32
+ "lint": "tslint -c ./tslint.json 'src/**/*.ts'",
33
+ "fix-typedoc": "shx rm -rf ./node_modules/typedoc/node_modules/typescript",
34
+ "prettier:list": "prettier --list-different \"src/**/*.ts\" \"__tests__/**/*.ts\"",
35
+ "prettier:check": "prettier --check \"src/**/*.ts\" \"__tests__/**/*.ts\"",
36
+ "prettier:write": "prettier --write \"src/**/*.ts\" \"__tests__/**/*.ts\""
37
+ },
38
+ "lint-staged": {
39
+ "*.{ts,tsx,js,jsx}": [
40
+ "prettier --write"
41
+ ]
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/mobxjs/mobx-state-tree.git"
46
+ },
47
+ "author": "Michel Weststrate",
48
+ "license": "MIT",
49
+ "bugs": {
50
+ "url": "https://github.com/mobxjs/mobx-state-tree/issues"
51
+ },
52
+ "files": [
53
+ "dist/"
54
+ ],
55
+ "devDependencies": {
56
+ "@size-limit/preset-big-lib": "^5.0.3",
57
+ "@types/bun": "^1.0.6",
58
+ "@types/node": "^12.0.2",
59
+ "concat": "^1.0.3",
60
+ "coveralls": "^3.1.0",
61
+ "cpr": "^3.0.1",
62
+ "husky": "^7.0.0",
63
+ "lint-staged": "^11.1.2",
64
+ "mobx": "^6.13.1",
65
+ "prettier": "3.4.1",
66
+ "rollup": "^2.18.1",
67
+ "rollup-plugin-commonjs": "^10.0.0",
68
+ "rollup-plugin-filesize": "^9.0.1",
69
+ "rollup-plugin-node-resolve": "^5.0.0",
70
+ "rollup-plugin-replace": "^2.1.0",
71
+ "rollup-plugin-terser": "^6.1.0",
72
+ "shx": "^0.3.2",
73
+ "size-limit": "^5.0.3",
74
+ "ts-essentials": "^9.4.1",
75
+ "ts-node": "^8.10.2",
76
+ "tslib": "^2.0.0",
77
+ "tslint": "^6.1.3",
78
+ "tslint-config-prettier": "^1.18.0",
79
+ "typedoc": "0.15.8",
80
+ "typedoc-plugin-markdown": "2.2.11",
81
+ "typescript": "^5.3.3",
82
+ "yarn-deduplicate": "^3.1.0"
83
+ },
84
+ "peerDependencies": {
85
+ "mobx": "^6.3.0"
86
+ },
87
+ "keywords": [
88
+ "mobx",
89
+ "mobx-state-tree",
90
+ "promise",
91
+ "reactive",
92
+ "frp",
93
+ "functional-reactive-programming",
94
+ "state management"
95
+ ],
96
+ "gitHead": "27ec7ac0b0743a367fb01a7f40192f3042bd91f2",
97
+ "prettier": {
98
+ "printWidth": 100,
99
+ "semi": false,
100
+ "tabWidth": 4,
101
+ "singleQuote": false,
102
+ "trailingComma": "none",
103
+ "arrowParens": "avoid",
104
+ "useTabs": false
105
+ },
106
+ "size-limit": [
107
+ {
108
+ "path": "./dist/mobx-state-tree.min.js",
109
+ "limit": "25 KB",
110
+ "webpack": false,
111
+ "running": false
112
+ }
41
113
  ]
42
- },
43
- "repository": {
44
- "type": "git",
45
- "url": "https://github.com/mobxjs/mobx-state-tree.git"
46
- },
47
- "author": "Michel Weststrate",
48
- "license": "MIT",
49
- "bugs": {
50
- "url": "https://github.com/mobxjs/mobx-state-tree/issues"
51
- },
52
- "files": [
53
- "dist/"
54
- ],
55
- "devDependencies": {
56
- "@size-limit/preset-big-lib": "^5.0.3",
57
- "@types/bun": "^1.0.6",
58
- "@types/node": "^12.0.2",
59
- "concat": "^1.0.3",
60
- "coveralls": "^3.1.0",
61
- "cpr": "^3.0.1",
62
- "husky": "^7.0.0",
63
- "lint-staged": "^11.1.2",
64
- "mobx": "^6.3.0",
65
- "prettier": "^2.4.1",
66
- "rollup": "^2.18.1",
67
- "rollup-plugin-commonjs": "^10.0.0",
68
- "rollup-plugin-filesize": "^9.0.1",
69
- "rollup-plugin-node-resolve": "^5.0.0",
70
- "rollup-plugin-replace": "^2.1.0",
71
- "rollup-plugin-terser": "^6.1.0",
72
- "shx": "^0.3.2",
73
- "size-limit": "^5.0.3",
74
- "ts-essentials": "^9.4.1",
75
- "ts-node": "^8.10.2",
76
- "tslib": "^2.0.0",
77
- "tslint": "^6.1.3",
78
- "tslint-config-prettier": "^1.18.0",
79
- "typedoc": "0.15.8",
80
- "typedoc-plugin-markdown": "2.2.11",
81
- "typescript": "^5.3.3",
82
- "yarn-deduplicate": "^3.1.0"
83
- },
84
- "peerDependencies": {
85
- "mobx": "^6.3.0"
86
- },
87
- "keywords": [
88
- "mobx",
89
- "mobx-state-tree",
90
- "promise",
91
- "reactive",
92
- "frp",
93
- "functional-reactive-programming",
94
- "state management"
95
- ],
96
- "gitHead": "27ec7ac0b0743a367fb01a7f40192f3042bd91f2",
97
- "prettier": {
98
- "printWidth": 100,
99
- "tabWidth": 2,
100
- "singleQuote": false,
101
- "trailingComma": "none",
102
- "semi": false
103
- },
104
- "size-limit": [
105
- {
106
- "path": "./dist/mobx-state-tree.min.js",
107
- "limit": "25 KB",
108
- "webpack": false,
109
- "running": false
110
- }
111
- ]
112
114
  }