@pluv/react 0.5.9 → 0.5.10

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,5 +1,5 @@
1
1
 
2
- > @pluv/react@0.5.9 build /home/runner/work/pluv/pluv/packages/react
2
+ > @pluv/react@0.5.10 build /home/runner/work/pluv/pluv/packages/react
3
3
  > tsup src/index.ts --format esm,cjs --dts --external react
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,10 +8,10 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 8.66 KB
12
- ESM ⚡️ Build success in 200ms
13
- CJS dist/index.js 11.15 KB
14
- CJS ⚡️ Build success in 202ms
11
+ ESM dist/index.mjs 8.65 KB
12
+ ESM ⚡️ Build success in 130ms
13
+ CJS dist/index.js 11.11 KB
14
+ CJS ⚡️ Build success in 130ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 5611ms
16
+ DTS ⚡️ Build success in 4787ms
17
17
  DTS dist/index.d.ts 4.37 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pluv/react
2
2
 
3
+ ## 0.5.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 5bbfb98: fix not properly handling unauthorized checks
8
+ - b85a232: bumped dependencies
9
+ - Updated dependencies [5bbfb98]
10
+ - Updated dependencies [b85a232]
11
+ - Updated dependencies [fde89cf]
12
+ - @pluv/client@0.8.0
13
+ - @pluv/types@0.2.0
14
+
3
15
  ## 0.5.9
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -39,14 +39,13 @@ module.exports = __toCommonJS(src_exports);
39
39
  var import_client2 = require("@pluv/client");
40
40
 
41
41
  // src/createBundle.tsx
42
+ var import_react3 = require("react");
42
43
  var import_react4 = require("react");
43
- var import_react5 = require("react");
44
44
 
45
45
  // src/createRoomBundle.tsx
46
46
  var import_client = require("@pluv/client");
47
47
  var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
48
48
  var import_react2 = require("react");
49
- var import_react3 = require("react");
50
49
 
51
50
  // src/internal/hooks/useRerender.ts
52
51
  var import_react = require("react");
@@ -73,7 +72,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
73
72
  var createRoomBundle = (client, options = {}) => {
74
73
  const PluvRoomContext = (0, import_react2.createContext)(null);
75
74
  const MockedRoomContext = (0, import_react2.createContext)({ room: null });
76
- const MockedRoomProvider = (0, import_react3.memo)((props) => {
75
+ const MockedRoomProvider = (0, import_react2.memo)((props) => {
77
76
  const {
78
77
  children,
79
78
  events,
@@ -92,7 +91,7 @@ var createRoomBundle = (client, options = {}) => {
92
91
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MockedRoomContext.Provider, { value: { room }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluvRoomContext.Provider, { value: room, children }) });
93
92
  });
94
93
  MockedRoomProvider.displayName = "MockedRoomProvider";
95
- const PluvRoomProvider = (0, import_react3.memo)((props) => {
94
+ const PluvRoomProvider = (0, import_react2.memo)((props) => {
96
95
  const {
97
96
  children,
98
97
  debug,
@@ -102,7 +101,7 @@ var createRoomBundle = (client, options = {}) => {
102
101
  room: _room
103
102
  } = props;
104
103
  const rerender = useRerender();
105
- const { room: mockedRoom } = (0, import_react3.useContext)(MockedRoomContext);
104
+ const { room: mockedRoom } = (0, import_react2.useContext)(MockedRoomContext);
106
105
  const [room] = (0, import_react2.useState)(() => {
107
106
  return client.createRoom(_room, {
108
107
  debug,
@@ -112,7 +111,7 @@ var createRoomBundle = (client, options = {}) => {
112
111
  onAuthorizationFail
113
112
  });
114
113
  });
115
- (0, import_react3.useEffect)(() => {
114
+ (0, import_react2.useEffect)(() => {
116
115
  const unsubscribe = room.subscribe("connection", () => {
117
116
  rerender();
118
117
  });
@@ -120,7 +119,7 @@ var createRoomBundle = (client, options = {}) => {
120
119
  unsubscribe();
121
120
  };
122
121
  }, [rerender, room]);
123
- (0, import_react3.useEffect)(() => {
122
+ (0, import_react2.useEffect)(() => {
124
123
  client.enter(room);
125
124
  return () => {
126
125
  client.leave(room);
@@ -129,10 +128,10 @@ var createRoomBundle = (client, options = {}) => {
129
128
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluvRoomContext.Provider, { value: mockedRoom != null ? mockedRoom : room, children });
130
129
  });
131
130
  PluvRoomProvider.displayName = "PluvRoomProvider";
132
- const usePluvRoom = () => (0, import_react3.useContext)(PluvRoomContext);
131
+ const usePluvRoom = () => (0, import_react2.useContext)(PluvRoomContext);
133
132
  const usePluvBroadcast = () => {
134
133
  const room = usePluvRoom();
135
- return (0, import_react3.useCallback)(
134
+ return (0, import_react2.useCallback)(
136
135
  (event, data) => {
137
136
  room.broadcast(event, data);
138
137
  },
@@ -142,14 +141,14 @@ var createRoomBundle = (client, options = {}) => {
142
141
  const usePluvConnection = (selector = identity, options2) => {
143
142
  var _a;
144
143
  const room = usePluvRoom();
145
- const subscribe = (0, import_react3.useCallback)(
144
+ const subscribe = (0, import_react2.useCallback)(
146
145
  (onStoreChange) => {
147
146
  return room.subscribe("connection", onStoreChange);
148
147
  },
149
148
  [room]
150
149
  );
151
150
  const getSnapshot = room.getConnection;
152
- const _selector = (0, import_react3.useCallback)(
151
+ const _selector = (0, import_react2.useCallback)(
153
152
  (snapshot) => selector(snapshot),
154
153
  [selector]
155
154
  );
@@ -163,7 +162,7 @@ var createRoomBundle = (client, options = {}) => {
163
162
  };
164
163
  const usePluvEvent = (type, callback) => {
165
164
  const room = usePluvRoom();
166
- (0, import_react3.useEffect)(() => {
165
+ (0, import_react2.useEffect)(() => {
167
166
  const unsubscribe = room.event(type, callback);
168
167
  return () => {
169
168
  unsubscribe();
@@ -173,14 +172,14 @@ var createRoomBundle = (client, options = {}) => {
173
172
  const usePluvMyPresence = (selector = identity, options2) => {
174
173
  var _a;
175
174
  const room = usePluvRoom();
176
- const subscribe = (0, import_react3.useCallback)(
175
+ const subscribe = (0, import_react2.useCallback)(
177
176
  (onStoreChange) => {
178
177
  return room.subscribe("my-presence", onStoreChange);
179
178
  },
180
179
  [room]
181
180
  );
182
181
  const getSnapshot = room.getMyPresence;
183
- const _selector = (0, import_react3.useCallback)(
182
+ const _selector = (0, import_react2.useCallback)(
184
183
  (snapshot) => {
185
184
  return !snapshot ? null : selector(snapshot);
186
185
  },
@@ -193,7 +192,7 @@ var createRoomBundle = (client, options = {}) => {
193
192
  _selector,
194
193
  (_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : import_fast_deep_equal.default
195
194
  );
196
- const updateMyPresence = (0, import_react3.useCallback)(
195
+ const updateMyPresence = (0, import_react2.useCallback)(
197
196
  (value) => {
198
197
  const presence = typeof value === "function" ? value(room.getMyPresence()) : value;
199
198
  room.updateMyPresence(presence);
@@ -205,14 +204,14 @@ var createRoomBundle = (client, options = {}) => {
205
204
  const usePluvMyself = (selector = identity, options2) => {
206
205
  var _a;
207
206
  const room = usePluvRoom();
208
- const subscribe = (0, import_react3.useCallback)(
207
+ const subscribe = (0, import_react2.useCallback)(
209
208
  (onStoreChange) => {
210
209
  return room.subscribe("myself", onStoreChange);
211
210
  },
212
211
  [room]
213
212
  );
214
213
  const getSnapshot = room.getMyself;
215
- const _selector = (0, import_react3.useCallback)(
214
+ const _selector = (0, import_react2.useCallback)(
216
215
  (snapshot) => {
217
216
  return !snapshot ? null : selector(snapshot);
218
217
  },
@@ -229,17 +228,17 @@ var createRoomBundle = (client, options = {}) => {
229
228
  const usePluvOther = (connectionId, selector = identity, options2) => {
230
229
  var _a;
231
230
  const room = usePluvRoom();
232
- const subscribe = (0, import_react3.useCallback)(
231
+ const subscribe = (0, import_react2.useCallback)(
233
232
  (onStoreChange) => {
234
233
  return room.other(connectionId, onStoreChange);
235
234
  },
236
235
  [room, connectionId]
237
236
  );
238
- const getSnapshot = (0, import_react3.useCallback)(
237
+ const getSnapshot = (0, import_react2.useCallback)(
239
238
  () => room.getOther(connectionId),
240
239
  [room, connectionId]
241
240
  );
242
- const _selector = (0, import_react3.useCallback)(
241
+ const _selector = (0, import_react2.useCallback)(
243
242
  (snapshot) => {
244
243
  return !snapshot ? null : selector(snapshot);
245
244
  },
@@ -256,7 +255,7 @@ var createRoomBundle = (client, options = {}) => {
256
255
  const usePluvOthers = (selector = identity, options2) => {
257
256
  var _a;
258
257
  const room = usePluvRoom();
259
- const subscribe = (0, import_react3.useCallback)(
258
+ const subscribe = (0, import_react2.useCallback)(
260
259
  (onStoreChange) => {
261
260
  return room.subscribe("others", onStoreChange);
262
261
  },
@@ -274,15 +273,15 @@ var createRoomBundle = (client, options = {}) => {
274
273
  const usePluvStorage = (key, selector = identity, options2) => {
275
274
  var _a;
276
275
  const room = usePluvRoom();
277
- const subscribe = (0, import_react3.useCallback)(
276
+ const subscribe = (0, import_react2.useCallback)(
278
277
  (onStoreChange) => room.storage(key, onStoreChange),
279
278
  [key, room]
280
279
  );
281
- const getSnapshot = (0, import_react3.useCallback)(() => {
280
+ const getSnapshot = (0, import_react2.useCallback)(() => {
282
281
  var _a2, _b;
283
282
  return (_b = (_a2 = room.getStorage(key)) == null ? void 0 : _a2.toJSON()) != null ? _b : null;
284
283
  }, [key, room]);
285
- const _selector = (0, import_react3.useCallback)(
284
+ const _selector = (0, import_react2.useCallback)(
286
285
  (snapshot) => {
287
286
  return !snapshot ? null : selector(snapshot);
288
287
  },
@@ -318,13 +317,13 @@ var createRoomBundle = (client, options = {}) => {
318
317
  // src/createBundle.tsx
319
318
  var import_jsx_runtime2 = require("react/jsx-runtime");
320
319
  var createBundle = (client) => {
321
- const PluvContext = (0, import_react4.createContext)(null);
322
- const PluvProvider = (0, import_react5.memo)((props) => {
320
+ const PluvContext = (0, import_react3.createContext)(null);
321
+ const PluvProvider = (0, import_react4.memo)((props) => {
323
322
  const { children } = props;
324
323
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PluvContext.Provider, { value: client, children });
325
324
  });
326
325
  PluvProvider.displayName = "PluvProvider";
327
- const usePluvClient = () => (0, import_react5.useContext)(PluvContext);
326
+ const usePluvClient = () => (0, import_react4.useContext)(PluvContext);
328
327
  const createRoomBundle2 = (options = {}) => createRoomBundle(client, options);
329
328
  return {
330
329
  createRoomBundle: createRoomBundle2,
package/dist/index.mjs CHANGED
@@ -8,8 +8,14 @@ import { memo as memo2, useContext as useContext2 } from "react";
8
8
  // src/createRoomBundle.tsx
9
9
  import { MockedRoom } from "@pluv/client";
10
10
  import fastDeepEqual from "fast-deep-equal";
11
- import { createContext, useState as useState2 } from "react";
12
- import { memo, useCallback as useCallback2, useContext, useEffect } from "react";
11
+ import {
12
+ createContext,
13
+ memo,
14
+ useCallback as useCallback2,
15
+ useContext,
16
+ useEffect,
17
+ useState as useState2
18
+ } from "react";
13
19
 
14
20
  // src/internal/hooks/useRerender.ts
15
21
  import { useCallback, useState } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/react",
3
- "version": "0.5.9",
3
+ "version": "0.5.10",
4
4
  "description": "@pluv/client React.js bindings",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "@types/use-sync-external-store": "^0.0.3",
21
21
  "fast-deep-equal": "^3.1.3",
22
22
  "use-sync-external-store": "^1.2.0",
23
- "@pluv/client": "^0.7.0",
23
+ "@pluv/client": "^0.8.0",
24
24
  "@pluv/types": "^0.2.0"
25
25
  },
26
26
  "peerDependencies": {
@@ -28,13 +28,13 @@
28
28
  "yjs": "^13.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/react": "18.2.0",
31
+ "@types/react": "18.2.6",
32
32
  "react": "18.2.0",
33
33
  "tsup": "^6.7.0",
34
34
  "typescript": "^5.0.4",
35
- "yjs": "^13.6.0",
35
+ "yjs": "^13.6.1",
36
36
  "@pluv/tsconfig": "^0.1.6",
37
- "eslint-config-pluv": "^0.1.11"
37
+ "eslint-config-pluv": "^0.1.12"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsup src/index.ts --format esm,cjs --dts --external react",
@@ -10,17 +10,24 @@ import type {
10
10
  } from "@pluv/client";
11
11
  import { MockedRoom } from "@pluv/client";
12
12
  import type {
13
+ IOEventMessage,
14
+ IOLike,
13
15
  Id,
14
16
  InferIOInput,
15
17
  InferIOOutput,
16
18
  InputZodLike,
17
- IOEventMessage,
18
- IOLike,
19
19
  JsonObject,
20
20
  } from "@pluv/types";
21
21
  import fastDeepEqual from "fast-deep-equal";
22
- import { createContext, Dispatch, FC, ReactNode, useState } from "react";
23
- import { memo, useCallback, useContext, useEffect } from "react";
22
+ import type { Dispatch, FC, ReactNode } from "react";
23
+ import {
24
+ createContext,
25
+ memo,
26
+ useCallback,
27
+ useContext,
28
+ useEffect,
29
+ useState,
30
+ } from "react";
24
31
  import type { AbstractType } from "yjs";
25
32
  import {
26
33
  identity,