mobx-state-tree 7.0.0-pre.1 → 7.0.0-pre.2
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/dist/core/type/type.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IValidationContext, IValidationResult, IStateTreeNode, ModelPrimitive } from "../../internal";
|
|
2
|
+
import type { WritableKeys } from "ts-essentials";
|
|
2
3
|
/**
|
|
3
4
|
* A state tree node value.
|
|
4
5
|
* @hidden
|
|
@@ -6,6 +7,7 @@ import { IValidationContext, IValidationResult, IStateTreeNode, ModelPrimitive }
|
|
|
6
7
|
export type STNValue<T, IT extends IAnyType> = T extends object ? T & IStateTreeNode<IT> : T;
|
|
7
8
|
/** @hidden */
|
|
8
9
|
declare const $type: unique symbol;
|
|
10
|
+
type ExcludeReadonly<T> = T extends {} ? T[WritableKeys<T>] : T;
|
|
9
11
|
/**
|
|
10
12
|
* A type, either complex or simple.
|
|
11
13
|
*/
|
|
@@ -25,7 +27,7 @@ export interface IType<C, S, T> {
|
|
|
25
27
|
*
|
|
26
28
|
* @returns An instance of that type.
|
|
27
29
|
*/
|
|
28
|
-
create(snapshot?: C
|
|
30
|
+
create(snapshot?: C | ExcludeReadonly<T>, env?: any): this["Type"];
|
|
29
31
|
/**
|
|
30
32
|
* Checks if a given snapshot / instance is of the given type.
|
|
31
33
|
*
|
|
@@ -40,7 +42,7 @@ export interface IType<C, S, T> {
|
|
|
40
42
|
* @param context Validation context, an array of { subpaths, subtypes } that should be validated
|
|
41
43
|
* @returns The validation result, an array with the list of validation errors.
|
|
42
44
|
*/
|
|
43
|
-
validate(thing: C, context: IValidationContext): IValidationResult;
|
|
45
|
+
validate(thing: C | T, context: IValidationContext): IValidationResult;
|
|
44
46
|
/**
|
|
45
47
|
* Gets the textual representation of the type as a string.
|
|
46
48
|
*/
|
|
@@ -41,7 +41,7 @@ type DefinablePropsNames<T> = {
|
|
|
41
41
|
}[keyof T];
|
|
42
42
|
/** @hidden */
|
|
43
43
|
export type ExtractCFromProps<P extends ModelProperties> = MaybeEmpty<{
|
|
44
|
-
[k in keyof P]: P[k]["CreationType"];
|
|
44
|
+
[k in keyof P]: P[k]["CreationType"] | P[k]["TypeWithoutSTN"];
|
|
45
45
|
}>;
|
|
46
46
|
/** @hidden */
|
|
47
47
|
export type MaybeEmpty<T> = keyof T extends never ? EmptyObject : T;
|
|
@@ -19,12 +19,12 @@ export interface ISnapshotProcessors<IT extends IAnyType, CustomC, CustomS> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Function that transforms an input snapshot.
|
|
21
21
|
*/
|
|
22
|
-
preProcessor?(snapshot: CustomC): IT["CreationType"];
|
|
22
|
+
preProcessor?(snapshot: _CustomOrOther<CustomC, IT["CreationType"]>): IT["CreationType"];
|
|
23
23
|
/**
|
|
24
24
|
* Function that transforms an output snapshot.
|
|
25
25
|
* @param snapshot
|
|
26
26
|
*/
|
|
27
|
-
postProcessor?(snapshot: IT["SnapshotType"], node: Instance<IT>): CustomS
|
|
27
|
+
postProcessor?(snapshot: IT["SnapshotType"], node: Instance<IT>): _CustomOrOther<CustomS, IT["SnapshotType"]>;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* `types.snapshotProcessor` - Runs a pre/post snapshot processor before/after serializing a given type.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-state-tree",
|
|
3
|
-
"version": "7.0.0-pre.
|
|
3
|
+
"version": "7.0.0-pre.2",
|
|
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",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"typings": "dist/index.d.ts",
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"scripts": {
|
|
18
|
-
"clean": "shx rm -rf dist
|
|
19
|
-
"build": "bun run clean && tsc && cpr lib dist --filter=\\.js$ && rollup -c",
|
|
18
|
+
"clean": "shx rm -rf dist lib",
|
|
19
|
+
"build": "bun run clean && tsc && cpr lib/src dist --filter=\\.js$ && rollup -c",
|
|
20
20
|
"test:dev": "./scripts/bun-test-dev.sh",
|
|
21
21
|
"test:prod": "./scripts/bun-test-prod.sh",
|
|
22
22
|
"test:all": "bun run test:dev && bun run test:prod && bun run size",
|