@pluv/react 0.27.0 → 0.28.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +16 -17
- package/dist/index.mjs +16 -17
- package/package.json +6 -6
- package/src/createRoomBundle.tsx +7 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/react@0.
|
|
2
|
+
> @pluv/react@0.28.0 build /home/runner/work/pluv/pluv/packages/react
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts --external react
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m11.84 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 141ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m14.23 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 141ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m6.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m6.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4997ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m6.04 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m6.04 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pluv/react
|
|
2
2
|
|
|
3
|
+
## 0.28.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 778b43e: Remove the `initialStorage` option from `createRoomBundle`. This has been moved to `createClient`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- @pluv/client@0.28.0
|
|
12
|
+
- @pluv/crdt@0.28.0
|
|
13
|
+
- @pluv/types@0.28.0
|
|
14
|
+
|
|
3
15
|
## 0.27.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluvRouterEventConfig, PluvRoomAddon, PluvRouter, PluvRoomDebug, MergeEvents, WebSocketConnection, UserInfo, AbstractRoom, MockedRoomEvents, PluvClient } from '@pluv/client';
|
|
2
2
|
export { ConnectionState, createClient } from '@pluv/client';
|
|
3
|
-
import { CrdtType,
|
|
3
|
+
import { CrdtType, AbstractCrdtDoc, InferCrdtJson } from '@pluv/crdt';
|
|
4
4
|
export { CrdtType, InferCrdtJson } from '@pluv/crdt';
|
|
5
5
|
import { IOLike, JsonObject, Id, InferIOOutput, IOEventMessage, InferIOInput } from '@pluv/types';
|
|
6
6
|
export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
|
|
@@ -8,7 +8,6 @@ import { FC, Dispatch, ReactNode } from 'react';
|
|
|
8
8
|
|
|
9
9
|
type CreateRoomBundleOptions<TIO extends IOLike, TMetadata extends JsonObject = {}, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> = {
|
|
10
10
|
addons?: readonly PluvRoomAddon<TIO, TMetadata, TPresence, TStorage>[];
|
|
11
|
-
initialStorage?: AbstractCrdtDocFactory<TStorage>;
|
|
12
11
|
router?: PluvRouter<TIO, TPresence, TStorage, TEvents>;
|
|
13
12
|
};
|
|
14
13
|
type BaseRoomProviderProps<TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>> = {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluvRouterEventConfig, PluvRoomAddon, PluvRouter, PluvRoomDebug, MergeEvents, WebSocketConnection, UserInfo, AbstractRoom, MockedRoomEvents, PluvClient } from '@pluv/client';
|
|
2
2
|
export { ConnectionState, createClient } from '@pluv/client';
|
|
3
|
-
import { CrdtType,
|
|
3
|
+
import { CrdtType, AbstractCrdtDoc, InferCrdtJson } from '@pluv/crdt';
|
|
4
4
|
export { CrdtType, InferCrdtJson } from '@pluv/crdt';
|
|
5
5
|
import { IOLike, JsonObject, Id, InferIOOutput, IOEventMessage, InferIOInput } from '@pluv/types';
|
|
6
6
|
export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
|
|
@@ -8,7 +8,6 @@ import { FC, Dispatch, ReactNode } from 'react';
|
|
|
8
8
|
|
|
9
9
|
type CreateRoomBundleOptions<TIO extends IOLike, TMetadata extends JsonObject = {}, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> = {
|
|
10
10
|
addons?: readonly PluvRoomAddon<TIO, TMetadata, TPresence, TStorage>[];
|
|
11
|
-
initialStorage?: AbstractCrdtDocFactory<TStorage>;
|
|
12
11
|
router?: PluvRouter<TIO, TPresence, TStorage, TEvents>;
|
|
13
12
|
};
|
|
14
13
|
type BaseRoomProviderProps<TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>> = {
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,6 @@ var import_react5 = require("react");
|
|
|
42
42
|
|
|
43
43
|
// src/createRoomBundle.tsx
|
|
44
44
|
var import_client = require("@pluv/client");
|
|
45
|
-
var import_crdt = require("@pluv/crdt");
|
|
46
45
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
|
47
46
|
var import_react4 = require("react");
|
|
48
47
|
|
|
@@ -112,17 +111,16 @@ var useSyncExternalStoreWithSelector = (subscribe, getClientSnapshot, getServerS
|
|
|
112
111
|
// src/createRoomBundle.tsx
|
|
113
112
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
114
113
|
var createRoomBundle = (client, options) => {
|
|
115
|
-
var _a;
|
|
116
|
-
const _initialStorage = (_a = options.initialStorage) != null ? _a : import_crdt.noop.doc();
|
|
117
114
|
const PluvRoomContext = (0, import_react4.createContext)(null);
|
|
118
115
|
const MockedRoomContext = (0, import_react4.createContext)({ room: null });
|
|
119
116
|
const MockedRoomProvider = (0, import_react4.memo)((props) => {
|
|
120
117
|
const { children, events, initialPresence, initialStorage, room: _room } = props;
|
|
121
118
|
const [room] = (0, import_react4.useState)(() => {
|
|
119
|
+
var _a;
|
|
122
120
|
return new import_client.MockedRoom(_room, {
|
|
123
121
|
events,
|
|
124
122
|
initialPresence,
|
|
125
|
-
initialStorage: typeof initialStorage === "function" ?
|
|
123
|
+
initialStorage: typeof initialStorage === "function" ? (_a = client._defs.initialStorage) == null ? void 0 : _a.getFactory(initialStorage) : client._defs.initialStorage
|
|
126
124
|
});
|
|
127
125
|
});
|
|
128
126
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MockedRoomContext.Provider, { value: { room }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluvRoomContext.Provider, { value: room, children }) });
|
|
@@ -133,11 +131,12 @@ var createRoomBundle = (client, options) => {
|
|
|
133
131
|
const rerender = useRerender();
|
|
134
132
|
const { room: mockedRoom } = (0, import_react4.useContext)(MockedRoomContext);
|
|
135
133
|
const [room] = (0, import_react4.useState)(() => {
|
|
134
|
+
var _a;
|
|
136
135
|
return client.createRoom(_room, {
|
|
137
136
|
addons: options.addons,
|
|
138
137
|
debug,
|
|
139
138
|
initialPresence,
|
|
140
|
-
initialStorage: typeof initialStorage === "function" ?
|
|
139
|
+
initialStorage: typeof initialStorage === "function" ? (_a = client._defs.initialStorage) == null ? void 0 : _a.getFactory(initialStorage) : client._defs.initialStorage,
|
|
141
140
|
metadata,
|
|
142
141
|
onAuthorizationFail,
|
|
143
142
|
router: options.router
|
|
@@ -194,7 +193,7 @@ var createRoomBundle = (client, options) => {
|
|
|
194
193
|
return canUndo;
|
|
195
194
|
};
|
|
196
195
|
const useConnection = (selector = identity, options2) => {
|
|
197
|
-
var
|
|
196
|
+
var _a;
|
|
198
197
|
const room = useRoom();
|
|
199
198
|
const subscribe = (0, import_react4.useCallback)(
|
|
200
199
|
(onStoreChange) => {
|
|
@@ -209,7 +208,7 @@ var createRoomBundle = (client, options) => {
|
|
|
209
208
|
getSnapshot,
|
|
210
209
|
getSnapshot,
|
|
211
210
|
_selector,
|
|
212
|
-
(
|
|
211
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : import_fast_deep_equal.default
|
|
213
212
|
);
|
|
214
213
|
};
|
|
215
214
|
const useDoc = () => {
|
|
@@ -237,7 +236,7 @@ var createRoomBundle = (client, options) => {
|
|
|
237
236
|
}
|
|
238
237
|
);
|
|
239
238
|
const useMyPresence = (selector = identity, options2) => {
|
|
240
|
-
var
|
|
239
|
+
var _a;
|
|
241
240
|
const room = useRoom();
|
|
242
241
|
const subscribe = (0, import_react4.useCallback)(
|
|
243
242
|
(onStoreChange) => {
|
|
@@ -252,12 +251,12 @@ var createRoomBundle = (client, options) => {
|
|
|
252
251
|
getSnapshot,
|
|
253
252
|
getSnapshot,
|
|
254
253
|
_selector,
|
|
255
|
-
(
|
|
254
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : import_fast_deep_equal.default
|
|
256
255
|
);
|
|
257
256
|
return [myPresence, room.updateMyPresence];
|
|
258
257
|
};
|
|
259
258
|
const useMyself = (selector = identity, options2) => {
|
|
260
|
-
var
|
|
259
|
+
var _a;
|
|
261
260
|
const room = useRoom();
|
|
262
261
|
const subscribe = (0, import_react4.useCallback)(
|
|
263
262
|
(onStoreChange) => {
|
|
@@ -277,11 +276,11 @@ var createRoomBundle = (client, options) => {
|
|
|
277
276
|
getSnapshot,
|
|
278
277
|
getSnapshot,
|
|
279
278
|
_selector,
|
|
280
|
-
(
|
|
279
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : import_fast_deep_equal.default
|
|
281
280
|
);
|
|
282
281
|
};
|
|
283
282
|
const useOther = (connectionId, selector = identity, options2) => {
|
|
284
|
-
var
|
|
283
|
+
var _a;
|
|
285
284
|
const room = useRoom();
|
|
286
285
|
const subscribe = (0, import_react4.useCallback)(
|
|
287
286
|
(onStoreChange) => {
|
|
@@ -301,11 +300,11 @@ var createRoomBundle = (client, options) => {
|
|
|
301
300
|
getSnapshot,
|
|
302
301
|
getSnapshot,
|
|
303
302
|
_selector,
|
|
304
|
-
(
|
|
303
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : import_fast_deep_equal.default
|
|
305
304
|
);
|
|
306
305
|
};
|
|
307
306
|
const useOthers = (selector = identity, options2) => {
|
|
308
|
-
var
|
|
307
|
+
var _a;
|
|
309
308
|
const room = useRoom();
|
|
310
309
|
const subscribe = (0, import_react4.useCallback)(
|
|
311
310
|
(onStoreChange) => {
|
|
@@ -319,7 +318,7 @@ var createRoomBundle = (client, options) => {
|
|
|
319
318
|
getSnapshot,
|
|
320
319
|
getSnapshot,
|
|
321
320
|
selector,
|
|
322
|
-
(
|
|
321
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : (a, b) => {
|
|
323
322
|
if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) {
|
|
324
323
|
return shallowArrayEqual(a, b);
|
|
325
324
|
}
|
|
@@ -332,7 +331,7 @@ var createRoomBundle = (client, options) => {
|
|
|
332
331
|
return room.redo;
|
|
333
332
|
};
|
|
334
333
|
const useStorage = (key, selector = identity, options2) => {
|
|
335
|
-
var
|
|
334
|
+
var _a, _b;
|
|
336
335
|
const room = useRoom();
|
|
337
336
|
const rerender = useRerender();
|
|
338
337
|
room.subscribe("storage-loaded", () => {
|
|
@@ -353,7 +352,7 @@ var createRoomBundle = (client, options) => {
|
|
|
353
352
|
getSnapshot,
|
|
354
353
|
getSnapshot,
|
|
355
354
|
_selector,
|
|
356
|
-
(
|
|
355
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : import_fast_deep_equal.default
|
|
357
356
|
);
|
|
358
357
|
const sharedType = (_b = room.getStorage(key)) != null ? _b : null;
|
|
359
358
|
return [data, sharedType];
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import { createContext as createContext2, memo as memo2, useContext as useContex
|
|
|
6
6
|
|
|
7
7
|
// src/createRoomBundle.tsx
|
|
8
8
|
import { MockedRoom } from "@pluv/client";
|
|
9
|
-
import { noop } from "@pluv/crdt";
|
|
10
9
|
import fastDeepEqual from "fast-deep-equal";
|
|
11
10
|
import { createContext, memo, useCallback as useCallback3, useContext, useEffect as useEffect2, useMemo, useState as useState3 } from "react";
|
|
12
11
|
|
|
@@ -76,17 +75,16 @@ var useSyncExternalStoreWithSelector = (subscribe, getClientSnapshot, getServerS
|
|
|
76
75
|
// src/createRoomBundle.tsx
|
|
77
76
|
import { jsx } from "react/jsx-runtime";
|
|
78
77
|
var createRoomBundle = (client, options) => {
|
|
79
|
-
var _a;
|
|
80
|
-
const _initialStorage = (_a = options.initialStorage) != null ? _a : noop.doc();
|
|
81
78
|
const PluvRoomContext = createContext(null);
|
|
82
79
|
const MockedRoomContext = createContext({ room: null });
|
|
83
80
|
const MockedRoomProvider = memo((props) => {
|
|
84
81
|
const { children, events, initialPresence, initialStorage, room: _room } = props;
|
|
85
82
|
const [room] = useState3(() => {
|
|
83
|
+
var _a;
|
|
86
84
|
return new MockedRoom(_room, {
|
|
87
85
|
events,
|
|
88
86
|
initialPresence,
|
|
89
|
-
initialStorage: typeof initialStorage === "function" ?
|
|
87
|
+
initialStorage: typeof initialStorage === "function" ? (_a = client._defs.initialStorage) == null ? void 0 : _a.getFactory(initialStorage) : client._defs.initialStorage
|
|
90
88
|
});
|
|
91
89
|
});
|
|
92
90
|
return /* @__PURE__ */ jsx(MockedRoomContext.Provider, { value: { room }, children: /* @__PURE__ */ jsx(PluvRoomContext.Provider, { value: room, children }) });
|
|
@@ -97,11 +95,12 @@ var createRoomBundle = (client, options) => {
|
|
|
97
95
|
const rerender = useRerender();
|
|
98
96
|
const { room: mockedRoom } = useContext(MockedRoomContext);
|
|
99
97
|
const [room] = useState3(() => {
|
|
98
|
+
var _a;
|
|
100
99
|
return client.createRoom(_room, {
|
|
101
100
|
addons: options.addons,
|
|
102
101
|
debug,
|
|
103
102
|
initialPresence,
|
|
104
|
-
initialStorage: typeof initialStorage === "function" ?
|
|
103
|
+
initialStorage: typeof initialStorage === "function" ? (_a = client._defs.initialStorage) == null ? void 0 : _a.getFactory(initialStorage) : client._defs.initialStorage,
|
|
105
104
|
metadata,
|
|
106
105
|
onAuthorizationFail,
|
|
107
106
|
router: options.router
|
|
@@ -158,7 +157,7 @@ var createRoomBundle = (client, options) => {
|
|
|
158
157
|
return canUndo;
|
|
159
158
|
};
|
|
160
159
|
const useConnection = (selector = identity, options2) => {
|
|
161
|
-
var
|
|
160
|
+
var _a;
|
|
162
161
|
const room = useRoom();
|
|
163
162
|
const subscribe = useCallback3(
|
|
164
163
|
(onStoreChange) => {
|
|
@@ -173,7 +172,7 @@ var createRoomBundle = (client, options) => {
|
|
|
173
172
|
getSnapshot,
|
|
174
173
|
getSnapshot,
|
|
175
174
|
_selector,
|
|
176
|
-
(
|
|
175
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : fastDeepEqual
|
|
177
176
|
);
|
|
178
177
|
};
|
|
179
178
|
const useDoc = () => {
|
|
@@ -201,7 +200,7 @@ var createRoomBundle = (client, options) => {
|
|
|
201
200
|
}
|
|
202
201
|
);
|
|
203
202
|
const useMyPresence = (selector = identity, options2) => {
|
|
204
|
-
var
|
|
203
|
+
var _a;
|
|
205
204
|
const room = useRoom();
|
|
206
205
|
const subscribe = useCallback3(
|
|
207
206
|
(onStoreChange) => {
|
|
@@ -216,12 +215,12 @@ var createRoomBundle = (client, options) => {
|
|
|
216
215
|
getSnapshot,
|
|
217
216
|
getSnapshot,
|
|
218
217
|
_selector,
|
|
219
|
-
(
|
|
218
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : fastDeepEqual
|
|
220
219
|
);
|
|
221
220
|
return [myPresence, room.updateMyPresence];
|
|
222
221
|
};
|
|
223
222
|
const useMyself = (selector = identity, options2) => {
|
|
224
|
-
var
|
|
223
|
+
var _a;
|
|
225
224
|
const room = useRoom();
|
|
226
225
|
const subscribe = useCallback3(
|
|
227
226
|
(onStoreChange) => {
|
|
@@ -241,11 +240,11 @@ var createRoomBundle = (client, options) => {
|
|
|
241
240
|
getSnapshot,
|
|
242
241
|
getSnapshot,
|
|
243
242
|
_selector,
|
|
244
|
-
(
|
|
243
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : fastDeepEqual
|
|
245
244
|
);
|
|
246
245
|
};
|
|
247
246
|
const useOther = (connectionId, selector = identity, options2) => {
|
|
248
|
-
var
|
|
247
|
+
var _a;
|
|
249
248
|
const room = useRoom();
|
|
250
249
|
const subscribe = useCallback3(
|
|
251
250
|
(onStoreChange) => {
|
|
@@ -265,11 +264,11 @@ var createRoomBundle = (client, options) => {
|
|
|
265
264
|
getSnapshot,
|
|
266
265
|
getSnapshot,
|
|
267
266
|
_selector,
|
|
268
|
-
(
|
|
267
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : fastDeepEqual
|
|
269
268
|
);
|
|
270
269
|
};
|
|
271
270
|
const useOthers = (selector = identity, options2) => {
|
|
272
|
-
var
|
|
271
|
+
var _a;
|
|
273
272
|
const room = useRoom();
|
|
274
273
|
const subscribe = useCallback3(
|
|
275
274
|
(onStoreChange) => {
|
|
@@ -283,7 +282,7 @@ var createRoomBundle = (client, options) => {
|
|
|
283
282
|
getSnapshot,
|
|
284
283
|
getSnapshot,
|
|
285
284
|
selector,
|
|
286
|
-
(
|
|
285
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : (a, b) => {
|
|
287
286
|
if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) {
|
|
288
287
|
return shallowArrayEqual(a, b);
|
|
289
288
|
}
|
|
@@ -296,7 +295,7 @@ var createRoomBundle = (client, options) => {
|
|
|
296
295
|
return room.redo;
|
|
297
296
|
};
|
|
298
297
|
const useStorage = (key, selector = identity, options2) => {
|
|
299
|
-
var
|
|
298
|
+
var _a, _b;
|
|
300
299
|
const room = useRoom();
|
|
301
300
|
const rerender = useRerender();
|
|
302
301
|
room.subscribe("storage-loaded", () => {
|
|
@@ -317,7 +316,7 @@ var createRoomBundle = (client, options) => {
|
|
|
317
316
|
getSnapshot,
|
|
318
317
|
getSnapshot,
|
|
319
318
|
_selector,
|
|
320
|
-
(
|
|
319
|
+
(_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : fastDeepEqual
|
|
321
320
|
);
|
|
322
321
|
const sharedType = (_b = room.getStorage(key)) != null ? _b : null;
|
|
323
322
|
return [data, sharedType];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "@pluv/client React.js bindings",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"fast-deep-equal": "^3.1.3",
|
|
21
|
-
"@pluv/
|
|
22
|
-
"@pluv/
|
|
23
|
-
"@pluv/
|
|
21
|
+
"@pluv/client": "^0.28.0",
|
|
22
|
+
"@pluv/crdt": "^0.28.0",
|
|
23
|
+
"@pluv/types": "^0.28.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@types/react": "^18.0.0",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"react": "^18.3.1",
|
|
33
33
|
"tsup": "^8.3.0",
|
|
34
34
|
"typescript": "^5.6.2",
|
|
35
|
-
"@pluv/tsconfig": "^0.
|
|
36
|
-
"eslint-config-pluv": "^0.
|
|
35
|
+
"@pluv/tsconfig": "^0.28.0",
|
|
36
|
+
"eslint-config-pluv": "^0.28.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsup src/index.ts --format esm,cjs --dts --external react",
|
package/src/createRoomBundle.tsx
CHANGED
|
@@ -13,8 +13,7 @@ import type {
|
|
|
13
13
|
WebSocketConnection,
|
|
14
14
|
} from "@pluv/client";
|
|
15
15
|
import { MockedRoom } from "@pluv/client";
|
|
16
|
-
import type { AbstractCrdtDoc,
|
|
17
|
-
import { noop } from "@pluv/crdt";
|
|
16
|
+
import type { AbstractCrdtDoc, CrdtType, InferCrdtJson } from "@pluv/crdt";
|
|
18
17
|
import type { IOEventMessage, IOLike, Id, InferIOInput, InferIOOutput, JsonObject } from "@pluv/types";
|
|
19
18
|
import fastDeepEqual from "fast-deep-equal";
|
|
20
19
|
import type { Dispatch, FC, ReactNode } from "react";
|
|
@@ -29,7 +28,6 @@ export type CreateRoomBundleOptions<
|
|
|
29
28
|
TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {},
|
|
30
29
|
> = {
|
|
31
30
|
addons?: readonly PluvRoomAddon<TIO, TMetadata, TPresence, TStorage>[];
|
|
32
|
-
initialStorage?: AbstractCrdtDocFactory<TStorage>;
|
|
33
31
|
router?: PluvRouter<TIO, TPresence, TStorage, TEvents>;
|
|
34
32
|
};
|
|
35
33
|
|
|
@@ -147,8 +145,6 @@ export const createRoomBundle = <
|
|
|
147
145
|
client: PluvClient<TIO, TPresence, TStorage, TMetadata>,
|
|
148
146
|
options: CreateRoomBundleOptions<TIO, TMetadata, TPresence, TStorage, TEvents>,
|
|
149
147
|
): CreateRoomBundle<TIO, TMetadata, TPresence, TStorage, TEvents> => {
|
|
150
|
-
const _initialStorage = (options.initialStorage ?? noop.doc()) as AbstractCrdtDocFactory<TStorage>;
|
|
151
|
-
|
|
152
148
|
/**
|
|
153
149
|
* !HACK
|
|
154
150
|
* @description We'll let the context error out if the room is not provided,
|
|
@@ -170,7 +166,9 @@ export const createRoomBundle = <
|
|
|
170
166
|
events,
|
|
171
167
|
initialPresence,
|
|
172
168
|
initialStorage:
|
|
173
|
-
typeof initialStorage === "function"
|
|
169
|
+
typeof initialStorage === "function"
|
|
170
|
+
? client._defs.initialStorage?.getFactory(initialStorage)
|
|
171
|
+
: client._defs.initialStorage,
|
|
174
172
|
});
|
|
175
173
|
});
|
|
176
174
|
|
|
@@ -195,7 +193,9 @@ export const createRoomBundle = <
|
|
|
195
193
|
debug,
|
|
196
194
|
initialPresence,
|
|
197
195
|
initialStorage:
|
|
198
|
-
typeof initialStorage === "function"
|
|
196
|
+
typeof initialStorage === "function"
|
|
197
|
+
? client._defs.initialStorage?.getFactory(initialStorage)
|
|
198
|
+
: client._defs.initialStorage,
|
|
199
199
|
metadata,
|
|
200
200
|
onAuthorizationFail,
|
|
201
201
|
router: options.router,
|