@yorkie-js/react 0.6.35 → 0.6.37
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/dist/yorkie-js-react.d.ts +76 -3
- package/dist/yorkie-js-react.es.js +713 -511
- package/dist/yorkie-js-react.es.js.map +1 -1
- package/dist/yorkie-js-react.js +713 -511
- package/dist/yorkie-js-react.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,14 +1,46 @@
|
|
|
1
1
|
import { ClientOptions } from '@yorkie-js/sdk';
|
|
2
2
|
import { default as default_2 } from 'react';
|
|
3
|
-
import { DocPresence } from '@yorkie-js/sdk';
|
|
4
3
|
import { Document as Document_2 } from '@yorkie-js/sdk';
|
|
5
4
|
import { Indexable } from '@yorkie-js/sdk';
|
|
6
5
|
import { JSONArray } from '@yorkie-js/sdk';
|
|
7
6
|
import { JSONObject } from '@yorkie-js/sdk';
|
|
8
7
|
import { JSX } from 'react/jsx-dev-runtime';
|
|
8
|
+
import { Presence } from '@yorkie-js/sdk';
|
|
9
9
|
import { PropsWithChildren } from 'react';
|
|
10
10
|
import { StreamConnectionStatus } from '@yorkie-js/sdk';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* `ChannelProvider` is a component that provides Channel context to its children.
|
|
14
|
+
* It must be used within a YorkieProvider to access the client.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <YorkieProvider apiKey="..." rpcAddr="...">
|
|
19
|
+
* <ChannelProvider channelKey="room-123" isRealtime={true}>
|
|
20
|
+
* <ChatRoom />
|
|
21
|
+
* </ChannelProvider>
|
|
22
|
+
* </YorkieProvider>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const ChannelProvider: React.FC<ChannelProviderProps>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* `ChannelProviderProps` represents the props for ChannelProvider.
|
|
29
|
+
*/
|
|
30
|
+
declare type ChannelProviderProps = PropsWithChildren<{
|
|
31
|
+
/**
|
|
32
|
+
* `channelKey` is the key for the channel.
|
|
33
|
+
*/
|
|
34
|
+
channelKey: string;
|
|
35
|
+
/**
|
|
36
|
+
* `isRealtime` determines the synchronization mode.
|
|
37
|
+
* - true: Realtime mode (automatic updates via watch stream)
|
|
38
|
+
* - false: Manual mode (requires manual sync)
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
isRealtime?: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
|
|
12
44
|
/**
|
|
13
45
|
* `createDocumentSelector` is a factory function that provides a selector-based `useDocument` hook.
|
|
14
46
|
* By currying this function, type T can be inferred from the selector function.
|
|
@@ -25,7 +57,7 @@ declare type DocumentContextType<R, P extends Indexable = Indexable> = {
|
|
|
25
57
|
presence: P;
|
|
26
58
|
}>;
|
|
27
59
|
connection: StreamConnectionStatus;
|
|
28
|
-
update: (callback: (root: R, presence:
|
|
60
|
+
update: (callback: (root: R, presence: Presence<P>) => void) => void;
|
|
29
61
|
loading: boolean;
|
|
30
62
|
error: Error | undefined;
|
|
31
63
|
};
|
|
@@ -51,6 +83,30 @@ export { JSONObject }
|
|
|
51
83
|
*/
|
|
52
84
|
export declare function shallowEqual<T>(valueA: T, valueB: T): boolean;
|
|
53
85
|
|
|
86
|
+
/**
|
|
87
|
+
* `useChannel` is a custom hook that returns the channel state.
|
|
88
|
+
* It must be used within a ChannelProvider.
|
|
89
|
+
*
|
|
90
|
+
* @returns An object containing count, loading, and error state
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```tsx
|
|
94
|
+
* function ChatRoom() {
|
|
95
|
+
* const { count, loading, error } = useChannel();
|
|
96
|
+
*
|
|
97
|
+
* if (loading) return <div>Loading...</div>;
|
|
98
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
99
|
+
*
|
|
100
|
+
* return <div>{count} users online</div>;
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare const useChannel: () => {
|
|
105
|
+
count: number;
|
|
106
|
+
loading: boolean;
|
|
107
|
+
error: Error | undefined;
|
|
108
|
+
};
|
|
109
|
+
|
|
54
110
|
/**
|
|
55
111
|
* `useConnection` is a custom hook that returns the connection status of the document.
|
|
56
112
|
*/
|
|
@@ -63,6 +119,23 @@ export declare const useConnection: () => StreamConnectionStatus;
|
|
|
63
119
|
*/
|
|
64
120
|
export declare function useDocument<R, P extends Indexable = Indexable>(): DocumentContextType<R, P>;
|
|
65
121
|
|
|
122
|
+
/**
|
|
123
|
+
* `usePresenceCount` is a custom hook that returns only the count value.
|
|
124
|
+
* It must be used within a PresenceProvider.
|
|
125
|
+
* This is a convenience hook for when you only need the count.
|
|
126
|
+
*
|
|
127
|
+
* @returns The current online user count
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```tsx
|
|
131
|
+
* function UserCounter() {
|
|
132
|
+
* const count = usePresenceCount();
|
|
133
|
+
* return <span>{count} users online</span>;
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare const usePresenceCount: () => number;
|
|
138
|
+
|
|
66
139
|
/**
|
|
67
140
|
* `usePresences` is a custom hook that returns the presences of the document.
|
|
68
141
|
*/
|
|
@@ -93,7 +166,7 @@ export declare function useYorkieDoc<R, P extends Indexable = Indexable>(apiKey:
|
|
|
93
166
|
presence: P;
|
|
94
167
|
}>;
|
|
95
168
|
connection: StreamConnectionStatus;
|
|
96
|
-
update: (callback: (root: R, presence:
|
|
169
|
+
update: (callback: (root: R, presence: Presence<P>) => void) => void;
|
|
97
170
|
loading: boolean;
|
|
98
171
|
error: Error | undefined;
|
|
99
172
|
};
|