r-state-tree 0.6.3 → 0.8.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.
- package/README.md +190 -56
- package/dist/api.d.ts +2 -2
- package/dist/configuration.d.ts +10 -0
- package/dist/decorators.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/model/Model.d.ts +6 -10
- package/dist/model/ModelAdministration.d.ts +14 -0
- package/dist/model/idMap.d.ts +4 -4
- package/dist/observables/preact.d.ts +1 -1
- package/dist/r-state-tree.cjs +657 -305
- package/dist/r-state-tree.js +657 -305
- package/dist/store/Store.d.ts +6 -5
- package/dist/store/StoreAdministration.d.ts +8 -4
- package/dist/types.d.ts +8 -7
- package/package.json +58 -57
package/dist/store/Store.d.ts
CHANGED
|
@@ -8,13 +8,14 @@ type CreateStoreProps<T extends Record<string, any>> = {
|
|
|
8
8
|
export declare function createStore<K extends Store<any>, T extends Record<string, any> = K extends Store<infer P> ? P : never>(Type: new (props: StoreProps<T>) => K, props?: CreateStoreProps<T>): K;
|
|
9
9
|
export declare function updateStore<K extends Store<T>, T extends Record<string, any>>(store: K, props: CreateStoreProps<T>): K;
|
|
10
10
|
export declare function types<T extends Store>(config: Partial<StoreConfiguration<T>>): Partial<StoreConfiguration<T>>;
|
|
11
|
-
export default class Store<PropsType extends Record<string, any> = StoreProps<Props>> {
|
|
12
|
-
static
|
|
11
|
+
export default class Store<PropsType extends Record<string, any> = StoreProps<Props>> implements Disposable {
|
|
12
|
+
static types?: StoreConfiguration<unknown>;
|
|
13
13
|
props: StoreProps<PropsType>;
|
|
14
14
|
constructor(props: StoreProps<PropsType>);
|
|
15
15
|
get key(): string | number | undefined;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
get isMounted(): boolean;
|
|
17
|
+
reaction<T>(track: () => T, callback: (value: T, previousValue: T) => void): () => void;
|
|
18
|
+
effect(callback: () => void | (() => void)): () => void;
|
|
19
|
+
[Symbol.dispose](): void;
|
|
19
20
|
}
|
|
20
21
|
export {};
|
|
@@ -6,10 +6,11 @@ export declare function getStoreAdm(store: Store): StoreAdministration;
|
|
|
6
6
|
export declare class StoreAdministration<StoreType extends Store = Store> extends ObjectAdministration<Store> {
|
|
7
7
|
static proxyTraps: ProxyHandler<object>;
|
|
8
8
|
parent: StoreAdministration | null;
|
|
9
|
-
|
|
9
|
+
private mountedSignal;
|
|
10
|
+
private disposed;
|
|
10
11
|
private contextCache;
|
|
11
12
|
private childStoreDataMap;
|
|
12
|
-
private
|
|
13
|
+
private ownedDisposers;
|
|
13
14
|
private configurationGetter?;
|
|
14
15
|
setConfiguration(configurationGetter: () => StoreConfiguration<StoreType>): void;
|
|
15
16
|
private get configuration();
|
|
@@ -22,9 +23,12 @@ export declare class StoreAdministration<StoreType extends Store = Store> extend
|
|
|
22
23
|
private getStore;
|
|
23
24
|
private getModelRef;
|
|
24
25
|
isRoot(): boolean;
|
|
26
|
+
get isMounted(): boolean;
|
|
25
27
|
getContextValue<T>(contextId: symbol, provideSymbol: symbol, defaultValue: T | undefined, hasDefault: boolean): T;
|
|
26
28
|
private lookupContextValue;
|
|
27
|
-
|
|
29
|
+
private own;
|
|
30
|
+
reaction<T>(track: () => T, callback: (value: T, previousValue: T) => void): () => void;
|
|
31
|
+
effect(callback: () => void | (() => void)): () => void;
|
|
28
32
|
mount(parent?: StoreAdministration | null, childName?: PropertyKey): void;
|
|
29
|
-
|
|
33
|
+
dispose(internal?: boolean): void;
|
|
30
34
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -45,11 +45,12 @@ export declare enum ObservableCfgTypes {
|
|
|
45
45
|
computed = "computed"
|
|
46
46
|
}
|
|
47
47
|
export type ConfigurationTypes = CommonCfgTypes | ModelCfgTypes | StoreCfgTypes | ObservableCfgTypes;
|
|
48
|
-
export type
|
|
48
|
+
export type ConfigurationValue = {
|
|
49
49
|
type: ConfigurationTypes;
|
|
50
50
|
childType?: Function;
|
|
51
51
|
[key: string]: unknown;
|
|
52
52
|
};
|
|
53
|
+
export type ConfigurationType = ConfigurationValue | Function;
|
|
53
54
|
export type ModelConfiguration<T> = Record<PropertyKey, ConfigurationType>;
|
|
54
55
|
export type StoreConfiguration<T> = Record<PropertyKey, ConfigurationType>;
|
|
55
56
|
export type Configuration<T> = ModelConfiguration<T> | StoreConfiguration<T>;
|
|
@@ -69,14 +70,14 @@ export type RefSnapshot = {
|
|
|
69
70
|
[key: string]: IdType;
|
|
70
71
|
[key: number]: IdType;
|
|
71
72
|
};
|
|
72
|
-
export declare const childType: ((childType: Function) =>
|
|
73
|
+
export declare const childType: ((childType: Function) => ConfigurationValue) & {
|
|
73
74
|
type: CommonCfgTypes;
|
|
74
75
|
};
|
|
75
|
-
export declare const stateType:
|
|
76
|
-
export declare const modelRefType: ((childType: Function) =>
|
|
76
|
+
export declare const stateType: ConfigurationValue;
|
|
77
|
+
export declare const modelRefType: ((childType: Function) => ConfigurationValue) & {
|
|
77
78
|
type: ModelCfgTypes;
|
|
78
79
|
};
|
|
79
|
-
export declare const idType:
|
|
80
|
-
export declare const modelType:
|
|
81
|
-
export declare const computedType:
|
|
80
|
+
export declare const idType: ConfigurationValue;
|
|
81
|
+
export declare const modelType: ConfigurationValue;
|
|
82
|
+
export declare const computedType: ConfigurationValue;
|
|
82
83
|
export {};
|
package/package.json
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
2
|
+
"name": "r-state-tree",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "reactive state management library",
|
|
5
|
+
"main": "dist/r-state-tree.cjs",
|
|
6
|
+
"module": "dist/r-state-tree.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/r-state-tree.js",
|
|
12
|
+
"require": "./dist/r-state-tree.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/*",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:watch": "vitest",
|
|
23
|
+
"test:cover": "vitest run --coverage",
|
|
24
|
+
"build": "vite build && pnpm run build:types",
|
|
25
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
26
|
+
"lint": "eslint ./src ./tests --ext .ts",
|
|
27
|
+
"format": "prettier --cache --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
28
|
+
"prepublishOnly": "pnpm run build"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/melnikov-s/r-state-tree.git"
|
|
33
|
+
},
|
|
34
|
+
"author": "Sergey Melnikov",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/melnikov-s/r-state-tree/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/melnikov-s/r-state-tree#readme",
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@tsmetadata/polyfill": "^1.1.3",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
|
43
|
+
"@typescript-eslint/parser": "^5.8.1",
|
|
44
|
+
"eslint": "^8.5.0",
|
|
45
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
46
|
+
"eslint-config-prettier": "^8.3.0",
|
|
47
|
+
"eslint-import-resolver-typescript": "^2.5.0",
|
|
48
|
+
"eslint-plugin-import": "^2.25.3",
|
|
49
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
50
|
+
"prettier": "^2.8.4",
|
|
51
|
+
"tslib": "^2.5.0",
|
|
52
|
+
"typescript": "5.9.3",
|
|
53
|
+
"vite": "7.1.9",
|
|
54
|
+
"vitest": "3.2.4"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@preact/signals-core": "^1.12.1"
|
|
58
|
+
}
|
|
59
|
+
}
|