@yorkie-js/react 0.6.3 → 0.6.6-rc

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,8 +1,11 @@
1
+ import { default as default_2 } from 'react';
1
2
  import { Indexable } from '@yorkie-js/sdk';
2
3
  import { JSONArray } from '@yorkie-js/sdk';
3
4
  import { JSONObject } from '@yorkie-js/sdk';
4
5
  import { JSX } from 'react/jsx-dev-runtime';
6
+ import { Presence } from '@yorkie-js/sdk';
5
7
  import { PropsWithChildren } from 'react';
8
+ import { StreamConnectionStatus } from '@yorkie-js/sdk';
6
9
 
7
10
  /**
8
11
  * `DocumentProvider` is a component that provides a document to its children.
@@ -13,13 +16,18 @@ export declare const DocumentProvider: <R, P extends Indexable = Indexable>({ do
13
16
  docKey: string;
14
17
  initialRoot?: R | undefined;
15
18
  initialPresence?: P | undefined;
16
- children?: React.ReactNode;
19
+ children?: default_2.ReactNode;
17
20
  }) => JSX.Element;
18
21
 
19
22
  export { JSONArray }
20
23
 
21
24
  export { JSONObject }
22
25
 
26
+ /**
27
+ * `useConnection` is a custom hook that returns the connection status of the document.
28
+ */
29
+ export declare const useConnection: () => StreamConnectionStatus;
30
+
23
31
  /**
24
32
  * `useDocument` is a custom hook that returns the root object and update function of the document.
25
33
  * This hook must be used within a `DocumentProvider`.
@@ -30,7 +38,8 @@ export declare const useDocument: <R, P extends Indexable = Indexable>() => {
30
38
  clientID: string;
31
39
  presence: P;
32
40
  }[];
33
- update: (callback: (root: R, presence: P) => void) => void;
41
+ connection: StreamConnectionStatus;
42
+ update: (callback: (root: R, presence: Presence<P>) => void) => void;
34
43
  loading: boolean;
35
44
  error: Error | undefined;
36
45
  };
@@ -52,18 +61,25 @@ export declare const useRoot: () => {
52
61
  };
53
62
 
54
63
  /**
55
- * `useYorkieDoc` is a custom hook that initializes a Yorkie client and attaches a document.
64
+ * `useYorkieDoc` is a custom hook that initializes a Yorkie Client and a
65
+ * document in a single hook.
56
66
  *
57
67
  * @param apiKey
58
68
  * @param docKey
59
- * @param initialRoot
60
69
  * @returns
61
70
  */
62
- export declare function useYorkieDoc<T>(apiKey: string, docKey: string, initialRoot: T, options?: {
71
+ export declare function useYorkieDoc<R, P extends Indexable>(apiKey: string, docKey: string, options?: {
72
+ initialRoot?: R;
73
+ initialPresence?: P;
63
74
  rpcAddr?: string;
64
75
  }): {
65
- root: T;
66
- update: (callback: (root: T) => void) => void;
76
+ root: R;
77
+ presences: Array<{
78
+ clientID: string;
79
+ presence: P;
80
+ }>;
81
+ connection: StreamConnectionStatus;
82
+ update: (callback: (root: R, presence: Presence<P>) => void) => void;
67
83
  loading: boolean;
68
84
  error: Error | undefined;
69
85
  };