@yorkie-js/react 0.6.38 → 0.6.39
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.
|
@@ -67,10 +67,11 @@ declare type DocumentContextType<R, P extends Indexable = Indexable> = {
|
|
|
67
67
|
* This component must be under a `YorkieProvider` component to initialize the
|
|
68
68
|
* Yorkie client properly.
|
|
69
69
|
*/
|
|
70
|
-
export declare const DocumentProvider: <R, P extends Indexable = Indexable>({ docKey, initialRoot, initialPresence, children, }: {
|
|
70
|
+
export declare const DocumentProvider: <R, P extends Indexable = Indexable>({ docKey, initialRoot, initialPresence, enableDevtools, children, }: {
|
|
71
71
|
docKey: string;
|
|
72
72
|
initialRoot?: R | undefined;
|
|
73
73
|
initialPresence?: P | undefined;
|
|
74
|
+
enableDevtools?: boolean | undefined;
|
|
74
75
|
children?: default_2.ReactNode;
|
|
75
76
|
}) => JSX.Element;
|
|
76
77
|
|
|
@@ -159,6 +160,7 @@ export declare const useRoot: <R>() => {
|
|
|
159
160
|
export declare function useYorkieDoc<R, P extends Indexable = Indexable>(apiKey: string, docKey: string, opts?: Omit<ClientOptions, 'apiKey'> & {
|
|
160
161
|
initialRoot?: R;
|
|
161
162
|
initialPresence?: P;
|
|
163
|
+
enableDevtools?: boolean;
|
|
162
164
|
}): {
|
|
163
165
|
root: R;
|
|
164
166
|
presences: Array<{
|
|
@@ -22294,7 +22294,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
22294
22294
|
};
|
|
22295
22295
|
}
|
|
22296
22296
|
const name$1 = "@yorkie-js/sdk";
|
|
22297
|
-
const version$1 = "0.6.
|
|
22297
|
+
const version$1 = "0.6.39";
|
|
22298
22298
|
const pkg$1 = {
|
|
22299
22299
|
name: name$1,
|
|
22300
22300
|
version: version$1
|
|
@@ -23715,7 +23715,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
23715
23715
|
};
|
|
23716
23716
|
}
|
|
23717
23717
|
const name = "@yorkie-js/react";
|
|
23718
|
-
const version = "0.6.
|
|
23718
|
+
const version = "0.6.39";
|
|
23719
23719
|
const pkg = {
|
|
23720
23720
|
name,
|
|
23721
23721
|
version
|
|
@@ -23905,7 +23905,7 @@ function shallowEqual(valueA, valueB) {
|
|
|
23905
23905
|
valueB
|
|
23906
23906
|
);
|
|
23907
23907
|
}
|
|
23908
|
-
function useYorkieDocument(client, clientLoading, clientError, docKey, initialRoot, initialPresence,
|
|
23908
|
+
function useYorkieDocument(client, clientLoading, clientError, docKey, initialRoot, initialPresence, enableDevtools, docStore) {
|
|
23909
23909
|
const initialRootRef = useRef(initialRoot);
|
|
23910
23910
|
const initialPresenceRef = useRef(initialPresence);
|
|
23911
23911
|
const [didMount, setDidMount] = useState(false);
|
|
@@ -23914,7 +23914,7 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
|
|
|
23914
23914
|
}, []);
|
|
23915
23915
|
useEffect(() => {
|
|
23916
23916
|
if (clientError) {
|
|
23917
|
-
|
|
23917
|
+
docStore.setState((state) => ({
|
|
23918
23918
|
...state,
|
|
23919
23919
|
loading: false,
|
|
23920
23920
|
error: clientError
|
|
@@ -23922,22 +23922,22 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
|
|
|
23922
23922
|
return;
|
|
23923
23923
|
}
|
|
23924
23924
|
if (!client || clientLoading || !didMount) {
|
|
23925
|
-
|
|
23925
|
+
docStore.setState((state) => ({
|
|
23926
23926
|
...state,
|
|
23927
23927
|
loading: true
|
|
23928
23928
|
}));
|
|
23929
23929
|
return;
|
|
23930
23930
|
}
|
|
23931
|
-
|
|
23931
|
+
docStore.setState((state) => ({
|
|
23932
23932
|
...state,
|
|
23933
23933
|
loading: true,
|
|
23934
23934
|
error: void 0
|
|
23935
23935
|
}));
|
|
23936
|
-
const newDoc = new Document(docKey);
|
|
23936
|
+
const newDoc = new Document(docKey, { enableDevtools });
|
|
23937
23937
|
const unsubs = [];
|
|
23938
23938
|
unsubs.push(
|
|
23939
23939
|
newDoc.subscribe(() => {
|
|
23940
|
-
|
|
23940
|
+
docStore.setState((state) => ({
|
|
23941
23941
|
...state,
|
|
23942
23942
|
root: newDoc.getRoot()
|
|
23943
23943
|
}));
|
|
@@ -23945,7 +23945,7 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
|
|
|
23945
23945
|
);
|
|
23946
23946
|
unsubs.push(
|
|
23947
23947
|
newDoc.subscribe("presence", () => {
|
|
23948
|
-
|
|
23948
|
+
docStore.setState((state) => ({
|
|
23949
23949
|
...state,
|
|
23950
23950
|
presences: newDoc.getPresences()
|
|
23951
23951
|
}));
|
|
@@ -23953,7 +23953,7 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
|
|
|
23953
23953
|
);
|
|
23954
23954
|
unsubs.push(
|
|
23955
23955
|
newDoc.subscribe("connection", (event) => {
|
|
23956
|
-
|
|
23956
|
+
docStore.setState((state) => ({
|
|
23957
23957
|
...state,
|
|
23958
23958
|
connection: event.value
|
|
23959
23959
|
}));
|
|
@@ -23969,13 +23969,13 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
|
|
|
23969
23969
|
try {
|
|
23970
23970
|
newDoc.update(callback);
|
|
23971
23971
|
} catch (err) {
|
|
23972
|
-
|
|
23972
|
+
docStore.setState((state) => ({
|
|
23973
23973
|
...state,
|
|
23974
23974
|
error: err instanceof Error ? err : new Error("Failed to update document")
|
|
23975
23975
|
}));
|
|
23976
23976
|
}
|
|
23977
23977
|
};
|
|
23978
|
-
|
|
23978
|
+
docStore.setState((state) => ({
|
|
23979
23979
|
...state,
|
|
23980
23980
|
doc: newDoc,
|
|
23981
23981
|
root: newDoc.getRoot(),
|
|
@@ -23983,12 +23983,12 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
|
|
|
23983
23983
|
update
|
|
23984
23984
|
}));
|
|
23985
23985
|
} catch (err) {
|
|
23986
|
-
|
|
23986
|
+
docStore.setState((state) => ({
|
|
23987
23987
|
...state,
|
|
23988
23988
|
error: err instanceof Error ? err : new Error("Failed to attach document")
|
|
23989
23989
|
}));
|
|
23990
23990
|
} finally {
|
|
23991
|
-
|
|
23991
|
+
docStore.setState((state) => ({
|
|
23992
23992
|
...state,
|
|
23993
23993
|
loading: false
|
|
23994
23994
|
}));
|
|
@@ -24003,13 +24003,14 @@ function useYorkieDocument(client, clientLoading, clientError, docKey, initialRo
|
|
|
24003
24003
|
unsub();
|
|
24004
24004
|
}
|
|
24005
24005
|
};
|
|
24006
|
-
}, [client, clientLoading, clientError, docKey,
|
|
24006
|
+
}, [client, clientLoading, clientError, docKey, docStore, didMount]);
|
|
24007
24007
|
}
|
|
24008
24008
|
const DocumentContext = createContext(void 0);
|
|
24009
24009
|
const DocumentProvider = ({
|
|
24010
24010
|
docKey,
|
|
24011
24011
|
initialRoot = {},
|
|
24012
24012
|
initialPresence = {},
|
|
24013
|
+
enableDevtools = false,
|
|
24013
24014
|
children
|
|
24014
24015
|
}) => {
|
|
24015
24016
|
const { client, loading: clientLoading, error: clientError } = useYorkie();
|
|
@@ -24034,6 +24035,7 @@ const DocumentProvider = ({
|
|
|
24034
24035
|
docKey,
|
|
24035
24036
|
initialRoot,
|
|
24036
24037
|
initialPresence,
|
|
24038
|
+
enableDevtools,
|
|
24037
24039
|
documentStore
|
|
24038
24040
|
);
|
|
24039
24041
|
return /* @__PURE__ */ jsx(DocumentContext.Provider, { value: documentStore, children });
|
|
@@ -24108,6 +24110,7 @@ function useYorkieDoc(apiKey, docKey, opts) {
|
|
|
24108
24110
|
docKey,
|
|
24109
24111
|
(opts == null ? void 0 : opts.initialRoot) ?? {},
|
|
24110
24112
|
(opts == null ? void 0 : opts.initialPresence) ?? {},
|
|
24113
|
+
(opts == null ? void 0 : opts.enableDevtools) ?? false,
|
|
24111
24114
|
documentStore
|
|
24112
24115
|
);
|
|
24113
24116
|
const documentState = useSelector(documentStore);
|