@homeostate/store-mobx-state-tree 0.1.2 → 0.2.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/CHANGELOG.md +14 -0
- package/dist/adapter.d.ts +5 -19
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +21 -24
- package/dist/adapter.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/adapter.ts +21 -24
- package/src/index.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @homeostate/store-mobx-state-tree
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 81d1d18: Stop exporting the adapter classes (`JotaiAdapter`, `MobxAdapter`, `MobxStateTreeAdapter`, `ReduxAdapter`, `TanStackStoreAdapter`, `ValtioAdapter`, `ZustandAdapter`); create adapters with the `create*Adapter` factories, which now carry the adapter docs and examples.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 33c7b14: Mark the package side-effect free, so bundlers can drop modules that are not imported.
|
|
12
|
+
- Updated dependencies [a643bbe]
|
|
13
|
+
- Updated dependencies [0bbf653]
|
|
14
|
+
- Updated dependencies [fb76f77]
|
|
15
|
+
- @homeostate/core@0.2.0
|
|
16
|
+
|
|
3
17
|
## 0.1.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { type IStateTreeNode, type IType } from "mobx-state-tree";
|
|
2
|
-
import type { StoreAdapter
|
|
2
|
+
import type { StoreAdapter } from "@homeostate/core";
|
|
3
3
|
/** A state tree node whose output snapshot is `S` */
|
|
4
4
|
export type SnapshotNode<S> = IStateTreeNode<IType<unknown, S, unknown>>;
|
|
5
5
|
/**
|
|
6
|
-
* MobX-State-Tree adapter that syncs a tree node through its snapshots.
|
|
6
|
+
* Creates a MobX-State-Tree adapter that syncs a tree node through its snapshots.
|
|
7
7
|
* Snapshots go to the backend once per action, and remote changes are applied
|
|
8
8
|
* with `applySnapshot`, so instances with identifiers are reconciled in place.
|
|
9
9
|
*
|
|
10
|
+
* @param node - The tree node to sync; usually the root instance
|
|
11
|
+
* @returns StoreAdapter instance for the node
|
|
12
|
+
*
|
|
10
13
|
* @example
|
|
11
14
|
* ```typescript
|
|
12
15
|
* import { types } from 'mobx-state-tree';
|
|
@@ -24,22 +27,5 @@ export type SnapshotNode<S> = IStateTreeNode<IType<unknown, S, unknown>>;
|
|
|
24
27
|
* counter.increment();
|
|
25
28
|
* ```
|
|
26
29
|
*/
|
|
27
|
-
export declare class MobxStateTreeAdapter<S extends object> implements StoreAdapter<S> {
|
|
28
|
-
private node;
|
|
29
|
-
/**
|
|
30
|
-
* Create a MobX-State-Tree adapter
|
|
31
|
-
* @param node - The tree node to sync; usually the root instance
|
|
32
|
-
*/
|
|
33
|
-
constructor(node: SnapshotNode<S>);
|
|
34
|
-
getState(): S;
|
|
35
|
-
setState(state: S): void;
|
|
36
|
-
subscribe(onStoreChange: () => void): Unsubscribe;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Factory function to create a MobX-State-Tree adapter
|
|
40
|
-
*
|
|
41
|
-
* @param node - The tree node to sync; usually the root instance
|
|
42
|
-
* @returns StoreAdapter instance for the node
|
|
43
|
-
*/
|
|
44
30
|
export declare function createMobxStateTreeAdapter<S extends object>(node: SnapshotNode<S>): StoreAdapter<S>;
|
|
45
31
|
//# sourceMappingURL=adapter.d.ts.map
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,KAAK,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,KAAK,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAElE,qDAAqD;AACrD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AA0BzE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,MAAM,EACzD,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GACpB,YAAY,CAAC,CAAC,CAAC,CAEjB"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
1
|
import { applySnapshot, getSnapshot, onSnapshot, } from "mobx-state-tree";
|
|
2
|
-
|
|
3
|
-
* MobX-State-Tree adapter that syncs a tree node through its snapshots.
|
|
4
|
-
* Snapshots go to the backend once per action, and remote changes are applied
|
|
5
|
-
* with `applySnapshot`, so instances with identifiers are reconciled in place.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { types } from 'mobx-state-tree';
|
|
10
|
-
* import * as Y from 'yjs';
|
|
11
|
-
* import { createYjsBackend } from '@homeostate/crdt-yjs';
|
|
12
|
-
*
|
|
13
|
-
* const Counter = types
|
|
14
|
-
* .model({ count: 0 })
|
|
15
|
-
* .actions((self) => ({ increment() { self.count++; } }));
|
|
16
|
-
*
|
|
17
|
-
* const counter = Counter.create();
|
|
18
|
-
* const adapter = createMobxStateTreeAdapter(counter);
|
|
19
|
-
* const engine = createSyncEngine(createYjsBackend(new Y.Doc(), 'shared'), adapter);
|
|
20
|
-
* engine.connect();
|
|
21
|
-
* counter.increment();
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export class MobxStateTreeAdapter {
|
|
2
|
+
class MobxStateTreeAdapter {
|
|
25
3
|
/**
|
|
26
4
|
* Create a MobX-State-Tree adapter
|
|
27
5
|
* @param node - The tree node to sync; usually the root instance
|
|
@@ -46,10 +24,29 @@ export class MobxStateTreeAdapter {
|
|
|
46
24
|
}
|
|
47
25
|
}
|
|
48
26
|
/**
|
|
49
|
-
*
|
|
27
|
+
* Creates a MobX-State-Tree adapter that syncs a tree node through its snapshots.
|
|
28
|
+
* Snapshots go to the backend once per action, and remote changes are applied
|
|
29
|
+
* with `applySnapshot`, so instances with identifiers are reconciled in place.
|
|
50
30
|
*
|
|
51
31
|
* @param node - The tree node to sync; usually the root instance
|
|
52
32
|
* @returns StoreAdapter instance for the node
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { types } from 'mobx-state-tree';
|
|
37
|
+
* import * as Y from 'yjs';
|
|
38
|
+
* import { createYjsBackend } from '@homeostate/crdt-yjs';
|
|
39
|
+
*
|
|
40
|
+
* const Counter = types
|
|
41
|
+
* .model({ count: 0 })
|
|
42
|
+
* .actions((self) => ({ increment() { self.count++; } }));
|
|
43
|
+
*
|
|
44
|
+
* const counter = Counter.create();
|
|
45
|
+
* const adapter = createMobxStateTreeAdapter(counter);
|
|
46
|
+
* const engine = createSyncEngine(createYjsBackend(new Y.Doc(), 'shared'), adapter);
|
|
47
|
+
* engine.connect();
|
|
48
|
+
* counter.increment();
|
|
49
|
+
* ```
|
|
53
50
|
*/
|
|
54
51
|
export function createMobxStateTreeAdapter(node) {
|
|
55
52
|
return new MobxStateTreeAdapter(node);
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,GAGX,MAAM,iBAAiB,CAAC;AAMzB
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,GAGX,MAAM,iBAAiB,CAAC;AAMzB,MAAM,oBAAoB;IAGxB;;;OAGG;IACH,YAAY,IAAqB;QANzB;;;;;WAAsB;QAO5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ;QACN,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,QAAQ,CAAC,KAAQ;QACf,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,SAAS,CAAC,aAAyB;QACjC,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC,CAAC;IACtD,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAAqB;IAErB,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createMobxStateTreeAdapter } from "./adapter.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homeostate/store-mobx-state-tree",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MobX-State-Tree adapter for @homeostate/core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"default": "./dist/index.js"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
"sideEffects": false,
|
|
32
33
|
"files": [
|
|
33
34
|
"dist",
|
|
34
35
|
"src",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"access": "public"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@homeostate/core": "^0.
|
|
45
|
+
"@homeostate/core": "^0.2.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
48
|
"mobx": "^6.0.0 || ^7.0.0",
|
package/src/adapter.ts
CHANGED
|
@@ -10,29 +10,7 @@ import type { StoreAdapter, Unsubscribe } from "@homeostate/core";
|
|
|
10
10
|
/** A state tree node whose output snapshot is `S` */
|
|
11
11
|
export type SnapshotNode<S> = IStateTreeNode<IType<unknown, S, unknown>>;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
* MobX-State-Tree adapter that syncs a tree node through its snapshots.
|
|
15
|
-
* Snapshots go to the backend once per action, and remote changes are applied
|
|
16
|
-
* with `applySnapshot`, so instances with identifiers are reconciled in place.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* import { types } from 'mobx-state-tree';
|
|
21
|
-
* import * as Y from 'yjs';
|
|
22
|
-
* import { createYjsBackend } from '@homeostate/crdt-yjs';
|
|
23
|
-
*
|
|
24
|
-
* const Counter = types
|
|
25
|
-
* .model({ count: 0 })
|
|
26
|
-
* .actions((self) => ({ increment() { self.count++; } }));
|
|
27
|
-
*
|
|
28
|
-
* const counter = Counter.create();
|
|
29
|
-
* const adapter = createMobxStateTreeAdapter(counter);
|
|
30
|
-
* const engine = createSyncEngine(createYjsBackend(new Y.Doc(), 'shared'), adapter);
|
|
31
|
-
* engine.connect();
|
|
32
|
-
* counter.increment();
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export class MobxStateTreeAdapter<S extends object> implements StoreAdapter<S> {
|
|
13
|
+
class MobxStateTreeAdapter<S extends object> implements StoreAdapter<S> {
|
|
36
14
|
private node: SnapshotNode<S>;
|
|
37
15
|
|
|
38
16
|
/**
|
|
@@ -57,10 +35,29 @@ export class MobxStateTreeAdapter<S extends object> implements StoreAdapter<S> {
|
|
|
57
35
|
}
|
|
58
36
|
|
|
59
37
|
/**
|
|
60
|
-
*
|
|
38
|
+
* Creates a MobX-State-Tree adapter that syncs a tree node through its snapshots.
|
|
39
|
+
* Snapshots go to the backend once per action, and remote changes are applied
|
|
40
|
+
* with `applySnapshot`, so instances with identifiers are reconciled in place.
|
|
61
41
|
*
|
|
62
42
|
* @param node - The tree node to sync; usually the root instance
|
|
63
43
|
* @returns StoreAdapter instance for the node
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import { types } from 'mobx-state-tree';
|
|
48
|
+
* import * as Y from 'yjs';
|
|
49
|
+
* import { createYjsBackend } from '@homeostate/crdt-yjs';
|
|
50
|
+
*
|
|
51
|
+
* const Counter = types
|
|
52
|
+
* .model({ count: 0 })
|
|
53
|
+
* .actions((self) => ({ increment() { self.count++; } }));
|
|
54
|
+
*
|
|
55
|
+
* const counter = Counter.create();
|
|
56
|
+
* const adapter = createMobxStateTreeAdapter(counter);
|
|
57
|
+
* const engine = createSyncEngine(createYjsBackend(new Y.Doc(), 'shared'), adapter);
|
|
58
|
+
* engine.connect();
|
|
59
|
+
* counter.increment();
|
|
60
|
+
* ```
|
|
64
61
|
*/
|
|
65
62
|
export function createMobxStateTreeAdapter<S extends object>(
|
|
66
63
|
node: SnapshotNode<S>,
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createMobxStateTreeAdapter } from "./adapter.js";
|
|
2
2
|
export type { SnapshotNode } from "./adapter.js";
|