@pluv/react 0.28.0 → 0.30.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 +91 -0
- package/dist/index.d.mts +14 -19
- package/dist/index.d.ts +14 -19
- package/dist/index.js +11 -23
- package/dist/index.mjs +11 -23
- package/package.json +7 -7
- package/src/createBundle.tsx +531 -16
- package/src/index.ts +1 -8
- package/src/createRoomBundle.tsx +0 -559
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/react@0.
|
|
2
|
+
> @pluv/react@0.30.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
|
+
[32mCJS[39m [1mdist/index.js [22m[32m13.92 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 84ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m11.47 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 87ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 6326ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m5.54 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m5.54 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,96 @@
|
|
|
1
1
|
# @pluv/react
|
|
2
2
|
|
|
3
|
+
## 0.30.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [cff933a]
|
|
8
|
+
- @pluv/client@0.30.0
|
|
9
|
+
- @pluv/crdt@0.30.0
|
|
10
|
+
- @pluv/types@0.30.0
|
|
11
|
+
|
|
12
|
+
## 0.29.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- 525aeae: **BREAKING**
|
|
17
|
+
|
|
18
|
+
Merge `createBundle` with `createRoomBundle`.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// Before
|
|
22
|
+
const {
|
|
23
|
+
createRoomBundle,
|
|
24
|
+
|
|
25
|
+
// components
|
|
26
|
+
PluvProvider,
|
|
27
|
+
|
|
28
|
+
// hooks
|
|
29
|
+
useClient,
|
|
30
|
+
} = createBundle(client);
|
|
31
|
+
|
|
32
|
+
export const {
|
|
33
|
+
// components
|
|
34
|
+
MockedRoomProvider,
|
|
35
|
+
PluvRoomProvider,
|
|
36
|
+
|
|
37
|
+
// utils
|
|
38
|
+
event,
|
|
39
|
+
|
|
40
|
+
// hooks
|
|
41
|
+
useBroadcast,
|
|
42
|
+
useCanRedo,
|
|
43
|
+
useCanUndo,
|
|
44
|
+
useConnection,
|
|
45
|
+
useDoc,
|
|
46
|
+
useEvent,
|
|
47
|
+
useMyPresence,
|
|
48
|
+
useMyself,
|
|
49
|
+
useOther,
|
|
50
|
+
useOthers,
|
|
51
|
+
useRedo,
|
|
52
|
+
useRoom,
|
|
53
|
+
useStorage,
|
|
54
|
+
useTransact,
|
|
55
|
+
useUndo,
|
|
56
|
+
} = createRoomBundle({});
|
|
57
|
+
|
|
58
|
+
// After
|
|
59
|
+
const {
|
|
60
|
+
// components
|
|
61
|
+
MockedRoomProvider,
|
|
62
|
+
PluvProvider,
|
|
63
|
+
PluvRoomProvider,
|
|
64
|
+
|
|
65
|
+
// utils
|
|
66
|
+
event,
|
|
67
|
+
|
|
68
|
+
// hooks
|
|
69
|
+
useBroadcast,
|
|
70
|
+
useCanRedo,
|
|
71
|
+
useCanUndo,
|
|
72
|
+
useClient,
|
|
73
|
+
useConnection,
|
|
74
|
+
useDoc,
|
|
75
|
+
useEvent,
|
|
76
|
+
useMyPresence,
|
|
77
|
+
useMyself,
|
|
78
|
+
useOther,
|
|
79
|
+
useOthers,
|
|
80
|
+
useRedo,
|
|
81
|
+
useRoom,
|
|
82
|
+
useStorage,
|
|
83
|
+
useTransact,
|
|
84
|
+
useUndo,
|
|
85
|
+
} = createBundle(client);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- @pluv/client@0.29.0
|
|
91
|
+
- @pluv/crdt@0.29.0
|
|
92
|
+
- @pluv/types@0.29.0
|
|
93
|
+
|
|
3
94
|
## 0.28.0
|
|
4
95
|
|
|
5
96
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluvRoomDebug, PluvRouterEventConfig, MergeEvents, PluvClient, WebSocketConnection, UserInfo, AbstractRoom, MockedRoomEvents, PluvRoomAddon, PluvRouter } from '@pluv/client';
|
|
2
2
|
export { ConnectionState, createClient } from '@pluv/client';
|
|
3
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';
|
|
7
|
-
import { FC, Dispatch
|
|
7
|
+
import { ReactNode, FC, Dispatch } from 'react';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
9
|
+
interface PluvProviderProps {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
13
12
|
type BaseRoomProviderProps<TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>> = {
|
|
14
13
|
children?: ReactNode;
|
|
15
14
|
initialStorage?: keyof TStorage extends never ? never : () => TStorage;
|
|
@@ -42,13 +41,15 @@ type EventProxy<TIO extends IOLike> = {
|
|
|
42
41
|
useEvent: (callback: (data: Id<IOEventMessage<TIO, event>>) => void) => void;
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
|
-
interface
|
|
44
|
+
interface CreateBundle<TIO extends IOLike, TMetadata extends JsonObject, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> {
|
|
46
45
|
MockedRoomProvider: FC<MockedRoomProviderProps<TIO, TPresence, TStorage>>;
|
|
46
|
+
PluvProvider: FC<PluvProviderProps>;
|
|
47
47
|
PluvRoomProvider: FC<PluvRoomProviderProps<TIO, TMetadata, TPresence, TStorage>>;
|
|
48
48
|
event: EventProxy<MergeEvents<TEvents, TIO>>;
|
|
49
49
|
useBroadcast: () => BroadcastProxy<MergeEvents<TEvents, TIO>>;
|
|
50
50
|
useCanRedo: () => boolean;
|
|
51
51
|
useCanUndo: () => boolean;
|
|
52
|
+
useClient: () => PluvClient<TIO, TPresence, TStorage, TMetadata>;
|
|
52
53
|
useConnection: <T extends unknown = WebSocketConnection>(selector: (connection: WebSocketConnection) => T, options?: SubscriptionHookOptions<Id<T>>) => Id<T>;
|
|
53
54
|
useDoc: () => AbstractCrdtDoc<TStorage>;
|
|
54
55
|
useEvent: <TType extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(type: TType, callback: (data: Id<IOEventMessage<MergeEvents<TEvents, TIO>, TType>>) => void) => void;
|
|
@@ -62,16 +63,10 @@ interface CreateRoomBundle<TIO extends IOLike, TMetadata extends JsonObject, TPr
|
|
|
62
63
|
useTransact: () => (fn: (storage: TStorage) => void, origin?: string) => void;
|
|
63
64
|
useUndo: () => () => void;
|
|
64
65
|
}
|
|
65
|
-
type
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
interface CreateBundle<TIO extends IOLike, TMetadata extends JsonObject, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}> {
|
|
71
|
-
createRoomBundle: <TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(options: CreateRoomBundleOptions<TIO, TMetadata, TPresence, TStorage, TEvents>) => CreateRoomBundle<TIO, TMetadata, TPresence, TStorage, TEvents>;
|
|
72
|
-
PluvProvider: FC<PluvProviderProps>;
|
|
73
|
-
useClient: () => PluvClient<TIO, TPresence, TStorage, TMetadata>;
|
|
74
|
-
}
|
|
75
|
-
declare const createBundle: <TIO extends IOLike, TMetadata extends JsonObject = {}, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}>(client: PluvClient<TIO, TPresence, TStorage, TMetadata>) => CreateBundle<TIO, TMetadata, TPresence, TStorage>;
|
|
66
|
+
type CreateBundleOptions<TIO extends IOLike, TMetadata extends JsonObject = {}, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> = {
|
|
67
|
+
addons?: readonly PluvRoomAddon<TIO, TMetadata, TPresence, TStorage>[];
|
|
68
|
+
router?: PluvRouter<TIO, TPresence, TStorage, TEvents>;
|
|
69
|
+
};
|
|
70
|
+
declare const createBundle: <TIO extends IOLike, TMetadata extends JsonObject = {}, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(client: PluvClient<TIO, TPresence, TStorage, TMetadata>, options?: CreateBundleOptions<TIO, TMetadata, TPresence, TStorage, TEvents>) => CreateBundle<TIO, TMetadata, TPresence, TStorage>;
|
|
76
71
|
|
|
77
|
-
export { type CreateBundle, type
|
|
72
|
+
export { type CreateBundle, type PluvProviderProps, type PluvRoomProviderProps, type SubscriptionHookOptions, createBundle };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluvRoomDebug, PluvRouterEventConfig, MergeEvents, PluvClient, WebSocketConnection, UserInfo, AbstractRoom, MockedRoomEvents, PluvRoomAddon, PluvRouter } from '@pluv/client';
|
|
2
2
|
export { ConnectionState, createClient } from '@pluv/client';
|
|
3
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';
|
|
7
|
-
import { FC, Dispatch
|
|
7
|
+
import { ReactNode, FC, Dispatch } from 'react';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
9
|
+
interface PluvProviderProps {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
13
12
|
type BaseRoomProviderProps<TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>> = {
|
|
14
13
|
children?: ReactNode;
|
|
15
14
|
initialStorage?: keyof TStorage extends never ? never : () => TStorage;
|
|
@@ -42,13 +41,15 @@ type EventProxy<TIO extends IOLike> = {
|
|
|
42
41
|
useEvent: (callback: (data: Id<IOEventMessage<TIO, event>>) => void) => void;
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
|
-
interface
|
|
44
|
+
interface CreateBundle<TIO extends IOLike, TMetadata extends JsonObject, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> {
|
|
46
45
|
MockedRoomProvider: FC<MockedRoomProviderProps<TIO, TPresence, TStorage>>;
|
|
46
|
+
PluvProvider: FC<PluvProviderProps>;
|
|
47
47
|
PluvRoomProvider: FC<PluvRoomProviderProps<TIO, TMetadata, TPresence, TStorage>>;
|
|
48
48
|
event: EventProxy<MergeEvents<TEvents, TIO>>;
|
|
49
49
|
useBroadcast: () => BroadcastProxy<MergeEvents<TEvents, TIO>>;
|
|
50
50
|
useCanRedo: () => boolean;
|
|
51
51
|
useCanUndo: () => boolean;
|
|
52
|
+
useClient: () => PluvClient<TIO, TPresence, TStorage, TMetadata>;
|
|
52
53
|
useConnection: <T extends unknown = WebSocketConnection>(selector: (connection: WebSocketConnection) => T, options?: SubscriptionHookOptions<Id<T>>) => Id<T>;
|
|
53
54
|
useDoc: () => AbstractCrdtDoc<TStorage>;
|
|
54
55
|
useEvent: <TType extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(type: TType, callback: (data: Id<IOEventMessage<MergeEvents<TEvents, TIO>, TType>>) => void) => void;
|
|
@@ -62,16 +63,10 @@ interface CreateRoomBundle<TIO extends IOLike, TMetadata extends JsonObject, TPr
|
|
|
62
63
|
useTransact: () => (fn: (storage: TStorage) => void, origin?: string) => void;
|
|
63
64
|
useUndo: () => () => void;
|
|
64
65
|
}
|
|
65
|
-
type
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
interface CreateBundle<TIO extends IOLike, TMetadata extends JsonObject, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}> {
|
|
71
|
-
createRoomBundle: <TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(options: CreateRoomBundleOptions<TIO, TMetadata, TPresence, TStorage, TEvents>) => CreateRoomBundle<TIO, TMetadata, TPresence, TStorage, TEvents>;
|
|
72
|
-
PluvProvider: FC<PluvProviderProps>;
|
|
73
|
-
useClient: () => PluvClient<TIO, TPresence, TStorage, TMetadata>;
|
|
74
|
-
}
|
|
75
|
-
declare const createBundle: <TIO extends IOLike, TMetadata extends JsonObject = {}, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}>(client: PluvClient<TIO, TPresence, TStorage, TMetadata>) => CreateBundle<TIO, TMetadata, TPresence, TStorage>;
|
|
66
|
+
type CreateBundleOptions<TIO extends IOLike, TMetadata extends JsonObject = {}, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> = {
|
|
67
|
+
addons?: readonly PluvRoomAddon<TIO, TMetadata, TPresence, TStorage>[];
|
|
68
|
+
router?: PluvRouter<TIO, TPresence, TStorage, TEvents>;
|
|
69
|
+
};
|
|
70
|
+
declare const createBundle: <TIO extends IOLike, TMetadata extends JsonObject = {}, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(client: PluvClient<TIO, TPresence, TStorage, TMetadata>, options?: CreateBundleOptions<TIO, TMetadata, TPresence, TStorage, TEvents>) => CreateBundle<TIO, TMetadata, TPresence, TStorage>;
|
|
76
71
|
|
|
77
|
-
export { type CreateBundle, type
|
|
72
|
+
export { type CreateBundle, type PluvProviderProps, type PluvRoomProviderProps, type SubscriptionHookOptions, createBundle };
|
package/dist/index.js
CHANGED
|
@@ -38,9 +38,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
38
38
|
var import_client2 = require("@pluv/client");
|
|
39
39
|
|
|
40
40
|
// src/createBundle.tsx
|
|
41
|
-
var import_react5 = require("react");
|
|
42
|
-
|
|
43
|
-
// src/createRoomBundle.tsx
|
|
44
41
|
var import_client = require("@pluv/client");
|
|
45
42
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
|
46
43
|
var import_react4 = require("react");
|
|
@@ -108,9 +105,10 @@ var useSyncExternalStoreWithSelector = (subscribe, getClientSnapshot, getServerS
|
|
|
108
105
|
return typeof window !== "undefined" ? noSsr(result, _getServerSnapshot == null ? void 0 : _getServerSnapshot()) : result;
|
|
109
106
|
};
|
|
110
107
|
|
|
111
|
-
// src/
|
|
108
|
+
// src/createBundle.tsx
|
|
112
109
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
113
|
-
var
|
|
110
|
+
var createBundle = (client, options = {}) => {
|
|
111
|
+
const PluvContext = (0, import_react4.createContext)(null);
|
|
114
112
|
const PluvRoomContext = (0, import_react4.createContext)(null);
|
|
115
113
|
const MockedRoomContext = (0, import_react4.createContext)({ room: null });
|
|
116
114
|
const MockedRoomProvider = (0, import_react4.memo)((props) => {
|
|
@@ -159,6 +157,12 @@ var createRoomBundle = (client, options) => {
|
|
|
159
157
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluvRoomContext.Provider, { value: mockedRoom != null ? mockedRoom : room, children });
|
|
160
158
|
});
|
|
161
159
|
PluvRoomProvider.displayName = "PluvRoomProvider";
|
|
160
|
+
const PluvProvider = (0, import_react4.memo)((props) => {
|
|
161
|
+
const { children } = props;
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluvContext.Provider, { value: client, children });
|
|
163
|
+
});
|
|
164
|
+
PluvProvider.displayName = "PluvProvider";
|
|
165
|
+
const useClient = () => (0, import_react4.useContext)(PluvContext);
|
|
162
166
|
const useRoom = () => (0, import_react4.useContext)(PluvRoomContext);
|
|
163
167
|
const useBroadcast = () => {
|
|
164
168
|
const room = useRoom();
|
|
@@ -368,6 +372,7 @@ var createRoomBundle = (client, options) => {
|
|
|
368
372
|
return {
|
|
369
373
|
// components
|
|
370
374
|
MockedRoomProvider,
|
|
375
|
+
PluvProvider,
|
|
371
376
|
PluvRoomProvider,
|
|
372
377
|
// proxies
|
|
373
378
|
event,
|
|
@@ -375,6 +380,7 @@ var createRoomBundle = (client, options) => {
|
|
|
375
380
|
useBroadcast,
|
|
376
381
|
useCanRedo,
|
|
377
382
|
useCanUndo,
|
|
383
|
+
useClient,
|
|
378
384
|
useConnection,
|
|
379
385
|
useDoc,
|
|
380
386
|
useEvent,
|
|
@@ -389,24 +395,6 @@ var createRoomBundle = (client, options) => {
|
|
|
389
395
|
useUndo
|
|
390
396
|
};
|
|
391
397
|
};
|
|
392
|
-
|
|
393
|
-
// src/createBundle.tsx
|
|
394
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
395
|
-
var createBundle = (client) => {
|
|
396
|
-
const PluvContext = (0, import_react5.createContext)(null);
|
|
397
|
-
const PluvProvider = (0, import_react5.memo)((props) => {
|
|
398
|
-
const { children } = props;
|
|
399
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PluvContext.Provider, { value: client, children });
|
|
400
|
-
});
|
|
401
|
-
PluvProvider.displayName = "PluvProvider";
|
|
402
|
-
const useClient = () => (0, import_react5.useContext)(PluvContext);
|
|
403
|
-
const createRoomBundle2 = (options) => createRoomBundle(client, options);
|
|
404
|
-
return {
|
|
405
|
-
createRoomBundle: createRoomBundle2,
|
|
406
|
-
PluvProvider,
|
|
407
|
-
useClient
|
|
408
|
-
};
|
|
409
|
-
};
|
|
410
398
|
// Annotate the CommonJS export names for ESM import in node:
|
|
411
399
|
0 && (module.exports = {
|
|
412
400
|
ConnectionState,
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
import { ConnectionState, createClient } from "@pluv/client";
|
|
3
3
|
|
|
4
4
|
// src/createBundle.tsx
|
|
5
|
-
import { createContext as createContext2, memo as memo2, useContext as useContext2 } from "react";
|
|
6
|
-
|
|
7
|
-
// src/createRoomBundle.tsx
|
|
8
5
|
import { MockedRoom } from "@pluv/client";
|
|
9
6
|
import fastDeepEqual from "fast-deep-equal";
|
|
10
7
|
import { createContext, memo, useCallback as useCallback3, useContext, useEffect as useEffect2, useMemo, useState as useState3 } from "react";
|
|
@@ -72,9 +69,10 @@ var useSyncExternalStoreWithSelector = (subscribe, getClientSnapshot, getServerS
|
|
|
72
69
|
return typeof window !== "undefined" ? noSsr(result, _getServerSnapshot == null ? void 0 : _getServerSnapshot()) : result;
|
|
73
70
|
};
|
|
74
71
|
|
|
75
|
-
// src/
|
|
72
|
+
// src/createBundle.tsx
|
|
76
73
|
import { jsx } from "react/jsx-runtime";
|
|
77
|
-
var
|
|
74
|
+
var createBundle = (client, options = {}) => {
|
|
75
|
+
const PluvContext = createContext(null);
|
|
78
76
|
const PluvRoomContext = createContext(null);
|
|
79
77
|
const MockedRoomContext = createContext({ room: null });
|
|
80
78
|
const MockedRoomProvider = memo((props) => {
|
|
@@ -123,6 +121,12 @@ var createRoomBundle = (client, options) => {
|
|
|
123
121
|
return /* @__PURE__ */ jsx(PluvRoomContext.Provider, { value: mockedRoom != null ? mockedRoom : room, children });
|
|
124
122
|
});
|
|
125
123
|
PluvRoomProvider.displayName = "PluvRoomProvider";
|
|
124
|
+
const PluvProvider = memo((props) => {
|
|
125
|
+
const { children } = props;
|
|
126
|
+
return /* @__PURE__ */ jsx(PluvContext.Provider, { value: client, children });
|
|
127
|
+
});
|
|
128
|
+
PluvProvider.displayName = "PluvProvider";
|
|
129
|
+
const useClient = () => useContext(PluvContext);
|
|
126
130
|
const useRoom = () => useContext(PluvRoomContext);
|
|
127
131
|
const useBroadcast = () => {
|
|
128
132
|
const room = useRoom();
|
|
@@ -332,6 +336,7 @@ var createRoomBundle = (client, options) => {
|
|
|
332
336
|
return {
|
|
333
337
|
// components
|
|
334
338
|
MockedRoomProvider,
|
|
339
|
+
PluvProvider,
|
|
335
340
|
PluvRoomProvider,
|
|
336
341
|
// proxies
|
|
337
342
|
event,
|
|
@@ -339,6 +344,7 @@ var createRoomBundle = (client, options) => {
|
|
|
339
344
|
useBroadcast,
|
|
340
345
|
useCanRedo,
|
|
341
346
|
useCanUndo,
|
|
347
|
+
useClient,
|
|
342
348
|
useConnection,
|
|
343
349
|
useDoc,
|
|
344
350
|
useEvent,
|
|
@@ -353,24 +359,6 @@ var createRoomBundle = (client, options) => {
|
|
|
353
359
|
useUndo
|
|
354
360
|
};
|
|
355
361
|
};
|
|
356
|
-
|
|
357
|
-
// src/createBundle.tsx
|
|
358
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
359
|
-
var createBundle = (client) => {
|
|
360
|
-
const PluvContext = createContext2(null);
|
|
361
|
-
const PluvProvider = memo2((props) => {
|
|
362
|
-
const { children } = props;
|
|
363
|
-
return /* @__PURE__ */ jsx2(PluvContext.Provider, { value: client, children });
|
|
364
|
-
});
|
|
365
|
-
PluvProvider.displayName = "PluvProvider";
|
|
366
|
-
const useClient = () => useContext2(PluvContext);
|
|
367
|
-
const createRoomBundle2 = (options) => createRoomBundle(client, options);
|
|
368
|
-
return {
|
|
369
|
-
createRoomBundle: createRoomBundle2,
|
|
370
|
-
PluvProvider,
|
|
371
|
-
useClient
|
|
372
|
-
};
|
|
373
|
-
};
|
|
374
362
|
export {
|
|
375
363
|
ConnectionState,
|
|
376
364
|
createBundle,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "@pluv/client React.js bindings",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,22 +18,22 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"fast-deep-equal": "^3.1.3",
|
|
21
|
-
"@pluv/client": "^0.
|
|
22
|
-
"@pluv/crdt": "^0.
|
|
23
|
-
"@pluv/types": "^0.
|
|
21
|
+
"@pluv/client": "^0.30.0",
|
|
22
|
+
"@pluv/crdt": "^0.30.0",
|
|
23
|
+
"@pluv/types": "^0.30.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@types/react": "^18.0.0",
|
|
27
27
|
"react": "^18.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/react": "^18.3.
|
|
30
|
+
"@types/react": "^18.3.8",
|
|
31
31
|
"eslint": "^8.57.0",
|
|
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.30.0",
|
|
36
|
+
"eslint-config-pluv": "^0.30.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsup src/index.ts --format esm,cjs --dts --external react",
|