@comapeo/core-react 7.2.0 → 9.0.0
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 +38 -0
- package/dist/commonjs/contexts/ClientApi.d.ts +8 -6
- package/dist/commonjs/contexts/ClientApi.js +15 -0
- package/dist/commonjs/contexts/ComapeoCore.d.ts +8 -0
- package/dist/commonjs/contexts/ComapeoCore.js +9 -0
- package/dist/commonjs/contexts/MapServer.d.ts +69 -0
- package/dist/commonjs/contexts/MapServer.js +92 -0
- package/dist/commonjs/contexts/MapShares.d.ts +52 -0
- package/dist/commonjs/contexts/MapShares.js +74 -0
- package/dist/commonjs/hooks/client.d.ts +3 -1
- package/dist/commonjs/hooks/documents.d.ts +3 -1
- package/dist/commonjs/hooks/invites.d.ts +0 -16
- package/dist/commonjs/hooks/invites.js +0 -32
- package/dist/commonjs/hooks/maps.d.ts +460 -3
- package/dist/commonjs/hooks/maps.js +261 -4
- package/dist/commonjs/hooks/projects.d.ts +17 -3
- package/dist/commonjs/index.d.ts +6 -3
- package/dist/commonjs/index.js +20 -6
- package/dist/commonjs/lib/http.d.ts +45 -0
- package/dist/commonjs/lib/http.js +103 -0
- package/dist/commonjs/lib/map-shares-stores.d.ts +80 -0
- package/dist/commonjs/lib/map-shares-stores.js +299 -0
- package/dist/commonjs/lib/presets.d.ts +3 -1
- package/dist/commonjs/lib/react-query/client.d.ts +6 -2
- package/dist/commonjs/lib/react-query/documents.d.ts +7 -3
- package/dist/commonjs/lib/react-query/invites.d.ts +6 -2
- package/dist/commonjs/lib/react-query/maps.d.ts +67 -19
- package/dist/commonjs/lib/react-query/maps.js +113 -11
- package/dist/commonjs/lib/react-query/mutation-result.d.ts +8 -0
- package/dist/commonjs/lib/react-query/mutation-result.js +22 -0
- package/dist/commonjs/lib/react-query/projects.d.ts +5 -1
- package/dist/commonjs/lib/react-query/projects.js +1 -6
- package/dist/commonjs/lib/sync.d.ts +3 -1
- package/dist/commonjs/lib/types.d.ts +3 -1
- package/dist/esm/contexts/ClientApi.d.ts +8 -6
- package/dist/esm/contexts/ClientApi.js +16 -1
- package/dist/esm/contexts/ComapeoCore.d.ts +8 -0
- package/dist/esm/contexts/ComapeoCore.js +6 -0
- package/dist/esm/contexts/MapServer.d.ts +69 -0
- package/dist/esm/contexts/MapServer.js +86 -0
- package/dist/esm/contexts/MapShares.d.ts +52 -0
- package/dist/esm/contexts/MapShares.js +65 -0
- package/dist/esm/hooks/client.d.ts +3 -1
- package/dist/esm/hooks/documents.d.ts +3 -1
- package/dist/esm/hooks/invites.d.ts +0 -16
- package/dist/esm/hooks/invites.js +1 -32
- package/dist/esm/hooks/maps.d.ts +460 -3
- package/dist/esm/hooks/maps.js +252 -6
- package/dist/esm/hooks/projects.d.ts +17 -3
- package/dist/esm/index.d.ts +6 -3
- package/dist/esm/index.js +5 -3
- package/dist/esm/lib/http.d.ts +45 -0
- package/dist/esm/lib/http.js +98 -0
- package/dist/esm/lib/map-shares-stores.d.ts +80 -0
- package/dist/esm/lib/map-shares-stores.js +291 -0
- package/dist/esm/lib/presets.d.ts +3 -1
- package/dist/esm/lib/react-query/client.d.ts +6 -2
- package/dist/esm/lib/react-query/documents.d.ts +7 -3
- package/dist/esm/lib/react-query/invites.d.ts +6 -2
- package/dist/esm/lib/react-query/maps.d.ts +67 -19
- package/dist/esm/lib/react-query/maps.js +109 -12
- package/dist/esm/lib/react-query/mutation-result.d.ts +8 -0
- package/dist/esm/lib/react-query/mutation-result.js +19 -0
- package/dist/esm/lib/react-query/projects.d.ts +5 -1
- package/dist/esm/lib/react-query/projects.js +1 -6
- package/dist/esm/lib/sync.d.ts +3 -1
- package/dist/esm/lib/types.d.ts +3 -1
- package/docs/API.md +567 -60
- package/package.json +40 -29
package/dist/esm/hooks/maps.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReceivedMapShareState, type SentMapShareState } from '../lib/map-shares-stores.js';
|
|
1
2
|
/**
|
|
2
3
|
* Get a URL that points to a StyleJSON resource served by the embedded HTTP server.
|
|
3
4
|
*
|
|
@@ -24,10 +25,466 @@
|
|
|
24
25
|
* }
|
|
25
26
|
* ```
|
|
26
27
|
*/
|
|
27
|
-
export declare function useMapStyleUrl(
|
|
28
|
-
refreshToken?: string;
|
|
29
|
-
}): {
|
|
28
|
+
export declare function useMapStyleUrl(): {
|
|
30
29
|
data: string;
|
|
31
30
|
error: Error | null;
|
|
32
31
|
isRefetching: boolean;
|
|
33
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Import a custom SMP map file, replacing any existing custom map. The mutation
|
|
35
|
+
* resolves once the file is successfully uploaded and processed by the server.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* function MapImportExample() {
|
|
40
|
+
* const { mutate: importMap } = useImportCustomMapFile()
|
|
41
|
+
*
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function useImportCustomMapFile(): Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverIdleResult<Response, Error, {
|
|
46
|
+
file: File | ({
|
|
47
|
+
readonly name: string;
|
|
48
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
49
|
+
readonly type: string;
|
|
50
|
+
text: () => Promise<string>;
|
|
51
|
+
readonly size: number;
|
|
52
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
53
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
54
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
55
|
+
} & {
|
|
56
|
+
exists: boolean;
|
|
57
|
+
});
|
|
58
|
+
}, unknown>, {
|
|
59
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Response, Error, {
|
|
60
|
+
file: File | ({
|
|
61
|
+
readonly name: string;
|
|
62
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
63
|
+
readonly type: string;
|
|
64
|
+
text: () => Promise<string>;
|
|
65
|
+
readonly size: number;
|
|
66
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
67
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
68
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
69
|
+
} & {
|
|
70
|
+
exists: boolean;
|
|
71
|
+
});
|
|
72
|
+
}, unknown>;
|
|
73
|
+
}> & {
|
|
74
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Response, Error, {
|
|
75
|
+
file: File | ({
|
|
76
|
+
readonly name: string;
|
|
77
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
78
|
+
readonly type: string;
|
|
79
|
+
text: () => Promise<string>;
|
|
80
|
+
readonly size: number;
|
|
81
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
82
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
83
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
84
|
+
} & {
|
|
85
|
+
exists: boolean;
|
|
86
|
+
});
|
|
87
|
+
}, unknown>;
|
|
88
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverLoadingResult<Response, Error, {
|
|
89
|
+
file: File | ({
|
|
90
|
+
readonly name: string;
|
|
91
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
92
|
+
readonly type: string;
|
|
93
|
+
text: () => Promise<string>;
|
|
94
|
+
readonly size: number;
|
|
95
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
96
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
97
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
98
|
+
} & {
|
|
99
|
+
exists: boolean;
|
|
100
|
+
});
|
|
101
|
+
}, unknown>, {
|
|
102
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Response, Error, {
|
|
103
|
+
file: File | ({
|
|
104
|
+
readonly name: string;
|
|
105
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
106
|
+
readonly type: string;
|
|
107
|
+
text: () => Promise<string>;
|
|
108
|
+
readonly size: number;
|
|
109
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
110
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
111
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
112
|
+
} & {
|
|
113
|
+
exists: boolean;
|
|
114
|
+
});
|
|
115
|
+
}, unknown>;
|
|
116
|
+
}> & {
|
|
117
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Response, Error, {
|
|
118
|
+
file: File | ({
|
|
119
|
+
readonly name: string;
|
|
120
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
121
|
+
readonly type: string;
|
|
122
|
+
text: () => Promise<string>;
|
|
123
|
+
readonly size: number;
|
|
124
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
125
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
126
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
127
|
+
} & {
|
|
128
|
+
exists: boolean;
|
|
129
|
+
});
|
|
130
|
+
}, unknown>;
|
|
131
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverErrorResult<Response, Error, {
|
|
132
|
+
file: File | ({
|
|
133
|
+
readonly name: string;
|
|
134
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
135
|
+
readonly type: string;
|
|
136
|
+
text: () => Promise<string>;
|
|
137
|
+
readonly size: number;
|
|
138
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
139
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
140
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
141
|
+
} & {
|
|
142
|
+
exists: boolean;
|
|
143
|
+
});
|
|
144
|
+
}, unknown>, {
|
|
145
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Response, Error, {
|
|
146
|
+
file: File | ({
|
|
147
|
+
readonly name: string;
|
|
148
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
149
|
+
readonly type: string;
|
|
150
|
+
text: () => Promise<string>;
|
|
151
|
+
readonly size: number;
|
|
152
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
153
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
154
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
155
|
+
} & {
|
|
156
|
+
exists: boolean;
|
|
157
|
+
});
|
|
158
|
+
}, unknown>;
|
|
159
|
+
}> & {
|
|
160
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Response, Error, {
|
|
161
|
+
file: File | ({
|
|
162
|
+
readonly name: string;
|
|
163
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
164
|
+
readonly type: string;
|
|
165
|
+
text: () => Promise<string>;
|
|
166
|
+
readonly size: number;
|
|
167
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
168
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
169
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
170
|
+
} & {
|
|
171
|
+
exists: boolean;
|
|
172
|
+
});
|
|
173
|
+
}, unknown>;
|
|
174
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverSuccessResult<Response, Error, {
|
|
175
|
+
file: File | ({
|
|
176
|
+
readonly name: string;
|
|
177
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
178
|
+
readonly type: string;
|
|
179
|
+
text: () => Promise<string>;
|
|
180
|
+
readonly size: number;
|
|
181
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
182
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
183
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
184
|
+
} & {
|
|
185
|
+
exists: boolean;
|
|
186
|
+
});
|
|
187
|
+
}, unknown>, {
|
|
188
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Response, Error, {
|
|
189
|
+
file: File | ({
|
|
190
|
+
readonly name: string;
|
|
191
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
192
|
+
readonly type: string;
|
|
193
|
+
text: () => Promise<string>;
|
|
194
|
+
readonly size: number;
|
|
195
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
196
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
197
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
198
|
+
} & {
|
|
199
|
+
exists: boolean;
|
|
200
|
+
});
|
|
201
|
+
}, unknown>;
|
|
202
|
+
}> & {
|
|
203
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Response, Error, {
|
|
204
|
+
file: File | ({
|
|
205
|
+
readonly name: string;
|
|
206
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
207
|
+
readonly type: string;
|
|
208
|
+
text: () => Promise<string>;
|
|
209
|
+
readonly size: number;
|
|
210
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
211
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
212
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
213
|
+
} & {
|
|
214
|
+
exists: boolean;
|
|
215
|
+
});
|
|
216
|
+
}, unknown>;
|
|
217
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync">;
|
|
218
|
+
export declare function useRemoveCustomMapFile(): Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverIdleResult<Response, Error, void, unknown>, {
|
|
219
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Response, Error, void, unknown>;
|
|
220
|
+
}> & {
|
|
221
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Response, Error, void, unknown>;
|
|
222
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverLoadingResult<Response, Error, void, unknown>, {
|
|
223
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Response, Error, void, unknown>;
|
|
224
|
+
}> & {
|
|
225
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Response, Error, void, unknown>;
|
|
226
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverErrorResult<Response, Error, void, unknown>, {
|
|
227
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Response, Error, void, unknown>;
|
|
228
|
+
}> & {
|
|
229
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Response, Error, void, unknown>;
|
|
230
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverSuccessResult<Response, Error, void, unknown>, {
|
|
231
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Response, Error, void, unknown>;
|
|
232
|
+
}> & {
|
|
233
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Response, Error, void, unknown>;
|
|
234
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync">;
|
|
235
|
+
export declare function useGetCustomMapInfo(): {
|
|
236
|
+
data: unknown;
|
|
237
|
+
error: Error | null;
|
|
238
|
+
isRefetching: boolean;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Get all map shares that the device has received. Automatically updates when
|
|
242
|
+
* new shares arrive or share states change.
|
|
243
|
+
*
|
|
244
|
+
* IMPORTANT: This hook will not trigger a re-render when download progress
|
|
245
|
+
* updates, only when the status changes. This is to avoid excessive re-renders
|
|
246
|
+
* during downloads. Use `useSingleReceivedMapShare` to get real-time updates on
|
|
247
|
+
* a specific share, including download progress.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```tsx
|
|
251
|
+
* function MapSharesList() {
|
|
252
|
+
* const shares = useManyReceivedMapShares()
|
|
253
|
+
*
|
|
254
|
+
* return shares.map(share => (
|
|
255
|
+
* <div key={share.shareId}>
|
|
256
|
+
* {share.mapName} from {share.senderDeviceName} - {share.state}
|
|
257
|
+
* </div>
|
|
258
|
+
* ))
|
|
259
|
+
* }
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
export declare function useManyReceivedMapShares(): ReceivedMapShareState[];
|
|
263
|
+
/**
|
|
264
|
+
* Get a single received map share based on its shareId.
|
|
265
|
+
*
|
|
266
|
+
* @param opts.shareId ID of the map share
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```tsx
|
|
270
|
+
* function MapShareDetail({ shareId }: { shareId: string }) {
|
|
271
|
+
* const share = useSingleReceivedMapShare({ shareId })
|
|
272
|
+
*
|
|
273
|
+
* return <div>{share.mapName} - {share.state}</div>
|
|
274
|
+
* }
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
export declare function useSingleReceivedMapShare({ shareId }: {
|
|
278
|
+
shareId: string;
|
|
279
|
+
}): ReceivedMapShareState;
|
|
280
|
+
/**
|
|
281
|
+
* Accept and download a map share that has been received. The mutate promise
|
|
282
|
+
* resolves once the map _starts_ downloading, before it finishes downloading.
|
|
283
|
+
* Use `useManyMapShares` or `useSingleMapShare` to track download progress.
|
|
284
|
+
*
|
|
285
|
+
* Throws if the share is not in `status="pending"` or if the download fails to
|
|
286
|
+
* start (e.g. if the shareId if invalid).
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```tsx
|
|
290
|
+
* function AcceptButton({ shareId }: { shareId: string }) {
|
|
291
|
+
* const { mutate: accept } = useAcceptMapShare()
|
|
292
|
+
*
|
|
293
|
+
* return <button onClick={() => accept({ shareId })}>Accept</button>
|
|
294
|
+
* }
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
export declare function useDownloadReceivedMapShare(): Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverIdleResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>, {
|
|
298
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>;
|
|
299
|
+
}> & {
|
|
300
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>;
|
|
301
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverLoadingResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>, {
|
|
302
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>;
|
|
303
|
+
}> & {
|
|
304
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>;
|
|
305
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverErrorResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>, {
|
|
306
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>;
|
|
307
|
+
}> & {
|
|
308
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>;
|
|
309
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverSuccessResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>, {
|
|
310
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>;
|
|
311
|
+
}> & {
|
|
312
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DownloadMapShareOptions, "projectId">, unknown>;
|
|
313
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync">;
|
|
314
|
+
/**
|
|
315
|
+
* Decline a map share that has been received. Notifies the sender that the
|
|
316
|
+
* share was declined.
|
|
317
|
+
*
|
|
318
|
+
* Throws if the share is not with `status="pending"`
|
|
319
|
+
* Throws if shareId is invalid
|
|
320
|
+
* Throws if decline request fails (e.g. network error)
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```tsx
|
|
324
|
+
* import { DeclineReason } from '@comapeo/core-react'
|
|
325
|
+
* function DeclineButton({ shareId }: { shareId: string }) {
|
|
326
|
+
* const { mutate: decline } = useDeclineMapShare()
|
|
327
|
+
*
|
|
328
|
+
* return (
|
|
329
|
+
* <button onClick={() => decline({ shareId, reason: DeclineReason.user_rejected })}>
|
|
330
|
+
* Decline
|
|
331
|
+
* </button>
|
|
332
|
+
* )
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
export declare function useDeclineReceivedMapShare(): Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverIdleResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>, {
|
|
337
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>;
|
|
338
|
+
}> & {
|
|
339
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>;
|
|
340
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverLoadingResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>, {
|
|
341
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>;
|
|
342
|
+
}> & {
|
|
343
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>;
|
|
344
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverErrorResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>, {
|
|
345
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>;
|
|
346
|
+
}> & {
|
|
347
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>;
|
|
348
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverSuccessResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>, {
|
|
349
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>;
|
|
350
|
+
}> & {
|
|
351
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").DeclineMapShareOptions, "projectId">, unknown>;
|
|
352
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync">;
|
|
353
|
+
/**
|
|
354
|
+
* Abort an in-progress map share download.
|
|
355
|
+
*
|
|
356
|
+
* Throws if the share is not in `status="downloading"`
|
|
357
|
+
* Throws if shareId is invalid
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```tsx
|
|
361
|
+
* function AbortButton({ shareId }: { shareId: string }) {
|
|
362
|
+
* const { mutate: abort } = useAbortMapShareDownload()
|
|
363
|
+
*
|
|
364
|
+
* return <button onClick={() => abort({ shareId })}>Cancel Download</button>
|
|
365
|
+
* }
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
export declare function useAbortReceivedMapShareDownload(): Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverIdleResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>, {
|
|
369
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>;
|
|
370
|
+
}> & {
|
|
371
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>;
|
|
372
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverLoadingResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>, {
|
|
373
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>;
|
|
374
|
+
}> & {
|
|
375
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>;
|
|
376
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverErrorResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>, {
|
|
377
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>;
|
|
378
|
+
}> & {
|
|
379
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>;
|
|
380
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverSuccessResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>, {
|
|
381
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>;
|
|
382
|
+
}> & {
|
|
383
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").AbortMapShareOptions, "projectId">, unknown>;
|
|
384
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync">;
|
|
385
|
+
/**
|
|
386
|
+
* Share a map with a device. The mutation resolves immediately after sending
|
|
387
|
+
* the share offer, without waiting for the recipient to accept or reject. The
|
|
388
|
+
* mutation resolves with the created map share object, including its ID, which
|
|
389
|
+
* can be used to track the share status with `useSingleSentMapShare`.
|
|
390
|
+
*
|
|
391
|
+
* @param opts.projectId Public ID of project for sending the map share: you can only send map shares to users on the same project
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```tsx
|
|
395
|
+
* function SendMapButton({ projectId, deviceId }: { projectId: string; deviceId: string }) {
|
|
396
|
+
* const { mutate: send } = useSendMapShare({ projectId }, {
|
|
397
|
+
* onSuccess: (mapShare) => {
|
|
398
|
+
* console.log('Share sent with id', mapShare.shareId)
|
|
399
|
+
* }
|
|
400
|
+
* })
|
|
401
|
+
*
|
|
402
|
+
* return (
|
|
403
|
+
* <button onClick={() => send({ receiverDeviceId: deviceId, mapId: 'custom' })}>
|
|
404
|
+
* Send Map
|
|
405
|
+
* </button>
|
|
406
|
+
* )
|
|
407
|
+
* }
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
export declare function useSendMapShare({ projectId }: {
|
|
411
|
+
projectId: string;
|
|
412
|
+
}): Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverIdleResult<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>, {
|
|
413
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>;
|
|
414
|
+
}> & {
|
|
415
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>;
|
|
416
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverLoadingResult<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>, {
|
|
417
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>;
|
|
418
|
+
}> & {
|
|
419
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>;
|
|
420
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverErrorResult<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>, {
|
|
421
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>;
|
|
422
|
+
}> & {
|
|
423
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>;
|
|
424
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverSuccessResult<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>, {
|
|
425
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>;
|
|
426
|
+
}> & {
|
|
427
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<import("@comapeo/map-server").MapShareState>, Error, import("../lib/map-shares-stores.js").CreateAndSendMapShareOptions, unknown>;
|
|
428
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync">;
|
|
429
|
+
/**
|
|
430
|
+
* Cancel a map share that was previously sent. If the recipient has not yet
|
|
431
|
+
* started downloading the share, they will not be notified until they attempt
|
|
432
|
+
* to accept the share and begin downloading it. If they are already downloading
|
|
433
|
+
* the share, the download will be canceled before completion. If the download
|
|
434
|
+
* is already complete, this action will throw an error.
|
|
435
|
+
*
|
|
436
|
+
* @param opts.projectId Public ID of project to request the map share cancellation for.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* ```tsx
|
|
440
|
+
* function CancelShareButton({ projectId, shareId }: { projectId: string; shareId: string }) {
|
|
441
|
+
* const { mutate: cancel } = useRequestCancelMapShare({ projectId })
|
|
442
|
+
*
|
|
443
|
+
* return <button onClick={() => cancel({ shareId })}>Cancel Share</button>
|
|
444
|
+
* }
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
export declare function useCancelSentMapShare(): Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverIdleResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>, {
|
|
448
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>;
|
|
449
|
+
}> & {
|
|
450
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>;
|
|
451
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverLoadingResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>, {
|
|
452
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>;
|
|
453
|
+
}> & {
|
|
454
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>;
|
|
455
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverErrorResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>, {
|
|
456
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>;
|
|
457
|
+
}> & {
|
|
458
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>;
|
|
459
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync"> | Pick<import("@tanstack/react-query").Override<import("@tanstack/react-query").MutationObserverSuccessResult<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>, {
|
|
460
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>;
|
|
461
|
+
}> & {
|
|
462
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Promise<void>, Error, Omit<import("../lib/map-shares-stores.js").CancelMapShareOptions, "projectId">, unknown>;
|
|
463
|
+
}, "error" | "status" | "mutate" | "reset" | "mutateAsync">;
|
|
464
|
+
/**
|
|
465
|
+
* Track the status and progress of a sent map share. Returns the current state
|
|
466
|
+
* of the share, updated in real-time. When the recipient starts downloading, or
|
|
467
|
+
* if they decline the share, then the returned share will update.
|
|
468
|
+
*
|
|
469
|
+
* Throws if no share with the specified ID is found.
|
|
470
|
+
*
|
|
471
|
+
* @param opts.shareId ID of the sent map share
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```tsx
|
|
475
|
+
* function SentShareStatus({ shareId }: { shareId: string }) {
|
|
476
|
+
* const mapShare = useSingleSentMapShare({ shareId })
|
|
477
|
+
*
|
|
478
|
+
* return (<div>
|
|
479
|
+
* <div>Share status: {mapShare.status}</div>
|
|
480
|
+
* {mapShare.status === 'pending' && <div>Waiting for recipient to accept...</div>}
|
|
481
|
+
* {mapShare.status === 'downloading' && (<div>Download in progress: {mapShare.downloadProgress}%</div>)}
|
|
482
|
+
* {mapShare.status === 'declined' && <div>Share was declined by recipient</div>}
|
|
483
|
+
* {mapShare.status === 'canceled' && <div>Share was canceled</div>}
|
|
484
|
+
* </div>)
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
export declare function useSingleSentMapShare({ shareId, }: {
|
|
489
|
+
shareId: string;
|
|
490
|
+
}): SentMapShareState;
|