@yorkie-js/react 0.6.0 → 0.6.1-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.
- package/README.md +19 -0
- package/dist/yorkie-js-react.d.ts +78 -0
- package/dist/yorkie-js-react.es.js +23234 -0
- package/dist/yorkie-js-react.es.js.map +1 -0
- package/dist/yorkie-js-react.js +23238 -0
- package/dist/yorkie-js-react.js.map +1 -0
- package/package.json +5 -1
- package/lib/index.js +0 -17
- package/lib/useDocument.js +0 -88
- package/src/index.ts +0 -21
- package/src/useDocument.ts +0 -116
- package/tsconfig.json +0 -26
- package/vite.config.js +0 -31
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Yorkie React SDK
|
|
2
|
+
|
|
3
|
+
Yorkie React SDK is a library that provides React hooks and components for building collaborative applications with Yorkie.
|
|
4
|
+
|
|
5
|
+
## How to use React SDK
|
|
6
|
+
|
|
7
|
+
To get started using Yorkie React SDK, see: https://yorkie.dev/docs/getting-started/with-react
|
|
8
|
+
|
|
9
|
+
## Contributing
|
|
10
|
+
|
|
11
|
+
See [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
|
|
12
|
+
|
|
13
|
+
## Contributors ✨
|
|
14
|
+
|
|
15
|
+
Thanks goes to these incredible people:
|
|
16
|
+
|
|
17
|
+
<a href="https://github.com/yorkie-team/yorkie-js-sdk/graphs/contributors">
|
|
18
|
+
<img src="https://contrib.rocks/image?repo=yorkie-team/yorkie-js-sdk" />
|
|
19
|
+
</a>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Indexable } from '@yorkie-js/sdk';
|
|
2
|
+
import { JSONArray } from '@yorkie-js/sdk';
|
|
3
|
+
import { JSONObject } from '@yorkie-js/sdk';
|
|
4
|
+
import { JSX } from 'react/jsx-runtime';
|
|
5
|
+
import { PropsWithChildren } from 'react';
|
|
6
|
+
|
|
7
|
+
export declare const DocumentProvider: <R, P extends Indexable>({ docKey, initialRoot, children, }: {
|
|
8
|
+
docKey: string;
|
|
9
|
+
initialRoot: R;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}) => JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { JSONArray }
|
|
14
|
+
|
|
15
|
+
export { JSONObject }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `useDocument` is a custom hook that returns the root object and update function of the document.
|
|
19
|
+
* This hook must be used within a `DocumentProvider`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const useDocument: <R, P extends Indexable>() => {
|
|
22
|
+
root: R;
|
|
23
|
+
presences: {
|
|
24
|
+
clientID: string;
|
|
25
|
+
presence: P;
|
|
26
|
+
}[];
|
|
27
|
+
update: (callback: (root: R, presence: P) => void) => void;
|
|
28
|
+
loading: boolean;
|
|
29
|
+
error: Error | undefined;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `usePresences` is a custom hook that returns the presences of the document.
|
|
34
|
+
*/
|
|
35
|
+
export declare const usePresence: () => {
|
|
36
|
+
clientID: string;
|
|
37
|
+
presence: any;
|
|
38
|
+
}[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `useRoot` is a custom hook that returns the root object of the document.
|
|
42
|
+
* This hook must be used within a `DocumentProvider`.
|
|
43
|
+
*/
|
|
44
|
+
export declare const useRoot: () => {
|
|
45
|
+
root: any;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `useYorkieDoc` is a custom hook that initializes a Yorkie client and attaches a document.
|
|
50
|
+
*
|
|
51
|
+
* @param apiKey
|
|
52
|
+
* @param docKey
|
|
53
|
+
* @param initialRoot
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
export declare function useYorkieDoc<T>(apiKey: string, docKey: string, initialRoot: T, options?: {
|
|
57
|
+
rpcAddr?: string;
|
|
58
|
+
}): {
|
|
59
|
+
root: T;
|
|
60
|
+
update: (callback: (root: T) => void) => void;
|
|
61
|
+
loading: boolean;
|
|
62
|
+
error: Error | undefined;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* `YorkieProvider` is a component that provides the Yorkie client to its children.
|
|
67
|
+
*/
|
|
68
|
+
export declare const YorkieProvider: React.FC<PropsWithChildren<YorkieProviderProps>>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* `YorkieProviderProps` is a set of properties for `YorkieProvider`.
|
|
72
|
+
*/
|
|
73
|
+
declare interface YorkieProviderProps {
|
|
74
|
+
apiKey: string;
|
|
75
|
+
rpcAddr?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { }
|