@yorkie-js/react 0.6.0 → 0.6.1-rc1
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 +84 -0
- package/dist/yorkie-js-react.es.js +23242 -0
- package/dist/yorkie-js-react.es.js.map +1 -0
- package/dist/yorkie-js-react.js +23246 -0
- package/dist/yorkie-js-react.js.map +1 -0
- package/package.json +8 -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,84 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* `DocumentProvider` is a component that provides a document to its children.
|
|
9
|
+
* This component must be under a `YorkieProvider` component to initialize the
|
|
10
|
+
* Yorkie client properly.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DocumentProvider: <R, P extends Indexable = Indexable>({ docKey, initialRoot, children, }: {
|
|
13
|
+
docKey: string;
|
|
14
|
+
initialRoot: R;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}) => JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { JSONArray }
|
|
19
|
+
|
|
20
|
+
export { JSONObject }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `useDocument` is a custom hook that returns the root object and update function of the document.
|
|
24
|
+
* This hook must be used within a `DocumentProvider`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const useDocument: <R, P extends Indexable = Indexable>() => {
|
|
27
|
+
root: R;
|
|
28
|
+
presences: {
|
|
29
|
+
clientID: string;
|
|
30
|
+
presence: P;
|
|
31
|
+
}[];
|
|
32
|
+
update: (callback: (root: R, presence: P) => void) => void;
|
|
33
|
+
loading: boolean;
|
|
34
|
+
error: Error | undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* `usePresences` is a custom hook that returns the presences of the document.
|
|
39
|
+
*/
|
|
40
|
+
export declare const usePresences: () => {
|
|
41
|
+
clientID: string;
|
|
42
|
+
presence: Indexable;
|
|
43
|
+
}[];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `useRoot` is a custom hook that returns the root object of the document.
|
|
47
|
+
* This hook must be used within a `DocumentProvider`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const useRoot: () => {
|
|
50
|
+
root: any;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* `useYorkieDoc` is a custom hook that initializes a Yorkie client and attaches a document.
|
|
55
|
+
*
|
|
56
|
+
* @param apiKey
|
|
57
|
+
* @param docKey
|
|
58
|
+
* @param initialRoot
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
export declare function useYorkieDoc<T>(apiKey: string, docKey: string, initialRoot: T, options?: {
|
|
62
|
+
rpcAddr?: string;
|
|
63
|
+
}): {
|
|
64
|
+
root: T;
|
|
65
|
+
update: (callback: (root: T) => void) => void;
|
|
66
|
+
loading: boolean;
|
|
67
|
+
error: Error | undefined;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* `YorkieProvider` is a component that provides the Yorkie client to its children.
|
|
72
|
+
* It initializes the Yorkie client with the given API key and RPC address.
|
|
73
|
+
*/
|
|
74
|
+
export declare const YorkieProvider: React.FC<PropsWithChildren<YorkieProviderProps>>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* `YorkieProviderProps` is a set of properties for `YorkieProvider`.
|
|
78
|
+
*/
|
|
79
|
+
declare interface YorkieProviderProps {
|
|
80
|
+
apiKey: string;
|
|
81
|
+
rpcAddr?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { }
|