@liveblocks/zustand 0.15.10 → 0.16.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 +16 -4
- package/lib/esm/index.js +2 -2
- package/lib/esm/index.mjs +2 -2
- package/lib/index.d.ts +3 -3
- package/lib/index.js +2 -2
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://liveblocks.io">
|
|
3
|
-
<img src="https://
|
|
3
|
+
<img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header.svg" alt="Liveblocks" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
#
|
|
7
|
+
# `@liveblocks/zustand`
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
<p>
|
|
10
|
+
<a href="https://npmjs.org/package/@liveblocks/zustand">
|
|
11
|
+
<img src="https://img.shields.io/npm/v/@liveblocks/zustand?style=flat&label=npm&color=c33" alt="NPM" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://bundlephobia.com/package/@liveblocks/zustand">
|
|
14
|
+
<img src="https://img.shields.io/bundlephobia/minzip/@liveblocks/zustand?style=flat&label=size&color=09f" alt="Size" />
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://github.com/liveblocks/liveblocks/blob/main/LICENSE">
|
|
17
|
+
<img src="https://img.shields.io/github/license/liveblocks/liveblocks?style=flat&label=license&color=f80" alt="License" />
|
|
18
|
+
</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
A [middleware](https://github.com/pmndrs/zustand#middleware) to integrate [Liveblocks](https://liveblocks.io) into [Zustand](https://github.com/pmndrs/zustand) stores.
|
|
10
22
|
|
|
11
23
|
## Installation
|
|
12
24
|
|
|
@@ -16,7 +28,7 @@ npm install @liveblocks/client @liveblocks/zustand
|
|
|
16
28
|
|
|
17
29
|
## Documentation
|
|
18
30
|
|
|
19
|
-
- Start with the [React
|
|
31
|
+
- Start with the [React and Zustand guide](https://liveblocks.io/docs/get-started/react-zustand).
|
|
20
32
|
- Explore the [API Reference](https://liveblocks.io/docs/api-reference/liveblocks-zustand).
|
|
21
33
|
|
|
22
34
|
## Examples
|
package/lib/esm/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var __spreadValues = (a, b) => {
|
|
|
39
39
|
return a;
|
|
40
40
|
};
|
|
41
41
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
42
|
-
const { patchLiveObjectKey, patchImmutableObject,
|
|
42
|
+
const { patchLiveObjectKey, patchImmutableObject, lsonToJson } = internals;
|
|
43
43
|
function middleware(config, options) {
|
|
44
44
|
if (process.env.NODE_ENV !== "production" && options.client == null) {
|
|
45
45
|
throw missingClient();
|
|
@@ -101,7 +101,7 @@ function middleware(config, options) {
|
|
|
101
101
|
updates[key] = initialState[key];
|
|
102
102
|
patchLiveObjectKey(root, key, void 0, initialState[key]);
|
|
103
103
|
} else {
|
|
104
|
-
updates[key] =
|
|
104
|
+
updates[key] = lsonToJson(liveblocksStatePart);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
});
|
package/lib/esm/index.mjs
CHANGED
|
@@ -39,7 +39,7 @@ var __spreadValues = (a, b) => {
|
|
|
39
39
|
return a;
|
|
40
40
|
};
|
|
41
41
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
42
|
-
const { patchLiveObjectKey, patchImmutableObject,
|
|
42
|
+
const { patchLiveObjectKey, patchImmutableObject, lsonToJson } = internals;
|
|
43
43
|
function middleware(config, options) {
|
|
44
44
|
if (process.env.NODE_ENV !== "production" && options.client == null) {
|
|
45
45
|
throw missingClient();
|
|
@@ -101,7 +101,7 @@ function middleware(config, options) {
|
|
|
101
101
|
updates[key] = initialState[key];
|
|
102
102
|
patchLiveObjectKey(root, key, void 0, initialState[key]);
|
|
103
103
|
} else {
|
|
104
|
-
updates[key] =
|
|
104
|
+
updates[key] = lsonToJson(liveblocksStatePart);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StateCreator, SetState, GetState, StoreApi } from "zustand";
|
|
2
|
-
import { Client,
|
|
3
|
-
export declare type LiveblocksState<TState, TPresence =
|
|
2
|
+
import { Client, Presence, Room, User } from "@liveblocks/client";
|
|
3
|
+
export declare type LiveblocksState<TState, TPresence extends Presence = Presence> = TState & {
|
|
4
4
|
/**
|
|
5
5
|
* Liveblocks extra state attached by the middleware
|
|
6
6
|
*/
|
|
@@ -51,5 +51,5 @@ declare type Options<T> = {
|
|
|
51
51
|
*/
|
|
52
52
|
presenceMapping?: Mapping<T>;
|
|
53
53
|
};
|
|
54
|
-
export declare function middleware<T extends
|
|
54
|
+
export declare function middleware<T extends Record<string, unknown>, TPresence extends Record<string, unknown> = Presence>(config: StateCreator<T, SetState<T>, GetState<LiveblocksState<T>>, StoreApi<T>>, options: Options<T>): StateCreator<LiveblocksState<T, TPresence>, SetState<LiveblocksState<T, TPresence>>, GetState<LiveblocksState<T, TPresence>>, StoreApi<LiveblocksState<T, TPresence>>>;
|
|
55
55
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -82,7 +82,7 @@ function mappingToFunctionIsNotAllowed(key) {
|
|
|
82
82
|
|
|
83
83
|
var patchLiveObjectKey = client.internals.patchLiveObjectKey,
|
|
84
84
|
patchImmutableObject = client.internals.patchImmutableObject,
|
|
85
|
-
|
|
85
|
+
lsonToJson = client.internals.lsonToJson;
|
|
86
86
|
function middleware(config, options) {
|
|
87
87
|
if (process.env.NODE_ENV !== "production" && options.client == null) {
|
|
88
88
|
throw missingClient();
|
|
@@ -157,7 +157,7 @@ function middleware(config, options) {
|
|
|
157
157
|
updates[_key] = initialState[_key];
|
|
158
158
|
patchLiveObjectKey(root, _key, undefined, initialState[_key]);
|
|
159
159
|
} else {
|
|
160
|
-
updates[_key] =
|
|
160
|
+
updates[_key] = lsonToJson(liveblocksStatePart);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/zustand",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"description": "",
|
|
5
|
+
"description": "A middleware to integrate Liveblocks into Zustand stores.",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"directory": "packages/liveblocks-zustand"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@liveblocks/client": "0.
|
|
39
|
+
"@liveblocks/client": "0.16.0",
|
|
40
40
|
"zustand": "^3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -51,7 +51,10 @@
|
|
|
51
51
|
"@testing-library/react": "^12.1.2",
|
|
52
52
|
"@testing-library/react-hooks": "^7.0.2",
|
|
53
53
|
"@types/jest": "^27.4.0",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.18.0",
|
|
55
|
+
"@typescript-eslint/parser": "^5.18.0",
|
|
54
56
|
"esbuild": "0.14.11",
|
|
57
|
+
"eslint": "^8.12.0",
|
|
55
58
|
"jest": "^27.4.7",
|
|
56
59
|
"msw": "^0.36.4",
|
|
57
60
|
"rollup": "^2.64.0",
|
|
@@ -59,4 +62,4 @@
|
|
|
59
62
|
"whatwg-fetch": "^3.6.2",
|
|
60
63
|
"zustand": "^3.6.9"
|
|
61
64
|
}
|
|
62
|
-
}
|
|
65
|
+
}
|